GATE
Loading...
Searching...
No Matches
AppOptionDef Class Reference

A single program parameter option definition. More...

#include <applications.hpp>

Public Types

enum  OptionTypeEnum {
  OptionType_Switch = GATE_APP_OPTION_TYPE_SWITCH , OptionType_Boolean = GATE_APP_OPTION_TYPE_BOOL , OptionType_Int32 = GATE_APP_OPTION_TYPE_I32 , OptionType_Int64 = GATE_APP_OPTION_TYPE_I64 ,
  OptionType_Real = GATE_APP_OPTION_TYPE_REAL , OptionType_String = GATE_APP_OPTION_TYPE_STRING , OptionType_StringArray = GATE_APP_OPTION_TYPE_ARRAY
}
 Data type of option. More...
 

Public Member Functions

 AppOptionDef (String const &key, OptionTypeEnum type, void *targetValue, String const alias=String(), String const &optionName=String(), String const &description=String())
 Construct app option definition.
 
 AppOptionDef (gate_app_option_t const &src)
 Construct app option definition from C object.
 
 AppOptionDef (AppOptionDef const &src)
 Copy constructor.
 
AppOptionDefoperator= (AppOptionDef const &src)
 Assignment operator.
 
 ~AppOptionDef () noexcept
 Destructor.
 
String Key () const
 Returns the option's long-key (e.g. "--my-param")
 
String Alias () const
 Returns the option's short-key alias (e.g. "-MP")
 
String OptionName () const
 Returns the option's variable name (documention purpose)
 
String Description () const
 Returns the option's description.
 
OptionTypeEnum Type () const noexcept
 Returns the option's value type.
 
bool_t getBool () const noexcept
 Returns the options value as bool type.
 
int32_t getInt32 () const noexcept
 Returns the options value as int32 type.
 
int64_t getInt64 () const noexcept
 Returns the options value as int64 type.
 
real64_t getReal () const noexcept
 Returns the options value as floating point type.
 
String getString () const
 Returns the options value as string.
 
Array< String > getStringArray () const
 Returns the options value as a string array.
 
gate_app_option_tc_impl () noexcept
 Returns a pointer to C implementation of option definition.
 
gate_app_option_t const * c_impl () const noexcept
 Returns a pointer to C implementation of option definition.
 
bool operator! () const noexcept
 Returns true if definition is empty/uninitialized.
 

Static Public Member Functions

static AppOptionDef createSwitch (String const &key, String const &alias=String(), String const &name=String(), String const &description=String())
 Creates a switch option defition.
 
static AppOptionDef createBool (String const &key, String const &alias=String(), bool_t default_value=false, String const &name=String(), String const &description=String())
 Creates a boolean option defition.
 
static AppOptionDef createInt32 (String const &key, String const &alias=String(), int32_t default_value=0, String const &name=String(), String const &description=String())
 Creates a int32 option defition.
 
static AppOptionDef createInt64 (String const &key, String const &alias=String(), int64_t default_value=0, String const &name=String(), String const &description=String())
 Creates a int64 option defition.
 
static AppOptionDef createReal64 (String const &key, String const &alias=String(), real64_t default_value=0.0, String const &name=String(), String const &description=String())
 Creates a floating-point option defition.
 
static AppOptionDef createString (String const &key, String const &alias=String(), String const &default_value=String(), String const &name=String(), String const &description=String())
 Creates a string option defition.
 
static AppOptionDef createArray (String const &key, String const &alias=String(), String const &name=String(), String const &description=String())
 Creates a string array option defition.
 

Detailed Description

A single program parameter option definition.

Member Enumeration Documentation

◆ OptionTypeEnum

Data type of option.

Enumerator
OptionType_Switch 

option is a boolean switch, TRUE if option is specified or FALSE when missing

OptionType_Boolean 

option value is a boolean value, accepts "true", "false", "0" or "1"

OptionType_Int32 

option value is a 32 bit integer

OptionType_Int64 

option value is a 64 bit integer

OptionType_Real 

option value is floating point number

OptionType_String 

option value is a 32 bit integer

OptionType_StringArray 

option value is an array of strings

Constructor & Destructor Documentation

◆ AppOptionDef() [1/2]

AppOptionDef ( String const & key,
OptionTypeEnum type,
void * targetValue,
String const alias = String(),
String const & optionName = String(),
String const & description = String() )

Construct app option definition.

Parameters
keyoption's full key identifier (e.g.: "--my-param")
typeoption's value type
targetValuepointer to variable that receives the option's value
aliasoption's short alias identifier (e.g.: "-MP")
optionNameinternal variable name of option value
descriptiondescription of option value

◆ AppOptionDef() [2/2]

Construct app option definition from C object.

Parameters
srcreference to source option to copy data from

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