Home
Base module

Configuration

Configuration is an abstract base class for managing different kinds of configuration storage back ends such as JSON, XML, or database.

Configuration

#include <icy/configuration.h>
class Configuration

Defined 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

NameKindOwner
PropertyChangedvariableDeclared here
ConfigurationfunctionDeclared here
~ConfigurationfunctionDeclared here
existsfunctionDeclared here
getStringfunctionDeclared here
getStringfunctionDeclared here
getRawStringfunctionDeclared here
getRawStringfunctionDeclared here
getIntfunctionDeclared here
getIntfunctionDeclared here
getLargeIntfunctionDeclared here
getLargeIntfunctionDeclared here
getDoublefunctionDeclared here
getDoublefunctionDeclared here
getBoolfunctionDeclared here
getBoolfunctionDeclared here
setStringfunctionDeclared here
setIntfunctionDeclared here
setLargeIntfunctionDeclared here
setDoublefunctionDeclared here
setBoolfunctionDeclared here
getRawfunctionDeclared here
setRawfunctionDeclared here
ConfigurationfunctionDeclared here
operator=functionDeclared here
ConfigurationfunctionDeclared here
operator=functionDeclared here
_mutexvariableDeclared here

Public Attributes

ReturnNameDescription
ThreadSignal< void(const std::string &, const std::string &)>PropertyChangedThe Key and Value of the changed configuration property.

PropertyChanged

ThreadSignal< void(const std::string &, const std::string &)> PropertyChanged

Defined in src/base/include/icy/configuration.h:138

The Key and Value of the changed configuration property.

Public Methods

ReturnNameDescription
ConfigurationCreates the Configuration.
~Configuration virtualDestroys the Configuration.
boolexists constReturns true if the property with the given key exists.
std::stringgetString constReturns the string value of the property with the given name. Throws a NotFoundException if the key does not exist.
std::stringgetString constIf a property with the given key exists, returns the property's string value, otherwise returns the given default value.
std::stringgetRawString 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.
std::stringgetRawString 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.
intgetInt 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.
intgetInt 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.
std::int64_tgetLargeInt 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.
std::int64_tgetLargeInt 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.
doublegetDouble 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.
doublegetDouble 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.
boolgetBool 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.
boolgetBool 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:
voidsetStringSets the property with the given key to the given value. An already existing value for the key is overwritten.
voidsetIntSets the property with the given key to the given value. An already existing value for the key is overwritten.
voidsetLargeIntSets the property with the given key to the given value. An already existing value for the key is overwritten.
voidsetDoubleSets the property with the given key to the given value. An already existing value for the key is overwritten.
voidsetBoolSets 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) const

Defined 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) const

Defined 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) const

Defined 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) const

Defined 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) const

Defined 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) const

Defined 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) const

Defined 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) const

Defined 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) const

Defined 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) const

Defined 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) const

Defined 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) const

Defined 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) const

Defined 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

ReturnNameDescription
boolgetRaw virtual constIf the property with the given key exists, stores the property's value in value and returns true. Otherwise, returns false.
voidsetRaw virtualSets the property with the given key to the given value. An already existing value for the key is overwritten.
ConfigurationDeleted constructor.
ConfigurationDeleted constructor.

getRaw

virtual const

virtual bool getRaw(const std::string & key, std::string & value) const

Defined 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 &) = delete

Defined in src/base/include/icy/configuration.h:170

Deleted constructor.


Configuration

Configuration(Configuration &&) = delete

Defined in src/base/include/icy/configuration.h:172

Deleted constructor.

Private Attributes

ReturnNameDescription
std::mutex_mutex

_mutex

std::mutex _mutex

Defined in src/base/include/icy/configuration.h:176