33 : _fieldname(name), _type(type), _is_array(false), _array_size(1)
39 static const std::regex type_regex(
"[a-zA-Z][a-zA-Z0-9_]*"
40 "(/[a-zA-Z][a-zA-Z0-9_]*){0,1}"
41 "(\\[[0-9]*\\]){0,1}");
43 static const std::regex field_regex(
"[a-zA-Z][a-zA-Z0-9_]*");
45 static const std::regex array_regex(
"(.+)(\\[([0-9]*)\\])");
48 std::string::const_iterator begin =
definition.begin();
49 std::string::const_iterator end =
definition.end();
50 std::match_results<std::string::const_iterator> what;
57 if (std::regex_search(begin, end, what, type_regex))
60 begin = what[0].second;
64 throw std::runtime_error(
"Bad type when parsing field: " +
definition);
67 if (regex_search(begin, end, what, field_regex))
70 begin = what[0].second;
74 throw std::runtime_error(
"Bad field when parsing field: " +
definition);
77 std::string temp_type =
type;
78 if (regex_search(temp_type, what, array_regex))
87 else if (what.size() == 4)
89 std::string
size(what[3].
first, what[3].second);
95 throw std::runtime_error(
"Bad array size when parsing field: " +
definition);
104 if (regex_search(begin, end, what, std::regex(
"\\S")))
108 begin = what[0].second;
110 if (
type ==
"string")
112 value.assign(begin, end);
116 if (regex_search(begin, end, what, std::regex(
"\\s*#")))
122 value.assign(begin, end);
129 else if (what[0] ==
"#")
135 if (regex_search(begin, end, what, std::regex(
"\\s*#")))
141 value.assign(begin, end);
150 std::shared_ptr<ROSMessage>
162 if (it == library.end())
173 s.erase(
s.begin(), std::find_if(
s.begin(),
s.end(),
174 [](
unsigned char ch) { return !std::isspace(ch); }));
179 s.erase(std::find_if(
s.rbegin(),
s.rend(),
180 [](
unsigned char ch) { return !std::isspace(ch); })