libhomegear-base
0.7
Base library for Homegear and Homegear family modules.
|
#include <BitReaderWriter.h>
Public Member Functions | |
virtual | ~BitReaderWriter () |
Static Public Member Functions | |
static std::vector< uint8_t > | getPosition (const std::vector< uint8_t > &data, uint32_t position, uint32_t size) |
Reads any number of bits at any position from a byte array. More... | |
static std::vector< uint8_t > | getPosition (const std::vector< char > &data, uint32_t position, uint32_t size) |
Reads any number of bits at any position from a byte array. More... | |
static uint8_t | getPosition8 (const std::vector< uint8_t > &data, uint32_t position, uint32_t size) |
Reads up to 8 bits at any position from a byte array and returns it as an uint8_t. More... | |
static uint16_t | getPosition16 (const std::vector< uint8_t > &data, uint32_t position, uint32_t size) |
Reads up to 16 bits at any position from a byte array and returns it as an uint16_t. More... | |
static uint32_t | getPosition32 (const std::vector< uint8_t > &data, uint32_t position, uint32_t size) |
Reads up to 32 bits at any position from a byte array and returns it as an uint32_t. More... | |
static uint64_t | getPosition64 (const std::vector< uint8_t > &data, uint32_t position, uint32_t size) |
Reads up to 64 bits at any position from a byte array and returns it as an uint64_t. More... | |
static void | setPositionLE (uint32_t position, uint32_t size, std::vector< uint8_t > &target, const std::vector< uint8_t > &source) |
Sets any number of bits at any position in a byte array. More... | |
static void | setPositionLE (uint32_t position, uint32_t size, std::vector< char > &target, const std::vector< uint8_t > &source) |
Sets any number of bits at any position in a byte array. More... | |
static void | setPositionBE (uint32_t position, uint32_t size, std::vector< uint8_t > &target, const std::vector< uint8_t > &source) |
Sets any number of bits at any position in a byte array. More... | |
static void | setPositionBE (uint32_t position, uint32_t size, std::vector< char > &target, const std::vector< uint8_t > &source) |
Sets any number of bits at any position in a byte array. More... | |
|
virtual |
|
static |
Reads any number of bits at any position from a byte array.
It is ok for position + size to exceed the array boundaries.
data | The byte array to read from. Index 0 must be the most significant byte. |
position | The position in bits starting with bit 7 of index 0 (position 1 is bit 6 of index 0 and so on). Example: If data is 00101000 00001000, position is 2 and size is 3 then the result is 00000101. |
size | The size in bits of the data to read. |
|
static |
Reads any number of bits at any position from a byte array.
It is ok for position + size to exceed the array boundaries.
data | The byte array to read from. Index 0 must be the most significant byte. |
position | The position in bits starting with bit 7 of index 0 (position 1 is bit 6 of index 0 and so on). Example: If data is 00101000 00001000, position is 2 and size is 3 then the result is 00000101. |
size | The size in bits of the data to read. |
|
static |
Reads up to 16 bits at any position from a byte array and returns it as an uint16_t.
data | The byte array to read from. Index 0 must be the most significant byte. |
position | The position in bits starting with bit 7 of index 0 (position 1 is bit 6 of index 0 and so on). Example: If data is 00101000 00001000, position is 2 and size is 3 then the result is 00000101. |
size | The size in bits of the data to read. |
|
static |
Reads up to 32 bits at any position from a byte array and returns it as an uint32_t.
data | The byte array to read from. Index 0 must be the most significant byte. |
position | The position in bits starting with bit 7 of index 0 (position 1 is bit 6 of index 0 and so on). Example: If data is 00101000 00001000, position is 2 and size is 3 then the result is 00000101. |
size | The size in bits of the data to read. |
|
static |
Reads up to 64 bits at any position from a byte array and returns it as an uint64_t.
data | The byte array to read from. Index 0 must be the most significant byte. |
position | The position in bits starting with bit 7 of index 0 (position 1 is bit 6 of index 0 and so on). Example: If data is 00101000 00001000, position is 2 and size is 3 then the result is 00000101. |
size | The size in bits of the data to read. |
|
static |
Reads up to 8 bits at any position from a byte array and returns it as an uint8_t.
data | The byte array to read from. Index 0 must be the most significant byte. |
position | The position in bits starting with bit 7 of index 0 (position 1 is bit 6 of index 0 and so on). Example: If data is 00101000, position is 2 and size is 3 then the result is 00000101. |
size | The size in bits of the data to read. |
|
static |
Sets any number of bits at any position in a byte array.
The source bytes are read MSB first (i. e. most significant byte at the smallest index). For example 0xABCD in source stays 0xABCD in target.
position | The position in bits starting with bit 7 of index 0 (position 1 is bit 6 of index 0 and so on). Example: If source is 00000101, position is 2, size is 3 and target.size() is 2 then the result is 00101000 00000000. |
size | The size in bits of the data to set. |
target | The byte array to write to. Index 0 is the most significant byte. When target is larger than ceil(size / 8.0) bytes, the last (bytes with higher index) ceil(size / 8.0) bytes are used. |
source | The right aligned byte array of the data to set. Bytes are read LSB first by default and set at position in target (counted from the most significant bit of the most significant byte). |
|
static |
Sets any number of bits at any position in a byte array.
The source bytes are read MSB first (i. e. most significant byte at the smallest index). For example 0xABCD in source stays 0xABCD in target.
position | The position in bits starting with bit 7 of index 0 (position 1 is bit 6 of index 0 and so on). Example: If source is 00000101, position is 2, size is 3 and target.size() is 2 then the result is 00101000 00000000. |
size | The size in bits of the data to set. |
target | The byte array to write to. Index 0 is the most significant byte. When target is larger than ceil(size / 8.0) bytes, the last (bytes with higher index) ceil(size / 8.0) bytes are used. |
source | The right aligned byte array of the data to set. Bytes are read LSB first by default and set at position in target (counted from the most significant bit of the most significant byte). |
|
static |
Sets any number of bits at any position in a byte array.
The source bytes are read LSB first (i. e. least significant byte at the smallest index). For example 0xABCD in source becomes 0xCDAB in target.
position | The position in bits starting with bit 7 of index 0 (position 1 is bit 6 of index 0 and so on). Example: If source is 00000101, position is 2, size is 3 and target.size() is 2 then the result is 00101000 00000000. |
size | The size in bits of the data to set. |
target | The byte array to write to. Index 0 is the most significant byte. |
source | The right aligned byte array of the data to set. Bytes are read MSB first by default and set at position in target (counted from the most significant bit of the most significant byte). |
|
static |
Sets any number of bits at any position in a byte array.
The source bytes are read LSB first (i. e. least significant byte at the smallest index). For example 0xABCD in source becomes 0xCDAB in target.
position | The position in bits starting with bit 7 of index 0 (position 1 is bit 6 of index 0 and so on). Example: If source is 00000101, position is 2, size is 3 and target.size() is 2 then the result is 00101000 00000000. Example 2: If source is 0xABCD, position is 0 and size is 16, the result is 0xCDAB. |
size | The size in bits of the data to set. |
target | The byte array to write to. Index 0 is the most significant byte. |
source | The right aligned byte array of the data to set. Bytes are read LSB first by default and set at position in target (counted from the most significant bit of the most significant byte). |