Represents a generic function. More...
Public Types | |
enum | Type { TypeInvalid, TypeInfixFunction, TypePredicateFunction, TypePrefixFunction } |
Public Member Functions | |
Function () | |
Constructs an invalid Function. | |
Type | functionType () const |
Returns the type of the Function. | |
void | setParameters (const ValueChain ¶meters) |
Replaces the function parameters with the contents of parameters . | |
ValueChain | parameters () const |
Returns the currently set parameters. | |
Protected Member Functions | |
Function (FunctionData *data) | |
const FunctionData * | data () const |
FunctionData * | data () |
Represents a generic function.
The Function class is very versatile in Cubi. It can be used for predicate functions in a projection, as an operator ("=" is an infix function with two parameters), or as a normal function in a FILTER
block.
Generally speaking, Function represents a n-ary operator (but it's not as scary as it looks).
The Function class also holds the function parameters' values, that is why apply() also returns a Function. If you have a PrefixFunction f
, and call f.apply(2)
, you get f(2)
, which is also a function. You could then call PrefixFunction::apply() again with the value 3, and you would get f(2, 3)
.
You will never use the Function class directly, but rather one of its subclasses.
ValueChain Function::parameters | ( | ) | const |
Returns the currently set parameters.
Note that the lib does not do any check on the number of parameters, you just add as many parameters as you want.