IronQuery
A SQL-first query builder for C++
Loading...
Searching...
No Matches
Public Member Functions | List of all members
iron_query::CaseBuilder Class Referencefinal

Transitional representation for CASE WHEN ... END. More...

#include <case_builder.hpp>

Public Member Functions

 CaseBuilder ()=default
 Starts an empty CASE expression; call When to add branches.
 
CaseBuilder When (Condition cond) &&
 Begins a new WHEN cond branch.
 
CaseBuilder Then (Expr result) &&
 Completes the pending branch as WHEN cond THEN result.
 
CaseBuilder Else (Expr result) &&
 Sets the ELSE result fallback branch.
 
Expr End () const
 Finalizes the expression as CASE ... [ELSE ...] END.
 

Detailed Description

Transitional representation for CASE WHEN ... END.

See also
https://www.postgresql.org/docs/current/sql-expressions.html#SQL-EXPRESSIONS-CASE

Member Function Documentation

◆ Else()

CaseBuilder iron_query::CaseBuilder::Else ( Expr  result) &&

Sets the ELSE result fallback branch.

Note
Does not check that all Then/Else branches of the same CASE share a compatible result type.

◆ End()

Expr iron_query::CaseBuilder::End ( ) const

Finalizes the expression as CASE ... [ELSE ...] END.

Exceptions
LogicErrorif no WHEN/THEN pair was added.

◆ Then()

CaseBuilder iron_query::CaseBuilder::Then ( Expr  result) &&

Completes the pending branch as WHEN cond THEN result.

Exceptions
LogicErrorif not preceded by When.
Note
Does not check that all Then/Else branches of the same CASE share a compatible result type.

◆ When()

CaseBuilder iron_query::CaseBuilder::When ( Condition  cond) &&

Begins a new WHEN cond branch.

Exceptions
LogicErrorif called twice in a row without a matching Then in between.

The documentation for this class was generated from the following file: