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;
119 FunctionWrongArgs = 2,
120 FunctionInvalidParams = 3,
121 FunctionNamedArgsError = 4
209 bool isValid() const;
212 bool hasParserError() const;
214 QString parserErrorString() const;
253 QSet<QString> referencedColumns() const;
266 QSet<QString> referencedVariables() const;
277 QSet<QString> referencedFunctions() const;
287 QList<const QgsExpressionNode *> nodes( )
const;
298 QList<const T *> lst;
299 const QList<const QgsExpressionNode *> allNodes( nodes() );
300 for (
const auto &node : allNodes )
302 const T *n =
dynamic_cast<const T *
>( node );
323 QSet<int> referencedAttributeIndexes(
const QgsFields &fields )
const;
326 bool needsGeometry()
const;
346 bool hasEvalError()
const;
348 QString evalErrorString()
const;
350 void setEvalErrorString(
const QString &str );
356 bool isField()
const;
373 void setExpression(
const QString &expression );
380 QString expression()
const;
388 QString dump()
const;
465 static QString replaceExpressionText(
const QString &action,
const QgsExpressionContext *context,
475 static QSet<QString> referencedVariables(
const QString &text );
487 static double evaluateToDouble(
const QString &text,
double fallbackValue );
502 static const QList<QgsExpressionFunction *> &Functions();
504 static const QStringList &BuiltinFunctions();
520 static bool unregisterFunction(
const QString &name );
526 static void cleanRegisteredFunctions();
529 static bool isFunctionName(
const QString &name );
532 static int functionIndex(
const QString &name );
538 static int functionCount();
545 static QString quotedColumnRef( QString name );
552 static QString quotedString( QString text );
562 static QString quotedValue(
const QVariant &value );
573 static QString quotedValue(
const QVariant &value, QVariant::Type type );
583 static QString helpText( QString name );
590 static QStringList tags(
const QString &name );
598 static QString variableHelpText(
const QString &variableName );
609 static QString
formatVariableHelp(
const QString &description,
bool showValue =
true,
const QVariant &value = QVariant() );
615 static QString group(
const QString &group );
626 static QString formatPreviewString(
const QVariant &value,
bool htmlOutput =
true,
int maximumPreviewLength = 60 );
636 static QString createFieldEqualityExpression(
const QString &fieldName,
const QVariant &value );
648 static bool isFieldEqualityExpression(
const QString &expression, QString &
field SIP_OUT, QVariant &value
SIP_OUT );
664 static bool attemptReduceToInClause(
const QStringList &expressions, QString &result
SIP_OUT );
667 SIP_PYOBJECT __repr__();
669 QString str = QStringLiteral(
"<QgsExpression: '%1'>" ).arg( sipCpp->expression() );
670 sipRes = PyUnicode_FromString( str.toUtf8().constData() );
685 QgsExpressionPrivate *d =
nullptr;
688 static
void initFunctionHelp()
SIP_SKIP;
690 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 id, geometry and a list of field/values...
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.