17 virtual bool parse(std::string argument)
const = 0;
18 virtual void print()
const = 0;
23 std::vector<Parser*> parsers;
27 void add_parser(
Parser* p) {
31 bool parse(std::string argument)
const {
32 for (
int i = 0; i < parsers.size(); i++) {
33 if (parsers[i]->parse(argument)) {
41 for (
int i = 0; i < parsers.size(); i++) {
48 template <
typename ArgType>
51 std::string name, description;
55 Argument(std::string n, std::string d, ArgType& l)
56 : name(n), description(d), location(l) {}
58 bool parse(std::string argument)
const {
59 std::stringstream stream(argument);
61 std::getline(stream, lhs,
'=');
62 std::getline(stream, rhs,
'=');
67 }
else if (rhs.length() == 0) {
70 std::stringstream rhs_stream(rhs);
71 rhs_stream >> location;
77 CkPrintf(
"%24s: %s\n", name.c_str(), description.c_str());
92 std::map<std::string, uint8_t> indices;
106 template <
typename ArgType>
108 if (indices.find(name) != indices.end()) {
110 CkPrintf(
"Duplicate argument registration: %s\n", name.c_str());
111 CkAbort(
"Argument parse error\n");
114 indices[name] = parsers.size();
119 CkPrintf(
"\n%s %s\n", std::string(25,
'=').c_str(), name.c_str());
120 AggregateParser::print();
126 void parse_command_line(
int argc,
char** argv);
Definition: command_line.h:21
void tw_add_arguments(ArgumentSet *args)
Add a new set of arguments for the simulator to parse.
Definition: command_line.C:8
Definition: command_line.h:15
void register_argument(std::string name, std::string desc, ArgType &loc)
Register a new command line argument to be parsed.
Definition: command_line.h:107
ArgumentSet(std::string n)
Definition: command_line.h:98
Class for a set of arguments that can be read from the command line.
Definition: command_line.h:89
Definition: command_line.h:49