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 );
354 bool isField()
const;
371 void setExpression(
const QString &expression );
378 QString expression()
const;
386 QString dump()
const;
463 static QString replaceExpressionText(
const QString &action,
const QgsExpressionContext *context,
473 static QSet<QString> referencedVariables(
const QString &text );
485 static double evaluateToDouble(
const QString &text,
double fallbackValue );
500 static const QList<QgsExpressionFunction *> &Functions();
502 static const QStringList &BuiltinFunctions();
518 static bool unregisterFunction(
const QString &name );
524 static void cleanRegisteredFunctions();
527 static bool isFunctionName(
const QString &name );
530 static int functionIndex(
const QString &name );
536 static int functionCount();
543 static QString quotedColumnRef( QString name );
550 static QString quotedString( QString text );
560 static QString quotedValue(
const QVariant &value );
571 static QString quotedValue(
const QVariant &value, QVariant::Type type );
581 static QString helpText( QString name );
588 static QStringList tags(
const QString &name );
596 static QString variableHelpText(
const QString &variableName );
607 static QString
formatVariableHelp(
const QString &description,
bool showValue =
true,
const QVariant &value = QVariant() );
613 static QString group(
const QString &group );
624 static QString formatPreviewString(
const QVariant &value,
bool htmlOutput =
true,
int maximumPreviewLength = 60 );
634 static QString createFieldEqualityExpression(
const QString &fieldName,
const QVariant &value );
646 static bool isFieldEqualityExpression(
const QString &expression, QString &
field SIP_OUT, QVariant &value
SIP_OUT );
662 static bool attemptReduceToInClause(
const QStringList &expressions, QString &result
SIP_OUT );
665 SIP_PYOBJECT __repr__();
667 QString
str = QStringLiteral(
"<QgsExpression: '%1'>" ).arg( sipCpp->expression() );
668 sipRes = PyUnicode_FromString(
str.toUtf8().constData() );
683 QgsExpressionPrivate *d =
nullptr;
686 static
void initFunctionHelp()
SIP_SKIP;
688 static
void initVariableHelp()
SIP_SKIP;
A general purpose distance and area calculator, capable of performing ellipsoid based calculations.
Expression contexts are used to encapsulate the parameters around which a QgsExpression should be eva...
A abstract base class for defining QgsExpression functions.
Abstract base class for all nodes that can appear in an expression.
Class for parsing and evaluation of expressions (formerly called "search strings").
QList< const T * > findNodes() const
Returns a list of all nodes of the given class which are used in this expression.
The feature class encapsulates a single feature including its unique ID, geometry and a list of field...
Encapsulate a field in an attribute table or data source.
Container of fields for a vector layer.
A geometry is the spatial representation of a feature.
The QgsOgcUtils class provides various utility functions for conversion between OGC (Open Geospatial ...
DistanceUnit
Units of distance.
This is the base class for vector data providers.
Represents a vector layer which manages a vector based data sets.
QString formatVariableHelp(const QString &variable, const QString &description, bool showValue, const QVariant &value)
Returns a HTML formatted string for use as a variable item help.
Q_DECLARE_METATYPE(QgsMeshTimeSettings)
Details about any parser errors that were found when parsing the expression.
QString errorMsg
The message for the error at this location.