Next: , Up: serialiser   [Contents][Index]


6.1 serialiser trait: type definitions

Struct Typedef: ccstructs_serialiser_T

Type of the serialiser trait. Instances of this type are meant to be handed by value to function calls.

Struct Typedef: ccname_trait_table_type(ccstructs_serialiser_T)

Type of methods table for the serialiser trait. It has the following fields:

ccname_trait_method_type(ccstructs_serialiser_T, required_size) * required_size

Pointer to function implementing the required_size() method.

ccname_trait_method_type(ccstructs_serialiser_T, write) * write

Pointer to function implementing the write() method.

Function Prototype: size_t ccname_trait_method_type(ccstructs_serialiser_T, required_size) (ccstructs_serialiser_T const I)

Type of functions implementing the required_size() method. Return the minimum number of bytes needed to hold the serialisation of the source struct; we should use the returned number to allocate a block of memory for the serialisation operation; it is possible that the actual serialisation will consume less memory.

Function Prototype: ccmem_block_t ccname_trait_method_type(ccstructs_serialiser_T, write) (cce_destination_t L, ccstructs_serialiser_T const I, ccmem_block_t B)

Type of functions implementing the write() method. Serialise the struct to the block of memory referenced by B, which must be big enough to hold the number of bytes returned by the method required_size().

When successful: return a new block referencing the leftover memory right after the serialised data. If an error occurs: raise an exception violation by performing a non–local exit to L; in this case there is no way to know the state of the data written on the output block B.

     memory block described by B
|-------------------------------------|
|++++++++++++++++++++++++|------------|
   memory filled with       leftover
   struct serialisation     memory

Next: , Up: serialiser   [Contents][Index]

This document describes version 0.3.0-devel.3 of CCStructs.