#include <icy/configuration.h>ScopedConfiguration provides multiple levels of configuration for a module. Multiple levels means that there is a module level scope, and a default scope. When a property is accessed, the module scope value will be used if available, otherwise the default scope value will be used.
Example scoping: Module: channels.[name].modes.[name].[value] Default: modes.[name].[value]
| Return | Name | Description |
|---|---|---|
Configuration & | config | |
std::string | currentScope | |
std::string | defaultScope |
Configuration & configstd::string currentScopestd::string defaultScope| Return | Name | Description |
|---|---|---|
ScopedConfiguration | #### Parameters | |
ScopedConfiguration | ||
std::string | getString const | Returns the string value, trying currentScope first then defaultScope. |
int | getInt const | Returns the int value, trying currentScope first then defaultScope. |
double | getDouble const | Returns the double value, trying currentScope first then defaultScope. |
bool | getBool const | Returns the bool value, trying currentScope first then defaultScope. |
void | setString | Writes a string value under the scoped key. |
void | setInt | Writes an int value under the scoped key. |
void | setDouble | Writes a double value under the scoped key. |
void | setBool | Writes a bool value under the scoped key. |
std::string | getCurrentScope const | #### Parameters |
std::string | getDafaultKey const | #### Parameters |
std::string | getScopedKey const | #### Parameters |
ScopedConfiguration(Configuration & config, const std::string & currentScope, const std::string & defaultScope)config Backing configuration store.
currentScope Key prefix for the module-level scope.
defaultScope Key prefix for the default/fallback scope.
ScopedConfiguration(const ScopedConfiguration & that)const
std::string getString(const std::string & key, const std::string & defaultValue, bool forceDefaultScope) constReturns the string value, trying currentScope first then defaultScope.
key Property key (without scope prefix).
defaultValue Fallback when neither scope has the key.
forceDefaultScope If true, skips currentScope and reads from defaultScope only.
Property value or defaultValue.
const
int getInt(const std::string & key, int defaultValue, bool forceDefaultScope) constReturns the int value, trying currentScope first then defaultScope.
key Property key (without scope prefix).
defaultValue Fallback when neither scope has the key.
forceDefaultScope If true, reads from defaultScope only.
Property value or defaultValue.
const
double getDouble(const std::string & key, double defaultValue, bool forceDefaultScope) constReturns the double value, trying currentScope first then defaultScope.
key Property key (without scope prefix).
defaultValue Fallback when neither scope has the key.
forceDefaultScope If true, reads from defaultScope only.
Property value or defaultValue.
const
bool getBool(const std::string & key, bool defaultValue, bool forceDefaultScope) constReturns the bool value, trying currentScope first then defaultScope.
key Property key (without scope prefix).
defaultValue Fallback when neither scope has the key.
forceDefaultScope If true, reads from defaultScope only.
Property value or defaultValue.
void setString(const std::string & key, const std::string & value, bool defaultScope)Writes a string value under the scoped key.
key Property key (without scope prefix).
value Value to store.
defaultScope If true, writes to defaultScope; otherwise to currentScope.
void setInt(const std::string & key, int value, bool defaultScope)Writes an int value under the scoped key.
key Property key (without scope prefix).
value Value to store.
defaultScope If true, writes to defaultScope; otherwise to currentScope.
void setDouble(const std::string & key, double value, bool defaultScope)Writes a double value under the scoped key.
key Property key (without scope prefix).
value Value to store.
defaultScope If true, writes to defaultScope; otherwise to currentScope.
void setBool(const std::string & key, bool value, bool defaultScope)Writes a bool value under the scoped key.
key Property key (without scope prefix).
value Value to store.
defaultScope If true, writes to defaultScope; otherwise to currentScope.
const
std::string getCurrentScope(const std::string & key) constkey Property key (without scope prefix).Fully qualified key in currentScope.
const
std::string getDafaultKey(const std::string & key) constkey Property key (without scope prefix).Fully qualified key in defaultScope.
const
std::string getScopedKey(const std::string & key, bool defaultScope) constkey Property key (without scope prefix).
defaultScope If true, returns the defaultScope key; otherwise currentScope key.
Fully qualified scoped key string.