![]() |
Gaia-ECS v0.9.3
A simple and powerful entity component system
|
Stack-only cursor over raw component bytes and runtime field metadata. More...
#include <component_cursor.h>
Public Member Functions | |
| ComponentCursor ()=default | |
| Creates an invalid cursor. | |
| GAIA_NODISCARD bool | valid () const noexcept |
| GAIA_NODISCARD uint32_t | depth () const noexcept |
| GAIA_NODISCARD Entity | type () const noexcept |
| GAIA_NODISCARD uint32_t | size () const noexcept |
| GAIA_NODISCARD const void * | ptr () const noexcept |
| GAIA_NODISCARD void * | mut_ptr () const noexcept |
| GAIA_NODISCARD uint32_t | field_count () const |
| bool | field (uint32_t index) |
| Descends into the reflected field at index. | |
| bool | field (util::str_view name) |
| Descends into the reflected field named name. | |
| bool | parent () noexcept |
| Moves back to the parent cursor scope. | |
| GAIA_NODISCARD bool | get_f32 (float *value) const noexcept |
| Reads the current cursor bytes as a scalar f32 convenience value. | |
| ComponentWriteResult | write_bytes (const void *data, uint32_t byteCount) noexcept |
| Writes exact bytes to the current cursor position. | |
Static Public Member Functions | |
| static GAIA_NODISCARD ComponentCursor | from_raw (const ComponentCache &components, Entity component, ComponentRawView view) |
| Creates a read-only cursor from a raw component view. | |
| static GAIA_NODISCARD ComponentCursor | from_raw (World &world, const ComponentCache &components, Entity entity, Entity component, ComponentRawMutView view) |
| Creates a mutable cursor from a raw component view. | |
Static Public Attributes | |
| static constexpr uint32_t | MaxDepth = 32 |
| Maximum nested field depth tracked by the cursor. | |
Stack-only cursor over raw component bytes and runtime field metadata.
The cursor is a short-lived non-owning view. It never owns component bytes or metadata and is invalidated by structural changes that can move component storage. Field navigation is strict: missing fields, unsupported type metadata, and out-of-bounds field ranges leave the cursor unchanged.
|
inlinenoexcept |
|
inline |
Descends into the reflected field at index.
| index | Reflected field index on the current type. |
|
inline |
Descends into the reflected field named name.
| name | Reflected field name on the current type. |
|
inline |
|
inlinestatic |
Creates a read-only cursor from a raw component view.
| components | Component metadata registry used for field/type lookup. |
| component | Component/type entity represented by view. |
| view | Raw component view returned by World::get_raw(). |
|
inlinestatic |
Creates a mutable cursor from a raw component view.
| world | World owning the mutated chunk storage. |
| components | Component metadata registry used for field/type lookup. |
| entity | Entity whose component payload is represented by view. |
| component | Component/type entity represented by view. |
| view | Raw component view returned by World::mut_raw(). |
|
inlinenoexcept |
Reads the current cursor bytes as a scalar f32 convenience value.
| value | Receives the read value. |
|
inlinenoexcept |
|
inlinenoexcept |
Moves back to the parent cursor scope.
|
inlinenoexcept |
|
inlinenoexcept |
|
inlinenoexcept |
|
inlinenoexcept |
|
inlinenoexcept |
Writes exact bytes to the current cursor position.
This is the cursor write path for runtime component data. It performs no type conversion and requires byteCount to match the current cursor scope size. Use field navigation to choose the address being written. Successful writes finish the root component write, so normal chunk write tracking and OnSet observers run.
| data | Bytes to copy. Must be non-null when byteCount is non-zero. |
| byteCount | Number of bytes to copy. Returns Ok when bytes were copied, otherwise the reason the write failed. |