Configuration
Configuration
#include <icy/configuration.h>class ConfigurationDefined in src/base/include/icy/configuration.h:31
Subclassed by:
Configuration
Configuration is an abstract base class for managing different kinds of configuration storage back ends such as JSON, XML, or database.
Subclasses must override the getRaw() and setRaw() and methods.
This class is safe for multithreaded use.
List of all members
| Name | Kind | Owner |
|---|---|---|
PropertyChanged | variable | Declared here |
Configuration | function | Declared here |
~Configuration | function | Declared here |
exists | function | Declared here |
getString | function | Declared here |
getString | function | Declared here |
getRawString | function | Declared here |
getRawString | function | Declared here |
getInt | function | Declared here |
getInt | function | Declared here |
getLargeInt | function | Declared here |
getLargeInt | function | Declared here |
getDouble | function | Declared here |
getDouble | function | Declared here |
getBool | function | Declared here |
getBool | function | Declared here |
setString | function | Declared here |
setInt | function | Declared here |
setLargeInt | function | Declared here |
setDouble | function | Declared here |
setBool | function | Declared here |
getRaw | function | Declared here |
setRaw | function | Declared here |
Configuration | function | Declared here |
operator= | function | Declared here |
Configuration | function | Declared here |
operator= | function | Declared here |
_mutex | variable | Declared here |
Public Attributes
| Return | Name | Description |
|---|---|---|
ThreadSignal< void(const std::string &, const std::string &)> | PropertyChanged | The Key and Value of the changed configuration property. |
PropertyChanged
ThreadSignal< void(const std::string &, const std::string &)> PropertyChangedDefined in src/base/include/icy/configuration.h:138
The Key and Value of the changed configuration property.
Public Methods
| Return | Name | Description |
|---|---|---|
Configuration | Creates the Configuration. | |
~Configuration virtual | Destroys the Configuration. | |
bool | exists const | Returns true if the property with the given key exists. |
std::string | getString const | Returns the string value of the property with the given name. Throws a NotFoundException if the key does not exist. |
std::string | getString const | If a property with the given key exists, returns the property's string value, otherwise returns the given default value. |
std::string | getRawString const | Returns the raw string value of the property with the given name. Throws a NotFoundException if the key does not exist. References to other properties are not expanded. |
std::string | getRawString const | If a property with the given key exists, returns the property's raw string value, otherwise returns the given default value. References to other properties are not expanded. |
int | getInt const | Returns the int value of the property with the given name. Throws a NotFoundException if the key does not exist. Throws a SyntaxException if the property can not be converted to an int. Numbers starting with 0x are treated as hexadecimal. |
int | getInt const | If a property with the given key exists, returns the property's int value, otherwise returns the given default value. Throws a SyntaxException if the property can not be converted to an int. Numbers starting with 0x are treated as hexadecimal. |
std::int64_t | getLargeInt const | Returns the int value of the property with the given name. Throws a NotFoundException if the key does not exist. Throws a SyntaxException if the property can not be converted to an int. Numbers starting with 0x are treated as hexadecimal. |
std::int64_t | getLargeInt const | If a property with the given key exists, returns the property's int value, otherwise returns the given default value. Throws a SyntaxException if the property can not be converted to an int. Numbers starting with 0x are treated as hexadecimal. |
double | getDouble const | Returns the double value of the property with the given name. Throws a NotFoundException if the key does not exist. Throws a SyntaxException if the property can not be converted to a double. |
double | getDouble const | If a property with the given key exists, returns the property's double value, otherwise returns the given default value. Throws a SyntaxException if the property can not be converted to an double. |
bool | getBool const | Returns the double value of the property with the given name. Throws a NotFoundException if the key does not exist. Throws a SyntaxException if the property can not be converted to a double. |
bool | getBool const | If a property with the given key exists, returns the property's bool value, otherwise returns the given default value. Throws a SyntaxException if the property can not be converted to a boolean. The following string values can be converted into a boolean: |
void | setString | Sets the property with the given key to the given value. An already existing value for the key is overwritten. |
void | setInt | Sets the property with the given key to the given value. An already existing value for the key is overwritten. |
void | setLargeInt | Sets the property with the given key to the given value. An already existing value for the key is overwritten. |
void | setDouble | Sets the property with the given key to the given value. An already existing value for the key is overwritten. |
void | setBool | Sets the property with the given key to the given value. An already existing value for the key is overwritten. |
Configuration
Configuration()Defined in src/base/include/icy/configuration.h:35
Creates the Configuration.
~Configuration
virtual
virtual ~Configuration()Defined in src/base/include/icy/configuration.h:38
Destroys the Configuration.
Reimplemented by
exists
const
bool exists(const std::string & key) constDefined in src/base/include/icy/configuration.h:41
Returns true if the property with the given key exists.
getString
const
std::string getString(const std::string & key) constDefined in src/base/include/icy/configuration.h:45
Returns the string value of the property with the given name. Throws a NotFoundException if the key does not exist.
getString
const
std::string getString(const std::string & key, const std::string & defaultValue) constDefined in src/base/include/icy/configuration.h:49
If a property with the given key exists, returns the property's string value, otherwise returns the given default value.
getRawString
const
std::string getRawString(const std::string & key) constDefined in src/base/include/icy/configuration.h:54
Returns the raw string value of the property with the given name. Throws a NotFoundException if the key does not exist. References to other properties are not expanded.
getRawString
const
std::string getRawString(const std::string & key, const std::string & defaultValue) constDefined in src/base/include/icy/configuration.h:59
If a property with the given key exists, returns the property's raw string value, otherwise returns the given default value. References to other properties are not expanded.
getInt
const
int getInt(const std::string & key) constDefined in src/base/include/icy/configuration.h:66
Returns the int value of the property with the given name. Throws a NotFoundException if the key does not exist. Throws a SyntaxException if the property can not be converted to an int. Numbers starting with 0x are treated as hexadecimal.
getInt
const
int getInt(const std::string & key, int defaultValue) constDefined in src/base/include/icy/configuration.h:73
If a property with the given key exists, returns the property's int value, otherwise returns the given default value. Throws a SyntaxException if the property can not be converted to an int. Numbers starting with 0x are treated as hexadecimal.
getLargeInt
const
std::int64_t getLargeInt(const std::string & key) constDefined in src/base/include/icy/configuration.h:80
Returns the int value of the property with the given name. Throws a NotFoundException if the key does not exist. Throws a SyntaxException if the property can not be converted to an int. Numbers starting with 0x are treated as hexadecimal.
getLargeInt
const
std::int64_t getLargeInt(const std::string & key, std::int64_t defaultValue) constDefined in src/base/include/icy/configuration.h:88
If a property with the given key exists, returns the property's int value, otherwise returns the given default value. Throws a SyntaxException if the property can not be converted to an int. Numbers starting with 0x are treated as hexadecimal.
getDouble
const
double getDouble(const std::string & key) constDefined in src/base/include/icy/configuration.h:94
Returns the double value of the property with the given name. Throws a NotFoundException if the key does not exist. Throws a SyntaxException if the property can not be converted to a double.
getDouble
const
double getDouble(const std::string & key, double defaultValue) constDefined in src/base/include/icy/configuration.h:100
If a property with the given key exists, returns the property's double value, otherwise returns the given default value. Throws a SyntaxException if the property can not be converted to an double.
getBool
const
bool getBool(const std::string & key) constDefined in src/base/include/icy/configuration.h:106
Returns the double value of the property with the given name. Throws a NotFoundException if the key does not exist. Throws a SyntaxException if the property can not be converted to a double.
getBool
const
bool getBool(const std::string & key, bool defaultValue) constDefined in src/base/include/icy/configuration.h:115
If a property with the given key exists, returns the property's bool value, otherwise returns the given default value. Throws a SyntaxException if the property can not be converted to a boolean. The following string values can be converted into a boolean:
numerical values: non zero becomes true, zero becomes false
strings: true, yes, on become true, false, no, off become false Case does not matter.
setString
void setString(const std::string & key, const std::string & value)Defined in src/base/include/icy/configuration.h:119
Sets the property with the given key to the given value. An already existing value for the key is overwritten.
setInt
void setInt(const std::string & key, int value)Defined in src/base/include/icy/configuration.h:123
Sets the property with the given key to the given value. An already existing value for the key is overwritten.
setLargeInt
void setLargeInt(const std::string & key, std::int64_t value)Defined in src/base/include/icy/configuration.h:127
Sets the property with the given key to the given value. An already existing value for the key is overwritten.
setDouble
void setDouble(const std::string & key, double value)Defined in src/base/include/icy/configuration.h:131
Sets the property with the given key to the given value. An already existing value for the key is overwritten.
setBool
void setBool(const std::string & key, bool value)Defined in src/base/include/icy/configuration.h:135
Sets the property with the given key to the given value. An already existing value for the key is overwritten.
Protected Methods
| Return | Name | Description |
|---|---|---|
bool | getRaw virtual const | If the property with the given key exists, stores the property's value in value and returns true. Otherwise, returns false. |
void | setRaw virtual | Sets the property with the given key to the given value. An already existing value for the key is overwritten. |
Configuration | Deleted constructor. | |
Configuration | Deleted constructor. |
getRaw
virtual const
virtual bool getRaw(const std::string & key, std::string & value) constDefined in src/base/include/icy/configuration.h:145
If the property with the given key exists, stores the property's value in value and returns true. Otherwise, returns false.
Must be overridden by subclasses.
Reimplemented by
setRaw
virtual
virtual void setRaw(const std::string & key, const std::string & value)Defined in src/base/include/icy/configuration.h:151
Sets the property with the given key to the given value. An already existing value for the key is overwritten.
The implementation is responsible for emitting the PropertyChanged signal.
Reimplemented by
Configuration
Configuration(const Configuration &) = deleteDefined in src/base/include/icy/configuration.h:170
Deleted constructor.
Configuration
Configuration(Configuration &&) = deleteDefined in src/base/include/icy/configuration.h:172
Deleted constructor.
Private Attributes
| Return | Name | Description |
|---|---|---|
std::mutex | _mutex |
_mutex
std::mutex _mutex