Go to the documentation of this file.
26 #include <SimoxUtility/algorithm/string/string_tools.h>
37 simox::alg::to_<int>(
s);
39 catch (simox::error::SimoxError&)
52 __PRETTY_FUNCTION__,
"Could not convert a string to an integer",
s);
61 simox::alg::to_<float>(
s);
63 catch (simox::error::SimoxError&)
76 __PRETTY_FUNCTION__,
"Could not convert a string to a floating point",
s);
92 __PRETTY_FUNCTION__,
"Could not convert a string to a number",
s);
100 for (
const auto& e :
split)
117 "Could not convert a string to a sequence of numbers. Note that number sequences "
118 "have to separated with ','",
128 simox::alg::to_<bool>(
s);
130 catch (simox::error::SimoxError&)
143 __PRETTY_FUNCTION__,
"Could not convert a string to a bool",
s);
147 std::optional<RapidXmlReaderNode>
150 for (
const auto& n : node.
nodes())
167 "A <" + node.
name() +
">-tag does not have the '" +
188 const std::string& att,
189 const std::string& def)
204 if (
v ==
"1" or
v ==
"true" or
v ==
"yes" or
v ==
"ja" or
v ==
"")
215 return (simox::alg::to_lower(name) == simox::alg::to_lower(node.
name()));
224 __PRETTY_FUNCTION__,
"The node has the wrong tag. Expected: " + name, node.
name());
231 for (
const auto& name :
names)
239 "The node has the wrong tag. Expected one of: " +
247 return simox::alg::to_lower(node.
name());
253 const size_t s = node.
nodes().size();
257 "The node <" + node.
name() +
258 "> has the wrong number of children",
267 const size_t s = node.
nodes().size();
271 "The node <" + node.
name() +
272 "> has the wrong number of children",
281 const size_t s = node.
nodes().size();
285 "The node <" + node.
name() +
286 "> has the wrong number of children",
295 const size_t s = node.
nodes().size();
299 "The node <" + node.
name() +
300 "> has the wrong number of children",
309 const size_t s = node.
nodes().size();
313 "The node <" + node.
name() +
314 "> has the wrong number of children",
bool HasAttribute(const RapidXmlReaderNode &node, const std::string &att)
bool CheckStrIsNumber(const std::string &)
bool CheckStrIsNumberSeq(const std::string &)
void EnforceTagNames(const RapidXmlReaderNode &node, const std::vector< std::string > &names)
std::string GetAttributeWithDefault(const RapidXmlReaderNode &node, const std::string &att, const std::string &def)
void EnforceTagName(const RapidXmlReaderNode &node, const std::string &name)
bool CheckStrIsFloat(const std::string &)
void EnforceStrIsInt(const std::string &)
std::string attribute_value(const char *attrName) const
bool CheckStrIsBool(const std::string &)
void EnforceChildSize(const RapidXmlReaderNode &node, const size_t size)
bool HasTagName(const RapidXmlReaderNode &node, const std::string &name)
All constantes for the aron XML parser, in addition to some utility functions wrapping around the arm...
std::vector< std::pair< std::string, std::string > > get_all_attributes() const
bool has_attribute(const char *attrName) const
std::optional< RapidXmlReaderNode > GetFirstNodeWithTag(const RapidXmlReaderNode &node, const std::string &name)
The ValueNotValidException class.
void EnforceStrIsNumberSeq(const std::string &)
std::string GetTagName(const RapidXmlReaderNode &node)
const std::string & to_string(const std::string &s)
void EnforceStrIsFloat(const std::string &)
double v(double t, double v0, double a0, double j)
void EnforceChildSizeGreaterEqual(const RapidXmlReaderNode &node, const size_t size)
std::string GetAttribute(const RapidXmlReaderNode &node, const std::string &att)
const simox::meta::IntEnumNames names
void EnforceAttribute(const RapidXmlReaderNode &node, const std::string &att)
void EnforceChildSizeSmallerEqual(const RapidXmlReaderNode &node, const size_t size)
std::vector< RapidXmlReaderNode > nodes(const char *name=nullptr) const
void EnforceStrIsBool(const std::string &)
bool CheckStrIsInt(const std::string &)
void EnforceChildSizeSmaller(const RapidXmlReaderNode &node, const size_t size)
double s(double t, double s0, double v0, double a0, double j)
void EnforceChildSizeGreater(const RapidXmlReaderNode &node, const size_t size)
void EnforceStrIsNumber(const std::string &)
std::vector< std::string > split(const std::string &source, const std::string &splitBy, bool trimElements=false, bool removeEmptyElements=false)
bool AttributeIsTrue(const RapidXmlReaderNode &node, const std::string &att)