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;
128 FunctionWrongArgs = 2,
129 FunctionInvalidParams = 3,
130 FunctionNamedArgsError = 4
218 bool isValid() const;
221 bool hasParserError() const;
223 QString parserErrorString() const;
250 QSet<QString> referencedColumns() const;
259 QSet<QString> referencedVariables() const;
266 QSet<QString> referencedFunctions() const;
276 QList<const QgsExpressionNode *> nodes( )
const;
287 QList<const T *> lst;
288 const QList<const QgsExpressionNode *> allNodes( nodes() );
289 for (
const auto &node : allNodes )
291 const T *n =
dynamic_cast<const T *
>( node );
304 QSet<int> referencedAttributeIndexes(
const QgsFields &fields )
const;
307 bool needsGeometry()
const;
327 bool hasEvalError()
const;
329 QString evalErrorString()
const;
331 void setEvalErrorString(
const QString &str );
337 bool isField()
const;
354 void setExpression(
const QString &expression );
361 QString expression()
const;
369 QString dump()
const;
438 static QString replaceExpressionText(
const QString &action,
const QgsExpressionContext *context,
448 static QSet<QString> referencedVariables(
const QString &text );
460 static double evaluateToDouble(
const QString &text,
double fallbackValue );
476 static QList<QgsExpressionFunction *> sFunctions
SIP_SKIP;
477 static const QList<QgsExpressionFunction *> &Functions();
481 static const QStringList &BuiltinFunctions();
497 static bool unregisterFunction(
const QString &name );
503 static QList<QgsExpressionFunction *> sOwnedFunctions
SIP_SKIP;
509 static void cleanRegisteredFunctions();
512 static bool isFunctionName(
const QString &name );
515 static int functionIndex(
const QString &name );
521 static int functionCount();
528 static QString quotedColumnRef( QString name );
535 static QString quotedString( QString text );
545 static QString quotedValue(
const QVariant &value );
556 static QString quotedValue(
const QVariant &value, QVariant::Type type );
566 static QString helpText( QString name );
574 static QString variableHelpText(
const QString &variableName );
585 static QString formatVariableHelp(
const QString &description,
bool showValue =
true,
const QVariant &value = QVariant() );
591 static QString group(
const QString &group );
600 static QString formatPreviewString(
const QVariant &value );
610 static QString createFieldEqualityExpression(
const QString &fieldName,
const QVariant &value );
613 void initGeomCalculator();
615 struct HelpArg SIP_SKIP
617 HelpArg(
const QString &arg,
const QString &desc,
bool descOnly =
false,
bool syntaxOnly =
false,
618 bool optional =
false,
const QString &defaultVal = QString() )
620 , mDescription( desc )
621 , mDescOnly( descOnly )
622 , mSyntaxOnly( syntaxOnly )
623 , mOptional( optional )
624 , mDefaultVal( defaultVal )
628 QString mDescription;
635 struct HelpExample SIP_SKIP
637 HelpExample(
const QString &expression,
const QString &returns,
const QString ¬e = QString() )
638 : mExpression( expression )
639 , mReturns( returns )
648 struct HelpVariant SIP_SKIP
650 HelpVariant(
const QString &name,
const QString &description,
651 const QList<QgsExpression::HelpArg> &arguments = QList<QgsExpression::HelpArg>(),
652 bool variableLenArguments =
false,
653 const QList<QgsExpression::HelpExample> &examples = QList<QgsExpression::HelpExample>(),
654 const QString ¬es = QString() )
656 , mDescription( description )
657 , mArguments( arguments )
658 , mVariableLenArguments( variableLenArguments )
659 , mExamples( examples )
664 QString mDescription;
665 QList<QgsExpression::HelpArg> mArguments;
666 bool mVariableLenArguments;
667 QList<QgsExpression::HelpExample> mExamples;
676 Help(
const QString &name,
const QString &type,
const QString &description,
const QList<QgsExpression::HelpVariant> &variants )
679 , mDescription( description )
680 , mVariants( variants )
685 QString mDescription;
686 QList<QgsExpression::HelpVariant> mVariants;
695 void detach() SIP_SKIP;
697 QgsExpressionPrivate *d =
nullptr;
699 static QHash<QString, Help> sFunctionHelpTexts;
700 static QHash<QString, QString> sVariableHelpTexts;
701 static QHash<QString, QString> sGroups;
704 static
void initFunctionHelp() SIP_SKIP;
706 static
void initVariableHelp() SIP_SKIP;
713 #endif // QGSEXPRESSION_H Class for parsing and evaluation of expressions (formerly called "search strings").
QString errorMsg
The message for the error at this location.
Details about any parser errors that were found when parsing the expression.
Container of fields for a vector layer.
A geometry is the spatial representation of a feature.
The feature class encapsulates a single feature including its id, geometry and a list of field/values...
Q_DECLARE_METATYPE(QModelIndex)
Expression contexts are used to encapsulate the parameters around which a QgsExpression should be eva...
Abstract base class for all nodes that can appear in an expression.
Encapsulate a field in an attribute table or data source.
DistanceUnit
Units of distance.
A general purpose distance and area calculator, capable of performing ellipsoid based calculations...
A abstract base class for defining QgsExpression functions.
This is the base class for vector data providers.
Represents a vector layer which manages a vector based data sets.
QList< const T * > findNodes() const
Returns a list of all nodes of the given class which are used in this expression. ...
The QgsOgcUtils class provides various utility functions for conversion between OGC (Open Geospatial ...