MCPcopy Create free account
hub / github.com/Barracuda09/SATPI / parseCommandArgumentString

Method parseCommandArgumentString

src/StringConverter.cpp:342–375  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

340}
341
342StringVector StringConverter::parseCommandArgumentString(const std::string &cmd) {
343 std::string arg;
344 StringVector argVector;
345 size_t quoteCount = 0;
346 bool inQuote = false;
347 for (size_t i = 0; i < cmd.size(); ++i) {
348 if (cmd[i] == '"') {
349 ++quoteCount;
350 if (quoteCount == 3) {
351 quoteCount = 0;
352 arg += cmd[i];
353 }
354 continue;
355 }
356 if (quoteCount > 0) {
357 if (quoteCount == 1) {
358 inQuote = !inQuote;
359 }
360 quoteCount = 0;
361 }
362 if (!inQuote && cmd[i] == ' ') {
363 if (!arg.empty()) {
364 argVector.push_back(arg);
365 arg.clear();
366 }
367 } else {
368 arg += cmd[i];
369 }
370 }
371 if (!arg.empty()) {
372 argVector.push_back(arg);
373 }
374 return argVector;
375}
376
377double StringConverter::getDoubleParameter(const std::string &msg,
378 const std::string &header_field, const std::string &parameter) {

Callers

nothing calls this directly

Calls 1

clearMethod · 0.45

Tested by

no test coverage detected