MIP_SDK
v3.0.0-187-g93c7302
MicroStrain Communications Library for embedded systems
|
Namespaces | |
C | |
connections | |
detail | |
extras | |
serialization | |
Classes | |
struct | BitfieldMemberIthruJ |
A class which represents part of a bitfield (see BitfieldMemberN) More... | |
struct | BitfieldMemberItoJ |
A class which represents part of a bitfield (see BitfieldMemberN) More... | |
struct | BitfieldMemberN |
A class which represents part of a bitfield. More... | |
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... | |
struct | IntegerWithBits |
Helper type to get an integer of at least N bits in size. More... | |
struct | IntegerWithBytes |
Helper type to get an integer of at least N bytes in size. More... | |
struct | IntegerWithBytes< 1 > |
struct | IntegerWithBytes< 2 > |
struct | IntegerWithBytes< 3 > |
struct | IntegerWithBytes< 4 > |
struct | IntegerWithBytes< 5 > |
struct | IntegerWithBytes< 6 > |
struct | IntegerWithBytes< 7 > |
struct | IntegerWithBytes< 8 > |
class | SaturatingInt |
A class representing an integer that saturates instead of overflowing. 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 > |
Functions | |
template<typename T > | |
constexpr T | bitmaskFirstN (unsigned int nbits) |
Creates a bitmask with 1s in the first N bits, i.e. bits [0..N). More... | |
template<typename T > | |
constexpr T | bitmaskN (unsigned int bitI, unsigned int nbits) |
Creates a bitmask with N '1' bits starting at bit I. More... | |
template<typename T > | |
constexpr T | bitmaskItoJ (unsigned int bitI, unsigned int bitJ) |
Creates a bitmask with bits [bitI..bitJ) set to 1 (excludes bit J). More... | |
template<typename T > | |
constexpr T | bitmaskIthruJ (unsigned int bitI, unsigned int bitJ) |
Creates a bitmask with bits [bitI..bitJ] set to 1 (includes bit J). More... | |
template<typename RegType > | |
constexpr bool | testBit (RegType reg, unsigned int bit) |
Checks if a specific bit in a value is set. More... | |
template<typename RegType > | |
constexpr void | setBit (RegType ®, unsigned int bit, bool value=true) |
Sets a specific bit in a variable to a specified value. More... | |
template<typename RegType > | |
constexpr RegType | getBitsN (RegType reg, unsigned int bitI, unsigned int nbits) |
Extracts a bitfield from a variable value. More... | |
template<typename RegType > | |
constexpr RegType | getBitsItoJ (RegType reg, unsigned int bitI, unsigned int bitJ) |
Extracts a bitfield from a variable value. More... | |
template<typename RegType > | |
constexpr RegType | getBitsIthruJ (RegType reg, unsigned int bitI, unsigned int bitJ) |
Extracts a bitfield from a variable value. More... | |
template<typename RegType > | |
constexpr void | setBitsN (RegType ®, unsigned int bitI, unsigned int nbits) |
Sets a series of consecutive bits in a variable to 1. More... | |
template<typename RegType > | |
constexpr void | setBitsItoJ (RegType ®, unsigned int bitI, unsigned int bitJ) |
Sets a series of consecutive bits in a variable to 1. More... | |
template<typename RegType > | |
constexpr void | setBitsIthruJ (RegType ®, unsigned int bitI, unsigned int bitJ) |
Sets a series of consecutive bits in a variable to 1. More... | |
template<typename RegType > | |
constexpr void | clearBitsN (RegType ®, unsigned int bitI, unsigned int nbits) |
Sets a series of consecutive bits in a variable to 0. More... | |
template<typename RegType > | |
constexpr void | clearBitsItoJ (RegType ®, unsigned int bitI, unsigned int bitJ) |
Sets a series of consecutive bits in a variable to 0. More... | |
template<typename RegType > | |
constexpr void | clearBitsIthruJ (RegType ®, unsigned int bitI, unsigned int bitJ) |
Sets a series of consecutive bits in a variable to 0. More... | |
template<typename RegType , typename ValType > | |
constexpr void | setBitsN (RegType ®, unsigned int bitI, unsigned int nbits, ValType value) |
Writes a value to a specific set of bits in a variable as if it were a bitfield. More... | |
template<typename RegType , typename ValType > | |
constexpr void | setBitsItoJ (RegType ®, unsigned int bitI, unsigned int bitJ, ValType value) |
Writes a value to a specific set of bits in a variable as if it were a bitfield. More... | |
template<typename RegType , typename ValType > | |
constexpr void | modifyBitsIthruJ (RegType ®, unsigned int bitI, unsigned int bitJ, ValType value) |
Writes a value to a specific set of bits in a variable as if it were a bitfield. More... | |
template<class T > | |
constexpr T | add_sat (T x, T y) noexcept |
template<class T > | |
constexpr T | sub_sat (T x, T y) noexcept |
template<class T , class U > | |
constexpr T | saturate_cast (U x) noexcept |
Convert an integral value to a different integral type while preventing overflow. More... | |
template<class T , class U > | |
constexpr void | assign_sat (T &destination, U value) |
Assign an integral value to a destination variable, clamping its value to the range of the destination type. More... | |
template<class T , class U > | |
constexpr T & | accum_sat (T &counter, U amount) |
Add a value to an accumulator and prevent it from overflowing. More... | |
template<class T , class U > | |
constexpr T & | reduce_sat (T &counter, U amount) |
Subtract a value from an accumulator and prevent it from overflowing. More... | |
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> |
|
constexpr |
Add a value to an accumulator and prevent it from overflowing.
T | Type of the accumulator. Let the compiler deduce this. |
U | Type of the value being added. Let the compiler deduce this. |
[out] | counter | Accumulator variable to modify. |
[in] | value | Value to add to counter. |
|
constexprnoexcept |
|
constexpr |
Assign an integral value to a destination variable, clamping its value to the range of the destination type.
T | Destination type. Let the compiler deduce this. |
U | Source type. Let the compiler deduce this. |
[out] | destination | Variable in which to store the value. |
[in] | value | Value to store in destination. |
|
constexpr |
Creates a bitmask with 1s in the first N bits, i.e. bits [0..N).
T | An unsigned integral type. |
nbits | The number of 1 bits starting at location 0. Must not exceed the number of bits in T (e.g. nbits <= 32 for T=uint32_t). |
|
constexpr |
Creates a bitmask with bits [bitI..bitJ] set to 1 (includes bit J).
If bitI == bitJ, then the result will have exactly one bit set.
T | An unsigned integral type. |
bitI | The 0-based index of the first 1 bit. Must not exceed the number of bits in T. |
bitJ | The 0-based index of the the last 1 bit. Must be greater than or equal to bitI and cannot exceed the number of bits in T. |
|
constexpr |
Creates a bitmask with bits [bitI..bitJ) set to 1 (excludes bit J).
T | An unsigned integral type. |
bitI | The 0-based index of the first 1 bit. Must not exceed the number of bits in T. |
bitJ | The 0-based index of the first 0 bit after the last 1 bit. Must be greater than or equal to bitI and cannot exceed the number of bits in T. |
|
constexpr |
Creates a bitmask with N '1' bits starting at bit I.
If bitI == bitJ, then the result will have exactly one bit set.
T | An unsigned integral type. |
bitI | The 0-based index of the first 1 bit. Must be LESS than the number of bits in T (and not equal). |
bitJ | The 0-based index of the the last 1 bit. Must be greater than or equal to bitI and cannot exceed the number of bits in T. |
|
constexpr |
Sets a series of consecutive bits in a variable to 0.
RegType | An unsigned integral type. Let the compiler deduce this. |
reg | Value to be modified. |
bitI | The 0-based index of the first affected bit. |
bitJ | The 0-based index of the last affected bit. |
|
constexpr |
Sets a series of consecutive bits in a variable to 0.
RegType | An unsigned integral type. Let the compiler deduce this. |
reg | Value to be modified. |
bitI | The 0-based index of the first affected bit. |
bitJ | The 0-based index of the bit after the last affected bit. |
|
constexpr |
Sets a series of consecutive bits in a variable to 0.
RegType | An unsigned integral type. Let the compiler deduce this. |
reg | Value to be modified. |
bitI | The 0-based index of the first affected bit. |
nbits | Number of consecutive bits to set to '0'. |
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. |
|
constexpr |
Extracts a bitfield from a variable value.
RegType | An unsigned integral type. Let the compiler deduce this. |
reg | Register value. |
bitI | The 0-based index of the first bit to extract. Must be less than the number of bits in RegType. |
bitJ | The 0-based index of the last bit to extract. Must be greater than or equal to bitI and less than the number of bits in RegType. |
|
constexpr |
Extracts a bitfield from a variable value.
RegType | An unsigned integral type. Let the compiler deduce this. |
reg | Register value. |
bitI | The 0-based index of the first bit to extract. Must be less than the number of bits in RegType. |
bitJ | The 0-based index of the bit after last bit to extract. Must be greater than or equal to bitI and cannot exceed the number of bits in RegType. |
|
constexpr |
Extracts a bitfield from a variable value.
RegType | An unsigned integral type. Let the compiler deduce this. |
reg | Register value. |
bitI | The 0-based index of the first bit to extract. Must be less than the number of bits in RegType. |
nbits | How many consecutive bits to extract. |
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. |
|
constexpr |
Writes a value to a specific set of bits in a variable as if it were a bitfield.
RegType | An unsigned integral type. Let the compiler deduce this. |
ValType | An integral type used for the input value. Let the compiler deduce this. |
reg | Value to be modified. |
bitI | The 0-based index of the first bit of value in reg. |
bitJ | The 0-based index of the last bit of value in reg. |
value | Value to insert into reg at bit I. |
|
constexpr |
Subtract a value from an accumulator and prevent it from overflowing.
T | Type of the accumulator. Let the compiler deduce this. |
U | Type of the value being subtracted. Let the compiler deduce this. |
[out] | counter | Accumulator variable to modify. |
[in] | value | Value to subtract from counter. |
|
constexprnoexcept |
Convert an integral value to a different integral type while preventing overflow.
See https://en.cppreference.com/w/cpp/numeric/saturate_cast
T | Result type. |
U | Source type. Let the compiler deduce this. |
x | Value to cast. |
|
constexpr |
Sets a specific bit in a variable to a specified value.
RegType | An integral type. Let the compiler deduce this. |
reg | Value to be modified. |
bit | The 0-based index of the bit to modify. Must be less than the number of bits in RegType. |
value | Sets the bit to this value. Default true. |
|
constexpr |
Sets a series of consecutive bits in a variable to 1.
RegType | An unsigned integral type. Let the compiler deduce this. |
reg | Value to be modified. |
bitI | The 0-based index of the first affected bit. |
bitJ | The 0-based index of the last affected bit. |
|
constexpr |
Sets a series of consecutive bits in a variable to 1.
RegType | An unsigned integral type. Let the compiler deduce this. |
reg | Value to be modified. |
bitI | The 0-based index of the first affected bit. |
bitJ | The 0-based index of the bit after the last affected bit. |
|
constexpr |
Writes a value to a specific set of bits in a variable as if it were a bitfield.
RegType | An unsigned integral type. Let the compiler deduce this. |
ValType | An integral type used for the input value. Let the compiler deduce this. |
reg | Value to be modified. |
bitI | The 0-based index of the first bit of value in reg. |
bitJ | The 0-based index of the bit after the last affected bit. |
value | Value to insert into reg at bit I. |
|
constexpr |
Sets a series of consecutive bits in a variable to 1.
RegType | An unsigned integral type. Let the compiler deduce this. |
reg | Value to be modified. |
bitI | The 0-based index of the first affected bit. |
nbits | Number of consecutive bits to set to '1'. |
|
constexpr |
Writes a value to a specific set of bits in a variable as if it were a bitfield.
RegType | An unsigned integral type. Let the compiler deduce this. |
ValType | An integral type used for the input value. Let the compiler deduce this. |
reg | Value to be modified. |
bitI | The 0-based index of the first bit of value in reg. |
nbits | Number of consecutive bits used to represent the value in reg. |
value | Value to insert into reg at bit I. |
|
constexprnoexcept |
|
constexpr |
Checks if a specific bit in a value is set.
RegType | An integral type. Let the compiler deduce this in most cases. |
reg | Value containing the bit to check. |
bit | The 0-based index of the bit to check in val. Must be less than the number of bits in RegType. |