![]() |
XII Release 0.1.0
|
xiiCommandLineOption (and derived types) are used to define options that the application supports. More...
#include <CommandLineOptions.h>
Public Types | |
enum class | LogAvailableModes { Always , IfHelpRequested } |
enum class | LogMode { Never , FirstTime , FirstTimeIfSpecified , Always , AlwaysIfSpecified } |
Describes whether the value of an option (and whether something went wrong), should be printed to xiiLog. More... | |
Public Member Functions | |
xiiCommandLineOption (xiiStringView sSortingGroup) | |
virtual void | GetSortingGroup (xiiStringBuilder &ref_sOut) const |
Writes the sorting group name to 'out'. | |
virtual void | GetOptions (xiiStringBuilder &ref_sOut) const =0 |
Writes all the supported options (e.g. '-arg') to 'out'. If more than one option is allowed, they should be separated with semicolons or pipes. | |
void | GetSplitOptions (xiiStringBuilder &out_sAll, xiiDynamicArray< xiiStringView > &ref_splitOptions) const |
Returns the supported option names (e.g. '-arg') as split strings. | |
virtual void | GetParamShortDesc (xiiStringBuilder &ref_sOut) const =0 |
Returns a very short description of the option (type). For example "<int>" or "<enum>". | |
virtual void | GetParamDefaultValueDesc (xiiStringBuilder &ref_sOut) const =0 |
Returns a very short string for the options default value. For example "0" or "auto". | |
virtual void | GetLongDesc (xiiStringBuilder &ref_sOut) const =0 |
Returns a proper description of the option. | |
virtual xiiStringView | GetType ()=0 |
Returns a string indicating the exact implementation type. | |
Static Public Member Functions | |
static bool | IsHelpRequested (const xiiCommandLineUtils *pUtils=xiiCommandLineUtils::GetGlobalInstance()) |
Checks whether a command line was passed that requests help output. | |
static xiiResult | RequireOptions (xiiStringView sRequiredOptions, xiiString *pMissingOption=nullptr, const xiiCommandLineUtils *pUtils=xiiCommandLineUtils::GetGlobalInstance()) |
Checks whether all required options are passed to the command line. | |
static bool | LogAvailableOptions (LogAvailableModes mode, xiiStringView sGroupFilter={}, const xiiCommandLineUtils *pUtils=xiiCommandLineUtils::GetGlobalInstance()) |
Prints all available options to the xiiLog. | |
static bool | LogAvailableOptionsToBuffer (xiiStringBuilder &out_sBuffer, LogAvailableModes mode, xiiStringView sGroupFilter={}, const xiiCommandLineUtils *pUtils=xiiCommandLineUtils::GetGlobalInstance()) |
Same as LogAvailableOptions() but captures the output from xiiLog and returns it in a xiiStringBuilder. | |
![]() | |
static const xiiRTTI * | GetStaticRTTI () |
Protected Attributes | |
xiiStringView | m_sSortingGroup |
![]() | |
xiiEnumerable * | m_pNextInstance |
xiiCommandLineOption (and derived types) are used to define options that the application supports.
Command line options are created as global variables anywhere throughout the code, wherever they are needed. The point of using them over going through xiiCommandLineUtils directly, is that the options can be listed automatically and thus an application can print all available options, when the user requests help.
Consequently, their main purpose is to make options discoverable and to document them in a consistent manner.
Additionally, classes like xiiCommandLineOptionEnum add functionality that makes some options easier to setup.
|
strong |
|
strong |
Describes whether the value of an option (and whether something went wrong), should be printed to xiiLog.
|
inline |
sSortingGroup | This string is used to sort options. Application options should start with an underscore, such that they appear first in the output. |
|
pure virtual |
Returns a proper description of the option.
The long description is allowed to contain newlines (
) and the output will be formatted accordingly.
Implemented in xiiCommandLineOptionDoc.
|
pure virtual |
Writes all the supported options (e.g. '-arg') to 'out'. If more than one option is allowed, they should be separated with semicolons or pipes.
Implemented in xiiCommandLineOptionDoc.
|
pure virtual |
Returns a very short string for the options default value. For example "0" or "auto".
Implemented in xiiCommandLineOptionDoc, xiiCommandLineOptionEnum, xiiCommandLineOptionFloat, and xiiCommandLineOptionInt.
|
pure virtual |
Returns a very short description of the option (type). For example "<int>" or "<enum>".
Implemented in xiiCommandLineOptionDoc, xiiCommandLineOptionEnum, xiiCommandLineOptionFloat, and xiiCommandLineOptionInt.
|
pure virtual |
Returns a string indicating the exact implementation type.
Implemented in xiiCommandLineOptionBool, xiiCommandLineOptionDoc, xiiCommandLineOptionEnum, xiiCommandLineOptionFloat, xiiCommandLineOptionInt, xiiCommandLineOptionPath, and xiiCommandLineOptionString.
|
static |
Prints all available options to the xiiLog.
sGroupFilter | If this is empty, all options from all 'sorting groups' are logged. If non-empty, only options from sorting groups that appear in this string will be logged. |
|
static |
Checks whether all required options are passed to the command line.
The options are passed as a semicolon-separated list (spare spaces are stripped away), for instance "-opt1; -opt2"