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


7.1 deserialiser trait: type definitions

Struct Typedef: ccstructs_deserialiser_T

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

Struct Typedef: ccname_trait_table_type(ccstructs_deserialiser_T)

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

ccname_trait_method_type(ccstructs_deserialiser_T, required_size) * required_size

Pointer to function implementing the required_size() method.

ccname_trait_method_type(ccstructs_deserialiser_T, read) * read

Pointer to function implementing the read() method.

Function Prototype: size_t ccname_trait_method_type(ccstructs_deserialiser_T, required_size) (ccstructs_deserialiser_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; it is possible that the actual serialisation has consumed less memory.

Example: let’s say we must read the serialised struct from a file, how many bytes do we need to read from the file to be sure to have it all? This function answers this question.

Function Prototype: ccmem_block_t ccname_trait_method_type(ccstructs_deserialiser_T, read) (cce_destination_t L, ccstructs_deserialiser_T const I, ccmem_block_t B)

Type of functions implementing the read() method. Deserialise the struct from the block of memory referenced by B, which must be big enough to hold the number of bytes returned by the method required_size(). Return a new block referencing the memory right after the deserialised data. If an error occurs: raise an exception violation by performing a non–local exit to L.


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

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