g2o
|
Command line parsing of argc and argv. More...
#include <command_args.h>
Classes | |
struct | CommandArgument |
Public Member Functions | |
CommandArgs () | |
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 More... | |
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 |
std::string | trim (const std::string &s) 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 46 of file command_args.h.
g2o::CommandArgs::CommandArgs | ( | ) |
Definition at line 103 of file command_args.cpp.
|
virtual |
Definition at line 107 of file command_args.cpp.
|
protected |
Definition at line 451 of file command_args.cpp.
References g2o::CAT_BOOL, g2o::CAT_DOUBLE, g2o::CAT_FLOAT, g2o::CAT_INT, g2o::CAT_STRING, g2o::CAT_VECTOR_INT, g2o::CommandArgs::CommandArgument::data, and g2o::CommandArgs::CommandArgument::type.
|
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 198 of file command_args.cpp.
References 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().
void g2o::CommandArgs::param | ( | const std::string & | name, |
int & | p, | ||
int | defValue, | ||
const std::string & | desc | ||
) |
add a int parameter
Definition at line 210 of file command_args.cpp.
References 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, |
float & | p, | ||
float | defValue, | ||
const std::string & | desc | ||
) |
add a float parameter
Definition at line 222 of file command_args.cpp.
References 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, |
double & | p, | ||
double | defValue, | ||
const std::string & | desc | ||
) |
add a float parameter
Definition at line 234 of file command_args.cpp.
References 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, |
std::string & | p, | ||
const std::string & | defValue, | ||
const std::string & | desc | ||
) |
add a string parameter
Definition at line 246 of file command_args.cpp.
References 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< int > & | p, | ||
const std::vector< int > & | defValue, | ||
const std::string & | desc | ||
) |
add an int vector parameter
Definition at line 258 of file command_args.cpp.
References 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::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 269 of file command_args.cpp.
References 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::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 342 of file command_args.cpp.
References 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 111 of file command_args.cpp.
References g2o::CAT_BOOL.
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 548 of file command_args.cpp.
Referenced by main().
void g2o::CommandArgs::printHelp | ( | std::ostream & | os | ) |
print the help
Definition at line 281 of file command_args.cpp.
References g2o::CAT_BOOL.
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 337 of file command_args.cpp.
|
protected |
Definition at line 379 of file command_args.cpp.
References g2o::CAT_BOOL, g2o::CAT_DOUBLE, g2o::CAT_FLOAT, g2o::CAT_INT, g2o::CAT_STRING, g2o::CAT_VECTOR_INT, g2o::convertString(), g2o::CommandArgs::CommandArgument::data, and g2o::CommandArgs::CommandArgument::type.
|
protected |
Definition at line 505 of file command_args.cpp.
|
protected |
Definition at line 358 of file command_args.cpp.
References g2o::CAT_BOOL, g2o::CAT_DOUBLE, g2o::CAT_FLOAT, g2o::CAT_INT, g2o::CAT_STRING, and g2o::CAT_VECTOR_INT.
|
protected |
Definition at line 110 of file command_args.h.
|
protected |
Definition at line 113 of file command_args.h.
|
protected |
Definition at line 111 of file command_args.h.
|
protected |
Definition at line 112 of file command_args.h.
|
protected |
Definition at line 114 of file command_args.h.