|
template<typename T1 , typename T2 , typename TreePath > |
void | pre (T1 &&t1, T2 &&t2, TreePath treePath) const |
| Method for prefix tree traversal. More...
|
|
template<typename T1 , typename T2 , typename TreePath > |
void | in (T1 &&t1, T2 &&t2, TreePath treePath) const |
| Method for infix tree traversal. More...
|
|
template<typename T1 , typename T2 , typename TreePath > |
void | post (T1 &&t1, T2 &&t2, TreePath treePath) const |
| Method for postfix traversal. More...
|
|
template<typename T1 , typename T2 , typename TreePath > |
void | leaf (T1 &&t1, T2 &&t2, TreePath treePath) const |
| Method for leaf traversal. More...
|
|
template<typename T1 , typename Child1 , typename T2 , typename Child2 , typename TreePath , typename ChildIndex > |
void | beforeChild (T1 &&t1, Child1 &&child1, T2 &&t2, Child2 &&child2, TreePath treePath, ChildIndex childIndex) const |
| Method for parent-child traversal. More...
|
|
template<typename T1 , typename Child1 , typename T2 , typename Child2 , typename TreePath , typename ChildIndex > |
void | afterChild (T1 &&t1, Child1 &&child1, T2 &&t2, Child2 &&child2, TreePath treePath, ChildIndex childIndex) const |
| Method for child-parent traversal. More...
|
|
Visitor interface and base class for visitors of pairs of TypeTrees.
DefaultPairVisitor defines the interface for visitors that can be applied to a pair of TypeTrees using applyToTreePair(). Each method of the visitor is passed a node of both trees (either as a mutable or a const reference, depending on the constness of the tree applyToTreePair() was called with). The last argument is of type TreePath and denotes the exact position of the nodes within the TypeTrees, 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 Node1,
typename Child1,
typename Node2,
typename Child2,
struct VisitChild
{
static const bool value = ...;
};
A hybrid version of TreePath that supports both compile time and run time indices.
Definition: treepath.hh:79
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 TreePairVisitor and DirectChildrenPairVisitor. The latter two inherit from both DefaultVisitor and one of the two mixin classes and can thus be used as convenient base classes.
- Note
- If your compiler does not support rvalue references, both trees must be either const or non-const. If you call applyToTreePair() with two trees of different constness, they will both be made const.
-
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.