TEC
A lightweight C++ library enabling safe, efficient execution in multithreaded and concurrent systems.
Loading...
Searching...
No Matches
tec::NdTypes::Header Struct Reference

Global header placed at the start of every serialized buffer. More...

#include <tec_nd_types.hpp>

Public Member Functions

 Header ()
 Default constructor initializing a valid empty header.
 
constexpr bool is_valid () const
 Check if the header appears valid.
 
constexpr int get_compression () const
 Extract compression algorithm type.
 
constexpr void set_compression (int comp_type)
 Set compression algorithm type.
 
constexpr int get_compression_level () const
 Extract compression level.
 
constexpr void set_compression_level (int nlevel)
 Set compression level.
 

Public Attributes

uint32_t magic
 Magic identifier (must match kMagic).
 
uint32_t size
 Total size of the serialized payload excluding this header (bytes).
 
uint16_t version
 Protocol version.
 
uint16_t id
 User-defined root object identifier.
 
int16_t status
 Status code (application-specific).
 
uint16_t compression_flags
 Compression type and level (low 4 bits: type, high 4 bits: level).
 
uint32_t size_uncompressed
 Original uncompressed payload size (for verification).
 
uint32_t reserved
 Reserved for future use (must be zero).
 

Static Public Attributes

static constexpr uint32_t kMagic {0x00041b00}
 Magic constant identifying valid serialized data.
 
static constexpr uint16_t kDefaultVersion {0x0100}
 Default protocol version.
 

Detailed Description

Global header placed at the start of every serialized buffer.

Fixed size: 24 bytes. Contains magic number, total size, version, root object ID, status, compression info, and uncompressed size.

Byte layout

Byte Size Field Type Description
0–3 4 magic uint32_t Magic number identifying valid data. Fixed value: 0x00041b00.
4–7 4 size uint32_t Total size of the entire serialized message excluding this header.
8–9 2 version uint16_t Protocol version. Default: 0x0100 (version 1.0).
10–11 2 id uint16_t User-defined root object identifier.
12–13 2 status int16_t Application-specific status code (e.g., success (0) or error code).
14–15 2 compression_flags uint16_t Bits 0–3: compression algorithm (0–15)
Bits 4–7: compression level (0–15)
16–19 4 size_uncompressed uint32_t Original payload size before compression (for verification/decompression).
20–23 4 reserved uint32_t Reserved for future use; must be zero.

This layout is guaranteed to be contiguous and exactly the sizes shown on all platforms due to the packing directive.

Member Function Documentation

◆ get_compression()

constexpr int tec::NdTypes::Header::get_compression ( ) const
inlineconstexpr

Extract compression algorithm type.

Returns
Compression type (0–15).

◆ get_compression_level()

constexpr int tec::NdTypes::Header::get_compression_level ( ) const
inlineconstexpr

Extract compression level.

Returns
Level value (0–15, typically 0–9).

◆ is_valid()

constexpr bool tec::NdTypes::Header::is_valid ( ) const
inlineconstexpr

Check if the header appears valid.

Returns
true if magic and version are acceptable.

◆ set_compression()

constexpr void tec::NdTypes::Header::set_compression ( int  comp_type)
inlineconstexpr

Set compression algorithm type.

Parameters
comp_typeType value (0–15).

◆ set_compression_level()

constexpr void tec::NdTypes::Header::set_compression_level ( int  nlevel)
inlineconstexpr

Set compression level.

Parameters
nlevelLevel value (0–15).

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