libsxbp  v0.27
Experimental generation of 2D spiralling lines based on input binary data.
Data Structures | Typedefs | Enumerations | Functions | Variables
serialise.h File Reference

This compilation unit provides functions for serialising spirals to and from byte sequences (which may be stored in files or any other form). More...

#include <stddef.h>
#include "saxbospiral.h"
Include dependency graph for serialise.h:

Go to the source code of this file.

Data Structures

struct  sxbp_serialise_result_t
 Stores both generic and serialisation-specific error information. More...
 

Typedefs

typedef enum sxbp_deserialise_diagnostic_t sxbp_deserialise_diagnostic_t
 Provides further error information specific to spiral de-serialisation.
 
typedef struct sxbp_serialise_result_t sxbp_serialise_result_t
 Stores both generic and serialisation-specific error information.
 

Enumerations

enum  sxbp_deserialise_diagnostic_t {
  SXBP_DESERIALISE_OK, SXBP_DESERIALISE_BAD_HEADER_SIZE, SXBP_DESERIALISE_BAD_MAGIC_NUMBER, SXBP_DESERIALISE_BAD_VERSION,
  SXBP_DESERIALISE_BAD_DATA_SIZE
}
 Provides further error information specific to spiral de-serialisation. More...
 

Functions

sxbp_serialise_result_t sxbp_load_spiral (sxbp_buffer_t buffer, sxbp_spiral_t *spiral)
 De-serialises a spiral from a buffer. More...
 
sxbp_serialise_result_t sxbp_dump_spiral (sxbp_spiral_t spiral, sxbp_buffer_t *buffer)
 Serialises a spiral to a buffer. More...
 

Variables

const size_t SXBP_FILE_HEADER_SIZE
 The size of the file header in bytes.
 
const size_t SXBP_LINE_T_PACK_SIZE
 The size in bytes of one line when stored in the file.
 

Detailed Description

This compilation unit provides functions for serialising spirals to and from byte sequences (which may be stored in files or any other form).

Author
Joshua Saxby <joshua.a.saxby+TNOPLuc8vM==.com
Date
2016, 2017

Enumeration Type Documentation

Provides further error information specific to spiral de-serialisation.

Enumerator
SXBP_DESERIALISE_OK 

no problem

SXBP_DESERIALISE_BAD_HEADER_SIZE 

header section too small to be valid

SXBP_DESERIALISE_BAD_MAGIC_NUMBER 

wrong magic number in header section

SXBP_DESERIALISE_BAD_VERSION 

unsupported data version (according to header)

SXBP_DESERIALISE_BAD_DATA_SIZE 

data section too small to be valid

Function Documentation

sxbp_serialise_result_t sxbp_dump_spiral ( sxbp_spiral_t  spiral,
sxbp_buffer_t *  buffer 
)

Serialises a spiral to a buffer.

Writes out a binary representation of a given spiral to a buffer, which can then be stored in a file or sent across the network as required.

Parameters
spiralThe spiral which should be serialised to buffer.
[out]bufferThe data buffer to write out the spiral data to.
Returns
For information on return values, see the documentation of the return types.
Note
Asserts:
  • That spiral.lines is not NULL
  • That buffer->bytes is NULL
See also
sxbp_status_t for generic error return codes and sxbp_deserialise_diagnostic_t for file-specific error return codes.
Todo:
The return type of this function could be changed to sxbp_status_t, as none of the serialisation-specific error codes can ever be returned by it.
sxbp_serialise_result_t sxbp_load_spiral ( sxbp_buffer_t  buffer,
sxbp_spiral_t *  spiral 
)

De-serialises a spiral from a buffer.

Reads in a binary representation of a spiral and populates a given spiral with the data which represents this spiral (if input data is valid).

Parameters
bufferThe data buffer to load the spiral from.
[out]spiralThe spiral to write the spiral data to.
Returns
For information on return values, see the documentation of the return types.
Note
Asserts:
  • That buffer.bytes is not NULL
  • That spiral->lines is NULL
See also
sxbp_status_t for generic error return codes and sxbp_deserialise_diagnostic_t for file-specific error return codes.