QgsWithVariableExpressionFunction class

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

Contents

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

Base classes

class QgsExpressionFunction
A abstract base class for defining QgsExpression functions.

Public functions

auto func(const QVariantList& values, const QgsExpressionContext* context, QgsExpression* parent, const QgsExpressionNodeFunction* node) -> QVariant override
Returns result of evaluating the function.
auto isStatic(const QgsExpressionNodeFunction* node, QgsExpression* parent, const QgsExpressionContext* context) const -> bool override
Will be called during prepare to determine if the function is static.
auto prepare(const QgsExpressionNodeFunction* node, QgsExpression* parent, const QgsExpressionContext* context) const -> bool override
This will be called during the prepare step() of an expression if it is not static.
auto run(QgsExpressionNode::NodeList* args, const QgsExpressionContext* context, QgsExpression* parent, const QgsExpressionNodeFunction* node) -> QVariant override
Evaluates the function, first evaluating all required arguments before passing them to the function's func() method.

Function documentation

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

Returns result of evaluating the function.

Parameters
values list of values passed to the function
context context expression is being evaluated against
parent parent expression
node expression node
Returns result of function

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

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.

bool QgsWithVariableExpressionFunction::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.

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