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 );
387 void setExpression(
const QString &expression );
394 QString expression()
const;
402 QString dump()
const;
479 static QString replaceExpressionText(
const QString &action,
const QgsExpressionContext *context,
489 static QSet<QString> referencedVariables(
const QString &text );
501 static double evaluateToDouble(
const QString &text,
double fallbackValue );
516 static const QList<QgsExpressionFunction *> &Functions();
518 static const QStringList &BuiltinFunctions();
534 static bool unregisterFunction(
const QString &name );
540 static void cleanRegisteredFunctions();
543 static bool isFunctionName(
const QString &name );
546 static int functionIndex(
const QString &name );
552 static int functionCount();
559 static QString quotedColumnRef( QString name );
566 static QString quotedString( QString text );
576 static QString quotedValue(
const QVariant &value );
587 static QString quotedValue(
const QVariant &value, QVariant::Type type );
597 static QString helpText( QString name );
604 static QStringList tags(
const QString &name );
618 static bool addVariableHelpText(
const QString name,
const QString &description );
627 static QString variableHelpText(
const QString &variableName );
638 static QString
formatVariableHelp(
const QString &description,
bool showValue =
true,
const QVariant &value = QVariant() );
644 static QString group(
const QString &group );
655 static QString formatPreviewString(
const QVariant &value,
bool htmlOutput =
true,
int maximumPreviewLength = 60 );
665 static QString createFieldEqualityExpression(
const QString &fieldName,
const QVariant &value );
677 static bool isFieldEqualityExpression(
const QString &expression, QString &
field SIP_OUT, QVariant &value
SIP_OUT );
693 static bool attemptReduceToInClause(
const QStringList &expressions, QString &result
SIP_OUT );
696 SIP_PYOBJECT __repr__();
698 QString
str = QStringLiteral(
"<QgsExpression: '%1'>" ).arg( sipCpp->expression() );
699 sipRes = PyUnicode_FromString(
str.toUtf8().constData() );
714 QgsExpressionPrivate *d =
nullptr;
717 static
void initFunctionHelp()
SIP_SKIP;
719 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.