16#ifndef QGSEXPRESSION_H
17#define QGSEXPRESSION_H
24#include <QDomDocument>
25#include <QCoreApplication>
44class 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;
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.
Q_DECLARE_METATYPE(QgsDatabaseQueryLogEntry)
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.
Details about any parser errors that were found when parsing the expression.
QString errorMsg
The message for the error at this location.