17#ifndef QGSEXPRESSIONNODE_H
18#define QGSEXPRESSIONNODE_H
22#include <QCoreApplication>
39 switch ( sipCpp->nodeType() )
42 sipType = sipType_QgsExpressionNodeUnaryOperator;
45 sipType = sipType_QgsExpressionNodeBinaryOperator;
48 sipType = sipType_QgsExpressionNodeInOperator;
51 sipType = sipType_QgsExpressionNodeFunction;
54 sipType = sipType_QgsExpressionNodeLiteral;
57 sipType = sipType_QgsExpressionNodeColumnRef;
60 sipType = sipType_QgsExpressionNodeCondition;
63 sipType = sipType_QgsExpressionNodeBetweenOperator;
135 int count()
const {
return mList.count(); }
142 void reserve(
int size ) { mList.reserve( size ); }
152 QList<QgsExpressionNode *>
list() {
return mList; }
163 QStringList
names()
const {
return mNameList; }
171 virtual QString
dump() const;
175 QStringList mNameList;
177 bool mHasNamedNodes = false;
182 static QString cleanNamedNodeName( const QString &name );
201 virtual QString
dump() const = 0;
342 void setCachedStaticValue(
const QVariant &value )
const SIP_SKIP;
Expression contexts are used to encapsulate the parameters around which a QgsExpression should be eva...
A list of expression nodes.
bool hasNamedNodes() const
Returns true if list contains any named nodes.
QStringList names() const
Returns a list of names for nodes.
void append(QgsExpressionNode *node)
Takes ownership of the provided node.
void reserve(int size)
Reserves size for the node list.
QList< QgsExpressionNode * > list()
Gets a list of all the nodes.
QgsExpressionNode * at(int i)
Gets the node at position i in the list.
int count() const
Returns the number of nodes in the list.
Abstract base class for all nodes that can appear in an expression.
bool hasCachedStaticValue() const
Returns true if the node can be replaced by a static cached value.
virtual QString dump() const =0
Dump this node into a serialized (part) of an expression.
QVariant eval(QgsExpression *parent, const QgsExpressionContext *context)
Evaluate this node with the given context and parent.
virtual QgsExpressionNode * clone() const =0
Generate a clone of this node.
virtual bool isStatic(QgsExpression *parent, const QgsExpressionContext *context) const =0
Returns true if this node can be evaluated for a static value.
bool prepare(QgsExpression *parent, const QgsExpressionContext *context)
Prepare this node for evaluation.
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.
bool mHasCachedValue
true if the node has a static, precalculated value.
const QgsExpressionNode * effectiveNode() const
Returns a reference to the simplest node which represents this node, after any compilation optimizati...
QVariant cachedStaticValue() const
Returns the node's static cached value.
virtual QSet< QString > referencedVariables() const =0
Returns a set of all variables which are used in this expression.
QVariant mCachedStaticValue
Contains the static, precalculated value for the node if mHasCachedValue is true.
QgsExpressionNode()=default
std::unique_ptr< QgsExpressionNode > mCompiledSimplifiedNode
Contains a compiled node which represents a simplified version of this node as a result of compilatio...
NodeType
Known node types.
@ ntBetweenOperator
Between operator.
@ ntIndexOperator
Index operator.
int parserFirstLine
First line in the parser this node was found.
QgsExpressionNode & operator=(const QgsExpressionNode &other)
int parserLastLine
Last line in the parser this node was found.
virtual bool needsGeometry() const =0
Abstract virtual method which returns if the geometry is required to evaluate this expression.
virtual QList< const QgsExpressionNode * > nodes() const =0
Returns a list of all nodes which are used in this expression.
void cloneTo(QgsExpressionNode *target) const
Copies the members of this node to the node provided in target.
int parserLastColumn
Last column in the parser this node was found.
int parserFirstColumn
First column in the parser this node was found.
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").
#define SIP_CONVERT_TO_SUBCLASS_CODE(code)
Q_DECLARE_METATYPE(QgsDatabaseQueryLogEntry)
QgsExpressionNode * node
Node.
NamedNode(const QString &name, QgsExpressionNode *node)
Constructor for NamedNode.