iterator for XML trees More...
#include <xmlstorage.h>
Public Member Functions | |
XMLPos (XMLNode *root) | |
XMLPos (const XMLPos &other) | |
XMLPos (XMLNode *node, const XS_String &name) | |
XMLPos (XMLNode *node, const XS_String &name, const XS_String &attr_name, const XS_String &attr_value) | |
XMLPos (const XMLPos &other, const XS_String &name) | |
XMLPos (const XMLPos &other, const XS_String &name, const XS_String &attr_name, const XS_String &attr_value) | |
XMLNode & | cur () |
access to current node | |
const XMLNode & | cur () const |
operator const XMLNode * () const | |
automatic access to current node | |
operator XMLNode * () | |
const XMLNode * | operator-> () const |
XMLNode * | operator-> () |
const XMLNode & | operator* () const |
XMLNode & | operator* () |
XS_String | get (const XS_String &attr_name, LPCXSSTR def=XS_EMPTY_STR) const |
attribute access | |
void | put (const XS_String &attr_name, const XS_String &value) |
attribute setting | |
template<typename T > | |
XS_String | get (const T &attr_name) const |
index operator attribute access | |
XS_String & | operator[] (const XS_String &attr_name) |
const XS_String & | operator[] (const XS_String &attr_name) const |
void | add_down (XMLNode *child) |
insert children when building tree | |
bool | back () |
go back to previous position | |
bool | go_down () |
go down to first child | |
bool | go_down (const XS_String &child_name, int n=0) |
search for child and go down | |
bool | iterate (const XS_String &child_name, int &cnt) |
iterate to the next matching child | |
bool | go (const XPath &xpath) |
move to the position defined by xpath in XML tree | |
bool | create_relative (const XPath &xpath) |
create child nodes using XPath notation and move to the deepest child | |
void | create (const XS_String &name) |
create node and move to it | |
void | create_node_content (const XS_String &node_name, const XS_String &content) |
create node with string content | |
void | smart_create (const XS_String &child_name) |
create node if not already existing and move to it | |
void | smart_create (const XS_String &child_name, const XS_String &attr_name, const XS_String &attr_value) |
search matching child node identified by key name and an attribute value | |
int | count (const XPath &xpath) const |
count the nodes matching the given relative XPath expression | |
int | filter (const XPath &xpath, XMLNode &target) const |
create a new node tree using the given XPath filter expression | |
bool | delete_this () |
delete current node and go back to previous position | |
void | remove_children (const XS_String &name) |
remove all children named 'name' | |
void | erase (const XS_String &attr_name) |
remove the attribute 'attr_name' from the current node | |
XS_String & | str () |
const XS_String & | str () const |
void | set_property (const XS_String &key, int value, const XS_String &name=XS_PROPERTY) |
void | set_property (const XS_String &key, double value, const XS_String &name=XS_PROPERTY) |
void | set_property (const XS_String &key, const XS_String &value, const XS_String &name=XS_PROPERTY) |
void | set_property (const XS_String &key, const struct XMLBool &value, const XS_String &name=XS_PROPERTY) |
void | set_property (const XS_String &key, const char *value, const XS_String &name=XS_PROPERTY) |
Protected Member Functions | |
void | go_to (XMLNode *child) |
go to specified node | |
Protected Attributes | |
XMLNode * | _root |
XMLNode * | _cur |
std::stack< XMLNode * > | _stack |
Friends | |
struct | const_XMLPos |
iterator for XML trees
Definition at line 2050 of file xmlstorage.h.
XMLStorage::XMLPos::XMLPos | ( | XMLNode * | root ) | [inline] |
Definition at line 2052 of file xmlstorage.h.
XMLStorage::XMLPos::XMLPos | ( | const XMLPos & | other ) | [inline] |
Definition at line 2058 of file xmlstorage.h.
Definition at line 2064 of file xmlstorage.h.
References smart_create().
: _root(node), _cur(node) { smart_create(name); }
XMLStorage::XMLPos::XMLPos | ( | XMLNode * | node, |
const XS_String & | name, | ||
const XS_String & | attr_name, | ||
const XS_String & | attr_value | ||
) | [inline] |
Definition at line 2071 of file xmlstorage.h.
References smart_create().
: _root(node), _cur(node) { smart_create(name, attr_name, attr_value); }
Definition at line 2078 of file xmlstorage.h.
References smart_create().
: _root(other._root), _cur(other._cur) { smart_create(name); }
XMLStorage::XMLPos::XMLPos | ( | const XMLPos & | other, |
const XS_String & | name, | ||
const XS_String & | attr_name, | ||
const XS_String & | attr_value | ||
) | [inline] |
Definition at line 2085 of file xmlstorage.h.
References smart_create().
: _root(other._root), _cur(other._cur) { smart_create(name, attr_name, attr_value); }
void XMLStorage::XMLPos::add_down | ( | XMLNode * | child ) | [inline] |
insert children when building tree
Definition at line 2131 of file xmlstorage.h.
References _cur, XMLStorage::XMLNode::add_child(), and go_to().
Referenced by create(), and smart_create().
bool XMLStorage::XMLPos::back | ( | ) | [inline] |
go back to previous position
Definition at line 2138 of file xmlstorage.h.
Referenced by NotifyArea::read_config(), set_property(), Favorites::write(), and NotifyArea::write_config().
{ if (!_stack.empty()) { _cur = _stack.top(); _stack.pop(); return true; } else { assert(!_stack.empty()); return false; } }
int XMLStorage::XMLPos::count | ( | const XPath & | xpath ) | const [inline] |
count the nodes matching the given relative XPath expression
Definition at line 2241 of file xmlstorage.h.
References _cur, and XMLStorage::XMLNode::count().
{ return _cur->count(xpath); }
void XMLStorage::XMLPos::create | ( | const XS_String & | name ) | [inline] |
create node and move to it
Definition at line 2202 of file xmlstorage.h.
References add_down().
Referenced by Favorites::write(), and XMLStorage::XMLMessage::XMLMessage().
{ add_down(new XMLNode(name)); }
void XMLStorage::XMLPos::create_node_content | ( | const XS_String & | node_name, |
const XS_String & | content | ||
) | [inline] |
create node with string content
Definition at line 2208 of file xmlstorage.h.
References _cur, XMLStorage::XMLNode::add_child(), and XMLStorage::XMLNode::set_content().
{ XMLNode* pNode = new XMLNode(node_name); pNode->set_content(content); _cur->add_child(pNode); }
bool XMLStorage::XMLPos::create_relative | ( | const XPath & | xpath ) | [inline] |
create child nodes using XPath notation and move to the deepest child
Definition at line 2191 of file xmlstorage.h.
References _cur, XMLStorage::XMLNode::create_relative(), and go_to().
Referenced by ExplorerGlobals::get_cfg().
{ XMLNode* node = _cur->create_relative(xpath); if (!node) return false; // invalid path specified go_to(node); return true; }
const XMLNode& XMLStorage::XMLPos::cur | ( | ) | const [inline] |
XMLNode& XMLStorage::XMLPos::cur | ( | ) | [inline] |
access to current node
Definition at line 2093 of file xmlstorage.h.
References _cur.
{ return *_cur; }
bool XMLStorage::XMLPos::delete_this | ( | ) | [inline] |
delete current node and go back to previous position
Definition at line 2299 of file xmlstorage.h.
References XMLStorage::XMLNode::_children, _cur, and _stack.
void XMLStorage::XMLPos::erase | ( | const XS_String & | attr_name ) | [inline] |
remove the attribute 'attr_name' from the current node
Definition at line 2320 of file xmlstorage.h.
References _cur, and XMLStorage::XMLNode::erase().
{ _cur->erase(attr_name); }
create a new node tree using the given XPath filter expression
Definition at line 2247 of file xmlstorage.h.
References _cur, and XMLStorage::XMLNode::filter().
{ return _cur->filter(xpath, target); }
XS_String XMLStorage::XMLPos::get | ( | const XS_String & | attr_name, |
LPCXSSTR | def = XS_EMPTY_STR |
||
) | const [inline] |
attribute access
Definition at line 2114 of file xmlstorage.h.
References _cur, and XMLStorage::XMLNode::get().
{ return _cur->get(attr_name, def); }
XS_String XMLStorage::XMLPos::get | ( | const T & | attr_name ) | const [inline] |
index operator attribute access
Definition at line 2126 of file xmlstorage.h.
References _cur.
{return (*_cur)[attr_name];}
bool XMLStorage::XMLPos::go | ( | const XPath & | xpath ) |
move to the position defined by xpath in XML tree
Definition at line 113 of file xmlstorage.cpp.
References XMLStorage::XPath::_absolute, _cur, _root, XMLStorage::XMLNode::find_relative(), and go_to().
{ XMLNode* node = xpath._absolute? _root: _cur; node = node->find_relative(xpath); if (node) { go_to(node); return true; } else return false; }
bool XMLStorage::XMLPos::go_down | ( | ) | [inline] |
go down to first child
Definition at line 2151 of file xmlstorage.h.
References _cur, XMLStorage::XMLNode::get_first_child(), and go_to().
Referenced by NotifyArea::read_config().
{ XMLNode* node = _cur->get_first_child(); if (node) { go_to(node); return true; } else return false; }
bool XMLStorage::XMLPos::go_down | ( | const XS_String & | child_name, |
int | n = 0 |
||
) | [inline] |
search for child and go down
Definition at line 2163 of file xmlstorage.h.
References _cur, XMLStorage::XPathElement::find(), and go_to().
{ XMLNode* node = XPathElement(child_name, n).find(_cur); if (node) { go_to(node); return true; } else return false; }
void XMLStorage::XMLPos::go_to | ( | XMLNode * | child ) | [inline, protected] |
go to specified node
Definition at line 2345 of file xmlstorage.h.
Referenced by add_down(), create_relative(), go(), go_down(), iterate(), and smart_create().
bool XMLStorage::XMLPos::iterate | ( | const XS_String & | child_name, |
int & | cnt | ||
) | [inline] |
iterate to the next matching child
Definition at line 2175 of file xmlstorage.h.
References _cur, XMLStorage::XPathElement::find(), and go_to().
{ XMLNode* node = XPathElement(child_name, cnt).find(_cur); if (node) { go_to(node); ++cnt; return true; } else return false; }
XMLStorage::XMLPos::operator const XMLNode * | ( | ) | const [inline] |
automatic access to current node
Definition at line 2104 of file xmlstorage.h.
References _cur.
{return _cur;}
XMLStorage::XMLPos::operator XMLNode * | ( | ) | [inline] |
XMLNode& XMLStorage::XMLPos::operator* | ( | ) | [inline] |
const XMLNode& XMLStorage::XMLPos::operator* | ( | ) | const [inline] |
const XMLNode* XMLStorage::XMLPos::operator-> | ( | ) | const [inline] |
XMLNode* XMLStorage::XMLPos::operator-> | ( | ) | [inline] |
attribute setting
Definition at line 2120 of file xmlstorage.h.
References _cur, and XMLStorage::XMLNode::put().
Referenced by set_property().
{ _cur->put(attr_name, value); }
void XMLStorage::XMLPos::remove_children | ( | const XS_String & | name ) | [inline] |
remove all children named 'name'
Definition at line 2314 of file xmlstorage.h.
References _cur, and XMLStorage::XMLNode::remove_children().
{ _cur->remove_children(name); }
void XMLStorage::XMLPos::set_property | ( | const XS_String & | key, |
const XS_String & | value, | ||
const XS_String & | name = XS_PROPERTY |
||
) | [inline] |
Definition at line 3879 of file xmlstorage.h.
References back(), put(), smart_create(), XMLStorage::XS_KEY, and XMLStorage::XS_VALUE.
{ smart_create(name, XS_KEY, key); put(XS_VALUE, value); back(); }
void XMLStorage::XMLPos::set_property | ( | const XS_String & | key, |
int | value, | ||
const XS_String & | name = XS_PROPERTY |
||
) | [inline] |
Definition at line 3865 of file xmlstorage.h.
References _cur, back(), smart_create(), XMLStorage::XS_KEY, and XMLStorage::XS_VALUE.
{ smart_create(name, XS_KEY, key); XMLIntRef(_cur, XS_VALUE) = value; back(); }
void XMLStorage::XMLPos::set_property | ( | const XS_String & | key, |
const struct XMLBool & | value, | ||
const XS_String & | name = XS_PROPERTY |
||
) |
void XMLStorage::XMLPos::set_property | ( | const XS_String & | key, |
const char * | value, | ||
const XS_String & | name = XS_PROPERTY |
||
) | [inline] |
Definition at line 2334 of file xmlstorage.h.
References set_property().
Referenced by set_property().
{set_property(key, XS_String(value), name);}
void XMLStorage::XMLPos::set_property | ( | const XS_String & | key, |
double | value, | ||
const XS_String & | name = XS_PROPERTY |
||
) | [inline] |
Definition at line 3872 of file xmlstorage.h.
References _cur, back(), smart_create(), XMLStorage::XS_KEY, and XMLStorage::XS_VALUE.
{ smart_create(name, XS_KEY, key); XMLDoubleRef(_cur, XS_VALUE) = value; back(); }
void XMLStorage::XMLPos::smart_create | ( | const XS_String & | child_name ) | [inline] |
create node if not already existing and move to it
Definition at line 2216 of file xmlstorage.h.
References _cur, add_down(), XMLStorage::XPathElement::find(), and go_to().
Referenced by ExplorerGlobals::get_cfg(), set_property(), NotifyArea::write_config(), and XMLPos().
{ XMLNode* node = XPathElement(child_name).find(_cur); if (node) go_to(node); else add_down(new XMLNode(child_name)); }
void XMLStorage::XMLPos::smart_create | ( | const XS_String & | child_name, |
const XS_String & | attr_name, | ||
const XS_String & | attr_value | ||
) | [inline] |
search matching child node identified by key name and an attribute value
Definition at line 2227 of file xmlstorage.h.
References _cur, add_down(), XMLStorage::XPathElement::find(), and go_to().
{ XMLNode* node = XPathElement(child_name, 0, attr_name, attr_value).find(_cur); if (node) go_to(node); else { node = new XMLNode(child_name); add_down(node); (*node)[attr_name] = attr_value; } }
const XS_String& XMLStorage::XMLPos::str | ( | ) | const [inline] |
XS_String& XMLStorage::XMLPos::str | ( | ) | [inline] |
friend struct const_XMLPos [friend] |
Definition at line 2338 of file xmlstorage.h.
XMLNode* XMLStorage::XMLPos::_cur [protected] |
Definition at line 2341 of file xmlstorage.h.
Referenced by add_down(), back(), count(), create_node_content(), create_relative(), cur(), delete_this(), erase(), filter(), get(), go(), go_down(), go_to(), iterate(), operator const XMLNode *(), operator XMLNode *(), operator*(), operator->(), operator[](), put(), remove_children(), set_property(), smart_create(), and str().
XMLNode* XMLStorage::XMLPos::_root [protected] |
Definition at line 2340 of file xmlstorage.h.
Referenced by go().
std::stack<XMLNode*> XMLStorage::XMLPos::_stack [protected] |
Definition at line 2342 of file xmlstorage.h.
Referenced by back(), delete_this(), and go_to().
ROS Explorer Source Code Documentation
generated on 02.01.2013 by ![]() |