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_fieldvoid 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_fieldvoid end_field();field_count
field_count[[nodiscard]] u32 field_count() const noexcept;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_4void pad_to_4();required_size
required_size[[nodiscard]] usize required_size() const noexcept;write_asset
write_assetvoid write_asset(
u64 hash,
const core::uuid &value);write_bool
write_boolvoid write_bool(
u64 hash,
bool value);write_bytes
write_bytesvoid write_bytes(
std::span<const u8> bytes);write_entity
write_entityvoid write_entity(
u64 hash,
ecs::entity value);write_field
write_fieldvoid 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_floatsvoid write_floats(
u64 hash,
script_field_kind kind,
std::span<const f32> values);write_int32
write_int32void write_int32(
u64 hash,
i32 value,
script_field_kind kind = script_field_kind::INT32);write_string
write_stringvoid write_string(
u64 hash,
std::string_view value);write_u32
write_u32void write_u32(
u32 value);Private
put
putvoid put(
const void *data,
usize size);