Parses command-line options supported by the application.
More...
#include <App.h>
|
|
| AppOptionParser () |
| | Constructs an AppOptionParser object.
|
|
virtual | ~AppOptionParser () |
| | Destroys an AppOptionParser object.
|
| void | allowUnknownOption (bool allow=true) |
| | Determines whether or not the parser will allow unknown options to pass through the parser without generating an error.
|
| void | setDescription (const std::string &description) |
| | Sets the portion of the usage information where the application description is displayed.
|
| void | setDisplayWidth (int displayWidth=75) |
| | Sets the display width of the usage information.
|
| void | setEpilogText (const std::string &epilogText) |
| | Sets the epilog portion of the usage information; that is, the part that comes after the list of supported options.
|
| void | setExecutable (const std::string &executable) |
| | Sets the portion of the usage information where the executable name is displayed.
|
| void | setUnparsedArgText (const std::string &unparsedArgText) |
| | Sets the portion of the usage information that represents the collection of unparsed arguments.
|
| void | setVersion (const std::string &version) |
| | Sets the portion of the usage information that represents the application version.
|
| virtual void | addOption (const AppOption &opt) |
| | Adds an allowed option to the parser.
|
| virtual void | addOption (const std::string &shortName, const std::string &longName, int valueType, void *valuePtr, const std::string &helpArgName, const std::string &helpText, bool showDefault) |
| | Adds an allowed option to the parser.
|
| virtual int | parse (int argc, char **argv) |
| | Parses the command-line options.
|
|
|
BasicStringList | unparsedArgs |
| | The collection of arguments that were not dealt with by the parser during option parsing.
|
Parses command-line options supported by the application.
The option parser defines the following options by default: –help Prints help text and exits –version Prints version information and exits
Definition at line 248 of file App.h.
◆ addOption() [1/2]
Adds an allowed option to the parser.
- Parameters
-
| opt | An AppOption object describing the option to add to the parser. |
Definition at line 247 of file App.cpp.
◆ addOption() [2/2]
| void addOption |
( |
const std::string & | shortName, |
|
|
const std::string & | longName, |
|
|
int | valueType, |
|
|
void * | valuePtr, |
|
|
const std::string & | helpArgName, |
|
|
const std::string & | helpText, |
|
|
bool | showDefault ) |
|
virtual |
Adds an allowed option to the parser.
- Parameters
-
| shortName | Short option name, without leading hyphen. If empty, this option does not support short format. |
| longName | Long option name, without leading hyphens. If empty, this option does not support long format. |
| valueType | Type of value that this option sets. Must be one of the AppOption::TYPE_* constants. |
| valuePtr | Pointer to a variable that holds the option value. |
| helpArgName | Option argument name to display in the help text. |
| helpText | Option help text. |
| showDefault | Whether or not to show the default value of the option in the help text. The default value will be appended to the help text given in helpText. |
Definition at line 252 of file App.cpp.
◆ allowUnknownOption()
| void allowUnknownOption |
( |
bool | allow = true | ) |
|
Determines whether or not the parser will allow unknown options to pass through the parser without generating an error.
The default behavior is to disallow unknown options.
- Parameters
-
| allow | Whether or not to allow unknown options to pass through. |
Definition at line 262 of file App.cpp.
◆ parse()
| int parse |
( |
int | argc, |
|
|
char ** | argv ) |
|
virtual |
Parses the command-line options.
After parsing, any unparsed arguments are collected in unparsedArgs.
- Parameters
-
| argc | The number of arguments specified on the command line, counting the executable name itself. |
| argv | The list of arguments specified on the command line, including the executable name itself. |
- Returns
- An integer indicating the success or failure of the parsing operation, as follows: 0 = all options parsed successfully 1 = error encountered in option processing 2 = usage information was requested 3 = version information was requested
Definition at line 297 of file App.cpp.
◆ setDescription()
| void setDescription |
( |
const std::string & | description | ) |
|
Sets the portion of the usage information where the application description is displayed.
- Parameters
-
| description | The application description. |
Definition at line 267 of file App.cpp.
◆ setDisplayWidth()
| void setDisplayWidth |
( |
int | displayWidth = 75 | ) |
|
Sets the display width of the usage information.
- Parameters
-
| displayWidth | The display width, in characters. |
Definition at line 272 of file App.cpp.
◆ setEpilogText()
| void setEpilogText |
( |
const std::string & | epilogText | ) |
|
Sets the epilog portion of the usage information; that is, the part that comes after the list of supported options.
The epilog text may be divided into lines via newline (
) characters.
- Parameters
-
| epilogText | The epilog text. |
Definition at line 277 of file App.cpp.
◆ setExecutable()
| void setExecutable |
( |
const std::string & | executable | ) |
|
Sets the portion of the usage information where the executable name is displayed.
This is usually the contents of argv[0].
- Parameters
-
| executable | The executable name to display. |
Definition at line 282 of file App.cpp.
◆ setUnparsedArgText()
| void setUnparsedArgText |
( |
const std::string & | unparsedArgText | ) |
|
Sets the portion of the usage information that represents the collection of unparsed arguments.
- Parameters
-
| unparsedArgText | The text to display. |
Definition at line 287 of file App.cpp.
◆ setVersion()
| void setVersion |
( |
const std::string & | version | ) |
|
Sets the portion of the usage information that represents the application version.
- Parameters
-
| version | The application version. |
Definition at line 292 of file App.cpp.
The documentation for this class was generated from the following files:
- /home/abuild/rpmbuild/BUILD/libcyberradio-24.10.14-build/libcyberradio-24.10.14/libcyberradio/include/LibCyberRadio/Common/App.h
- /home/abuild/rpmbuild/BUILD/libcyberradio-24.10.14-build/libcyberradio-24.10.14/libcyberradio/libcyberradio/Common/App.cpp