Fixed-size byte array with hex string conversion. More...
#include <bytearray.h>
Public Types | |
| using | Ptr = SharedPtr< ByteArray > |
| using | DataType = std::array< uint8_t, NumBytes > |
Public Member Functions | |
| ByteArray () | |
| Default constructor. Value-initializes all bytes to zero. | |
| ByteArray (const DataType &val) | |
| Constructs from a std::array. | |
| ByteArray (const DataType &&val) | |
| Move-constructs from a std::array. | |
| ByteArray (const uint8_t *src) | |
| Constructs from a raw byte pointer. Copies NumBytes from src. | |
| ~ByteArray () | |
| Destructor. | |
| constexpr size_t | size () const |
| Returns the number of bytes. | |
| uint8_t & | operator[] (size_t index) |
| Returns a mutable reference to the byte at index. | |
| const uint8_t & | operator[] (size_t index) const |
| Returns a const reference to the byte at index. | |
| uint8_t * | data () |
| Returns a mutable pointer to the underlying data. | |
| const uint8_t * | data () const |
| Returns a const pointer to the underlying data. | |
| bool | isZero () const |
| Returns true if all bytes are zero. | |
| String | toHexString () const |
| Converts the byte array to a lowercase hexadecimal string. | |
Static Public Member Functions | |
| static ByteArray | fromHexString (const char *str, Error *err=nullptr) |
| Constructs a ByteArray from a hexadecimal C string. | |
| static ByteArray | fromHexString (const String &str, Error *err=nullptr) |
| Constructs a ByteArray from a hexadecimal String. | |
Friends | |
| bool | operator== (const ByteArray &lhs, const ByteArray &rhs) |
| Returns true if both arrays contain identical bytes. | |
| bool | operator!= (const ByteArray &lhs, const ByteArray &rhs) |
| Returns true if the arrays differ. | |
Fixed-size byte array with hex string conversion.
A specialization of fixed-size array for uint8_t data, providing conversion to and from hexadecimal strings.
| NumBytes | Number of bytes (fixed at compile time). |
Converts the byte array to a lowercase hexadecimal string.