Command line parser.
More...
#include <CommandLine.h>
List of all members.
Public Member Functions |
| CommandLine () |
| Constructor.
|
| ~CommandLine () |
| Destructor.
|
uint32 | GetNumOfOptions () const |
| Get number of registered options.
|
CommandLineOption * | GetOption (uint32 nIndex) const |
| Get option by index.
|
CommandLineOption * | GetOption (const String &sName) const |
| Get option by name.
|
PLCORE_API void | Clear () |
| Delete all options.
|
PLCORE_API bool | AddParameter (const String &sName, const String &sShort, const String &sLong, const String &sDescription, const String &sDefault, bool bRequired=false) |
| Add parameter.
|
PLCORE_API bool | AddFlag (const String &sName, const String &sShort, const String &sLong, const String &sDescription, bool bRequired=false) |
| Add flag (on/off)
|
PLCORE_API bool | AddArgument (const String &sName, const String &sDescription, const String &sDefault, bool bRequired=false) |
| Add argument.
|
PLCORE_API bool | ParseCommandLine (const Array< String > &lstArgs) |
| Parse command line arguments.
|
bool | HasErrors () const |
| Check if there were any errors parsing the command line arguments.
|
PLCORE_API bool | IsValueSet (const String &sName) const |
| Check if an option value is set ('true' for boolean options or any other than "" for string values)
|
PLCORE_API String | GetValue (const String &sName) const |
| Get option value.
|
uint32 | GetNumOfAdditionalArguments () const |
| Get number of additional arguments that have been defined.
|
String | GetAdditionalArgument (uint32 nIndex) const |
| Get additional argument.
|
PLCORE_API void | PrintHelp (const String &sProgramName) const |
| Display a help text with all available options on the console.
|
Static Public Member Functions |
static PLCORE_API String | ArgumentsToString (const Array< String > &lstArguments) |
| Convert a command array to a string.
|
static PLCORE_API Array< String > | StringToArguments (const String &sCmdLine) |
| Convert a command string to an array.
|
Detailed Description
Constructor & Destructor Documentation
Member Function Documentation
Convert a command array to a string.
- Parameters:
-
[in] | lstArguments | List of arguments |
- Returns:
- Command string
Convert a command string to an array.
- Parameters:
-
[in] | sCmdLine | Command string |
- Returns:
- Command array of arguments
Get number of registered options.
- Returns:
- Number of options that have been registered
Get option by index.
- Parameters:
-
[in] | nIndex | Index of the option to retrieve |
- Returns:
- Pointer to option, or a null pointer
Get option by name.
- Parameters:
-
[in] | sName | Name of the option to retrieve (short or long name) |
- Returns:
- Pointer to option, or a null pointer
Add parameter.
- Parameters:
-
[in] | sName | Parameter name (logical name, must *not* start with "-" or "--") |
[in] | sShort | Short name (must start with "-", e.g. "-a") or "" |
[in] | sLong | Long name (must start with "--", e.g. "-optiona") or "" |
[in] | sDescription | Description text for this option |
[in] | sDefault | Default value |
[in] | bRequired | Is the option required? |
- Returns:
- 'true' if option could be added, 'false' on error
Add flag (on/off)
- Parameters:
-
[in] | sName | Parameter name (logical name, must *not* start with "-" or "--") |
[in] | sShort | Short name (must start with "-", e.g. "-a") or "" |
[in] | sLong | Long name (must start with "--", e.g. "-optiona") or "" |
[in] | sDescription | Description text for this option |
[in] | bRequired | Is the option required? |
- Returns:
- 'true' if option could be added, 'false' on error
Add argument.
- Parameters:
-
[in] | sName | Parameter name (logical name, must *not* start with "-" or "--") |
[in] | sDescription | Description text for this option |
[in] | sDefault | Default value |
[in] | bRequired | Is the option required? |
- Returns:
- 'true' if option could be added, 'false' on error
Parse command line arguments.
- Parameters:
-
[in] | lstArgs | List of arguments |
- Returns:
- 'true' if the command line could be parsed without error, else 'false'
Check if there were any errors parsing the command line arguments.
- Returns:
- 'true' if there were errors, else 'false'
Check if an option value is set ('true' for boolean options or any other than "" for string values)
- Parameters:
-
[in] | sName | Name of option (short or long name) |
- Returns:
- 'true' if the value is set, else 'false'
Get option value.
- Parameters:
-
[in] | sName | Name of option (short or long name) |
- Returns:
- Value of option ("true"/"false" for boolean values)
Get number of additional arguments that have been defined.
- Returns:
- Number of additional arguments
Get additional argument.
- Parameters:
-
[in] | nIndex | Index of argument to get |
- Returns:
- Additional argument, or ""
Display a help text with all available options on the console.
- Parameters:
-
[in] | sProgramName | Name of the program |
The documentation for this class was generated from the following files: