GGExpr class
#include <GGUI/Public/Binding.h>
GGExpr: a value computed from fields and constants.
Stored as a short postfix program: trivially copyable, comparable, no allocation. An expression that overflows MaxOps is invalid (IsValid) and evaluates to 0.
Public static variables
- static uint32_t MaxOps constexpr
- the most steps an expression has: constants, fields, and operations
Public static functions
Constructors, destructors, conversion operators
Public functions
- auto IsValid() const -> bool
- Whether it computes something: not empty, and within MaxOps.
- auto Evaluate(const BindingReader& reader, BindTarget target, bool& bValid) const -> float
- Its value for
target.bValidis false if a field couldn't be read. - auto IsOneField(FieldID& field) const -> bool
- True if the expression is exactly one field;
fieldreceives it. -
template<typename TFn>void ForEachField(TFn&& fn) const
fn(field)for each field it reads, in order, repeats included.
Friends
- auto operator+(const GGExpr& a, const GGExpr& b) -> GGExpr
aplusb.- auto operator-(const GGExpr& a, const GGExpr& b) -> GGExpr
aminusb.- auto operator*(const GGExpr& a, const GGExpr& b) -> GGExpr
atimesb.- auto operator/(const GGExpr& a, const GGExpr& b) -> GGExpr
aoverb.- auto operator<(const GGExpr& a, const GGExpr& b) -> GGExpr
- 1 if
ais less thanb, else 0. - auto operator>(const GGExpr& a, const GGExpr& b) -> GGExpr
- 1 if
ais more thanb, else 0. - auto operator<=(const GGExpr& a, const GGExpr& b) -> GGExpr
- 1 if
ais at mostb, else 0. - auto operator>=(const GGExpr& a, const GGExpr& b) -> GGExpr
- 1 if
ais at leastb, else 0. - auto Min(const GGExpr& a, const GGExpr& b) -> GGExpr
- The smaller of
aandb. - auto Max(const GGExpr& a, const GGExpr& b) -> GGExpr
- The larger of
aandb. - auto Clamp(const GGExpr& x, const GGExpr& low, const GGExpr& high) -> GGExpr
xkept betweenlowandhigh.- auto Normalize(const GGExpr& x, const GGExpr& low, const GGExpr& high) -> GGExpr
- Position of
xbetweenlowandhigh, as 0..1. - auto Lerp(const GGExpr& a, const GGExpr& b, const GGExpr& t) -> GGExpr
aatt0,batt1, and in between on a line.- auto Select(const GGExpr& condition, const GGExpr& whenTrue, const GGExpr& whenFalse) -> GGExpr
whenTrueifconditionis non-zero.- auto operator==(const GGExpr& a, const GGExpr& b) -> bool
- Program equality. Bindings with equal expressions and targets are the same binding.