serialization.h
| File Path | engine/include/conjure/ecs/serialization.h |
| API ↗ | Archives and serialisation |
Serialisation.
Structs
| File | Description |
|---|---|
unresolved_component |
One component of an unknown type kept verbatim through a load/save round trip. |
unresolved_components |
The built-in component (id 0, EDITOR_HIDDEN, non-trivial) every registry registers so unknown component names on load are preserved and written back unchanged. |
Forward Declarations
component_registry
entity_archive
world
Constants
| Name | Type | Value | Description |
|---|---|---|---|
UNRESOLVED_COMPONENTS_NAME |
inline constexpr std:: |
"conjure.ecs.unresolved_ |
Registered name of the unresolved_components component. |
Functions
Public
component_from_json
component_from_json[[nodiscard]] CONJURE_API core::result<void> component_from_json(
world &target,
entity owner,
component_id id,
const core::json::value &in);Updates the live component id of owner from JSON (missing members keep their value) and stamps its column version. Same lookup errors as component_to_json; SERIALIZATION_FAILED with the field path for malformed input.
component_to_json
component_to_json[[nodiscard]] CONJURE_API core::result<void> component_to_json(
const world &source,
entity target,
component_id id,
core::json::writer &out);Serialises the live component id of target with its serializer (editor inspector and AI protocol). Entity references are written as {"external":"<index>:<generation>"}. ENTITY_NOT_ALIVE / COMPONENT_NOT_PRESENT / UNKNOWN_COMPONENT when the component cannot be found.
detail::read_reflected_component
detail::read_reflected_component[[nodiscard]] CONJURE_API core::result<void> read_reflected_component( const core::reflect::type_info &type, void *component, const core::json::value &in );Reads a reflected component from a JSON object; missing members keep their value. Errors name the field path.
detail::read_typed_component
detail::read_typed_componenttemplate <typename ComponentType> [[nodiscard]] core::result<void> read_typed_component(void *component, const core::json::value &in);detail::read_unresolved_components
detail::read_unresolved_components[[nodiscard]] CONJURE_API core::result<void> read_unresolved_components( void *component, const core::json::value &in );detail::remap_reflected_entities
detail::remap_reflected_entitiesCONJURE_API void remap_reflected_entities( const core::reflect::type_info &type, void *component, const entity_remap &map );Rewrites every entity field a reflected type contains through the remap table.
detail::remap_typed_component
detail::remap_typed_componenttemplate <typename ComponentType> void remap_typed_component(void *component, const entity_remap &map);detail::write_reflected_component
detail::write_reflected_component[[nodiscard]] CONJURE_API core::result<void> write_reflected_component( const core::reflect::type_info &type, const void *component, core::json::writer &out );Writes a reflected component as a JSON object using the archive encoding for entity and asset reference fields.
detail::write_typed_component
detail::write_typed_componenttemplate <typename ComponentType> [[nodiscard]] core::result<void> write_typed_component(const void *component, core::json::writer &out);detail::write_unresolved_components
detail::write_unresolved_components[[nodiscard]] CONJURE_API core::result<void> write_unresolved_components( const void *component, core::json::writer &out );Serializer hooks of the unresolved_components component: an object mapping each preserved name to its verbatim JSON.
make_default_serializer
make_default_serializertemplate <typename ComponentType> [[nodiscard]] component_serializer make_default_serializer() noexcept;The reflection-driven serializer of a CONJURE_REFLECT_STRUCT component type. Types without a description get hooks that fail with INVALID_STATE.
read_archive_json
read_archive_json[[nodiscard]] CONJURE_API core::result<entity_archive> read_archive_json(
const core::json::value &in,
const component_registry ®istry);Parses an archive written by write_archive_json. Unknown component names are preserved in an unresolved_components component (one INFO log each); malformed component JSON fails the whole load with SERIALIZATION_FAILED and an "<entity index>/<component>/<field>" path; an entity reference outside the archive fails with ARCHIVE_CORRUPT.
read_component_json
read_component_json[[nodiscard]] CONJURE_API core::result<void> read_component_json(
const component_info &info,
void *component,
const core::json::value &in);Reads one component instance through the type's serializer. SERIALIZATION_FAILED with the failing field path when the JSON does not match the type.
write_archive_json
write_archive_json[[nodiscard]] CONJURE_API core::result<void> write_archive_json(
const entity_archive &archive,
core::json::writer &out);Emits {"entities":[{"components":{"<name>":{...}}}]} for the archive, entities in archive order and each entity's component keys sorted by name (byte order of the UTF-8 text), so two registries that assigned the ids in different orders write the same text. Unresolved components are re-emitted verbatim under their original names, in the same sorted order, except a preserved entry whose name now resolves to a (non-transient) component the entity holds: it is dropped in favour of that component, so the name is written once. ARCHIVE_CORRUPT for an unregistered component id, or the component serializer's error. On failure the writer holds partial, unbalanced output; reset() or discard it before reuse.
write_component_json
write_component_json[[nodiscard]] CONJURE_API core::result<void> write_component_json(
const component_info &info,
const void *component,
core::json::writer &out);Writes one component instance through the type's serializer (custom hooks, else the reflection walker, else the unresolved_components encoding). SERIALIZATION_FAILED when the type cannot be serialised; TRANSIENT types write an empty object.