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]

List of all members.

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
 automatic access to current node
 operator XMLNode * ()
const XMLNodeoperator-> () const
XMLNodeoperator-> ()
const XMLNodeoperator * () const
XMLNodeoperator * ()
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_Stringoperator[] (const XS_String &attr_name)
const XS_Stringoperator[] (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, size_t &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_Stringstr ()
const XS_Stringstr () 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


Detailed Description

iterator for XML trees

Definition at line 1493 of file xmlstorage.h.


Constructor & Destructor Documentation

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

Definition at line 1495 of file xmlstorage.h.

Referenced by XMLStorage::XMLMessageReader::XMLMessageReader().

01495 {
01496     XMLPos(XMLNode* root)
01497      :  _root(root),
01498         _cur(root)
01499     {

Here is the caller graph for this function:

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

Definition at line 1501 of file xmlstorage.h.

01503      :  _root(other._root),
01504         _cur(other._cur)
01505     {   // don't copy _stack

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

Definition at line 1507 of file xmlstorage.h.

01509      :  _root(node),
01510         _cur(node)
01511     {
01512         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 1514 of file xmlstorage.h.

01516      :  _root(node),
01517         _cur(node)
01518     {
01519         smart_create(name, attr_name, attr_value);

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

Definition at line 1521 of file xmlstorage.h.

01523      :  _root(other._root),
01524         _cur(other._cur)
01525     {
01526         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 1528 of file xmlstorage.h.

01530      :  _root(other._root),
01531         _cur(other._cur)
01532     {
01533         smart_create(name, attr_name, attr_value);


Member Function Documentation

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

access to current node

Definition at line 1536 of file xmlstorage.h.

01538     {
01539         return *_cur;

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

Definition at line 1541 of file xmlstorage.h.

01543     {
01544         return *_cur;

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

automatic access to current node

Definition at line 1547 of file xmlstorage.h.

01548 {return _cur;}

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

Definition at line 1548 of file xmlstorage.h.

01548 {return _cur;}

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

Definition at line 1550 of file xmlstorage.h.

01551 {return _cur;}

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

Definition at line 1551 of file xmlstorage.h.

01551 {return _cur;}

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

Definition at line 1553 of file xmlstorage.h.

01554 {return *_cur;}

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

Definition at line 1554 of file xmlstorage.h.

01554 {return *_cur;}

XS_String XMLStorage::XMLPos::get ( const XS_String attr_name,
LPCXSSTR  def = XS_EMPTY_STR 
) const [inline]

attribute access

Definition at line 1557 of file xmlstorage.h.

01559     {
01560         return _cur->get(attr_name, def);

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

attribute setting

Definition at line 1563 of file xmlstorage.h.

Referenced by set_property().

01565     {
01566         _cur->put(attr_name, value);

Here is the caller graph for this function:

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

index operator attribute access

Definition at line 1569 of file xmlstorage.h.

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

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

Definition at line 1570 of file xmlstorage.h.

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

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

Definition at line 1571 of file xmlstorage.h.

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

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

insert children when building tree

Definition at line 1574 of file xmlstorage.h.

01576     {
01577         _cur->add_child(child);
01578         go_to(child);

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

go back to previous position

Definition at line 1581 of file xmlstorage.h.

Referenced by XMLStorage::XMLWriter::create_node_content(), XMLRPCParser::get_any(), XMLRPCParser::get_array(), XMLRPCParser::get_binary(), XMLRPCParser::get_bool(), XMLRPCParser::get_date(), XMLRPCParser::get_double(), XMLRPCParser::get_int(), XMLRPCParser::get_parameter_types(), XMLRPCParser::get_string(), XMLRPCParser::get_struct(), set_property(), test_delete(), test_read(), test_read1(), test_read2(), test_write(), xml_test(), XMLRPCRequest::XMLRPCRequest(), and XMLRPCResult::XMLRPCResult().

01583     {
01584         if (!_stack.empty()) {
01585             _cur = _stack.top();
01586             _stack.pop();
01587             return true;
01588         } else
01589             return false;

Here is the caller graph for this function:

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

go down to first child

Definition at line 1592 of file xmlstorage.h.

Referenced by XMLRPCParser::next_parameter(), test_delete(), XMLRPCParser::XMLRPCParser(), XMLRPCRequest::XMLRPCRequest(), and XMLRPCResult::XMLRPCResult().

01594     {
01595         XMLNode* node = _cur->get_first_child();
01596 
01597         if (node) {
01598             go_to(node);
01599             return true;
01600         } else
01601             return false;

Here is the caller graph for this function:

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

search for child and go down

Definition at line 1604 of file xmlstorage.h.

01606     {
01607         XMLNode* node = XPathElement(child_name, n).find(_cur);
01608 
01609         if (node) {
01610             go_to(node);
01611             return true;
01612         } else
01613             return false;

bool XMLStorage::XMLPos::iterate ( const XS_String child_name,
size_t &  cnt 
) [inline]

iterate to the next matching child

Definition at line 1616 of file xmlstorage.h.

Referenced by XMLRPCParser::get_parameter_types(), and XMLRPCParser::next_parameter().

01618     {
01619         XMLNode* node = XPathElement(child_name, cnt).find(_cur);
01620 
01621         if (node) {
01622             go_to(node);
01623             ++cnt;
01624             return true;
01625         } else
01626             return false;

Here is the caller graph for this function:

bool XMLStorage::XMLPos::go ( const XPath xpath  ) 

move to the position defined by xpath in XML tree

Definition at line 112 of file xmlstorage.cpp.

References XMLStorage::XPath::_absolute, _cur, _root, XMLStorage::XMLNode::find_relative(), and go_to().

Referenced by test_read(), test_read1(), test_read2(), xml_test(), and XMLRPCResult::XMLRPCResult().

00113 {
00114     XMLNode* node = xpath._absolute? _root: _cur;
00115 
00116     node = node->find_relative(xpath);
00117 
00118     if (node) {
00119         go_to(node);
00120         return true;
00121     } else
00122         return false;
00123 }

Here is the call graph for this function:

Here is the caller graph for this function:

bool XMLStorage::XMLPos::create_relative ( const XPath xpath  )  [inline]

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

Definition at line 1632 of file xmlstorage.h.

01634     {
01635         XMLNode* node = _cur->create_relative(xpath);
01636         if (!node)
01637             return false;   // invalid path specified
01638 
01639         go_to(node);
01640         return true;

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

create node and move to it

Definition at line 1643 of file xmlstorage.h.

Referenced by XMLStorage::XMLWriter::create_node_content(), test_write(), and xml_test().

01645     {
01646         add_down(new XMLNode(name));

Here is the caller graph for this function:

void XMLStorage::XMLPos::create_node_content ( const XS_String node_name,
const XS_String content 
) [inline]

create node with string content

Definition at line 1649 of file xmlstorage.h.

References XMLStorage::XMLNode::set_content().

01651     {
01652         XMLNode* pNode = new XMLNode(node_name);
01653             pNode->set_content(content);
01654         _cur->add_child(pNode);

Here is the call graph for this function:

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

create node if not already existing and move to it

Definition at line 1657 of file xmlstorage.h.

Referenced by set_property().

01659     {
01660         XMLNode* node = XPathElement(child_name).find(_cur);
01661 
01662         if (node)
01663             go_to(node);
01664         else
01665             add_down(new XMLNode(child_name));

Here is the caller graph for this function:

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 1668 of file xmlstorage.h.

01670     {
01671         XMLNode* node = XPathElement(child_name, 0, attr_name, attr_value).find(_cur);
01672 
01673         if (node)
01674             go_to(node);
01675         else {
01676             node = new XMLNode(child_name);
01677             add_down(node);
01678             (*node)[attr_name] = attr_value;
01679         }

int XMLStorage::XMLPos::count ( const XPath xpath  )  const [inline]

count the nodes matching the given relative XPath expression

Definition at line 1682 of file xmlstorage.h.

Referenced by test_read().

01684     {
01685         return _cur->count(xpath);

Here is the caller graph for this function:

int XMLStorage::XMLPos::filter ( const XPath xpath,
XMLNode target 
) const [inline]

create a new node tree using the given XPath filter expression

Definition at line 1688 of file xmlstorage.h.

Referenced by test_read().

01690     {
01691         return _cur->filter(xpath, target);

Here is the caller graph for this function:

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

delete current node and go back to previous position

Definition at line 1740 of file xmlstorage.h.

References XMLStorage::XMLNode::_children.

Referenced by test_delete().

01742     {
01743         if (!_stack.empty()) {
01744             XMLNode* pLast = _stack.top();
01745 
01746             if (pLast->_children.remove(_cur)) {
01747                 _cur = _stack.top();
01748                 return true;
01749             }
01750         }
01751 
01752         return false;

Here is the caller graph for this function:

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

remove all children named 'name'

Definition at line 1755 of file xmlstorage.h.

01757     {
01758         _cur->remove_children(name);

void XMLStorage::XMLPos::erase ( const XS_String attr_name  )  [inline]

remove the attribute 'attr_name' from the current node

Definition at line 1761 of file xmlstorage.h.

Referenced by test_delete().

01763     {
01764         _cur->erase(attr_name);

Here is the caller graph for this function:

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

Definition at line 1766 of file xmlstorage.h.

01767 {return *_cur;}

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

Definition at line 1767 of file xmlstorage.h.

01767 {return *_cur;}

void XMLStorage::XMLPos::set_property ( const XS_String key,
int  value,
const XS_String name = XS_PROPERTY 
) [inline]

Definition at line 2274 of file xmlstorage.h.

References _cur, back(), smart_create(), XMLStorage::XS_KEY, and XMLStorage::XS_VALUE.

02276 {
02277     smart_create(name, XS_KEY, key);
02278         XMLIntRef(_cur, XS_VALUE) = value;
02279     back();

Here is the call graph for this function:

void XMLStorage::XMLPos::set_property ( const XS_String key,
double  value,
const XS_String name = XS_PROPERTY 
) [inline]

Definition at line 2281 of file xmlstorage.h.

References _cur, back(), smart_create(), XMLStorage::XS_KEY, and XMLStorage::XS_VALUE.

02283 {
02284     smart_create(name, XS_KEY, key);
02285         XMLDoubleRef(_cur, XS_VALUE) = value;
02286     back();

Here is the call graph for this function:

void XMLStorage::XMLPos::set_property ( const XS_String key,
const XS_String value,
const XS_String name = XS_PROPERTY 
) [inline]

Definition at line 2288 of file xmlstorage.h.

References back(), put(), smart_create(), XMLStorage::XS_KEY, and XMLStorage::XS_VALUE.

02290 {
02291     smart_create(name, XS_KEY, key);
02292         put(XS_VALUE, value);
02293     back();

Here is the call graph for this function:

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 1775 of file xmlstorage.h.

References XMLStorage::XS_String::XS_String().

01777         {set_property(key, XS_String(value), name);}

Here is the call graph for this function:

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

go to specified node

Definition at line 1786 of file xmlstorage.h.

Referenced by go().

01788     {
01789         _stack.push(_cur);
01790         _cur = child;

Here is the caller graph for this function:


Friends And Related Function Documentation

friend struct const_XMLPos [friend]

Definition at line 1779 of file xmlstorage.h.


Member Data Documentation

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

Definition at line 1781 of file xmlstorage.h.

Referenced by go().

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

Definition at line 1782 of file xmlstorage.h.

Referenced by XMLStorage::XMLPropertyReader::const_iterator::get_node(), go(), XMLStorage::XMLPropertyReader::const_iterator::operator *(), XMLStorage::XMLPropertyReader::const_iterator::operator BaseIterator(), XMLStorage::XMLPropertyReader::const_iterator::operator!=(), XMLStorage::XMLPropertyReader::const_iterator::operator++(), XMLStorage::XMLPropertyReader::const_iterator::operator==(), and set_property().

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

Definition at line 1783 of file xmlstorage.h.

Referenced by XMLStorage::XMLWriter::operator[](), XMLStorage::XMLWriter::put(), and XMLStorage::XMLWriter::set_content().


The documentation for this struct was generated from the following files:
Generated on Sat Jan 9 00:05:55 2010 for XMLStorage/C++ by  doxygen 1.5.4