Move leafDataToString to utils

Change-Id: I3ddb9b55a0e3d4371cb8e6569e4e70c6d284bdbf
diff --git a/src/interpreter.cpp b/src/interpreter.cpp
index eca4879..d9d5214 100644
--- a/src/interpreter.cpp
+++ b/src/interpreter.cpp
@@ -10,31 +10,6 @@
 #include "datastore_access.hpp"
 #include "interpreter.hpp"
 
-struct leafDataToString : boost::static_visitor<std::string> {
-    std::string operator()(const enum_& data) const
-    {
-        return data.m_value;
-    }
-
-    std::string operator()(const binary_& data) const
-    {
-        return data.m_value;
-    }
-
-    std::string operator()(const identityRef_& data) const
-    {
-        return data.m_value;
-    }
-
-    template <typename T>
-    std::string operator()(const T& data) const
-    {
-        std::stringstream stream;
-        stream << data;
-        return stream.str();
-    }
-};
-
 void Interpreter::operator()(const commit_&) const
 {
     m_datastore.commitChanges();
@@ -64,7 +39,7 @@
 {
     auto items = m_datastore.getItems(absolutePathFromCommand(get));
     for (auto it : items) {
-        std::cout << it.first << " = " << boost::apply_visitor(leafDataToString(), it.second) << std::endl;
+        std::cout << it.first << " = " << leafDataToString(it.second) << std::endl;
     }
 }
 
diff --git a/src/utils.cpp b/src/utils.cpp
index 421fc3e..7f93d27 100644
--- a/src/utils.cpp
+++ b/src/utils.cpp
@@ -77,3 +77,33 @@
             [prefix] (auto it) { return boost::starts_with(it, prefix); });
     return filtered;
 }
+
+struct leafDataToStringVisitor : boost::static_visitor<std::string> {
+    std::string operator()(const enum_& data) const
+    {
+        return data.m_value;
+    }
+
+    std::string operator()(const binary_& data) const
+    {
+        return data.m_value;
+    }
+
+    std::string operator()(const identityRef_& data) const
+    {
+        return data.m_value;
+    }
+
+    template <typename T>
+    std::string operator()(const T& data) const
+    {
+        std::stringstream stream;
+        stream << data;
+        return stream.str();
+    }
+};
+
+std::string leafDataToString(const leaf_data_ value)
+{
+    return boost::apply_visitor(leafDataToStringVisitor(), value);
+}
diff --git a/src/utils.hpp b/src/utils.hpp
index dcaefb3..a9fde88 100644
--- a/src/utils.hpp
+++ b/src/utils.hpp
@@ -21,3 +21,4 @@
 std::string fullNodeName(const dataPath_& location, const ModuleNodePair& pair);
 /** Returns a subset of the original set with only the strings starting with prefix */
 std::set<std::string> filterByPrefix(const std::set<std::string>& set, const std::string_view prefix);
+std::string leafDataToString(const leaf_data_ value);