2017-04-30 15:14:39 +02:00
|
|
|
/************************************************************************
|
|
|
|
* This file has been generated automatically from *
|
|
|
|
* *
|
|
|
|
* src/core/qgsexpression.h *
|
|
|
|
* *
|
|
|
|
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
|
|
|
|
************************************************************************/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2011-08-09 20:48:13 +02:00
|
|
|
class QgsExpression
|
|
|
|
{
|
2017-04-30 15:14:39 +02:00
|
|
|
%Docstring
|
|
|
|
Class for parsing and evaluation of expressions (formerly called "search strings").
|
|
|
|
The expressions try to follow both syntax and semantics of SQL expressions.
|
|
|
|
|
|
|
|
Usage:
|
|
|
|
\code{.cpp}
|
|
|
|
QgsExpression exp("gid*2 > 10 and type not in ('D','F'));
|
|
|
|
if (exp.hasParserError())
|
|
|
|
{
|
|
|
|
// show error message with parserErrorString() and exit
|
|
|
|
}
|
|
|
|
QVariant result = exp.evaluate(feature, fields);
|
|
|
|
if (exp.hasEvalError())
|
|
|
|
{
|
|
|
|
// show error message with evalErrorString()
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// examine the result
|
|
|
|
}
|
|
|
|
\endcode
|
|
|
|
|
|
|
|
Three Value Logic
|
|
|
|
=================
|
|
|
|
|
|
|
|
Similarly to SQL, this class supports three-value logic: true/false/unknown.
|
|
|
|
Unknown value may be a result of operations with missing data (NULL). Please note
|
|
|
|
that NULL is different value than zero or an empty string. For example
|
|
|
|
3 > NULL returns unknown.
|
|
|
|
|
|
|
|
There is no special (three-value) 'boolean' type: true/false is represented as
|
|
|
|
1/0 integer, unknown value is represented the same way as NULL values: invalid QVariant.
|
|
|
|
|
|
|
|
Performance
|
|
|
|
===========
|
|
|
|
|
|
|
|
For better performance with many evaluations you may first call prepare(fields) function
|
|
|
|
to find out indices of columns and then repeatedly call evaluate(feature).
|
|
|
|
|
|
|
|
Type conversion
|
|
|
|
===============
|
|
|
|
|
|
|
|
Operators and functions that expect arguments to be of a particular
|
|
|
|
type automatically convert the arguments to that type, e.g. sin('2.1') will convert
|
|
|
|
the argument to a double, length(123) will first convert the number to a string.
|
|
|
|
Explicit conversion can be achieved with to_int, to_real, to_string functions.
|
|
|
|
If implicit or explicit conversion is invalid, the evaluation returns an error.
|
|
|
|
Comparison operators do numeric comparison in case both operators are numeric (int/double)
|
|
|
|
or they can be converted to numeric types.
|
|
|
|
|
|
|
|
Implicit sharing
|
|
|
|
================
|
|
|
|
|
|
|
|
This class is implicitly shared, copying has a very low overhead.
|
|
|
|
It is normally preferable to call `QgsExpression( otherExpression )` instead of
|
|
|
|
`QgsExpression( otherExpression.expression() )`. A deep copy will only be made
|
|
|
|
when prepare() is called. For usage this means mainly, that you should
|
|
|
|
normally keep an unprepared master copy of a QgsExpression and whenever using it
|
|
|
|
with a particular QgsFeatureIterator copy it just before and prepare it using the
|
|
|
|
same context as the iterator.
|
|
|
|
|
|
|
|
Implicit sharing was added in 2.14
|
|
|
|
%End
|
|
|
|
|
2011-08-09 20:48:13 +02:00
|
|
|
%TypeHeaderCode
|
|
|
|
#include "qgsexpression.h"
|
|
|
|
%End
|
2012-09-24 02:28:15 +02:00
|
|
|
public:
|
2017-04-30 15:14:39 +02:00
|
|
|
|
|
|
|
QgsExpression( const QString &expr );
|
|
|
|
%Docstring
|
|
|
|
Creates a new expression based on the provided string.
|
|
|
|
The string will immediately be parsed. For optimization
|
|
|
|
prepare() should always be called before every
|
|
|
|
loop in which this expression is used.
|
|
|
|
%End
|
|
|
|
|
|
|
|
QgsExpression( const QgsExpression &other );
|
|
|
|
%Docstring
|
|
|
|
Create a copy of this expression. This is preferred
|
|
|
|
over recreating an expression from a string since
|
|
|
|
it does not need to be re-parsed.
|
|
|
|
%End
|
|
|
|
|
|
|
|
|
2016-09-08 11:06:22 +02:00
|
|
|
QgsExpression();
|
2017-04-30 15:14:39 +02:00
|
|
|
%Docstring
|
|
|
|
Create an empty expression.
|
|
|
|
|
|
|
|
.. versionadded:: 3.0
|
|
|
|
%End
|
2016-09-08 11:06:22 +02:00
|
|
|
|
2012-09-24 02:28:15 +02:00
|
|
|
~QgsExpression();
|
|
|
|
|
2017-04-30 15:14:39 +02:00
|
|
|
bool operator==( const QgsExpression &other ) const;
|
|
|
|
%Docstring
|
|
|
|
Compares two expressions. The operator returns true
|
|
|
|
if the expression string is equal.
|
|
|
|
|
|
|
|
.. versionadded:: 3.0
|
|
|
|
:rtype: bool
|
|
|
|
%End
|
|
|
|
|
2016-09-07 14:02:54 +02:00
|
|
|
bool isValid() const;
|
2017-04-30 15:14:39 +02:00
|
|
|
%Docstring
|
|
|
|
Checks if this expression is valid.
|
|
|
|
A valid expression could be parsed but does not necessarily evaluate properly.
|
|
|
|
|
|
|
|
.. versionadded:: 3.0
|
|
|
|
:rtype: bool
|
|
|
|
%End
|
2016-09-07 14:02:54 +02:00
|
|
|
|
2012-09-24 02:28:15 +02:00
|
|
|
bool hasParserError() const;
|
2017-04-30 15:14:39 +02:00
|
|
|
%Docstring
|
|
|
|
Returns true if an error occurred when parsing the input expression
|
|
|
|
:rtype: bool
|
|
|
|
%End
|
2012-09-24 02:28:15 +02:00
|
|
|
QString parserErrorString() const;
|
2017-04-30 15:14:39 +02:00
|
|
|
%Docstring
|
|
|
|
Returns parser error
|
|
|
|
:rtype: str
|
|
|
|
%End
|
2012-09-24 02:28:15 +02:00
|
|
|
|
2013-03-15 00:43:07 +01:00
|
|
|
|
2017-04-30 15:14:39 +02:00
|
|
|
const QgsExpression::Node *rootNode() const;
|
|
|
|
%Docstring
|
|
|
|
Returns root node of the expression. Root node is null is parsing has failed
|
|
|
|
:rtype: QgsExpression.Node
|
|
|
|
%End
|
|
|
|
|
New framework for context based expressions
This commit adds the ability for expressions to be evaluated against
specific contexts. It replaces the previous behaviour where
expressions were evaluated against a specific feature and could
utilise fragile global "special columns".
Now, expressions are instead evaluated using a context designed for
each individual expression. This is done via QgsExpressionContext
and QgsExpressionContextScope objects.
A QgsExpressionContextScope encapsulates the variables and functions
relating to a specific context. For instance, scopes can be created
for "global" variables (such as QGIS version, platform, and user-set
variables specified within the QGIS options dialog. Think things
like user name, work department, etc), or for "project" variables
(eg project path, title, filename, and user-set variables set
through the project properties dialog. Project version, reference
number, that kind of thing). Many more scopes are planned, including
map layer scopes (variables for layer name, id, user-set variables
through the layer properties dialog), composer scopes, etc...
QgsExpressionContextScopes are 'stacked' into a QgsExpressionContext
object. Scopes added later to a QgsExpressionContext will override
any variables or functions provided by earlier scopes, so for
instance a user could override their global 'author' variable set
within QGIS options with a different 'author' set via the project
properties dialog.
The intended use is that a QgsExpressionContext is created before
a batch set of QgsExpression evaluations. Scopes are then added to
the context based on what makes sense for that particular
expression. Eg, almost all contexts will consist of the global
scope and project scope, and then additional scopes as required.
So a composer label would be evaluated against a context
consisting of the global scope, project scope, composition scope
and finally composer item scope. The batch set of expression
evaluations would then be performed using this context, after which
the context is discarded. In other words, a context is designed
for use for one specific set of expression evaluations only.
2015-08-07 15:29:51 +10:00
|
|
|
bool prepare( const QgsExpressionContext *context );
|
2017-04-30 15:14:39 +02:00
|
|
|
%Docstring
|
|
|
|
Get the expression ready for evaluation - find out column indexes.
|
|
|
|
\param context context for preparing expression
|
|
|
|
.. versionadded:: 2.12
|
|
|
|
:rtype: bool
|
|
|
|
%End
|
2012-09-24 02:28:15 +02:00
|
|
|
|
2016-10-03 10:39:41 +02:00
|
|
|
QSet<QString> referencedColumns() const;
|
2017-04-30 15:14:39 +02:00
|
|
|
%Docstring
|
|
|
|
Get list of columns referenced by the expression.
|
|
|
|
|
|
|
|
.. note::
|
|
|
|
|
|
|
|
If the returned list contains the QgsFeatureRequest.AllAttributes constant then
|
|
|
|
all attributes from the layer are required for evaluation of the expression.
|
|
|
|
QgsFeatureRequest.setSubsetOfAttributes automatically handles this case.
|
|
|
|
|
2017-04-29 23:45:17 +02:00
|
|
|
.. seealso:: referencedAttributeIndexes()
|
2017-04-30 15:14:39 +02:00
|
|
|
:rtype: set of str
|
|
|
|
%End
|
2014-07-09 21:29:20 +10:00
|
|
|
|
2016-10-25 18:53:36 +02:00
|
|
|
QSet<QString> referencedVariables() const;
|
2017-04-30 15:14:39 +02:00
|
|
|
%Docstring
|
|
|
|
Return a list of all variables which are used in this expression.
|
|
|
|
If the list contains a NULL QString, there is a variable name used
|
|
|
|
which is determined at runtime.
|
|
|
|
|
|
|
|
.. versionadded:: 3.0
|
|
|
|
:rtype: set of str
|
|
|
|
%End
|
2016-10-25 18:53:36 +02:00
|
|
|
|
2017-04-30 15:14:39 +02:00
|
|
|
QSet<int> referencedAttributeIndexes( const QgsFields &fields ) const;
|
|
|
|
%Docstring
|
|
|
|
Return a list of field name indexes obtained from the provided fields.
|
|
|
|
|
|
|
|
.. versionadded:: 3.0
|
|
|
|
:rtype: set of int
|
|
|
|
%End
|
2016-09-22 07:57:13 +02:00
|
|
|
|
2014-11-26 14:06:56 +01:00
|
|
|
bool needsGeometry() const;
|
2017-04-30 15:14:39 +02:00
|
|
|
%Docstring
|
|
|
|
Returns true if the expression uses feature geometry for some computation
|
|
|
|
:rtype: bool
|
|
|
|
%End
|
2012-09-24 02:28:15 +02:00
|
|
|
|
|
|
|
|
New framework for context based expressions
This commit adds the ability for expressions to be evaluated against
specific contexts. It replaces the previous behaviour where
expressions were evaluated against a specific feature and could
utilise fragile global "special columns".
Now, expressions are instead evaluated using a context designed for
each individual expression. This is done via QgsExpressionContext
and QgsExpressionContextScope objects.
A QgsExpressionContextScope encapsulates the variables and functions
relating to a specific context. For instance, scopes can be created
for "global" variables (such as QGIS version, platform, and user-set
variables specified within the QGIS options dialog. Think things
like user name, work department, etc), or for "project" variables
(eg project path, title, filename, and user-set variables set
through the project properties dialog. Project version, reference
number, that kind of thing). Many more scopes are planned, including
map layer scopes (variables for layer name, id, user-set variables
through the layer properties dialog), composer scopes, etc...
QgsExpressionContextScopes are 'stacked' into a QgsExpressionContext
object. Scopes added later to a QgsExpressionContext will override
any variables or functions provided by earlier scopes, so for
instance a user could override their global 'author' variable set
within QGIS options with a different 'author' set via the project
properties dialog.
The intended use is that a QgsExpressionContext is created before
a batch set of QgsExpression evaluations. Scopes are then added to
the context based on what makes sense for that particular
expression. Eg, almost all contexts will consist of the global
scope and project scope, and then additional scopes as required.
So a composer label would be evaluated against a context
consisting of the global scope, project scope, composition scope
and finally composer item scope. The batch set of expression
evaluations would then be performed using this context, after which
the context is discarded. In other words, a context is designed
for use for one specific set of expression evaluations only.
2015-08-07 15:29:51 +10:00
|
|
|
QVariant evaluate();
|
2017-04-30 15:14:39 +02:00
|
|
|
%Docstring
|
|
|
|
Evaluate the feature and return the result.
|
|
|
|
.. note::
|
|
|
|
|
|
|
|
this method does not expect that prepare() has been called on this instance
|
|
|
|
.. versionadded:: 2.12
|
|
|
|
:rtype: QVariant
|
|
|
|
%End
|
New framework for context based expressions
This commit adds the ability for expressions to be evaluated against
specific contexts. It replaces the previous behaviour where
expressions were evaluated against a specific feature and could
utilise fragile global "special columns".
Now, expressions are instead evaluated using a context designed for
each individual expression. This is done via QgsExpressionContext
and QgsExpressionContextScope objects.
A QgsExpressionContextScope encapsulates the variables and functions
relating to a specific context. For instance, scopes can be created
for "global" variables (such as QGIS version, platform, and user-set
variables specified within the QGIS options dialog. Think things
like user name, work department, etc), or for "project" variables
(eg project path, title, filename, and user-set variables set
through the project properties dialog. Project version, reference
number, that kind of thing). Many more scopes are planned, including
map layer scopes (variables for layer name, id, user-set variables
through the layer properties dialog), composer scopes, etc...
QgsExpressionContextScopes are 'stacked' into a QgsExpressionContext
object. Scopes added later to a QgsExpressionContext will override
any variables or functions provided by earlier scopes, so for
instance a user could override their global 'author' variable set
within QGIS options with a different 'author' set via the project
properties dialog.
The intended use is that a QgsExpressionContext is created before
a batch set of QgsExpression evaluations. Scopes are then added to
the context based on what makes sense for that particular
expression. Eg, almost all contexts will consist of the global
scope and project scope, and then additional scopes as required.
So a composer label would be evaluated against a context
consisting of the global scope, project scope, composition scope
and finally composer item scope. The batch set of expression
evaluations would then be performed using this context, after which
the context is discarded. In other words, a context is designed
for use for one specific set of expression evaluations only.
2015-08-07 15:29:51 +10:00
|
|
|
|
2017-04-30 15:14:39 +02:00
|
|
|
QVariant evaluate( const QgsExpressionContext *context );
|
|
|
|
%Docstring
|
|
|
|
Evaluate the expression against the specified context and return the result.
|
|
|
|
\param context context for evaluating expression
|
|
|
|
.. note::
|
|
|
|
|
|
|
|
prepare() should be called before calling this method.
|
|
|
|
.. versionadded:: 2.12
|
|
|
|
:rtype: QVariant
|
|
|
|
%End
|
New framework for context based expressions
This commit adds the ability for expressions to be evaluated against
specific contexts. It replaces the previous behaviour where
expressions were evaluated against a specific feature and could
utilise fragile global "special columns".
Now, expressions are instead evaluated using a context designed for
each individual expression. This is done via QgsExpressionContext
and QgsExpressionContextScope objects.
A QgsExpressionContextScope encapsulates the variables and functions
relating to a specific context. For instance, scopes can be created
for "global" variables (such as QGIS version, platform, and user-set
variables specified within the QGIS options dialog. Think things
like user name, work department, etc), or for "project" variables
(eg project path, title, filename, and user-set variables set
through the project properties dialog. Project version, reference
number, that kind of thing). Many more scopes are planned, including
map layer scopes (variables for layer name, id, user-set variables
through the layer properties dialog), composer scopes, etc...
QgsExpressionContextScopes are 'stacked' into a QgsExpressionContext
object. Scopes added later to a QgsExpressionContext will override
any variables or functions provided by earlier scopes, so for
instance a user could override their global 'author' variable set
within QGIS options with a different 'author' set via the project
properties dialog.
The intended use is that a QgsExpressionContext is created before
a batch set of QgsExpression evaluations. Scopes are then added to
the context based on what makes sense for that particular
expression. Eg, almost all contexts will consist of the global
scope and project scope, and then additional scopes as required.
So a composer label would be evaluated against a context
consisting of the global scope, project scope, composition scope
and finally composer item scope. The batch set of expression
evaluations would then be performed using this context, after which
the context is discarded. In other words, a context is designed
for use for one specific set of expression evaluations only.
2015-08-07 15:29:51 +10:00
|
|
|
|
2012-09-24 02:28:15 +02:00
|
|
|
bool hasEvalError() const;
|
2017-04-30 15:14:39 +02:00
|
|
|
%Docstring
|
|
|
|
Returns true if an error occurred when evaluating last input
|
|
|
|
:rtype: bool
|
|
|
|
%End
|
2012-09-24 02:28:15 +02:00
|
|
|
QString evalErrorString() const;
|
2017-04-30 15:14:39 +02:00
|
|
|
%Docstring
|
|
|
|
Returns evaluation error
|
|
|
|
:rtype: str
|
|
|
|
%End
|
|
|
|
void setEvalErrorString( const QString &str );
|
|
|
|
%Docstring
|
|
|
|
Set evaluation error (used internally by evaluation functions)
|
|
|
|
%End
|
2012-09-24 02:28:15 +02:00
|
|
|
|
2015-04-27 09:10:59 +10:00
|
|
|
bool isField() const;
|
2017-04-30 15:14:39 +02:00
|
|
|
%Docstring
|
|
|
|
Checks whether an expression consists only of a single field reference
|
|
|
|
.. versionadded:: 2.9
|
|
|
|
:rtype: bool
|
|
|
|
%End
|
|
|
|
|
|
|
|
static bool checkExpression( const QString &text, const QgsExpressionContext *context, QString &errorMessage /Out/ );
|
|
|
|
%Docstring
|
|
|
|
Tests whether a string is a valid expression.
|
|
|
|
\param text string to test
|
|
|
|
\param context optional expression context
|
|
|
|
\param errorMessage will be filled with any error message from the validation
|
|
|
|
:return: true if string is a valid expression
|
|
|
|
.. versionadded:: 2.12
|
|
|
|
:rtype: bool
|
|
|
|
%End
|
|
|
|
|
|
|
|
void setExpression( const QString &expression );
|
|
|
|
%Docstring
|
|
|
|
Set the expression string, will reset the whole internal structure.
|
|
|
|
|
|
|
|
.. versionadded:: 3.0
|
|
|
|
%End
|
2015-04-27 09:10:59 +10:00
|
|
|
|
2015-12-09 15:44:56 +01:00
|
|
|
QString expression() const;
|
2017-04-30 15:14:39 +02:00
|
|
|
%Docstring
|
|
|
|
API calls, dump() will be used to create one instead.
|
|
|
|
:rtype: str
|
|
|
|
%End
|
2015-12-09 15:44:56 +01:00
|
|
|
|
2012-09-24 02:28:15 +02:00
|
|
|
QString dump() const;
|
2017-04-30 15:14:39 +02:00
|
|
|
%Docstring
|
|
|
|
expression() instead.
|
|
|
|
:rtype: str
|
|
|
|
%End
|
2012-09-24 02:28:15 +02:00
|
|
|
|
2014-01-26 18:35:21 +01:00
|
|
|
QgsDistanceArea *geomCalculator();
|
2017-04-30 15:14:39 +02:00
|
|
|
%Docstring
|
|
|
|
Return calculator used for distance and area calculations
|
|
|
|
(used by $length, $area and $perimeter functions only)
|
2017-04-29 23:45:17 +02:00
|
|
|
.. seealso:: setGeomCalculator()
|
|
|
|
.. seealso:: distanceUnits()
|
|
|
|
.. seealso:: areaUnits()
|
2017-04-30 15:14:39 +02:00
|
|
|
:rtype: QgsDistanceArea
|
|
|
|
%End
|
|
|
|
|
|
|
|
void setGeomCalculator( const QgsDistanceArea *calc );
|
|
|
|
%Docstring
|
|
|
|
Sets the geometry calculator used for distance and area calculations in expressions.
|
|
|
|
(used by $length, $area and $perimeter functions only). By default, no geometry
|
|
|
|
calculator is set and all distance and area calculations are performed using simple
|
|
|
|
cartesian methods (ie no ellipsoidal calculations).
|
|
|
|
\param calc geometry calculator. Ownership is not transferred. Set to a None to force
|
|
|
|
cartesian calculations.
|
2017-04-29 23:45:17 +02:00
|
|
|
.. seealso:: geomCalculator()
|
2017-04-30 15:14:39 +02:00
|
|
|
%End
|
2012-09-24 02:28:15 +02:00
|
|
|
|
2016-07-17 14:56:05 +10:00
|
|
|
QgsUnitTypes::DistanceUnit distanceUnits() const;
|
2017-04-30 15:14:39 +02:00
|
|
|
%Docstring
|
|
|
|
Returns the desired distance units for calculations involving geomCalculator(), e.g., "$length" and "$perimeter".
|
|
|
|
.. note::
|
|
|
|
|
|
|
|
distances are only converted when a geomCalculator() has been set
|
|
|
|
.. versionadded:: 2.14
|
2017-04-29 23:45:17 +02:00
|
|
|
.. seealso:: setDistanceUnits()
|
|
|
|
.. seealso:: areaUnits()
|
2017-04-30 15:14:39 +02:00
|
|
|
:rtype: QgsUnitTypes.DistanceUnit
|
|
|
|
%End
|
2016-02-13 11:23:58 +11:00
|
|
|
|
2016-07-17 14:56:05 +10:00
|
|
|
void setDistanceUnits( QgsUnitTypes::DistanceUnit unit );
|
2017-04-30 15:14:39 +02:00
|
|
|
%Docstring
|
|
|
|
Sets the desired distance units for calculations involving geomCalculator(), e.g., "$length" and "$perimeter".
|
|
|
|
.. note::
|
|
|
|
|
|
|
|
distances are only converted when a geomCalculator() has been set
|
|
|
|
.. versionadded:: 2.14
|
2017-04-29 23:45:17 +02:00
|
|
|
.. seealso:: distanceUnits()
|
|
|
|
.. seealso:: setAreaUnits()
|
2017-04-30 15:14:39 +02:00
|
|
|
%End
|
2016-02-13 11:23:58 +11:00
|
|
|
|
2016-02-15 19:02:19 +11:00
|
|
|
QgsUnitTypes::AreaUnit areaUnits() const;
|
2017-04-30 15:14:39 +02:00
|
|
|
%Docstring
|
|
|
|
Returns the desired areal units for calculations involving geomCalculator(), e.g., "$area".
|
|
|
|
.. note::
|
|
|
|
|
|
|
|
areas are only converted when a geomCalculator() has been set
|
|
|
|
.. versionadded:: 2.14
|
2017-04-29 23:45:17 +02:00
|
|
|
.. seealso:: setAreaUnits()
|
|
|
|
.. seealso:: distanceUnits()
|
2017-04-30 15:14:39 +02:00
|
|
|
:rtype: QgsUnitTypes.AreaUnit
|
|
|
|
%End
|
2016-02-15 19:02:19 +11:00
|
|
|
|
|
|
|
void setAreaUnits( QgsUnitTypes::AreaUnit unit );
|
2017-04-30 15:14:39 +02:00
|
|
|
%Docstring
|
|
|
|
Sets the desired areal units for calculations involving geomCalculator(), e.g., "$area".
|
|
|
|
.. note::
|
|
|
|
|
|
|
|
areas are only converted when a geomCalculator() has been set
|
|
|
|
.. versionadded:: 2.14
|
2017-04-29 23:45:17 +02:00
|
|
|
.. seealso:: areaUnits()
|
|
|
|
.. seealso:: setDistanceUnits()
|
2017-04-30 15:14:39 +02:00
|
|
|
%End
|
|
|
|
|
|
|
|
static QString replaceExpressionText( const QString &action, const QgsExpressionContext *context,
|
|
|
|
const QgsDistanceArea *distanceArea = 0 );
|
|
|
|
%Docstring
|
|
|
|
This function replaces each expression between [% and %]
|
|
|
|
in the string with the result of its evaluation with the specified context
|
|
|
|
|
|
|
|
Additional substitutions can be passed through the substitutionMap parameter
|
|
|
|
\param action The source string in which placeholders should be replaced.
|
|
|
|
\param context Expression context
|
|
|
|
\param distanceArea Optional QgsDistanceArea. If specified, the QgsDistanceArea is used for distance
|
|
|
|
and area conversion
|
|
|
|
.. versionadded:: 2.12
|
|
|
|
:rtype: str
|
|
|
|
%End
|
|
|
|
|
|
|
|
static double evaluateToDouble( const QString &text, const double fallbackValue );
|
|
|
|
%Docstring
|
|
|
|
Attempts to evaluate a text string as an expression to a resultant double
|
|
|
|
value.
|
|
|
|
\param text text to evaluate as expression
|
|
|
|
\param fallbackValue value to return if text can not be evaluated as a double
|
|
|
|
:return: evaluated double value, or fallback value
|
|
|
|
.. versionadded:: 2.7
|
|
|
|
.. note::
|
|
|
|
|
|
|
|
this method is inefficient for bulk evaluation of expressions, it is intended
|
|
|
|
for one-off evaluations only.
|
|
|
|
:rtype: float
|
|
|
|
%End
|
2016-02-15 19:02:19 +11:00
|
|
|
|
2012-01-06 19:25:04 +01:00
|
|
|
enum UnaryOperator
|
|
|
|
{
|
|
|
|
uoNot,
|
|
|
|
uoMinus,
|
|
|
|
};
|
2015-02-03 02:21:52 +01:00
|
|
|
|
2012-01-06 19:25:04 +01:00
|
|
|
enum BinaryOperator
|
|
|
|
{
|
|
|
|
// logical
|
|
|
|
boOr,
|
|
|
|
boAnd,
|
2011-08-09 20:48:13 +02:00
|
|
|
|
2012-01-06 19:25:04 +01:00
|
|
|
// comparison
|
2017-04-30 15:14:39 +02:00
|
|
|
boEQ,
|
|
|
|
boNE,
|
|
|
|
boLE,
|
|
|
|
boGE,
|
|
|
|
boLT,
|
|
|
|
boGT,
|
2012-01-06 19:25:04 +01:00
|
|
|
boRegexp,
|
|
|
|
boLike,
|
2012-09-24 02:28:15 +02:00
|
|
|
boNotLike,
|
2012-01-06 19:25:04 +01:00
|
|
|
boILike,
|
2012-09-24 02:28:15 +02:00
|
|
|
boNotILike,
|
2012-01-06 19:25:04 +01:00
|
|
|
boIs,
|
|
|
|
boIsNot,
|
|
|
|
|
|
|
|
// math
|
|
|
|
boPlus,
|
|
|
|
boMinus,
|
|
|
|
boMul,
|
|
|
|
boDiv,
|
2014-12-06 16:35:06 +11:00
|
|
|
boIntDiv,
|
2012-01-06 19:25:04 +01:00
|
|
|
boMod,
|
|
|
|
boPow,
|
|
|
|
|
|
|
|
// strings
|
|
|
|
boConcat,
|
|
|
|
};
|
2016-02-14 03:50:23 +01:00
|
|
|
|
2014-05-27 23:22:50 +02:00
|
|
|
enum SpatialOperator
|
|
|
|
{
|
|
|
|
soBbox,
|
|
|
|
soIntersects,
|
|
|
|
soContains,
|
|
|
|
soCrosses,
|
|
|
|
soEquals,
|
|
|
|
soDisjoint,
|
|
|
|
soOverlaps,
|
|
|
|
soTouches,
|
|
|
|
soWithin,
|
|
|
|
};
|
2012-01-06 19:25:04 +01:00
|
|
|
|
2016-02-14 03:50:23 +01:00
|
|
|
|
2012-09-24 02:28:15 +02:00
|
|
|
|
2016-03-29 16:22:04 +11:00
|
|
|
class Parameter
|
2017-04-30 15:14:39 +02:00
|
|
|
{
|
|
|
|
%Docstring
|
|
|
|
Represents a single parameter passed to a function.
|
|
|
|
.. versionadded:: 2.16
|
|
|
|
%End
|
|
|
|
|
|
|
|
%TypeHeaderCode
|
|
|
|
#include "qgsexpression.h"
|
|
|
|
%End
|
2016-03-29 16:22:04 +11:00
|
|
|
public:
|
|
|
|
|
2017-04-30 15:14:39 +02:00
|
|
|
Parameter( const QString &name,
|
2016-03-29 16:22:04 +11:00
|
|
|
bool optional = false,
|
2017-04-30 15:14:39 +02:00
|
|
|
const QVariant &defaultValue = QVariant() );
|
|
|
|
%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
|
|
|
|
%End
|
2016-03-29 16:22:04 +11:00
|
|
|
|
|
|
|
QString name() const;
|
2017-04-30 15:14:39 +02:00
|
|
|
%Docstring
|
|
|
|
Returns the name of the parameter.
|
|
|
|
:rtype: str
|
|
|
|
%End
|
2016-03-29 16:22:04 +11:00
|
|
|
|
|
|
|
bool optional() const;
|
2017-04-30 15:14:39 +02:00
|
|
|
%Docstring
|
|
|
|
Returns true if the parameter is optional.
|
|
|
|
:rtype: bool
|
|
|
|
%End
|
2016-03-29 16:22:04 +11:00
|
|
|
|
|
|
|
QVariant defaultValue() const;
|
2017-04-30 15:14:39 +02:00
|
|
|
%Docstring
|
|
|
|
Returns the default value for the parameter.
|
|
|
|
:rtype: QVariant
|
|
|
|
%End
|
2016-03-29 16:22:04 +11:00
|
|
|
|
2017-04-30 15:14:39 +02:00
|
|
|
bool operator==( const QgsExpression::Parameter &other ) const;
|
|
|
|
%Docstring
|
|
|
|
:rtype: bool
|
|
|
|
%End
|
2016-03-29 16:22:04 +11:00
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
typedef QList< QgsExpression::Parameter > ParameterList;
|
|
|
|
|
2017-04-30 15:14:39 +02:00
|
|
|
|
|
|
|
|
2012-11-04 21:56:49 +10:00
|
|
|
class Function
|
2017-04-30 15:14:39 +02:00
|
|
|
{
|
|
|
|
%Docstring
|
|
|
|
A abstract base class for defining QgsExpression functions.
|
|
|
|
%End
|
|
|
|
|
|
|
|
%TypeHeaderCode
|
|
|
|
#include "qgsexpression.h"
|
|
|
|
%End
|
2012-11-04 21:56:49 +10:00
|
|
|
public:
|
2016-03-29 16:22:04 +11:00
|
|
|
|
2017-04-30 15:14:39 +02:00
|
|
|
Function( const QString &fnname,
|
2015-06-06 10:42:55 +02:00
|
|
|
int params,
|
2017-04-30 15:14:39 +02:00
|
|
|
const QString &group,
|
|
|
|
const QString &helpText = QString(),
|
2015-06-06 10:42:55 +02:00
|
|
|
bool lazyEval = false,
|
2015-08-20 15:06:09 +10:00
|
|
|
bool handlesNull = false,
|
|
|
|
bool isContextual = false );
|
2017-04-30 15:14:39 +02:00
|
|
|
%Docstring
|
|
|
|
Constructor for function which uses unnamed parameters
|
|
|
|
%End
|
2015-05-29 08:57:54 +02:00
|
|
|
|
2017-04-30 15:14:39 +02:00
|
|
|
Function( const QString &fnname,
|
2016-10-10 12:27:11 +10:00
|
|
|
int params,
|
2017-04-30 15:14:39 +02:00
|
|
|
const QStringList &groups,
|
|
|
|
const QString &helpText = QString(),
|
2016-10-10 12:27:11 +10:00
|
|
|
bool lazyEval = false,
|
|
|
|
bool handlesNull = false,
|
|
|
|
bool isContextual = false );
|
2017-04-30 15:14:39 +02:00
|
|
|
%Docstring
|
|
|
|
Constructor for function which uses unnamed parameters and group list
|
|
|
|
.. versionadded:: 3.0
|
|
|
|
%End
|
2016-10-10 12:27:11 +10:00
|
|
|
|
2017-04-30 15:14:39 +02:00
|
|
|
Function( const QString &fnname,
|
|
|
|
const QgsExpression::ParameterList ¶ms,
|
|
|
|
const QString &group,
|
|
|
|
const QString &helpText = QString(),
|
2016-03-29 16:22:04 +11:00
|
|
|
bool lazyEval = false,
|
|
|
|
bool handlesNull = false,
|
|
|
|
bool isContextual = false );
|
2017-04-30 15:14:39 +02:00
|
|
|
%Docstring
|
|
|
|
Constructor for function which uses named parameter list.
|
|
|
|
.. versionadded:: 2.16
|
|
|
|
%End
|
2016-03-29 16:22:04 +11:00
|
|
|
|
2017-04-30 15:14:39 +02:00
|
|
|
Function( const QString &fnname,
|
|
|
|
const QgsExpression::ParameterList ¶ms,
|
|
|
|
const QStringList &groups,
|
|
|
|
const QString &helpText = QString(),
|
2016-10-10 12:27:11 +10:00
|
|
|
bool lazyEval = false,
|
|
|
|
bool handlesNull = false,
|
|
|
|
bool isContextual = false );
|
2017-04-30 15:14:39 +02:00
|
|
|
%Docstring
|
|
|
|
Constructor for function which uses named parameter list and group list.
|
|
|
|
.. versionadded:: 3.0
|
|
|
|
%End
|
2016-10-10 12:27:11 +10:00
|
|
|
|
2015-05-27 22:39:23 +10:00
|
|
|
virtual ~Function();
|
2015-05-29 08:57:54 +02:00
|
|
|
|
2016-03-29 16:22:04 +11:00
|
|
|
QString name() const;
|
2017-04-30 15:14:39 +02:00
|
|
|
%Docstring
|
|
|
|
The name of the function.
|
|
|
|
:rtype: str
|
|
|
|
%End
|
|
|
|
|
2016-03-29 16:22:04 +11:00
|
|
|
int params() const;
|
2017-04-30 15:14:39 +02:00
|
|
|
%Docstring
|
|
|
|
The number of parameters this function takes.
|
|
|
|
:rtype: int
|
|
|
|
%End
|
2016-03-29 16:22:04 +11:00
|
|
|
|
|
|
|
int minParams() const;
|
2017-04-30 15:14:39 +02:00
|
|
|
%Docstring
|
|
|
|
The minimum number of parameters this function takes.
|
|
|
|
:rtype: int
|
|
|
|
%End
|
2016-03-29 16:22:04 +11:00
|
|
|
|
2017-04-30 15:14:39 +02:00
|
|
|
const QgsExpression::ParameterList ¶meters() const;
|
|
|
|
%Docstring
|
|
|
|
Returns the list of named parameters for the function, if set.
|
|
|
|
.. versionadded:: 2.16
|
|
|
|
:rtype: QgsExpression.ParameterList
|
|
|
|
%End
|
2016-03-29 16:22:04 +11:00
|
|
|
|
2017-04-30 15:14:39 +02:00
|
|
|
virtual bool usesGeometry( const QgsExpression::NodeFunction *node ) const;
|
|
|
|
%Docstring
|
|
|
|
Does this function use a geometry object.
|
|
|
|
:rtype: bool
|
|
|
|
%End
|
2014-07-09 21:29:20 +10:00
|
|
|
|
2015-05-03 18:40:09 +10:00
|
|
|
virtual QStringList aliases() const;
|
2017-04-30 15:14:39 +02:00
|
|
|
%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
|
|
|
|
.. versionadded:: 2.9
|
|
|
|
:rtype: list of str
|
|
|
|
%End
|
2015-05-03 18:40:09 +10:00
|
|
|
|
2016-03-29 16:22:04 +11:00
|
|
|
bool lazyEval() const;
|
2017-04-30 15:14:39 +02:00
|
|
|
%Docstring
|
|
|
|
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 **
|
|
|
|
:rtype: bool
|
|
|
|
%End
|
|
|
|
|
|
|
|
virtual QSet<QString> referencedColumns( const QgsExpression::NodeFunction *node ) const;
|
|
|
|
%Docstring
|
|
|
|
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.
|
|
|
|
|
|
|
|
.. versionadded:: 3.0
|
|
|
|
:rtype: set of str
|
|
|
|
%End
|
2015-02-03 02:21:52 +01:00
|
|
|
|
2015-08-20 15:06:09 +10:00
|
|
|
bool isContextual() const;
|
2017-04-30 15:14:39 +02:00
|
|
|
%Docstring
|
|
|
|
Returns whether the function is only available if provided by a QgsExpressionContext object.
|
|
|
|
.. versionadded:: 2.12
|
|
|
|
:rtype: bool
|
|
|
|
%End
|
2015-08-20 15:06:09 +10:00
|
|
|
|
2016-10-10 12:27:11 +10:00
|
|
|
virtual bool isDeprecated() const;
|
2017-04-30 15:14:39 +02:00
|
|
|
%Docstring
|
|
|
|
Returns true if the function is deprecated and should not be presented as a valid option
|
|
|
|
to users in expression builders.
|
|
|
|
.. versionadded:: 3.0
|
|
|
|
:rtype: bool
|
|
|
|
%End
|
2016-10-10 12:27:11 +10:00
|
|
|
|
2016-03-29 16:22:04 +11:00
|
|
|
QString group() const;
|
2017-04-30 15:14:39 +02:00
|
|
|
%Docstring
|
|
|
|
Returns the first group which the function belongs to.
|
|
|
|
.. note::
|
|
|
|
|
|
|
|
consider using groups() instead, as some functions naturally belong in multiple groups
|
|
|
|
:rtype: str
|
|
|
|
%End
|
2016-10-10 12:27:11 +10:00
|
|
|
|
|
|
|
QStringList groups() const;
|
2017-04-30 15:14:39 +02:00
|
|
|
%Docstring
|
|
|
|
Returns a list of the groups the function belongs to.
|
|
|
|
.. versionadded:: 3.0
|
2017-04-29 23:45:17 +02:00
|
|
|
.. seealso:: group()
|
2017-04-30 15:14:39 +02:00
|
|
|
:rtype: list of str
|
|
|
|
%End
|
2016-10-10 12:27:11 +10:00
|
|
|
|
2016-08-06 22:16:24 +10:00
|
|
|
const QString helpText() const;
|
2017-04-30 15:14:39 +02:00
|
|
|
%Docstring
|
|
|
|
The help text for the function.
|
|
|
|
:rtype: str
|
|
|
|
%End
|
2012-11-04 21:56:49 +10:00
|
|
|
|
2017-04-30 15:14:39 +02:00
|
|
|
virtual QVariant func( const QVariantList &values, const QgsExpressionContext *context, QgsExpression *parent ) = 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
|
|
|
|
:return: result of function
|
|
|
|
:rtype: QVariant
|
|
|
|
%End
|
|
|
|
|
|
|
|
bool operator==( const QgsExpression::Function &other ) const;
|
|
|
|
%Docstring
|
|
|
|
:rtype: bool
|
|
|
|
%End
|
2012-01-06 19:25:04 +01:00
|
|
|
|
2015-06-06 10:42:55 +02:00
|
|
|
virtual bool handlesNull() const;
|
2017-04-30 15:14:39 +02:00
|
|
|
%Docstring
|
|
|
|
:rtype: bool
|
|
|
|
%End
|
|
|
|
|
2015-06-06 10:42:55 +02:00
|
|
|
};
|
2014-01-26 18:35:21 +01:00
|
|
|
|
2017-04-30 15:14:39 +02:00
|
|
|
|
|
|
|
static const QList<QgsExpression::Function *> &Functions();
|
|
|
|
%Docstring
|
|
|
|
:rtype: list of QgsExpression.Function
|
|
|
|
%End
|
|
|
|
|
|
|
|
static const QStringList &BuiltinFunctions();
|
|
|
|
%Docstring
|
|
|
|
:rtype: list of str
|
|
|
|
%End
|
|
|
|
|
|
|
|
static bool registerFunction( QgsExpression::Function *function, bool transferOwnership = false );
|
|
|
|
%Docstring
|
|
|
|
Registers a function to the expression engine. This is required to allow expressions to utilize the function.
|
|
|
|
\param function function to register
|
|
|
|
\param transferOwnership set to true to transfer ownership of function to expression engine
|
|
|
|
:return: true on successful registration
|
2017-04-29 23:45:17 +02:00
|
|
|
.. seealso:: unregisterFunction
|
2017-04-30 15:14:39 +02:00
|
|
|
:rtype: bool
|
|
|
|
%End
|
|
|
|
|
|
|
|
static bool unregisterFunction( const QString &name );
|
|
|
|
%Docstring
|
|
|
|
Unregisters a function from the expression engine. The function will no longer be usable in expressions.
|
|
|
|
\param name function name
|
2017-04-29 23:45:17 +02:00
|
|
|
.. seealso:: registerFunction
|
2017-04-30 15:14:39 +02:00
|
|
|
:rtype: bool
|
|
|
|
%End
|
|
|
|
|
|
|
|
|
2015-08-25 21:37:57 +10:00
|
|
|
static void cleanRegisteredFunctions();
|
2017-04-30 15:14:39 +02:00
|
|
|
%Docstring
|
|
|
|
Deletes all registered functions whose ownership have been transferred to the expression engine.
|
|
|
|
.. versionadded:: 2.12
|
|
|
|
%End
|
2015-08-25 21:37:57 +10:00
|
|
|
|
2017-04-30 15:14:39 +02:00
|
|
|
static bool isFunctionName( const QString &name );
|
|
|
|
%Docstring
|
|
|
|
tells whether the identifier is a name of existing function
|
|
|
|
:rtype: bool
|
|
|
|
%End
|
2012-01-06 19:25:04 +01:00
|
|
|
|
2017-04-30 15:14:39 +02:00
|
|
|
static int functionIndex( const QString &name );
|
|
|
|
%Docstring
|
|
|
|
return index of the function in Functions array
|
|
|
|
:rtype: int
|
|
|
|
%End
|
2012-01-06 19:25:04 +01:00
|
|
|
|
|
|
|
static int functionCount();
|
2017-04-30 15:14:39 +02:00
|
|
|
%Docstring
|
|
|
|
Returns the number of functions defined in the parser
|
|
|
|
:return: The number of function defined in the parser.
|
|
|
|
:rtype: int
|
|
|
|
%End
|
2012-01-06 19:25:04 +01:00
|
|
|
|
|
|
|
static QString quotedColumnRef( QString name );
|
2017-04-30 15:14:39 +02:00
|
|
|
%Docstring
|
|
|
|
Returns a quoted column reference (in double quotes)
|
2017-04-29 23:45:17 +02:00
|
|
|
.. seealso:: quotedString()
|
|
|
|
.. seealso:: quotedValue()
|
2017-04-30 15:14:39 +02:00
|
|
|
:rtype: str
|
|
|
|
%End
|
2015-12-01 19:33:27 +11:00
|
|
|
|
2012-06-02 00:04:01 +02:00
|
|
|
static QString quotedString( QString text );
|
2017-04-30 15:14:39 +02:00
|
|
|
%Docstring
|
|
|
|
Returns a quoted version of a string (in single quotes)
|
2017-04-29 23:45:17 +02:00
|
|
|
.. seealso:: quotedValue()
|
|
|
|
.. seealso:: quotedColumnRef()
|
2017-04-30 15:14:39 +02:00
|
|
|
:rtype: str
|
|
|
|
%End
|
|
|
|
|
|
|
|
static QString quotedValue( const QVariant &value );
|
|
|
|
%Docstring
|
|
|
|
Returns a string representation of a literal value, including appropriate
|
|
|
|
quotations where required.
|
|
|
|
\param value value to convert to a string representation
|
|
|
|
.. versionadded:: 2.14
|
2017-04-29 23:45:17 +02:00
|
|
|
.. seealso:: quotedString()
|
|
|
|
.. seealso:: quotedColumnRef()
|
2017-04-30 15:14:39 +02:00
|
|
|
:rtype: str
|
|
|
|
%End
|
|
|
|
|
|
|
|
static QString quotedValue( const QVariant &value, QVariant::Type type );
|
|
|
|
%Docstring
|
|
|
|
Returns a string representation of a literal value, including appropriate
|
|
|
|
quotations where required.
|
|
|
|
\param value value to convert to a string representation
|
|
|
|
\param type value type
|
|
|
|
.. versionadded:: 2.14
|
2017-04-29 23:45:17 +02:00
|
|
|
.. seealso:: quotedString()
|
|
|
|
.. seealso:: quotedColumnRef()
|
2017-04-30 15:14:39 +02:00
|
|
|
:rtype: str
|
|
|
|
%End
|
2012-01-06 19:25:04 +01:00
|
|
|
|
|
|
|
|
2013-03-15 00:43:07 +01:00
|
|
|
enum NodeType
|
|
|
|
{
|
|
|
|
ntUnaryOperator,
|
|
|
|
ntBinaryOperator,
|
|
|
|
ntInOperator,
|
|
|
|
ntFunction,
|
|
|
|
ntLiteral,
|
|
|
|
ntColumnRef,
|
|
|
|
ntCondition
|
|
|
|
};
|
|
|
|
|
2012-01-06 19:25:04 +01:00
|
|
|
class Node
|
2017-04-30 15:14:39 +02:00
|
|
|
{
|
2017-04-29 23:45:17 +02:00
|
|
|
%Docstring
|
|
|
|
|
|
|
|
Abstract base class for all nodes that can appear in an expression.
|
|
|
|
%End
|
2017-04-30 15:14:39 +02:00
|
|
|
|
|
|
|
%TypeHeaderCode
|
|
|
|
#include "qgsexpression.h"
|
|
|
|
%End
|
|
|
|
|
|
|
|
%ConvertToSubClassCode
|
|
|
|
switch ( sipCpp->nodeType() )
|
2015-05-12 17:24:57 +01:00
|
|
|
{
|
2017-04-29 23:45:17 +02:00
|
|
|
case QgsExpression::ntUnaryOperator:
|
|
|
|
sipType = sipType_QgsExpression_NodeUnaryOperator;
|
|
|
|
break;
|
|
|
|
case QgsExpression::ntBinaryOperator:
|
|
|
|
sipType = sipType_QgsExpression_NodeBinaryOperator;
|
|
|
|
break;
|
|
|
|
case QgsExpression::ntInOperator:
|
|
|
|
sipType = sipType_QgsExpression_NodeInOperator;
|
|
|
|
break;
|
|
|
|
case QgsExpression::ntFunction:
|
|
|
|
sipType = sipType_QgsExpression_NodeFunction;
|
|
|
|
break;
|
|
|
|
case QgsExpression::ntLiteral:
|
|
|
|
sipType = sipType_QgsExpression_NodeLiteral;
|
|
|
|
break;
|
|
|
|
case QgsExpression::ntColumnRef:
|
|
|
|
sipType = sipType_QgsExpression_NodeColumnRef;
|
|
|
|
break;
|
|
|
|
case QgsExpression::ntCondition:
|
|
|
|
sipType = sipType_QgsExpression_NodeCondition;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
sipType = 0;
|
|
|
|
break;
|
2015-05-12 17:24:57 +01:00
|
|
|
}
|
2017-04-30 15:14:39 +02:00
|
|
|
%End
|
2012-01-06 19:25:04 +01:00
|
|
|
public:
|
|
|
|
virtual ~Node();
|
2016-02-14 03:50:23 +01:00
|
|
|
|
2013-03-15 00:43:07 +01:00
|
|
|
virtual QgsExpression::NodeType nodeType() const = 0;
|
2017-04-30 15:14:39 +02:00
|
|
|
%Docstring
|
2017-04-29 23:45:17 +02:00
|
|
|
Get the type of this node.
|
2017-04-30 15:14:39 +02:00
|
|
|
|
|
|
|
:return: The type of this node
|
|
|
|
:rtype: QgsExpression.NodeType
|
|
|
|
%End
|
|
|
|
|
2017-04-29 23:45:17 +02:00
|
|
|
virtual QString dump() const = 0;
|
2017-04-30 15:14:39 +02:00
|
|
|
%Docstring
|
2017-04-29 23:45:17 +02:00
|
|
|
Dump this node into a serialized (part) of an expression.
|
|
|
|
The returned expression does not necessarily literally match
|
|
|
|
the original expression, it's just guaranteed to behave the same way.
|
|
|
|
:rtype: str
|
2017-04-30 15:14:39 +02:00
|
|
|
%End
|
2016-02-14 03:50:23 +01:00
|
|
|
|
2017-04-29 23:45:17 +02:00
|
|
|
QVariant eval( QgsExpression *parent, const QgsExpressionContext *context );
|
2017-04-30 15:14:39 +02:00
|
|
|
%Docstring
|
2017-04-29 23:45:17 +02:00
|
|
|
Evaluate this node with the given context and parent.
|
|
|
|
This will return a cached value if it has been determined to be static
|
|
|
|
during the prepare() execution.
|
2017-04-30 15:14:39 +02:00
|
|
|
|
2017-04-29 23:45:17 +02:00
|
|
|
.. versionadded:: 2.12
|
|
|
|
:rtype: QVariant
|
2017-04-30 15:14:39 +02:00
|
|
|
%End
|
|
|
|
|
|
|
|
virtual QgsExpression::Node *clone() const = 0;
|
|
|
|
%Docstring
|
|
|
|
Generate a clone of this node.
|
|
|
|
Make sure that the clone does not contain any information which is
|
|
|
|
generated in prepare and context related.
|
|
|
|
Ownership is transferred to the caller.
|
|
|
|
|
|
|
|
:return: a deep copy of this node.
|
|
|
|
:rtype: QgsExpression.Node
|
|
|
|
%End
|
2012-01-06 19:25:04 +01:00
|
|
|
|
2016-10-03 10:39:41 +02:00
|
|
|
virtual QSet<QString> referencedColumns() const = 0;
|
2017-04-30 15:14:39 +02:00
|
|
|
%Docstring
|
|
|
|
Abstract virtual method which returns a list of columns required to
|
|
|
|
evaluate this node.
|
|
|
|
|
|
|
|
When reimplementing this, you need to return any column that is required to
|
|
|
|
evaluate this node and in addition recursively collect all the columns required
|
|
|
|
to evaluate child nodes.
|
|
|
|
|
|
|
|
:return: A list of columns required to evaluate this expression
|
|
|
|
:rtype: set of str
|
|
|
|
%End
|
2016-02-14 03:50:23 +01:00
|
|
|
|
2016-10-25 18:53:36 +02:00
|
|
|
virtual QSet<QString> referencedVariables() const = 0;
|
2017-04-30 15:14:39 +02:00
|
|
|
%Docstring
|
2017-04-29 23:45:17 +02:00
|
|
|
Return a set of all variables which are used in this expression.
|
2017-04-30 15:14:39 +02:00
|
|
|
:rtype: set of str
|
|
|
|
%End
|
2016-10-25 18:53:36 +02:00
|
|
|
|
2012-01-06 19:25:04 +01:00
|
|
|
virtual bool needsGeometry() const = 0;
|
2017-04-30 15:14:39 +02:00
|
|
|
%Docstring
|
|
|
|
Abstract virtual method which returns if the geometry is required to evaluate
|
|
|
|
this expression.
|
|
|
|
|
|
|
|
This needs to call `needsGeometry()` recursively on any child nodes.
|
|
|
|
|
|
|
|
:return: true if a geometry is required to evaluate this expression
|
|
|
|
:rtype: bool
|
|
|
|
%End
|
2017-04-29 23:45:17 +02:00
|
|
|
|
|
|
|
virtual bool isStatic( QgsExpression *parent, const QgsExpressionContext *context ) const = 0;
|
|
|
|
%Docstring
|
|
|
|
Returns true if this node can be evaluated for a static value. This is used during
|
|
|
|
the prepare() step and in case it returns true, the value of this node will already
|
|
|
|
be evaluated and the result cached (and therefore not re-evaluated in subsequent calls
|
|
|
|
to eval()). In case this returns true, prepareNode() will never be called.
|
|
|
|
|
|
|
|
.. versionadded:: 3.0
|
|
|
|
:rtype: bool
|
|
|
|
%End
|
|
|
|
|
|
|
|
bool prepare( QgsExpression *parent, const QgsExpressionContext *context );
|
|
|
|
%Docstring
|
|
|
|
Prepare this node for evaluation.
|
|
|
|
This will check if the node content is static and in this case cache the value.
|
|
|
|
If it's not static it will call prepareNode() to allow the node to do initialization
|
|
|
|
work like for example resolving a column name to an attribute index.
|
|
|
|
|
|
|
|
.. versionadded:: 2.12
|
|
|
|
:rtype: bool
|
|
|
|
%End
|
|
|
|
|
|
|
|
private:
|
|
|
|
virtual bool prepareNode( QgsExpression *parent, const QgsExpressionContext *context ) = 0 ;
|
|
|
|
%Docstring
|
|
|
|
Abstract virtual preparation method
|
|
|
|
Errors are reported to the parent
|
|
|
|
.. versionadded:: 3.0
|
|
|
|
:rtype: bool
|
|
|
|
%End
|
|
|
|
private:
|
|
|
|
virtual QVariant evalNode( QgsExpression *parent, const QgsExpressionContext *context ) = 0 ;
|
|
|
|
%Docstring
|
|
|
|
Abstract virtual eval method
|
|
|
|
Errors are reported to the parent
|
|
|
|
.. versionadded:: 3.0
|
|
|
|
:rtype: QVariant
|
|
|
|
%End
|
2012-01-06 19:25:04 +01:00
|
|
|
};
|
|
|
|
|
2016-03-29 16:22:04 +11:00
|
|
|
class NamedNode
|
2017-04-30 15:14:39 +02:00
|
|
|
{
|
|
|
|
|
|
|
|
%TypeHeaderCode
|
|
|
|
#include "qgsexpression.h"
|
|
|
|
%End
|
2016-03-29 16:22:04 +11:00
|
|
|
public:
|
|
|
|
|
2017-04-30 15:14:39 +02:00
|
|
|
NamedNode( const QString &name, QgsExpression::Node *node );
|
|
|
|
%Docstring
|
|
|
|
Constructor for NamedNode
|
|
|
|
\param name node name
|
|
|
|
\param node node
|
|
|
|
%End
|
2016-03-29 16:22:04 +11:00
|
|
|
|
|
|
|
QString name;
|
2017-04-30 15:14:39 +02:00
|
|
|
%Docstring
|
|
|
|
Node name
|
|
|
|
%End
|
2016-03-29 16:22:04 +11:00
|
|
|
|
2017-04-30 15:14:39 +02:00
|
|
|
QgsExpression::Node *node;
|
|
|
|
%Docstring
|
|
|
|
Node
|
|
|
|
%End
|
2016-03-29 16:22:04 +11:00
|
|
|
};
|
|
|
|
|
2012-01-06 19:25:04 +01:00
|
|
|
class NodeList
|
2017-04-30 15:14:39 +02:00
|
|
|
{
|
|
|
|
|
|
|
|
%TypeHeaderCode
|
|
|
|
#include "qgsexpression.h"
|
|
|
|
%End
|
2012-01-06 19:25:04 +01:00
|
|
|
public:
|
|
|
|
NodeList();
|
2017-04-30 15:14:39 +02:00
|
|
|
virtual ~NodeList();
|
|
|
|
void append( QgsExpression::Node *node /Transfer/ );
|
|
|
|
%Docstring
|
|
|
|
Takes ownership of the provided node
|
|
|
|
%End
|
2016-03-29 16:22:04 +11:00
|
|
|
|
2017-04-30 15:14:39 +02:00
|
|
|
void append( QgsExpression::NamedNode *node /Transfer/ );
|
|
|
|
%Docstring
|
|
|
|
Adds a named node. Takes ownership of the provided node.
|
|
|
|
.. versionadded:: 2.16
|
|
|
|
%End
|
2016-03-29 16:22:04 +11:00
|
|
|
|
|
|
|
int count() const;
|
2017-04-30 15:14:39 +02:00
|
|
|
%Docstring
|
|
|
|
Returns the number of nodes in the list.
|
|
|
|
:rtype: int
|
|
|
|
%End
|
2016-03-29 16:22:04 +11:00
|
|
|
|
|
|
|
bool hasNamedNodes() const;
|
2017-04-30 15:14:39 +02:00
|
|
|
%Docstring
|
|
|
|
.. versionadded:: 2.16
|
|
|
|
:rtype: bool
|
|
|
|
%End
|
2016-03-29 16:22:04 +11:00
|
|
|
|
2017-04-30 15:14:39 +02:00
|
|
|
QList<QgsExpression::Node *> list();
|
|
|
|
%Docstring
|
|
|
|
Get a list of all the nodes.
|
|
|
|
:rtype: list of QgsExpression.Node
|
|
|
|
%End
|
2016-10-27 11:33:42 +02:00
|
|
|
|
2017-04-30 15:14:39 +02:00
|
|
|
QgsExpression::Node *at( int i );
|
|
|
|
%Docstring
|
|
|
|
Get the node at position i in the list.
|
|
|
|
|
|
|
|
.. versionadded:: 3.0
|
|
|
|
:rtype: QgsExpression.Node
|
|
|
|
%End
|
2016-03-29 16:22:04 +11:00
|
|
|
|
|
|
|
QStringList names() const;
|
2017-04-30 15:14:39 +02:00
|
|
|
%Docstring
|
|
|
|
.. versionadded:: 2.16
|
|
|
|
:rtype: list of str
|
|
|
|
%End
|
2016-03-29 16:22:04 +11:00
|
|
|
|
2017-04-30 15:14:39 +02:00
|
|
|
QgsExpression::NodeList *clone() const;
|
|
|
|
%Docstring
|
|
|
|
Creates a deep copy of this list. Ownership is transferred to the caller
|
|
|
|
:rtype: QgsExpression.NodeList
|
|
|
|
%End
|
2012-01-06 19:25:04 +01:00
|
|
|
|
|
|
|
virtual QString dump() const;
|
2017-04-30 15:14:39 +02:00
|
|
|
%Docstring
|
|
|
|
:rtype: str
|
|
|
|
%End
|
|
|
|
|
2012-01-06 19:25:04 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
class NodeUnaryOperator : QgsExpression::Node
|
2017-04-30 15:14:39 +02:00
|
|
|
{
|
2017-04-29 23:45:17 +02:00
|
|
|
%Docstring
|
|
|
|
A unary node is either negative as in boolean (not) or as in numbers (minus).
|
|
|
|
%End
|
2017-04-30 15:14:39 +02:00
|
|
|
|
|
|
|
%TypeHeaderCode
|
|
|
|
#include "qgsexpression.h"
|
|
|
|
%End
|
2012-01-06 19:25:04 +01:00
|
|
|
public:
|
2017-04-29 23:45:17 +02:00
|
|
|
|
2017-04-30 15:14:39 +02:00
|
|
|
NodeUnaryOperator( QgsExpression::UnaryOperator op, QgsExpression::Node *operand /Transfer/ );
|
2017-04-29 23:45:17 +02:00
|
|
|
%Docstring
|
|
|
|
A node unary operator is modifying the value of ``operand`` by negating it with \op.
|
|
|
|
%End
|
2012-01-06 19:25:04 +01:00
|
|
|
~NodeUnaryOperator();
|
|
|
|
|
2013-03-13 23:03:10 +01:00
|
|
|
QgsExpression::UnaryOperator op() const;
|
2017-04-30 15:14:39 +02:00
|
|
|
%Docstring
|
|
|
|
:rtype: QgsExpression.UnaryOperator
|
|
|
|
%End
|
|
|
|
QgsExpression::Node *operand() const;
|
|
|
|
%Docstring
|
|
|
|
:rtype: QgsExpression.Node
|
|
|
|
%End
|
2012-01-06 19:25:04 +01:00
|
|
|
|
2013-03-15 00:43:07 +01:00
|
|
|
virtual QgsExpression::NodeType nodeType() const;
|
2017-04-29 23:45:17 +02:00
|
|
|
virtual bool prepareNode( QgsExpression *parent, const QgsExpressionContext *context );
|
|
|
|
virtual QVariant evalNode( QgsExpression *parent, const QgsExpressionContext *context );
|
2012-01-06 19:25:04 +01:00
|
|
|
virtual QString dump() const;
|
2012-09-24 02:28:15 +02:00
|
|
|
|
2016-10-03 10:39:41 +02:00
|
|
|
virtual QSet<QString> referencedColumns() const;
|
2016-10-25 18:53:36 +02:00
|
|
|
virtual QSet<QString> referencedVariables() const;
|
2012-01-06 19:25:04 +01:00
|
|
|
virtual bool needsGeometry() const;
|
2017-04-30 15:14:39 +02:00
|
|
|
virtual QgsExpression::Node *clone() const;
|
|
|
|
|
2017-04-29 23:45:17 +02:00
|
|
|
virtual bool isStatic( QgsExpression *parent, const QgsExpressionContext *context ) const;
|
|
|
|
|
2012-01-06 19:25:04 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
class NodeBinaryOperator : QgsExpression::Node
|
2017-04-30 15:14:39 +02:00
|
|
|
{
|
|
|
|
|
|
|
|
%TypeHeaderCode
|
|
|
|
#include "qgsexpression.h"
|
|
|
|
%End
|
2012-01-06 19:25:04 +01:00
|
|
|
public:
|
2017-04-29 23:45:17 +02:00
|
|
|
|
2017-04-30 15:14:39 +02:00
|
|
|
NodeBinaryOperator( QgsExpression::BinaryOperator op, QgsExpression::Node *opLeft /Transfer/, QgsExpression::Node *opRight /Transfer/ );
|
2017-04-29 23:45:17 +02:00
|
|
|
%Docstring
|
|
|
|
Binary combination of the left and the right with op.
|
|
|
|
%End
|
2012-01-06 19:25:04 +01:00
|
|
|
~NodeBinaryOperator();
|
|
|
|
|
2013-03-13 23:03:10 +01:00
|
|
|
QgsExpression::BinaryOperator op() const;
|
2017-04-30 15:14:39 +02:00
|
|
|
%Docstring
|
|
|
|
:rtype: QgsExpression.BinaryOperator
|
|
|
|
%End
|
|
|
|
QgsExpression::Node *opLeft() const;
|
|
|
|
%Docstring
|
|
|
|
:rtype: QgsExpression.Node
|
|
|
|
%End
|
|
|
|
QgsExpression::Node *opRight() const;
|
|
|
|
%Docstring
|
|
|
|
:rtype: QgsExpression.Node
|
|
|
|
%End
|
2012-01-06 19:25:04 +01:00
|
|
|
|
2013-03-15 00:43:07 +01:00
|
|
|
virtual QgsExpression::NodeType nodeType() const;
|
2017-04-29 23:45:17 +02:00
|
|
|
virtual bool prepareNode( QgsExpression *parent, const QgsExpressionContext *context );
|
|
|
|
virtual QVariant evalNode( QgsExpression *parent, const QgsExpressionContext *context );
|
2012-01-06 19:25:04 +01:00
|
|
|
virtual QString dump() const;
|
2012-09-24 02:28:15 +02:00
|
|
|
|
2016-10-03 10:39:41 +02:00
|
|
|
virtual QSet<QString> referencedColumns() const;
|
2016-10-25 18:53:36 +02:00
|
|
|
virtual QSet<QString> referencedVariables() const;
|
2012-01-06 19:25:04 +01:00
|
|
|
virtual bool needsGeometry() const;
|
2017-04-30 15:14:39 +02:00
|
|
|
virtual QgsExpression::Node *clone() const;
|
2017-04-29 23:45:17 +02:00
|
|
|
virtual bool isStatic( QgsExpression *parent, const QgsExpressionContext *context ) const;
|
2014-05-27 23:22:50 +02:00
|
|
|
|
|
|
|
int precedence() const;
|
2017-04-30 15:14:39 +02:00
|
|
|
%Docstring
|
|
|
|
:rtype: int
|
|
|
|
%End
|
2014-12-11 14:04:44 +01:00
|
|
|
bool leftAssociative() const;
|
2017-04-30 15:14:39 +02:00
|
|
|
%Docstring
|
|
|
|
:rtype: bool
|
|
|
|
%End
|
|
|
|
|
2012-01-06 19:25:04 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
class NodeInOperator : QgsExpression::Node
|
2017-04-30 15:14:39 +02:00
|
|
|
{
|
|
|
|
|
|
|
|
%TypeHeaderCode
|
|
|
|
#include "qgsexpression.h"
|
|
|
|
%End
|
2012-01-06 19:25:04 +01:00
|
|
|
public:
|
2017-04-29 23:45:17 +02:00
|
|
|
|
2017-04-30 15:14:39 +02:00
|
|
|
NodeInOperator( QgsExpression::Node *node /Transfer/, QgsExpression::NodeList *list /Transfer/, bool notin = false );
|
2017-04-29 23:45:17 +02:00
|
|
|
%Docstring
|
|
|
|
This node tests if the result of \node is in the result of ``list``. Optionally it can be inverted with ``notin`` which by default is false.
|
|
|
|
%End
|
2017-04-30 15:14:39 +02:00
|
|
|
virtual ~NodeInOperator();
|
2012-01-06 19:25:04 +01:00
|
|
|
|
2017-04-30 15:14:39 +02:00
|
|
|
QgsExpression::Node *node() const;
|
|
|
|
%Docstring
|
|
|
|
:rtype: QgsExpression.Node
|
|
|
|
%End
|
2013-03-13 23:03:10 +01:00
|
|
|
bool isNotIn() const;
|
2017-04-30 15:14:39 +02:00
|
|
|
%Docstring
|
|
|
|
:rtype: bool
|
|
|
|
%End
|
|
|
|
QgsExpression::NodeList *list() const;
|
|
|
|
%Docstring
|
|
|
|
:rtype: QgsExpression.NodeList
|
|
|
|
%End
|
2012-01-06 19:25:04 +01:00
|
|
|
|
2013-03-15 00:43:07 +01:00
|
|
|
virtual QgsExpression::NodeType nodeType() const;
|
2017-04-29 23:45:17 +02:00
|
|
|
virtual bool prepareNode( QgsExpression *parent, const QgsExpressionContext *context );
|
|
|
|
virtual QVariant evalNode( QgsExpression *parent, const QgsExpressionContext *context );
|
2012-01-06 19:25:04 +01:00
|
|
|
virtual QString dump() const;
|
2012-09-24 02:28:15 +02:00
|
|
|
|
2016-10-03 10:39:41 +02:00
|
|
|
virtual QSet<QString> referencedColumns() const;
|
2016-10-25 18:53:36 +02:00
|
|
|
virtual QSet<QString> referencedVariables() const;
|
2012-01-06 19:25:04 +01:00
|
|
|
virtual bool needsGeometry() const;
|
2017-04-30 15:14:39 +02:00
|
|
|
virtual QgsExpression::Node *clone() const;
|
2017-04-29 23:45:17 +02:00
|
|
|
virtual bool isStatic( QgsExpression *parent, const QgsExpressionContext *context ) const;
|
2017-04-30 15:14:39 +02:00
|
|
|
|
2012-01-06 19:25:04 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
class NodeFunction : QgsExpression::Node
|
2017-04-30 15:14:39 +02:00
|
|
|
{
|
|
|
|
|
|
|
|
%TypeHeaderCode
|
|
|
|
#include "qgsexpression.h"
|
|
|
|
%End
|
2012-01-06 19:25:04 +01:00
|
|
|
public:
|
2017-04-29 23:45:17 +02:00
|
|
|
|
2017-04-30 15:14:39 +02:00
|
|
|
NodeFunction( int fnIndex, QgsExpression::NodeList *args /Transfer/ );
|
2017-04-29 23:45:17 +02:00
|
|
|
%Docstring
|
|
|
|
A function node consists of an index of the function in the global function array and
|
|
|
|
a list of arguments that will be passed to it.
|
|
|
|
%End
|
2017-04-30 15:14:39 +02:00
|
|
|
|
|
|
|
virtual ~NodeFunction();
|
2012-01-06 19:25:04 +01:00
|
|
|
|
2013-03-13 23:03:10 +01:00
|
|
|
int fnIndex() const;
|
2017-04-30 15:14:39 +02:00
|
|
|
%Docstring
|
|
|
|
:rtype: int
|
|
|
|
%End
|
|
|
|
QgsExpression::NodeList *args() const;
|
|
|
|
%Docstring
|
|
|
|
:rtype: QgsExpression.NodeList
|
|
|
|
%End
|
2012-01-06 19:25:04 +01:00
|
|
|
|
2013-03-15 00:43:07 +01:00
|
|
|
virtual QgsExpression::NodeType nodeType() const;
|
2017-04-29 23:45:17 +02:00
|
|
|
virtual bool prepareNode( QgsExpression *parent, const QgsExpressionContext *context );
|
|
|
|
virtual QVariant evalNode( QgsExpression *parent, const QgsExpressionContext *context );
|
2012-01-06 19:25:04 +01:00
|
|
|
virtual QString dump() const;
|
2012-09-24 02:28:15 +02:00
|
|
|
|
2016-10-03 10:39:41 +02:00
|
|
|
virtual QSet<QString> referencedColumns() const;
|
2016-10-25 18:53:36 +02:00
|
|
|
virtual QSet<QString> referencedVariables() const;
|
2012-01-06 19:25:04 +01:00
|
|
|
virtual bool needsGeometry() const;
|
2017-04-30 15:14:39 +02:00
|
|
|
virtual QgsExpression::Node *clone() const;
|
2017-04-29 23:45:17 +02:00
|
|
|
virtual bool isStatic( QgsExpression *parent, const QgsExpressionContext *context ) const;
|
2017-04-30 15:14:39 +02:00
|
|
|
|
|
|
|
static bool validateParams( int fnIndex, QgsExpression::NodeList *args, QString &error );
|
|
|
|
%Docstring
|
|
|
|
Tests whether the provided argument list is valid for the matching function
|
|
|
|
:rtype: bool
|
|
|
|
%End
|
2016-03-29 16:22:04 +11:00
|
|
|
|
2012-01-06 19:25:04 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
class NodeLiteral : QgsExpression::Node
|
2017-04-30 15:14:39 +02:00
|
|
|
{
|
|
|
|
|
|
|
|
%TypeHeaderCode
|
|
|
|
#include "qgsexpression.h"
|
|
|
|
%End
|
2012-01-06 19:25:04 +01:00
|
|
|
public:
|
2017-04-30 15:14:39 +02:00
|
|
|
NodeLiteral( const QVariant &value );
|
2012-01-06 19:25:04 +01:00
|
|
|
|
2017-04-30 15:14:39 +02:00
|
|
|
QVariant value() const;
|
|
|
|
%Docstring
|
|
|
|
The value of the literal.
|
|
|
|
:rtype: QVariant
|
|
|
|
%End
|
2012-01-06 19:25:04 +01:00
|
|
|
|
2013-03-15 00:43:07 +01:00
|
|
|
virtual QgsExpression::NodeType nodeType() const;
|
2017-04-29 23:45:17 +02:00
|
|
|
virtual bool prepareNode( QgsExpression *parent, const QgsExpressionContext *context );
|
|
|
|
virtual QVariant evalNode( QgsExpression *parent, const QgsExpressionContext *context );
|
2012-01-06 19:25:04 +01:00
|
|
|
virtual QString dump() const;
|
2012-09-24 02:28:15 +02:00
|
|
|
|
2016-10-03 10:39:41 +02:00
|
|
|
virtual QSet<QString> referencedColumns() const;
|
2016-10-25 18:53:36 +02:00
|
|
|
virtual QSet<QString> referencedVariables() const;
|
2012-01-06 19:25:04 +01:00
|
|
|
virtual bool needsGeometry() const;
|
2017-04-30 15:14:39 +02:00
|
|
|
virtual QgsExpression::Node *clone() const;
|
2017-04-29 23:45:17 +02:00
|
|
|
virtual bool isStatic( QgsExpression *parent, const QgsExpressionContext *context ) const;
|
2017-04-30 15:14:39 +02:00
|
|
|
|
2012-01-06 19:25:04 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
class NodeColumnRef : QgsExpression::Node
|
2017-04-30 15:14:39 +02:00
|
|
|
{
|
|
|
|
|
|
|
|
%TypeHeaderCode
|
|
|
|
#include "qgsexpression.h"
|
|
|
|
%End
|
2012-01-06 19:25:04 +01:00
|
|
|
public:
|
2017-04-30 15:14:39 +02:00
|
|
|
NodeColumnRef( const QString &name );
|
2012-01-06 19:25:04 +01:00
|
|
|
|
2013-03-13 23:03:10 +01:00
|
|
|
QString name() const;
|
2017-04-30 15:14:39 +02:00
|
|
|
%Docstring
|
|
|
|
The name of the column.
|
|
|
|
:rtype: str
|
|
|
|
%End
|
2012-01-06 19:25:04 +01:00
|
|
|
|
2017-04-30 15:23:19 +02:00
|
|
|
virtual QgsExpression::NodeType nodeType() const;
|
2017-04-29 23:45:17 +02:00
|
|
|
virtual bool prepareNode( QgsExpression *parent, const QgsExpressionContext *context );
|
|
|
|
virtual QVariant evalNode( QgsExpression *parent, const QgsExpressionContext *context );
|
2012-01-06 19:25:04 +01:00
|
|
|
virtual QString dump() const;
|
2012-09-24 02:28:15 +02:00
|
|
|
|
2016-10-03 10:39:41 +02:00
|
|
|
virtual QSet<QString> referencedColumns() const;
|
2016-10-25 18:53:36 +02:00
|
|
|
virtual QSet<QString> referencedVariables() const;
|
2012-01-06 19:25:04 +01:00
|
|
|
virtual bool needsGeometry() const;
|
2014-01-26 18:35:21 +01:00
|
|
|
|
2017-04-30 15:14:39 +02:00
|
|
|
virtual QgsExpression::Node *clone() const;
|
2017-04-29 23:45:17 +02:00
|
|
|
virtual bool isStatic( QgsExpression *parent, const QgsExpressionContext *context ) const;
|
2017-04-30 15:14:39 +02:00
|
|
|
|
2012-01-06 19:25:04 +01:00
|
|
|
};
|
|
|
|
|
2017-04-29 23:45:17 +02:00
|
|
|
|
2012-01-07 01:20:03 +01:00
|
|
|
class WhenThen
|
2017-04-30 15:14:39 +02:00
|
|
|
{
|
|
|
|
|
|
|
|
%TypeHeaderCode
|
|
|
|
#include "qgsexpression.h"
|
|
|
|
%End
|
2012-09-24 02:28:15 +02:00
|
|
|
public:
|
2017-04-29 23:45:17 +02:00
|
|
|
|
|
|
|
WhenThen( QgsExpression::Node *whenExp, QgsExpression::Node *thenExp );
|
|
|
|
%Docstring
|
|
|
|
A combination of when and then. Simple as that.
|
|
|
|
%End
|
2012-09-24 02:28:15 +02:00
|
|
|
~WhenThen();
|
2012-01-07 01:20:03 +01:00
|
|
|
|
2016-01-22 18:45:45 +11:00
|
|
|
|
2017-04-29 23:45:17 +02:00
|
|
|
QgsExpression::WhenThen *clone() const;
|
|
|
|
%Docstring
|
|
|
|
Get a deep copy of this WhenThen combination.
|
|
|
|
:rtype: QgsExpression.WhenThen
|
|
|
|
%End
|
2016-01-22 18:45:45 +11:00
|
|
|
|
2017-04-30 15:14:39 +02:00
|
|
|
private:
|
|
|
|
WhenThen( const QgsExpression::WhenThen &rh );
|
2012-01-07 01:20:03 +01:00
|
|
|
};
|
2017-04-30 15:14:39 +02:00
|
|
|
typedef QList<QgsExpression::WhenThen *> WhenThenList;
|
2012-01-07 01:20:03 +01:00
|
|
|
|
|
|
|
class NodeCondition : QgsExpression::Node
|
2017-04-30 15:14:39 +02:00
|
|
|
{
|
|
|
|
|
|
|
|
%TypeHeaderCode
|
|
|
|
#include "qgsexpression.h"
|
|
|
|
%End
|
2012-09-24 02:28:15 +02:00
|
|
|
public:
|
2017-04-29 23:45:17 +02:00
|
|
|
|
2017-04-30 15:14:39 +02:00
|
|
|
NodeCondition( QgsExpression::WhenThenList *conditions, QgsExpression::Node *elseExp = 0 );
|
2017-04-29 23:45:17 +02:00
|
|
|
%Docstring
|
|
|
|
Create a new node with the given list of ``conditions`` and an optional ``elseExp`` expression.
|
|
|
|
%End
|
2017-04-30 15:14:39 +02:00
|
|
|
|
|
|
|
|
2012-09-24 02:28:15 +02:00
|
|
|
~NodeCondition();
|
|
|
|
|
2013-03-15 00:43:07 +01:00
|
|
|
virtual QgsExpression::NodeType nodeType() const;
|
2017-04-29 23:45:17 +02:00
|
|
|
virtual QVariant evalNode( QgsExpression *parent, const QgsExpressionContext *context );
|
|
|
|
virtual bool prepareNode( QgsExpression *parent, const QgsExpressionContext *context );
|
2012-09-24 02:28:15 +02:00
|
|
|
virtual QString dump() const;
|
|
|
|
|
2016-10-03 10:39:41 +02:00
|
|
|
virtual QSet<QString> referencedColumns() const;
|
2016-10-25 18:53:36 +02:00
|
|
|
virtual QSet<QString> referencedVariables() const;
|
2012-09-24 02:28:15 +02:00
|
|
|
virtual bool needsGeometry() const;
|
2017-04-30 15:14:39 +02:00
|
|
|
virtual QgsExpression::Node *clone() const;
|
2017-04-29 23:45:17 +02:00
|
|
|
virtual bool isStatic( QgsExpression *parent, const QgsExpressionContext *context ) const;
|
2017-04-30 15:14:39 +02:00
|
|
|
|
2012-01-07 01:20:03 +01:00
|
|
|
};
|
2017-04-30 15:14:39 +02:00
|
|
|
|
2016-08-06 22:16:24 +10:00
|
|
|
static QString helpText( QString name );
|
2017-04-30 15:14:39 +02:00
|
|
|
%Docstring
|
|
|
|
Returns the help text for a specified function.
|
|
|
|
\param name function name
|
2017-04-29 23:45:17 +02:00
|
|
|
.. seealso:: variableHelpText()
|
2017-04-30 15:14:39 +02:00
|
|
|
:rtype: str
|
|
|
|
%End
|
2015-08-20 13:41:45 +10:00
|
|
|
|
2017-04-30 15:14:39 +02:00
|
|
|
static QString variableHelpText( const QString &variableName, bool showValue = true, const QVariant &value = QVariant() );
|
|
|
|
%Docstring
|
|
|
|
Returns the help text for a specified variable.
|
|
|
|
\param variableName name of variable
|
|
|
|
\param showValue set to true to include current value of variable in help text
|
|
|
|
\param value current value of variable to show in help text
|
2017-04-29 23:45:17 +02:00
|
|
|
.. seealso:: helpText()
|
2017-04-30 15:14:39 +02:00
|
|
|
.. versionadded:: 2.12
|
|
|
|
:rtype: str
|
|
|
|
%End
|
|
|
|
|
|
|
|
static QString group( const QString &group );
|
|
|
|
%Docstring
|
|
|
|
Returns the translated name for a function group.
|
|
|
|
\param group untranslated group name
|
|
|
|
:rtype: str
|
|
|
|
%End
|
|
|
|
|
|
|
|
static QString formatPreviewString( const QVariant &value );
|
|
|
|
%Docstring
|
|
|
|
Formats an expression result for friendly display to the user. Truncates the result to a sensible
|
|
|
|
length, and presents text representations of non numeric/text types (e.g., geometries and features).
|
|
|
|
\param value expression result to format
|
|
|
|
:return: formatted string, may contain HTML formatting characters
|
|
|
|
.. versionadded:: 2.14
|
|
|
|
:rtype: str
|
|
|
|
%End
|
2016-01-27 11:19:58 +11:00
|
|
|
|
2012-09-24 02:28:15 +02:00
|
|
|
protected:
|
|
|
|
void initGeomCalculator();
|
2017-04-30 15:14:39 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2011-08-09 20:48:13 +02:00
|
|
|
};
|
2017-04-30 15:14:39 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/************************************************************************
|
|
|
|
* This file has been generated automatically from *
|
|
|
|
* *
|
|
|
|
* src/core/qgsexpression.h *
|
|
|
|
* *
|
|
|
|
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
|
|
|
|
************************************************************************/
|