ticpp::Iterator< T > Class Template Reference

Iterator for conveniently stepping through Nodes and Attributes. More...

#include <ticpp.h>

List of all members.

Public Member Functions

T * begin (const Node *parent) const
 For for loop comparisons.
T * end () const
 For for loop comparisons.
 Iterator (const std::string &value="")
 Constructor.
 Iterator (T *node, const std::string &value="")
 Constructor.
 Iterator (const Iterator &it)
 Constructor.
T * Get () const
 Gets internal pointer.
Iteratoroperator= (const Iterator &it)
 Sets internal pointer.
Iteratoroperator= (T *p)
 Sets internal pointer.
Iteratoroperator++ ()
 Sets internal pointer to the Next Sibling, or Iterator::END, if there are no more siblings.
Iterator operator++ (int)
 Sets internal pointer to the Next Sibling, or Iterator::END, if there are no more siblings.
Iteratoroperator-- ()
 Sets internal pointer to the Previous Sibling, or Iterator::END, if there are no prior siblings.
Iterator operator-- (int)
 Sets internal pointer to the Previous Sibling, or Iterator::END, if there are no prior siblings.
bool operator!= (const T *p) const
 Compares internal pointer.
bool operator!= (const Iterator &it) const
 Compares internal pointer.
bool operator== (T *p) const
 Compares internal pointer*.
bool operator== (const Iterator &it) const
 Compares internal pointer.
T * operator-> () const
 So Iterator behaves like a STL iterator.
T & operator* () const
 So Iterator behaves like a STL iterator.


Detailed Description

template<class T = Node>
class ticpp::Iterator< T >

Iterator for conveniently stepping through Nodes and Attributes.

TinyXML++ introduces iterators:

    ticpp::Iterator< ticpp::Node > child;
    for ( child = child.begin( parent ); child != child.end(); child++ )

Iterators have the added advantage of filtering by type:

    // Only iterates through Comment nodes
    ticpp::Iterator< ticpp::Comment > child;
    for ( child = child.begin( parent ); child != child.end(); child++ )

    // Only iterates through Element nodes with value "ElementValue"
    ticpp::Iterator< ticpp::Element > child( "ElementValue" );
    for ( child = child.begin( parent ); child != child.end(); child++ )

Finally, Iterators also work with Attributes

    ticpp::Iterator< ticpp::Attribute > attribute;
    for ( attribute = attribute.begin( element ); attribute != attribute.end(); attribute++ )

Constructor & Destructor Documentation

template<class T = Node>
ticpp::Iterator< T >::Iterator ( const std::string &  value = ""  )  [inline]

Constructor.

Parameters:
value If not empty, this iterator will only visit nodes with matching value.
        // Only iterates through Element nodes with value "ElementValue"
        ticpp::Iterator< ticpp::Element > child( "ElementValue" );
        for ( child = child.begin( parent ); child != child.end(); child++ )


Member Function Documentation

template<class T = Node>
T* ticpp::Iterator< T >::begin ( const Node parent  )  const [inline]

For for loop comparisons.

Parameters:
parent The parent of the nodes to iterate.
Returns:
The first child of type T.
        ticpp::Iterator< ticpp::Node > child;
        for ( child = child.begin( parent ); child != child.end(); child++ )

References ticpp::Node::IterateFirst().

template<class T = Node>
T* ticpp::Iterator< T >::end (  )  const [inline]

For for loop comparisons.

Returns:
NULL
        ticpp::Iterator< ticpp::Node > child;
        for ( child = child.begin( parent ); child != child.end(); child++ )

template<class T = Node>
T* ticpp::Iterator< T >::Get (  )  const [inline]

Gets internal pointer.

Returns:
The internal pointer.


The documentation for this class was generated from the following file:

Generated on Sun Feb 15 23:12:14 2009 for TinyXml by  doxygen 1.5.6