Used to call a function OnEachNode member of the subtree of nodes descended from a specific node.
More...
#include <treewalker.h>
|
int | Depth () const |
| How many descendants deep are we during traversal. More...
|
|
Used to call a function OnEachNode member of the subtree of nodes descended from a specific node.
If you want to do a deep tree traversal, you'll either have to do it via a recursive function or some equivalent method or use a TreeWalker. This provides a helper for depth-first traversal of a subtree. In order to use it, you have to implement XML::TreeWalker interface and call XML::Node::Traverse() function.
Definition at line 83 of file treewalker.h.
int Mezzanine::XML::TreeWalker::Depth |
( |
) | |
const |
|
protected |
How many descendants deep are we during traversal.
- Returns
- This returns -1 if called from TreeWalker::OnTraversalBegin() or TreeWalker::OnTraversalEnd(), and returns 0-based depth if called from OnEachNode - depth is 0 for all children of the traversal root, 1 for all grandchildren, 2 for great-grandchildren and so on.
virtual bool Mezzanine::XML::TreeWalker::OnEachNode |
( |
Node & |
node) | |
|
|
pure virtual |
A Pure Virtual function that is expected to be implemented to create the desired behavior.
- Parameters
-
node | The curren node being trraversed. |
This is called on every Node that is traversed except the root node of the traversed subtree. Can be used to perform sophisticated searches of a portion of the xml document, alter the document on a large scale, gather statistics, or just about any other behavior that requires touching many nodes.
- Returns
- if true Traversal is expected to continue, if false, then traversal ends and the Node::Traverse() that was called is expected to return false.
virtual bool Mezzanine::XML::TreeWalker::OnTraversalBegin |
( |
Node & |
node) | |
|
|
virtual |
Called by the root Node of the xml subtree when traversal begins.
- Parameters
-
node | The first node the Tree to traverse |
By default this simply returns true, but is expected to be overridden with any desired behavior
- Returns
- True by default. If it returns false, then traversal ends and the Node::Traverse() that was called is expected to return false.
virtual bool Mezzanine::XML::TreeWalker::OnTraversalEnd |
( |
Node & |
node) | |
|
|
virtual |
Called on the root Node of the xml subtree when traversal ends.
- Parameters
-
node | The last node the Tree to traverse |
By default this simply returns true, but is expected to be overridden with any desired behavior
- Returns
- True by default. If it returns false, then traversal ends and the Node::Traverse() that was called is expected to return false.
The documentation for this class was generated from the following file: