mal-packet-weaver
C++20 packet serialization/deserialization library.
|
A dynamically resizable array of bytes. More...
#include "byte-helper.hpp"
Public Member Functions | |
template<typename T > | |
constexpr T * | as () |
Convert the ByteArray to a typed pointer. | |
template<typename T > | |
constexpr const T * | as () const |
Convert the ByteArray to a const typed pointer. | |
constexpr ByteView | as_view () const |
Convert the ByteArray to a ByteView. | |
template<typename First , typename Second , typename... Args> | |
void | append (First &&first, Second &&second, Args &&...args) |
Append multiple data sources to the byte array. | |
template<typename First , typename Second > | |
void | append (First &&first, Second &&second) |
Append two data sources to the byte array. | |
template<typename T > requires (sizeof(T) == sizeof(std::byte)) | |
void | append (const std::vector< T > &other) |
Append a vector of data to the byte array. | |
template<typename T > requires (sizeof(T) == sizeof(std::byte)) | |
void | append (const std::span< T > &other) |
Append a span of data to the byte array. | |
template<typename T > requires (sizeof(T) == sizeof(std::byte)) | |
void | append (const std::basic_string< T > &other) |
Append a string of data to the byte array. | |
template<typename T > requires (sizeof(T) == sizeof(std::byte)) | |
void | append (const std::basic_string_view< T > &other) |
Append a string view of data to the byte array. | |
constexpr ByteView | view (size_t from=0) const |
Create a ByteView of a subsequence of the byte array. | |
constexpr ByteView | view (size_t from, size_t length) const |
Create a ByteView of a subsequence of the byte array. | |
Static Public Member Functions | |
template<typename... Args> | |
static ByteArray | from_byte_arrays (Args &&...args) |
Create a byte array from multiple data sources. | |
template<std::integral Integer> | |
static ByteArray | from_integral (const Integer integer) |
Create a byte array from an integral value. | |
Public Attributes | |
T | elements |
STL member. | |
A dynamically resizable array of bytes.
ByteArray is a wrapper around std::vector<std::byte> with additional functionality for convenient manipulation of byte data.
Definition at line 88 of file byte-helper.hpp.
|
inline |
Append a string of data to the byte array.
This function appends the characters of the provided string to the end of the byte array.
T | The character type of the string. |
other | The string to append. |
Definition at line 231 of file byte-helper.hpp.
|
inline |
Append a string view of data to the byte array.
This function appends the characters of the provided string view to the end of the byte array.
T | The character type of the string view. |
other | The string view to append. |
Definition at line 255 of file byte-helper.hpp.
|
inline |
Append a span of data to the byte array.
This function appends the elements of the provided span to the end of the byte array.
T | The type of elements in the span. |
other | The span to append. |
Definition at line 206 of file byte-helper.hpp.
|
inline |
Append a vector of data to the byte array.
This function appends the elements of the provided vector to the end of the byte array.
T | The type of elements in the vector. |
other | The vector to append. |
Definition at line 181 of file byte-helper.hpp.
|
inline |
Append two data sources to the byte array.
This function appends the provided data sources to the end of the byte array.
First | The type of the first data source. |
Second | The type of the second data source. |
first | The first data source. |
second | The second data source. |
Definition at line 164 of file byte-helper.hpp.
|
inline |
Append multiple data sources to the byte array.
This function appends the provided data sources to the end of the byte array.
First | The type of the first data source. |
Second | The type of the second data source. |
Args | The types of additional data sources. |
first | The first data source. |
second | The second data source. |
args | Additional data sources. |
Definition at line 146 of file byte-helper.hpp.
|
inlinenodiscardconstexpr |
Convert the ByteArray to a typed pointer.
This function interprets the underlying byte data as a sequence of the specified type and returns a pointer to the first element.
T | The type to interpret the byte data as. |
Definition at line 104 of file byte-helper.hpp.
|
inlinenodiscardconstexpr |
Convert the ByteArray to a const typed pointer.
This function interprets the underlying byte data as a sequence of the specified type and returns a const pointer to the first element.
T | The type to interpret the byte data as. |
Definition at line 119 of file byte-helper.hpp.
|
inlinenodiscardconstexpr |
|
inlinestatic |
Create a byte array from multiple data sources.
This static function creates a new byte array by appending the provided data sources.
Args | The types of data sources. |
args | Data sources to append to the new byte array. |
Definition at line 279 of file byte-helper.hpp.
|
inlinestatic |
Create a byte array from an integral value.
This static function creates a new byte array containing the binary representation of the provided integral value.
Integer | The type of the integral value. |
integer | The integral value to convert to a byte array. |
Definition at line 303 of file byte-helper.hpp.
Create a ByteView of a subsequence of the byte array.
This function creates a ByteView that represents a subsequence of the byte array, starting from the specified index.
from | The starting index of the subview. |
length | The length of the subview. |
Definition at line 335 of file byte-helper.hpp.
Create a ByteView of a subsequence of the byte array.
This function creates a ByteView that represents a subsequence of the byte array, starting from the specified index.
from | The starting index of the subview. |
Definition at line 320 of file byte-helper.hpp.
|
inherited |
STL member.