Expressions¶
-
class Expression¶
A server side expression.
-
static Expression constant_double(Client &connection, double value)¶
A constant value of double precision floating point type.
- Parameters:
-
static Expression constant_float(Client &connection, float value)¶
A constant value of single precision floating point type.
- Parameters:
-
static Expression constant_int(Client &connection, int32_t value)¶
A constant value of integer type.
- Parameters:
-
static Expression constant_bool(Client &connection, bool value)¶
A constant value of boolean type.
- Parameters:
-
static Expression constant_string(Client &connection, std::string value)¶
A constant value of string type.
- Parameters:
-
static Expression call(Client &connection, krpc::schema::ProcedureCall call)¶
An RPC call.
- Parameters:
-
static Expression equal(Client &connection, Expression arg0, Expression arg1)¶
Equality comparison.
- Parameters:
-
static Expression not_equal(Client &connection, Expression arg0, Expression arg1)¶
Inequality comparison.
- Parameters:
-
static Expression greater_than(Client &connection, Expression arg0, Expression arg1)¶
Greater than numerical comparison.
- Parameters:
-
static Expression greater_than_or_equal(Client &connection, Expression arg0, Expression arg1)¶
Greater than or equal numerical comparison.
- Parameters:
-
static Expression less_than(Client &connection, Expression arg0, Expression arg1)¶
Less than numerical comparison.
- Parameters:
-
static Expression less_than_or_equal(Client &connection, Expression arg0, Expression arg1)¶
Less than or equal numerical comparison.
- Parameters:
-
static Expression and__(Client &connection, Expression arg0, Expression arg1)¶
Boolean and operator.
- Parameters:
-
static Expression or__(Client &connection, Expression arg0, Expression arg1)¶
Boolean or operator.
- Parameters:
-
static Expression exclusive_or(Client &connection, Expression arg0, Expression arg1)¶
Boolean exclusive-or operator.
- Parameters:
-
static Expression not__(Client &connection, Expression arg)¶
Boolean negation operator.
- Parameters:
-
static Expression add(Client &connection, Expression arg0, Expression arg1)¶
Numerical addition.
- Parameters:
-
static Expression subtract(Client &connection, Expression arg0, Expression arg1)¶
Numerical subtraction.
- Parameters:
-
static Expression multiply(Client &connection, Expression arg0, Expression arg1)¶
Numerical multiplication.
- Parameters:
-
static Expression divide(Client &connection, Expression arg0, Expression arg1)¶
Numerical division.
- Parameters:
-
static Expression modulo(Client &connection, Expression arg0, Expression arg1)¶
Numerical modulo operator.
- Parameters:
- Returns:
The remainder of arg0 divided by arg1
-
static Expression power(Client &connection, Expression arg0, Expression arg1)¶
Numerical power operator.
- Parameters:
- Returns:
arg0 raised to the power of arg1, with type of arg0
-
static Expression left_shift(Client &connection, Expression arg0, Expression arg1)¶
Bitwise left shift.
- Parameters:
-
static Expression right_shift(Client &connection, Expression arg0, Expression arg1)¶
Bitwise right shift.
- Parameters:
-
static Expression cast(Client &connection, Expression arg, Type type)¶
Perform a cast to the given type.
- Parameters:
type – Type to cast the argument to.
-
static Expression parameter(Client &connection, std::string name, Type type)¶
A named parameter of type double.
- Parameters:
name – The name of the parameter.
type – The type of the parameter.
- Returns:
A named parameter.
-
static Expression function(Client &connection, std::vector<Expression> parameters, Expression body)¶
A function.
- Parameters:
parameters – The parameters of the function.
body – The body of the function.
- Returns:
A function.
-
static Expression invoke(Client &connection, Expression function, std::map<std::string, Expression> args)¶
A function call.
- Parameters:
function – The function to call.
args – The arguments to call the function with.
- Returns:
A function call.
-
static Expression create_tuple(Client &connection, std::vector<Expression> elements)¶
Construct a tuple.
- Parameters:
elements – The elements.
- Returns:
The tuple.
-
static Expression create_list(Client &connection, std::vector<Expression> values)¶
Construct a list.
- Parameters:
values – The value. Should all be of the same type.
- Returns:
The list.
-
static Expression create_set(Client &connection, std::set<Expression> values)¶
Construct a set.
- Parameters:
values – The values. Should all be of the same type.
- Returns:
The set.
-
static Expression create_dictionary(Client &connection, std::vector<Expression> keys, std::vector<Expression> values)¶
Construct a dictionary, from a list of corresponding keys and values.
- Parameters:
keys – The keys. Should all be of the same type.
values – The values. Should all be of the same type.
- Returns:
The dictionary.
-
static Expression to_list(Client &connection, Expression arg)¶
Convert a collection to a list.
- Parameters:
arg – The collection.
- Returns:
The collection as a list.
-
static Expression to_set(Client &connection, Expression arg)¶
Convert a collection to a set.
- Parameters:
arg – The collection.
- Returns:
The collection as a set.
-
static Expression get(Client &connection, Expression arg, Expression index)¶
Access an element in a tuple, list or dictionary.
- Parameters:
arg – The tuple, list or dictionary.
index – The index of the element to access. A zero indexed integer for a tuple or list, or a key for a dictionary.
- Returns:
The element.
-
static Expression count(Client &connection, Expression arg)¶
Number of elements in a collection.
- Parameters:
arg – The list, set or dictionary.
- Returns:
The number of elements in the collection.
-
static Expression sum(Client &connection, Expression arg)¶
Sum all elements of a collection.
- Parameters:
arg – The list or set.
- Returns:
The sum of the elements in the collection.
-
static Expression max(Client &connection, Expression arg)¶
Maximum of all elements in a collection.
- Parameters:
arg – The list or set.
- Returns:
The maximum elements in the collection.
-
static Expression min(Client &connection, Expression arg)¶
Minimum of all elements in a collection.
- Parameters:
arg – The list or set.
- Returns:
The minimum elements in the collection.
-
static Expression average(Client &connection, Expression arg)¶
Minimum of all elements in a collection.
- Parameters:
arg – The list or set.
- Returns:
The minimum elements in the collection.
-
static Expression select(Client &connection, Expression arg, Expression func)¶
Run a function on every element in the collection.
- Parameters:
arg – The list or set.
func – The function.
- Returns:
The modified collection.
-
static Expression where(Client &connection, Expression arg, Expression func)¶
Run a function on every element in the collection.
- Parameters:
arg – The list or set.
func – The function.
- Returns:
The modified collection.
-
static Expression contains(Client &connection, Expression arg, Expression value)¶
Determine if a collection contains a value.
- Parameters:
arg – The collection.
value – The value to look for.
- Returns:
Whether the collection contains a value.
-
static Expression aggregate(Client &connection, Expression arg, Expression func)¶
Applies an accumulator function over a sequence.
- Parameters:
arg – The collection.
func – The accumulator function.
- Returns:
The accumulated value.
-
static Expression aggregate_with_seed(Client &connection, Expression arg, Expression seed, Expression func)¶
Applies an accumulator function over a sequence, with a given seed.
- Parameters:
arg – The collection.
seed – The seed value.
func – The accumulator function.
- Returns:
The accumulated value.
-
static Expression concat(Client &connection, Expression arg1, Expression arg2)¶
Concatenate two sequences.
- Parameters:
arg1 – The first sequence.
arg2 – The second sequence.
- Returns:
The first sequence followed by the second sequence.
-
static Expression order_by(Client &connection, Expression arg, Expression key)¶
Order a collection using a key function.
- Parameters:
arg – The collection to order.
key – A function that takes a value from the collection and generates a key to sort on.
- Returns:
The ordered collection.
-
static Expression all(Client &connection, Expression arg, Expression predicate)¶
Determine whether all items in a collection satisfy a boolean predicate.
- Parameters:
arg – The collection.
predicate – The predicate function.
- Returns:
Whether all items satisfy the predicate.
-
static Expression any(Client &connection, Expression arg, Expression predicate)¶
Determine whether any item in a collection satisfies a boolean predicate.
- Parameters:
arg – The collection.
predicate – The predicate function.
- Returns:
Whether any item satisfies the predicate.
-
static Expression constant_double(Client &connection, double value)¶