#include <ByteArrayUtil.h>
|
static std::vector< uint8_t > | fromHex (const std::string &hex) |
|
static std::string | toHex (const std::vector< char > &byteArray) |
|
static std::string | toHex (const std::vector< uint8_t > &byteArray) |
|
static int | twoBytesToInt (const std::vector< uint8_t > &bytes, const int offset) |
|
static int | twoBytesSignedToInt (const std::vector< uint8_t > &bytes, const int offset) |
|
static int | threeBytesToInt (const std::vector< uint8_t > &bytes, const int offset) |
|
static int | threeBytesSignedToInt (const std::vector< uint8_t > &bytes, const int offset) |
|
static int | fourBytesToInt (const std::vector< uint8_t > &bytes, const int offset) |
|
◆ fourBytesToInt()
int keyple::core::util::ByteArrayUtil::fourBytesToInt |
( |
const std::vector< uint8_t > & |
bytes, |
|
|
const int |
offset |
|
) |
| |
|
static |
Convert four bytes from a byte array into an integer.
The four bytes are expected to be in the MSB first order (aka network order).
Throw an exception if the buffer is null or not long enough to contain 4 bytes.
- Parameters
-
bytes | byte array |
offset | offset from which the 4 bytes are |
- Returns
- the resulting int
- Exceptions
-
IllegalArgumentException | if the buffer has a bad length |
◆ fromHex()
std::vector< uint8_t > keyple::core::util::ByteArrayUtil::fromHex |
( |
const std::string & |
hex | ) |
|
|
static |
Create a byte array from an hexa string. This method allows spaces and "h".
- Parameters
-
- Returns
- byte array
◆ threeBytesSignedToInt()
int keyple::core::util::ByteArrayUtil::threeBytesSignedToInt |
( |
const std::vector< uint8_t > & |
bytes, |
|
|
const int |
offset |
|
) |
| |
|
static |
Convert three bytes (signed) from a byte array into an integer.
The three bytes are expected to be in the MSB first order (aka network order).
The number is also considered as signed. That is, if the MSB (first left bit) is 1, then the number is negative and the conversion is done accordingly with the usual binary arithmetic.
Throw an exception if the buffer is null or not long enough to contain all 3 bytes.
- Parameters
-
bytes | byte array containing a 3-byte signed number |
offset | offset from which the 3 bytes are |
- Returns
- the resulting int
- Exceptions
-
IllegalArgumentException | if the buffer has a bad length |
◆ threeBytesToInt()
int keyple::core::util::ByteArrayUtil::threeBytesToInt |
( |
const std::vector< uint8_t > & |
bytes, |
|
|
const int |
offset |
|
) |
| |
|
static |
Convert three bytes from a byte array into an integer.
The three bytes are expected to be in the MSB first order (aka network order).
Throw an exception if the buffer is null or not long enough to contain all 3 bytes.
- Parameters
-
bytes | byte array |
offset | offset from which the 3 bytes are |
- Returns
- the resulting int
- Exceptions
-
IllegalArgumentException | if the buffer has a bad length |
◆ toHex() [1/2]
std::string keyple::core::util::ByteArrayUtil::toHex |
( |
const std::vector< char > & |
byteArray | ) |
|
|
static |
Represents the byte array in a hexadecimal string.
- Parameters
-
byteArray | byte array to represent to hex |
- Returns
- Hex representation of the byte array
◆ toHex() [2/2]
std::string keyple::core::util::ByteArrayUtil::toHex |
( |
const std::vector< uint8_t > & |
byteArray | ) |
|
|
static |
Represents the byte array in a hexadecimal string.
- Parameters
-
byteArray | byte array to represent to hex |
- Returns
- Hex representation of the byte array
◆ twoBytesSignedToInt()
int keyple::core::util::ByteArrayUtil::twoBytesSignedToInt |
( |
const std::vector< uint8_t > & |
bytes, |
|
|
const int |
offset |
|
) |
| |
|
static |
Convert two bytes (signed) from a byte array into an integer.
The two bytes are expected to be in the MSB first order (aka network order).
The number is also considered as signed. That is, if the MSB (first left bit) is 1, then the number is negative and the conversion is done accordingly with the usual binary arithmetic.
Throw an exception if the buffer is null or not long enough to contain 2 bytes.
- Parameters
-
bytes | byte array |
offset | offset from which the 2 bytes are |
- Returns
- the resulting int
- Exceptions
-
IllegalArgumentException | if the buffer has a bad length |
◆ twoBytesToInt()
int keyple::core::util::ByteArrayUtil::twoBytesToInt |
( |
const std::vector< uint8_t > & |
bytes, |
|
|
const int |
offset |
|
) |
| |
|
static |
Convert two bytes (unsigned) from a byte array into an integer.
The two bytes are expected to be in the MSB first order (aka network order).
Throw an exception if the buffer is null or not long enough to contain 2 bytes.
- Parameters
-
bytes | byte array |
offset | offset from which the 2 bytes are |
- Returns
- the resulting int
- Exceptions
-
IllegalArgumentException | if the buffer has a bad length |
The documentation for this class was generated from the following files: