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