MIP_SDK
latest-2-g34f3e39
MicroStrain Communications Library for embedded systems
|
Namespaces | |
C | |
connections | |
extras | |
serialization | |
Classes | |
class | Connection |
Represents a type of connection. More... | |
class | Id |
Representes an ID number ranging from 1..N including N. More... | |
class | Index |
Represents an index ranging from 0..N excluding N. More... | |
class | Serializer |
Serializes or deserializes data to/from a byte buffer. More... | |
class | SerializerBase |
Represents a view of a buffer of bytes of known capacity. More... | |
struct | Span |
Implementation of std::span from C++20. More... | |
struct | Span< T, DYNAMIC_EXTENT > |
Typedefs | |
using | EmbeddedTimestamp = C::microstrain_embedded_timestamp |
using | EmbeddedTimeout = C::microstrain_embedded_timeout |
using | BigEndianSerializer = Serializer< serialization::Endian::big > |
using | LittleEndianSerializer = Serializer< serialization::Endian::little > |
Enumerations | |
enum | LogLevel { LogLevel::OFF = MICROSTRAIN_LOG_LEVEL_OFF, LogLevel::FATAL = MICROSTRAIN_LOG_LEVEL_FATAL, LogLevel::ERROR = MICROSTRAIN_LOG_LEVEL_ERROR, LogLevel::WARN = MICROSTRAIN_LOG_LEVEL_WARN, LogLevel::INFO = MICROSTRAIN_LOG_LEVEL_INFO, LogLevel::DEBUG = MICROSTRAIN_LOG_LEVEL_DEBUG, LogLevel::TRACE = MICROSTRAIN_LOG_LEVEL_TRACE } |
Functions | |
constexpr bool | operator== (Id l, Index r) |
constexpr bool | operator== (Index l, Id r) |
template<class Container > | |
auto * | indexOrNull (Container &container, Index index) |
template<class Container , typename Value > | |
auto | indexOrDefault (Container &container, Index index, Value default_) |
template<serialization::Endian E, class T > | |
std::enable_if< std::is_arithmetic< T >::value, size_t >::type | 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 | 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 | 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 | 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 | 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 | 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 | 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 | extract (Serializer< E > &serializer, T *values, size_t count) |
Reads an array from a Serializer. More... | |
template<serialization::Endian E, class T > | |
size_t | 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 | 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 | 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 | 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 | 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 | 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 | 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 | extract (Serializer< E > &serializer, T0 &value0, T1 &value1, Ts &... values) |
Reads multiple values from a Serializer. More... | |
template<serialization::Endian E, class T > | |
bool | 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 | 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 | 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 | 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... | |
using microstrain::BigEndianSerializer = typedef Serializer<serialization::Endian::big> |
using microstrain::EmbeddedTimeout = typedef C::microstrain_embedded_timeout |
using microstrain::EmbeddedTimestamp = typedef C::microstrain_embedded_timestamp |
using microstrain::LittleEndianSerializer = typedef Serializer<serialization::Endian::little> |
|
strong |
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.
Example:
E | Endianness of buffer. Automatically deduced from the serializer parameter. |
T | Type of the class. Automatically deduced from the object parameter. |
serializer | Serializer object pointing to the source buffer. |
object | The class to read from the buffer. |
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.
E | Endianness of buffer. Automatically deduced from the serializer parameter. |
T | Type of the value to read. Automatically deduced from the value parameter. |
buffer | Serializer object pointing to the source buffer. | |
[out] | value | The read value is stored in this variable. Can be a reference to bool, int, uint32_t, float, etc. |
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 { /*...*/ };
E | Endianness of buffer. Automatically deduced from the serializer parameter. |
T | Type of the enum. Automatically deduced from the underlying type of the enum. |
buffer | Serializer object pointing to the source buffer. | |
[out] | value | The value will be stored in this variable. |
size_t microstrain::extract | ( | Serializer< E > & | serializer, |
const std::array< T, N > & | values | ||
) |
Reads a std::array from a Serializer.
E | Endianness of buffer. Automatically deduced from the serializer parameter. |
T | Type of array elements. Automatically deduced from the values parameter. |
serializer | Serializer object pointing to the source buffer. |
values | std::array of values |
size_t microstrain::extract | ( | Serializer< E > & | serializer, |
microstrain::Span< const T > | values | ||
) |
Reads an array from a Serializer via a Span.
E | Endianness of buffer. Automatically deduced from the serializer parameter. |
T | Type of array elements. Automatically deduced from the values parameter. |
serializer | Serializer object pointing to the source buffer. |
values | Span containing pointer and count. |
size_t microstrain::extract | ( | Serializer< E > & | serializer, |
T * | values, | ||
size_t | count | ||
) |
Reads an array from a Serializer.
E | Endianness of buffer. Automatically deduced from the serializer parameter. |
T | Type of array elements. Automatically deduced from the values parameter. |
serializer | Serializer object pointing to the source buffer. |
values | Pointer to the first value in the array. |
count | Number of elements in the array to read. |
size_t microstrain::extract | ( | Serializer< E > & | serializer, |
T(&) | values[N] | ||
) |
Reads a fixed-size array from a Serializer.
E | Endianness of buffer. Automatically deduced from the serializer parameter. |
T | Type of array elements. Automatically deduced from the values parameter. |
serializer | Serializer object pointing to the source buffer. |
values | C-style array of values |
size_t microstrain::extract | ( | Serializer< E > & | serializer, |
T0 & | value0, | ||
T1 & | value1, | ||
Ts &... | values | ||
) |
Reads multiple values from a Serializer.
This function is equivalent to calling extract on each parameter in sequence.
This function can make use of C++17 fold expressions to improve performance by combining the buffer bounds checks when all types are of known size (i.e. numeric types).
E | Endianness of buffer. Automatically deduced from the serializer parameter. |
Ts | Types of values. Automatically deduced from the values parameters. |
serializer | Serializer object pointing to the destination buffer. |
values | One or more parameters to be read. |
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.
Use this overload to read a single value without needing to manually construct a Serializer object.
Example:
E | Endianness of buffer. Must be manually specified. |
T | Type of value. Automatically deduced from the value parameter. |
value | Parameter to deserialize. This can be any serializable type. |
buffer | Pointer to first element of the byte buffer. |
buffer_length | Length/size of buffer. |
offset | Starting offset (default 0). |
exact_size | Returns true only if exactly buffer_length-offset bytes are read. Default false. |
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).
Use this overload to read a single value without needing to manually construct a Serializer object.
E | Endianness of buffer. Must be manually specified. |
T | Type of value. Automatically deduced from the value parameter. |
value | Parameter to deserialize. This can be any serializable type. |
buffer | Source buffer span. |
offset | Starting offset (default 0). |
exact_size | Returns true only if exactly buffer.size()-offset bytes are read. Default false. |
auto microstrain::indexOrDefault | ( | Container & | container, |
Index | index, | ||
Value | default_ | ||
) |
auto* microstrain::indexOrNull | ( | Container & | container, |
Index | index | ||
) |
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.
Use this overload to write a single value without needing to manually construct a Serializer object.
Example:
E | Endianness of buffer. Must be manually specified. |
T | Type of value. Automatically deduced from the value parameter. |
value | Parameter to serialize. This can be any serializable type. |
buffer | Pointer to first element of the byte buffer. |
buffer_length | Length/size of buffer. |
offset | Starting offset. Default 0. |
exact_size | Returns true only if exactly buffer_length plus offset bytes are written. Default false. |
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.
Example:
E | Endianness of buffer. Automatically deduced from the serializer parameter. |
T | Type of the class. Automatically deduced from the object parameter. |
serializer | Serializer object pointing to the destination buffer. |
object | The class to write to the buffer. |
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.
E | Endianness of buffer. Automatically deduced from the serializer parameter. |
T | Type of the value to write. Automatically deduced from the value parameter. |
buffer | Serializer object pointing to the destination buffer. |
value | A number to write to the buffer. Can be bool, int, uint32_t, float, etc. |
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 { /*...*/ };
E | Endianness of buffer. Automatically deduced from the serializer parameter. |
T | Type of the enum. Automatically deduced from the underlying type of the enum. |
buffer | Serializer object pointing to the destination buffer. |
value | The enum value to write to the buffer. |
size_t microstrain::insert | ( | Serializer< E > & | serializer, |
const std::array< T, N > & | values | ||
) |
Writes a std::array to a Serializer.
E | Endianness of buffer. Automatically deduced from the serializer parameter. |
T | Type of array elements. Automatically deduced from the values parameter. |
serializer | Serializer object pointing to the destination buffer. |
values | std::array of values |
size_t microstrain::insert | ( | Serializer< E > & | serializer, |
const T * | values, | ||
size_t | count | ||
) |
Writes an array to a Serializer.
E | Endianness of buffer. Automatically deduced from the serializer parameter. |
T | Type of array elements. Automatically deduced from the values parameter. |
serializer | Serializer object pointing to the destination buffer. |
values | Pointer to the first value in the array. |
count | Number of elements in the array to write. |
size_t microstrain::insert | ( | Serializer< E > & | serializer, |
const T(&) | values[N] | ||
) |
Writes a fixed-size array to a Serializer.
E | Endianness of buffer. Automatically deduced from the serializer parameter. |
T | Type of array elements. Automatically deduced from the values parameter. |
serializer | Serializer object pointing to the destination buffer. |
values | C-style array of values |
size_t microstrain::insert | ( | Serializer< E > & | serializer, |
const T0 & | value0, | ||
const T1 & | value1, | ||
Ts... | values | ||
) |
Writes multiple values to a Serializer.
This function is equivalent to calling insert on each parameter in sequence.
This function can make use of C++17 fold expressions to improve performance by combining the buffer bounds checks when all types are of known size (i.e. numeric types).
E | Endianness of buffer. Automatically deduced from the serializer parameter. |
Ts | Types of values. Automatically deduced from the values parameters. |
serializer | Serializer object pointing to the destination buffer. |
values | One or more parameters to be written. |
size_t microstrain::insert | ( | Serializer< E > & | serializer, |
microstrain::Span< const T > | values | ||
) |
Writes an array to a Serializer via a Span.
E | Endianness of buffer. Automatically deduced from the serializer parameter. |
T | Type of array elements. Automatically deduced from the values parameter. |
serializer | Serializer object pointing to the destination buffer. |
values | Span containing pointer and count. |
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).
Use this overload to write a single value without needing to manually construct a Serializer object.
E | Endianness of buffer. Must be manually specified. |
T | Type of value. Automatically deduced from the value parameter. |
value | Parameter to serialize. This can be any serializable type. |
buffer | Source buffer span. |
offset | Starting offset. Default 0. |
exact_size | Returns true only if exactly buffer.size()-offset bytes are written. Default false. |