Subgroup: Expression
Class: QgsExpressionNode¶
-
class
qgis.core.
QgsExpressionNode
¶ Bases:
sip.wrapper
Abstract base class for all nodes that can appear in an expression.
Methods
clone
Generate a clone of this node. dump
Dump this node into a serialized (part) of an expression. eval
Evaluate this node with the given context and parent. isStatic
Returns true if this node can be evaluated for a static value. needsGeometry
Abstract virtual method which returns if the geometry is required to evaluate this expression. nodeType
Get the type of this node. prepare
Prepare this node for evaluation. referencedColumns
Abstract virtual method which returns a list of columns required to evaluate this node. referencedVariables
Return a set of all variables which are used in this expression. Attributes
ntBinaryOperator
ntColumnRef
ntCondition
ntFunction
ntInOperator
ntLiteral
ntUnaryOperator
-
class
NamedNode
(name: str, node: QgsExpressionNode)¶ Bases:
sip.wrapper
Constructor for NamedNode
Parameters: - name – node name
- node – node
QgsExpressionNode.NamedNode(QgsExpressionNode.NamedNode)
-
name
¶
-
node
¶
-
class
NodeList
¶ Bases:
sip.wrapper
QgsExpressionNode.NodeList(QgsExpressionNode.NodeList)
-
append
(self, node: QgsExpressionNode)¶ Takes ownership of the provided node
append(self, node: QgsExpressionNode.NamedNode) Adds a named node. Takes ownership of the provided node.
New in version 2.16.
-
at
(self, i: int) → QgsExpressionNode¶ Get the node at position i in the list.
New in version 3.0.
-
clone
(self) → QgsExpressionNode.NodeList¶ Creates a deep copy of this list. Ownership is transferred to the caller
-
count
(self) → int¶ Returns the number of nodes in the list.
-
dump
(self) → str¶
-
hasNamedNodes
(self) → bool¶ Returns true if list contains any named nodes
New in version 2.16.
-
list
(self) → object¶ Get a list of all the nodes.
-
names
(self) → List[str]¶ Returns a list of names for nodes. Unnamed nodes will be indicated by an empty string in the list.
New in version 2.16.
-
-
class
NodeType
¶ Bases:
int
-
clone
(self) → QgsExpressionNode¶ Generate a clone of this node. Ownership is transferred to the caller.
Returns: a deep copy of this node.
-
dump
(self) → str¶ 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.
-
eval
(self, parent: QgsExpression, context: QgsExpressionContext) → Any¶ 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.
New in version 2.12.
-
isStatic
(self, parent: QgsExpression, context: QgsExpressionContext) → bool¶ 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.
New in version 3.0.
-
needsGeometry
(self) → bool¶ Abstract virtual method which returns if the geometry is required to evaluate this expression.
This needs to call needsGeometry() recursively on any child nodes.
Returns: true if a geometry is required to evaluate this expression
-
nodeType
(self) → QgsExpressionNode.NodeType¶ Get the type of this node.
Returns: The type of this node
-
ntBinaryOperator
= 1¶
-
ntColumnRef
= 5¶
-
ntCondition
= 6¶
-
ntFunction
= 3¶
-
ntInOperator
= 2¶
-
ntLiteral
= 4¶
-
ntUnaryOperator
= 0¶
-
prepare
(self, parent: QgsExpression, context: QgsExpressionContext) → bool¶ 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.
New in version 2.12.
-
referencedColumns
(self) → Set[str]¶ 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.
Returns: A list of columns required to evaluate this expression
-
referencedVariables
(self) → Set[str]¶ Return a set of all variables which are used in this expression.
-
class