Unit 'fpexprpars' Package
[Overview][Constants][Types][Classes][Procedures and functions][Index] [#fcl]

TIfOperation

[Properties (by Name)] [Methods (by Name)] [Events (by Name)]

Internally used class for conditional if-then-else operations

Declaration

Source position: fpexprpars.pp line 260

type TIfOperation = class(TFPBinaryOperation)

public

  procedure Check; override;

  

Validate the conditional operation for correctness

  procedure InitAggregate; override;

  

Initialize aggregate processing for if operation

  procedure UpdateAggregate; override;

  

Update aggregate calculations for if operation

  function HasAggregate; override;

  

Check if conditional operation contains aggregates

  function NodeType; override;

  

Get the result type for conditional operation

  constructor Create();

  

Create conditional operation with condition and branches

  destructor destroy; override;

  

Destroy conditional operation and free resources

  function AsString; override;

  

Get string representation of conditional operation

  property Condition: TFPExprNode; [r]

  

The condition expression of the if operation

end;

Inheritance

TIfOperation

  

Internally used class for conditional if-then-else operations

|

TFPBinaryOperation

  

Internally used class for binary operations with left and right operands

|

TFPExprNode

  

Class for representing nodes in expression trees

|

TObject

Description

The TIfOperation class implements conditional if-then-else operations in expressions, allowing for branching logic based on boolean conditions. It extends the expression framework to provide conditional evaluation similar to the ternary operator in many programming languages.

The operation evaluates a boolean condition and returns one of two expressions based on the result: the "then" expression if the condition is True, or the "else" expression if the condition is False. This enables complex conditional logic within expressions.

The class manages three operands: the condition (which must evaluate to boolean), the "then" expression (evaluated when condition is True), and the "else" expression (evaluated when condition is False). Only one of the result expressions is evaluated, providing efficient conditional processing.

This class is used internally by the TFPExpressionParser class to construct an AST (Abstract Syntax Tree). There is normally no need for you to use or instantiate this class directly.

See also

TFPExprNode

  

Class for representing nodes in expression trees


Documentation generated on: Dec 15 2025