114 std::vector<Argument> _args;
115 std::map<std::string, Var> _vars;
135 int GetVarInt(std::string name_,
int if_not_found_);
143 std::string
GetVarStr(std::string name_, std::string if_not_found_);
152 bool _SearchName(std::string name_,
Argument& dest_);
160 bool _SearchShortAlias(std::string short_alias_,
Argument& dest_);
163 std::string _cur_name;
198 std::string short_alias_,
Class for parsing command line arguments.
Definition argparse.h:113
int GetVarInt(std::string name_, int if_not_found_)
Get the integer value of a variable.
Definition argparse.cpp:111
bool _showed_help
Flag indicating whether help was shown.
Definition argparse.h:181
Result
Enumeration of possible results from parsing arguments.
Definition argparse.h:121
@ UNKNOWN_FLAG
Unknown flag encountered.
Definition argparse.h:124
@ SHOWED_HELP
Help message was shown.
Definition argparse.h:123
@ BAD_PARAM
Bad parameter provided.
Definition argparse.h:125
@ UNKNOWN_VAR
Unknown variable encountered.
Definition argparse.h:126
@ OK
Parsing successful.
Definition argparse.h:122
void ShowHelp()
Display help information for all arguments.
Definition argparse.cpp:102
Result ParseArgs(const std::vector< std::string > &args)
Parse command line arguments.
Definition argparse.cpp:58
int AddArgument(std::string name_, std::string short_alias_, std::string help_, Argument::Action action_=Argument::store_true)
Add an argument to the parser.
Definition argparse.cpp:141
ArgumentParser()
Constructor for ArgumentParser.
Definition argparse.cpp:181
std::string GetVarStr(std::string name_, std::string if_not_found_)
Get the string value of a variable.
Definition argparse.cpp:116
Structure representing a command line argument.
Definition argparse.h:71
Action
Enumeration of possible actions for an argument.
Definition argparse.h:79
@ do_nothing
No action.
Definition argparse.h:80
@ show_help
Show help message.
Definition argparse.h:83
@ store_true
Store true (1)
Definition argparse.h:82
@ store_false
Store false (0)
Definition argparse.h:81
void ShowHelp() const
Display help information for the argument.
Definition argparse.cpp:54
std::string _help
Help description for the argument.
Definition argparse.h:74
Action _action
Action associated with the argument.
Definition argparse.h:86
std::string _name
Full name of the argument (e.g., –help)
Definition argparse.h:72
std::string _short_alias
Short alias for the argument (e.g., -h)
Definition argparse.h:73
Structure representing a variable associated with an argument.
Definition argparse.h:97
void Clear()
Clear the variable values.
Definition argparse.h:104
std::string _str
String value of the variable.
Definition argparse.h:99
int _val
Integer value of the variable.
Definition argparse.h:98