fwt_software/include/fgc/CommandParser.h

29 lines
882 B
C++

#pragma once
#include <string>
namespace fgc {
// A parsed console command line: "<verb> [device] [option] [value]".
// Examples:
// "snapshot" -> verb=snapshot
// "capture on" -> verb=capture device=on
// "gimbal nudge yaw 5" -> verb=gimbal device=nudge option=yaw value=5
// "set camera profile night" -> verb=set device=camera option="profile night"
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