nw::ByteArray

struct ByteArray

Public Types

using Base = Vector<uint8_t>
using iterator = Base::iterator
using const_iterator = Base::const_iterator
using size_type = Base::size_type

Public Functions

ByteArray() = default
ByteArray(const uint8_t *buffer, size_t len)
ByteArray(ByteArray&&) = default
ByteArray(const ByteArray&) = default
ByteArray &operator=(ByteArray&&) = default
ByteArray &operator=(const ByteArray&) = default
inline bool operator==(const ByteArray &other) const
inline uint8_t &operator[](size_type pos)
inline const uint8_t &operator[](size_type pos) const
void append(const void *buffer, size_t len)

Appends bytes to the array.

inline void clear()

Clears the data in the array.

inline uint8_t *data() noexcept

Returns pointer to the underlying array.

inline const uint8_t *data() const noexcept

Returns pointer to the underlying array.

inline void push_back(uint8_t byte)

Appends one element to the array.

bool read_at(size_t offset, void *buffer, size_t size) const

Reads size bytes at offset into an arbitrary buffer

inline void reserve(size_type count)

Increases the capacity of the array by count elements.

inline void resize(size_type count)

Resizes array to contain count elements. If greater, than current size, null padded.

inline size_type size() const noexcept

Returns the number of bytes.

inline std::span<uint8_t> span()

Construct std::span.

inline std::span<const uint8_t> span() const

Construct std::span.

StringView string_view() const

Constructs string view of the array.

bool write_to(const std::filesystem::path &path) const

Write contents to file.

Public Static Functions

static ByteArray from_file(const std::filesystem::path &path)

Load a file into memory.