Command line parsing of argc and argv. More...
#include <command_args.h>
Classes | |
| struct | CmpPairFirst |
| struct | CommandArgument |
Public Member Functions | |
| CommandArgs () | |
| const std::string & | getBanner () const |
| return the banner string | |
| void | param (const std::string &name, bool &p, bool defValue, const std::string &desc) |
| void | param (const std::string &name, int &p, int defValue, const std::string &desc) |
| void | param (const std::string &name, float &p, float defValue, const std::string &desc) |
| void | param (const std::string &name, double &p, double defValue, const std::string &desc) |
| void | param (const std::string &name, std::string &p, const std::string &defValue, const std::string &desc) |
| void | paramLeftOver (const std::string &name, std::string &p, const std::string &defValue, const std::string &desc, bool optional=false) |
| bool | parseArgs (int argc, char **argv, bool exitOnError=true) |
| void | printHelp (std::ostream &os) |
| void | printParams (std::ostream &os) |
| void | setBanner (const std::string &banner) |
| virtual | ~CommandArgs () |
Protected Member Functions | |
| std::string | arg2str (const CommandArgument &ca) const |
| template<typename T > | |
| bool | convertString (const std::string &s, T &x) const |
| void | str2arg (const std::string &input, CommandArgument &ca) const |
| std::string | trim (const std::string &s) const |
| const char * | type2str (int t) const |
Protected Attributes | |
| std::vector< CommandArgument > | _args |
| std::string | _banner |
| std::vector< CommandArgument > | _leftOvers |
| std::vector< CommandArgument > | _leftOversOptional |
| std::string | _progName |
Command line parsing of argc and argv.
Parse the command line to get the program options. Additionally, we can store the config in a file and reload a parameter set from this file.
Definition at line 50 of file command_args.h.
Definition at line 49 of file command_args.cpp.
| g2o::CommandArgs::~CommandArgs | ( | ) | [virtual] |
Definition at line 53 of file command_args.cpp.
| std::string g2o::CommandArgs::arg2str | ( | const CommandArgument & | ca | ) | const [protected] |
Definition at line 345 of file command_args.cpp.
| bool g2o::CommandArgs::convertString | ( | const std::string & | s, |
| T & | x | ||
| ) | const [inline, protected] |
convert a string into an other type.
Definition at line 119 of file command_args.h.
| const std::string& g2o::CommandArgs::getBanner | ( | ) | const [inline] |
return the banner string
Definition at line 96 of file command_args.h.
| void g2o::CommandArgs::param | ( | const std::string & | name, |
| bool & | p, | ||
| bool | defValue, | ||
| const std::string & | desc | ||
| ) |
add a bool parameter, if found on the command line, will toggle defValue
Definition at line 144 of file command_args.cpp.
| void g2o::CommandArgs::param | ( | const std::string & | name, |
| int & | p, | ||
| int | defValue, | ||
| const std::string & | desc | ||
| ) |
add a int parameter
Definition at line 156 of file command_args.cpp.
| void g2o::CommandArgs::param | ( | const std::string & | name, |
| float & | p, | ||
| float | defValue, | ||
| const std::string & | desc | ||
| ) |
add a float parameter
Definition at line 168 of file command_args.cpp.
| void g2o::CommandArgs::param | ( | const std::string & | name, |
| double & | p, | ||
| double | defValue, | ||
| const std::string & | desc | ||
| ) |
add a float parameter
Definition at line 180 of file command_args.cpp.
| void g2o::CommandArgs::param | ( | const std::string & | name, |
| std::string & | p, | ||
| const std::string & | defValue, | ||
| const std::string & | desc | ||
| ) |
add a string parameter
Definition at line 243 of file command_args.cpp.
| void g2o::CommandArgs::paramLeftOver | ( | const std::string & | name, |
| std::string & | p, | ||
| const std::string & | defValue, | ||
| const std::string & | desc, | ||
| bool | optional = false |
||
| ) |
add a param wich is specified as a plain argument
Definition at line 260 of file command_args.cpp.
| bool g2o::CommandArgs::parseArgs | ( | int | argc, |
| char ** | argv, | ||
| bool | exitOnError = true |
||
| ) |
parse the command line for the requested parameters.
| argc | the number of params |
| argv | the value array |
| exitOnError | call exit() if the parsing fails |
Definition at line 57 of file command_args.cpp.
| void g2o::CommandArgs::printHelp | ( | std::ostream & | os | ) |
print the help
Definition at line 192 of file command_args.cpp.
| void g2o::CommandArgs::printParams | ( | std::ostream & | os | ) |
print the value of all params to an ostream
| void g2o::CommandArgs::setBanner | ( | const std::string & | banner | ) |
Definition at line 255 of file command_args.cpp.
| void g2o::CommandArgs::str2arg | ( | const std::string & | input, |
| CommandArgument & | ca | ||
| ) | const [protected] |
Definition at line 293 of file command_args.cpp.
| std::string g2o::CommandArgs::trim | ( | const std::string & | s | ) | const [protected] |
Definition at line 390 of file command_args.cpp.
| const char * g2o::CommandArgs::type2str | ( | int | t | ) | const [protected] |
Definition at line 276 of file command_args.cpp.
std::vector<CommandArgument> g2o::CommandArgs::_args [protected] |
Definition at line 105 of file command_args.h.
std::string g2o::CommandArgs::_banner [protected] |
Definition at line 108 of file command_args.h.
std::vector<CommandArgument> g2o::CommandArgs::_leftOvers [protected] |
Definition at line 106 of file command_args.h.
Definition at line 107 of file command_args.h.
std::string g2o::CommandArgs::_progName [protected] |
Definition at line 109 of file command_args.h.