MezzanineEngine 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Types | Public Member Functions | List of all members
Mezzanine::XML::NamedNodeIterator Class Reference

Child node iterator (a forward iterator over a collection of Node) only iterates over nodes with a given name. More...

#include <nodeiterator.h>

Public Types

typedef ptrdiff_t difference_type
 An Iterator trait.
 
typedef std::forward_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

 NamedNodeIterator ()
 Default constructor.
 
 NamedNodeIterator (const Node &node, const Char8 *Name)
 Construct an iterator which points to the specified node.
 
bool operator!= (const NamedNodeIterator &rhs) const
 Compares this NamedNodeIterator to another NamedNodeIterator for inequality. More...
 
Nodeoperator* () const
 Deferences this Iterator. More...
 
const NamedNodeIteratoroperator++ ()
 Increment the iterator to the next member of the container. More...
 
NamedNodeIterator operator++ (int)
 Increment the iterator to the next member of the container. More...
 
Nodeoperator-> () const
 Get the pointer the Node this points to. More...
 
bool operator== (const NamedNodeIterator &rhs) const
 Compares this NamedNodeIterator to another NamedNodeIterator for equality. More...
 

Detailed Description

Child node iterator (a forward iterator over a collection of Node) only iterates over nodes with a given name.

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 159 of file nodeiterator.h.

Member Function Documentation

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

Compares this NamedNodeIterator to another NamedNodeIterator for inequality.

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

Deferences this Iterator.

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

Increment the iterator to the next member of the container.

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

Increment the iterator to the next member of the container.

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

Get the pointer the Node this points to.

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

Compares this NamedNodeIterator to another NamedNodeIterator for equality.

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

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