QGIS/python/core/auto_generated/expression/qgsexpressionfunction.sip.in
Nyall Dawson 3f6b490218 Sipify
2025-04-02 11:11:10 +10:00

280 lines
8.9 KiB
Plaintext

/************************************************************************
* This file has been generated automatically from *
* *
* src/core/expression/qgsexpressionfunction.h *
* *
* Do not edit manually ! Edit header and run scripts/sipify.py again *
************************************************************************/
class QgsExpressionFunction
{
%Docstring(signature="appended")
An abstract base class for defining :py:class:`QgsExpression` functions.
%End
%TypeHeaderCode
#include "qgsexpressionfunction.h"
%End
public:
class Parameter
{
%Docstring(signature="appended")
Represents a single parameter passed to a function.
%End
%TypeHeaderCode
#include "qgsexpressionfunction.h"
%End
public:
Parameter( const QString &name,
bool optional = false,
const QVariant &defaultValue = QVariant(),
bool isSubExpression = false );
%Docstring
Constructor for Parameter.
:param name: parameter name, used when named parameter are specified in
an expression
:param optional: set to ``True`` if parameter should be optional
:param defaultValue: default value to use for optional parameters
:param isSubExpression: set to ``True`` if this parameter is a
sub-expression
%End
QString name() const;
%Docstring
Returns the name of the parameter.
%End
bool optional() const;
%Docstring
Returns ``True`` if the parameter is optional.
%End
QVariant defaultValue() const;
%Docstring
Returns the default value for the parameter.
%End
bool isSubExpression() const;
%Docstring
Returns ``True`` if parameter argument is a separate sub-expression, and
should not be checked while determining referenced columns for the
expression.
.. versionadded:: 3.2
%End
bool operator==( const QgsExpressionFunction::Parameter &other ) const;
};
typedef QList< QgsExpressionFunction::Parameter > ParameterList;
QgsExpressionFunction( const QString &fnname,
int params,
const QString &group,
const QString &helpText = QString(),
bool lazyEval = false,
bool handlesNull = false,
bool isContextual = false );
%Docstring
Constructor for function which uses unnamed parameters
%End
QgsExpressionFunction( const QString &fnname,
int params,
const QStringList &groups,
const QString &helpText = QString(),
bool lazyEval = false,
bool handlesNull = false,
bool isContextual = false );
%Docstring
Constructor for function which uses unnamed parameters and group list
%End
QgsExpressionFunction( const QString &fnname,
const QgsExpressionFunction::ParameterList &params,
const QString &group,
const QString &helpText = QString(),
bool lazyEval = false,
bool handlesNull = false,
bool isContextual = false );
%Docstring
Constructor for function which uses named parameter list.
%End
QgsExpressionFunction( const QString &fnname,
const QgsExpressionFunction::ParameterList &params,
const QStringList &groups,
const QString &helpText = QString(),
bool lazyEval = false,
bool handlesNull = false,
bool isContextual = false );
%Docstring
Constructor for function which uses named parameter list and group list.
%End
virtual ~QgsExpressionFunction();
QString name() const;
%Docstring
The name of the function.
%End
int params() const;
%Docstring
The number of parameters this function takes.
%End
int minParams() const;
%Docstring
The minimum number of parameters this function takes.
%End
const QgsExpressionFunction::ParameterList &parameters() const;
%Docstring
Returns the list of named parameters for the function, if set.
%End
virtual bool usesGeometry( const QgsExpressionNodeFunction *node ) const;
%Docstring
Does this function use a geometry object.
%End
virtual QStringList aliases() const;
%Docstring
Returns a list of possible aliases for the function. These include other
permissible names for the function, e.g., deprecated names.
:return: list of known aliases
%End
bool lazyEval() const;
%Docstring
``True`` if this function should use lazy evaluation. Lazy evaluation
functions take :py:class:`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.
%End
virtual bool isStatic( const QgsExpressionNodeFunction *node, QgsExpression *parent, const QgsExpressionContext *context ) const;
%Docstring
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.
%End
virtual bool prepare( const QgsExpressionNodeFunction *node, QgsExpression *parent, const QgsExpressionContext *context ) const;
%Docstring
This will be called during the prepare
:py:func:`~QgsExpressionFunction.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.
%End
virtual QSet<QString> referencedColumns( const QgsExpressionNodeFunction *node ) const;
%Docstring
Returns a set of field names which are required for this function. May
contain :py:class:`QgsFeatureRequest`.AllAttributes to signal that all
attributes are required. If in doubt this will return more fields than
strictly required.
%End
bool isContextual() const;
%Docstring
Returns whether the function is only available if provided by a
:py:class:`QgsExpressionContext` object.
%End
virtual bool isDeprecated() const;
%Docstring
Returns ``True`` if the function is deprecated and should not be
presented as a valid option to users in expression builders.
%End
QString group() const;
%Docstring
Returns the first group which the function belongs to.
.. note::
consider using :py:func:`~QgsExpressionFunction.groups` instead, as some functions naturally belong in multiple groups
%End
QStringList groups() const;
%Docstring
Returns a list of the groups the function belongs to.
.. seealso:: :py:func:`group`
%End
const QString helpText() const;
%Docstring
The help text for the function.
%End
virtual QVariant func( const QVariantList &values, const QgsExpressionContext *context, QgsExpression *parent, const QgsExpressionNodeFunction *node ) = 0;
%Docstring
Returns result of evaluating the function.
:param values: list of values passed to the function
:param context: context expression is being evaluated against
:param parent: parent expression
:param node: expression node
:return: result of function
%End
virtual QVariant run( QgsExpressionNode::NodeList *args, const QgsExpressionContext *context, QgsExpression *parent, const QgsExpressionNodeFunction *node );
%Docstring
Evaluates the function, first evaluating all required arguments before
passing them to the function's :py:func:`~QgsExpressionFunction.func`
method.
%End
bool operator==( const QgsExpressionFunction &other ) const;
virtual bool handlesNull() const;
%Docstring
Returns ``True`` if the function handles NULL values in arguments by
itself, and the default NULL value handling should be skipped.
%End
protected:
static bool allParamsStatic( const QgsExpressionNodeFunction *node, QgsExpression *parent, const QgsExpressionContext *context );
%Docstring
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.
%End
};
/************************************************************************
* This file has been generated automatically from *
* *
* src/core/expression/qgsexpressionfunction.h *
* *
* Do not edit manually ! Edit header and run scripts/sipify.py again *
************************************************************************/