Ark Server API (ASE) - Wiki
|
#include <AbstractConfiguration.h>
Classes | |
class | KeyValue |
A key-value pair, used as event argument. More... | |
Public Types | |
using | Keys = std::vector<std::string> |
using | Ptr = AutoPtr<AbstractConfiguration> |
Public Member Functions | |
AbstractConfiguration () | |
bool | hasProperty (const std::string &key) const |
Creates the AbstractConfiguration. | |
bool | hasOption (const std::string &key) const |
Returns true iff the property with the given key exists. | |
bool | has (const std::string &key) const |
std::string | getString (const std::string &key) const |
std::string | getString (const std::string &key, const std::string &defaultValue) const |
std::string | getRawString (const std::string &key) const |
std::string | getRawString (const std::string &key, const std::string &defaultValue) const |
int | getInt (const std::string &key) const |
unsigned int | getUInt (const std::string &key) const |
int | getInt (const std::string &key, int defaultValue) const |
unsigned int | getUInt (const std::string &key, unsigned int defaultValue) const |
double | getDouble (const std::string &key) const |
double | getDouble (const std::string &key, double defaultValue) const |
bool | getBool (const std::string &key) const |
bool | getBool (const std::string &key, bool defaultValue) const |
virtual void | setString (const std::string &key, const std::string &value) |
virtual void | setInt (const std::string &key, int value) |
virtual void | setUInt (const std::string &key, unsigned int value) |
virtual void | setDouble (const std::string &key, double value) |
virtual void | setBool (const std::string &key, bool value) |
void | keys (Keys &range) const |
void | keys (const std::string &key, Keys &range) const |
Returns in range the names of all keys at root level. | |
const Ptr | createView (const std::string &prefix) const |
Ptr | createView (const std::string &prefix) |
Creates a non-mutable view (see ConfigurationView) into the configuration. | |
std::string | expand (const std::string &value) const |
Creates a view (see ConfigurationView) into the configuration. | |
void | remove (const std::string &key) |
void | enableEvents (bool enable=true) |
bool | eventsEnabled () const |
Enables (or disables) events. | |
Public Member Functions inherited from Poco::RefCountedObject | |
RefCountedObject () | |
void | duplicate () const |
void | release () const noexcept |
Increments the object's reference count. | |
int | referenceCount () const |
Public Attributes | |
Poco::BasicEvent< KeyValue > | propertyChanging |
Poco::BasicEvent< const KeyValue > | propertyChanged |
Poco::BasicEvent< const std::string > | propertyRemoving |
Poco::BasicEvent< const std::string > | propertyRemoved |
Protected Member Functions | |
virtual bool | getRaw (const std::string &key, std::string &value) const =0 |
Returns true iff events are enabled. | |
virtual void | setRaw (const std::string &key, const std::string &value)=0 |
virtual void | enumerate (const std::string &key, Keys &range) const =0 |
virtual void | removeRaw (const std::string &key) |
void | setRawWithEvent (const std::string &key, std::string value) |
virtual | ~AbstractConfiguration () |
Protected Member Functions inherited from Poco::RefCountedObject | |
virtual | ~RefCountedObject () |
Returns the reference count. | |
Static Protected Member Functions | |
static int | parseInt (const std::string &value) |
static unsigned | parseUInt (const std::string &value) |
static bool | parseBool (const std::string &value) |
Private Member Functions | |
std::string | internalExpand (const std::string &value) const |
std::string | uncheckedExpand (const std::string &value) const |
AbstractConfiguration (const AbstractConfiguration &) | |
AbstractConfiguration & | operator= (const AbstractConfiguration &) |
Private Attributes | |
int | _depth |
bool | _eventsEnabled |
Poco::Mutex | _mutex |
Friends | |
class | LayeredConfiguration |
class | ConfigurationView |
class | ConfigurationMapper |
AbstractConfiguration is an abstract base class for different kinds of configuration data, such as INI files, property files, XML configuration files or the Windows Registry.
Configuration property keys have a hierarchical format, consisting of names separated by periods. The exact interpretation of key names is up to the actual subclass implementation of AbstractConfiguration. Keys are case sensitive.
All public methods are synchronized, so the class is safe for multithreaded use. AbstractConfiguration implements reference counting based garbage collection.
Subclasses must override the getRaw(), setRaw() and enumerate() methods.
Definition at line 34 of file AbstractConfiguration.h.
using Poco::Util::AbstractConfiguration::Keys = std::vector<std::string> |
Definition at line 50 of file AbstractConfiguration.h.
Definition at line 51 of file AbstractConfiguration.h.
Poco::Util::AbstractConfiguration::AbstractConfiguration | ( | ) |
Fired after a property has been removed by a call to remove().
|
protectedvirtual |
|
private |
Ptr Poco::Util::AbstractConfiguration::createView | ( | const std::string & | prefix | ) |
Creates a non-mutable view (see ConfigurationView) into the configuration.
const Ptr Poco::Util::AbstractConfiguration::createView | ( | const std::string & | prefix | ) | const |
Returns in range the names of all subkeys under the given key. If an empty key is passed, all root level keys are returned.
void Poco::Util::AbstractConfiguration::enableEvents | ( | bool | enable = true | ) |
Removes the property with the given key.
Does nothing if the key does not exist.
|
protectedpure virtual |
Sets the property with the given key to the given value. An already existing value for the key is overwritten.
Must be overridden by subclasses.
bool Poco::Util::AbstractConfiguration::eventsEnabled | ( | ) | const |
Enables (or disables) events.
std::string Poco::Util::AbstractConfiguration::expand | ( | const std::string & | value | ) | const |
Creates a view (see ConfigurationView) into the configuration.
bool Poco::Util::AbstractConfiguration::getBool | ( | const std::string & | key | ) | 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. If the value contains references to other properties (${<property>}), these are expanded.
bool Poco::Util::AbstractConfiguration::getBool | ( | const std::string & | key, |
bool | defaultValue ) const |
Returns the boolean 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 boolean. If the value contains references to other properties (${<property>}), these are expanded.
double Poco::Util::AbstractConfiguration::getDouble | ( | const std::string & | key | ) | const |
If a property with the given key exists, returns the property's unsigned int value, otherwise returns the given default value. Throws a SyntaxException if the property can not be converted to an unsigned int. Numbers starting with 0x are treated as hexadecimal. If the value contains references to other properties (${<property>}), these are expanded.
double Poco::Util::AbstractConfiguration::getDouble | ( | const std::string & | key, |
double | defaultValue ) 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. If the value contains references to other properties (${<property>}), these are expanded.
int Poco::Util::AbstractConfiguration::getInt | ( | const std::string & | key | ) | 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 Poco::Util::AbstractConfiguration::getInt | ( | const std::string & | key, |
int | defaultValue ) const |
Returns the unsigned 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 unsigned int. Numbers starting with 0x are treated as hexadecimal. If the value contains references to other properties (${<property>}), these are expanded.
|
protectedpure virtual |
Returns true iff events are enabled.
std::string Poco::Util::AbstractConfiguration::getRawString | ( | const std::string & | key | ) | const |
If a property with the given key exists, returns the property's string value, otherwise returns the given default value. If the value contains references to other properties (${<property>}), these are expanded.
std::string Poco::Util::AbstractConfiguration::getRawString | ( | const std::string & | key, |
const std::string & | defaultValue ) 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 Poco::Util::AbstractConfiguration::getString | ( | const std::string & | key | ) | const |
Returns true iff the property with the given key exists.
Same as hasProperty().
std::string Poco::Util::AbstractConfiguration::getString | ( | const std::string & | key, |
const std::string & | defaultValue ) const |
Returns the string value of the property with the given name. Throws a NotFoundException if the key does not exist. If the value contains references to other properties (${<property>}), these are expanded.
unsigned int Poco::Util::AbstractConfiguration::getUInt | ( | const std::string & | key | ) | 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. If the value contains references to other properties (${<property>}), these are expanded.
unsigned int Poco::Util::AbstractConfiguration::getUInt | ( | const std::string & | key, |
unsigned int | defaultValue ) 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. If the value contains references to other properties (${<property>}), these are expanded.
bool Poco::Util::AbstractConfiguration::has | ( | const std::string & | key | ) | const |
Returns true iff the property with the given key exists.
Same as hasProperty().
bool Poco::Util::AbstractConfiguration::hasOption | ( | const std::string & | key | ) | const |
Returns true iff the property with the given key exists.
bool Poco::Util::AbstractConfiguration::hasProperty | ( | const std::string & | key | ) | const |
Creates the AbstractConfiguration.
|
private |
void Poco::Util::AbstractConfiguration::keys | ( | const std::string & | key, |
Keys & | range ) const |
Returns in range the names of all keys at root level.
void Poco::Util::AbstractConfiguration::keys | ( | Keys & | range | ) | const |
Sets the property with the given key to the given value. An already existing value for the key is overwritten.
|
private |
|
staticprotected |
Returns string as unsigned integer. Decimal and hexadecimal notation is supported.
|
staticprotected |
Removes the property with the given key.
Does nothing if the key does not exist.
Should be overridden by subclasses; the default implementation throws a Poco::NotImplementedException.
|
staticprotected |
Returns string as signed integer. Decimal and hexadecimal notation is supported.
void Poco::Util::AbstractConfiguration::remove | ( | const std::string & | key | ) |
Replaces all occurrences of ${<property>} in value with the value of the <property>. If <property> does not exist, nothing is changed.
If a circular property reference is detected, a CircularReferenceException will be thrown.
|
protectedvirtual |
Returns in range the names of all subkeys under the given key. If an empty key is passed, all root level keys are returned.
|
virtual |
Sets the property with the given key to the given value. An already existing value for the key is overwritten.
|
virtual |
Sets the property with the given key to the given value. An already existing value for the key is overwritten.
|
virtual |
Sets the property with the given key to the given value. An already existing value for the key is overwritten.
|
protectedpure virtual |
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.
|
protected |
|
virtual |
If a property with the given key exists, returns the property's boolean 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:
|
virtual |
Sets the property with the given key to the given value. An already existing value for the key is overwritten.
|
private |
|
friend |
Definition at line 386 of file AbstractConfiguration.h.
|
friend |
Definition at line 385 of file AbstractConfiguration.h.
|
friend |
Definition at line 384 of file AbstractConfiguration.h.
|
mutableprivate |
Definition at line 380 of file AbstractConfiguration.h.
|
private |
Definition at line 381 of file AbstractConfiguration.h.
|
mutableprivate |
Definition at line 382 of file AbstractConfiguration.h.
Poco::BasicEvent<const KeyValue> Poco::Util::AbstractConfiguration::propertyChanged |
Fired before a property value is changed or a new property is created.
Can be used to check or fix a property value, or to cancel the change by throwing an exception.
The event delegate can use one of the get...() functions to obtain the current property value.
Definition at line 93 of file AbstractConfiguration.h.
Poco::BasicEvent<KeyValue> Poco::Util::AbstractConfiguration::propertyChanging |
Definition at line 83 of file AbstractConfiguration.h.
Poco::BasicEvent<const std::string> Poco::Util::AbstractConfiguration::propertyRemoved |
Fired before a property is removed by a call to remove().
Note: This will even be fired if the key does not exist and the remove operation will fail with an exception.
Definition at line 105 of file AbstractConfiguration.h.
Poco::BasicEvent<const std::string> Poco::Util::AbstractConfiguration::propertyRemoving |
Fired after a property value has been changed or a property has been created.
Definition at line 97 of file AbstractConfiguration.h.