Add dump command

Change-Id: If38d01ebb8788090f91a76daf6b7fc9add0320b7
diff --git a/src/sysrepo_access.cpp b/src/sysrepo_access.cpp
index e95d740..61ff560 100644
--- a/src/sysrepo_access.cpp
+++ b/src/sysrepo_access.cpp
@@ -432,3 +432,25 @@
 
     return res;
 }
+
+std::string SysrepoAccess::dump(const DataFormat format) const
+{
+    std::shared_ptr<libyang::Data_Node> root;
+    auto input = getItems("/");
+    if (input.empty()) {
+        return "";
+    }
+    for (const auto& [k, v] : input) {
+        if (v.type() == typeid(special_) && boost::get<special_>(v).m_value != SpecialValue::PresenceContainer) {
+            continue;
+        }
+        if (!root) {
+            root = m_schema->dataNodeFromPath(k, leafDataToString(v));
+        } else {
+            // Using UPDATE here, because in multi-key list, all of the keys get created with the first key (because they are encoded in the path)
+            // and libyang complains if the node already exists.
+            root->new_path(nullptr, k.c_str(), leafDataToString(v).c_str(), LYD_ANYDATA_CONSTSTRING, LYD_PATH_OPT_UPDATE);
+        }
+    }
+    return root->print_mem(format == DataFormat::Xml ? LYD_XML : LYD_JSON, LYP_WITHSIBLINGS | LYP_FORMAT);
+}