cv::CommandLineParser Class Reference

Command Line Parser. More...

#include <core.hpp>

List of all members.

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

Detailed Description

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");


Constructor & Destructor Documentation

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

the default constructor


Member Function Documentation

template<typename _Tp >
_Tp cv::CommandLineParser::get ( const std::string &  name,
const _Tp &  default_value = _Tp() 
)

get parameter, if parameter is not given get default parameter

std::string cv::CommandLineParser::getString ( const std::string &  name  )  const [protected]
bool cv::CommandLineParser::has ( const std::string &  keys  )  const [protected]
template<typename _Tp >
static _Tp cv::CommandLineParser::getData ( const std::string &  str  )  [static, protected]
template<typename _Tp >
_Tp cv::CommandLineParser::fromStringNumber ( const std::string &  str  )  [protected]
CV_EXPORTS double cv::CommandLineParser::analyzeValue< double > ( const std::string &  str  )  [protected]
template<>
CV_EXPORTS bool cv::CommandLineParser::get ( const std::string &  name,
const bool &  default_value 
)

Member Data Documentation

std::map<std::string, std::string > cv::CommandLineParser::data [protected]

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