Václav Kubernát | bddbb17 | 2018-06-13 16:27:39 +0200 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2018 CESNET, https://photonics.cesnet.cz/ |
| 3 | * Copyright (C) 2018 FIT CVUT, https://fit.cvut.cz/ |
| 4 | * |
| 5 | * Written by Václav Kubernát <kubervac@fit.cvut.cz> |
| 6 | * |
| 7 | */ |
| 8 | |
Václav Kubernát | 9456b5c | 2019-10-02 21:14:52 +0200 | [diff] [blame] | 9 | #include <boost/algorithm/string/predicate.hpp> |
Václav Kubernát | bddbb17 | 2018-06-13 16:27:39 +0200 | [diff] [blame] | 10 | #include "static_schema.hpp" |
| 11 | #include "utils.hpp" |
| 12 | |
| 13 | InvalidNodeException::~InvalidNodeException() = default; |
| 14 | |
| 15 | StaticSchema::StaticSchema() |
| 16 | { |
Václav Kubernát | efcac93 | 2020-01-10 15:26:32 +0100 | [diff] [blame] | 17 | m_nodes.emplace("/", std::unordered_map<std::string, NodeType>()); |
Václav Kubernát | bddbb17 | 2018-06-13 16:27:39 +0200 | [diff] [blame] | 18 | } |
| 19 | |
| 20 | const std::unordered_map<std::string, NodeType>& StaticSchema::children(const std::string& name) const |
| 21 | { |
| 22 | return m_nodes.at(name); |
| 23 | } |
| 24 | |
Václav Kubernát | 744f57f | 2018-06-29 22:46:26 +0200 | [diff] [blame] | 25 | bool StaticSchema::nodeExists(const std::string& location, const std::string& node) const |
Václav Kubernát | bddbb17 | 2018-06-13 16:27:39 +0200 | [diff] [blame] | 26 | { |
Václav Kubernát | 744f57f | 2018-06-29 22:46:26 +0200 | [diff] [blame] | 27 | if (node.empty()) |
Václav Kubernát | bddbb17 | 2018-06-13 16:27:39 +0200 | [diff] [blame] | 28 | return true; |
| 29 | const auto& childrenRef = children(location); |
| 30 | |
Václav Kubernát | 744f57f | 2018-06-29 22:46:26 +0200 | [diff] [blame] | 31 | return childrenRef.find(node) != childrenRef.end(); |
Václav Kubernát | bddbb17 | 2018-06-13 16:27:39 +0200 | [diff] [blame] | 32 | } |
| 33 | |
Václav Kubernát | 75877de | 2019-11-20 17:43:02 +0100 | [diff] [blame] | 34 | bool StaticSchema::isModule(const std::string& name) const |
Václav Kubernát | bddbb17 | 2018-06-13 16:27:39 +0200 | [diff] [blame] | 35 | { |
Václav Kubernát | 744f57f | 2018-06-29 22:46:26 +0200 | [diff] [blame] | 36 | return m_modules.find(name) != m_modules.end(); |
| 37 | } |
| 38 | |
Václav Kubernát | 2eaceb8 | 2018-10-08 19:56:30 +0200 | [diff] [blame] | 39 | bool StaticSchema::isContainer(const schemaPath_& location, const ModuleNodePair& node) const |
Václav Kubernát | 744f57f | 2018-06-29 22:46:26 +0200 | [diff] [blame] | 40 | { |
Václav Kubernát | efcac93 | 2020-01-10 15:26:32 +0100 | [diff] [blame] | 41 | std::string locationString = pathToSchemaString(location, Prefixes::Always); |
Václav Kubernát | 744f57f | 2018-06-29 22:46:26 +0200 | [diff] [blame] | 42 | auto fullName = fullNodeName(location, node); |
| 43 | if (!nodeExists(locationString, fullName)) |
Václav Kubernát | bddbb17 | 2018-06-13 16:27:39 +0200 | [diff] [blame] | 44 | return false; |
| 45 | |
Václav Kubernát | 744f57f | 2018-06-29 22:46:26 +0200 | [diff] [blame] | 46 | return children(locationString).at(fullName).type() == typeid(yang::container); |
Václav Kubernát | bddbb17 | 2018-06-13 16:27:39 +0200 | [diff] [blame] | 47 | } |
| 48 | |
| 49 | void StaticSchema::addContainer(const std::string& location, const std::string& name, yang::ContainerTraits isPresence) |
| 50 | { |
| 51 | m_nodes.at(location).emplace(name, yang::container{isPresence}); |
| 52 | |
| 53 | //create a new set of children for the new node |
| 54 | std::string key = joinPaths(location, name); |
| 55 | m_nodes.emplace(key, std::unordered_map<std::string, NodeType>()); |
| 56 | } |
| 57 | |
Václav Kubernát | 2eaceb8 | 2018-10-08 19:56:30 +0200 | [diff] [blame] | 58 | bool StaticSchema::listHasKey(const schemaPath_& location, const ModuleNodePair& node, const std::string& key) const |
Václav Kubernát | bddbb17 | 2018-06-13 16:27:39 +0200 | [diff] [blame] | 59 | { |
Václav Kubernát | efcac93 | 2020-01-10 15:26:32 +0100 | [diff] [blame] | 60 | std::string locationString = pathToSchemaString(location, Prefixes::Always); |
Václav Kubernát | 744f57f | 2018-06-29 22:46:26 +0200 | [diff] [blame] | 61 | assert(isList(location, node)); |
Václav Kubernát | bddbb17 | 2018-06-13 16:27:39 +0200 | [diff] [blame] | 62 | |
Václav Kubernát | 744f57f | 2018-06-29 22:46:26 +0200 | [diff] [blame] | 63 | const auto& child = children(locationString).at(fullNodeName(location, node)); |
Václav Kubernát | bddbb17 | 2018-06-13 16:27:39 +0200 | [diff] [blame] | 64 | const auto& list = boost::get<yang::list>(child); |
| 65 | return list.m_keys.find(key) != list.m_keys.end(); |
| 66 | } |
| 67 | |
Václav Kubernát | 2eaceb8 | 2018-10-08 19:56:30 +0200 | [diff] [blame] | 68 | const std::set<std::string> StaticSchema::listKeys(const schemaPath_& location, const ModuleNodePair& node) const |
Václav Kubernát | bddbb17 | 2018-06-13 16:27:39 +0200 | [diff] [blame] | 69 | { |
Václav Kubernát | efcac93 | 2020-01-10 15:26:32 +0100 | [diff] [blame] | 70 | std::string locationString = pathToSchemaString(location, Prefixes::Always); |
Václav Kubernát | 744f57f | 2018-06-29 22:46:26 +0200 | [diff] [blame] | 71 | assert(isList(location, node)); |
Václav Kubernát | bddbb17 | 2018-06-13 16:27:39 +0200 | [diff] [blame] | 72 | |
Václav Kubernát | 744f57f | 2018-06-29 22:46:26 +0200 | [diff] [blame] | 73 | const auto& child = children(locationString).at(fullNodeName(location, node)); |
Václav Kubernát | bddbb17 | 2018-06-13 16:27:39 +0200 | [diff] [blame] | 74 | const auto& list = boost::get<yang::list>(child); |
| 75 | return list.m_keys; |
| 76 | } |
| 77 | |
Václav Kubernát | 2eaceb8 | 2018-10-08 19:56:30 +0200 | [diff] [blame] | 78 | bool StaticSchema::isList(const schemaPath_& location, const ModuleNodePair& node) const |
Václav Kubernát | bddbb17 | 2018-06-13 16:27:39 +0200 | [diff] [blame] | 79 | { |
Václav Kubernát | efcac93 | 2020-01-10 15:26:32 +0100 | [diff] [blame] | 80 | std::string locationString = pathToSchemaString(location, Prefixes::Always); |
Václav Kubernát | 744f57f | 2018-06-29 22:46:26 +0200 | [diff] [blame] | 81 | auto fullName = fullNodeName(location, node); |
| 82 | if (!nodeExists(locationString, fullName)) |
Václav Kubernát | bddbb17 | 2018-06-13 16:27:39 +0200 | [diff] [blame] | 83 | return false; |
Václav Kubernát | 744f57f | 2018-06-29 22:46:26 +0200 | [diff] [blame] | 84 | const auto& child = children(locationString).at(fullName); |
Václav Kubernát | bddbb17 | 2018-06-13 16:27:39 +0200 | [diff] [blame] | 85 | if (child.type() != typeid(yang::list)) |
| 86 | return false; |
| 87 | |
| 88 | return true; |
| 89 | } |
| 90 | |
| 91 | void StaticSchema::addList(const std::string& location, const std::string& name, const std::set<std::string>& keys) |
| 92 | { |
| 93 | m_nodes.at(location).emplace(name, yang::list{keys}); |
| 94 | |
Václav Kubernát | 1446fe1 | 2019-10-02 19:32:51 +0200 | [diff] [blame] | 95 | std::string key = joinPaths(location, name); |
| 96 | m_nodes.emplace(key, std::unordered_map<std::string, NodeType>()); |
Václav Kubernát | bddbb17 | 2018-06-13 16:27:39 +0200 | [diff] [blame] | 97 | } |
| 98 | |
Václav Kubernát | 2eaceb8 | 2018-10-08 19:56:30 +0200 | [diff] [blame] | 99 | bool StaticSchema::isPresenceContainer(const schemaPath_& location, const ModuleNodePair& node) const |
Václav Kubernát | bddbb17 | 2018-06-13 16:27:39 +0200 | [diff] [blame] | 100 | { |
Václav Kubernát | 744f57f | 2018-06-29 22:46:26 +0200 | [diff] [blame] | 101 | if (!isContainer(location, node)) |
Václav Kubernát | bddbb17 | 2018-06-13 16:27:39 +0200 | [diff] [blame] | 102 | return false; |
Václav Kubernát | efcac93 | 2020-01-10 15:26:32 +0100 | [diff] [blame] | 103 | std::string locationString = pathToSchemaString(location, Prefixes::Always); |
Václav Kubernát | 744f57f | 2018-06-29 22:46:26 +0200 | [diff] [blame] | 104 | return boost::get<yang::container>(children(locationString).at(fullNodeName(location, node))).m_presence == yang::ContainerTraits::Presence; |
Václav Kubernát | bddbb17 | 2018-06-13 16:27:39 +0200 | [diff] [blame] | 105 | } |
| 106 | |
| 107 | void StaticSchema::addLeaf(const std::string& location, const std::string& name, const yang::LeafDataTypes& type) |
| 108 | { |
Václav Kubernát | 6a8d1d9 | 2019-04-24 20:30:36 +0200 | [diff] [blame] | 109 | m_nodes.at(location).emplace(name, yang::leaf{type, {}, {}, {}}); |
Václav Kubernát | e69133a | 2019-11-01 19:01:34 +0100 | [diff] [blame] | 110 | std::string key = joinPaths(location, name); |
| 111 | m_nodes.emplace(key, std::unordered_map<std::string, NodeType>()); |
Václav Kubernát | bddbb17 | 2018-06-13 16:27:39 +0200 | [diff] [blame] | 112 | } |
| 113 | |
| 114 | void StaticSchema::addLeafEnum(const std::string& location, const std::string& name, std::set<std::string> enumValues) |
| 115 | { |
Václav Kubernát | eeb3884 | 2019-03-20 19:46:05 +0100 | [diff] [blame] | 116 | yang::leaf toAdd; |
| 117 | toAdd.m_type = yang::LeafDataTypes::Enum; |
| 118 | toAdd.m_enumValues = enumValues; |
| 119 | m_nodes.at(location).emplace(name, toAdd); |
Václav Kubernát | e69133a | 2019-11-01 19:01:34 +0100 | [diff] [blame] | 120 | std::string key = joinPaths(location, name); |
| 121 | m_nodes.emplace(key, std::unordered_map<std::string, NodeType>()); |
Václav Kubernát | eeb3884 | 2019-03-20 19:46:05 +0100 | [diff] [blame] | 122 | } |
| 123 | |
| 124 | void StaticSchema::addLeafIdentityRef(const std::string& location, const std::string& name, const ModuleValuePair& base) |
| 125 | { |
| 126 | assert(base.first); // base identity cannot have an empty module |
| 127 | yang::leaf toAdd; |
| 128 | toAdd.m_type = yang::LeafDataTypes::IdentityRef; |
| 129 | toAdd.m_identBase = base; |
| 130 | m_nodes.at(location).emplace(name, toAdd); |
Václav Kubernát | e69133a | 2019-11-01 19:01:34 +0100 | [diff] [blame] | 131 | std::string key = joinPaths(location, name); |
| 132 | m_nodes.emplace(key, std::unordered_map<std::string, NodeType>()); |
Václav Kubernát | bddbb17 | 2018-06-13 16:27:39 +0200 | [diff] [blame] | 133 | } |
| 134 | |
Václav Kubernát | 6a8d1d9 | 2019-04-24 20:30:36 +0200 | [diff] [blame] | 135 | void StaticSchema::addLeafRef(const std::string& location, const std::string& name, const std::string& source) |
| 136 | { |
| 137 | yang::leaf toAdd; |
| 138 | toAdd.m_type = yang::LeafDataTypes::LeafRef; |
| 139 | toAdd.m_leafRefSource = source; |
| 140 | m_nodes.at(location).emplace(name, toAdd); |
Václav Kubernát | e69133a | 2019-11-01 19:01:34 +0100 | [diff] [blame] | 141 | std::string key = joinPaths(location, name); |
| 142 | m_nodes.emplace(key, std::unordered_map<std::string, NodeType>()); |
Václav Kubernát | 6a8d1d9 | 2019-04-24 20:30:36 +0200 | [diff] [blame] | 143 | } |
| 144 | |
Václav Kubernát | 744f57f | 2018-06-29 22:46:26 +0200 | [diff] [blame] | 145 | void StaticSchema::addModule(const std::string& name) |
Václav Kubernát | bddbb17 | 2018-06-13 16:27:39 +0200 | [diff] [blame] | 146 | { |
Václav Kubernát | 744f57f | 2018-06-29 22:46:26 +0200 | [diff] [blame] | 147 | m_modules.emplace(name); |
| 148 | } |
Václav Kubernát | bddbb17 | 2018-06-13 16:27:39 +0200 | [diff] [blame] | 149 | |
Václav Kubernát | eeb3884 | 2019-03-20 19:46:05 +0100 | [diff] [blame] | 150 | void StaticSchema::addIdentity(const std::optional<ModuleValuePair>& base, const ModuleValuePair& name) |
| 151 | { |
| 152 | if (base) |
| 153 | m_identities.at(base.value()).emplace(name); |
| 154 | |
| 155 | m_identities.emplace(name, std::set<ModuleValuePair>()); |
| 156 | } |
Václav Kubernát | 744f57f | 2018-06-29 22:46:26 +0200 | [diff] [blame] | 157 | |
Václav Kubernát | 2eaceb8 | 2018-10-08 19:56:30 +0200 | [diff] [blame] | 158 | bool StaticSchema::leafEnumHasValue(const schemaPath_& location, const ModuleNodePair& node, const std::string& value) const |
Václav Kubernát | 744f57f | 2018-06-29 22:46:26 +0200 | [diff] [blame] | 159 | { |
Václav Kubernát | 989b5de | 2019-02-20 16:28:35 +0100 | [diff] [blame] | 160 | auto enums = enumValues(location, node); |
| 161 | return enums.find(value) != enums.end(); |
Václav Kubernát | bddbb17 | 2018-06-13 16:27:39 +0200 | [diff] [blame] | 162 | } |
| 163 | |
Václav Kubernát | eeb3884 | 2019-03-20 19:46:05 +0100 | [diff] [blame] | 164 | void StaticSchema::getIdentSet(const ModuleValuePair& ident, std::set<ModuleValuePair>& res) const |
| 165 | { |
| 166 | res.insert(ident); |
| 167 | auto derivedIdentities = m_identities.at(ident); |
| 168 | for (auto it : derivedIdentities) { |
| 169 | getIdentSet(it, res); |
| 170 | } |
| 171 | } |
| 172 | |
| 173 | const std::set<std::string> StaticSchema::validIdentities(const schemaPath_& location, const ModuleNodePair& node, const Prefixes prefixes) const |
| 174 | { |
Václav Kubernát | efcac93 | 2020-01-10 15:26:32 +0100 | [diff] [blame] | 175 | std::string locationString = pathToSchemaString(location, Prefixes::Always); |
Václav Kubernát | eeb3884 | 2019-03-20 19:46:05 +0100 | [diff] [blame] | 176 | assert(isLeaf(location, node)); |
| 177 | |
| 178 | const auto& child = children(locationString).at(fullNodeName(location, node)); |
| 179 | const auto& leaf = boost::get<yang::leaf>(child); |
| 180 | |
| 181 | std::set<ModuleValuePair> identSet; |
| 182 | getIdentSet(leaf.m_identBase, identSet); |
| 183 | |
| 184 | std::set<std::string> res; |
| 185 | std::transform(identSet.begin(), identSet.end(), std::inserter(res, res.end()), [location, node, prefixes](const auto& it) { |
| 186 | auto topLevelModule = location.m_nodes.empty() ? node.first.get() : location.m_nodes.front().m_prefix.get().m_name; |
| 187 | std::string stringIdent; |
| 188 | if (prefixes == Prefixes::Always || (it.first && it.first.value() != topLevelModule)) { |
| 189 | stringIdent += it.first ? it.first.value() : topLevelModule; |
| 190 | stringIdent += ":"; |
| 191 | } |
| 192 | stringIdent += it.second; |
| 193 | return stringIdent; |
| 194 | }); |
| 195 | |
| 196 | return res; |
| 197 | } |
| 198 | |
| 199 | bool StaticSchema::leafIdentityIsValid(const schemaPath_& location, const ModuleNodePair& node, const ModuleValuePair& value) const |
| 200 | { |
| 201 | auto identities = validIdentities(location, node, Prefixes::Always); |
| 202 | |
| 203 | auto topLevelModule = location.m_nodes.empty() ? node.first.get() : location.m_nodes.front().m_prefix.get().m_name; |
| 204 | auto identModule = value.first ? value.first.value() : topLevelModule; |
Václav Kubernát | 1bf704e | 2019-04-12 13:30:50 +0200 | [diff] [blame] | 205 | return std::any_of(identities.begin(), identities.end(), [toFind = identModule + ":" + value.second](const auto& x) { return x == toFind; }); |
Václav Kubernát | eeb3884 | 2019-03-20 19:46:05 +0100 | [diff] [blame] | 206 | } |
| 207 | |
Václav Kubernát | 2eaceb8 | 2018-10-08 19:56:30 +0200 | [diff] [blame] | 208 | bool StaticSchema::isLeaf(const schemaPath_& location, const ModuleNodePair& node) const |
Václav Kubernát | bddbb17 | 2018-06-13 16:27:39 +0200 | [diff] [blame] | 209 | { |
Václav Kubernát | efcac93 | 2020-01-10 15:26:32 +0100 | [diff] [blame] | 210 | std::string locationString = pathToSchemaString(location, Prefixes::Always); |
Václav Kubernát | 744f57f | 2018-06-29 22:46:26 +0200 | [diff] [blame] | 211 | auto fullName = fullNodeName(location, node); |
| 212 | if (!nodeExists(locationString, fullName)) |
Václav Kubernát | bddbb17 | 2018-06-13 16:27:39 +0200 | [diff] [blame] | 213 | return false; |
| 214 | |
Václav Kubernát | 744f57f | 2018-06-29 22:46:26 +0200 | [diff] [blame] | 215 | return children(locationString).at(fullName).type() == typeid(yang::leaf); |
Václav Kubernát | bddbb17 | 2018-06-13 16:27:39 +0200 | [diff] [blame] | 216 | } |
| 217 | |
Václav Kubernát | 6a8d1d9 | 2019-04-24 20:30:36 +0200 | [diff] [blame] | 218 | std::string lastNodeOfSchemaPath(const std::string& path) |
| 219 | { |
| 220 | std::string res = path; |
| 221 | auto pos = res.find_last_of('/'); |
Václav Kubernát | efcac93 | 2020-01-10 15:26:32 +0100 | [diff] [blame] | 222 | if (pos == 0) { // path had only one path fragment - "/something:something" |
| 223 | res.erase(0, 1); |
| 224 | return res; |
| 225 | } |
| 226 | if (pos != res.npos) { // path had more fragments |
Václav Kubernát | 6a8d1d9 | 2019-04-24 20:30:36 +0200 | [diff] [blame] | 227 | res.erase(0, pos); |
Václav Kubernát | efcac93 | 2020-01-10 15:26:32 +0100 | [diff] [blame] | 228 | return res; |
| 229 | } |
| 230 | |
| 231 | // path was empty |
Václav Kubernát | 6a8d1d9 | 2019-04-24 20:30:36 +0200 | [diff] [blame] | 232 | return res; |
| 233 | } |
| 234 | |
| 235 | yang::LeafDataTypes StaticSchema::leafrefBase(const schemaPath_& location, const ModuleNodePair& node) const |
| 236 | { |
Václav Kubernát | efcac93 | 2020-01-10 15:26:32 +0100 | [diff] [blame] | 237 | std::string locationString = pathToSchemaString(location, Prefixes::Always); |
Václav Kubernát | 6a8d1d9 | 2019-04-24 20:30:36 +0200 | [diff] [blame] | 238 | auto leaf{boost::get<yang::leaf>(children(locationString).at(fullNodeName(location, node)))}; |
| 239 | auto locationOfSource = stripLastNodeFromPath(leaf.m_leafRefSource); |
| 240 | auto nameOfSource = lastNodeOfSchemaPath(leaf.m_leafRefSource); |
| 241 | return boost::get<yang::leaf>(children(locationOfSource).at(nameOfSource)).m_type; |
| 242 | } |
| 243 | |
Václav Kubernát | 2eaceb8 | 2018-10-08 19:56:30 +0200 | [diff] [blame] | 244 | yang::LeafDataTypes StaticSchema::leafType(const schemaPath_& location, const ModuleNodePair& node) const |
Václav Kubernát | bddbb17 | 2018-06-13 16:27:39 +0200 | [diff] [blame] | 245 | { |
Václav Kubernát | efcac93 | 2020-01-10 15:26:32 +0100 | [diff] [blame] | 246 | std::string locationString = pathToSchemaString(location, Prefixes::Always); |
Václav Kubernát | 744f57f | 2018-06-29 22:46:26 +0200 | [diff] [blame] | 247 | return boost::get<yang::leaf>(children(locationString).at(fullNodeName(location, node))).m_type; |
| 248 | } |
| 249 | |
Václav Kubernát | 989b5de | 2019-02-20 16:28:35 +0100 | [diff] [blame] | 250 | const std::set<std::string> StaticSchema::enumValues(const schemaPath_& location, const ModuleNodePair& node) const |
| 251 | { |
Václav Kubernát | efcac93 | 2020-01-10 15:26:32 +0100 | [diff] [blame] | 252 | std::string locationString = pathToSchemaString(location, Prefixes::Always); |
Václav Kubernát | 989b5de | 2019-02-20 16:28:35 +0100 | [diff] [blame] | 253 | assert(isLeaf(location, node)); |
| 254 | |
| 255 | const auto& child = children(locationString).at(fullNodeName(location, node)); |
| 256 | const auto& leaf = boost::get<yang::leaf>(child); |
| 257 | return leaf.m_enumValues; |
| 258 | } |
| 259 | |
Václav Kubernát | e7d4aea | 2018-09-11 18:15:48 +0200 | [diff] [blame] | 260 | // We do not test StaticSchema, so we don't need to implement recursive childNodes |
| 261 | // for this class. |
Václav Kubernát | 2eaceb8 | 2018-10-08 19:56:30 +0200 | [diff] [blame] | 262 | std::set<std::string> StaticSchema::childNodes(const schemaPath_& path, const Recursion) const |
Václav Kubernát | 744f57f | 2018-06-29 22:46:26 +0200 | [diff] [blame] | 263 | { |
Václav Kubernát | efcac93 | 2020-01-10 15:26:32 +0100 | [diff] [blame] | 264 | std::string locationString = pathToSchemaString(path, Prefixes::Always); |
Václav Kubernát | 744f57f | 2018-06-29 22:46:26 +0200 | [diff] [blame] | 265 | std::set<std::string> res; |
| 266 | |
| 267 | auto childrenRef = children(locationString); |
| 268 | |
Václav Kubernát | 90de950 | 2019-11-20 17:19:44 +0100 | [diff] [blame] | 269 | std::transform(childrenRef.begin(), childrenRef.end(), std::inserter(res, res.end()), [](auto it) { return it.first; }); |
Václav Kubernát | 744f57f | 2018-06-29 22:46:26 +0200 | [diff] [blame] | 270 | return res; |
Václav Kubernát | bddbb17 | 2018-06-13 16:27:39 +0200 | [diff] [blame] | 271 | } |
Václav Kubernát | 9456b5c | 2019-10-02 21:14:52 +0200 | [diff] [blame] | 272 | |
| 273 | // We do not test StaticSchema, so we don't need to implement recursive moduleNodes |
| 274 | // for this class. |
| 275 | std::set<std::string> StaticSchema::moduleNodes(const module_& module, const Recursion) const |
| 276 | { |
| 277 | std::set<std::string> res; |
| 278 | auto topLevelNodes = m_nodes.at(""); |
| 279 | auto modulePlusColon = module.m_name + ":"; |
| 280 | for (const auto& it : topLevelNodes) { |
| 281 | if (boost::algorithm::starts_with(it.first, modulePlusColon)) { |
| 282 | res.insert(it.first); |
| 283 | } |
| 284 | } |
| 285 | return res; |
| 286 | } |