Ark Server API (ASE) - Wiki
Loading...
Searching...
No Matches
Poco::Util::AbstractConfiguration Class Referenceabstract

#include <AbstractConfiguration.h>

+ Inheritance diagram for Poco::Util::AbstractConfiguration:
+ Collaboration diagram for Poco::Util::AbstractConfiguration:

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< KeyValuepropertyChanging
 
Poco::BasicEvent< const KeyValuepropertyChanged
 
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 &)
 
AbstractConfigurationoperator= (const AbstractConfiguration &)
 

Private Attributes

int _depth
 
bool _eventsEnabled
 
Poco::Mutex _mutex
 

Friends

class LayeredConfiguration
 
class ConfigurationView
 
class ConfigurationMapper
 

Detailed Description

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.

Member Typedef Documentation

◆ Keys

using Poco::Util::AbstractConfiguration::Keys = std::vector<std::string>

Definition at line 50 of file AbstractConfiguration.h.

◆ Ptr

Constructor & Destructor Documentation

◆ AbstractConfiguration() [1/2]

Poco::Util::AbstractConfiguration::AbstractConfiguration ( )

Fired after a property has been removed by a call to remove().

◆ ~AbstractConfiguration()

virtual Poco::Util::AbstractConfiguration::~AbstractConfiguration ( )
protectedvirtual

◆ AbstractConfiguration() [2/2]

Poco::Util::AbstractConfiguration::AbstractConfiguration ( const AbstractConfiguration & )
private

Member Function Documentation

◆ createView() [1/2]

Ptr Poco::Util::AbstractConfiguration::createView ( const std::string & prefix)

Creates a non-mutable view (see ConfigurationView) into the configuration.

◆ createView() [2/2]

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.

◆ enableEvents()

void Poco::Util::AbstractConfiguration::enableEvents ( bool enable = true)

Removes the property with the given key.

Does nothing if the key does not exist.

◆ enumerate()

virtual void Poco::Util::AbstractConfiguration::enumerate ( const std::string & key,
Keys & range ) const
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.

◆ eventsEnabled()

bool Poco::Util::AbstractConfiguration::eventsEnabled ( ) const

Enables (or disables) events.

◆ expand()

std::string Poco::Util::AbstractConfiguration::expand ( const std::string & value) const

Creates a view (see ConfigurationView) into the configuration.

◆ getBool() [1/2]

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.

◆ getBool() [2/2]

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.

◆ getDouble() [1/2]

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.

◆ getDouble() [2/2]

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.

◆ getInt() [1/2]

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.

◆ getInt() [2/2]

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.

◆ getRaw()

virtual bool Poco::Util::AbstractConfiguration::getRaw ( const std::string & key,
std::string & value ) const
protectedpure virtual

Returns true iff events are enabled.

◆ getRawString() [1/2]

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.

◆ getRawString() [2/2]

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.

◆ getString() [1/2]

std::string Poco::Util::AbstractConfiguration::getString ( const std::string & key) const

Returns true iff the property with the given key exists.

Same as hasProperty().

◆ getString() [2/2]

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.

◆ getUInt() [1/2]

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.

◆ getUInt() [2/2]

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.

◆ has()

bool Poco::Util::AbstractConfiguration::has ( const std::string & key) const

Returns true iff the property with the given key exists.

Same as hasProperty().

◆ hasOption()

bool Poco::Util::AbstractConfiguration::hasOption ( const std::string & key) const

Returns true iff the property with the given key exists.

◆ hasProperty()

bool Poco::Util::AbstractConfiguration::hasProperty ( const std::string & key) const

Creates the AbstractConfiguration.

◆ internalExpand()

std::string Poco::Util::AbstractConfiguration::internalExpand ( const std::string & value) const
private

◆ keys() [1/2]

void Poco::Util::AbstractConfiguration::keys ( const std::string & key,
Keys & range ) const

Returns in range the names of all keys at root level.

◆ keys() [2/2]

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.

◆ operator=()

AbstractConfiguration & Poco::Util::AbstractConfiguration::operator= ( const AbstractConfiguration & )
private

◆ parseBool()

static bool Poco::Util::AbstractConfiguration::parseBool ( const std::string & value)
staticprotected

Returns string as unsigned integer. Decimal and hexadecimal notation is supported.

◆ parseInt()

static int Poco::Util::AbstractConfiguration::parseInt ( const std::string & value)
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.

◆ parseUInt()

static unsigned Poco::Util::AbstractConfiguration::parseUInt ( const std::string & value)
staticprotected

Returns string as signed integer. Decimal and hexadecimal notation is supported.

◆ remove()

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.

◆ removeRaw()

virtual void Poco::Util::AbstractConfiguration::removeRaw ( const std::string & key)
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.

◆ setBool()

virtual void Poco::Util::AbstractConfiguration::setBool ( const std::string & key,
bool value )
virtual

Sets the property with the given key to the given value. An already existing value for the key is overwritten.

◆ setDouble()

virtual void Poco::Util::AbstractConfiguration::setDouble ( const std::string & key,
double value )
virtual

Sets the property with the given key to the given value. An already existing value for the key is overwritten.

◆ setInt()

virtual void Poco::Util::AbstractConfiguration::setInt ( const std::string & key,
int value )
virtual

Sets the property with the given key to the given value. An already existing value for the key is overwritten.

◆ setRaw()

virtual void Poco::Util::AbstractConfiguration::setRaw ( const std::string & key,
const std::string & value )
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.

◆ setRawWithEvent()

void Poco::Util::AbstractConfiguration::setRawWithEvent ( const std::string & key,
std::string value )
protected

◆ setString()

virtual void Poco::Util::AbstractConfiguration::setString ( const std::string & key,
const std::string & value )
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:

  • numerical values: non zero becomes true, zero becomes false
  • strings: true, yes, on become true, false, no, off become false Case does not matter. If the value contains references to other properties (${<property>}), these are expanded.

◆ setUInt()

virtual void Poco::Util::AbstractConfiguration::setUInt ( const std::string & key,
unsigned int value )
virtual

Sets the property with the given key to the given value. An already existing value for the key is overwritten.

◆ uncheckedExpand()

std::string Poco::Util::AbstractConfiguration::uncheckedExpand ( const std::string & value) const
private

Friends And Related Symbol Documentation

◆ ConfigurationMapper

friend class ConfigurationMapper
friend

Definition at line 386 of file AbstractConfiguration.h.

◆ ConfigurationView

friend class ConfigurationView
friend

Definition at line 385 of file AbstractConfiguration.h.

◆ LayeredConfiguration

friend class LayeredConfiguration
friend

Definition at line 384 of file AbstractConfiguration.h.

Member Data Documentation

◆ _depth

int Poco::Util::AbstractConfiguration::_depth
mutableprivate

Definition at line 380 of file AbstractConfiguration.h.

◆ _eventsEnabled

bool Poco::Util::AbstractConfiguration::_eventsEnabled
private

Definition at line 381 of file AbstractConfiguration.h.

◆ _mutex

Poco::Mutex Poco::Util::AbstractConfiguration::_mutex
mutableprivate

Definition at line 382 of file AbstractConfiguration.h.

◆ propertyChanged

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.

◆ propertyChanging

Poco::BasicEvent<KeyValue> Poco::Util::AbstractConfiguration::propertyChanging

Definition at line 83 of file AbstractConfiguration.h.

◆ propertyRemoved

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.

◆ propertyRemoving

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.


The documentation for this class was generated from the following file: