Refactor NetconfAccess::getItems algorithm
I'll be using the same algorithm in YangAccess.
Change-Id: Iff7eb70e64525111dab71fee2fe4e5e08c80dfc0
diff --git a/src/netconf_access.cpp b/src/netconf_access.cpp
index a7cd6b4..bcf6fb4 100644
--- a/src/netconf_access.cpp
+++ b/src/netconf_access.cpp
@@ -5,7 +5,6 @@
*
*/
-#include <boost/algorithm/string/predicate.hpp>
#include <libyang/Libyang.hpp>
#include <libyang/Tree_Data.hpp>
#include "libyang_utils.hpp"
@@ -23,19 +22,7 @@
auto config = m_session->get((path != "/") ? std::optional{path} : std::nullopt);
if (config) {
- auto siblings = config->tree_for();
- for (auto it = siblings.begin(); it < siblings.end(); it++) {
- if ((*it)->schema()->nodetype() == LYS_LEAFLIST) {
- auto leafListPath = stripLeafListValueFromPath((*it)->path());
- res.emplace_back(leafListPath, special_{SpecialValue::LeafList});
- while (it != siblings.end() && boost::starts_with((*it)->path(), leafListPath)) {
- lyNodesToTree(res, (*it)->tree_dfs());
- it++;
- }
- } else {
- lyNodesToTree(res, (*it)->tree_dfs());
- }
- }
+ lyNodesToTree(res, config->tree_for());
}
return res;
}
@@ -141,9 +128,7 @@
Tree res;
auto output = m_session->rpc(data);
if (output) {
- for (auto it : output->tree_for()) {
- lyNodesToTree(res, it->tree_dfs(), joinPaths(path, "/"));
- }
+ lyNodesToTree(res, output->tree_for(), joinPaths(path, "/"));
}
return res;
}