|
libdoip
0.1.0
DoIP (Diagnostics over Internet Protocol) ISO 13400 C++17 Library
|
A dynamic array of bytes with utility methods for network protocol handling. More...
#include <ByteArray.h>


Public Member Functions | |
| ByteArray ()=default | |
| Default constructor - creates an empty ByteArray. More... | |
| ByteArray (const uint8_t *data, size_t size) | |
| Constructs a ByteArray from a raw byte array. More... | |
| ByteArray (const std::initializer_list< uint8_t > &init_list) | |
| void | writeU16At (size_t index, uint16_t value) |
| Writes a 16-bit unsigned integer in big-endian format at a specific index. More... | |
| void | writeU16BE (uint16_t value) |
| Appends a 16-bit unsigned integer in big-endian format to the end. More... | |
| void | writeU32At (size_t index, uint32_t value) |
| Writes a 32-bit unsigned integer in big-endian format at a specific index. More... | |
| void | writeU32BE (uint32_t value) |
| Appends a 32-bit unsigned integer in big-endian format to the end. More... | |
| template<typename E > | |
| void | writeEnum (E value) |
| template<typename E > | |
| void | writeEnumAt (size_t index, E value) |
| Writes an enum class value at a specific index as its underlying integral type. More... | |
| uint16_t | readU16BE (size_t index) const |
| Reads a 16-bit unsigned integer in big-endian format from a specific index. More... | |
| uint32_t | readU32BE (size_t index) const |
| Reads a 32-bit unsigned integer in big-endian format from a specific index. More... | |
| template<typename E > | |
| E | readEnum (size_t index) const |
A dynamic array of bytes with utility methods for network protocol handling.
ByteArray extends std::vector<uint8_t> with convenient methods for reading and writing multi-byte integer values in big-endian format (network byte order). This is commonly used in DoIP and other network protocols.
Definition at line 60 of file ByteArray.h.
|
default |
Default constructor - creates an empty ByteArray.
|
inlineexplicit |
Constructs a ByteArray from a raw byte array.
| data | Pointer to the source byte array |
| size | Number of bytes to copy from the source array |
Definition at line 72 of file ByteArray.h.
|
inline |
Definition at line 82 of file ByteArray.h.
|
inline |
Definition at line 265 of file ByteArray.h.
References readU16BE(), and readU32BE().
|
inline |
Reads a 16-bit unsigned integer in big-endian format from a specific index.
Reads 2 bytes starting at the specified index and interprets them as a 16-bit unsigned integer in big-endian (network) byte order.
| index | Starting index to read from (must be < size() - 1) |
| std::out_of_range | if index + 1 >= size() |
Definition at line 224 of file ByteArray.h.
References doip::util::readU16BE().
Referenced by readEnum().
|
inline |
Reads a 32-bit unsigned integer in big-endian format from a specific index.
Reads 4 bytes starting at the specified index and interprets them as a 32-bit unsigned integer in big-endian (network) byte order.
| index | Starting index to read from (must be < size() - 3) |
| std::out_of_range | if index + 3 >= size() |
Definition at line 241 of file ByteArray.h.
References doip::util::readU32BE().
Referenced by doip::DoIPMessage::getPayloadLengthFromHeader(), and readEnum().
|
inline |
Definition at line 165 of file ByteArray.h.
References writeU16BE(), and writeU32BE().
Referenced by doip::DoIPMessage::buildMessage(), doip::message::makeRoutingActivationRequest(), and doip::message::makeVehicleIdentificationResponse().
|
inline |
Writes an enum class value at a specific index as its underlying integral type.
Overwrites bytes starting at the specified index with the enum value converted to its underlying integral type in big-endian format.
| E | Enum class type |
| index | Starting index where to write |
| value | The enum value to write |
| std::out_of_range | if not enough space at index |
Definition at line 194 of file ByteArray.h.
References writeU16At(), and writeU32At().
|
inline |
Writes a 16-bit unsigned integer in big-endian format at a specific index.
Overwrites 2 bytes starting at the specified index with the value in big-endian (network) byte order.
| index | Starting index where to write (must be < size() - 1) |
| value | The 16-bit value to write |
| std::out_of_range | if index + 1 >= size() |
Definition at line 94 of file ByteArray.h.
Referenced by writeEnumAt().
|
inline |
Appends a 16-bit unsigned integer in big-endian format to the end.
Adds 2 bytes to the end of the ByteArray representing the value in big-endian (network) byte order.
| value | The 16-bit value to append |
Definition at line 110 of file ByteArray.h.
Referenced by doip::message::makeAliveCheckResponse(), doip::message::makeDiagnosticMessage(), doip::message::makeDiagnosticNegativeResponse(), doip::message::makeDiagnosticPositiveResponse(), doip::message::makeRoutingActivationRequest(), doip::message::makeRoutingActivationResponse(), doip::message::makeVehicleIdentificationResponse(), doip::DoIPDefaultConnection::sendRoutingActivationResponse(), and writeEnum().
|
inline |
Writes a 32-bit unsigned integer in big-endian format at a specific index.
Overwrites 4 bytes starting at the specified index with the value in big-endian (network) byte order.
| index | Starting index where to write (must be < size() - 3) |
| value | The 32-bit value to write |
| std::out_of_range | if index + 3 >= size() |
Definition at line 125 of file ByteArray.h.
Referenced by writeEnumAt().
|
inline |
Appends a 32-bit unsigned integer in big-endian format to the end.
Adds 4 bytes to the end of the ByteArray representing the value in big-endian (network) byte order.
| value | The 32-bit value to append |
Definition at line 143 of file ByteArray.h.
Referenced by doip::DoIPMessage::buildMessage(), and writeEnum().