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;
128 FunctionWrongArgs = 2,
129 FunctionInvalidParams = 3,
130 FunctionNamedArgsError = 4
218 bool isValid() const;
221 bool hasParserError() const;
223 QString parserErrorString() const;
254 QSet<QString> referencedColumns() const;
263 QSet<QString> referencedVariables() const;
270 QSet<QString> referencedFunctions() const;
280 QList<const QgsExpressionNode *> nodes( )
const;
291 QList<const T *> lst;
292 const QList<const QgsExpressionNode *> allNodes( nodes() );
293 for (
const auto &node : allNodes )
295 const T *n =
dynamic_cast<const T *
>( node );
308 QSet<int> referencedAttributeIndexes(
const QgsFields &fields )
const;
311 bool needsGeometry()
const;
331 bool hasEvalError()
const;
333 QString evalErrorString()
const;
335 void setEvalErrorString(
const QString &str );
341 bool isField()
const;
358 void setExpression(
const QString &expression );
365 QString expression()
const;
373 QString dump()
const;
450 static QString replaceExpressionText(
const QString &action,
const QgsExpressionContext *context,
460 static QSet<QString> referencedVariables(
const QString &text );
472 static double evaluateToDouble(
const QString &text,
double fallbackValue );
487 static const QList<QgsExpressionFunction *> &Functions();
489 static const QStringList &BuiltinFunctions();
505 static bool unregisterFunction(
const QString &name );
511 static void cleanRegisteredFunctions();
514 static bool isFunctionName(
const QString &name );
517 static int functionIndex(
const QString &name );
523 static int functionCount();
530 static QString quotedColumnRef( QString name );
537 static QString quotedString( QString text );
547 static QString quotedValue(
const QVariant &value );
558 static QString quotedValue(
const QVariant &value, QVariant::Type type );
568 static QString helpText( QString name );
575 static QStringList tags(
const QString &name );
583 static QString variableHelpText(
const QString &variableName );
594 static QString
formatVariableHelp(
const QString &description,
bool showValue =
true,
const QVariant &value = QVariant() );
600 static QString group(
const QString &group );
610 static QString formatPreviewString(
const QVariant &value,
bool htmlOutput =
true );
620 static QString createFieldEqualityExpression(
const QString &fieldName,
const QVariant &value );
623 SIP_PYOBJECT __repr__();
625 QString str = QStringLiteral(
"<QgsExpression: '%1'>" ).arg( sipCpp->expression() );
626 sipRes = PyUnicode_FromString( str.toUtf8().constData() );
641 QgsExpressionPrivate *d =
nullptr;
644 static
void initFunctionHelp()
SIP_SKIP;
646 static
void initVariableHelp()
SIP_SKIP;
653 #endif // QGSEXPRESSION_H