39 std::vector<RapidXmlReaderNode> nodes;
47 "DefaultRapidXmlWrapper NullPointerException");
52 get_attrib_value(
const char* attrName)
const
55 for (
auto& node : nodes)
57 if (node.has_attribute(attrName))
59 return node.attribute_value(attrName);
67 "' does not exist in node " +
92 "DefaultRapidXmlWrapper NullPointerException in constructor");
95 reverse(rnodes.begin(), rnodes.end());
96 nodes = std::move(rnodes);
114 std::vector<RapidXmlReaderNode>
v;
117 if (n.get_node_ptr()->first_node(name) !=
nullptr)
119 v.push_back(n.first_node(name));
124 std::stringstream ch;
127 std::string(
"Node with name '") + name +
"' does not exist in node " +
146 if (n.has_attribute(attrName))
156 const std::string& trueValue,
157 const std::string& falseValue)
const
164 const std::string& trueValue,
165 const std::string& falseValue)
const
167 std::string
value = std::string(get_attrib_value(attrName));
169 if (
value == trueValue)
173 else if (
value == falseValue)
180 std::string(
"Invalid value '") +
value +
"' for attribute '" + attrName +
181 "'. Expecting '" + trueValue +
"' or '" + falseValue +
"'.");
187 const std::string& trueValue,
188 const std::string& falseValue,
189 bool defaultValue)
const
196 const std::string& trueValue,
197 const std::string& falseValue,
198 bool defaultValue)
const
207 std::string
value = std::string(get_attrib_value(name));
209 if (
value == trueValue)
213 else if (
value == falseValue)
220 std::string(
"Invalid value '") +
value +
"' for attribute '" + name +
221 "'. Expecting '" + trueValue +
"' or '" + falseValue +
"'.");
234 return std::string(get_attrib_value(attrName));
248 std::stringstream(get_attrib_value(attrName)) >>
value;
255 return attribute_as<T>(attrName.c_str());
276 return attribute_as<float>(attrName);
288 return attribute_as<uint32_t>(attrName);
295 return std::string(get_value());
302 std::stringstream strValue(get_value());
304 strValue >> retValue;
312 return static_cast<uint32_t
>(std::stoul(get_value(),
nullptr, 0));
319 return static_cast<uint16_t
>(std::stoul(get_value(),
nullptr, 0));
326 return static_cast<int32_t
>(std::stoul(get_value(),
nullptr, 0));
333 return static_cast<int16_t
>(std::stoul(get_value(),
nullptr, 0));
337 value_as_bool(
const std::string& trueValue,
const std::string& falseValue)
const
340 std::string
value = std::string(get_value());
341 if (
value == trueValue)
345 else if (
value == falseValue)
354 s += std::string(node.name());
357 s =
s.substr(0,
s.length() - 2);
360 std::string(
"Invalid value '") +
value +
"' for represented nodes " +
s +
361 ". Expecting '" + trueValue +
"' or '" + falseValue +
"'.");
367 const std::string& falseValue,
368 bool defaultValue)
const
371 std::string
value = std::string(get_value());
372 if (
value == trueValue)
376 else if (
value == falseValue)
389 return !nodes.empty();
392 std::vector<std::string>
396 std::set<std::string> results;
399 const auto paths = n.getChildPaths();
400 results.insert(paths.begin(), paths.end());
402 return {results.begin(), results.end()};
405 std::vector<std::string>
409 std::vector<std::string> results;
412 results.push_back(n.getPath());
420 std::vector<std::string> paths =
getPaths();
421 std::string all_paths;
422 for (std::string path : paths)
427 all_paths = all_paths.substr(0, all_paths.length() - 4);
444 add_node_at(std::vector<RapidXmlReaderNode> added_nodes,
size_t position)
446 if (position > nodes.size())
449 "The index is out of range: given index ")
450 << position <<
" size of container: " << nodes.size();
453 if (!added_nodes.empty())
455 std::vector<RapidXmlReaderNode>
v;
456 v.reserve(added_nodes.size() + nodes.size());
457 for (
auto& node : added_nodes)
461 v.emplace_back(std::move(node));
466 const auto n_inserted =
v.size();
467 v.insert(
v.end(), nodes.rbegin(), nodes.rend());
470 std::rotate(it, it + n_inserted, it + n_inserted + position);
486 if (pos >= nodes.size())
488 pos = nodes.size() - 1;
492 std::vector<RapidXmlReaderNode>
v = nodes;
494 v.erase(
v.begin() + pos);