script_fields.h¶
| File Path | engine/include/conjure/scripting/script_fields.h |
| API ↗ | Scripting, Scripts, components and the runtime |
The field blob: the single wire format of apply_fields and collect_fields.
Structs¶
| File | Description |
|---|---|
field_blob_field |
One field as the reader yields it. The payload view points into the blob. |
Classes¶
| File | Description |
|---|---|
field_blob_reader |
|
field_blob_writer |
Constants¶
| Name | Type | Value | Description |
|---|---|---|---|
FIELD_BLOB_FIELD_HEADER_SIZE |
inline constexpr usize |
16 |
|
FIELD_BLOB_HEADER_SIZE |
inline constexpr usize |
8 |
|
FIELD_BLOB_MAGIC |
inline constexpr u32 |
0x42465343u |
|
FIELD_BLOB_VERSION |
inline constexpr u16 |
1 |
Functions¶
Public¶
blob_to_json¶
blob_to_json¶[[nodiscard]] CONJURE_API core::result<core::json::document> blob_to_json(
const script_class_info &classInfo,
std::span<const u8> blob);Decodes a blob into a JSON object keyed by field name. Fields whose hash the class does not know are skipped (counted in a DEBUG log). FIELD_BLOB_INVALID for a malformed blob.
entity_from_json¶
entity_from_json¶[[nodiscard]] CONJURE_API ecs::entity entity_from_json(
const core::json::value &value) noexcept;The JSON form of an entity reference in script fields: the packed id as a number (0 = null).
is_value_compatible¶
is_value_compatible¶[[nodiscard]] CONJURE_API bool is_value_compatible(
script_field_kind kind,
script_field_kind elementKind,
const core::json::value &value) noexcept;True when a JSON value can be encoded as this kind (number for INT32, array of 3 numbers for VEC3, ...). An invalid value is never compatible.
json_to_blob¶
json_to_blob¶[[nodiscard]] CONJURE_API core::result<usize> json_to_blob(
const script_class_info &classInfo,
const core::json::value &fields,
std::span<u8> output);Encodes the fields of a class from a JSON object into a blob. Missing or mismatched JSON members take the field default; JSON keys not in the schema are ignored (they stay in script_entry.fields). Returns the bytes needed; with an output that is too small the content is cut at the overflow and the caller retries with the returned size. Only a pass with a non-empty output warns about mismatched members, so the measure-then-write idiom reports each once.
read_field_value¶
read_field_value¶[[nodiscard]] CONJURE_API core::result<core::json::document> read_field_value(
const script_field_info &field,
std::span<const u8> payload);Decodes one payload into JSON. FIELD_BLOB_INVALID when the payload is too short or malformed.
remap_entity_fields_json¶
remap_entity_fields_json¶[[nodiscard]] CONJURE_API core::json::document remap_entity_fields_json(
const script_class_info &classInfo,
const core::json::value &fields,
const std::function<ecs::entity(ecs::entity)> &remap);Rewrites every ENTITY field and every element of a LIST of ENTITY in fields through remap and returns the result; members the schema does not know pass through unchanged.
write_field_value¶
write_field_value¶CONJURE_API void write_field_value(
field_blob_writer &writer,
const script_class_info &classInfo,
const script_field_info &field,
const core::json::value &value,
bool warnOnMismatch = true);Appends the payload of one value of field (default when value is invalid or mismatched, with a WARN naming the class and field unless warnOnMismatch is false) as one blob field.