fwt_software/include/fgc/CommandParser.h

29 lines
863 B
C++

#pragma once
#include <string>
namespace fgc {
// A parsed console command line: "<verb> [device] [option] [value]".
// Examples:
// "start" -> verb=start
// "set fps 5" -> verb=set device=fps value=5
// "set camera jxlq 2" -> verb=set device=camera option=jxlq value=2
// "set motorctl kd180" -> verb=set device=motorctl option=kd180
struct Command {
std::string verb;
std::string device;
std::string option;
double value = 0.0;
bool has_value = false;
bool empty() const { return verb.empty(); }
};
// Whitespace-tokenizing parser. Robust to commands with or without a trailing
// numeric value and to non-numeric option strings (e.g. raw motor commands).
// Replaces the fragile Boost.Spirit Qi grammar.
Command parseCommand(const std::string& line);
} // namespace fgc