JaffarPlus
High-performance best-first search optimizer for tool-assisted speedruns
Loading...
Searching...
No Matches
jaffarPlus::Property Class Reference

A named, typed reference to a value stored at a memory address. More...

#include <property.hpp>

Public Types

enum  datatype_t {
  dt_uint8 , dt_uint16 , dt_uint32 , dt_uint64 ,
  dt_int8 , dt_int16 , dt_int32 , dt_int64 ,
  dt_bool , dt_float32 , dt_float64
}
 The interpretation of the bytes at the property's memory address. More...
 
enum  endianness_t { little , big }
 The byte order of the value stored at the property's memory address. More...
 

Public Member Functions

 Property ()=delete
 Default construction is disabled; a property requires a name, pointer, datatype and endianness.
 
 Property (const std::string &name, void *const pointer, const datatype_t datatype, endianness_t endianness)
 Constructs a property describing a value in memory.
 
size_t getSize () const
 Returns the size in bytes of the property's value.
 
template<typename T >
getValue () const
 Reads the property's value at its memory address as type T, applying endianness conversion.
 
datatype_t getDatatype () const
 Returns the property's datatype.
 
std::string getName () const
 Returns the property's name.
 
jaffarCommon::hash::hash_t getNameHash () const
 Returns the hash of the property's name.
 
void * getPointer () const
 Returns the raw pointer to the property's value in memory.
 

Static Public Member Functions

static endianness_t parseEndiannessName (const std::string &endiannessName)
 Maps a configuration endianness string to its endianness_t value.
 
static datatype_t parseDatatypeName (const std::string &datatypeName)
 Maps a configuration datatype string to its datatype_t value.
 
static size_t getDatatypeSize (const datatype_t datatype)
 Returns the size in bytes of a given datatype.
 

Private Attributes

const std::string _name
 Identifying name of the property.
 
void *const _pointer
 Pointer to the property's value in game memory.
 
const datatype_t _datatype
 How the bytes at _pointer are interpreted.
 
const endianness_t _endianness
 Byte order of the value at _pointer.
 
const jaffarCommon::hash::hash_t _nameHash
 Precomputed hash of _name for fast lookup.
 

Detailed Description

A named, typed reference to a value stored at a memory address.

A property pairs a name with a raw pointer into game memory, a datatype describing how the bytes at that address are interpreted, and an endianness describing their byte order. Conditions and other engine components read the live value through getValue.

Definition at line 24 of file property.hpp.

Member Enumeration Documentation

◆ datatype_t

The interpretation of the bytes at the property's memory address.

Enumerator
dt_uint8 

Unsigned 8-bit integer (config datatype "UINT8").

dt_uint16 

Unsigned 16-bit integer (config datatype "UINT16").

dt_uint32 

Unsigned 32-bit integer (config datatype "UINT32").

dt_uint64 

Unsigned 64-bit integer (config datatype "UINT64").

dt_int8 

Signed 8-bit integer (config datatype "INT8").

dt_int16 

Signed 16-bit integer (config datatype "INT16").

dt_int32 

Signed 32-bit integer (config datatype "INT32").

dt_int64 

Signed 64-bit integer (config datatype "INT64").

dt_bool 

Boolean stored in a single byte (config datatype "BOOL").

dt_float32 

Single precision float, 32-bit (config datatype "FLOAT32").

dt_float64 

Double precision float, 64-bit (config datatype "FLOAT64").

Definition at line 28 of file property.hpp.

◆ endianness_t

The byte order of the value stored at the property's memory address.

Enumerator
little 

Little endian byte order (config endianness "Little").

big 

Big endian byte order (config endianness "Big").

Definition at line 44 of file property.hpp.

Constructor & Destructor Documentation

◆ Property()

jaffarPlus::Property::Property ( const std::string &  name,
void *const  pointer,
const datatype_t  datatype,
endianness_t  endianness 
)
inline

Constructs a property describing a value in memory.

Parameters
nameIdentifying name for the property; also hashed for fast lookup.
pointerPointer to the bytes in game memory this property refers to.
datatypeHow the bytes at pointer are interpreted.
endiannessByte order of the value at pointer.

Definition at line 60 of file property.hpp.

Member Function Documentation

◆ getDatatype()

datatype_t jaffarPlus::Property::getDatatype ( ) const
inline

Returns the property's datatype.

Definition at line 186 of file property.hpp.

◆ getDatatypeSize()

static size_t jaffarPlus::Property::getDatatypeSize ( const datatype_t  datatype)
inlinestatic

Returns the size in bytes of a given datatype.

Parameters
datatypeThe datatype to measure.
Returns
The byte size of datatype.
Exceptions
Alogic error if the datatype is not recognized.

Definition at line 114 of file property.hpp.

◆ getName()

std::string jaffarPlus::Property::getName ( ) const
inline

Returns the property's name.

Definition at line 188 of file property.hpp.

◆ getNameHash()

jaffarCommon::hash::hash_t jaffarPlus::Property::getNameHash ( ) const
inline

Returns the hash of the property's name.

Definition at line 190 of file property.hpp.

◆ getPointer()

void * jaffarPlus::Property::getPointer ( ) const
inline

Returns the raw pointer to the property's value in memory.

Definition at line 192 of file property.hpp.

◆ getSize()

size_t jaffarPlus::Property::getSize ( ) const
inline

Returns the size in bytes of the property's value.

Returns
The byte size of the property's datatype.

Definition at line 69 of file property.hpp.

◆ getValue()

template<typename T >
T jaffarPlus::Property::getValue ( ) const
inline

Reads the property's value at its memory address as type T, applying endianness conversion.

When the property is little endian the bytes are returned as-is. When it is big endian the bytes are reversed into the returned value.

Template Parameters
TThe type to read the value as; its size must match the property's datatype size.
Returns
The value at the property's pointer, interpreted as T.
Exceptions
Alogic error if sizeof(T) does not match the property's datatype size.

Definition at line 144 of file property.hpp.

◆ parseDatatypeName()

static datatype_t jaffarPlus::Property::parseDatatypeName ( const std::string &  datatypeName)
inlinestatic

Maps a configuration datatype string to its datatype_t value.

Parameters
datatypeNameThe datatype token from the config (e.g. "UINT8", "INT32", "BOOL", "FLOAT64").
Returns
The matching datatype enum value.
Exceptions
Alogic error if the token is not recognized.

Definition at line 91 of file property.hpp.

◆ parseEndiannessName()

static endianness_t jaffarPlus::Property::parseEndiannessName ( const std::string &  endiannessName)
inlinestatic

Maps a configuration endianness string to its endianness_t value.

Parameters
endiannessNameThe endianness token from the config ("Little" or "Big").
Returns
The matching endianness enum value.
Exceptions
Alogic error if the token is not recognized.

Definition at line 77 of file property.hpp.

Member Data Documentation

◆ _datatype

const datatype_t jaffarPlus::Property::_datatype
private

How the bytes at _pointer are interpreted.

Definition at line 197 of file property.hpp.

◆ _endianness

const endianness_t jaffarPlus::Property::_endianness
private

Byte order of the value at _pointer.

Definition at line 198 of file property.hpp.

◆ _name

const std::string jaffarPlus::Property::_name
private

Identifying name of the property.

Definition at line 195 of file property.hpp.

◆ _nameHash

const jaffarCommon::hash::hash_t jaffarPlus::Property::_nameHash
private

Precomputed hash of _name for fast lookup.

Definition at line 199 of file property.hpp.

◆ _pointer

void* const jaffarPlus::Property::_pointer
private

Pointer to the property's value in game memory.

Definition at line 196 of file property.hpp.


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