NuriaProject Framework
0.1
The NuriaProject Framework
|
The LazyConditionWalker class lets you walk over a LazyCondition tree to make modifications to it. More...
#include <lazyconditionwalker.hpp>
Public Member Functions | |
LazyConditionWalker () | |
LazyConditionWalker (const LazyConditionWalker &other) | |
~LazyConditionWalker () | |
void | onCondition (LazyCondition::Type type, const Callback &method) |
void | onField (int fieldType, const Callback &method) |
void | onVariant (int userType, const Callback &method) |
LazyConditionWalker & | operator= (const LazyConditionWalker &other) |
LazyCondition | walk (const LazyCondition &condition, bool walkArguments=false) |
The LazyConditionWalker class lets you walk over a LazyCondition tree to make modifications to it.
Using the on* methods, you can register handler methods. That method will be passed two arguments: First a QVariantList, which contains the stack to the particular item, the last element being the item itself. Second, the item itself.
The method may return a value, which will replace the previous value. Further checks don't take place on validity, so make sure that your result is legal in the position.
All nodes are walked depth-first. Children of a returned item are skipped.
Nuria::LazyConditionWalker::LazyConditionWalker | ( | ) |
Constructs a empty walker.
Nuria::LazyConditionWalker::LazyConditionWalker | ( | const LazyConditionWalker & | other | ) |
Copy constructor.
Nuria::LazyConditionWalker::~LazyConditionWalker | ( | ) |
Destructor.
void Nuria::LazyConditionWalker::onCondition | ( | LazyCondition::Type | type, |
const Callback & | method | ||
) |
Registers method as handler for conditions of type.
void Nuria::LazyConditionWalker::onField | ( | int | fieldType, |
const Callback & | method | ||
) |
Registers method as handler for fields of fieldType. This also works with custom types.
void Nuria::LazyConditionWalker::onVariant | ( | int | userType, |
const Callback & | method | ||
) |
Register method as handler for variants of type userType.
Registering a handler for LazyCondition or Field has no effect.
LazyConditionWalker& Nuria::LazyConditionWalker::operator= | ( | const LazyConditionWalker & | other | ) |
Assignment operator.
LazyCondition Nuria::LazyConditionWalker::walk | ( | const LazyCondition & | condition, |
bool | walkArguments = false |
||
) |
Walks over condition and returns the resulting condition.
When passing true
for walkArguments, arguments of TestCalls are also visited. Be aware that this feature increases the complexity.