9 #include <boost/algorithm/string/predicate.hpp> 21 static XmlRpcValueCreator createArray(
const std::vector<XmlRpcValue>&
values)
23 XmlRpcValueCreator ret;
24 ret._type = TypeArray;
25 ret._value.asArray =
new ValueArray(values);
30 static XmlRpcValueCreator createStruct(
const std::map<std::string, XmlRpcValue>& members)
32 XmlRpcValueCreator ret;
33 ret._type = TypeStruct;
34 ret._value.asStruct =
new std::map<std::string, XmlRpcValue>(members);
42 if(n.Type() != YAML::NodeType::Scalar)
46 case YAML::NodeType::Map:
48 std::map<std::string, XmlRpc::XmlRpcValue> members;
49 for(YAML::const_iterator it = n.begin(); it != n.end(); ++it)
51 members[it->first.as<std::string>()] =
yamlToXmlRpc(ctx, it->second);
53 return XmlRpcValueCreator::createStruct(members);
55 case YAML::NodeType::Sequence:
57 std::vector<XmlRpc::XmlRpcValue>
values;
58 for(YAML::const_iterator it = n.begin(); it != n.end(); ++it)
62 return XmlRpcValueCreator::createArray(values);
65 throw ctx.
error(
"Invalid YAML node type");
73 if(n.Tag() ==
"tag:yaml.org,2002:int")
75 if(n.Tag() ==
"tag:yaml.org,2002:float")
77 if(n.Tag() ==
"tag:yaml.org,2002:bool")
79 if(n.Tag() ==
"tag:yaml.org,2002:str")
81 if(n.Tag() ==
"tag:yaml.org,2002:binary")
83 auto binary = n.as<YAML::Binary>();
87 std::vector<unsigned char> copy(binary.data(), binary.data()+binary.size());
93 if(n.Tag() ==
"!degrees")
104 if(n.Tag() ==
"!radians")
124 catch(YAML::Exception&) {}
127 catch(YAML::Exception&) {}
130 catch(YAML::Exception&) {}
134 std::string str = n.as<std::string>();
139 if(boost::starts_with(str,
"deg(") && boost::ends_with(str,
")"))
153 if(boost::starts_with(str,
"rad(") && boost::ends_with(str,
")"))
167 catch(YAML::Exception&) {}
169 throw ctx.
error(
"Could not convert YAML value");
virtual const char * what() const noexceptoverride
double evaluateROSParamPython(const std::string &input)
Evaluate a deg(...) rosparam expression.
ParseException error(const char *fmt, const Args &...args) const
XmlRpc::XmlRpcValue yamlToXmlRpc(const ParseContext &ctx, const YAML::Node &n)