Engine → Scripting → script_fields.h
field_blob_writer¶
| Type | Class |
| Namespace | conjure::scripting |
| Include File Path | engine/include/conjure/scripting/script_fields.h |
| Source File Path | engine/src/scripting/script_fields.cpp |
| API ↗ | Scripting, Scripts, components and the runtime |
Syntax¶
Constructors¶
| Access | Signature | Description |
|---|---|---|
| public | explicit field_blob_writer(
std::span<u8> output) noexcept; | Writes into output; an empty span measures (required_size() reports what a real pass needs). Every write past the end sets overflowed() and keeps counting bytes. |
Important
Copy constructor and assignment has been deleted.
Destructors¶
| Access | Signature | Description |
|---|---|---|
| public | ~field_blob_writer(); |
Variables¶
| Access | Name | Type | Default | Description |
|---|---|---|---|---|
| private | mBegun | bool | false | |
| private | mCursor | usize | 0 | |
| private | mFieldCount | u32 | 0 | |
| private | mFieldOpen | bool | false | |
| private | m | usize | 0 | |
| private | m | usize | 0 | |
| private | mOutput | std::span<u8> | {} | |
| private | mOverflowed | bool | false |
Functions¶
Public¶
begin_field¶
begin_field¶void begin_field(
u64 hash,
script_field_kind kind,
script_field_kind elementKind);Starts a field whose payload is written piecewise through the raw helpers; end_field() patches the payload size. Nested begin_field is not allowed.
end_field¶
end_field¶void end_field();finish¶
finish¶[[nodiscard]] usize finish();Patches the field count and returns the bytes the blob needs. When that is more than the output size (overflowed()), the output is NOT a valid blob: the header counts every field while the bytes stop at the overflow, possibly inside a field header, so field_blob_reader rejects it. Retry with an output of the returned size (the measure-then-write idiom json_to_blob uses).
overflowed¶
overflowed¶[[nodiscard]] bool overflowed() const noexcept;pad_to_4¶
pad_to_4¶void pad_to_4();write_asset¶
write_asset¶void write_asset(
u64 hash,
const core::uuid &value);write_entity¶
write_entity¶void write_entity(
u64 hash,
ecs::entity value);write_field¶
write_field¶void write_field(
u64 hash,
script_field_kind kind,
script_field_kind elementKind,
std::span<const u8> payload);Writes one field header plus payload, padded to 4 bytes.
write_floats¶
write_floats¶void write_floats(
u64 hash,
script_field_kind kind,
std::span<const f32> values);write_int32¶
write_int32¶void write_int32(
u64 hash,
i32 value,
script_field_kind kind = script_field_kind::INT32);