10#include <jaffarCommon/bitwise.hpp>
61 if (operation ==
"==")
return op_equal;
65 if (operation ==
"<")
return op_less;
72 JAFFAR_THROW_LOGIC(
"[Error] Unrecognized operator: '%s'. Valid operators are: ==, !=, >, >=, <, <=, %%0, %%N, BitTrue, BitFalse\n", operation.c_str());
135 return _opFcPtr(immediate1, immediate2);
140 static __INLINE__
bool _opEqual(
const T a,
const T b) {
return a == b; }
142 static __INLINE__
bool _opNotEqual(
const T a,
const T b) {
return a != b; }
144 static __INLINE__
bool _opGreater(
const T a,
const T b) {
return a > b; }
148 static __INLINE__
bool _opLess(
const T a,
const T b) {
return a < b; }
152 static __INLINE__
bool _opBitTrue(
const T a,
const T b) {
return jaffarCommon::bitwise::getBitFlag(a, b); }
154 static __INLINE__
bool _opBitFalse(
const T a,
const T b) {
return !jaffarCommon::bitwise::getBitFlag(a, b); }
156 static __INLINE__
bool _opModuloZero(
const T a,
const T b) {
return (uint64_t)a % (uint64_t)b == 0; }
158 static __INLINE__
bool _opModuloNonZero(
const T a,
const T b) {
return (uint64_t)a % (uint64_t)b > 0; }
Abstract base for a single boolean comparison.
virtual bool evaluate() const =0
Evaluates the condition against the current values of its operands.
const operator_t _opType
The comparison operator selected for this condition.
static operator_t getOperatorType(const std::string &operation)
Maps a configuration operator string to its operator_t value.
operator_t
The comparison operator applied between the condition's two operands.
@ op_bit_false
the bit of operand1 at index operand2 is clear (config operator "BitFalse")
@ op_equal
operand1 == operand2 (config operator "==")
@ op_bit_true
the bit of operand1 at index operand2 is set (config operator "BitTrue")
@ op_modulo_non_zero
operand1 % operand2 != 0 (config operator "%N")
@ op_not_equal
operand1 != operand2 (config operator "!=")
@ op_modulo_zero
operand1 % operand2 == 0 (config operator "%0")
@ op_greater
operand1 > operand2 (config operator ">")
@ op_less
operand1 < operand2 (config operator "<")
@ op_less_or_equal
operand1 <= operand2 (config operator "<=")
@ op_greater_or_equal
operand1 >= operand2 (config operator ">=")
Condition(const operator_t opType)
Constructs a condition with the given operator.
A named, typed reference to a value stored at a memory address.
T getValue() const
Reads the property's value at its memory address as type T, applying endianness conversion.
Concrete, type-specialized condition over operands of type T.
_vCondition(const operator_t opType, Property *property1, Property *property2, T immediate1, T immediate2)
Builds a typed condition from its operands.
const T _immediate2
Second operand's immediate value (used when _property2 is null).
static bool _opLessOrEqual(const T a, const T b)
Returns a <= b.
static bool _opBitTrue(const T a, const T b)
Returns true if the bit of a at index b is set.
static bool _opGreaterOrEqual(const T a, const T b)
Returns a >= b.
static bool _opModuloNonZero(const T a, const T b)
Returns true if a % b != 0.
const T _immediate1
First operand's immediate value (used when _property1 is null).
Property *const _property2
Second operand as a property, or nullptr to use _immediate2.
static bool _opLess(const T a, const T b)
Returns a < b.
Property *const _property1
First operand as a property, or nullptr to use _immediate1.
static bool _opGreater(const T a, const T b)
Returns a > b.
bool(* _opFcPtr)(const T, const T)
Resolved operator implementation, selected once at construction from _opType.
static bool _opBitFalse(const T a, const T b)
Returns true if the bit of a at index b is clear.
static bool _opEqual(const T a, const T b)
Returns a == b.
bool evaluate() const
Evaluates the comparison using the operands' current values.
static bool _opNotEqual(const T a, const T b)
Returns a != b.
static bool _opModuloZero(const T a, const T b)
Returns true if a % b == 0.
A named, typed view into a region of game memory, with datatype and endianness handling and a templat...