QGIS API Documentation  2.99.0-Master (314842d)
Public Member Functions | List of all members
QgsExpression::Function Class Referenceabstract

A abstract base class for defining QgsExpression functions. More...

#include <qgsexpression.h>

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

Public Member Functions

 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 ()=default
 
virtual QStringList aliases () const
 Returns a list of possible aliases for the function. More...
 
virtual QVariant func (const QVariantList &values, const QgsExpressionContext *context, QgsExpression *parent)=0
 Returns result of evaluating 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
 
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 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...
 
virtual QSet< QString > referencedColumns (const NodeFunction *node) const
 Returns a set of field names which are required for this function. More...
 
virtual bool usesGeometry (const NodeFunction *node) const
 Does this function use a geometry object. More...
 

Detailed Description

A abstract base class for defining QgsExpression functions.

Definition at line 456 of file qgsexpression.h.

Constructor & Destructor Documentation

◆ Function() [1/4]

QgsExpression::Function::Function ( const QString &  fnname,
int  params,
const QString &  group,
const QString &  helpText = QString(),
bool  lazyEval = false,
bool  handlesNull = false,
bool  isContextual = false 
)
inline

Constructor for function which uses unnamed parameters.

Definition at line 461 of file qgsexpression.h.

◆ Function() [2/4]

QgsExpression::Function::Function ( const QString &  fnname,
int  params,
const QStringList &  groups,
const QString &  helpText = QString(),
bool  lazyEval = false,
bool  handlesNull = false,
bool  isContextual = false 
)
inline

Constructor for function which uses unnamed parameters and group list.

Note
added in QGIS 3.0

Definition at line 481 of file qgsexpression.h.

◆ Function() [3/4]

QgsExpression::Function::Function ( const QString &  fnname,
const ParameterList params,
const QString &  group,
const QString &  helpText = QString(),
bool  lazyEval = false,
bool  handlesNull = false,
bool  isContextual = false 
)
inline

Constructor for function which uses named parameter list.

Note
added in QGIS 2.16

Definition at line 501 of file qgsexpression.h.

◆ Function() [4/4]

QgsExpression::Function::Function ( const QString &  fnname,
const ParameterList params,
const QStringList &  groups,
const QString &  helpText = QString(),
bool  lazyEval = false,
bool  handlesNull = false,
bool  isContextual = false 
)
inline

Constructor for function which uses named parameter list and group list.

Note
added in QGIS 3.0

Definition at line 521 of file qgsexpression.h.

◆ ~Function()

virtual QgsExpression::Function::~Function ( )
virtualdefault

Member Function Documentation

◆ aliases()

virtual QStringList QgsExpression::Function::aliases ( ) const
inlinevirtual

Returns a list of possible aliases for the function.

These include other permissible names for the function, e.g., deprecated names.

Returns
list of known aliases
Note
added in QGIS 2.9

Reimplemented in QgsExpression::StaticFunction.

Definition at line 574 of file qgsexpression.h.

◆ func()

virtual QVariant QgsExpression::Function::func ( const QVariantList &  values,
const QgsExpressionContext context,
QgsExpression parent 
)
pure virtual

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

Implemented in QgsExpression::StaticFunction, and QgsScopedExpressionFunction.

◆ group()

QString QgsExpression::Function::group ( ) const
inline

Returns the first group which the function belongs to.

Note
consider using groups() instead, as some functions naturally belong in multiple groups

Definition at line 605 of file qgsexpression.h.

◆ groups()

QStringList QgsExpression::Function::groups ( ) const
inline

Returns a list of the groups the function belongs to.

Note
added in QGIS 3.0
See also
group()

Definition at line 611 of file qgsexpression.h.

◆ handlesNull()

virtual bool QgsExpression::Function::handlesNull ( ) const
inlinevirtual

Definition at line 626 of file qgsexpression.h.

◆ helpText()

const QString QgsExpression::Function::helpText ( ) const
inline

The help text for the function.

Definition at line 614 of file qgsexpression.h.

◆ isContextual()

bool QgsExpression::Function::isContextual ( ) const
inline

Returns whether the function is only available if provided by a QgsExpressionContext object.

Note
added in QGIS 2.12

Definition at line 594 of file qgsexpression.h.

◆ isDeprecated()

virtual bool QgsExpression::Function::isDeprecated ( ) const
inlinevirtual

Returns true if the function is deprecated and should not be presented as a valid option to users in expression builders.

Note
added in QGIS 3.0

Definition at line 600 of file qgsexpression.h.

◆ lazyEval()

bool QgsExpression::Function::lazyEval ( ) const
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 579 of file qgsexpression.h.

◆ minParams()

int QgsExpression::Function::minParams ( ) const
inline

The minimum number of parameters this function takes.

Definition at line 547 of file qgsexpression.h.

◆ name()

QString QgsExpression::Function::name ( ) const
inline

The name of the function.

Definition at line 541 of file qgsexpression.h.

◆ operator==()

bool QgsExpression::Function::operator== ( const Function other) const

Definition at line 6100 of file qgsexpression.cpp.

◆ parameters()

const ParameterList& QgsExpression::Function::parameters ( ) const
inline

Returns the list of named parameters for the function, if set.

Note
added in QGIS 2.16

Definition at line 564 of file qgsexpression.h.

◆ params()

int QgsExpression::Function::params ( ) const
inline

The number of parameters this function takes.

Definition at line 544 of file qgsexpression.h.

◆ referencedColumns()

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

Note
Added in QGIS 3.0

Reimplemented in QgsExpression::StaticFunction, and QgsScopedExpressionFunction.

Definition at line 6094 of file qgsexpression.cpp.

◆ usesGeometry()

bool QgsExpression::Function::usesGeometry ( const NodeFunction node) const
virtual

Does this function use a geometry object.

Reimplemented in QgsExpression::StaticFunction, and QgsScopedExpressionFunction.

Definition at line 6088 of file qgsexpression.cpp.


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