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/static_schema.cpp b/src/static_schema.cpp
index ce94218..9be7751 100644
--- a/src/static_schema.cpp
+++ b/src/static_schema.cpp
@@ -31,12 +31,12 @@
return childrenRef.find(node) != childrenRef.end();
}
-bool StaticSchema::isModule(const path_&, const std::string& name) const
+bool StaticSchema::isModule(const schemaPath_&, const std::string& name) const
{
return m_modules.find(name) != m_modules.end();
}
-bool StaticSchema::isContainer(const path_& location, const ModuleNodePair& node) const
+bool StaticSchema::isContainer(const schemaPath_& location, const ModuleNodePair& node) const
{
std::string locationString = pathToAbsoluteSchemaString(location);
auto fullName = fullNodeName(location, node);
@@ -55,7 +55,7 @@
m_nodes.emplace(key, std::unordered_map<std::string, NodeType>());
}
-bool StaticSchema::listHasKey(const path_& location, const ModuleNodePair& node, const std::string& key) const
+bool StaticSchema::listHasKey(const schemaPath_& location, const ModuleNodePair& node, const std::string& key) const
{
std::string locationString = pathToAbsoluteSchemaString(location);
assert(isList(location, node));
@@ -65,7 +65,7 @@
return list.m_keys.find(key) != list.m_keys.end();
}
-const std::set<std::string> StaticSchema::listKeys(const path_& location, const ModuleNodePair& node) const
+const std::set<std::string> StaticSchema::listKeys(const schemaPath_& location, const ModuleNodePair& node) const
{
std::string locationString = pathToAbsoluteSchemaString(location);
assert(isList(location, node));
@@ -75,7 +75,7 @@
return list.m_keys;
}
-bool StaticSchema::isList(const path_& location, const ModuleNodePair& node) const
+bool StaticSchema::isList(const schemaPath_& location, const ModuleNodePair& node) const
{
std::string locationString = pathToAbsoluteSchemaString(location);
auto fullName = fullNodeName(location, node);
@@ -95,7 +95,7 @@
m_nodes.emplace(name, std::unordered_map<std::string, NodeType>());
}
-bool StaticSchema::isPresenceContainer(const path_& location, const ModuleNodePair& node) const
+bool StaticSchema::isPresenceContainer(const schemaPath_& location, const ModuleNodePair& node) const
{
if (!isContainer(location, node))
return false;
@@ -119,7 +119,7 @@
}
-bool StaticSchema::leafEnumHasValue(const path_& location, const ModuleNodePair& node, const std::string& value) const
+bool StaticSchema::leafEnumHasValue(const schemaPath_& location, const ModuleNodePair& node, const std::string& value) const
{
std::string locationString = pathToAbsoluteSchemaString(location);
assert(isLeaf(location, node));
@@ -129,7 +129,7 @@
return list.m_enumValues.find(value) != list.m_enumValues.end();
}
-bool StaticSchema::isLeaf(const path_& location, const ModuleNodePair& node) const
+bool StaticSchema::isLeaf(const schemaPath_& location, const ModuleNodePair& node) const
{
std::string locationString = pathToAbsoluteSchemaString(location);
auto fullName = fullNodeName(location, node);
@@ -139,7 +139,7 @@
return children(locationString).at(fullName).type() == typeid(yang::leaf);
}
-yang::LeafDataTypes StaticSchema::leafType(const path_& location, const ModuleNodePair& node) const
+yang::LeafDataTypes StaticSchema::leafType(const schemaPath_& location, const ModuleNodePair& node) const
{
std::string locationString = pathToAbsoluteSchemaString(location);
return boost::get<yang::leaf>(children(locationString).at(fullNodeName(location, node))).m_type;
@@ -147,7 +147,7 @@
// We do not test StaticSchema, so we don't need to implement recursive childNodes
// for this class.
-std::set<std::string> StaticSchema::childNodes(const path_& path, const Recursion) const
+std::set<std::string> StaticSchema::childNodes(const schemaPath_& path, const Recursion) const
{
std::string locationString = pathToAbsoluteSchemaString(path);
std::set<std::string> res;