QGIS API Documentation  3.20.0-Odense (decaadbb31)
Public Member Functions | List of all members
QgsWithVariableExpressionFunction Class Reference

Handles the with_variable(name, value, node) expression function. More...

#include <qgsexpressionfunction.h>

Inheritance diagram for QgsWithVariableExpressionFunction:
Inheritance graph
[legend]

Public Member Functions

 QgsWithVariableExpressionFunction ()
 
QVariant func (const QVariantList &values, const QgsExpressionContext *context, QgsExpression *parent, const QgsExpressionNodeFunction *node) override
 Returns result of evaluating the function. More...
 
bool isStatic (const QgsExpressionNodeFunction *node, QgsExpression *parent, const QgsExpressionContext *context) const override
 Will be called during prepare to determine if the function is static. More...
 
bool prepare (const QgsExpressionNodeFunction *node, QgsExpression *parent, const QgsExpressionContext *context) const override
 This will be called during the prepare step() of an expression if it is not static. More...
 
QVariant run (QgsExpressionNode::NodeList *args, const QgsExpressionContext *context, QgsExpression *parent, const QgsExpressionNodeFunction *node) override
 Evaluates the function, first evaluating all required arguments before passing them to the function's func() method. More...
 
- Public Member Functions inherited from QgsExpressionFunction
 QgsExpressionFunction (const QString &fnname, const QgsExpressionFunction::ParameterList &params, const QString &group, const QString &helpText=QString(), bool lazyEval=false, bool handlesNull=false, bool isContextual=false)
 Constructor for function which uses named parameter list. More...
 
 QgsExpressionFunction (const QString &fnname, const QgsExpressionFunction::ParameterList &params, const QStringList &groups, const QString &helpText=QString(), bool lazyEval=false, bool handlesNull=false, bool isContextual=false)
 Constructor for function which uses named parameter list and group list. More...
 
 QgsExpressionFunction (const QString &fnname, int params, const QString &group, const QString &helpText=QString(), bool lazyEval=false, bool handlesNull=false, bool isContextual=false)
 Constructor for function which uses unnamed parameters. More...
 
 QgsExpressionFunction (const QString &fnname, int params, const QStringList &groups, const QString &helpText=QString(), bool lazyEval=false, bool handlesNull=false, bool isContextual=false)
 Constructor for function which uses unnamed parameters and group list. More...
 
virtual ~QgsExpressionFunction ()=default
 
virtual QStringList aliases () const
 Returns a list of possible aliases for the function. More...
 
QString group () const
 Returns the first group which the function belongs to. More...
 
QStringList groups () const
 Returns a list of the groups the function belongs to. More...
 
virtual bool handlesNull () const
 Returns true if the function handles NULL values in arguments by itself, and the default NULL value handling should be skipped. More...
 
const QString helpText () const
 The help text for the function. More...
 
bool isContextual () const
 Returns whether the function is only available if provided by a QgsExpressionContext object. More...
 
virtual bool isDeprecated () const
 Returns true if the function is deprecated and should not be presented as a valid option to users in expression builders. More...
 
bool lazyEval () const
 true if this function should use lazy evaluation. More...
 
int minParams () const
 The minimum number of parameters this function takes. More...
 
QString name () const
 The name of the function. More...
 
bool operator== (const QgsExpressionFunction &other) const
 
const QgsExpressionFunction::ParameterListparameters () const
 Returns the list of named parameters for the function, if set. More...
 
int params () const
 The number of parameters this function takes. More...
 
virtual QSet< QString > referencedColumns (const QgsExpressionNodeFunction *node) const
 Returns a set of field names which are required for this function. More...
 
virtual bool usesGeometry (const QgsExpressionNodeFunction *node) const
 Does this function use a geometry object. More...
 

Additional Inherited Members

- Public Types inherited from QgsExpressionFunction
typedef QVariant(* FcnEval) (const QVariantList &values, const QgsExpressionContext *context, QgsExpression *parent, const QgsExpressionNodeFunction *node)
 Function definition for evaluation against an expression context, using a list of values as parameters to the function. More...
 
typedef QList< QgsExpressionFunction::ParameterParameterList
 List of parameters, used for function definition. More...
 
- Static Protected Member Functions inherited from QgsExpressionFunction
static bool allParamsStatic (const QgsExpressionNodeFunction *node, QgsExpression *parent, const QgsExpressionContext *context)
 This will return true if all the params for the provided function node are static within the constraints imposed by the context within the given parent. More...
 

Detailed Description

Handles the with_variable(name, value, node) expression function.

It temporarily appends a new scope to the expression context for all nested nodes.

Note
Not available in Python bindings
Since
QGIS 3.0

Definition at line 579 of file qgsexpressionfunction.h.

Constructor & Destructor Documentation

◆ QgsWithVariableExpressionFunction()

QgsWithVariableExpressionFunction::QgsWithVariableExpressionFunction ( )

Definition at line 7582 of file qgsexpressionfunction.cpp.

Member Function Documentation

◆ func()

QVariant QgsWithVariableExpressionFunction::func ( const QVariantList &  values,
const QgsExpressionContext context,
QgsExpression parent,
const QgsExpressionNodeFunction node 
)
overridevirtual

Returns result of evaluating the function.

Parameters
valueslist of values passed to the function
contextcontext expression is being evaluated against
parentparent expression
nodeexpression node
Returns
result of function

Implements QgsExpressionFunction.

Definition at line 7646 of file qgsexpressionfunction.cpp.

◆ isStatic()

bool QgsWithVariableExpressionFunction::isStatic ( const QgsExpressionNodeFunction node,
QgsExpression parent,
const QgsExpressionContext context 
) const
overridevirtual

Will be called during prepare to determine if the function is static.

A function is static if it will return the same value for every feature with different attributes and/or geometry.

By default this will return true, if all arguments that have been passed to the function are also static.

Since
QGIS 3.0

Reimplemented from QgsExpressionFunction.

Definition at line 7592 of file qgsexpressionfunction.cpp.

◆ prepare()

bool QgsWithVariableExpressionFunction::prepare ( const QgsExpressionNodeFunction node,
QgsExpression parent,
const QgsExpressionContext context 
) const
overridevirtual

This will be called during the prepare step() of an expression if it is not static.

This can be used by functions to do any preparation steps that might help to speedup the upcoming evaluation.

Since
QGIS 3.0

Reimplemented from QgsExpressionFunction.

Definition at line 7658 of file qgsexpressionfunction.cpp.

◆ run()

QVariant QgsWithVariableExpressionFunction::run ( QgsExpressionNode::NodeList args,
const QgsExpressionContext context,
QgsExpression parent,
const QgsExpressionNodeFunction node 
)
overridevirtual

Evaluates the function, first evaluating all required arguments before passing them to the function's func() method.

Reimplemented from QgsExpressionFunction.

Definition at line 7617 of file qgsexpressionfunction.cpp.


The documentation for this class was generated from the following files: