QGIS API Documentation  2.99.0-Master (c558d51)
Public Member Functions | List of all members
QgsExpression::StaticFunction Class Reference

c++ helper class for defining QgsExpression functions. More...

#include <qgsexpression.h>

Inheritance diagram for QgsExpression::StaticFunction:
Inheritance graph
[legend]

Public Member Functions

 StaticFunction (const QString &fnname, int params, FcnEval fcn, const QString &group, const QString &helpText=QString(), bool usesGeometry=false, const QSet< QString > &referencedColumns=QSet< QString >(), bool lazyEval=false, const QStringList &aliases=QStringList(), bool handlesNull=false)
 Static function for evaluation against a QgsExpressionContext, using an unnamed list of parameter values. More...
 
 StaticFunction (const QString &fnname, const ParameterList &params, FcnEval fcn, const QString &group, const QString &helpText=QString(), bool usesGeometry=false, const QSet< QString > &referencedColumns=QSet< QString >(), bool lazyEval=false, const QStringList &aliases=QStringList(), bool handlesNull=false)
 Static function for evaluation against a QgsExpressionContext, using a named list of parameter values. More...
 
 StaticFunction (const QString &fnname, const ParameterList &params, FcnEval fcn, const QString &group, const QString &helpText, std::function< bool(const NodeFunction *node) > usesGeometry, std::function< QSet< QString >(const NodeFunction *node) > referencedColumns, bool lazyEval=false, const QStringList &aliases=QStringList(), bool handlesNull=false)
 Static function for evaluation against a QgsExpressionContext, using a named list of parameter values. More...
 
 StaticFunction (const QString &fnname, const ParameterList &params, FcnEval fcn, const QStringList &groups, const QString &helpText=QString(), bool usesGeometry=false, const QSet< QString > &referencedColumns=QSet< QString >(), bool lazyEval=false, const QStringList &aliases=QStringList(), bool handlesNull=false)
 Static function for evaluation against a QgsExpressionContext, using a named list of parameter values and list of groups. More...
 
virtual ~StaticFunction ()
 
virtual QStringList aliases () const override
 Returns a list of possible aliases for the function. More...
 
virtual QVariant func (const QVariantList &values, const QgsExpressionContext *context, QgsExpression *parent) override
 Returns result of evaluating the function. More...
 
virtual QSet< QString > referencedColumns (const QgsExpression::NodeFunction *node) const override
 Returns a set of field names which are required for this function. More...
 
virtual bool usesGeometry (const QgsExpression::NodeFunction *node) const override
 Does this function use a geometry object. More...
 
- Public Member Functions inherited from QgsExpression::Function
 Function (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...
 
 Function (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...
 
 Function (const QString &fnname, const 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...
 
 Function (const QString &fnname, const 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...
 
virtual ~Function ()
 
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
 
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 mininum number of parameters this function takes. More...
 
QString name () const
 The name of the function. More...
 
bool operator== (const Function &other) const
 
const 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...
 

Detailed Description

c++ helper class for defining QgsExpression functions.

Note
not available in Python bindings

Definition at line 642 of file qgsexpression.h.

Constructor & Destructor Documentation

QgsExpression::StaticFunction::StaticFunction ( const QString &  fnname,
int  params,
FcnEval  fcn,
const QString &  group,
const QString &  helpText = QString(),
bool  usesGeometry = false,
const QSet< QString > &  referencedColumns = QSet<QString>(),
bool  lazyEval = false,
const QStringList &  aliases = QStringList(),
bool  handlesNull = false 
)
inline

Static function for evaluation against a QgsExpressionContext, using an unnamed list of parameter values.

Definition at line 648 of file qgsexpression.h.

QgsExpression::StaticFunction::StaticFunction ( const QString &  fnname,
const ParameterList params,
FcnEval  fcn,
const QString &  group,
const QString &  helpText = QString(),
bool  usesGeometry = false,
const QSet< QString > &  referencedColumns = QSet<QString>(),
bool  lazyEval = false,
const QStringList &  aliases = QStringList(),
bool  handlesNull = false 
)
inline

Static function for evaluation against a QgsExpressionContext, using a named list of parameter values.

Definition at line 667 of file qgsexpression.h.

QgsExpression::StaticFunction::StaticFunction ( const QString &  fnname,
const ParameterList params,
QgsExpression::FcnEval  fcn,
const QString &  group,
const QString &  helpText,
std::function< bool(const NodeFunction *node) >  usesGeometry,
std::function< QSet< QString >(const NodeFunction *node) >  referencedColumns,
bool  lazyEval = false,
const QStringList &  aliases = QStringList(),
bool  handlesNull = false 
)

Static function for evaluation against a QgsExpressionContext, using a named list of parameter values.

Lambda functions can be provided that will be called to determine if a geometry is used an which columns are referenced. This is only required if this cannot be determined by calling each parameter node's usesGeometry() or referencedColumns() method. For example, an aggregate expression requires the geometry and all columns if the parent variable is used. If a nullptr is passed as a node to these functions, they should stay on the safe side and return if they could potentially require a geometry or columns.

Definition at line 6027 of file qgsexpression.cpp.

QgsExpression::StaticFunction::StaticFunction ( const QString &  fnname,
const ParameterList params,
FcnEval  fcn,
const QStringList &  groups,
const QString &  helpText = QString(),
bool  usesGeometry = false,
const QSet< QString > &  referencedColumns = QSet<QString>(),
bool  lazyEval = false,
const QStringList &  aliases = QStringList(),
bool  handlesNull = false 
)
inline

Static function for evaluation against a QgsExpressionContext, using a named list of parameter values and list of groups.

Definition at line 709 of file qgsexpression.h.

virtual QgsExpression::StaticFunction::~StaticFunction ( )
inlinevirtual

Definition at line 726 of file qgsexpression.h.

Member Function Documentation

virtual QStringList QgsExpression::StaticFunction::aliases ( ) const
inlineoverridevirtual

Returns a list of possible aliases for the function.

These include other permissible names for the function, eg deprecated names.

Returns
list of known aliases
Note
added in QGIS 2.9

Reimplemented from QgsExpression::Function.

Definition at line 739 of file qgsexpression.h.

virtual QVariant QgsExpression::StaticFunction::func ( const QVariantList &  values,
const QgsExpressionContext context,
QgsExpression parent 
)
inlineoverridevirtual

Returns result of evaluating the function.

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

Implements QgsExpression::Function.

Definition at line 734 of file qgsexpression.h.

QSet< QString > QgsExpression::StaticFunction::referencedColumns ( const QgsExpression::NodeFunction 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.

Note
Added in QGIS 3.0

Reimplemented from QgsExpression::Function.

Definition at line 6045 of file qgsexpression.cpp.

bool QgsExpression::StaticFunction::usesGeometry ( const QgsExpression::NodeFunction node) const
overridevirtual

Does this function use a geometry object.

Reimplemented from QgsExpression::Function.

Definition at line 6037 of file qgsexpression.cpp.


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