QGIS API Documentation 3.41.0-Master (3440c17df1d)
Loading...
Searching...
No Matches
Public Member Functions | List of all members
QgsScopedExpressionFunction Class Referenceabstract

Expression function for use within a QgsExpressionContextScope. More...

#include <qgsexpressioncontext.h>

Inheritance diagram for QgsScopedExpressionFunction:
Inheritance graph
[legend]

Public Member Functions

 QgsScopedExpressionFunction (const QString &fnname, const QgsExpressionFunction::ParameterList &params, const QString &group, const QString &helpText=QString(), bool usesGeometry=false, const QSet< QString > &referencedColumns=QSet< QString >(), bool lazyEval=false, bool handlesNull=false, bool isContextual=true)
 Create a new QgsScopedExpressionFunction using named parameters.
 
 QgsScopedExpressionFunction (const QString &fnname, int params, const QString &group, const QString &helpText=QString(), bool usesGeometry=false, const QSet< QString > &referencedColumns=QSet< QString >(), bool lazyEval=false, bool handlesNull=false, bool isContextual=true)
 Create a new QgsScopedExpressionFunction.
 
virtual QgsScopedExpressionFunctionclone () const =0
 Returns a clone of the function.
 
QVariant func (const QVariantList &values, const QgsExpressionContext *context, QgsExpression *parent, const QgsExpressionNodeFunction *node) override=0
 Returns result of evaluating the function.
 
bool isStatic (const QgsExpressionNodeFunction *node, QgsExpression *parent, const QgsExpressionContext *context) const override
 Will be called during prepare to determine if the function is static.
 
QSet< QString > referencedColumns (const QgsExpressionNodeFunction *node) const override
 Returns a set of field names which are required for this function.
 
bool usesGeometry (const QgsExpressionNodeFunction *node) const override
 Does this function use a geometry object.
 
- 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.
 
 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.
 
 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.
 
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.
 
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::ParameterListparameters () 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 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.
 

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.
 
typedef QList< QgsExpressionFunction::ParameterParameterList
 List of parameters, used for function definition.
 
- 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.
 

Detailed Description

Expression function for use within a QgsExpressionContextScope.

This differs from a standard QgsExpression::Function in that it requires an implemented clone() method.

Definition at line 42 of file qgsexpressioncontext.h.

Constructor & Destructor Documentation

◆ QgsScopedExpressionFunction() [1/2]

QgsScopedExpressionFunction::QgsScopedExpressionFunction ( const QString &  fnname,
int  params,
const QString &  group,
const QString &  helpText = QString(),
bool  usesGeometry = false,
const QSet< QString > &  referencedColumns = QSet<QString>(),
bool  lazyEval = false,
bool  handlesNull = false,
bool  isContextual = true 
)
inline

Create a new QgsScopedExpressionFunction.

Definition at line 50 of file qgsexpressioncontext.h.

◆ QgsScopedExpressionFunction() [2/2]

QgsScopedExpressionFunction::QgsScopedExpressionFunction ( const QString &  fnname,
const QgsExpressionFunction::ParameterList params,
const QString &  group,
const QString &  helpText = QString(),
bool  usesGeometry = false,
const QSet< QString > &  referencedColumns = QSet<QString>(),
bool  lazyEval = false,
bool  handlesNull = false,
bool  isContextual = true 
)
inline

Create a new QgsScopedExpressionFunction using named parameters.

Definition at line 68 of file qgsexpressioncontext.h.

Member Function Documentation

◆ clone()

virtual QgsScopedExpressionFunction * QgsScopedExpressionFunction::clone ( ) const
pure virtual

Returns a clone of the function.

◆ func()

QVariant QgsScopedExpressionFunction::func ( const QVariantList &  values,
const QgsExpressionContext context,
QgsExpression parent,
const QgsExpressionNodeFunction node 
)
overridepure virtual

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.

◆ isStatic()

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

Reimplemented from QgsExpressionFunction.

Definition at line 980 of file qgsexpressioncontextutils.cpp.

◆ referencedColumns()

QSet< QString > QgsScopedExpressionFunction::referencedColumns ( const QgsExpressionNodeFunction node) const
overridevirtual

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 from QgsExpressionFunction.

Definition at line 974 of file qgsexpressioncontextutils.cpp.

◆ usesGeometry()

bool QgsScopedExpressionFunction::usesGeometry ( const QgsExpressionNodeFunction node) const
overridevirtual

Does this function use a geometry object.

Reimplemented from QgsExpressionFunction.

Definition at line 968 of file qgsexpressioncontextutils.cpp.


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