Arduino KVComm  master
Key-Value pair communication library for Arduino
Classes | Macros
KV_Types.hpp File Reference

KV_Type type definitions for fundamental types (int::_t, uint::_t, float, double, bool, char). These definitions specify how variables of these types should be serialized and deserialized when writing and reading them from/to the buffer. More...

#include <stdint.h>
#include <string.h>
Include dependency graph for KV_Types.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  KV_Type< T >
 Template struct for making types serializable. More...
 
struct  KV_Type< int8_t >
 
struct  KV_Type< uint8_t >
 
struct  KV_Type< int16_t >
 
struct  KV_Type< uint16_t >
 
struct  KV_Type< int32_t >
 
struct  KV_Type< uint32_t >
 
struct  KV_Type< int64_t >
 
struct  KV_Type< uint64_t >
 
struct  KV_Type< float >
 
struct  KV_Type< double >
 
struct  KV_Type< bool >
 
struct  KV_Type< char >
 

Macros

#define KV_ADD_TRIVIAL_TYPE(type, typeid)
 Add a KV_Type definition that can be (de)serialized by just memcpying. More...
 

Detailed Description

KV_Type type definitions for fundamental types (int::_t, uint::_t, float, double, bool, char). These definitions specify how variables of these types should be serialized and deserialized when writing and reading them from/to the buffer.


Definition in file KV_Types.hpp.

Macro Definition Documentation

◆ KV_ADD_TRIVIAL_TYPE

#define KV_ADD_TRIVIAL_TYPE (   type,
  typeid 
)
Value:
template <> \
struct KV_Type<type> { \
constexpr inline static uint8_t getTypeID() { return typeid; } \
constexpr inline static size_t getLength() { return sizeof(type); } \
inline static void writeToBuffer(const type &t, uint8_t *buffer) { \
memcpy(buffer, &t, getLength()); \
} \
inline static void readFromBuffer(type &t, const uint8_t *buffer) { \
memcpy(&t, buffer, getLength()); \
} \
}

Add a KV_Type definition that can be (de)serialized by just memcpying.

Definition at line 53 of file KV_Types.hpp.

KV_Type
Template struct for making types serializable.
Definition: KV_Types.hpp:43