Lib Sub-System: Coder

01 The coder sub-system contains encoding and decoding functions to serialize simple data types into/from a byte stream.
02 Sooner or later, every data structure is made up of integer values and strings.
Support for serializing these data types is available within the Semys Library; More complex data constructs are serialized using common conventions.

Encoding Rules

03

Boolean

A boolean value (true / false) is stored within one byte: 0x01 for true, 0x00 for false.
04

Integer

Integer values (16 to 64 bits width) are all stored in network byte (big-endian) format.
05

Raw data (bytes)

Raw data (byte arrays of arbitrary size) are stored without any modification.
The size (if required) has to be serialized separately. Typically, this is done by preceeding the raw bytes with an uint32 value, that specifies the amount.
06

Strings

Strings should be serialized in UTF-8, with a preceeding uint32 value that specifies the amount of bytes used. Since coding/decoding UTF-8 is not available to all environments, this data is handled as follows:
  • Library (internal): uses only ASCII - thus compatible.
  • [CPP] Arch: std::string is used and can hold UTF-8 encoded data; either 'mis'use the string or use the direct raw coder interface (Coder::Code(byte *, uint32))
  • [C#] Arch: Encoding.UTF8 is used.
Technically, a string behaves like a raw byte array, but we explicitly settle the character encoding.
07 Functions:
08 Some functions are independent on the type of the coder (encoder, decoder) - The functions have the term 'Coder', 'Encoder' or 'Decoder' in their name, to be used respectively.
Encoder and Decoder functions should not be used on the other type of coder.
09 Reference: SemysCoder.h
Implementation: Semys Library

Goto: Main Page; This page is part of the Semys software documentation. See About: Documentation for details.