Split path_ into schemaPath_ and dataPath_

This change is necessary because different commands accept different
kinds of paths (for example "cd" only accepts a data path, on the other
hand "ls" doesn't care about data, so it accepts both). One option was to
create a new path struct for every command, but that could get quickly
out of control as new commands get added. The other option was define only
the data path and schema path and then change the commands' grammars, so
that they only accept the relevant paths, but in the end always return a
data path or a schema path.

Change-Id: I7668a446fbf674c7a5deae22d9aacdfb3da9b07e
diff --git a/src/parser.cpp b/src/parser.cpp
index f25f1a3..bb17495 100644
--- a/src/parser.cpp
+++ b/src/parser.cpp
@@ -21,7 +21,7 @@
 command_ Parser::parseCommand(const std::string& line, std::ostream& errorStream)
 {
     command_ parsedCommand;
-    ParserContext ctx(*m_schema, m_curDir);
+    ParserContext ctx(*m_schema, dataPathToSchemaPath(m_curDir));
     auto it = line.begin();
 
     boost::spirit::x3::error_handler<std::string::const_iterator> errorHandler(it, line.end(), errorStream);
@@ -39,7 +39,7 @@
     return parsedCommand;
 }
 
-void Parser::changeNode(const path_& name)
+void Parser::changeNode(const dataPath_& name)
 {
     if (name.m_scope == Scope::Absolute) {
         m_curDir = name;
@@ -58,10 +58,24 @@
     return "/" + pathToDataString(m_curDir);
 }
 
-std::set<std::string> Parser::availableNodes(const boost::optional<path_>& path, const Recursion& option) const
+struct getSchemaPathVisitor : boost::static_visitor<schemaPath_> {
+    schemaPath_ operator()(const dataPath_& path) const
+    {
+        return dataPathToSchemaPath(path);
+    }
+
+    schemaPath_ operator()(const schemaPath_& path) const
+    {
+        return path;
+    }
+};
+
+std::set<std::string> Parser::availableNodes(const boost::optional<dataPath_>& path, const Recursion& option) const
 {
-    auto pathArg = m_curDir;
-    if (path)
-        pathArg.m_nodes.insert(pathArg.m_nodes.end(), path->m_nodes.begin(), path->m_nodes.end());
+    auto pathArg = dataPathToSchemaPath(m_curDir);
+    if (path) {
+        auto schemaPath = dataPathToSchemaPath(*path);
+        pathArg.m_nodes.insert(pathArg.m_nodes.end(), schemaPath.m_nodes.begin(), schemaPath.m_nodes.end());
+    }
     return m_schema->childNodes(pathArg, option);
 }