VoiceMan
Classes | Public Member Functions | Public Attributes
CmdArgsParser Class Reference

Parses command line arguments and prints help screen. More...

List of all members.

Classes

struct  USEDPARAM

Public Member Functions

 CmdArgsParser (CmdArg *allParams)
 The constructor.
const std::string operator[] (const std::string &name) const
 Returns additional argument value of command line parameter.
bool parse (int argc, char *argv[])
 Performs parsing of arguments provided by user.
void printHelp () const
 Prints description of all available arguments.
bool used (const std::string &name) const
 Checks if specified parameter was used at program call.

Public Attributes

const std::vector< std::string > & files
 The set of arguments specified after known command line parameters.

Detailed Description

This class receives command line arguments and compares them with the table specified in application source code to determine invalid usage and easy command line check. Also this class can print prepared help screen with all available arguments and their descriptions.


Constructor & Destructor Documentation

CmdArgsParser::CmdArgsParser ( CmdArg allParams)

Number of all available arguments is determined implicitly by the items of allParam argument. The last item in this array must have space in its shortName field.

Parameters:
[in]allParamsThe array with available command line arguments

Member Function Documentation

const std::string CmdArgsParser::operator[] ( const std::string &  name) const

Use this operator to get value of the specified parameter.

Parameters:
[in]Thename of parameter to get argument of, specified by longName field
Returns:
Requested value of the specified parameter
bool CmdArgsParser::parse ( int  argc,
char *  argv[] 
)

This method performs complete command line parsing and fills all internal structures with the result. If there are invalid arguments specified by user this method prints error description and returns zero.

Parameters:
[in]argcThe argc parameter received from main() function call
[in]argvThe argv parameter received from main() function call
Returns:
Non-zero if there are no errors or zero if there are invalid command line arguments
void CmdArgsParser::printHelp ( ) const

Use this method to generate complete help screen.

bool CmdArgsParser::used ( const std::string &  name) const

Use this method to check command line argument using.

Parameters:
[in]nameThe parameter name to check specified by longName field value
Returns:
Non-zero if parameter was used