Logo Search packages:      
Sourcecode: poco version File versions  Download package

Poco::Util::XMLConfiguration Class Reference

#include <XMLConfiguration.h>

Inheritance diagram for Poco::Util::XMLConfiguration:

Poco::Util::AbstractConfiguration Poco::RefCountedObject

List of all members.


Detailed Description

This configuration class extracts configuration properties from an XML document. An XPath-like syntax for property names is supported to allow full access to the XML document. XML namespaces are not supported. The name of the root element of an XML document is not significant. Periods in tag names are not supported.

Given the following XML document as an example:

<config> <prop1>value1</prop1> <prop2>value2</prop2> <prop3> <prop4 attr="value3"> <prop4 attr="value4"> </prop3> <prop5>value5</prop5> <prop5>value6</prop5> </config>

The following property names would be valid and would yield the shown values:

prop1 -> value1 prop2 -> value2 prop3.prop4 -> (empty string) prop3.prop4[] -> value3 prop3.prop4[1][] -> value4 prop5[0] -> value5 prop5[1] -> value6

Enumerating attributes is not supported. Calling keys("prop3.prop4") will return an empty range.

Setting properties is not supported. An attempt to set a property results in a NotImplementedException being thrown.

Definition at line 55 of file XMLConfiguration.h.


Public Types

typedef std::vector< std::string > Keys

Public Member Functions

AbstractConfigurationcreateView (const std::string &prefix)
 Creates a non-mutable view (see ConfigurationView) into the configuration.
const AbstractConfigurationcreateView (const std::string &prefix) const
void duplicate () const
std::string expand (const std::string &value) const
 Creates a view (see ConfigurationView) into the configuration.
bool getBool (const std::string &key, bool defaultValue) const
bool getBool (const std::string &key) const
double getDouble (const std::string &key, double defaultValue) const
double getDouble (const std::string &key) const
int getInt (const std::string &key, int defaultValue) const
int getInt (const std::string &key) const
std::string getRawString (const std::string &key, const std::string &defaultValue) const
std::string getRawString (const std::string &key) const
std::string getString (const std::string &key, const std::string &defaultValue) const
std::string getString (const std::string &key) const
bool hasOption (const std::string &key) const
 Returns true iff the property with the given key exists.
bool hasProperty (const std::string &key) const
 Creates the AbstractConfiguration.
void keys (const std::string &key, Keys &range) const
 Returns in range the names of all keys at root level.
void keys (Keys &range) const
void load (const Poco::XML::Node *pNode)
void load (const Poco::XML::Document *pDocument)
void load (const std::string &path)
void load (std::istream &istr)
void load (Poco::XML::InputSource *pInputSource)
 Creates the XMLConfiguration using the given XML node.
int referenceCount () const
void release () const
 Increments the object's reference count.
void setBool (const std::string &key, bool value)
void setDouble (const std::string &key, double value)
void setInt (const std::string &key, int value)
void setString (const std::string &key, const std::string &value)
 XMLConfiguration (const Poco::XML::Node *pNode)
 Creates the XMLConfiguration using the given XML document.
 XMLConfiguration (const Poco::XML::Document *pDocument)
 XMLConfiguration (const std::string &path)
 XMLConfiguration (std::istream &istr)
 XMLConfiguration (Poco::XML::InputSource *pInputSource)
 Creates an empty XMLConfiguration.

Protected Member Functions

virtual void enumerate (const std::string &key, Keys &range) const =0
void enumerate (const std::string &key, Keys &range) const
bool getRaw (const std::string &key, std::string &value) const
void setRaw (const std::string &key, const std::string &value)

Static Protected Member Functions

static bool parseBool (const std::string &value)
static int parseInt (const std::string &value)

Private Member Functions

const Poco::XML::NodefindNode (const std::string &key) const

Static Private Member Functions

static const Poco::XML::NodefindAttribute (const std::string &name, const Poco::XML::Node *pNode)
static const Poco::XML::NodefindElement (int index, const Poco::XML::Node *pNode)
static const Poco::XML::NodefindElement (const std::string &name, const Poco::XML::Node *pNode)
static const Poco::XML::NodefindNode (std::string::const_iterator &it, const std::string::const_iterator &end, const Poco::XML::Node *pNode)

Private Attributes

Poco::XML::AutoPtr
< Poco::XML::Document
_pDocument
Poco::XML::AutoPtr
< Poco::XML::Node
_pRoot

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

Generated by  Doxygen 1.6.0   Back to index