Spinning Topp Logo BlackTopp Studios
inc
Public Types | Public Member Functions | Friends | List of all members
Mezzanine::XML::NodeIterator Class Reference

Child node iterator (a bidirectional iterator over a collection of Node) More...

#include <nodeiterator.h>

Public Types

typedef ptrdiff_t difference_type
 An Iterator trait.
 
typedef std::bidirectional_iterator_tag iterator_category
 An Iterator trait.
 
typedef Nodepointer
 An Iterator trait.
 
typedef Nodereference
 An Iterator trait.
 
typedef Node value_type
 An Iterator trait.
 

Public Member Functions

 NodeIterator ()
 Default Constructor, makes a blank iterator.
 
 NodeIterator (const Node &node)
 Construct an iterator which points to the specified node. More...
 
bool operator!= (const NodeIterator &rhs) const
 Compares this NodeIterator to another NodeIterator for inequality. More...
 
Nodeoperator* () const
 Deferences this Iterator. More...
 
const NodeIteratoroperator++ ()
 Increment the iterator to the next member of the container. More...
 
NodeIterator operator++ (int)
 Increment the iterator to the next member of the container. More...
 
const NodeIteratoroperator-- ()
 Decrement the iterator to the next member of the container. More...
 
NodeIterator operator-- (int)
 Decrement the iterator to the next member of the container. More...
 
Nodeoperator-> () const
 Get the pointer the Node this points to. More...
 
bool operator== (const NodeIterator &rhs) const
 Compares this NodeIterator to another NodeIterator for equality. More...
 

Friends

class Node
 

Detailed Description

Child node iterator (a bidirectional iterator over a collection of Node)

Node::begin() and Node::attributes_begin() return iterators that point to the first node/attribute, respectively; Node::end() and Node::attributes_end() return past-the-end iterator for node/attribute list, respectively - this iterator can't be dereferenced, but decrementing it results in an iterator pointing to the last element in the list (except for empty lists, where decrementing past-the-end iterator results in undefined behavior). Past-the-end iterator is commonly used as a termination value for iteration loops. If you want to get an iterator that points to an existing handle, you can construct the iterator with the handle as a single constructor argument, like so: xml_node_iterator(node). For xml_attribute_iterator, you'll have to provide both an attribute and its parent node.

Node::begin() and Node::end() return equal iterators if called on null Node; such iterators can't be dereferenced. Node::attributes_begin() and Node::attributes_end() behave the same way. For correct iterator usage this means that child node/attribute collections of null nodes appear to be empty.

Both types of iterators have bidirectional iterator semantics (i.e. they can be incremented and decremented, but efficient random access is not supported) and support all usual iterator operations - comparison, dereference, etc. The iterators are invalidated if the node/attribute objects they're pointing to are removed from the tree; adding nodes/attributes does not invalidate any iterators.

Definition at line 77 of file nodeiterator.h.

Constructor & Destructor Documentation

Mezzanine::XML::NodeIterator::NodeIterator ( const Node node)

Construct an iterator which points to the specified node.

Parameters
nodeA Node that this iterator will point to.

Member Function Documentation

bool Mezzanine::XML::NodeIterator::operator!= ( const NodeIterator rhs) const

Compares this NodeIterator to another NodeIterator for inequality.

Parameters
rhsThe Right Hand Side NodeIterator.
Returns
False if the internal data stored in Node this NodeIterator refers to is the same as the metadata in the other NodeIterator's Node, True otherwise.
Node& Mezzanine::XML::NodeIterator::operator* ( ) const

Deferences this Iterator.

Returns
a Node reference to the node pointed at by this NodeIterator.
const NodeIterator& Mezzanine::XML::NodeIterator::operator++ ( )

Increment the iterator to the next member of the container.

Returns
Returns a const NodeIterator.
NodeIterator Mezzanine::XML::NodeIterator::operator++ ( int  )

Increment the iterator to the next member of the container.

Returns
Returns a NodeIterator.
const NodeIterator& Mezzanine::XML::NodeIterator::operator-- ( )

Decrement the iterator to the next member of the container.

Returns
Returns a const NodeIterator.
NodeIterator Mezzanine::XML::NodeIterator::operator-- ( int  )

Decrement the iterator to the next member of the container.

Returns
Returns a NodeIterator.
Node* Mezzanine::XML::NodeIterator::operator-> ( ) const

Get the pointer the Node this points to.

Returns
A pointer to the Node this NodeIterator references.
bool Mezzanine::XML::NodeIterator::operator== ( const NodeIterator rhs) const

Compares this NodeIterator to another NodeIterator for equality.

Parameters
rhsThe Right Hand Side NodeIterator
Returns
True if the internal data stored in Node this NodeIterator refers to is the same as the metadata in the other NodeIterator's Node, false otherwise.

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