17#ifndef QGSEXPRESSIONNODEIMPL_H
18#define QGSEXPRESSIONNODEIMPL_H
25using namespace Qt::StringLiterals;
56 SIP_PYOBJECT __repr__();
57 % MethodCode QString str = u
"<QgsExpressionNodeUnaryOperator: %1>"_s.arg( sipCpp->text() );
58 sipRes = PyUnicode_FromString( str.toUtf8().constData() );
81 QString
dump()
const override;
86 QList<const QgsExpressionNode *>
nodes() const override
SIP_SKIP;
87 bool needsGeometry() const override;
107 std::unique_ptr<QgsExpressionNode> mOperand;
109 static const char *UNARY_OPERATOR_TEXT[];
167 SIP_PYOBJECT __repr__();
168 % MethodCode QString str = u
"<QgsExpressionNodeBinaryOperator: %1>"_s.arg( sipCpp->text() );
169 sipRes = PyUnicode_FromString( str.toUtf8().constData() );
196 QString
dump()
const override;
201 QList<const QgsExpressionNode *>
nodes() const override
SIP_SKIP;
203 bool needsGeometry() const override;
211 int precedence() const;
216 bool leftAssociative() const;
222 QString text() const;
231 qlonglong computeInt( qlonglong x, qlonglong y );
232 double computeDouble(
double x,
double y );
239 QDateTime computeDateTimeFromInterval(
const QDateTime &d,
QgsInterval *i );
247 std::unique_ptr<QgsExpressionNode> mOpLeft;
248 std::unique_ptr<QgsExpressionNode> mOpRight;
250 static const char *BINARY_OPERATOR_TEXT[];
284 QString
dump()
const override;
289 QList<const QgsExpressionNode *>
nodes() const override
SIP_SKIP;
291 bool needsGeometry() const override;
303 std::unique_ptr<QgsExpressionNode> mContainer;
304 std::unique_ptr<QgsExpressionNode> mIndex;
320 , mLowerBound( nodeLowerBound )
321 , mHigherBound( nodeHigherBound )
336 QString
dump()
const override;
341 QList<const QgsExpressionNode *>
nodes() const override
SIP_SKIP;
342 bool needsGeometry() const override;
370 std::unique_ptr<QgsExpressionNode> mNode;
371 std::unique_ptr<QgsExpressionNode> mLowerBound;
372 std::unique_ptr<QgsExpressionNode> mHigherBound;
373 bool mNegate =
false;
411 QString
dump()
const override;
416 QList<const QgsExpressionNode *>
nodes() const override
SIP_SKIP;
417 bool needsGeometry() const override;
430 std::unique_ptr<QgsExpressionNode> mNode;
431 std::unique_ptr<QgsExpressionNodeInOperator::NodeList> mList;
459 SIP_PYOBJECT __repr__();
461 std::shared_ptr<QgsExpressionFunction> fd = sipCpp->function();
471 QString str = u
"<QgsExpressionNodeFunction: %1>"_s.arg(
function );
472 sipRes = PyUnicode_FromString( str.toUtf8().constData() );
498 QString
dump()
const override;
504 QList<const QgsExpressionNode *>
nodes() const override
SIP_SKIP;
505 bool needsGeometry() const override;
511 static
bool validateParams(
int fnIndex,
QgsExpressionNode::NodeList *args, QString &error );
521 std::shared_ptr<QgsExpressionFunction> mFunction =
nullptr;
522 std::unique_ptr<NodeList> mArgs;
540 SIP_PYOBJECT __repr__();
541 % MethodCode QString str = u
"<QgsExpressionNodeLiteral: %1>"_s.arg( sipCpp->valueAsString() );
542 sipRes = PyUnicode_FromString( str.toUtf8().constData() );
555 QString
dump()
const override;
561 QList<const QgsExpressionNode *>
nodes() const override
SIP_SKIP;
562 bool needsGeometry() const override;
571 QString valueAsString() const;
593 SIP_PYOBJECT __repr__();
594 % MethodCode QString str = u
"<QgsExpressionNodeColumnRef: \"%1\">"_s.arg( sipCpp->name() );
595 sipRes = PyUnicode_FromString( str.toUtf8().constData() );
608 QString
dump()
const override;
613 QList<const QgsExpressionNode *>
nodes() const override
SIP_SKIP;
615 bool needsGeometry() const override;
670 std::unique_ptr<QgsExpressionNode> mWhenExp;
671 std::unique_ptr<QgsExpressionNode> mThenExp;
692 QString
dump()
const override;
710 QList<const QgsExpressionNode *>
nodes() const override
SIP_SKIP;
712 bool needsGeometry() const override;
726 WhenThenList mConditions;
727 std::unique_ptr<QgsExpressionNode> mElseExp;
Expression contexts are used to encapsulate the parameters around which a QgsExpression should be eva...
An abstract base class for defining QgsExpression functions.
SQL-like BETWEEN and NOT BETWEEN predicates.
bool negate() const
Returns true if the predicate is an exclusion test (NOT BETWEEN).
QgsExpressionNode * node() const
Returns the expression node.
QgsExpressionNodeBetweenOperator(QgsExpressionNode *node, QgsExpressionNode *nodeLowerBound, QgsExpressionNode *nodeHigherBound, bool negate=false)
This node tests if the result of node is between the result of nodeLowerBound and nodeHigherBound nod...
A binary expression operator, which operates on two values.
QgsExpressionNode * opLeft() const
Returns the node to the left of the operator.
QgsExpressionNode * opRight() const
Returns the node to the right of the operator.
QgsExpressionNodeBinaryOperator::BinaryOperator op() const
Returns the binary operator.
QgsExpressionNodeBinaryOperator(QgsExpressionNodeBinaryOperator::BinaryOperator op, QgsExpressionNode *opLeft, QgsExpressionNode *opRight)
Binary combination of the left and the right with op.
BinaryOperator
list of binary operators
QgsExpressionNodeColumnRef(const QString &name)
Constructor for QgsExpressionNodeColumnRef, referencing the column with the specified name.
QString name() const
The name of the column.
Represents a "WHEN... THEN..." portation of a CASE WHEN clause in an expression.
WhenThen & operator=(const WhenThen &rh)=delete
WhenThen(const WhenThen &rh)=delete
WhenThen(QgsExpressionNode *whenExp, QgsExpressionNode *thenExp)
A combination of when and then.
QgsExpressionNode * thenExp() const
The expression node that makes the THEN result part of the condition.
QgsExpressionNode * whenExp() const
The expression that makes the WHEN part of the condition.
friend class QgsExpressionNodeCondition
An expression node for CASE WHEN clauses.
QgsExpressionNodeCondition(const QgsExpressionNodeCondition::WhenThenList &conditions, QgsExpressionNode *elseExp=nullptr)
Create a new node with the given list of conditions and an optional elseExp expression.
QList< QgsExpressionNodeCondition::WhenThen * > WhenThenList
QgsExpressionNodeCondition(QgsExpressionNodeCondition::WhenThenList *conditions, QgsExpressionNode *elseExp=nullptr)
Create a new node with the given list of conditions and an optional elseExp expression.
QgsExpressionNode * elseExp() const
The ELSE expression used for the condition.
WhenThenList conditions() const
The list of WHEN THEN expression parts of the expression.
An expression node for expression functions.
int fnIndex() const
Returns the index of the node's function.
QgsExpressionNode::NodeList * args() const
Returns a list of arguments specified for the function.
std::shared_ptr< QgsExpressionFunction > function() const
Returns a reference to the node's function.
QgsExpressionNodeFunction(int fnIndex, QgsExpressionNode::NodeList *args)
A function node consists of an index of the function in the global function array and a list of argum...
An expression node for value IN or NOT IN clauses.
QgsExpressionNode * node() const
Returns the expression node.
QgsExpressionNodeInOperator(QgsExpressionNode *node, QgsExpressionNode::NodeList *list, bool notin=false)
This node tests if the result of node is in the result of list.
QgsExpressionNode::NodeList * list() const
Returns the list of nodes to search for matching values within.
bool isNotIn() const
Returns true if this node is a "NOT IN" operator, or false if the node is a normal "IN" operator.
An indexing expression operator, which allows use of square brackets [] to reference map and array it...
QgsExpressionNodeIndexOperator(QgsExpressionNode *container, QgsExpressionNode *index)
Constructor for QgsExpressionNodeIndexOperator.
QgsExpressionNode * index() const
Returns the index node, representing an array element index or map key.
QgsExpressionNode * container() const
Returns the container node, representing an array or map value.
QVariant value() const
The value of the literal.
QgsExpressionNodeLiteral(const QVariant &value)
Constructor for QgsExpressionNodeLiteral, with the specified literal value.
A unary node is either negative as in boolean (not) or as in numbers (minus).
QgsExpressionNodeUnaryOperator::UnaryOperator op() const
Returns the unary operator.
QgsExpressionNodeUnaryOperator(QgsExpressionNodeUnaryOperator::UnaryOperator op, QgsExpressionNode *operand)
A node unary operator is modifying the value of operand by negating it with op.
QgsExpressionNode * operand() const
Returns the node the operator will operate upon.
UnaryOperator
list of unary operators
A list of expression nodes.
Abstract base class for all nodes that can appear in an expression.
virtual QString dump() const =0
Dump this node into a serialized (part) of an expression.
virtual QgsExpressionNode * clone() const =0
Generate a clone of this node.
virtual QSet< QString > referencedColumns() const =0
Abstract virtual method which returns a list of columns required to evaluate this node.
virtual QgsExpressionNode::NodeType nodeType() const =0
Gets the type of this node.
virtual QSet< QString > referencedVariables() const =0
Returns a set of all variables which are used in this expression.
QgsExpressionNode()=default
NodeType
Known node types.
virtual QList< const QgsExpressionNode * > nodes() const =0
Returns a list of all nodes which are used in this expression.
virtual QSet< QString > referencedFunctions() const =0
Returns a set of all functions which are used in this expression.
Handles parsing and evaluation of expressions (formerly called "search strings").
A representation of the interval between two datetime values.