Move leafDataToString to utils
Change-Id: I3ddb9b55a0e3d4371cb8e6569e4e70c6d284bdbf
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);
+}