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 startup.
|
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 make easy checks of their presence. Also this class can print prepared help screen with all available arguments and their description.
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] | allParams | The array with available command line arguments |
Member Function Documentation
const std::string CmdArgsParser::operator[] |
( |
const std::string & |
name |
) |
const |
- Parameters:
-
[in] | The | name of parameter to get argument of, specified by longName field value |
bool CmdArgsParser::parse |
( |
int |
argc, |
|
|
char * |
argv[] | |
|
) |
| | |
This method performs complete command line parsing and fills all internal structures to save the result. If there are invalid arguments specified by user this method prints error description and returns zero.
- Parameters:
-
[in] | argc | The argc parameter received from main() function call |
[in] | argv | The argv parameter received from main() function call |
- Returns:
- Non-zero if there are no errors or zero if there are invalid command line arguments
bool CmdArgsParser::used |
( |
const std::string & |
name |
) |
const |
- Parameters:
-
[in] | name | The parameter to check specified by longName field value |