Remove unused overloads in Schema
Change-Id: I919c7175401c557a489b6f288f7f5517a77472d9
diff --git a/src/schema.hpp b/src/schema.hpp
index 42d0728..2daa73f 100644
--- a/src/schema.hpp
+++ b/src/schema.hpp
@@ -62,12 +62,10 @@
virtual yang::NodeTypes nodeType(const std::string& path) const = 0;
virtual yang::NodeTypes nodeType(const schemaPath_& location, const ModuleNodePair& node) const = 0;
virtual bool isModule(const std::string& name) const = 0;
- virtual bool listHasKey(const schemaPath_& location, const ModuleNodePair& node, const std::string& key) const = 0;
virtual bool listHasKey(const schemaPath_& listPath, const std::string& key) const = 0;
virtual bool leafIsKey(const std::string& leafPath) const = 0;
virtual bool isConfig(const std::string& path) const = 0;
virtual std::optional<std::string> defaultValue(const std::string& leafPath) const = 0;
- virtual const std::set<std::string> listKeys(const schemaPath_& location, const ModuleNodePair& node) const = 0;
virtual const std::set<std::string> listKeys(const schemaPath_& listPath) const = 0;
virtual yang::TypeInfo leafType(const schemaPath_& location, const ModuleNodePair& node) const = 0;
virtual yang::TypeInfo leafType(const std::string& path) const = 0;
diff --git a/src/static_schema.cpp b/src/static_schema.cpp
index 203b61e..989ef21 100644
--- a/src/static_schema.cpp
+++ b/src/static_schema.cpp
@@ -34,31 +34,11 @@
m_nodes.emplace(key, std::unordered_map<std::string, NodeInfo>());
}
-bool StaticSchema::listHasKey(const schemaPath_& location, const ModuleNodePair& node, const std::string& key) const
-{
- std::string locationString = pathToSchemaString(location, Prefixes::Always);
- assert(isList(location, node));
-
- const auto& child = children(locationString).at(fullNodeName(location, node));
- const auto& list = std::get<yang::list>(child.m_nodeType);
- return list.m_keys.find(key) != list.m_keys.end();
-}
-
bool StaticSchema::listHasKey(const schemaPath_& listPath, const std::string& key) const
{
return listKeys(listPath).count(key);
}
-const std::set<std::string> StaticSchema::listKeys(const schemaPath_& location, const ModuleNodePair& node) const
-{
- std::string locationString = pathToSchemaString(location, Prefixes::Always);
- assert(isList(location, node));
-
- const auto& child = children(locationString).at(fullNodeName(location, node));
- const auto& list = std::get<yang::list>(child.m_nodeType);
- return list.m_keys;
-}
-
std::string lastNodeOfSchemaPath(const std::string& path)
{
std::string res = path;
diff --git a/src/static_schema.hpp b/src/static_schema.hpp
index 09b6271..9d897b1 100644
--- a/src/static_schema.hpp
+++ b/src/static_schema.hpp
@@ -62,12 +62,10 @@
yang::NodeTypes nodeType(const std::string& path) const override;
yang::NodeTypes nodeType(const schemaPath_& location, const ModuleNodePair& node) const override;
bool isModule(const std::string& name) const override;
- bool listHasKey(const schemaPath_& location, const ModuleNodePair& node, const std::string& key) const override;
bool listHasKey(const schemaPath_& listPath, const std::string& key) const override;
bool leafIsKey(const std::string& leafPath) const override;
bool isConfig(const std::string& leafPath) const override;
std::optional<std::string> defaultValue(const std::string& leafPath) const override;
- const std::set<std::string> listKeys(const schemaPath_& location, const ModuleNodePair& node) const override;
const std::set<std::string> listKeys(const schemaPath_& listPath) const override;
yang::TypeInfo leafType(const schemaPath_& location, const ModuleNodePair& node) const override;
yang::TypeInfo leafType(const std::string& path) const override;
diff --git a/src/yang_schema.cpp b/src/yang_schema.cpp
index b44ef5f..c8bf540 100644
--- a/src/yang_schema.cpp
+++ b/src/yang_schema.cpp
@@ -93,14 +93,6 @@
return set.find(name) != set.end();
}
-bool YangSchema::listHasKey(const schemaPath_& location, const ModuleNodePair& node, const std::string& key) const
-{
- if (!isList(location, node))
- return false;
- const auto keys = listKeys(location, node);
- return keys.find(key) != keys.end();
-}
-
bool YangSchema::listHasKey(const schemaPath_& listPath, const std::string& key) const
{
const auto keys = listKeys(listPath);
@@ -153,30 +145,20 @@
return impl_getSchemaNode(absPath);
}
-namespace {
-const std::set<std::string> impl_listKeys(const libyang::S_Schema_Node_List& list)
+const std::set<std::string> YangSchema::listKeys(const schemaPath_& listPath) const
{
+ auto node = getSchemaNode(listPath);
+ if (node->nodetype() != LYS_LIST) {
+ return {};
+ }
+
+ auto list = std::make_shared<libyang::Schema_Node_List>(node);
std::set<std::string> keys;
const auto& keysVec = list->keys();
std::transform(keysVec.begin(), keysVec.end(), std::inserter(keys, keys.begin()), [](const auto& it) { return it->name(); });
return keys;
}
-}
-
-const std::set<std::string> YangSchema::listKeys(const schemaPath_& location, const ModuleNodePair& node) const
-{
- if (!isList(location, node))
- return {};
- auto list = std::make_shared<libyang::Schema_Node_List>(getSchemaNode(location, node));
- return impl_listKeys(list);
-}
-
-const std::set<std::string> YangSchema::listKeys(const schemaPath_& listPath) const
-{
- auto list = std::make_shared<libyang::Schema_Node_List>(getSchemaNode(listPath));
- return impl_listKeys(list);
-}
namespace {
std::set<enum_> enumValues(const libyang::S_Type& typeArg)
diff --git a/src/yang_schema.hpp b/src/yang_schema.hpp
index aed1a5d..3663ccd 100644
--- a/src/yang_schema.hpp
+++ b/src/yang_schema.hpp
@@ -34,12 +34,10 @@
yang::NodeTypes nodeType(const std::string& path) const override;
yang::NodeTypes nodeType(const schemaPath_& location, const ModuleNodePair& node) const override;
bool isModule(const std::string& name) const override;
- bool listHasKey(const schemaPath_& location, const ModuleNodePair& node, const std::string& key) const override;
bool listHasKey(const schemaPath_& listPath, const std::string& key) const override;
bool leafIsKey(const std::string& leafPath) const override;
bool isConfig(const std::string& path) const override;
std::optional<std::string> defaultValue(const std::string& leafPath) const override;
- const std::set<std::string> listKeys(const schemaPath_& location, const ModuleNodePair& node) const override;
const std::set<std::string> listKeys(const schemaPath_& listPath) const override;
yang::TypeInfo leafType(const schemaPath_& location, const ModuleNodePair& node) const override;
yang::TypeInfo leafType(const std::string& path) const override;