Fix handling of choice statements in YangSchema
Now that I'm using `libyang::Context::get_node`, the code got a little
less complicated, since it always returns a Schema_Node instead of
a Set.
Change-Id: Iab3734ed4cb5957cb635f268b882963c95d36206
Issue: https://tree.taiga.io/project/jktjkt-netconf-cli/issue/119
diff --git a/src/yang_schema.cpp b/src/yang_schema.cpp
index c9e3d3c..2619943 100644
--- a/src/yang_schema.cpp
+++ b/src/yang_schema.cpp
@@ -188,7 +188,7 @@
return keys.find(key) != keys.end();
}
-libyang::S_Set YangSchema::getNodeSet(const schemaPath_& location, const ModuleNodePair& node) const
+libyang::S_Schema_Node YangSchema::getSchemaNode(const schemaPath_& location, const ModuleNodePair& node) const
{
std::string absPath = location.m_nodes.empty() ? "" : "/";
absPath += pathToAbsoluteSchemaString(location) + "/" + fullNodeName(location, node);
@@ -205,21 +205,10 @@
[&oldOptions]() {
libyang::set_log_options(oldOptions);
});
- return m_context->find_path(absPath.c_str());
+ return m_context->get_node(nullptr, absPath.c_str());
}
}
-libyang::S_Schema_Node YangSchema::getSchemaNode(const schemaPath_& location, const ModuleNodePair& node) const
-{
- const auto set = getNodeSet(location, node);
- if (!set)
- return nullptr;
- const auto& schemaSet = set->schema();
- if (set->number() != 1)
- return nullptr;
- return *schemaSet.begin();
-}
-
const std::set<std::string> YangSchema::listKeys(const schemaPath_& location, const ModuleNodePair& node) const
{
std::set<std::string> keys;