|
template<typename T , typename TreePath > |
void | pre (T &&, TreePath) const |
| Method for prefix tree traversal.
|
|
template<typename T , typename TreePath > |
void | in (T &&, TreePath) const |
| Method for infix tree traversal.
|
|
template<typename T , typename TreePath > |
void | post (T &&, TreePath) const |
| Method for postfix tree traversal.
|
|
template<typename T , typename TreePath > |
void | leaf (T &&, TreePath) const |
| Method for leaf traversal.
|
|
template<typename T , typename Child , typename TreePath , typename ChildIndex > |
void | beforeChild (T &&, Child &&, TreePath, ChildIndex) const |
| Method for parent-child traversal.
|
|
template<typename T , typename Child , typename TreePath , typename ChildIndex > |
void | afterChild (T &&, Child &&, TreePath, ChildIndex) const |
| Method for child-parent traversal.
|
|
Visitor interface and base class for TypeTree visitors.
DefaultVisitor defines the interface for visitors that can be applied to a TypeTree using applyToTree(). Each method of the visitor is passed a node of the tree (either as a mutable or a const reference, depending on the constness of the tree applyToTree() was called with). The second argument is of type TreePath and denotes the exact position of the node within the TypeTree, encoded as child indices starting at the root node.
In order to create a functioning visitor, an implementation will - in addition to providing the methods of this class - also have to contain the following template struct, which is used to determine whether to visit a given node:
template<typename Node, typename Child, typename TreePath>
struct VisitChild
{
static const bool value = ...;
};
For the two most common scenarios - visiting only direct children and visiting the whole tree - there are mixin classes VisitDirectChildren and VisitTree and combined base classes TreeVisitor and DirectChildrenVisitor. The latter two inherit from both DefaultVisitor and one of the two mixin classes and can thus be used as convenient base classes.
- Note
- This class can also be used as a convenient base class if the implemented visitor only needs to act on some of the possible callback sites, avoiding a lot of boilerplate code.