|
Xpace
|
Each high-level Xpace object has a Configuration. More...
#include <config.h>
Public Types | |
| typedef std::function< bool(uint depth, uint pos, const String &tag, const String &config)> | nodeCallback |
| Callback for traversing Configuration nodes depth the node's depth. More... | |
| typedef std::function< bool(uint depth, const String &tag, intptr_t elt)> | elt_callback |
Public Member Functions | |
| Configuration (const String &str=String(), const String &tag=String()) | |
| create a configuration from a fragment of XML More... | |
| Configuration (File *file, const String &tag=String()) | |
| create a configuration from a configuration File More... | |
| Configuration (const Configuration &, const String &tag=String()) | |
| Configuration & | operator= (const Configuration &) |
| ~Configuration () | |
| bool | operator! () const |
| String | toString () const |
| Configuration (const QDomElement &elt, const QDomDocument &doc=QDomDocument(), bool deep=false) | |
| Convert a QDomElement to a Configuration. More... | |
| operator const QDomElement & () const | |
| Convert a Configuration to a QDomElement. More... | |
| const QDomDocument & | getDomDocument () const |
| Get the QDomDocument containing this Config. More... | |
| String | getTag () const |
| Configuration | findTag (const String &tag, const String &name=String(), const String &value=String(), bool deep=true) const |
| Copy a sub-configuration. More... | |
| String | getValue (const String &tag=String()) const |
| get a node's value or an attribute search for attribute first, then child value More... | |
| int64 | getValueInt (const String &tag=String(), int64 def=0, bool *ok=0) const |
| bool | getValueBool (const String &tag=String()) const |
| String | getValuePath (const String &tag) const |
| get named values, starting at root More... | |
| bool | hasChild (const String &tag) const |
| void | addChild (const Configuration &child) |
| std::vector< String > | getChild (const String &tag) const |
| std::vector< int64 > | getChildInt (const String &tag, int64 def, bool *ok) const |
| std::vector< bool > | getChildBool (const String &tag) const |
| void | setTag (const String &tag) |
| set attribute values More... | |
| void | setValue (const String &name, const String &value) |
| void | setValue (const String &name, int64 value) |
| void | setValue (const String &name, bool value) |
| bool | traverse (nodeCallback callback, bool deep=false, const String &tag=String(), uint maxDepth=~0) const |
| Traverse (pre-order) a Configuration. More... | |
| bool | write (File *f) const |
| serialize the Configuration More... | |
Protected Member Functions | |
| bool | elt_traverse (elt_callback, const String &tag) |
Each high-level Xpace object has a Configuration.
| typedef std::function<bool(uint depth, uint pos, const String& tag, const String& config)> Xpace::Configuration::nodeCallback |
Callback for traversing Configuration nodes depth the node's depth.
| pos | the node's position (relative to parent) |
| tag | the node's XML tag |
| config | the node's (sub-)Configuration |
| typedef std::function<bool(uint depth, const String& tag, intptr_t elt)> Xpace::Configuration::elt_callback |
| Xpace::Configuration::Configuration | ( | const String & | str = String(), |
| const String & | tag = String() |
||
| ) |
create a configuration from a fragment of XML
| str | the XML fragment |
| tag | search the Configuration for a sub-configuration with this tag (cf. findTag) |
| XML_No_Value | if tag is not found |
| XML_Error |
create a configuration from a configuration File
| file | the configuration File |
| tag | search the Configuration for a sub-configuration with this tag (cf. findTag) |
| File_Cant_Read | |
| XML_Error | |
| XML_No_Value | if tag is not found |
| Xpace::Configuration::Configuration | ( | const Configuration & | , |
| const String & | tag = String() |
||
| ) |
| tag | search the Configuration for a sub-configuration with this tag (cf. findTag) |
| Xpace::Configuration::~Configuration | ( | ) |
| Xpace::Configuration::Configuration | ( | const QDomElement & | elt, |
| const QDomDocument & | doc = QDomDocument(), |
||
| bool | deep = false |
||
| ) |
Convert a QDomElement to a Configuration.
| elt | the QDomElement to be converted |
| doc | the QDomDocument the element's XML document (if none, create a document) |
| deep | if true, convert children as well |
| Configuration& Xpace::Configuration::operator= | ( | const Configuration & | ) |
| bool Xpace::Configuration::operator! | ( | ) | const |
| String Xpace::Configuration::toString | ( | ) | const |
Referenced by Xpace::IndexList::CantOpen::CantOpen(), Xpace::TranslatePtr< LOC, STR >::create(), Xpace::TranslateString< LOC, STR >::create(), Xpace::TranslatePtr< LOC, STR >::TranslatePtr(), and Xpace::TranslateStringDateTime< LOC, STR >::TranslateStringDateTime().
| Xpace::Configuration::operator const QDomElement & | ( | ) | const |
Convert a Configuration to a QDomElement.
| const QDomDocument& Xpace::Configuration::getDomDocument | ( | ) | const |
Get the QDomDocument containing this Config.
| String Xpace::Configuration::getTag | ( | ) | const |
Referenced by Xpace::Sink< uint >::add(), and Xpace::TranslateStringIPv4< LOC, STR >::TranslateStringIPv4().
| Configuration Xpace::Configuration::findTag | ( | const String & | tag, |
| const String & | name = String(), |
||
| const String & | value = String(), |
||
| bool | deep = true |
||
| ) | const |
Copy a sub-configuration.
| tag | search the Configuration for a sub-configuration with this tag |
| name | search for a sub-configuration with this attribute or child |
| value | search for a sub-configuration with an attribute/child called name with this value |
| deep | iff true, return all descendants |
get a node's value or an attribute search for attribute first, then child value
| tag | the tag of the child/attribute whose value we want; separate >1 tags with '|' if tag is empty, return this node's value |
Referenced by Xpace::TranslatePtr< LOC, STR >::create(), and Xpace::TranslateString< LOC, STR >::create().
| int64 Xpace::Configuration::getValueInt | ( | const String & | tag = String(), |
| int64 | def = 0, |
||
| bool * | ok = 0 |
||
| ) | const |
| tag | the tag of the child/attribute whose value we want; separate >1 tags with '|' if tag is empty, return this node's value |
| def | the default value if not found |
| ok | fillin true if found |
Referenced by Xpace::TranslateStringInt< LOC, STR >::operator()().
| tag | the tag of the child/attribute whose value we want; separate >1 tags with '|' if tag is empty, return this node's value |
Referenced by Xpace::TranslatePtr< LOC, STR >::create().
get named values, starting at root
| name | depth-first search for this tag |
| tag | the Child's tag |
| void Xpace::Configuration::addChild | ( | const Configuration & | child | ) |
| add | a this as a child |
| tag | the child tag whose values we want |
| std::vector<int64> Xpace::Configuration::getChildInt | ( | const String & | tag, |
| int64 | def, | ||
| bool * | ok | ||
| ) | const |
| tag | the child tag whose values we want |
| def | the default value if not found |
| ok | fillin true if found |
| tag | the child tags whose values we want |
| void Xpace::Configuration::setTag | ( | const String & | tag | ) |
set attribute values
set this Configuation's XML tag
| tag | the new tag |
| name | set this attribute |
| value | to this (String) value |
| name | set this attribute |
| value | to this (integer) value |
| tag | set this attribute |
| value | to this (boolean) value |
| bool Xpace::Configuration::traverse | ( | nodeCallback | callback, |
| bool | deep = false, |
||
| const String & | tag = String(), |
||
| uint | maxDepth = ~0 |
||
| ) | const |
Traverse (pre-order) a Configuration.
| callback | the callback function |
| deep | iff true, put each node's children in config sent to callback |
| tag | if not empty, match this tag before calling back |
| maxDepth | how many levels to descend (relative to tag, if any) |
|
protected |