You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
42 lines
1.8 KiB
C++
42 lines
1.8 KiB
C++
9 years ago
|
#include "exprevaluator.h"
|
||
|
|
||
|
#ifdef _MSC_VER
|
||
|
ExprEvaluator::ExprEvaluator()
|
||
|
{
|
||
|
m_operations["=="] = [](QVariant left, QVariant right) { return left == right; };
|
||
|
m_operations["!="] = [](QVariant left, QVariant right) { return left != right; };
|
||
|
m_operations["<"] = [](QVariant left, QVariant right) { return left < right; };
|
||
|
m_operations["<="] = [](QVariant left, QVariant right) { return left <= right; };
|
||
|
m_operations[">"] = [](QVariant left, QVariant right) { return left > right; };
|
||
|
m_operations[">="] = [](QVariant left, QVariant right) { return left >= right; };
|
||
|
m_operations["%"] = [](QVariant left, QVariant right) { return left.toString().contains(right.toString()); };
|
||
|
|
||
|
m_operations["||"] = [](QVariant left, QVariant right) { return left.toBool() || right.toBool(); };
|
||
|
m_operations["&&"] = [](QVariant left, QVariant right) { return left.toBool() && right.toBool(); };
|
||
|
}
|
||
|
#else
|
||
|
const QMap<QString, std::function<bool(QVariant, QVariant)> > ExprEvaluator::m_operations = {
|
||
|
{ "==", [](QVariant left, QVariant right) { return left == right; }},
|
||
|
{ "!=", [](QVariant left, QVariant right) { return left != right; }},
|
||
|
{ "<", [](QVariant left, QVariant right) { return left < right; }},
|
||
|
{ "<=", [](QVariant left, QVariant right) { return left <= right; }},
|
||
|
{ ">", [](QVariant left, QVariant right) { return left > right; }},
|
||
|
{ ">=", [](QVariant left, QVariant right) { return left >= right; }},
|
||
|
{ "%", [](QVariant left, QVariant right) { return left.toString().contains(right.toString()); }},
|
||
|
|
||
|
{ "||", [](QVariant left, QVariant right) { return left.toBool() || right.toBool(); }},
|
||
|
{ "&&", [](QVariant left, QVariant right) { return left.toBool() && right.toBool(); }}
|
||
|
};
|
||
|
|
||
|
ExprEvaluator::ExprEvaluator()
|
||
|
{
|
||
|
}
|
||
|
#endif
|
||
|
|
||
|
|
||
|
bool ExprEvaluator::evaluate(const QObject *data, const QString &expression)
|
||
|
{
|
||
|
return true;
|
||
|
}
|
||
|
|