Merge "Refactor leafValueFromValue"
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 79dd345..ccf0aeb 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -110,6 +110,7 @@
 
 add_library(yangschema STATIC
     src/yang_schema.cpp
+    src/libyang_utils.cpp
     )
 target_link_libraries(yangschema schemas ${LIBYANG_LIBRARIES})
 # Ensure that this doesn't override Boost's -isystem -- see the log for details.
diff --git a/src/libyang_utils.cpp b/src/libyang_utils.cpp
new file mode 100644
index 0000000..0885c64
--- /dev/null
+++ b/src/libyang_utils.cpp
@@ -0,0 +1,32 @@
+#include "libyang_utils.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;
+    }
+}
diff --git a/src/libyang_utils.hpp b/src/libyang_utils.hpp
new file mode 100644
index 0000000..42b6198
--- /dev/null
+++ b/src/libyang_utils.hpp
@@ -0,0 +1,11 @@
+/*
+ * Copyright (C) 2020 CESNET, https://photonics.cesnet.cz/
+ *
+ * Written by Václav Kubernát <kubernat@cesnet.cz>
+ *
+*/
+
+#include <libyang/Tree_Data.hpp>
+#include "ast_values.hpp"
+
+leaf_data_ leafValueFromValue(const libyang::S_Value& value, LY_DATA_TYPE type);
diff --git a/src/netconf_access.cpp b/src/netconf_access.cpp
index 4f4a923..5b1ad78 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)