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;
119 FunctionWrongArgs = 2,
120 FunctionInvalidParams = 3,
121 FunctionNamedArgsError = 4
209 bool isValid() const;
212 bool hasParserError() const;
214 QString parserErrorString() const;
245 QSet<QString> referencedColumns() const;
254 QSet<QString> referencedVariables() const;
261 QSet<QString> referencedFunctions() const;
271 QList<const QgsExpressionNode *> nodes( )
const;
282 QList<const T *> lst;
283 const QList<const QgsExpressionNode *> allNodes( nodes() );
284 for (
const auto &node : allNodes )
286 const T *n =
dynamic_cast<const T *
>( node );
299 QSet<int> referencedAttributeIndexes(
const QgsFields &fields )
const;
302 bool needsGeometry()
const;
322 bool hasEvalError()
const;
324 QString evalErrorString()
const;
326 void setEvalErrorString(
const QString &str );
332 bool isField()
const;
349 void setExpression(
const QString &expression );
356 QString expression()
const;
364 QString dump()
const;
441 static QString replaceExpressionText(
const QString &action,
const QgsExpressionContext *context,
451 static QSet<QString> referencedVariables(
const QString &text );
463 static double evaluateToDouble(
const QString &text,
double fallbackValue );
478 static const QList<QgsExpressionFunction *> &Functions();
480 static const QStringList &BuiltinFunctions();
496 static bool unregisterFunction(
const QString &name );
502 static void cleanRegisteredFunctions();
505 static bool isFunctionName(
const QString &name );
508 static int functionIndex(
const QString &name );
514 static int functionCount();
521 static QString quotedColumnRef( QString name );
528 static QString quotedString( QString text );
538 static QString quotedValue(
const QVariant &value );
549 static QString quotedValue(
const QVariant &value, QVariant::Type type );
559 static QString helpText( QString name );
566 static QStringList tags(
const QString &name );
574 static QString variableHelpText(
const QString &variableName );
585 static QString
formatVariableHelp(
const QString &description,
bool showValue =
true,
const QVariant &value = QVariant() );
591 static QString group(
const QString &group );
601 static QString formatPreviewString(
const QVariant &value,
bool htmlOutput =
true );
611 static QString createFieldEqualityExpression(
const QString &fieldName,
const QVariant &value );
614 SIP_PYOBJECT __repr__();
616 QString str = QStringLiteral(
"<QgsExpression: '%1'>" ).arg( sipCpp->expression() );
617 sipRes = PyUnicode_FromString( str.toUtf8().constData() );
632 QgsExpressionPrivate *d =
nullptr;
635 static
void initFunctionHelp()
SIP_SKIP;
637 static
void initVariableHelp()
SIP_SKIP;
644 #endif // QGSEXPRESSION_H