Merge "Rename .h header files to .hpp"
diff --git a/src/libyang_utils.cpp b/src/libyang_utils.cpp
index e6b825d..9051e16 100644
--- a/src/libyang_utils.cpp
+++ b/src/libyang_utils.cpp
@@ -1,4 +1,5 @@
#include "libyang_utils.hpp"
+#include <cmath>
leaf_data_ leafValueFromValue(const libyang::S_Value& value, LY_DATA_TYPE type)
{
@@ -17,7 +18,7 @@
case LY_TYPE_UINT16:
return value->uint16();
case LY_TYPE_UINT32:
- return value->uintu32();
+ return value->uint32();
case LY_TYPE_UINT64:
return value->uint64();
case LY_TYPE_BOOL:
@@ -28,6 +29,11 @@
return enum_{std::string(value->enm()->name())};
case LY_TYPE_BINARY:
return std::string{value->binary()};
+ case LY_TYPE_DEC64:
+ {
+ auto v = value->dec64();
+ return v.value * std::pow(10, -v.digits);
+ }
default: // TODO: implement all types
return "(can't print)"s;
}
diff --git a/src/netconf-client.cpp b/src/netconf-client.cpp
index 2869a1f..63045f0 100644
--- a/src/netconf-client.cpp
+++ b/src/netconf-client.cpp
@@ -288,10 +288,11 @@
throw std::runtime_error("Cannot create get RPC");
}
auto reply = impl::do_rpc_data(this, std::move(rpc));
+ auto dataNode = libyang::create_new_Data_Node(reply->data);
// TODO: can we do without copying?
// If we just default-construct a new node (or use the create_new_Data_Node) and then set reply->data to nullptr,
// there are mem leaks and even libnetconf2 complains loudly.
- return libyang::create_new_Data_Node(reply->data)->dup_withsiblings(1);
+ return dataNode ? dataNode->dup_withsiblings(1) : nullptr;
}
std::string Session::getSchema(const std::string_view identifier, const std::optional<std::string_view> version)
@@ -320,14 +321,9 @@
throw std::runtime_error("Cannot create get-config RPC");
}
auto reply = impl::do_rpc_data(this, std::move(rpc));
- // TODO: can we do without copying?
- // If we just default-construct a new node (or use the create_new_Data_Node) and then set reply->data to nullptr,
- // there are mem leaks and even libnetconf2 complains loudly.
auto dataNode = libyang::create_new_Data_Node(reply->data);
- if (!dataNode)
- return nullptr;
- else
- return dataNode->dup_withsiblings(1);
+ // TODO: can we do without copying? See Session::get() for details.
+ return dataNode ? dataNode->dup_withsiblings(1) : nullptr;
}
void Session::editConfig(const NC_DATASTORE datastore,
diff --git a/src/netconf_access.cpp b/src/netconf_access.cpp
index fd8f2a8..4cffb52 100644
--- a/src/netconf_access.cpp
+++ b/src/netconf_access.cpp
@@ -52,7 +52,7 @@
DatastoreAccess::Tree NetconfAccess::getItems(const std::string& path)
{
Tree res;
- auto config = m_session->getConfig(NC_DATASTORE_RUNNING, (path != "/") ? std::optional{path} : std::nullopt);
+ auto config = m_session->get((path != "/") ? std::optional{path} : std::nullopt);
if (config) {
for (auto it : config->tree_for()) {
diff --git a/submodules/dependencies b/submodules/dependencies
index e0af555..71ee2bd 160000
--- a/submodules/dependencies
+++ b/submodules/dependencies
@@ -1 +1 @@
-Subproject commit e0af5558e441b630580bf4ad0aab8a700ab09ce2
+Subproject commit 71ee2bde0047fbb3d585a7b6af202d819cdaa864
diff --git a/tests/datastore_access.cpp b/tests/datastore_access.cpp
index a7fc6f5..4a25803 100644
--- a/tests/datastore_access.cpp
+++ b/tests/datastore_access.cpp
@@ -288,6 +288,17 @@
}
+ SECTION("floats")
+ {
+ datastore.setLeaf("/example-schema:leafDecimal", 123.4);
+ REQUIRE_CALL(mock, write("/example-schema:leafDecimal", std::nullopt, "123.4"s));
+ datastore.commitChanges();
+ DatastoreAccess::Tree expected {
+ {"/example-schema:leafDecimal", 123.4},
+ };
+ REQUIRE(datastore.getItems("/example-schema:leafDecimal") == expected);
+ }
+
waitForCompletionAndBitMore(seq1);
}