|
g2o
|
Command line parsing of argc and argv. More...
#include <command_args.h>
Classes | |
| struct | CommandArgument |
Public Member Functions | |
| virtual | ~CommandArgs () |
| bool | parseArgs (int argc, char **argv, bool exitOnError=true) |
| 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 | param (const std::string &name, std::vector< int > &p, const std::vector< int > &defValue, const std::string &desc) |
| void | param (const std::string &name, std::vector< double > &p, const std::vector< double > &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) |
| void | printParams (std::ostream &os) |
| const std::string & | getBanner () const |
| return the banner string | |
| void | setBanner (const std::string &banner) |
| void | printHelp (std::ostream &os) |
| bool | parsedParam (const std::string ¶mFlag) const |
Protected Member Functions | |
| const char * | type2str (int t) const |
| void | str2arg (const std::string &input, CommandArgument &ca) const |
| std::string | arg2str (const CommandArgument &ca) const |
Protected Attributes | |
| std::vector< CommandArgument > | _args |
| std::vector< CommandArgument > | _leftOvers |
| std::vector< CommandArgument > | _leftOversOptional |
| std::string | _banner |
| 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 45 of file command_args.h.
|
virtual |
Definition at line 104 of file command_args.cpp.
|
protected |
Definition at line 395 of file command_args.cpp.
References g2o::CAT_BOOL, g2o::CAT_DOUBLE, g2o::CAT_FLOAT, g2o::CAT_INT, g2o::CAT_STRING, g2o::CAT_VECTOR_DOUBLE, g2o::CAT_VECTOR_INT, g2o::CommandArgs::CommandArgument::data, and g2o::CommandArgs::CommandArgument::type.
Referenced by printHelp().
|
inline |
| 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 188 of file command_args.cpp.
References _args, g2o::CAT_BOOL, g2o::CommandArgs::CommandArgument::data, g2o::CommandArgs::CommandArgument::description, g2o::CommandArgs::CommandArgument::name, g2o::CommandArgs::CommandArgument::parsed, and g2o::CommandArgs::CommandArgument::type.
Referenced by main(), parsedParam(), and g2o::RunG2OViewer::run().
| void g2o::CommandArgs::param | ( | const std::string & | name, |
| double & | p, | ||
| double | defValue, | ||
| const std::string & | desc | ||
| ) |
add a float parameter
Definition at line 224 of file command_args.cpp.
References _args, g2o::CAT_DOUBLE, g2o::CommandArgs::CommandArgument::data, g2o::CommandArgs::CommandArgument::description, g2o::CommandArgs::CommandArgument::name, g2o::CommandArgs::CommandArgument::parsed, and g2o::CommandArgs::CommandArgument::type.
| void g2o::CommandArgs::param | ( | const std::string & | name, |
| float & | p, | ||
| float | defValue, | ||
| const std::string & | desc | ||
| ) |
add a float parameter
Definition at line 212 of file command_args.cpp.
References _args, g2o::CAT_FLOAT, g2o::CommandArgs::CommandArgument::data, g2o::CommandArgs::CommandArgument::description, g2o::CommandArgs::CommandArgument::name, g2o::CommandArgs::CommandArgument::parsed, and g2o::CommandArgs::CommandArgument::type.
| void g2o::CommandArgs::param | ( | const std::string & | name, |
| int & | p, | ||
| int | defValue, | ||
| const std::string & | desc | ||
| ) |
add a int parameter
Definition at line 200 of file command_args.cpp.
References _args, g2o::CAT_INT, g2o::CommandArgs::CommandArgument::data, g2o::CommandArgs::CommandArgument::description, g2o::CommandArgs::CommandArgument::name, g2o::CommandArgs::CommandArgument::parsed, and g2o::CommandArgs::CommandArgument::type.
| 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 236 of file command_args.cpp.
References _args, g2o::CAT_STRING, g2o::CommandArgs::CommandArgument::data, g2o::CommandArgs::CommandArgument::description, g2o::CommandArgs::CommandArgument::name, g2o::CommandArgs::CommandArgument::parsed, and g2o::CommandArgs::CommandArgument::type.
| void g2o::CommandArgs::param | ( | const std::string & | name, |
| std::vector< double > & | p, | ||
| const std::vector< double > & | defValue, | ||
| const std::string & | desc | ||
| ) |
add an vector of doubles as a parameter
Definition at line 261 of file command_args.cpp.
References _args, g2o::CAT_VECTOR_DOUBLE, g2o::CommandArgs::CommandArgument::data, g2o::CommandArgs::CommandArgument::description, g2o::CommandArgs::CommandArgument::name, g2o::CommandArgs::CommandArgument::parsed, and g2o::CommandArgs::CommandArgument::type.
| void g2o::CommandArgs::param | ( | const std::string & | name, |
| std::vector< int > & | p, | ||
| const std::vector< int > & | defValue, | ||
| const std::string & | desc | ||
| ) |
add an int vector parameter
Definition at line 248 of file command_args.cpp.
References _args, g2o::CAT_VECTOR_INT, g2o::CommandArgs::CommandArgument::data, g2o::CommandArgs::CommandArgument::description, g2o::CommandArgs::CommandArgument::name, g2o::CommandArgs::CommandArgument::parsed, and g2o::CommandArgs::CommandArgument::type.
| 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 which is specified as a plain argument
Definition at line 331 of file command_args.cpp.
References _leftOvers, _leftOversOptional, g2o::CAT_STRING, g2o::CommandArgs::CommandArgument::data, g2o::CommandArgs::CommandArgument::description, g2o::CommandArgs::CommandArgument::name, g2o::CommandArgs::CommandArgument::optional, g2o::CommandArgs::CommandArgument::parsed, and g2o::CommandArgs::CommandArgument::type.
Referenced by main(), and g2o::RunG2OViewer::run().
| 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 106 of file command_args.cpp.
References _args, _leftOvers, _leftOversOptional, _progName, g2o::CAT_BOOL, printHelp(), and str2arg().
Referenced by main(), and g2o::RunG2OViewer::run().
| bool g2o::CommandArgs::parsedParam | ( | const std::string & | paramFlag | ) | const |
returns true, if the param was parsed via the command line
Definition at line 421 of file command_args.cpp.
References _args, and param().
Referenced by main().
| void g2o::CommandArgs::printHelp | ( | std::ostream & | os | ) |
print the help
Definition at line 274 of file command_args.cpp.
References _args, _banner, _leftOvers, _leftOversOptional, _progName, arg2str(), g2o::CAT_BOOL, and type2str().
Referenced by parseArgs().
| void g2o::CommandArgs::printParams | ( | std::ostream & | os | ) |
print the value of all params to an ostream
| void g2o::CommandArgs::setBanner | ( | const std::string & | banner | ) |
|
protected |
Definition at line 368 of file command_args.cpp.
References g2o::CAT_BOOL, g2o::CAT_DOUBLE, g2o::CAT_FLOAT, g2o::CAT_INT, g2o::CAT_STRING, g2o::CAT_VECTOR_DOUBLE, g2o::CAT_VECTOR_INT, g2o::CommandArgs::CommandArgument::data, and g2o::CommandArgs::CommandArgument::type.
Referenced by parseArgs().
|
protected |
Definition at line 348 of file command_args.cpp.
References g2o::CAT_BOOL, g2o::CAT_DOUBLE, g2o::CAT_FLOAT, g2o::CAT_INT, g2o::CAT_STRING, g2o::CAT_VECTOR_DOUBLE, and g2o::CAT_VECTOR_INT.
Referenced by printHelp().
|
protected |
Definition at line 122 of file command_args.h.
Referenced by param(), param(), param(), param(), param(), param(), param(), parseArgs(), parsedParam(), and printHelp().
|
protected |
Definition at line 125 of file command_args.h.
Referenced by printHelp(), and setBanner().
|
protected |
Definition at line 123 of file command_args.h.
Referenced by paramLeftOver(), parseArgs(), and printHelp().
|
protected |
Definition at line 124 of file command_args.h.
Referenced by paramLeftOver(), parseArgs(), and printHelp().
|
protected |
Definition at line 126 of file command_args.h.
Referenced by parseArgs(), and printHelp().