XII Release 0.1.0
Loading...
Searching...
No Matches
xiiCommandLineOptionEnum Class Reference

An 'enum' option is a string option that only allows certain phrases ('keys'). More...

#include <CommandLineOptions.h>

Inheritance diagram for xiiCommandLineOptionEnum:
[legend]

Classes

struct  EnumKeyValue
 

Public Member Functions

 xiiCommandLineOptionEnum (xiiStringView sSortingGroup, xiiStringView sArgument, xiiStringView sLongDesc, xiiStringView sEnumKeysAndValues, xiiInt32 iDefaultValue, bool bCaseSensitive=false)
 
xiiInt32 GetOptionValue (LogMode logMode, const xiiCommandLineUtils *pUtils=xiiCommandLineUtils::GetGlobalInstance()) const
 Returns the value of this option. Either what was specified on the command line, or the default value.
 
virtual void GetParamShortDesc (xiiStringBuilder &ref_sOut) const override
 Returns a very short description of the option (type). For example "<int>" or "<enum>".
 
virtual void GetParamDefaultValueDesc (xiiStringBuilder &ref_sOut) const override
 Returns a very short string for the options default value. For example "0" or "auto".
 
void GetEnumKeysAndValues (xiiDynamicArray< EnumKeyValue > &out_keysAndValues) const
 Returns the enum keys (names) and values (integers) extracted from the string that was passed to the constructor.
 
void SetDefaultValue (xiiInt32 value)
 Modifies the default value.
 
xiiInt32 GetDefaultValue () const
 Returns the default value.
 
virtual xiiStringView GetType () override
 Returns "Enum".
 
- Public Member Functions inherited from xiiCommandLineOptionDoc
 xiiCommandLineOptionDoc (xiiStringView sSortingGroup, xiiStringView sArgument, xiiStringView sParamShortDesc, xiiStringView sLongDesc, xiiStringView sDefaultValue, bool bCaseSensitive=false)
 
virtual void GetOptions (xiiStringBuilder &ref_sOut) const override
 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.
 
virtual void GetLongDesc (xiiStringBuilder &ref_sOut) const override
 Returns a proper description of the option.
 
bool IsOptionSpecified (xiiStringBuilder *out_pWhich=nullptr, const xiiCommandLineUtils *pUtils=xiiCommandLineUtils::GetGlobalInstance()) const
 Checks whether any of the option variants is set on the command line, and returns which one. For example '-h' or '-help'.
 
- Public Member Functions inherited from xiiCommandLineOption
 xiiCommandLineOption (xiiStringView sSortingGroup)
 
virtual void GetSortingGroup (xiiStringBuilder &ref_sOut) const
 Writes the sorting group name to 'out'.
 
void GetSplitOptions (xiiStringBuilder &out_sAll, xiiDynamicArray< xiiStringView > &ref_splitOptions) const
 Returns the supported option names (e.g. '-arg') as split strings.
 

Protected Attributes

xiiInt32 m_iDefaultValue = 0
 
xiiStringView m_sEnumKeysAndValues
 
- Protected Attributes inherited from xiiCommandLineOptionDoc
xiiStringView m_sArgument
 
xiiStringView m_sParamShortDesc
 
xiiStringView m_sParamDefaultValue
 
xiiStringView m_sLongDesc
 
bool m_bCaseSensitive = false
 
bool m_bLoggedOnce = false
 
- Protected Attributes inherited from xiiCommandLineOption
xiiStringView m_sSortingGroup
 
- Protected Attributes inherited from xiiEnumerable< xiiCommandLineOption >
xiiEnumerablem_pNextInstance
 

Additional Inherited Members

- Public Types inherited from xiiCommandLineOption
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...
 
- Static Public Member Functions inherited from xiiCommandLineOption
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 Public Member Functions inherited from xiiNoBase
static const xiiRTTIGetStaticRTTI ()
 
- Protected Member Functions inherited from xiiCommandLineOptionDoc
bool ShouldLog (LogMode mode, bool bWasSpecified) const
 
void LogOption (xiiStringView sOption, xiiStringView sValue, bool bWasSpecified) const
 

Detailed Description

An 'enum' option is a string option that only allows certain phrases ('keys').

Each phrase has an integer value, and GetOptionValue() returns the integer value of the selected phrase. It is valid for the default value to be different from all the phrase values, which can be used to detect whether the user provided any phrase at all.

The allowed values are passed in as a single string, in the form "OptA = 0 | OptB = 1 | ..." Phrase values ("= 0" etc) are optional, and if not given are automatically assigned starting at zero. Multiple phrases may share the same value.

Member Function Documentation

◆ GetParamDefaultValueDesc()

void xiiCommandLineOptionEnum::GetParamDefaultValueDesc ( xiiStringBuilder & ref_sOut) const
overridevirtual

Returns a very short string for the options default value. For example "0" or "auto".

Reimplemented from xiiCommandLineOptionDoc.

◆ GetParamShortDesc()

void xiiCommandLineOptionEnum::GetParamShortDesc ( xiiStringBuilder & ref_sOut) const
overridevirtual

Returns a very short description of the option (type). For example "<int>" or "<enum>".

Reimplemented from xiiCommandLineOptionDoc.

◆ GetType()

virtual xiiStringView xiiCommandLineOptionEnum::GetType ( )
inlineoverridevirtual

Returns "Enum".

Reimplemented from xiiCommandLineOptionDoc.


The documentation for this class was generated from the following files: