NuriaProject Framework
0.1
The NuriaProject Framework
|
LazyCondition offers lazily evaluated conditions for C++. More...
#include <lazyevaluation.hpp>
Public Types | |
enum | Type { Empty = 0, Single, Equal, NonEqual, Greater, GreaterEqual, Less, LessEqual, LogicAnd, LogicOr } |
Public Member Functions | |
LazyCondition () | |
LazyCondition (const Field &field) | |
LazyCondition (const QVariant &single) | |
LazyCondition (const LazyCondition &other) | |
LazyCondition (const QVariant &left, Type type, const QVariant &right) | |
~LazyCondition () | |
void | compile (AbstractConditionEvaluator *evaluator=nullptr) |
bool | evaluate (const QVariantList &arguments) const |
bool | isValid () const |
const QVariant & | left () const |
operator QVariant () const | |
LazyCondition | operator&& (const LazyCondition &other) |
template<typename... Args> | |
bool | operator() (const Args &...args) |
LazyCondition & | operator= (const LazyCondition &other) |
LazyCondition | operator|| (const LazyCondition &other) |
const QVariant & | right () const |
Type | type () const |
LazyCondition offers lazily evaluated conditions for C++.
This class also acts as functor, meaning that you can later call it like a method. This also means that you can pass a instance to every function which expects a functor, like STL algorithms.
You can reference to arguments by index (Starting from 0) using Nuria::arg.
Available types of conditions.
Nuria::LazyCondition::LazyCondition | ( | ) |
Constructs a instance of type Empty.
Nuria::LazyCondition::~LazyCondition | ( | ) |
Destructor.
Nuria::LazyCondition::LazyCondition | ( | const Field & | field | ) |
Constructs a instance of type Single.
Nuria::LazyCondition::LazyCondition | ( | const QVariant & | single | ) |
Constructs a instance of type Single.
Nuria::LazyCondition::LazyCondition | ( | const LazyCondition & | other | ) |
Copy constructor.
Nuria::LazyCondition::LazyCondition | ( | const QVariant & | left, |
Type | type, | ||
const QVariant & | right | ||
) |
Constructor.
void Nuria::LazyCondition::compile | ( | AbstractConditionEvaluator * | evaluator = nullptr | ) |
Compiles the condition using evaluator. If no evaluator is given, the default implementation will be used. Ownership of evaluator will be transferred to this instance.
bool Nuria::LazyCondition::evaluate | ( | const QVariantList & | arguments | ) | const |
Evaluates the condition with arguments as input. If not already done the condition will be first compiled.
bool Nuria::LazyCondition::isValid | ( | ) | const |
Returns true
if the type of this condition is not Empty.
const QVariant& Nuria::LazyCondition::left | ( | ) | const |
Returns the left-hand side value of the condition.
Nuria::LazyCondition::operator QVariant | ( | ) | const |
Allow implicit conversion to QVariant.
LazyCondition Nuria::LazyCondition::operator&& | ( | const LazyCondition & | other | ) |
Returns a LazyCondition with a logical and conjunction between this instance (on the left-hand side) and other (on the right-hand side).
|
inline |
Evaluates the condition.
LazyCondition& Nuria::LazyCondition::operator= | ( | const LazyCondition & | other | ) |
Assignment operator.
LazyCondition Nuria::LazyCondition::operator|| | ( | const LazyCondition & | other | ) |
Returns a LazyCondition with a logical or conjunction between this instance (on the left-hand side) and other (on the right-hand side).
const QVariant& Nuria::LazyCondition::right | ( | ) | const |
Returns the right-hand side value of the condition.