Refactor leafValueFromValue
This function will be useful in other libyang enabled contexts.
Change-Id: Iae808d892be27749571f5086fac7af17290953e8
diff --git a/src/netconf_access.cpp b/src/netconf_access.cpp
index 78d80b1..bf01ca0 100644
--- a/src/netconf_access.cpp
+++ b/src/netconf_access.cpp
@@ -7,42 +7,12 @@
#include <libyang/Libyang.hpp>
#include <libyang/Tree_Data.hpp>
+#include "libyang_utils.hpp"
#include "netconf-client.h"
#include "netconf_access.hpp"
#include "utils.hpp"
#include "yang_schema.hpp"
-leaf_data_ leafValueFromValue(const libyang::S_Value& value, LY_DATA_TYPE type)
-{
- using namespace std::string_literals;
- switch (type) {
- case LY_TYPE_INT8:
- return value->int8();
- case LY_TYPE_INT16:
- return value->int16();
- case LY_TYPE_INT32:
- return value->int32();
- case LY_TYPE_INT64:
- return value->int64();
- case LY_TYPE_UINT8:
- return value->uint8();
- case LY_TYPE_UINT16:
- return value->uint16();
- case LY_TYPE_UINT32:
- return value->uintu32();
- case LY_TYPE_UINT64:
- return value->uint64();
- case LY_TYPE_BOOL:
- return bool(value->bln());
- case LY_TYPE_STRING:
- return std::string(value->string());
- case LY_TYPE_ENUM:
- return enum_{std::string(value->enm()->name())};
- default: // TODO: implement all types
- return "(can't print)"s;
- }
-}
-
NetconfAccess::~NetconfAccess() = default;
std::map<std::string, leaf_data_> NetconfAccess::getItems(const std::string& path)