Cleanup formatting
Wew, that's a lot of stuff. But I thought it makes sense after the
sysrepo migration.
Change-Id: If363d2ce1b11106113a9f0c37a3bcd59a940bd0b
diff --git a/src/ast_handlers.cpp b/src/ast_handlers.cpp
index b77964b..6fde52c 100644
--- a/src/ast_handlers.cpp
+++ b/src/ast_handlers.cpp
@@ -26,5 +26,5 @@
boost::optional<std::string> optModuleToOptString(const boost::optional<module_> module)
{
- return module.flat_map([] (const auto& module) { return boost::optional<std::string>(module.m_name); });
+ return module.flat_map([](const auto& module) { return boost::optional<std::string>(module.m_name); });
}
diff --git a/src/ast_handlers.hpp b/src/ast_handlers.hpp
index c4658e4..686af85 100644
--- a/src/ast_handlers.hpp
+++ b/src/ast_handlers.hpp
@@ -57,7 +57,7 @@
if (schema.listHasKey(dataPathToSchemaPath(parserContext.m_tmpListPath), ast)) {
parserContext.m_tmpListKeyLeafPath.m_location = dataPathToSchemaPath(parserContext.m_tmpListPath);
- parserContext.m_tmpListKeyLeafPath.m_node = { optModuleToOptString(parserContext.m_tmpListPath.m_nodes.back().m_prefix), ast };
+ parserContext.m_tmpListKeyLeafPath.m_node = {optModuleToOptString(parserContext.m_tmpListPath.m_nodes.back().m_prefix), ast};
} else {
auto listName = std::get<list_>(parserContext.m_tmpListPath.m_nodes.back().m_suffix).m_name;
parserContext.m_errorMsg = listName + " is not indexed by \"" + ast + "\".";
@@ -333,12 +333,12 @@
decltype(listInstances) filteredInstances;
//This filters out instances, which don't correspond to the partial instance we have.
- const auto partialFitsComplete = [&parserContext] (const auto& complete) {
+ const auto partialFitsComplete = [&parserContext](const auto& complete) {
const auto& partial = parserContext.m_tmpListKeys;
- return std::all_of(partial.begin(), partial.end(), [&complete] (const auto& oneKV) {
- const auto& [k, v] = oneKV;
- return complete.at(k) == v;
- });
+ return std::all_of(partial.begin(), partial.end(), [&complete](const auto& oneKV) {
+ const auto& [k, v] = oneKV;
+ return complete.at(k) == v;
+ });
};
std::copy_if(listInstances.begin(), listInstances.end(), std::inserter(filteredInstances, filteredInstances.end()), partialFitsComplete);
@@ -370,7 +370,7 @@
};
template <typename T>
-std::string commandNamesVisitor (boost::type<T>)
+std::string commandNamesVisitor(boost::type<T>)
{
return T::name;
}
diff --git a/src/ast_path.cpp b/src/ast_path.cpp
index b9f7ae4..7ab9b18 100644
--- a/src/ast_path.cpp
+++ b/src/ast_path.cpp
@@ -63,7 +63,6 @@
: m_prefix(module)
, m_suffix(node)
{
-
}
schemaNode_::schemaNode_(decltype(m_suffix) node)
diff --git a/src/cli.cpp b/src/cli.cpp
index f89c8d6..4f4328a 100644
--- a/src/cli.cpp
+++ b/src/cli.cpp
@@ -60,8 +60,8 @@
-v enable verbose mode
-p <port> port number [default: 830]
)";
-#include "netconf_access.hpp"
#include "cli-netconf.hpp"
+#include "netconf_access.hpp"
#define PROGRAM_NAME "netconf-access"
#else
#error "Unknown CLI backend"
@@ -86,7 +86,7 @@
} else if (ds.asString() == "running") {
datastoreType = Datastore::Running;
} else {
- std::cerr << PROGRAM_NAME << ": unknown datastore: " << ds.asString() << "\n";
+ std::cerr << PROGRAM_NAME << ": unknown datastore: " << ds.asString() << "\n";
return 1;
}
}
@@ -129,7 +129,6 @@
std::cerr << ex.what() << "\n";
return 1;
}
-
}
}
if (const auto& dataFiles = args["-i"]) {
@@ -175,10 +174,10 @@
Replxx lineEditor;
- lineEditor.bind_key(Replxx::KEY::meta(Replxx::KEY::BACKSPACE), [&lineEditor] (const auto& code) {
+ lineEditor.bind_key(Replxx::KEY::meta(Replxx::KEY::BACKSPACE), [&lineEditor](const auto& code) {
return lineEditor.invoke(Replxx::ACTION::KILL_TO_BEGINING_OF_WORD, code);
});
- lineEditor.bind_key(Replxx::KEY::control('W'), [&lineEditor] (const auto& code) {
+ lineEditor.bind_key(Replxx::KEY::control('W'), [&lineEditor](const auto& code) {
return lineEditor.invoke(Replxx::ACTION::KILL_TO_WHITESPACE_ON_LEFT, code);
});
diff --git a/src/datastore_access.hpp b/src/datastore_access.hpp
index da9c33f..057c96a 100644
--- a/src/datastore_access.hpp
+++ b/src/datastore_access.hpp
@@ -12,9 +12,9 @@
#include <memory>
#include <optional>
#include <string>
-#include "yang_operations.hpp"
#include "ast_values.hpp"
#include "list_instance.hpp"
+#include "yang_operations.hpp"
/*! \class DatastoreAccess
* \brief Abstract class for accessing a datastore
diff --git a/src/grammars.hpp b/src/grammars.hpp
index 161a515..7e5b49d 100644
--- a/src/grammars.hpp
+++ b/src/grammars.hpp
@@ -112,7 +112,7 @@
{
auto& parserContext = x3::get<parser_context_tag>(ctx);
auto iterBeforeDestination = begin;
- auto save_iter = x3::no_skip[x3::eps[([&iterBeforeDestination](auto& ctx) {iterBeforeDestination = _where(ctx).begin();})]];
+ auto save_iter = x3::no_skip[x3::eps[([&iterBeforeDestination](auto& ctx) { iterBeforeDestination = _where(ctx).begin(); })]];
auto grammar = datastoreSuggestions > copy_source > space_separator > datastoreSuggestions > save_iter > copy_destination;
try {
diff --git a/src/interpreter.cpp b/src/interpreter.cpp
index a39167e..97836bf 100644
--- a/src/interpreter.cpp
+++ b/src/interpreter.cpp
@@ -115,7 +115,7 @@
auto toPrint = m_datastore.schema()->availableNodes(toCanonicalPath(ls.m_path), recursion);
for (const auto& it : toPrint) {
- std::cout << (it.first ? *it.first + ":" : "" ) + it.second << std::endl;
+ std::cout << (it.first ? *it.first + ":" : "") + it.second << std::endl;
}
}
@@ -134,8 +134,7 @@
case yang::NodeTypes::PresenceContainer:
ss << "presence container";
break;
- case yang::NodeTypes::Leaf:
- {
+ case yang::NodeTypes::Leaf: {
auto leafType = m_datastore.schema()->leafType(path);
auto typedefName = m_datastore.schema()->leafTypeName(path);
std::string baseTypeStr;
diff --git a/src/interpreter.hpp b/src/interpreter.hpp
index 54a8d05..c59e3d2 100644
--- a/src/interpreter.hpp
+++ b/src/interpreter.hpp
@@ -9,8 +9,8 @@
#pragma once
#include <boost/variant/static_visitor.hpp>
-#include "proxy_datastore.hpp"
#include "parser.hpp"
+#include "proxy_datastore.hpp"
struct Interpreter : boost::static_visitor<void> {
diff --git a/src/leaf_data.hpp b/src/leaf_data.hpp
index 964c154..7bab723 100644
--- a/src/leaf_data.hpp
+++ b/src/leaf_data.hpp
@@ -140,7 +140,7 @@
bool operator()(const yang::IdentityRef& type) const
{
createSetSuggestions(type);
- auto checkValidIdentity = [this, type] (auto& ctx) {
+ auto checkValidIdentity = [this, type](auto& ctx) {
identityRef_ pair{boost::get<identityRef_>(_attr(ctx))};
if (!pair.m_prefix) {
pair.m_prefix = module_{parserContext.currentSchemaPath().m_nodes.front().m_prefix.get().m_name};
diff --git a/src/libyang_utils.cpp b/src/libyang_utils.cpp
index f1af868..1f0c372 100644
--- a/src/libyang_utils.cpp
+++ b/src/libyang_utils.cpp
@@ -6,7 +6,7 @@
leaf_data_ leafValueFromNode(libyang::S_Data_Node_Leaf_List node)
{
- std::function<leaf_data_(libyang::S_Data_Node_Leaf_List)> impl = [&impl] (libyang::S_Data_Node_Leaf_List node) -> leaf_data_ {
+ std::function<leaf_data_(libyang::S_Data_Node_Leaf_List)> impl = [&impl](libyang::S_Data_Node_Leaf_List node) -> leaf_data_ {
// value_type() is what's ACTUALLY stored inside `node`
// Leafrefs sometimes don't hold a reference to another, but they have the actual pointed-to value.
switch (node->value_type()) {
@@ -28,8 +28,7 @@
return node->value()->int32();
case LY_TYPE_INT64:
return node->value()->int64();
- case LY_TYPE_DEC64:
- {
+ case LY_TYPE_DEC64: {
auto v = node->value()->dec64();
return v.value * std::pow(10, -v.digits);
}
@@ -43,24 +42,22 @@
return identityRef_{node->value()->ident()->module()->name(), node->value()->ident()->name()};
case LY_TYPE_EMPTY:
return empty_{};
- case LY_TYPE_LEAFREF:
- {
+ case LY_TYPE_LEAFREF: {
auto refsTo = node->value()->leafref();
assert(refsTo);
return impl(std::make_shared<libyang::Data_Node_Leaf_List>(node->value()->leafref()));
}
- case LY_TYPE_BITS:
- {
+ case LY_TYPE_BITS: {
auto bits = node->value()->bit();
std::vector<libyang::S_Type_Bit> filterNull;
- std::copy_if(bits.begin(), bits.end(), std::back_inserter(filterNull), [] (auto bit) { return bit; });
+ std::copy_if(bits.begin(), bits.end(), std::back_inserter(filterNull), [](auto bit) { return bit; });
bits_ res;
- std::transform(filterNull.begin(), filterNull.end(), std::inserter(res.m_bits, res.m_bits.end()), [] (const auto& bit) { return bit->name(); });
+ std::transform(filterNull.begin(), filterNull.end(), std::inserter(res.m_bits, res.m_bits.end()), [](const auto& bit) { return bit->name(); });
return bits_{res};
}
default:
return std::string{"(can't print)"};
- }
+ }
};
return impl(node);
}
@@ -68,7 +65,7 @@
namespace {
void impl_lyNodesToTree(DatastoreAccess::Tree& res, const std::vector<std::shared_ptr<libyang::Data_Node>> items, std::optional<std::string> ignoredXPathPrefix)
{
- auto stripXPathPrefix = [&ignoredXPathPrefix] (auto path) {
+ auto stripXPathPrefix = [&ignoredXPathPrefix](auto path) {
return ignoredXPathPrefix && path.find(*ignoredXPathPrefix) != std::string::npos ? path.substr(ignoredXPathPrefix->size()) : path;
};
diff --git a/src/netconf-client.cpp b/src/netconf-client.cpp
index 42e9edc..fde9561 100644
--- a/src/netconf-client.cpp
+++ b/src/netconf-client.cpp
@@ -13,8 +13,8 @@
#include <nc_client.h>
}
#include <sstream>
-#include "netconf-client.hpp"
#include "UniqueResource.hpp"
+#include "netconf-client.hpp"
namespace libnetconf {
@@ -67,7 +67,7 @@
nc_reply_free(reinterpret_cast<nc_reply*>(reply));
}
-char *ssh_auth_interactive_cb(const char *auth_name, const char *instruction, const char *prompt, int echo, void *priv)
+char* ssh_auth_interactive_cb(const char* auth_name, const char* instruction, const char* prompt, int echo, void* priv)
{
const auto cb = static_cast<const client::KbdInteractiveCb*>(priv);
auto res = (*cb)(auth_name, instruction, prompt, echo);
@@ -162,7 +162,6 @@
default:
throw std::runtime_error{"Unhandled reply type"};
}
-
}
unique_ptr_for<struct nc_reply_data> do_rpc_data(client::Session* session, unique_ptr_for<struct nc_rpc>&& rpc)
diff --git a/src/netconf_access.cpp b/src/netconf_access.cpp
index 2c64cd4..1e56659 100644
--- a/src/netconf_access.cpp
+++ b/src/netconf_access.cpp
@@ -233,7 +233,7 @@
// I take the first child here, because the first element (the parent of the child()) will be the list
for (const auto& keyLeaf : instance->child()->tree_for()) {
auto leafData = std::make_shared<libyang::Data_Node_Leaf_List>(keyLeaf);
- instanceRes.insert({ leafData->schema()->name(), leafValueFromNode(leafData)});
+ instanceRes.insert({leafData->schema()->name(), leafValueFromNode(leafData)});
}
res.emplace_back(instanceRes);
}
diff --git a/src/path_parser.hpp b/src/path_parser.hpp
index 3abbce3..d03f670 100644
--- a/src/path_parser.hpp
+++ b/src/path_parser.hpp
@@ -266,7 +266,7 @@
using attribute_type = ModeToAttribute<PARSER_MODE>;
std::function<bool(const Schema&, const std::string& path)> m_filterFunction;
- PathParser(const std::function<bool(const Schema&, const std::string& path)>& filterFunction = [] (const auto&, const auto&) {return true;})
+ PathParser(const std::function<bool(const Schema&, const std::string& path)>& filterFunction = [](const auto&, const auto&) { return true; })
: m_filterFunction(filterFunction)
{
}
@@ -393,7 +393,7 @@
auto const trailingSlash_def =
x3::omit['/'] >> x3::attr(TrailingSlash::Present);
-auto const filterConfigFalse = [] (const Schema& schema, const std::string& path) {
+auto const filterConfigFalse = [](const Schema& schema, const std::string& path) {
return schema.isConfig(path);
};
@@ -441,7 +441,7 @@
}
if (attr.m_nodes.empty()
- || (!std::holds_alternative<rpcNode_>(attr.m_nodes.back().m_suffix) && !std::holds_alternative<actionNode_>(attr.m_nodes.back().m_suffix))) {
+ || (!std::holds_alternative<rpcNode_>(attr.m_nodes.back().m_suffix) && !std::holds_alternative<actionNode_>(attr.m_nodes.back().m_suffix))) {
auto& parserContext = x3::get<parser_context_tag>(ctx);
parserContext.m_errorMsg = "This is not a path to an RPC/action.";
return false;
@@ -453,7 +453,7 @@
auto const rpcActionPath = as<dataPath_>[RpcActionPath()];
-auto const noRpcOrAction = [] (const Schema& schema, const std::string& path) {
+auto const noRpcOrAction = [](const Schema& schema, const std::string& path) {
auto nodeType = schema.nodeType(path);
return nodeType != yang::NodeTypes::Rpc && nodeType != yang::NodeTypes::Action;
};
diff --git a/src/proxy_datastore.cpp b/src/proxy_datastore.cpp
index 393edef..113a923 100644
--- a/src/proxy_datastore.cpp
+++ b/src/proxy_datastore.cpp
@@ -60,9 +60,8 @@
}
namespace {
-struct getInputPath
-{
- template<typename InputType>
+struct getInputPath {
+ template <typename InputType>
auto operator()(const InputType& input)
{
return input.m_path;
diff --git a/src/proxy_datastore.hpp b/src/proxy_datastore.hpp
index ab69193..e7650cd 100644
--- a/src/proxy_datastore.hpp
+++ b/src/proxy_datastore.hpp
@@ -35,6 +35,7 @@
void cancel();
[[nodiscard]] std::shared_ptr<Schema> schema() const;
+
private:
/** @brief Picks a datastore based on the requested path.
*
diff --git a/src/python_netconf.cpp b/src/python_netconf.cpp
index 19c096f..7a0e4d3 100644
--- a/src/python_netconf.cpp
+++ b/src/python_netconf.cpp
@@ -8,8 +8,8 @@
#include <pybind11/functional.h>
#include <pybind11/pybind11.h>
#include <pybind11/stl.h>
-#include "netconf_access.hpp"
#include "netconf-client.hpp"
+#include "netconf_access.hpp"
using namespace std::literals;
using namespace pybind11::literals;
diff --git a/src/static_schema.cpp b/src/static_schema.cpp
index af1004a..a75f471 100644
--- a/src/static_schema.cpp
+++ b/src/static_schema.cpp
@@ -167,9 +167,9 @@
return res;
}
- auto getTopLevelModule = [] (const auto& path) -> boost::optional<std::string> {
+ auto getTopLevelModule = [](const auto& path) -> boost::optional<std::string> {
if (!path.m_nodes.empty()) {
- return path.m_nodes.begin()->m_prefix.flat_map([] (const auto& module) {return boost::optional<std::string>(module.m_name);});
+ return path.m_nodes.begin()->m_prefix.flat_map([](const auto& module) { return boost::optional<std::string>(module.m_name); });
}
return boost::none;
@@ -213,7 +213,6 @@
yang::NodeTypes operator()(const yang::leaf&)
{
return yang::NodeTypes::Leaf;
-
}
yang::NodeTypes operator()(const yang::leaflist&)
{
diff --git a/src/sysrepo_access.cpp b/src/sysrepo_access.cpp
index f6e8d1d..7c21cad 100644
--- a/src/sysrepo_access.cpp
+++ b/src/sysrepo_access.cpp
@@ -9,8 +9,8 @@
#include <experimental/iterator>
#include <libyang/Tree_Data.hpp>
#include <libyang/Tree_Schema.hpp>
-#include <sysrepo-cpp/Session.hpp>
#include <sstream>
+#include <sysrepo-cpp/Session.hpp>
#include "libyang_utils.hpp"
#include "sysrepo_access.hpp"
#include "utils.hpp"
@@ -44,8 +44,7 @@
return std::string(value->data()->get_string());
case SR_ENUM_T:
return enum_{std::string(value->data()->get_enum())};
- case SR_IDENTITYREF_T:
- {
+ case SR_IDENTITYREF_T: {
auto pair = splitModuleNode(value->data()->get_identityref());
return identityRef_{*pair.first, pair.second};
}
@@ -61,8 +60,7 @@
return special_{SpecialValue::PresenceContainer};
case SR_LIST_T:
return special_{SpecialValue::List};
- case SR_BITS_T:
- {
+ case SR_BITS_T: {
bits_ res;
std::istringstream ss(value->data()->get_bits());
while (!ss.eof()) {
@@ -71,7 +69,6 @@
res.m_bits.push_back(bit);
}
return res;
-
}
default: // TODO: implement all types
return value->val_to_string();
@@ -333,7 +330,7 @@
}
// TODO: merge this with executeAction
-DatastoreAccess::Tree SysrepoAccess::executeRpc(const std::string &path, const Tree &input)
+DatastoreAccess::Tree SysrepoAccess::executeRpc(const std::string& path, const Tree& input)
{
auto srInput = toSrVals(path, input);
auto output = m_session->rpc_send(path.c_str(), srInput);
@@ -384,7 +381,7 @@
decltype(lists) instances;
auto wantedTree = *(m_schema->dataNodeFromPath(path)->find_path(path.c_str())->data().begin());
- std::copy_if(lists.begin(), lists.end(), std::inserter(instances, instances.end()), [this, pathToCheck=wantedTree->schema()->path()](const auto& item) {
+ std::copy_if(lists.begin(), lists.end(), std::inserter(instances, instances.end()), [this, pathToCheck = wantedTree->schema()->path()](const auto& item) {
// This filters out non-instances.
if (item.second.type() != typeid(special_) || boost::get<special_>(item.second).m_value != SpecialValue::List) {
return false;
diff --git a/src/sysrepo_access.hpp b/src/sysrepo_access.hpp
index e43b733..d0ad869 100644
--- a/src/sysrepo_access.hpp
+++ b/src/sysrepo_access.hpp
@@ -43,6 +43,7 @@
void copyConfig(const Datastore source, const Datastore destination) override;
[[nodiscard]] std::string dump(const DataFormat format) const override;
+
private:
std::vector<ListInstance> listInstances(const std::string& path) override;
[[noreturn]] void reportErrors() const;
diff --git a/src/yang_access.hpp b/src/yang_access.hpp
index ab948cf..62c43d6 100644
--- a/src/yang_access.hpp
+++ b/src/yang_access.hpp
@@ -53,8 +53,8 @@
void impl_removeNode(const std::string& path);
void validate();
- std::unique_ptr<ly_ctx, void(*)(ly_ctx*)> m_ctx;
- std::unique_ptr<lyd_node, void(*)(lyd_node*)> m_datastore;
+ std::unique_ptr<ly_ctx, void (*)(ly_ctx*)> m_ctx;
+ std::unique_ptr<lyd_node, void (*)(lyd_node*)> m_datastore;
std::shared_ptr<YangSchema> m_schema;
const int m_validation_mode;
};
diff --git a/src/yang_schema.cpp b/src/yang_schema.cpp
index 8793dd4..7f27711 100644
--- a/src/yang_schema.cpp
+++ b/src/yang_schema.cpp
@@ -198,7 +198,7 @@
auto leaf = std::make_shared<NodeType>(node);
auto leafUnits = leaf->units();
std::function<yang::TypeInfo(std::shared_ptr<libyang::Type>)> resolveType;
- resolveType = [this, &resolveType, leaf, leafUnits] (std::shared_ptr<libyang::Type> type) -> yang::TypeInfo {
+ resolveType = [this, &resolveType, leaf, leafUnits](std::shared_ptr<libyang::Type> type) -> yang::TypeInfo {
yang::LeafDataType resType;
switch (type->base()) {
case LY_TYPE_STRING:
@@ -249,24 +249,22 @@
case LY_TYPE_LEAFREF:
resType.emplace<yang::LeafRef>(::leafrefPath(type), std::make_unique<yang::TypeInfo>(leafType(::leafrefPath(type))));
break;
- case LY_TYPE_BITS:
- {
- auto resBits = yang::Bits{};
- for (const auto& bit : type->info()->bits()->bit()) {
- resBits.m_allowedValues.emplace(bit->name());
- }
- resType.emplace<yang::Bits>(std::move(resBits));
- break;
+ case LY_TYPE_BITS: {
+ auto resBits = yang::Bits{};
+ for (const auto& bit : type->info()->bits()->bit()) {
+ resBits.m_allowedValues.emplace(bit->name());
}
- case LY_TYPE_UNION:
- {
- auto resUnion = yang::Union{};
- for (auto unionType : type->info()->uni()->types()) {
- resUnion.m_unionTypes.emplace_back(resolveType(unionType));
- }
- resType.emplace<yang::Union>(std::move(resUnion));
- break;
+ resType.emplace<yang::Bits>(std::move(resBits));
+ break;
+ }
+ case LY_TYPE_UNION: {
+ auto resUnion = yang::Union{};
+ for (auto unionType : type->info()->uni()->types()) {
+ resUnion.m_unionTypes.emplace_back(resolveType(unionType));
}
+ resType.emplace<yang::Union>(std::move(resUnion));
+ break;
+ }
default:
using namespace std::string_literals;
throw UnsupportedYangTypeException("the type of "s + leaf->name() + " is not supported: " + std::to_string(leaf->type()->base()));
diff --git a/src/yang_schema.hpp b/src/yang_schema.hpp
index 3d1dc81..632f538 100644
--- a/src/yang_schema.hpp
+++ b/src/yang_schema.hpp
@@ -70,6 +70,7 @@
std::shared_ptr<libyang::Module> getYangModule(const std::string& name);
[[nodiscard]] std::string dataPathToSchemaPath(const std::string& path);
+
private:
friend class YangAccess;
template <typename NodeType>