Add support for leaflist
Change-Id: Idcb529f85240a32e84d82934c81fcf0c3451f94e
diff --git a/src/netconf_access.cpp b/src/netconf_access.cpp
index 1340332..6fd3f69 100644
--- a/src/netconf_access.cpp
+++ b/src/netconf_access.cpp
@@ -38,9 +38,15 @@
if (it->schema()->nodetype() == LYS_LIST) {
res.emplace(stripXPathPrefix(it->path()), special_{SpecialValue::List});
}
- if (it->schema()->nodetype() == LYS_LEAF) {
+ if (it->schema()->nodetype() == LYS_LEAF || it->schema()->nodetype() == LYS_LEAFLIST) {
+ using namespace std::string_literals;
libyang::Data_Node_Leaf_List leaf(it);
- res.emplace(stripXPathPrefix(it->path()), leafValueFromValue(leaf.value(), leaf.leaf_type()->base()));
+ auto value = leafValueFromValue(leaf.value(), leaf.leaf_type()->base());
+ if (it->schema()->nodetype() == LYS_LEAFLIST) {
+ std::string strippedLeafListValue = stripLeafListValueFromPath(it->path());
+ res.emplace(stripXPathPrefix(strippedLeafListValue), special_{SpecialValue::LeafList});
+ }
+ res.emplace(stripXPathPrefix(it->path()), value);
}
}
}
@@ -115,6 +121,19 @@
doEditFromDataNode(node);
}
+void NetconfAccess::createLeafListInstance(const std::string& path)
+{
+ auto node = m_schema->dataNodeFromPath(path);
+ doEditFromDataNode(node);
+}
+void NetconfAccess::deleteLeafListInstance(const std::string& path)
+{
+ auto node = m_schema->dataNodeFromPath(path);
+ auto list = *(node->find_path(path.c_str())->data().begin());
+ list->insert_attr(m_schema->getYangModule("ietf-netconf"), "operation", "delete");
+ doEditFromDataNode(node);
+}
+
void NetconfAccess::doEditFromDataNode(std::shared_ptr<libyang::Data_Node> dataNode)
{
auto data = dataNode->print_mem(LYD_XML, 0);