16 #ifndef QGSEXPRESSION_H
17 #define QGSEXPRESSION_H
19 #include "qgis_core.h"
21 #include <QStringList>
24 #include <QDomDocument>
25 #include <QCoreApplication>
44 class QgsExpressionPrivate;
117 FunctionWrongArgs = 2,
118 FunctionInvalidParams = 3,
119 FunctionNamedArgsError = 4
207 bool isValid() const;
210 bool hasParserError() const;
212 QString parserErrorString() const;
251 QSet<QString> referencedColumns() const;
264 QSet<QString> referencedVariables() const;
275 QSet<QString> referencedFunctions() const;
285 QList<const QgsExpressionNode *> nodes( )
const;
296 QList<const T *> lst;
297 const QList<const QgsExpressionNode *> allNodes( nodes() );
298 for (
const auto &node : allNodes )
300 const T *n =
dynamic_cast<const T *
>( node );
321 QSet<int> referencedAttributeIndexes(
const QgsFields &fields )
const;
324 bool needsGeometry()
const;
344 bool hasEvalError()
const;
346 QString evalErrorString()
const;
348 void setEvalErrorString(
const QString &
str );
356 bool isField()
const;
370 static int expressionToLayerFieldIndex(
const QString &expression,
const QgsVectorLayer *layer );
384 static QString quoteFieldExpression(
const QString &expression,
const QgsVectorLayer *layer );
401 void setExpression(
const QString &expression );
408 QString expression()
const;
416 QString dump()
const;
493 static QString replaceExpressionText(
const QString &action,
const QgsExpressionContext *context,
503 static QSet<QString> referencedVariables(
const QString &text );
515 static double evaluateToDouble(
const QString &text,
double fallbackValue );
530 static const QList<QgsExpressionFunction *> &Functions();
532 static const QStringList &BuiltinFunctions();
548 static bool unregisterFunction(
const QString &name );
554 static void cleanRegisteredFunctions();
557 static bool isFunctionName(
const QString &name );
560 static int functionIndex(
const QString &name );
566 static int functionCount();
573 static QString quotedColumnRef( QString name );
580 static QString quotedString( QString text );
590 static QString quotedValue(
const QVariant &value );
601 static QString quotedValue(
const QVariant &value, QVariant::Type type );
611 static QString helpText( QString name );
618 static QStringList tags(
const QString &name );
632 static bool addVariableHelpText(
const QString name,
const QString &description );
641 static QString variableHelpText(
const QString &variableName );
652 static QString
formatVariableHelp(
const QString &description,
bool showValue =
true,
const QVariant &value = QVariant() );
658 static QString group(
const QString &group );
669 static QString formatPreviewString(
const QVariant &value,
bool htmlOutput =
true,
int maximumPreviewLength = 60 );
680 static QString createFieldEqualityExpression(
const QString &fieldName,
const QVariant &value, QVariant::Type fieldType = QVariant::Type::Invalid );
692 static bool isFieldEqualityExpression(
const QString &expression, QString &
field SIP_OUT, QVariant &value
SIP_OUT );
708 static bool attemptReduceToInClause(
const QStringList &expressions, QString &result
SIP_OUT );
711 SIP_PYOBJECT __repr__();
713 QString
str = QStringLiteral(
"<QgsExpression: '%1'>" ).arg( sipCpp->expression() );
714 sipRes = PyUnicode_FromString(
str.toUtf8().constData() );
729 QgsExpressionPrivate *d =
nullptr;
732 static
void initFunctionHelp()
SIP_SKIP;
734 static
void initVariableHelp()
SIP_SKIP;
741 #endif // QGSEXPRESSION_H