XMLStorage::XMLPos Struct Reference

iterator for XML trees More...

#include <xmlstorage.h>

Inheritance diagram for XMLStorage::XMLPos:

Inheritance graph
[legend]
Collaboration diagram for XMLStorage::XMLPos:

Collaboration graph
[legend]

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)
XMLNodecur ()
 access to current node
const XMLNodecur () const
 operator const XMLNode * () const
 C++ access to current node.
 operator XMLNode * ()
const XMLNodeoperator-> () const
XMLNodeoperator-> ()
const XMLNodeoperator * () const
XMLNodeoperator * ()
XS_String get (const XS_String &attr_name) 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
 C++ attribute access.
XS_Stringoperator[] (const XS_String &attr_name)
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 &name, int n=0)
 search for child and go down
bool go (const char *path)
 move XPath like to position in XML tree
bool create_relative (const char *path)
 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 smart_create (const XS_String &name)
 create node if not already existing and move to it
void smart_create (const XS_String &name, const XS_String &attr_name, const XS_String &attr_value)
 search matching child node identified by key name and an attribute value
XS_Stringstr ()
const XS_Stringstr () const

Protected Member Functions

void go_to (XMLNode *child)
 go to specified node

Protected Attributes

XMLNode_root
XMLNode_cur
std::stack< XMLNode * > _stack

Detailed Description

iterator for XML trees

Definition at line 1248 of file xmlstorage.h.


Constructor & Destructor Documentation

XMLStorage::XMLPos::XMLPos ( XMLNode root  )  [inline]

Definition at line 1250 of file xmlstorage.h.

01251      :  _root(root),
01252         _cur(root)
01253     {
01254     }

XMLStorage::XMLPos::XMLPos ( const XMLPos other  )  [inline]

Definition at line 1256 of file xmlstorage.h.

01257      :  _root(other._root),
01258         _cur(other._cur)
01259     {   // don't copy _stack
01260     }

XMLStorage::XMLPos::XMLPos ( XMLNode node,
const XS_String name 
) [inline]

Definition at line 1262 of file xmlstorage.h.

01263      :  _root(node),
01264         _cur(node)
01265     {
01266         smart_create(name);
01267     }

XMLStorage::XMLPos::XMLPos ( XMLNode node,
const XS_String name,
const XS_String attr_name,
const XS_String attr_value 
) [inline]

Definition at line 1269 of file xmlstorage.h.

01270      :  _root(node),
01271         _cur(node)
01272     {
01273         smart_create(name, attr_name, attr_value);
01274     }

XMLStorage::XMLPos::XMLPos ( const XMLPos other,
const XS_String name 
) [inline]

Definition at line 1276 of file xmlstorage.h.

01277      :  _root(other._root),
01278         _cur(other._cur)
01279     {
01280         smart_create(name);
01281     }

XMLStorage::XMLPos::XMLPos ( const XMLPos other,
const XS_String name,
const XS_String attr_name,
const XS_String attr_value 
) [inline]

Definition at line 1283 of file xmlstorage.h.

01284      :  _root(other._root),
01285         _cur(other._cur)
01286     {
01287         smart_create(name, attr_name, attr_value);
01288     }


Member Function Documentation

XMLNode& XMLStorage::XMLPos::cur (  )  [inline]

access to current node

Definition at line 1291 of file xmlstorage.h.

01292     {
01293         return *_cur;
01294     }

const XMLNode& XMLStorage::XMLPos::cur (  )  const [inline]

Definition at line 1296 of file xmlstorage.h.

01297     {
01298         return *_cur;
01299     }

XMLStorage::XMLPos::operator const XMLNode * (  )  const [inline]

C++ access to current node.

Definition at line 1302 of file xmlstorage.h.

01302 {return _cur;}

XMLStorage::XMLPos::operator XMLNode * (  )  [inline]

Definition at line 1303 of file xmlstorage.h.

01303 {return _cur;}

const XMLNode* XMLStorage::XMLPos::operator-> (  )  const [inline]

Definition at line 1305 of file xmlstorage.h.

01305 {return _cur;}

XMLNode* XMLStorage::XMLPos::operator-> (  )  [inline]

Definition at line 1306 of file xmlstorage.h.

01306 {return _cur;}

const XMLNode& XMLStorage::XMLPos::operator * (  )  const [inline]

Definition at line 1308 of file xmlstorage.h.

01308 {return *_cur;}

XMLNode& XMLStorage::XMLPos::operator * (  )  [inline]

Definition at line 1309 of file xmlstorage.h.

01309 {return *_cur;}

XS_String XMLStorage::XMLPos::get ( const XS_String attr_name  )  const [inline]

attribute access

Definition at line 1312 of file xmlstorage.h.

01313     {
01314         return _cur->get(attr_name);
01315     }

void XMLStorage::XMLPos::put ( const XS_String attr_name,
const XS_String value 
) [inline]

attribute setting

Definition at line 1318 of file xmlstorage.h.

01319     {
01320         _cur->put(attr_name, value);
01321     }

template<typename T>
XS_String XMLStorage::XMLPos::get ( const T &  attr_name  )  const [inline]

C++ attribute access.

Definition at line 1324 of file xmlstorage.h.

01324 {return (*_cur)[attr_name];}

XS_String& XMLStorage::XMLPos::operator[] ( const XS_String attr_name  )  [inline]

Definition at line 1325 of file xmlstorage.h.

01325 {return (*_cur)[attr_name];}

void XMLStorage::XMLPos::add_down ( XMLNode child  )  [inline]

insert children when building tree

Definition at line 1328 of file xmlstorage.h.

01329     {
01330         _cur->add_child(child);
01331         go_to(child);
01332     }

bool XMLStorage::XMLPos::back (  )  [inline]

go back to previous position

Definition at line 1335 of file xmlstorage.h.

01336     {
01337         if (!_stack.empty()) {
01338             _cur = _stack.top();
01339             _stack.pop();
01340             return true;
01341         } else
01342             return false;
01343     }

bool XMLStorage::XMLPos::go_down (  )  [inline]

go down to first child

Definition at line 1346 of file xmlstorage.h.

01347     {
01348         XMLNode* node = _cur->get_first_child();
01349 
01350         if (node) {
01351             go_to(node);
01352             return true;
01353         } else
01354             return false;
01355     }

bool XMLStorage::XMLPos::go_down ( const XS_String name,
int  n = 0 
) [inline]

search for child and go down

Definition at line 1358 of file xmlstorage.h.

01359     {
01360         XMLNode* node = _cur->find(name, n);
01361 
01362         if (node) {
01363             go_to(node);
01364             return true;
01365         } else
01366             return false;
01367     }

bool XMLStorage::XMLPos::go ( const char *  path  ) 

move XPath like to position in XML tree

bool XMLStorage::XMLPos::create_relative ( const char *  path  )  [inline]

create child nodes using XPath notation and move to the deepest child

Definition at line 1373 of file xmlstorage.h.

01374     {
01375         XMLNode* node = _cur->create_relative(path);
01376         if (!node)
01377             return false;   // invalid path specified
01378 
01379         go_to(node);
01380         return true;
01381     }

void XMLStorage::XMLPos::create ( const XS_String name  )  [inline]

create node and move to it

Definition at line 1384 of file xmlstorage.h.

01385     {
01386         add_down(new XMLNode(name));
01387     }

void XMLStorage::XMLPos::smart_create ( const XS_String name  )  [inline]

create node if not already existing and move to it

Definition at line 1390 of file xmlstorage.h.

01391     {
01392         XMLNode* node = _cur->find(name);
01393 
01394         if (node)
01395             go_to(node);
01396         else
01397             add_down(new XMLNode(name));
01398     }

void XMLStorage::XMLPos::smart_create ( const XS_String 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 1401 of file xmlstorage.h.

01402     {
01403         XMLNode* node = _cur->find(name, attr_name, attr_value);
01404 
01405         if (node)
01406             go_to(node);
01407         else {
01408             node = new XMLNode(name);
01409             add_down(node);
01410             (*node)[attr_name] = attr_value;
01411         }
01412     }

XS_String& XMLStorage::XMLPos::str (  )  [inline]

Definition at line 1460 of file xmlstorage.h.

01460 {return *_cur;}

const XS_String& XMLStorage::XMLPos::str (  )  const [inline]

Definition at line 1461 of file xmlstorage.h.

01461 {return *_cur;}

void XMLStorage::XMLPos::go_to ( XMLNode child  )  [inline, protected]

go to specified node

Definition at line 1469 of file xmlstorage.h.

01470     {
01471         _stack.push(_cur);
01472         _cur = child;
01473     }


Field Documentation

XMLNode* XMLStorage::XMLPos::_root [protected]

Definition at line 1464 of file xmlstorage.h.

XMLNode* XMLStorage::XMLPos::_cur [protected]

Definition at line 1465 of file xmlstorage.h.

std::stack<XMLNode*> XMLStorage::XMLPos::_stack [protected]

Definition at line 1466 of file xmlstorage.h.


The documentation for this struct was generated from the following file:
IBrowser Source Code Documentation
generated on 18.09.2008 by doxygen

Homepage