Arduino KVComm  master
Key-Value pair communication library for Arduino
Static Public Member Functions | List of all members
KV_Type< T > Struct Template Reference

Template struct for making types serializable. More...

#include <KVComm/KV_Types.hpp>

Collaboration diagram for KV_Type< T >:

Static Public Member Functions

constexpr static uint8_t getTypeID ()
 
constexpr static size_t getLength ()
 
static void writeToBuffer (const T &, uint8_t *buffer)
 
static T readFromBuffer (const uint8_t *buffer)
 

Detailed Description

template<class T>
struct KV_Type< T >

Template struct for making types serializable.

Specializations should implement the following methods:

getTypeID should return an arbitrary, unique identifier for the type.
getLength returns the size of the type in bytes.
writeToBuffer copies an object of the type into a byte buffer (it shouldn't write more than getLength() bytes).
readFromBuffer converts a buffer of bytes into an object of the type (it shouldn't read more than getLength() bytes).

When copying data from and to the buffer, don't break the strict aliasing rule and keep in mind that the compiler can add padding bytes to structs.

Template Parameters
TThe type to make serializable.

Definition at line 43 of file KV_Types.hpp.

Member Function Documentation

◆ getTypeID()

constexpr static uint8_t getTypeID ( )
staticconstexpr

◆ getLength()

constexpr static size_t getLength ( )
staticconstexpr

◆ writeToBuffer()

static void writeToBuffer ( const T &  ,
uint8_t *  buffer 
)
static

◆ readFromBuffer()

static T readFromBuffer ( const uint8_t *  buffer)
static

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