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 Node * | pointer |
An Iterator trait. | |
typedef Node & | reference |
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... | |
Node & | operator* () const |
Deferences this Iterator. More... | |
const NodeIterator & | operator++ () |
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 NodeIterator & | operator-- () |
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... | |
Node * | operator-> () 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 |
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.
Mezzanine::XML::NodeIterator::NodeIterator | ( | const Node & | node) |
Construct an iterator which points to the specified node.
node | A Node that this iterator will point to. |
bool Mezzanine::XML::NodeIterator::operator!= | ( | const NodeIterator & | rhs) | const |
Compares this NodeIterator to another NodeIterator for inequality.
rhs | The Right Hand Side NodeIterator. |
Node& Mezzanine::XML::NodeIterator::operator* | ( | ) | const |
Deferences this Iterator.
const NodeIterator& Mezzanine::XML::NodeIterator::operator++ | ( | ) |
Increment the iterator to the next member of the container.
NodeIterator Mezzanine::XML::NodeIterator::operator++ | ( | int | ) |
Increment the iterator to the next member of the container.
const NodeIterator& Mezzanine::XML::NodeIterator::operator-- | ( | ) |
Decrement the iterator to the next member of the container.
NodeIterator Mezzanine::XML::NodeIterator::operator-- | ( | int | ) |
Decrement the iterator to the next member of the container.
Node* Mezzanine::XML::NodeIterator::operator-> | ( | ) | const |
Get the pointer the Node this points to.
bool Mezzanine::XML::NodeIterator::operator== | ( | const NodeIterator & | rhs) | const |
Compares this NodeIterator to another NodeIterator for equality.
rhs | The Right Hand Side NodeIterator |