Skip to content

TIfOperation

Internally used class for conditional if-then-else operations

Declaration

Source position: fpexprpars.pp line 260

type

  TIfOperation = class(TFPBinaryOperation)
  public
    procedure Check;
    procedure InitAggregate;
    procedure UpdateAggregate;
    function HasAggregate : Boolean;
    function NodeType : TResultType;
    constructor Create;
    destructor destroy;
    function AsString : AnsiString;
    property Condition: TFPExprNode; {r}
  end;

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.

Properties

Member Visibility Description
Condition read only public The condition expression of the if operation
See all Properties

Methods

Member Visibility Description
AsString public Get string representation of conditional operation
Check public Validate the conditional operation for correctness
Create public Create conditional operation with condition and branches
destroy public Destroy conditional operation and free resources
HasAggregate public Check if conditional operation contains aggregates
InitAggregate public Initialize aggregate processing for if operation
NodeType public Get the result type for conditional operation
UpdateAggregate public Update aggregate calculations for if operation
See all Methods

See also

Name Description
TFPExprNode Class for representing nodes in expression trees