GestureRecognitionToolkit  Version: 0.2.5
The Gesture Recognition Toolkit (GRT) is a cross-platform, open-source, c++ machine learning library for real-time gesture recognition.
CommandLineParser Class Reference

Public Member Functions

 CommandLineParser ()
 
virtual ~CommandLineParser ()
 
bool addOption (const std::string &option, const std::string &id)
 
template<class T >
bool addOption (const std::string &option, const std::string &id, const T &defaultValue)
 
bool parse (const int argc, char *argv[])
 
template<class T >
bool get (const std::string &id, T &value)
 
bool getValidId (const std::string &id)
 
bool getOptionParsed (const std::string &id)
 
unsigned int getNumOptions () const
 
bool setInfoLoggingEnabled (const bool loggingEnabled)
 
bool setWarningLoggingEnabled (const bool loggingEnabled)
 
bool setErrorLoggingEnabled (const bool loggingEnabled)
 

Protected Member Functions

template<class T >
std::string toString (const T &value)
 

Protected Attributes

InfoLog infoLog
 
WarningLog warningLog
 
ErrorLog errorLog
 
std::map< std::string, std::string > options
 Holds the options lookup map.
 
std::map< std::string, std::string > results
 Stores the results for each option in the options lookup map.
 
std::map< std::string, bool > parsed
 Stores the results that have been parsed.
 

Detailed Description

Definition at line 41 of file CommandLineParser.h.

Constructor & Destructor Documentation

CommandLineParser::CommandLineParser ( )
inline

Default constructor.

Definition at line 46 of file CommandLineParser.h.

virtual CommandLineParser::~CommandLineParser ( )
inlinevirtual

Default destructor.

Definition at line 51 of file CommandLineParser.h.

Member Function Documentation

bool CommandLineParser::addOption ( const std::string &  option,
const std::string &  id 
)
inline

Adds an option with a specific retrival id. For example, addOption("-f","filename") would add the option "-f" which can be retrived using the "filename" id.

Parameters
conststd::string &option: the command line option you want to store when the command line is parsed
conststd::string &id: the id that will be used to retrieve the data associated with the option
Returns
returns true if the option was added succesfully, false otherwise

Definition at line 60 of file CommandLineParser.h.

template<class T >
bool CommandLineParser::addOption ( const std::string &  option,
const std::string &  id,
const T &  defaultValue 
)
inline

Adds an option with a specific retrival id. For example, addOption("-f","filename") would add the option "-f" which can be retrived using the "filename" id.

Parameters
conststd::string &option: the command line option you want to store when the command line is parsed
conststd::string &id: the id that will be used to retrieve the data associated with the option
Returns
returns true if the option was added succesfully, false otherwise

Definition at line 81 of file CommandLineParser.h.

template<class T >
bool CommandLineParser::get ( const std::string &  id,
T &  value 
)
inline

Retrives the value associated with the relevant id and stores it in value. If the id is invalid or the type can not be parsed, then the function will return false.

Parameters
conststd::string &id: the search id
T&value: stores the return value
TdefaultValue = T(): sets the default return value if the id is not found
Returns
returns true if the value associated with the id was found succesfully, false otherwise

Definition at line 140 of file CommandLineParser.h.

unsigned int CommandLineParser::getNumOptions ( ) const
inline
Returns
returns the number of options in the options map

Definition at line 209 of file CommandLineParser.h.

bool CommandLineParser::getOptionParsed ( const std::string &  id)
inline

Checks if the id was succesfully parsed from the command line. If the id is invalid or was not parsed, then the function will return false.

Parameters
conststd::string &id: the search id
Returns
returns true if the value associated with the id was parsed from the command line succesfully, false otherwise

Definition at line 193 of file CommandLineParser.h.

bool CommandLineParser::getValidId ( const std::string &  id)
inline

Validates if id is validate (i.e., it exists in the lookup table). Any value in the lookup table will be validate, regardless of its parsed state. If the id is invalid, then the function will return false.

Parameters
conststd::string &id: the search id
Returns
returns true if the value associated with the id is valid, false otherwise

Definition at line 171 of file CommandLineParser.h.

bool CommandLineParser::parse ( const int  argc,
char *  argv[] 
)
inline

Parses the command line arguments, storing any relevant results in the results buffer. The can then be accessed using the get(...) function.

Parameters
constint argc: the number of command line arguments
char* argv[]: an array of arguments
Returns
returns true if the command line was parsed succesfully, false otherwise

Definition at line 103 of file CommandLineParser.h.

bool CommandLineParser::setErrorLoggingEnabled ( const bool  loggingEnabled)
inline

Sets if error logging is enabled/disabled for this specific instance. If you want to enable/disable error logging globally, then you should use the ErrorLog::enableLogging( bool ) function.

Returns
returns true if the parameter was updated, false otherwise

Definition at line 239 of file CommandLineParser.h.

bool CommandLineParser::setInfoLoggingEnabled ( const bool  loggingEnabled)
inline

Sets if info logging is enabled/disabled for this specific instance. If you want to enable/disable info logging globally, then you should use the InfoLog::enableLogging( bool ) function.

Returns
returns true if the parameter was updated, false otherwise

Definition at line 219 of file CommandLineParser.h.

bool CommandLineParser::setWarningLoggingEnabled ( const bool  loggingEnabled)
inline

Sets if warning logging is enabled/disabled for this specific instance. If you want to enable/disable warning logging globally, then you should use the WarningLog::enableLogging( bool ) function.

Returns
returns true if the parameter was updated, false otherwise

Definition at line 229 of file CommandLineParser.h.


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