Gaia-ECS v1.0.0
A simple and powerful entity component system
Loading...
Searching...
No Matches
gaia::ser::serializer Struct Reference

Runtime serializer type-erased handle. Traversal logic is shared with compile-time serialization, while raw I/O is delegated through function pointers bound to a concrete serializer instance. This is a binary traversal API. JSON document I/O uses ser::ser_json. More...

#include <ser_rt.h>

Public Member Functions

 serializer (const serializer_ctx &ctx)
 Creates a serializer from an existing callback context.
 
GAIA_NODISCARD bool valid () const
 Checks whether mandatory backend callbacks are bound.
 
template<typename T >
void save (const T &arg)
 Serializes a value through generic traversal.
 
template<typename T >
void load (T &arg)
 Deserializes a value through generic traversal.
 
template<typename T >
void save_raw (const T &value)
 Writes the object representation of a typed value.
 
template<typename T >
void load_raw (T &value)
 Reads an object representation into a typed value.
 
void save_raw (const void *src, uint32_t size, serialization_type_id id)
 Writes raw bytes through the bound backend.
 
void load_raw (void *src, uint32_t size, serialization_type_id id)
 Reads raw bytes through the bound backend.
 
GAIA_NODISCARD const char * data () const
 Returns the backend data pointer when exposed.
 
void reset ()
 Resets the backend when supported.
 
GAIA_NODISCARD uint32_t tell () const
 Returns the current backend cursor.
 
GAIA_NODISCARD uint32_t bytes () const
 Returns the backend byte count when exposed.
 
void seek (uint32_t pos)
 Moves the backend cursor.
 

Static Public Member Functions

template<typename TSerializer >
static serializer_ctx bind_ctx (TSerializer &obj)
 Creates a callback context bound to a concrete backend.
 
template<typename TSerializer >
static serializer bind (TSerializer &obj)
 Creates a runtime serializer bound to a concrete backend.
 

Public Attributes

serializer_ctx m_ctx {}
 Bound backend context and callback table.
 

Detailed Description

Runtime serializer type-erased handle. Traversal logic is shared with compile-time serialization, while raw I/O is delegated through function pointers bound to a concrete serializer instance. This is a binary traversal API. JSON document I/O uses ser::ser_json.

Constructor & Destructor Documentation

◆ serializer()

gaia::ser::serializer::serializer ( const serializer_ctx ctx)
inlineexplicit

Creates a serializer from an existing callback context.

Parameters
ctxBackend context to copy.

Member Function Documentation

◆ bind()

template<typename TSerializer >
static serializer gaia::ser::serializer::bind ( TSerializer &  obj)
inlinestatic

Creates a runtime serializer bound to a concrete backend.

Template Parameters
TSerializerBackend type.
Parameters
objBackend instance that must outlive the serializer.
Returns
Bound runtime serializer.

◆ bind_ctx()

template<typename TSerializer >
static serializer_ctx gaia::ser::serializer::bind_ctx ( TSerializer &  obj)
inlinestatic

Creates a callback context bound to a concrete backend.

Template Parameters
TSerializerBackend type.
Parameters
objBackend instance that must outlive the context.
Returns
Type-erased callback context.

◆ bytes()

GAIA_NODISCARD uint32_t gaia::ser::serializer::bytes ( ) const
inline

Returns the backend byte count when exposed.

Returns
Byte count, or zero when unsupported.

◆ data()

GAIA_NODISCARD const char * gaia::ser::serializer::data ( ) const
inline

Returns the backend data pointer when exposed.

Returns
Backing data pointer, or null when unsupported.

◆ load()

template<typename T >
void gaia::ser::serializer::load ( T &  arg)
inline

Deserializes a value through generic traversal.

Template Parameters
TValue type.
Parameters
[out]argDestination value.

◆ load_raw() [1/2]

template<typename T >
void gaia::ser::serializer::load_raw ( T &  value)
inline

Reads an object representation into a typed value.

Template Parameters
TValue type.
Parameters
[out]valueDestination value.

◆ load_raw() [2/2]

void gaia::ser::serializer::load_raw ( void *  src,
uint32_t  size,
serialization_type_id  id 
)
inline

Reads raw bytes through the bound backend.

Parameters
[out]srcDestination bytes.
sizeNumber of bytes.
idSerialization representation.

◆ save()

template<typename T >
void gaia::ser::serializer::save ( const T &  arg)
inline

Serializes a value through generic traversal.

Template Parameters
TValue type.
Parameters
argValue to serialize.

◆ save_raw() [1/2]

template<typename T >
void gaia::ser::serializer::save_raw ( const T &  value)
inline

Writes the object representation of a typed value.

Template Parameters
TValue type.
Parameters
valueValue to write.

◆ save_raw() [2/2]

void gaia::ser::serializer::save_raw ( const void *  src,
uint32_t  size,
serialization_type_id  id 
)
inline

Writes raw bytes through the bound backend.

Parameters
srcSource bytes.
sizeNumber of bytes.
idSerialization representation.

◆ seek()

void gaia::ser::serializer::seek ( uint32_t  pos)
inline

Moves the backend cursor.

Parameters
posAbsolute byte position.

◆ tell()

GAIA_NODISCARD uint32_t gaia::ser::serializer::tell ( ) const
inline

Returns the current backend cursor.

Returns
Cursor position in bytes.

◆ valid()

GAIA_NODISCARD bool gaia::ser::serializer::valid ( ) const
inline

Checks whether mandatory backend callbacks are bound.

Returns
True when save, load, tell, and seek are available.

The documentation for this struct was generated from the following file: