#include <icy/configuration.h>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.
| Return | Name | Description |
|---|---|---|
ThreadSignal< void(const std::string &, const std::string &)> | PropertyChanged | The Key and Value of the changed configuration property. |
ThreadSignal< void(const std::string &, const std::string &)> PropertyChangedThe Key and Value of the changed configuration property.
| 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()Creates the Configuration.
virtual
virtual ~Configuration()Destroys the Configuration.
const
bool exists(const std::string & key) constReturns true if the property with the given key exists.
const
std::string getString(const std::string & key) constReturns the string value of the property with the given name. Throws a NotFoundException if the key does not exist.
const
std::string getString(const std::string & key, const std::string & defaultValue) constIf a property with the given key exists, returns the property's string value, otherwise returns the given default value.
const
std::string getRawString(const std::string & key) constReturns 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.
const
std::string getRawString(const std::string & key, const std::string & defaultValue) constIf 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.
const
int getInt(const std::string & key) constReturns 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.
const
int getInt(const std::string & key, int defaultValue) constIf 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.
const
std::int64_t getLargeInt(const std::string & key) constReturns 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.
const
std::int64_t getLargeInt(const std::string & key, std::int64_t defaultValue) constIf 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.
const
double getDouble(const std::string & key) constReturns 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.
const
double getDouble(const std::string & key, double defaultValue) constIf 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.
const
bool getBool(const std::string & key) constReturns 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.
const
bool getBool(const std::string & key, bool defaultValue) constIf 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.
void setString(const std::string & key, const std::string & value)Sets the property with the given key to the given value. An already existing value for the key is overwritten.
void setInt(const std::string & key, int value)Sets the property with the given key to the given value. An already existing value for the key is overwritten.
void setLargeInt(const std::string & key, std::int64_t value)Sets the property with the given key to the given value. An already existing value for the key is overwritten.
void setDouble(const std::string & key, double value)Sets the property with the given key to the given value. An already existing value for the key is overwritten.
void setBool(const std::string & key, bool value)Sets the property with the given key to the given value. An already existing value for the key is overwritten.
| Return | Name | Description |
|---|---|---|
bool | getRaw const | If the property with the given key exists, stores the property's value in value and returns true. Otherwise, returns false. |
void | setRaw | 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. |
const
bool getRaw(const std::string & key, std::string & value) constIf 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.
void setRaw(const std::string & key, const std::string & value)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.
Configuration(const Configuration &) = deleteDeleted constructor.
Configuration(Configuration &&) = deleteDeleted constructor.
| Return | Name | Description |
|---|---|---|
std::mutex | _mutex |
std::mutex _mutex