MIP_SDK  latest-2-g34f3e39
MicroStrain Communications Library for embedded systems
Classes | Namespaces | Typedefs | Functions
serializer.hpp File Reference
#include "readwrite.hpp"
#include "../span.hpp"
#include <array>
#include <stdint.h>
#include <stddef.h>

Go to the source code of this file.

Classes

class  microstrain::SerializerBase
 Represents a view of a buffer of bytes of known capacity. More...
 
class  microstrain::Serializer< E >
 Serializes or deserializes data to/from a byte buffer. More...
 

Namespaces

 microstrain
 

Typedefs

using microstrain::BigEndianSerializer = Serializer< serialization::Endian::big >
 
using microstrain::LittleEndianSerializer = Serializer< serialization::Endian::little >
 

Functions

template<serialization::Endian E, class T >
std::enable_if< std::is_arithmetic< T >::value, size_t >::type microstrain::insert (Serializer< E > &buffer, T value)
 Inserts a numeric value to a Serializer. More...
 
template<serialization::Endian E, class T >
std::enable_if< std::is_arithmetic< T >::value, size_t >::type microstrain::extract (Serializer< E > &buffer, T &value)
 Reads a numeric value from a Serializer. More...
 
template<serialization::Endian E, class T >
std::enable_if< std::is_enum< T >::value, size_t >::type microstrain::insert (Serializer< E > &buffer, T value)
 Writes an enum to a Serializer. For this to work properly, the enum must have its underlying type specified, i.e., like enum Foo : uint32_t { /*...*‍/ }; More...
 
template<serialization::Endian E, class T >
std::enable_if< std::is_enum< T >::value, size_t >::type microstrain::extract (Serializer< E > &buffer, T &value)
 Reads an enum from a Serializer. For this to work properly, the enum must have its underlying type specified, i.e., like enum Foo : uint32_t { /*...*‍/ }; More...
 
template<serialization::Endian E, class T , decltype &::insert = nullptr>
std::enable_if< std::is_class< T >::value, size_t >::type microstrain::insert (microstrain::Serializer< E > &serializer, const T &object)
 Writes a class object to a Serializer. This overload is available to any class which defines a method insert. It shall take a Serializer reference as the sole parameter. More...
 
template<serialization::Endian E, class T , decltype &::extract = nullptr>
std::enable_if< std::is_class< T >::value, size_t >::type microstrain::extract (microstrain::Serializer< E > &serializer, T &object)
 Reads a class object from a Serializer. This overload is available to any class which defines a method extract. It shall take a Serializer reference as the sole parameter. More...
 
template<serialization::Endian E, class T >
size_t microstrain::insert (Serializer< E > &serializer, const T *values, size_t count)
 Writes an array to a Serializer. More...
 
template<serialization::Endian E, class T >
size_t microstrain::extract (Serializer< E > &serializer, T *values, size_t count)
 Reads an array from a Serializer. More...
 
template<serialization::Endian E, class T >
size_t microstrain::insert (Serializer< E > &serializer, microstrain::Span< const T > values)
 Writes an array to a Serializer via a Span. More...
 
template<serialization::Endian E, class T >
size_t microstrain::extract (Serializer< E > &serializer, microstrain::Span< const T > values)
 Reads an array from a Serializer via a Span. More...
 
template<serialization::Endian E, class T , size_t N>
size_t microstrain::insert (Serializer< E > &serializer, const T(&values)[N])
 Writes a fixed-size array to a Serializer. More...
 
template<serialization::Endian E, class T , size_t N>
size_t microstrain::extract (Serializer< E > &serializer, T(&values)[N])
 Reads a fixed-size array from a Serializer. More...
 
template<serialization::Endian E, class T , size_t N>
size_t microstrain::insert (Serializer< E > &serializer, const std::array< T, N > &values)
 Writes a std::array to a Serializer. More...
 
template<serialization::Endian E, class T , size_t N>
size_t microstrain::extract (Serializer< E > &serializer, const std::array< T, N > &values)
 Reads a std::array from a Serializer. More...
 
template<serialization::Endian E, typename T0 , typename T1 , typename... Ts>
size_t microstrain::insert (Serializer< E > &serializer, const T0 &value0, const T1 &value1, Ts... values)
 Writes multiple values to a Serializer. More...
 
template<serialization::Endian E, typename T0 , typename T1 , typename... Ts>
size_t microstrain::extract (Serializer< E > &serializer, T0 &value0, T1 &value1, Ts &... values)
 Reads multiple values from a Serializer. More...
 
template<serialization::Endian E, class T >
bool microstrain::insert (const T &value, uint8_t *buffer, size_t buffer_length, size_t offset=0, bool exact_size=false)
 Serializes a value to a raw byte buffer. More...
 
template<serialization::Endian E, class T >
bool microstrain::extract (T &value, const uint8_t *buffer, size_t buffer_length, size_t offset=0, bool exact_size=false)
 Deserializes a value from a raw byte buffer. More...
 
template<serialization::Endian E, class T >
bool microstrain::insert (T value, microstrain::Span< uint8_t > buffer, size_t offset=0, bool exact_size=false)
 Serializes a value to a raw byte buffer (span version). More...
 
template<serialization::Endian E, class T >
bool microstrain::extract (T &value, microstrain::Span< const uint8_t > buffer, size_t offset=0, bool exact_size=false)
 Deserializes a value from a raw byte buffer (span version). More...