Fix pathToDataString
The function wasn't properly converting multi-keyed lists. It also
didn't care if the path was absolute. This patch fixes both of these
issues.
Issue: https://tree.taiga.io/project/jktjkt-netconf-cli/issue/143
Change-Id: I4c3d19202be28e84b1db9a8311f49b848ef48a34
diff --git a/src/ast_path.cpp b/src/ast_path.cpp
index 861e52d..3a486a5 100644
--- a/src/ast_path.cpp
+++ b/src/ast_path.cpp
@@ -137,7 +137,7 @@
std::ostringstream res;
res << node.m_name + "[";
std::transform(node.m_keys.begin(), node.m_keys.end(),
- std::experimental::make_ostream_joiner(res, ' '),
+ std::experimental::make_ostream_joiner(res, "]["),
[] (const auto& it) { return it.first + "=" + escapeListKeyString(it.second); });
res << "]";
return res.str();
@@ -161,6 +161,9 @@
std::string pathToDataString(const dataPath_& path)
{
std::string res;
+ if (path.m_scope == Scope::Absolute) {
+ res = "/";
+ }
for (const auto it : path.m_nodes)
if (it.m_prefix)
res = joinPaths(res, it.m_prefix.value().m_name + ":" + boost::apply_visitor(nodeToDataStringVisitor(), it.m_suffix));