codex
Loading...
Searching...
No Matches
codex::Packet Class Reference

Wrapper for a raw byte buffer with methods to extract data from it. More...

#include <packet_reader.hpp>

Public Member Functions

std::span< char, Ndata ()
 Provides direct access to the underlying buffer.
 
auto get (Readable auto *...ps)
 Extracts typed data from the underlying raw byte buffer.
 
std::span< char, Ndata ()
 Provides direct access to the underlying buffer.
 
auto get (Readable auto *...ps)
 Extracts typed data from the underlying raw byte buffer.
 

Static Public Attributes

static constexpr std::size_t N = 32
 Maximum buffer size.
 

Private Member Functions

template<typename T >
void advance ()
 Advances i after reading a type T.
 
template<typename T >
T read ()
 Reads a sngle value of type T from the buffer.
 
template<typename T >
ReadResult read (T *p)
 Checks that the buffer contains a value of type T and reads it.
 
template<typename T >
void advance ()
 Advances i after reading a type T.
 
template<typename T >
T read ()
 Reads a sngle value of type T from the buffer.
 
template<typename T >
ReadResult read (T *p)
 Checks that the buffer contains a value of type T and reads it.
 

Private Attributes

std::array< char, Nbuf = {}
 Raw byte buffer.
 
size_t i = {}
 Current offset into buf.
 

Detailed Description

Wrapper for a raw byte buffer with methods to extract data from it.

Values in the buffer are in the form:

buffer: | Type | value | Type | value | ... |
size: uint8_t size uint8_t size
Type
Data types that can be read from a buffer.
Definition packet_reader.hpp:14
Definition ops.c:29

where size is sizeof(T) and T is such that type_to_enum<T> is the value in each preceding Type value in the buffer.

Member Function Documentation

◆ advance() [1/2]

template<typename T >
void codex::Packet::advance ( )
private

Advances i after reading a type T.

Here is the caller graph for this function:

◆ advance() [2/2]

template<typename T >
void codex::Packet::advance ( )
private

Advances i after reading a type T.

◆ data() [1/2]

std::span< char, N > codex::Packet::data ( )
inline

Provides direct access to the underlying buffer.

Here is the caller graph for this function:

◆ data() [2/2]

std::span< char, N > codex::Packet::data ( )
inline

Provides direct access to the underlying buffer.

◆ get() [1/2]

auto codex::Packet::get ( Readable auto *... ps)
inline

Extracts typed data from the underlying raw byte buffer.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ get() [2/2]

auto codex::Packet::get ( Readable auto *... ps)
inline

Extracts typed data from the underlying raw byte buffer.

Here is the call graph for this function:

◆ read() [1/4]

template<typename T >
T codex::Packet::read ( )
private

Reads a sngle value of type T from the buffer.

Here is the caller graph for this function:

◆ read() [2/4]

template<typename T >
T codex::Packet::read ( )
private

Reads a sngle value of type T from the buffer.

◆ read() [3/4]

template<typename T >
ReadResult codex::Packet::read ( T * p)
private

Checks that the buffer contains a value of type T and reads it.

The current position in the buffer must contain a Type value t such that t == type_to_enum<T>.

Here is the call graph for this function:

◆ read() [4/4]

template<typename T >
ReadResult codex::Packet::read ( T * p)
private

Checks that the buffer contains a value of type T and reads it.

The current position in the buffer must contain a Type value t such that t == type_to_enum<T>.

Member Data Documentation

◆ buf

std::array< char, N > codex::Packet::buf = {}
private

Raw byte buffer.

◆ i

size_t codex::Packet::i = {}
private

Current offset into buf.

Incremented after each get.

◆ N

static constexpr std::size_t codex::Packet::N = 32
staticconstexpr

Maximum buffer size.


The documentation for this class was generated from the following files: