Public Member Functions | Protected Member Functions | Protected Attributes | Friends

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, 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_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 2138 of file xmlstorage.h.


Constructor & Destructor Documentation

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

Definition at line 2140 of file xmlstorage.h.

     :  _root(root),
        _cur(root)
    {
    }
XMLStorage::XMLPos::XMLPos ( const XMLPos other ) [inline]

Definition at line 2146 of file xmlstorage.h.

     :  _root(other._root),
        _cur(other._cur)
    {   // don't copy _stack
    }
XMLStorage::XMLPos::XMLPos ( XMLNode node,
const XS_String name 
) [inline]

Definition at line 2152 of file xmlstorage.h.

References smart_create().

     :  _root(node),
        _cur(node)
    {
        smart_create(name);
    }

Here is the call graph for this function:

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

Definition at line 2159 of file xmlstorage.h.

References smart_create().

     :  _root(node),
        _cur(node)
    {
        smart_create(name, attr_name, attr_value);
    }

Here is the call graph for this function:

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

Definition at line 2166 of file xmlstorage.h.

References smart_create().

     :  _root(other._root),
        _cur(other._cur)
    {
        smart_create(name);
    }

Here is the call graph for this function:

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

Definition at line 2173 of file xmlstorage.h.

References smart_create().

     :  _root(other._root),
        _cur(other._cur)
    {
        smart_create(name, attr_name, attr_value);
    }

Here is the call graph for this function:


Member Function Documentation

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

insert children when building tree

Definition at line 2219 of file xmlstorage.h.

References _cur, XMLStorage::XMLNode::add_child(), and go_to().

Referenced by create(), and smart_create().

    {
        _cur->add_child(child);
        go_to(child);
    }

Here is the call graph for this function:

Here is the caller graph for this function:

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

count the nodes matching the given relative XPath expression

Definition at line 2329 of file xmlstorage.h.

References _cur, and XMLStorage::XMLNode::count().

Referenced by test_read().

    {
        return _cur->count(xpath);
    }

Here is the call graph for this function:

Here is the caller graph for this function:

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

create node and move to it

Definition at line 2290 of file xmlstorage.h.

References add_down().

Referenced by test_write(), xml_test(), and XMLStorage::XMLMessage::XMLMessage().

    {
        add_down(new XMLNode(name));
    }

Here is the call graph for this function:

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 2296 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);
    }

Here is the call 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 2279 of file xmlstorage.h.

References _cur, XMLStorage::XMLNode::create_relative(), and go_to().

    {
        XMLNode* node = _cur->create_relative(xpath);
        if (!node)
            return false;   // invalid path specified

        go_to(node);
        return true;
    }

Here is the call graph for this function:

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

Definition at line 2186 of file xmlstorage.h.

References _cur.

    {
        return *_cur;
    }
XMLNode& XMLStorage::XMLPos::cur (  ) [inline]

access to current node

Definition at line 2181 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 2387 of file xmlstorage.h.

References XMLStorage::XMLNode::_children, _cur, and _stack.

Referenced by test_delete().

    {
        if (!_stack.empty()) {
            XMLNode* pLast = _stack.top();

            if (pLast->_children.remove(_cur)) {
                _cur = _stack.top();
                return true;
            }
        }

        return false;
    }

Here is the caller graph for this function:

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

remove the attribute 'attr_name' from the current node

Definition at line 2408 of file xmlstorage.h.

References _cur, and XMLStorage::XMLNode::erase().

Referenced by test_delete().

    {
        _cur->erase(attr_name);
    }

Here is the call graph for this function:

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

References _cur, and XMLStorage::XMLNode::filter().

Referenced by test_read().

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

Here is the call graph for this function:

Here is the caller graph for this function:

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

attribute access

Definition at line 2202 of file xmlstorage.h.

References _cur, and XMLStorage::XMLNode::get().

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

Here is the call 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 2214 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 111 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 XMLRPC::XMLRPCResult::XMLRPCResult().

{
    XMLNode* node = xpath._absolute? _root: _cur;

    node = node->find_relative(xpath);

    if (node) {
        go_to(node);
        return true;
    } else
        return false;
}

Here is the call graph for this function:

Here is the caller graph for this function:

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

go down to first child

Definition at line 2239 of file xmlstorage.h.

References _cur, XMLStorage::XMLNode::get_first_child(), and go_to().

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

    {
        XMLNode* node = _cur->get_first_child();

        if (node) {
            go_to(node);
            return true;
        } else
            return false;
    }

Here is the call graph for this function:

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 2251 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;
    }

Here is the call graph for this function:

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

go to specified node

Definition at line 2433 of file xmlstorage.h.

References _cur, and _stack.

Referenced by add_down(), create_relative(), go(), go_down(), iterate(), and smart_create().

    {
        _stack.push(_cur);
        _cur = child;
    }

Here is the caller graph for this function:

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

iterate to the next matching child

Definition at line 2263 of file xmlstorage.h.

References _cur, XMLStorage::XPathElement::find(), and go_to().

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

    {
        XMLNode* node = XPathElement(child_name, cnt).find(_cur);

        if (node) {
            go_to(node);
            ++cnt;
            return true;
        } else
            return false;
    }

Here is the call graph for this function:

Here is the caller graph for this function:

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

automatic access to current node

Definition at line 2192 of file xmlstorage.h.

References _cur.

{return _cur;}
XMLStorage::XMLPos::operator XMLNode * (  ) [inline]

Definition at line 2193 of file xmlstorage.h.

References _cur.

{return _cur;}
XMLNode& XMLStorage::XMLPos::operator* (  ) [inline]

Definition at line 2199 of file xmlstorage.h.

References _cur.

{return *_cur;}
const XMLNode& XMLStorage::XMLPos::operator* (  ) const [inline]

Definition at line 2198 of file xmlstorage.h.

References _cur.

{return *_cur;}
const XMLNode* XMLStorage::XMLPos::operator-> (  ) const [inline]

Definition at line 2195 of file xmlstorage.h.

References _cur.

{return _cur;}
XMLNode* XMLStorage::XMLPos::operator-> (  ) [inline]

Definition at line 2196 of file xmlstorage.h.

References _cur.

{return _cur;}
XS_String& XMLStorage::XMLPos::operator[] ( const XS_String attr_name ) [inline]

Definition at line 2215 of file xmlstorage.h.

References _cur.

{return (*_cur)[attr_name];}
const XS_String& XMLStorage::XMLPos::operator[] ( const XS_String attr_name ) const [inline]

Definition at line 2216 of file xmlstorage.h.

References _cur.

{return (*_cur)[attr_name];}
void XMLStorage::XMLPos::put ( const XS_String attr_name,
const XS_String value 
) [inline]

attribute setting

Definition at line 2208 of file xmlstorage.h.

References _cur, and XMLStorage::XMLNode::put().

Referenced by set_property().

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

Here is the call graph for this function:

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

References _cur, and XMLStorage::XMLNode::remove_children().

    {
        _cur->remove_children(name);
    }

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 3974 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();
}

Here is the call graph for this function:

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

Definition at line 3960 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();
}

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

References set_property().

Referenced by set_property().

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

Here is the call graph for this function:

Here is the caller 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 3967 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();
}

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

References _cur, add_down(), XMLStorage::XPathElement::find(), and go_to().

Referenced by set_property(), and XMLPos().

    {
        XMLNode* node = XPathElement(child_name).find(_cur);

        if (node)
            go_to(node);
        else
            add_down(new XMLNode(child_name));
    }

Here is the call graph for this function:

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 2315 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;
        }
    }

Here is the call graph for this function:

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

Definition at line 2414 of file xmlstorage.h.

References _cur.

{return *_cur;}
XS_String& XMLStorage::XMLPos::str (  ) [inline]

Definition at line 2413 of file xmlstorage.h.

References _cur.

{return *_cur;}

Friends And Related Function Documentation

friend struct const_XMLPos [friend]

Definition at line 2426 of file xmlstorage.h.


Member Data Documentation

Definition at line 2428 of file xmlstorage.h.

Referenced by go().

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

Definition at line 2430 of file xmlstorage.h.

Referenced by back(), delete_this(), and go_to().


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