16#ifndef QGSEXPRESSION_H
17#define QGSEXPRESSION_H
24#include <QDomDocument>
25#include <QCoreApplication>
43class QgsExpressionPrivate;
116 FunctionWrongArgs = 2,
117 FunctionInvalidParams = 3,
118 FunctionNamedArgsError = 4
206 bool isValid() const;
209 bool hasParserError() const;
211 QString parserErrorString() const;
250 QSet<QString> referencedColumns() const;
263 QSet<QString> referencedVariables() const;
274 QSet<QString> referencedFunctions() const;
284 QList<const QgsExpressionNode *> nodes( )
const;
295 QList<const T *> lst;
296 const QList<const QgsExpressionNode *> allNodes( nodes() );
297 for (
const auto &node : allNodes )
299 const T *n =
dynamic_cast<const T *
>( node );
320 QSet<int> referencedAttributeIndexes(
const QgsFields &fields )
const;
323 bool needsGeometry()
const;
343 bool hasEvalError()
const;
345 QString evalErrorString()
const;
347 void setEvalErrorString(
const QString &
str );
355 bool isField()
const;
369 static int expressionToLayerFieldIndex(
const QString &expression,
const QgsVectorLayer *layer );
383 static QString quoteFieldExpression(
const QString &expression,
const QgsVectorLayer *layer );
400 void setExpression(
const QString &expression );
407 QString expression()
const;
415 QString dump()
const;
492 static QString replaceExpressionText(
const QString &action,
const QgsExpressionContext *context,
502 static QSet<QString> referencedVariables(
const QString &text );
514 static double evaluateToDouble(
const QString &text,
double fallbackValue );
529 static const QList<QgsExpressionFunction *> &Functions();
531 static const QStringList &BuiltinFunctions();
547 static bool unregisterFunction(
const QString &name );
553 static void cleanRegisteredFunctions();
556 static bool isFunctionName(
const QString &name );
559 static int functionIndex(
const QString &name );
565 static int functionCount();
572 static QString quotedColumnRef( QString name );
579 static QString quotedString( QString text );
589 static QString quotedValue(
const QVariant &value );
600 static QString quotedValue(
const QVariant &value, QVariant::Type type );
610 static QString helpText( QString name );
617 static QStringList tags(
const QString &name );
631 static bool addVariableHelpText(
const QString name,
const QString &description );
640 static QString variableHelpText(
const QString &variableName );
651 static QString
formatVariableHelp(
const QString &description,
bool showValue =
true,
const QVariant &value = QVariant() );
657 static QString group(
const QString &group );
668 static QString formatPreviewString(
const QVariant &value,
bool htmlOutput =
true,
int maximumPreviewLength = 60 );
679 static QString createFieldEqualityExpression(
const QString &fieldName,
const QVariant &value, QVariant::Type fieldType = QVariant::Type::Invalid );
691 static bool isFieldEqualityExpression(
const QString &expression, QString &
field SIP_OUT, QVariant &value
SIP_OUT );
707 static bool attemptReduceToInClause(
const QStringList &expressions, QString &result
SIP_OUT );
710 SIP_PYOBJECT __repr__();
712 QString
str = QStringLiteral(
"<QgsExpression: '%1'>" ).arg( sipCpp->expression() );
713 sipRes = PyUnicode_FromString(
str.toUtf8().constData() );
728 QgsExpressionPrivate *d =
nullptr;
731 static
void initFunctionHelp()
SIP_SKIP;
733 static
void initVariableHelp()
SIP_SKIP;
DistanceUnit
Units of distance.
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 ...
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.