GestureRecognitionToolkit  Version: 0.2.0
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)
 
bool parse (const int argc, char *argv[])
 
template<class T >
bool get (const std::string &id, T &value, T defaultValue=T())
 
bool validate (const std::string &id)
 
bool setInfoLoggingEnabled (const bool loggingEnabled)
 
bool setWarningLoggingEnabled (const bool loggingEnabled)
 
bool setErrorLoggingEnabled (const bool loggingEnabled)
 

Protected Attributes

InfoLog infoLog
 
WarningLog warningLog
 
ErrorLog errorLog
 
std::map< std::string, std::string > options
 
std::map< std::string, std::string > results
 

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::get ( const std::string &  id,
T &  value,
defaultValue = T() 
)
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 106 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 80 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 181 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 159 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 170 of file CommandLineParser.h.

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

Validates if 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 succesfully, false otherwise

Definition at line 138 of file CommandLineParser.h.


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