Configuration Class Reference

#include <configurationdatabase.h>

详细描述

配置 database 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)

私有成员函数

  MAXON_INTERFACE_NONVIRTUAL ( 配置 , MAXON_REFERENCE_NONE , "net.maxon.interface.configuration")

成员函数文档编制

◆  MAXON_INTERFACE_NONVIRTUAL()

MAXON_INTERFACE_NONVIRTUAL ( 配置   ,
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; CONFIGURATIONENTRY_ORIGIN origin; CONFIGURATIONENTRY_STATE state; ifnoerr ( Configuration::QueryBool ( "g_show_cells" _s, result, origin, state)) g_show_cells = result; // only set value if no error occured
参数
[in] key Key that is searched in the database.
[out] result Value of the database entry if valid or false.
[out] origin Documents where the database entry was defined.
[out] state State of the database entry.
返回
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; CONFIGURATIONENTRY_ORIGIN origin; CONFIGURATIONENTRY_STATE state; ifnoerr ( Configuration::QueryInt ( "g_cellNumber" _s, result, origin, state)) g_cellNumber = result; // only set value if no error occured
参数
[in] key Key that is searched in the database.
[out] result Value of the database entry if valid or 0.
[out] origin Documents where the database entry was defined.
[out] state State of the database entry.
返回
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; CONFIGURATIONENTRY_ORIGIN origin; CONFIGURATIONENTRY_STATE state; ifnoerr ( Configuration::QueryInt ( "g_cellSize" _s, result, origin, state)) g_cellSize = result; // only set value if no error occured
参数
[in] key Key that is searched in the database.
[out] result Value of the database entry if valid or 0.0.
[out] origin Documents where the database entry was defined.
[out] state State of the database entry.
返回
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; CONFIGURATIONENTRY_ORIGIN origin; CONFIGURATIONENTRY_STATE state; ifnoerr ( Configuration::QueryInt ( "g_cellName" _s, result, origin, state)) g_cellName = result; // only set value if no error occured
参数
[in] key Key that is searched in the database.
[out] result Value of the database entry or an empty string if not present.
[out] origin Documents where the database entry was defined.
[out] state State of the database entry.
返回
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.

参数
[in] key Key that is processed.
[in] defaultValue Default value that will show up in the help information.
[in] category The help category (should usually be set to either CONFIGURATION_CATEGORY::REGULAR or CONFIGURATION_CATEGORY::DEVELOPMENT ).
[in] help Help text as a C string.
返回
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.

参数
[in] key Key that is processed.
[in] defaultValue Default value that will show up in the help information.
[in] minValue The smallest allowed value.
[in] maxValue The largest allowed value.
[in] category The help category (should usually be set to either CONFIGURATION_CATEGORY::REGULAR or CONFIGURATION_CATEGORY::DEVELOPMENT ).
[in] help Help text as a C string.
返回
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.

参数
[in] key Key that is processed.
[in] defaultValue Default value that will show up in the help information.
[in] minValue The smallest allowed value.
[in] maxValue The largest allowed value.
[in] category The help category (should usually be set to either CONFIGURATION_CATEGORY::REGULAR or CONFIGURATION_CATEGORY::DEVELOPMENT ).
[in] help Help text as a C string.
返回
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.

参数
[in] key Key that is processed.
[in] defaultValue Default value that will show up in the help information.
[in] category The help category (should usually be set to either CONFIGURATION_CATEGORY::REGULAR or CONFIGURATION_CATEGORY::DEVELOPMENT ).
[in] help Help text as a C string.
返回
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]

参数
[in] key Key that is processed.
[in] option Option that the key is checked for.
[in] isDefaultValue Determines if the passed option is the default value.
[in] caseSensitive If true the corresponding entry in the database will only be flagged if the case-sensitive comparison is successful.
[in] category The help category (should usually be set to either CONFIGURATION_CATEGORY::REGULAR or CONFIGURATION_CATEGORY::DEVELOPMENT ).
[in] help Help text as a C string.
返回
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.

参数
[in] key Case-Sensitive key that is processed.
[in] value Value to be set.
返回
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.

参数
[in] key Case-Sensitive key that is processed.
[in] value Value to be set.
返回
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.

参数
[in] key Case-Sensitive key that is processed.
[in] value Value to be set.
返回
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.

参数
[in] key Case-Sensitive key that is processed.
[in] value Value to be set.
返回
OK on success. A possible result value is IllegalArgumentError if the key did not exist.
Int
maxon::Int Int
定义: ge_sys_math.h:62
ifnoerr
#define ifnoerr(...)
The opposite of iferr.
定义: 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.
定义: configuration.h:26
maxon::Configuration::QueryInt
static MAXON_METHOD Result< void > QueryInt(const String &key, Int &result, CONFIGURATIONENTRY_ORIGIN &origin, CONFIGURATIONENTRY_STATE &state)
Bool
maxon::Bool Bool
定义: ge_sys_math.h:53
maxon::CONFIGURATIONENTRY_STATE
CONFIGURATIONENTRY_STATE
State of a configuration value.
定义: configuration.h:35