QGIS API Documentation 3.41.0-Master (3c143d501a8)
|
A abstract base class for defining QgsExpression functions. More...
#include <qgsexpressionfunction.h>
Classes | |
class | Parameter |
Represents a single parameter passed to a function. More... | |
Public Types | |
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. | |
typedef QList< QgsExpressionFunction::Parameter > | ParameterList |
List of parameters, used for function definition. | |
Public Member Functions | |
QgsExpressionFunction (const QString &fnname, const QgsExpressionFunction::ParameterList ¶ms, const QString &group, const QString &helpText=QString(), bool lazyEval=false, bool handlesNull=false, bool isContextual=false) | |
Constructor for function which uses named parameter list. | |
QgsExpressionFunction (const QString &fnname, const QgsExpressionFunction::ParameterList ¶ms, 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. | |
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. | |
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. | |
virtual | ~QgsExpressionFunction ()=default |
virtual QStringList | aliases () const |
Returns a list of possible aliases for the function. | |
virtual QVariant | func (const QVariantList &values, const QgsExpressionContext *context, QgsExpression *parent, const QgsExpressionNodeFunction *node)=0 |
Returns result of evaluating the function. | |
QString | group () const |
Returns the first group which the function belongs to. | |
QStringList | groups () const |
Returns a list of the groups the function belongs to. | |
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. | |
const QString | helpText () const |
The help text for the function. | |
bool | isContextual () const |
Returns whether the function is only available if provided by a QgsExpressionContext object. | |
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. | |
virtual bool | isStatic (const QgsExpressionNodeFunction *node, QgsExpression *parent, const QgsExpressionContext *context) const |
Will be called during prepare to determine if the function is static. | |
bool | lazyEval () const |
true if this function should use lazy evaluation. | |
int | minParams () const |
The minimum number of parameters this function takes. | |
QString | name () const |
The name of the function. | |
bool | operator== (const QgsExpressionFunction &other) const |
const QgsExpressionFunction::ParameterList & | parameters () const |
Returns the list of named parameters for the function, if set. | |
int | params () const |
The number of parameters this function takes. | |
virtual bool | prepare (const QgsExpressionNodeFunction *node, QgsExpression *parent, const QgsExpressionContext *context) const |
This will be called during the prepare step() of an expression if it is not static. | |
virtual QSet< QString > | referencedColumns (const QgsExpressionNodeFunction *node) const |
Returns a set of field names which are required for this function. | |
virtual QVariant | run (QgsExpressionNode::NodeList *args, const QgsExpressionContext *context, QgsExpression *parent, const QgsExpressionNodeFunction *node) |
Evaluates the function, first evaluating all required arguments before passing them to the function's func() method. | |
virtual bool | usesGeometry (const QgsExpressionNodeFunction *node) const |
Does this function use a geometry object. | |
Static Protected Member Functions | |
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. | |
A abstract base class for defining QgsExpression functions.
Definition at line 40 of file qgsexpressionfunction.h.
typedef QVariant(* QgsExpressionFunction::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.
Definition at line 47 of file qgsexpressionfunction.h.
typedef QList< QgsExpressionFunction::Parameter > QgsExpressionFunction::ParameterList |
List of parameters, used for function definition.
Definition at line 103 of file qgsexpressionfunction.h.
|
inline |
Constructor for function which uses unnamed parameters.
Definition at line 106 of file qgsexpressionfunction.h.
|
inline |
Constructor for function which uses unnamed parameters and group list.
Definition at line 126 of file qgsexpressionfunction.h.
|
inline |
Constructor for function which uses named parameter list.
Definition at line 146 of file qgsexpressionfunction.h.
|
inline |
Constructor for function which uses named parameter list and group list.
Definition at line 166 of file qgsexpressionfunction.h.
|
virtualdefault |
|
virtual |
Returns a list of possible aliases for the function.
These include other permissible names for the function, e.g., deprecated names.
Reimplemented in QgsStaticExpressionFunction.
Definition at line 129 of file qgsexpressionfunction.cpp.
|
staticprotected |
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.
This can be used as callback for custom implementations of subclasses. It is the default for implementation for StaticFunction::isStatic.
Definition at line 250 of file qgsexpressionfunction.cpp.
|
pure virtual |
Returns result of evaluating the function.
values | list of values passed to the function |
context | context expression is being evaluated against |
parent | parent expression |
node | expression node |
Implemented in QgsStaticExpressionFunction, QgsArrayForeachExpressionFunction, QgsArrayFilterExpressionFunction, QgsWithVariableExpressionFunction, and QgsScopedExpressionFunction.
|
inline |
Returns the first group which the function belongs to.
Definition at line 272 of file qgsexpressionfunction.h.
|
inline |
Returns a list of the groups the function belongs to.
Definition at line 278 of file qgsexpressionfunction.h.
|
virtual |
Returns true
if the function handles NULL values in arguments by itself, and the default NULL value handling should be skipped.
Definition at line 166 of file qgsexpressionfunction.cpp.
const QString QgsExpressionFunction::helpText | ( | ) | const |
The help text for the function.
Definition at line 85 of file qgsexpressionfunction.cpp.
|
inline |
Returns whether the function is only available if provided by a QgsExpressionContext object.
Definition at line 260 of file qgsexpressionfunction.h.
|
virtual |
Returns true
if the function is deprecated and should not be presented as a valid option to users in expression builders.
Definition at line 156 of file qgsexpressionfunction.cpp.
|
virtual |
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.
Reimplemented in QgsStaticExpressionFunction, QgsArrayForeachExpressionFunction, QgsArrayFilterExpressionFunction, QgsWithVariableExpressionFunction, and QgsScopedExpressionFunction.
Definition at line 134 of file qgsexpressionfunction.cpp.
|
inline |
true
if this function should use lazy evaluation.
Lazy evaluation functions take QgsExpression::Node objects rather than the node results when called. You can use node->eval(parent, feature) to evaluate the node and return the result Functions are non lazy default and will be given the node return value when called.
Definition at line 226 of file qgsexpressionfunction.h.
|
inline |
The minimum number of parameters this function takes.
Definition at line 192 of file qgsexpressionfunction.h.
|
inline |
The name of the function.
Definition at line 186 of file qgsexpressionfunction.h.
bool QgsExpressionFunction::operator== | ( | const QgsExpressionFunction & | other | ) | const |
Definition at line 161 of file qgsexpressionfunction.cpp.
|
inline |
Returns the list of named parameters for the function, if set.
Definition at line 209 of file qgsexpressionfunction.h.
|
inline |
The number of parameters this function takes.
Definition at line 189 of file qgsexpressionfunction.h.
|
virtual |
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.
Reimplemented in QgsStaticExpressionFunction, QgsArrayForeachExpressionFunction, QgsArrayFilterExpressionFunction, and QgsWithVariableExpressionFunction.
Definition at line 142 of file qgsexpressionfunction.cpp.
|
virtual |
Returns a set of field names which are required for this function.
May contain QgsFeatureRequest::AllAttributes to signal that all attributes are required. If in doubt this will return more fields than strictly required.
Reimplemented in QgsStaticExpressionFunction, and QgsScopedExpressionFunction.
Definition at line 150 of file qgsexpressionfunction.cpp.
|
virtual |
Evaluates the function, first evaluating all required arguments before passing them to the function's func() method.
Reimplemented in QgsArrayForeachExpressionFunction, QgsArrayFilterExpressionFunction, and QgsWithVariableExpressionFunction.
Definition at line 90 of file qgsexpressionfunction.cpp.
|
virtual |
Does this function use a geometry object.
Reimplemented in QgsStaticExpressionFunction, and QgsScopedExpressionFunction.
Definition at line 123 of file qgsexpressionfunction.cpp.