11 colors.resize(input.size());
15 auto currentColor = replxx::Replxx::Color::BRIGHTMAGENTA;
18 for (; location < input.size() && input[location] ==
' '; ++location)
20 colors[location] = replxx::Replxx::Color::DEFAULT;
24 for (; location < input.size(); ++location)
26 if (input[location] !=
' ')
28 colors[location] = replxx::Replxx::Color::BRIGHTMAGENTA;
38 while (location < input.size())
41 size_t nextSpace = input.find(
' ', location);
42 size_t nextAssignment = input.find(
'=', location);
43 if (nextSpace == location)
46 colors[location] = replxx::Replxx::Color::DEFAULT;
52 auto color = replxx::Replxx::Color::WHITE;
53 if (nextAssignment == location)
56 color = replxx::Replxx::Color::BRIGHTRED;
60 if (nextAssignment == std::string::npos)
65 color = replxx::Replxx::Color::BRIGHTCYAN;
70 color = replxx::Replxx::Color::BRIGHTRED;
76 if (nextAssignment < nextSpace || nextSpace == std::string::npos)
78 color = replxx::Replxx::Color::WHITE;
85 color = replxx::Replxx::Color::BRIGHTCYAN;
90 color = replxx::Replxx::Color::BRIGHTRED;
97 for (; location < input.size() && input[location] !=
' '; ++location)
99 colors[location] = color;
112 size_t location = input.find(
' ');
115 throw Exception(
"Syntax error: empty command");
117 else if (location == std::string::npos)
122 else if (location == 0)
125 input = input.substr(1);
136 input = input.substr(location + 1);
140 while (!input.empty())
143 size_t nextSpace = input.find(
' ');
144 size_t nextAssignment = input.find(
'=');
150 input = input.substr(1);
152 else if (nextAssignment == 0)
154 throw Exception(
"Syntax error: empty key for parameter");
156 else if (nextSpace == std::string::npos)
158 if (nextAssignment == std::string::npos)
167 throw Exception(
"Syntax error: stray name or path");
173 std::string key = input.substr(0, nextAssignment);
176 command._parameters[key] = input.substr(nextAssignment + 1);
180 throw Exception(
"Syntax error: duplicate parameter");
189 if (nextAssignment > nextSpace)
194 command._path = input.substr(0, nextSpace);
198 throw Exception(
"Syntax error: stray name or path");
204 std::string key = input.substr(0, nextAssignment);
207 command._parameters[key] = input.substr(nextAssignment + 1, nextSpace - nextAssignment - 1);
211 throw Exception(
"Syntax error: duplicate parameter");
216 input = input.substr(nextSpace + 1);
232 std::regex matcher(pattern, std::regex_constants::icase);
235 return std::regex_match(
_verb, matcher);
Exception class thrown by all library classes.
ROSLIB_DECL std::string command(const std::string &cmd)