跳到主要内容

Data Stream

Module: Core API

Defines data stream for reading and writing data in the form of bytes.

Functions

Name
template <typename T >
T
unpack(const char * buffer, size_t len)
template <typename T >
void
unpack(T & res, const char * buffer, size_t len)
template <typename T >
T
unpack(const std::vector< char > & bytes)
template <typename T >
size_t
pack_size(const T & value)
template <typename T >
std::vector< char >
pack(const T & value)

Functions Documentation

function unpack

template <typename T >
T unpack(
const char * buffer,
size_t len
)

Parameters:

  • buffer - Pointer to the buffer
  • len - Length of the buffer

Template Parameters:

  • T - Type of the unpacked data

Return: T - The unpacked data

Unpack data inside a fixed size buffer as T

function unpack

template <typename T >
void unpack(
T & res,
const char * buffer,
size_t len
)

Parameters:

  • res - Variable to fill with the unpacking
  • buffer - Pointer to the buffer
  • len - Length of the buffer

Template Parameters:

  • T - Type of the unpacked data

Return: T - The unpacked data

Unpack data inside a fixed size buffer as T

function unpack

template <typename T >
T unpack(
const std::vector< char > & bytes
)

Parameters:

  • bytes - Buffer

Template Parameters:

  • T - Type of the unpacked data

Return: T - The unpacked data

Unpack data inside a variable size buffer as T

function pack_size

template <typename T >
size_t pack_size(
const T & value
)

Parameters:

  • value - Data to be packed

Template Parameters:

  • T - Type of the data to be packed

Return: size_t - Size of the packed data

Get the size of the packed data

function pack

template <typename T >
std::vector< char > pack(
const T & value
)

Parameters:

  • value - Data to be packed

Template Parameters:

  • T - Type of the data to be packed

Return: bytes - The packed data

Get packed data


Updated on 2022-12-05 at 15:38:08 +0000