argument parser class
More...
#include <argument_parser.h>
argument parser class
Yet another argument parser, meant to speed up development of new applications. Its focus is on being object oriented and safe to use
◆ ArgNumberCheck
types of argument number checking
◆ addCommand()
| int ArgParser::addCommand |
( |
APCmd & |
cmd, |
|
|
const std::string & |
name, |
|
|
const std::string & |
shortInfo, |
|
|
const std::string & |
description, |
|
|
ArgNumberCheck |
argNumberCheck, |
|
|
const int |
argNumber = -1, |
|
|
const std::string & |
otherArguments = "" |
|
) |
| |
add a command
- Parameters
-
| cmd | a reference to the command; use it to compare the actually selected command against this one after parsing |
| name | the name of the command to be parsed from the command line |
| shortInfo | a short description, used for general help screen |
| description | a description, used for the help screens |
| argNumberCheck | what kind of argument number checking |
| argNumber | optional number of arguments |
| otherArguments | value to display in the help screen for following (non option) arguments |
◆ addOption()
| int ArgParser::addOption |
( |
const APCmd & |
cmd, |
|
|
APOpt & |
key, |
|
|
bool |
required |
|
) |
| |
add an option to a command - this will fail with an assertion of key has not been initialized using init()
- Parameters
-
| cmd | the command to add an option to |
| key | the option reference; use it to check for certain options after parsing |
| required | whether this option is required |
◆ appName()
| std::string ArgParser::appName |
( |
| ) |
const |
the name of the application, from argv[0]
◆ command()
the command which was parsed, to be used to compare against actual APCmd obtained from addCommand calls
◆ getAppIdentification()
| virtual std::string ArgParser::getAppIdentification |
( |
| ) |
const |
|
inlinevirtual |
- Returns
- an application identification to be used in the usage
Reimplemented in CardsArgumentParser.
◆ getIdValue()
| int ArgParser::getIdValue |
( |
const APCmd & |
command | ) |
|
- Returns
- the id value of the command
◆ getOptionValue()
| std::string ArgParser::getOptionValue |
( |
const APOpt & |
key | ) |
const |
- Returns
- the value attached to the option
- Parameters
-
◆ isSet()
| bool ArgParser::isSet |
( |
const APOpt & |
key | ) |
const |
- Returns
- true if
- Parameters
-
| key | is set, false otherwise |
◆ otherArguments()
| const std::vector< std::string > & ArgParser::otherArguments |
( |
| ) |
const |
◆ parse()
| void ArgParser::parse |
( |
int |
argc, |
|
|
char ** |
argv |
|
) |
| |
the actual parsing. Highly recommended :-)
◆ printHelp()
| void ArgParser::printHelp |
( |
const std::string & |
cmd | ) |
|
- Returns
- the help of the command
The documentation for this class was generated from the following files: