Use namespaced libyang-cpp
Change-Id: Id9f89f58920cf0ce8649a57b3cf712d121b3840e
diff --git a/src/yang_schema.cpp b/src/yang_schema.cpp
index 7bcf258..68a4cf2 100644
--- a/src/yang_schema.cpp
+++ b/src/yang_schema.cpp
@@ -51,8 +51,8 @@
}
YangSchema::YangSchema()
+ : m_context(std::make_shared<libyang::Context>())
{
- m_context = std::make_shared<Context>();
}
YangSchema::~YangSchema() = default;
@@ -106,7 +106,7 @@
{
if (!isContainer(location, node))
return false;
- return Schema_Node_Container(getSchemaNode(location, node)).presence();
+ return libyang::Schema_Node_Container(getSchemaNode(location, node)).presence();
}
bool YangSchema::leafEnumHasValue(const path_& location, const ModuleNodePair& node, const std::string& value) const
@@ -114,7 +114,7 @@
if (!isLeaf(location, node) || leafType(location, node) != yang::LeafDataTypes::Enum)
return false;
- Schema_Node_Leaf leaf(getSchemaNode(location, node));
+ libyang::Schema_Node_Leaf leaf(getSchemaNode(location, node));
const auto& enm = leaf.type()->info()->enums()->enm();
return std::any_of(enm.begin(), enm.end(), [=](const auto& x) { return x->name() == value; });
@@ -135,14 +135,14 @@
return set->number() == 1;
}
-S_Set YangSchema::getNodeSet(const path_& location, const ModuleNodePair& node) const
+libyang::S_Set YangSchema::getNodeSet(const path_& location, const ModuleNodePair& node) const
{
std::string absPath = location.m_nodes.empty() ? "" : "/";
absPath += pathToAbsoluteSchemaString(location) + "/" + fullNodeName(location, node);
return m_context->find_path(absPath.c_str());
}
-std::shared_ptr<Schema_Node> YangSchema::getSchemaNode(const path_& location, const ModuleNodePair& node) const
+libyang::S_Schema_Node YangSchema::getSchemaNode(const path_& location, const ModuleNodePair& node) const
{
const auto set = getNodeSet(location, node);
if (!set)
@@ -158,7 +158,7 @@
std::set<std::string> keys;
if (!isList(location, node))
return keys;
- Schema_Node_List list(getSchemaNode(location, node));
+ libyang::Schema_Node_List list(getSchemaNode(location, node));
const auto& keysVec = list.keys();
std::transform(keysVec.begin(), keysVec.end(), std::inserter(keys, keys.begin()),
@@ -172,7 +172,7 @@
if (!isLeaf(location, node))
throw InvalidSchemaQueryException(fullNodeName(location, node) + " is not a leaf");
- Schema_Node_Leaf leaf(getSchemaNode(location, node));
+ libyang::Schema_Node_Leaf leaf(getSchemaNode(location, node));
switch (leaf.type()->base()) {
case LY_TYPE_STRING:
return yang::LeafDataTypes::String;
diff --git a/src/yang_schema.hpp b/src/yang_schema.hpp
index e30c701..51c3be0 100644
--- a/src/yang_schema.hpp
+++ b/src/yang_schema.hpp
@@ -14,9 +14,11 @@
#include "ast_path.hpp"
#include "schema.hpp"
+namespace libyang {
class Context;
class Set;
class Schema_Node;
+}
/*! \class YangSchema
* \brief A schema class, which uses libyang for queries.
@@ -52,9 +54,9 @@
bool nodeExists(const path_& location, const ModuleNodePair& node) const;
/** @short Returns a set of nodes, that match the location and name criteria. */
- std::shared_ptr<Set> getNodeSet(const path_& location, const ModuleNodePair& node) const;
+ std::shared_ptr<libyang::Set> getNodeSet(const path_& location, const ModuleNodePair& node) const;
/** @short Returns a single Schema_Node if the criteria matches only one, otherwise nullptr. */
- std::shared_ptr<Schema_Node> getSchemaNode(const path_& location, const ModuleNodePair& node) const;
- std::shared_ptr<Context> m_context;
+ std::shared_ptr<libyang::Schema_Node> getSchemaNode(const path_& location, const ModuleNodePair& node) const;
+ std::shared_ptr<libyang::Context> m_context;
};
diff --git a/submodules/libyang b/submodules/libyang
index 9a72222..a0ce0e4 160000
--- a/submodules/libyang
+++ b/submodules/libyang
@@ -1 +1 @@
-Subproject commit 9a722224c187c80f31bab5c37c22f65a8bb4521e
+Subproject commit a0ce0e4ab56f77cd0798cea7e6a4ec7a7f2c30b1