|
|
@ -1,21 +1,5 @@
|
|
|
|
#include "exprevaluator.h"
|
|
|
|
#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(); };
|
|
|
|
|
|
|
|
m_caseSensitive = false;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#else
|
|
|
|
|
|
|
|
const QMap<QString, std::function<bool(QVariant, QVariant)> > ExprEvaluator::m_operations = {
|
|
|
|
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; }},
|
|
|
@ -35,13 +19,6 @@ const QMap<QString, std::function<bool(QVariant, QVariant)> > ExprEvaluator::m_o
|
|
|
|
{ "&&", [](QVariant left, QVariant right) { return left.toBool() && right.toBool(); }}
|
|
|
|
{ "&&", [](QVariant left, QVariant right) { return left.toBool() && right.toBool(); }}
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
ExprEvaluator::ExprEvaluator()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
m_caseSensitive = false;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool ExprEvaluator::evaluate(QObject *object, const QString &exp)
|
|
|
|
bool ExprEvaluator::evaluate(QObject *object, const QString &exp)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (exp.contains("&&") && exp.contains("||"))
|
|
|
|
if (exp.contains("&&") && exp.contains("||"))
|
|
|
|