#include <ByteVector.hpp>
Public Member Functions | |
ByteVector () | |
ByteVector constructor. More... | |
template<typename T1 > | |
ByteVector (T1 arg1) | |
ByteVector constructor. More... | |
template<typename T1 , typename T2 > | |
ByteVector (T1 arg1, T2 arg2) | |
ByteVector constructor. More... | |
bool | consume (std::size_t count) const |
Manually consumes data, thus skipping the values. More... | |
template<typename T , typename std::enable_if< std::is_integral< T >::value, T >::type * = nullptr> | |
bool | pack (const T &val) |
Packs integer types into the ByteVector. Ensures little endian packing. More... | |
template<typename T , typename std::enable_if< std::is_floating_point< T >::value, T >::type * = nullptr> | |
bool | pack (const T &val) |
Packs floating point types into the ByteVector. Uses IEEE 754 format. More... | |
template<typename encoding_T , typename T1 , typename T2 , typename std::enable_if< std::is_arithmetic< T1 >::value, T1 >::type * = nullptr, typename std::enable_if< std::is_arithmetic< T2 >::value, T2 >::type * = nullptr> | |
bool | pack (const T1 val, const T2 scale, const T2 offset=0) |
Packs scaled values (e.g. float to scaled int) as packed_val = (val+offset)*scale. More... | |
bool | pack (const std::string &val, size_t max_len=std::numeric_limits< size_t >::max()) |
Packs string data into the ByteVector. More... | |
bool | pack (const ByteVector &data, size_t max_len=std::numeric_limits< size_t >::max()) |
Packs another ByteVector into the ByteVector. More... | |
template<typename T , typename std::enable_if< std::is_base_of< Packable, T >::value, T >::type * = nullptr> | |
bool | pack (const T &val) |
Packs an an object which inherits from type Packable into the ByteVector. More... | |
template<typename encoding_T , typename T1 , typename T2 , typename std::enable_if< std::is_arithmetic< T1 >::value, T1 >::type * = nullptr, typename std::enable_if< std::is_arithmetic< T2 >::value, T2 >::type * = nullptr> | |
bool | pack (const Value< T1 > val, const T2 scale, const T2 offset=0) |
Packs scaled value types (e.g. value<float> to scaled int) as packed_val = (val+offset)*scale. More... | |
bool | pack (const Value< ByteVector > &val, size_t max_len=std::numeric_limits< size_t >::max()) |
Packs a Value<ByteVector> into the ByteVector. More... | |
bool | pack (const Value< std::string > &val, size_t max_len=std::numeric_limits< size_t >::max()) |
Packs a Value<std::string> into the ByteVector. More... | |
template<class T > | |
bool | pack (const Value< T > &val) |
Packs the contents of a Value<T> into the ByteVector. More... | |
template<typename T , typename std::enable_if< std::is_integral< T >::value, T >::type * = nullptr> | |
bool | unpack (T &val) const |
Extracts little endian integers from the ByteVector. Consumes a number of bytes matching sizeof(T). Fails if not enough bytes are available. More... | |
bool | unpack (bool &val) const |
unpack Extracts a boolen from a single byte More... | |
template<typename T , typename std::enable_if< std::is_floating_point< T >::value, T >::type * = nullptr> | |
bool | unpack (T &val) const |
Extracts floating point numbers from the ByteVector. Consumes a number of bytes matching sizeof(T). Fails if not enough bytes are available. More... | |
bool | unpack (std::string &val, size_t count=std::numeric_limits< size_t >::max()) const |
Extracts data from the ByteVector and stores it in a std::string. Consumes all remaining data unless instructed otherwise. More... | |
bool | unpack (ByteVector &val, size_t count=std::numeric_limits< size_t >::max()) const |
Extracts data from the ByteVector and stores it in a another ByteVector. Consumes all remaining data unless instructed otherwise. More... | |
template<typename encoding_T , typename T1 , typename T2 , typename std::enable_if< std::is_arithmetic< T1 >::value, T1 >::type * = nullptr, typename std::enable_if< std::is_arithmetic< T2 >::value, T2 >::type * = nullptr> | |
bool | unpack (T1 &val, T2 scale, T2 offset=0) const |
Unpacks scaled value types (e.g. scaled int to floating point) as val = (packed_val/scale)-offset. More... | |
template<typename T , typename std::enable_if< std::is_base_of< Packable, T >::value, T >::type * = nullptr> | |
bool | unpack (T &obj) const |
unpack Unpacks an an object which inherits from type Packable More... | |
template<class T > | |
bool | unpack (Value< T > &val) const |
Unpacks Value types other than string and ByteVector specializations. More... | |
bool | unpack (Value< std::string > &val, size_t count=std::numeric_limits< size_t >::max()) const |
Extracts data from the ByteVector and stores it in a Value<std::string>. Consumes all remaining data unless instructed otherwise. More... | |
bool | unpack (Value< ByteVector > &val, size_t count=std::numeric_limits< size_t >::max()) const |
Extracts data from the ByteVector and stores it in a Value<ByteVector>. Consumes all remaining data unless instructed otherwise. More... | |
template<typename encoding_T , typename T1 , typename T2 = float, typename std::enable_if< std::is_arithmetic< T1 >::value, T1 >::type * = nullptr, typename std::enable_if< std::is_arithmetic< T2 >::value, T2 >::type * = nullptr> | |
bool | unpack (Value< T1 > &val, T2 scale=1, T2 offset=0) const |
Unpacks scaled Value types (e.g. scaled int to floating point) as val = (packed_val/scale)-offset. More... | |
std::vector< uint8_t >::iterator | unpacking_iterator () |
Gives an iterator to the next element ready for unpacking. More... | |
std::vector< uint8_t >::const_iterator | unpacking_iterator () const |
Gives an iterator to the next element ready for unpacking. More... | |
std::size_t | unpacking_offset () const |
Gives the number of bytes which have already been consumed by unpack operations. More... | |
std::size_t | unpacking_remaining () const |
Returns the number of bytes still avialable for unpacking. More... | |
Protected Attributes | |
std::size_t | offset |
Definition at line 15 of file ByteVector.hpp.
|
inline |
ByteVector constructor.
Definition at line 20 of file ByteVector.hpp.
|
inline |
ByteVector constructor.
arg1 | Single argument passed to constructor of parent std::vector class |
Definition at line 28 of file ByteVector.hpp.
|
inline |
ByteVector constructor.
arg1 | First of two arguments passed to constructor of parent std::vector class |
arg2 | Second of two arguments passed to constructor of parent std::vector class |
Definition at line 38 of file ByteVector.hpp.
|
inline |
Manually consumes data, thus skipping the values.
count | Number of bytes to consume |
Definition at line 436 of file ByteVector.hpp.
|
inline |
Packs integer types into the ByteVector. Ensures little endian packing.
T | Underlying data type to be packed. Must be an integral type. |
val | Value to be packed |
Definition at line 51 of file ByteVector.hpp.
|
inline |
Packs floating point types into the ByteVector. Uses IEEE 754 format.
T | Underlying data type to be packed. Must be a floating point type. |
val | Value to be packed |
Definition at line 70 of file ByteVector.hpp.
|
inline |
Packs scaled values (e.g. float to scaled int) as packed_val = (val+offset)*scale.
encoding_T | Data type to use for the actual data packing (usually an integral type) |
T1 | Type of input value (usually a floating point type) |
T2 | Type of scale and offset coefficients |
val | Value to be packed |
scale | Value of scaling to apply to the offset value |
offset | Value of offset to apply to the input value (optional, defaults to 0) |
Definition at line 94 of file ByteVector.hpp.
|
inline |
Packs string data into the ByteVector.
val | String to be packed |
max_len | Optional max number of characters to transfer into the ByteVector |
Definition at line 110 of file ByteVector.hpp.
|
inline |
Packs another ByteVector into the ByteVector.
data | ByteVector to be packed |
max_len | Optional max number of characters to transfer into the ByteVector |
Definition at line 130 of file ByteVector.hpp.
|
inline |
Packs an an object which inherits from type Packable into the ByteVector.
val | Reference to object to be packed |
Definition at line 149 of file ByteVector.hpp.
|
inline |
Packs scaled value types (e.g. value<float> to scaled int) as packed_val = (val+offset)*scale.
encoding_T | Data type to use for the actual data packing (usually an integral type) |
T1 | Type of input value (usually a floating point type) |
T2 | Type of scale and offset coefficients |
val | Value to be packed |
scale | Value of scaling to apply to the offset value |
offset | Value of offset to apply to the input value (optional, defaults to 0) |
Definition at line 171 of file ByteVector.hpp.
|
inline |
Packs a Value<ByteVector> into the ByteVector.
val | The Value<ByteVector> to be packed |
max_len | Optional max number of characters to transfer into the ByteVector |
Definition at line 183 of file ByteVector.hpp.
|
inline |
Packs a Value<std::string> into the ByteVector.
val | The Value<std::string> to be packed |
max_len | Optional max number of characters to transfer into the ByteVector |
Definition at line 196 of file ByteVector.hpp.
|
inline |
Packs the contents of a Value<T> into the ByteVector.
T | Type of the Value<T> being packed. May be automatically deduced from arguments |
val | The Value<T> to be packed |
Definition at line 209 of file ByteVector.hpp.
|
inline |
Extracts little endian integers from the ByteVector. Consumes a number of bytes matching sizeof(T). Fails if not enough bytes are available.
T | Underlying data type to be extracted. Must be an integral type. |
val | Destination of unpack operation. |
Definition at line 224 of file ByteVector.hpp.
|
inline |
unpack Extracts a boolen from a single byte
val | Destination of unpack operation. |
Definition at line 238 of file ByteVector.hpp.
|
inline |
Extracts floating point numbers from the ByteVector. Consumes a number of bytes matching sizeof(T). Fails if not enough bytes are available.
T | Underlying data type to be extracted. Must be a floating point type. |
val | Destination of unpack operation. |
Definition at line 256 of file ByteVector.hpp.
|
inline |
Extracts data from the ByteVector and stores it in a std::string. Consumes all remaining data unless instructed otherwise.
val | Destination of unpack operation. |
count | Max number of bytes to extract. Optional, if unset, all remaining bytes will be consumed. |
Definition at line 271 of file ByteVector.hpp.
|
inline |
Extracts data from the ByteVector and stores it in a another ByteVector. Consumes all remaining data unless instructed otherwise.
val | Destination of unpack operation. |
count | Max number of bytes to extract. Optional, if unset, all remaining bytes will be consumed. |
Definition at line 295 of file ByteVector.hpp.
|
inline |
Unpacks scaled value types (e.g. scaled int to floating point) as val = (packed_val/scale)-offset.
encoding_T | data type used to store the scaled value (usually an integral type) |
T1 | type of output value (usually a floating point type) |
T2 | type of scale and offset coefficients |
val | Destination of unpack operation |
scale | Value of scaling to apply to the offset value |
offset | Value of offset to apply to the input value (optional, defaults to 0) |
Definition at line 324 of file ByteVector.hpp.
|
inline |
unpack Unpacks an an object which inherits from type Packable
val | Reference to object to be unpacked |
Definition at line 341 of file ByteVector.hpp.
|
inline |
Unpacks Value types other than string and ByteVector specializations.
T | Type of the Value<T> being packed. May be automatically deduced from arguments |
val | The destination of the unpack operation |
Definition at line 353 of file ByteVector.hpp.
|
inline |
Extracts data from the ByteVector and stores it in a Value<std::string>. Consumes all remaining data unless instructed otherwise.
val | Destination of unpack operation. |
count | Max number of bytes to extract. Optional, if unset, all remaining bytes will be consumed. |
Definition at line 366 of file ByteVector.hpp.
|
inline |
Extracts data from the ByteVector and stores it in a Value<ByteVector>. Consumes all remaining data unless instructed otherwise.
val | Destination of unpack operation. |
count | Max number of bytes to extract. Optional, if unset, all remaining bytes will be consumed. |
Definition at line 380 of file ByteVector.hpp.
|
inline |
Unpacks scaled Value types (e.g. scaled int to floating point) as val = (packed_val/scale)-offset.
encoding_T | data type used to store the scaled Value (usually an integral type) |
T1 | type of output Value (usually a floating point type) |
T2 | type of scale and offset coefficients (default: float) |
val | Destination of unpack operation |
scale | Value of scaling to apply to the offset value |
offset | Value of offset to apply to the input value (optional, defaults to 0) |
Definition at line 403 of file ByteVector.hpp.
|
inline |
Gives an iterator to the next element ready for unpacking.
Definition at line 418 of file ByteVector.hpp.
|
inline |
Gives an iterator to the next element ready for unpacking.
Definition at line 426 of file ByteVector.hpp.
|
inline |
Gives the number of bytes which have already been consumed by unpack operations.
Definition at line 412 of file ByteVector.hpp.
|
inline |
Returns the number of bytes still avialable for unpacking.
Definition at line 448 of file ByteVector.hpp.
|
mutableprotected |
Definition at line 451 of file ByteVector.hpp.