Change return value of Schema::childNodes
I'll need to use this method to generate what can be parsed as paths in
the upcoming path parser rework. As a side effect, path completion
generation gets a little bit simpler, because now I don't have to parse
the strings of format "[module:]node" and just trust whatever the schema
gives me.
Change-Id: I881cdbbd8254b846c21cee1ac0a3b7af1e40a696
diff --git a/src/yang_schema.cpp b/src/yang_schema.cpp
index 80ec7f3..2c8b30d 100644
--- a/src/yang_schema.cpp
+++ b/src/yang_schema.cpp
@@ -320,10 +320,10 @@
return res;
}
-std::set<std::string> YangSchema::availableNodes(const boost::variant<dataPath_, schemaPath_, module_>& path, const Recursion recursion) const
+std::set<ModuleNodePair> YangSchema::availableNodes(const boost::variant<dataPath_, schemaPath_, module_>& path, const Recursion recursion) const
{
using namespace std::string_view_literals;
- std::set<std::string> res;
+ std::set<ModuleNodePair> res;
std::vector<libyang::S_Schema_Node> nodes;
std::string topLevelModule;
@@ -351,15 +351,14 @@
continue;
if (recursion == Recursion::Recursive) {
for (auto it : node->tree_dfs()) {
- res.insert(it->path(LYS_PATH_FIRST_PREFIX));
+ res.insert(ModuleNodePair(boost::none, it->path(LYS_PATH_FIRST_PREFIX)));
}
} else {
- std::string toInsert;
+ ModuleNodePair toInsert;
if (topLevelModule.empty() || topLevelModule != node->module()->name()) {
- toInsert += node->module()->name();
- toInsert += ":";
+ toInsert.first = node->module()->name();
}
- toInsert += node->name();
+ toInsert.second = node->name();
res.insert(toInsert);
}
}