Public Member Functions |
| CommandLineParser (int argc, const char *argv[]) |
| the default constructor
|
template<typename _Tp > |
_Tp | get (const std::string &name, const _Tp &default_value=_Tp()) |
| get parameter, if parameter is not given get default parameter
|
template<> |
CV_EXPORTS bool | get (const std::string &name, const bool &default_value) |
Protected Member Functions |
std::string | getString (const std::string &name) const |
bool | has (const std::string &keys) const |
template<typename _Tp > |
_Tp | fromStringNumber (const std::string &str) |
template<typename _Tp > |
_Tp | analyzeValue (const std::string &str) |
Static Protected Member Functions |
template<typename _Tp > |
static _Tp | getData (const std::string &str) |
Protected Attributes |
std::map< std::string,
std::string > | data |
Command Line Parser.
The class is used for reading command arguments. Supports the following syntax: -k=10 --key --db=-10.11 -key1 argument --inputFile=lena.jpg CommandLineParser parser(argc, argv); int k = parser.get<int>("k", -1); //these methods also work double db = parser.get<double>("db"); //with <float> and <unsigned int>=""> type bool key = parser.get<bool>("key"); <The method return 'true', if 'key' was defined in command line " and it will return 'false' otherwise.>
bool key1 = parser.get<bool>("key1"); The method return 'true', if 'key' was defined in command line
" and it will return 'false' otherwise.> string argument = parser.get<string>("0"); <If you need to take argument. It's the first parameter without '-' or '--' increment and without value. It has index 0. The second parameter of this type will have index 1> It also works with 'int', 'unsigned int', 'double' and 'float' types. string inputFile = parser.get<string>("inputFile");