OpenCV  2.4.13.5
Open Source Computer Vision
cv::CommandLineParser Class Reference

#include <core.hpp>

Public Member Functions

 CommandLineParser (int argc, const char *const argv[], const char *key_map)
 the default constructor More...
 
template<typename _Tp >
_Tp get (const std::string &name, bool space_delete=true)
 get parameter, you can choose: delete spaces in end and begin or not More...
 
void printParams ()
 print short name, full name, current value and help for all params More...
 
template<>
bool get (const std::string &name, bool space_delete)
 

Protected Member Functions

std::string getString (const std::string &name)
 
bool has (const std::string &keys)
 
template<typename _Tp >
_Tp analyzeValue (const std::string &str, bool space_delete=false)
 
template<typename _Tp >
_Tp fromStringNumber (const std::string &str)
 
template<>
int analyzeValue (const std::string &str, bool space_delete)
 
template<>
unsigned int analyzeValue (const std::string &str, bool space_delete)
 
template<>
uint64 analyzeValue (const std::string &str, bool space_delete)
 
template<>
float analyzeValue (const std::string &str, bool space_delete)
 
template<>
double analyzeValue (const std::string &str, bool space_delete)
 

Static Protected Member Functions

template<typename _Tp >
static _Tp getData (const std::string &str)
 

Protected Attributes

std::map< std::string, std::vector< std::string > > data
 

Detailed Description

"\nThe CommandLineParser class is designed for command line arguments parsing\n" "Keys map: \n" "Before you start to work with CommandLineParser you have to create a map for keys.\n" " It will look like this\n" " const char* keys =\n" " {\n" " { s| string| 123asd |string parameter}\n" " { d| digit | 100 |digit parameter }\n" " { c|noCamera|false |without camera }\n" " { 1| |some text|help }\n" " { 2| |333 |another help }\n" " };\n" "Usage syntax: \n" " \"{" - start of parameter string.
" " "}" - end of parameter string
" " "|" - separator between short name, full name, default value and help
" "Supported syntax:
" " --key1=arg1 <If a key with '--' must has an argument
" " you have to assign it through '=' sign.>
" "<If the key with '--' doesn't have any argument, it means that it is a bool key>
" " -key2=arg2 <If a key with '-' must has an argument
" " you have to assign it through '=' sign.>
" "If the key with '-' doesn't have any argument, it means that it is a bool key
" " key3 <This key can't has any parameter>
" "Usage:
" " Imagine that the input parameters are next:
" " -s=string_value --digit=250 --noCamera lena.jpg 10000
" " CommandLineParser parser(argc, argv, keys) - create a parser object
" " parser.get<string>("s" or "string") will return you first parameter value
" " parser.get<string>("s", false or "string", false) will return you first parameter value
" " without spaces in end and begin
" " parser.get<int>("d" or "digit") will return you second parameter value.
" " It also works with 'unsigned int', 'double', and 'float' types>
" " parser.get<bool>("c" or "noCamera") will return you true .
" " If you enter this key in commandline>
" " It return you false otherwise.
" " parser.get<string>("1") will return you the first argument without parameter (lena.jpg)
" " parser.get<int>("2") will return you the second argument without parameter (10000)
" " It also works with 'unsigned int', 'double', and 'float' types
"

Constructor & Destructor Documentation

§ CommandLineParser()

cv::CommandLineParser::CommandLineParser ( int  argc,
const char *const  argv[],
const char *  key_map 
)

the default constructor

Member Function Documentation

§ analyzeValue() [1/6]

template<typename _Tp >
_Tp cv::CommandLineParser::analyzeValue ( const std::string &  str,
bool  space_delete = false 
)
protected

§ analyzeValue() [2/6]

template<>
int cv::CommandLineParser::analyzeValue ( const std::string &  str,
bool  space_delete 
)
protected

§ analyzeValue() [3/6]

template<>
unsigned int cv::CommandLineParser::analyzeValue ( const std::string &  str,
bool  space_delete 
)
protected

§ analyzeValue() [4/6]

template<>
uint64 cv::CommandLineParser::analyzeValue ( const std::string &  str,
bool  space_delete 
)
protected

§ analyzeValue() [5/6]

template<>
float cv::CommandLineParser::analyzeValue ( const std::string &  str,
bool  space_delete 
)
protected

§ analyzeValue() [6/6]

template<>
double cv::CommandLineParser::analyzeValue ( const std::string &  str,
bool  space_delete 
)
protected

§ fromStringNumber()

template<typename _Tp >
_Tp cv::CommandLineParser::fromStringNumber ( const std::string &  str)
protected

§ get() [1/2]

template<typename _Tp >
_Tp cv::CommandLineParser::get ( const std::string &  name,
bool  space_delete = true 
)
inline

get parameter, you can choose: delete spaces in end and begin or not

§ get() [2/2]

template<>
bool cv::CommandLineParser::get ( const std::string &  name,
bool  space_delete 
)

§ getData()

template<typename _Tp >
static _Tp cv::CommandLineParser::getData ( const std::string &  str)
inlinestaticprotected

§ getString()

std::string cv::CommandLineParser::getString ( const std::string &  name)
protected

§ has()

bool cv::CommandLineParser::has ( const std::string &  keys)
protected

§ printParams()

void cv::CommandLineParser::printParams ( )

print short name, full name, current value and help for all params

Member Data Documentation

§ data

std::map<std::string, std::vector<std::string> > cv::CommandLineParser::data
protected

The documentation for this class was generated from the following file: