Configuration Class Reference

#include <configurationdatabase.h>

Detailed Description

Configuration database functions.

Static Public Member Functions

static MAXON_METHOD Result< void > QueryBool (const String &key, Bool &result, CONFIGURATIONENTRY_ORIGIN &origin, CONFIGURATIONENTRY_STATE &state)
 
static MAXON_METHOD Result< void > QueryInt (const String &key, Int &result, CONFIGURATIONENTRY_ORIGIN &origin, CONFIGURATIONENTRY_STATE &state)
 
static MAXON_METHOD Result< void > QueryFloat (const String &key, Float &result, CONFIGURATIONENTRY_ORIGIN &origin, CONFIGURATIONENTRY_STATE &state)
 
static MAXON_METHOD Result< void > QueryString (const String &key, String &result, CONFIGURATIONENTRY_ORIGIN &origin, CONFIGURATIONENTRY_STATE &state)
 
static MAXON_METHOD Result< void > AddHelpForBool (const String &key, Bool defaultValue, CONFIGURATION_CATEGORY category, const Char *help)
 
static MAXON_METHOD Result< void > AddHelpForInt (const String &key, Int defaultValue, Int minValue, Int maxValue, CONFIGURATION_CATEGORY category, const Char *help)
 
static MAXON_METHOD Result< void > AddHelpForFloat (const String &key, Float defaultValue, Float minValue, Float maxValue, CONFIGURATION_CATEGORY category, const Char *help)
 
static MAXON_METHOD Result< void > AddHelpForString (const String &key, const String &defaultValue, CONFIGURATION_CATEGORY category, const Char *help)
 
static MAXON_METHOD Result< void > AddHelpForOption (const String &key, const String &option, Bool isDefaultValue, Bool caseSensitive, CONFIGURATION_CATEGORY category, const Char *help)
 
static MAXON_METHOD Result< void > BroadcastBool (const String &key, Bool value)
 
static MAXON_METHOD Result< void > BroadcastInt (const String &key, Int value)
 
static MAXON_METHOD Result< void > BroadcastFloat (const String &key, Float value)
 
static MAXON_METHOD Result< void > BroadcastString (const String &key, const String &value)
 

Private Member Functions

 MAXON_INTERFACE_NONVIRTUAL (Configuration, MAXON_REFERENCE_NONE, "net.maxon.interface.configuration")
 

Member Function Documentation

◆ MAXON_INTERFACE_NONVIRTUAL()

MAXON_INTERFACE_NONVIRTUAL ( Configuration  ,
MAXON_REFERENCE_NONE  ,
"net.maxon.interface.configuration"   
)
private

◆ QueryBool()

static MAXON_METHOD Result<void> QueryBool ( const String key,
Bool result,
CONFIGURATIONENTRY_ORIGIN origin,
CONFIGURATIONENTRY_STATE state 
)
static

Retrieves a boolean value from the configuration database. If an entry is not present the function will return an error. If an entry is present but its state is invalid the function will also return an error and set 'state' to CONFIGURATIONENTRY_STATE::INVALID. In that case you can use GetConfigurationDatabaseString to retrieve the text content of the entry.

Sample code showing correct usage:

Bool g_show_cells = true; // default value
Bool result;
ifnoerr (Configuration::QueryBool("g_show_cells"_s, result, origin, state))
g_show_cells = result; // only set value if no error occured
Parameters
[in]keyKey that is searched in the database.
[out]resultValue of the database entry if valid or false.
[out]originDocuments where the database entry was defined.
[out]stateState of the database entry.
Returns
IllegalArgumentError if there is no entry in the database or its value is invalid.

◆ QueryInt()

static MAXON_METHOD Result<void> QueryInt ( const String key,
Int result,
CONFIGURATIONENTRY_ORIGIN origin,
CONFIGURATIONENTRY_STATE state 
)
static

Retrieves an integer value from the configuration database. If an entry is not present the function will return an error. If an entry is present but its state is invalid the function will also return an error and set 'state' to CONFIGURATIONENTRY_STATE::INVALID. In that case you can use GetConfigurationDatabaseString to retrieve the text content of the entry.

Sample code showing correct usage:

Int g_cellNumber = 3; // default value
Int result;
ifnoerr (Configuration::QueryInt("g_cellNumber"_s, result, origin, state))
g_cellNumber = result; // only set value if no error occured
Parameters
[in]keyKey that is searched in the database.
[out]resultValue of the database entry if valid or 0.
[out]originDocuments where the database entry was defined.
[out]stateState of the database entry.
Returns
IllegalArgumentError if there is no entry in the database or its value is invalid.

◆ QueryFloat()

static MAXON_METHOD Result<void> QueryFloat ( const String key,
Float result,
CONFIGURATIONENTRY_ORIGIN origin,
CONFIGURATIONENTRY_STATE state 
)
static

Retrieves a floating point value from the configuration database. If an entry is not present the function will return an error. If an entry is present but its state is invalid the function will also return an error and set 'state' to CONFIGURATIONENTRY_STATE::INVALID. In that case you can use GetConfigurationDatabaseString to retrieve the text content of the entry.

Sample code showing correct usage:

Int g_cellSize = 3.0; // default value
Int result;
ifnoerr (Configuration::QueryInt("g_cellSize"_s, result, origin, state))
g_cellSize = result; // only set value if no error occured
Parameters
[in]keyKey that is searched in the database.
[out]resultValue of the database entry if valid or 0.0.
[out]originDocuments where the database entry was defined.
[out]stateState of the database entry.
Returns
IllegalArgumentError if there is no entry in the database or its value is invalid.

◆ QueryString()

static MAXON_METHOD Result<void> QueryString ( const String key,
String result,
CONFIGURATIONENTRY_ORIGIN origin,
CONFIGURATIONENTRY_STATE state 
)
static

Retrieves a string from the configuration database. This function can also be called on any boolean, integer or floating point types as all values are stored as strings in the database. If an entry is not present the function will return an error.

Sample code showing correct usage:

Int g_cellName = "unknown"_s; // default value
Int result;
ifnoerr (Configuration::QueryInt("g_cellName"_s, result, origin, state))
g_cellName = result; // only set value if no error occured
Parameters
[in]keyKey that is searched in the database.
[out]resultValue of the database entry or an empty string if not present.
[out]originDocuments where the database entry was defined.
[out]stateState of the database entry.
Returns
IllegalArgumentError if there is no entry in the database.

◆ AddHelpForBool()

static MAXON_METHOD Result<void> AddHelpForBool ( const String key,
Bool  defaultValue,
CONFIGURATION_CATEGORY  category,
const Char help 
)
static

Adds information to the help system (command line option 'help') and marks an entry in the configuration database as used (or invalid). This is necessary so that the application won't warn that a key is unknown. This routine must only be used for values created dynamically at runtime and not if a value was created by one of the MAXON_CONFIGURATION_XXX macros.

Parameters
[in]keyKey that is processed.
[in]defaultValueDefault value that will show up in the help information.
[in]categoryThe help category (should usually be set to either CONFIGURATION_CATEGORY::REGULAR or CONFIGURATION_CATEGORY::DEVELOPMENT).
[in]helpHelp text as a C string.
Returns
OK on success.

◆ AddHelpForInt()

static MAXON_METHOD Result<void> AddHelpForInt ( const String key,
Int  defaultValue,
Int  minValue,
Int  maxValue,
CONFIGURATION_CATEGORY  category,
const Char help 
)
static

Adds information to the help system (command line option 'help') and marks an entry in the configuration database as used (or invalid / out of range). This is necessary so that the application won't warn that a key is unknown. This routine must only be used for values created dynamically at runtime and not if a value was created by one of the MAXON_CONFIGURATION_XXX macros.

Parameters
[in]keyKey that is processed.
[in]defaultValueDefault value that will show up in the help information.
[in]minValueThe smallest allowed value.
[in]maxValueThe largest allowed value.
[in]categoryThe help category (should usually be set to either CONFIGURATION_CATEGORY::REGULAR or CONFIGURATION_CATEGORY::DEVELOPMENT).
[in]helpHelp text as a C string.
Returns
OK on success.

◆ AddHelpForFloat()

static MAXON_METHOD Result<void> AddHelpForFloat ( const String key,
Float  defaultValue,
Float  minValue,
Float  maxValue,
CONFIGURATION_CATEGORY  category,
const Char help 
)
static

Adds information to the help system (command line option 'help') and marks an entry in the configuration database as used (or invalid / out of range). This is necessary so that the application won't warn that a key is unknown. This routine must only be used for values created dynamically at runtime and not if a value was created by one of the MAXON_CONFIGURATION_XXX macros.

Parameters
[in]keyKey that is processed.
[in]defaultValueDefault value that will show up in the help information.
[in]minValueThe smallest allowed value.
[in]maxValueThe largest allowed value.
[in]categoryThe help category (should usually be set to either CONFIGURATION_CATEGORY::REGULAR or CONFIGURATION_CATEGORY::DEVELOPMENT).
[in]helpHelp text as a C string.
Returns
OK on success.

◆ AddHelpForString()

static MAXON_METHOD Result<void> AddHelpForString ( const String key,
const String defaultValue,
CONFIGURATION_CATEGORY  category,
const Char help 
)
static

Adds information to the help system (command line option 'help') and marks an entry in the configuration database as used (or invalid / out of range). This is necessary so that the application won't warn that a key is unknown. This routine must only be used for values created dynamically at runtime and not if a value was created by one of the MAXON_CONFIGURATION_XXX macros.

Parameters
[in]keyKey that is processed.
[in]defaultValueDefault value that will show up in the help information.
[in]categoryThe help category (should usually be set to either CONFIGURATION_CATEGORY::REGULAR or CONFIGURATION_CATEGORY::DEVELOPMENT).
[in]helpHelp text as a C string.
Returns
OK on success.

◆ AddHelpForOption()

static MAXON_METHOD Result<void> AddHelpForOption ( const String key,
const String option,
Bool  isDefaultValue,
Bool  caseSensitive,
CONFIGURATION_CATEGORY  category,
const Char help 
)
static

Adds information to the help system (command line option 'help') and marks an entry in the configuration database as used if the passed option was set. This is necessary so that the application won't warn that a key is unknown. This routine must only be used for values created dynamically at runtime and not if a value was created by one of the MAXON_CONFIGURATION_XXX macros. Call this routine multiple times to add all available options. category and help should be the same for each call. Example: three calls with option set to "a", "b" and then "c" will create the help text description key=[a|b|c]

Parameters
[in]keyKey that is processed.
[in]optionOption that the key is checked for.
[in]isDefaultValueDetermines if the passed option is the default value.
[in]caseSensitiveIf true the corresponding entry in the database will only be flagged if the case-sensitive comparison is successful.
[in]categoryThe help category (should usually be set to either CONFIGURATION_CATEGORY::REGULAR or CONFIGURATION_CATEGORY::DEVELOPMENT).
[in]helpHelp text as a C string.
Returns
OK on success.

◆ BroadcastBool()

static MAXON_METHOD Result<void> BroadcastBool ( const String key,
Bool  value 
)
static

Copies a value into all modules that defined it. E.g. in case of a crash situation g_inCrashhandler can be set to true with this routine.

Parameters
[in]keyCase-Sensitive key that is processed.
[in]valueValue to be set.
Returns
OK on success. A possible result value is IllegalArgumentError if the key did not exist.

◆ BroadcastInt()

static MAXON_METHOD Result<void> BroadcastInt ( const String key,
Int  value 
)
static

Copies a value into all modules that defined it. E.g. in case of a crash situation g_inCrashhandler can be set to true with this routine.

Parameters
[in]keyCase-Sensitive key that is processed.
[in]valueValue to be set.
Returns
OK on success. A possible result value is IllegalArgumentError if the key did not exist.

◆ BroadcastFloat()

static MAXON_METHOD Result<void> BroadcastFloat ( const String key,
Float  value 
)
static

Copies a value into all modules that defined it. E.g. in case of a crash situation g_inCrashhandler can be set to true with this routine.

Parameters
[in]keyCase-Sensitive key that is processed.
[in]valueValue to be set.
Returns
OK on success. A possible result value is IllegalArgumentError if the key did not exist.

◆ BroadcastString()

static MAXON_METHOD Result<void> BroadcastString ( const String key,
const String value 
)
static

Copies a value into all modules that defined it. E.g. in case of a crash situation g_inCrashhandler can be set to true with this routine.

Parameters
[in]keyCase-Sensitive key that is processed.
[in]valueValue to be set.
Returns
OK on success. A possible result value is IllegalArgumentError if the key did not exist.
Int
maxon::Int Int
Definition: ge_sys_math.h:64
ifnoerr
#define ifnoerr(...)
The opposite of iferr.
Definition: errorbase.h:385
maxon::Configuration::QueryBool
static MAXON_METHOD Result< void > QueryBool(const String &key, Bool &result, CONFIGURATIONENTRY_ORIGIN &origin, CONFIGURATIONENTRY_STATE &state)
maxon::CONFIGURATIONENTRY_ORIGIN
CONFIGURATIONENTRY_ORIGIN
Source where a configuration value was defined.
Definition: configuration.h:27
maxon::Configuration::QueryInt
static MAXON_METHOD Result< void > QueryInt(const String &key, Int &result, CONFIGURATIONENTRY_ORIGIN &origin, CONFIGURATIONENTRY_STATE &state)
Bool
maxon::Bool Bool
Definition: ge_sys_math.h:55
maxon::CONFIGURATIONENTRY_STATE
CONFIGURATIONENTRY_STATE
State of a configuration value.
Definition: configuration.h:36