Ocean
|
This class implements an application or module configuration toolkit. More...
Data Structures | |
class | Value |
This class implements a configuration value. More... | |
Public Types | |
enum | ValueType { TYPE_INVALID , TYPE_UNDEFINED , TYPE_BOOL , TYPE_INT , TYPE_NUMBER , TYPE_STRING , TYPE_MULTI_BOOL , TYPE_MULTI_INT , TYPE_MULTI_NUMBER , TYPE_MULTI_STRING , TYPE_GROUP } |
Definition of different value types. More... | |
Public Member Functions | |
virtual | ~Config () |
Destructs a configuration toolkit. More... | |
virtual bool | read () |
Reads / loads all values of this configuration. More... | |
virtual bool | write () |
Writes / saves all values of this configuration. More... | |
Timestamp | writeTimestamp () const |
Returns the timestamp of the last write execution. More... | |
virtual unsigned int | values () const |
Returns the number of sub values. More... | |
virtual unsigned int | values (const std::string &name) const |
Returns the number of sub values with a given name. More... | |
virtual bool | exist (const std::string &name) const |
Returns whether this value holds at least one specified sub value. More... | |
virtual Value & | value (const unsigned int index, std::string &name) |
Returns a sub value specified by it's index. More... | |
virtual bool | value (const unsigned int index, std::string &name, Value **value) |
Returns a sub value specified by it's index. More... | |
virtual bool | value (const std::string &name, const unsigned int index, Value **value) |
Returns a sub value specified by it's name and it's index if more than one value exists with the same name. More... | |
virtual Value & | value (const std::string &name, const unsigned int index=0) |
Returns a sub value specified by it's name and it's index if more than one value exists with the same name. More... | |
virtual Value & | add (const std::string &name) |
Adds a new sub value specified by it's name. More... | |
virtual Value & | operator[] (const std::string &name) |
Returns the first sub value specified by it's name or creates a new one if not existing. More... | |
Protected Member Functions | |
Config () | |
Creates a new configuration toolkit. More... | |
Config (const Config &config)=delete | |
Disabled copy constructor. More... | |
Config & | operator= (const Config &config)=delete |
Disabled copy operator. More... | |
Static Protected Member Functions | |
static Value & | nullValue () |
Returns the default value holding no data. More... | |
Protected Attributes | |
Timestamp | writeTimestamp_ |
Holds the timestamp of the most recent write execution. More... | |
This class implements an application or module configuration toolkit.
Each configuration toolkit holds a value tree.
Different single value types are supported like e.g. boolean, integer or strings.
Furthermore, groups can be specified holding an arbitrary number of sub values.
Values names does not need to be unique. Therefore, a group can hold several sub values with the same name.
Also, values with the same name can have different value types.
However, this is an abstract configuration object and therefore should be used as platform independent interface only.
Use e.g. file configuration or a registry configuration object instead. The entire object is not thread-safe.
Definition of different value types.
Enumerator | |
---|---|
TYPE_INVALID | Invalid value type. |
TYPE_UNDEFINED | Undefined value type. |
TYPE_BOOL | Boolean value type. |
TYPE_INT | Integer value type. |
TYPE_NUMBER | Number value type. |
TYPE_STRING | String value type. |
TYPE_MULTI_BOOL | Multi boolean value type. |
TYPE_MULTI_INT | Multi integer value type. |
TYPE_MULTI_NUMBER | Multi number value type. |
TYPE_MULTI_STRING | Multi string value type. |
TYPE_GROUP | Group value type. |
|
virtual |
Destructs a configuration toolkit.
|
protected |
Creates a new configuration toolkit.
|
protecteddelete |
Disabled copy constructor.
config | Object which would be copied |
|
virtual |
Adds a new sub value specified by it's name.
name | The name of the sub value to create |
Reimplemented in Ocean::IO::XMLConfig, Ocean::IO::JSONConfig, and Ocean::IO::FileConfig.
|
virtual |
Returns whether this value holds at least one specified sub value.
name | The name of the sub value to check |
Reimplemented in Ocean::Platform::Win::RegistryConfig, Ocean::IO::XMLConfig, Ocean::IO::JSONConfig, and Ocean::IO::FileConfig.
|
staticprotected |
Returns the default value holding no data.
Disabled copy operator.
config | Object which would be copied |
|
virtual |
Returns the first sub value specified by it's name or creates a new one if not existing.
name | The name of the sub value to return |
Reimplemented in Ocean::Platform::Win::RegistryConfig, Ocean::IO::XMLConfig, Ocean::IO::JSONConfig, and Ocean::IO::FileConfig.
|
virtual |
Reads / loads all values of this configuration.
Reimplemented in Ocean::Platform::Win::RegistryConfig, Ocean::IO::XMLConfig, Ocean::IO::JSONConfig, and Ocean::IO::FileConfig.
|
virtual |
Returns a sub value specified by it's name and it's index if more than one value exists with the same name.
name | The name of the value to return |
index | The index within those sub values with the specified name |
value | Resulting sub value |
Reimplemented in Ocean::Platform::Win::RegistryConfig, Ocean::IO::XMLConfig, Ocean::IO::JSONConfig, and Ocean::IO::FileConfig.
|
virtual |
Returns a sub value specified by it's name and it's index if more than one value exists with the same name.
name | The name of the value to return |
index | The index within those sub values with the specified name |
Reimplemented in Ocean::Platform::Win::RegistryConfig, Ocean::IO::XMLConfig, Ocean::IO::JSONConfig, and Ocean::IO::FileConfig.
|
virtual |
Returns a sub value specified by it's index.
index | The index of the sub value to return |
name | Resulting name of the returning value |
Reimplemented in Ocean::Platform::Win::RegistryConfig, Ocean::IO::XMLConfig, Ocean::IO::JSONConfig, and Ocean::IO::FileConfig.
|
virtual |
Returns a sub value specified by it's index.
index | The index of the sub value to return |
name | Resulting name of the returning value |
value | Resulting sub value |
Reimplemented in Ocean::Platform::Win::RegistryConfig, Ocean::IO::XMLConfig, Ocean::IO::JSONConfig, and Ocean::IO::FileConfig.
|
virtual |
Returns the number of sub values.
Reimplemented in Ocean::Platform::Win::RegistryConfig, Ocean::IO::XMLConfig, Ocean::IO::JSONConfig, and Ocean::IO::FileConfig.
|
virtual |
Returns the number of sub values with a given name.
name | The name of the sub values to return |
Reimplemented in Ocean::Platform::Win::RegistryConfig, Ocean::IO::XMLConfig, Ocean::IO::JSONConfig, and Ocean::IO::FileConfig.
|
virtual |
Writes / saves all values of this configuration.
Reimplemented in Ocean::Platform::Win::RegistryConfig, Ocean::IO::XMLConfig, Ocean::IO::JSONConfig, and Ocean::IO::FileConfig.
|
inline |
Returns the timestamp of the last write execution.
|
protected |
Holds the timestamp of the most recent write execution.