StormByte 2.0.0
C++26 foundation of the StormByte suite
 
Loading...
Searching...
No Matches
StormByte::BinaryData Class Referencefinal

DLL-boundary-safe owned contiguous sequence of std::byte. More...

#include <StormByte/binary_data.hxx>

Public Types

using value_type = std::byte
 Element type.
 
using size_type = std::size_t
 STL size typedef; size() returns StormByte::ByteSize.
 
using difference_type = std::ptrdiff_t
 Iterator difference.
 
using reference = std::byte &
 Mutable reference to an element.
 
using const_reference = const std::byte &
 Const reference to an element.
 
using pointer = std::byte *
 Mutable pointer and iterator.
 
using const_pointer = const std::byte *
 Const pointer and iterator.
 
using iterator = std::byte *
 Contiguous mutable iterator.
 
using const_iterator = const std::byte *
 Contiguous const iterator.
 
using reverse_iterator = std::reverse_iterator< iterator >
 Reverse iterator.
 
using const_reverse_iterator = std::reverse_iterator< const_iterator >
 Const reverse iterator.
 

Public Member Functions

 BinaryData () noexcept
 Construct an empty sequence.
 
 BinaryData (const StormByte::ByteSize &count, std::byte value)
 Construct count bytes filled with value.
 
 BinaryData (const StormByte::ByteSize &count)
 Construct count zeroed bytes.
 
 BinaryData (std::span< const std::byte > bytes)
 Copy bytes from a contiguous span.
 
 BinaryData (const std::byte *bytes, const StormByte::ByteSize &count)
 Copy count bytes starting at bytes.
 
 BinaryData (std::initializer_list< std::byte > list)
 Copy from an initializer list.
 
 BinaryData (std::string_view sv)
 Copy character bytes from a string view (no trailing NUL).
 
 BinaryData (const char *s)
 Copy character bytes from a C string (no trailing NUL).
 
 BinaryData (const std::vector< std::byte > &bytes)
 Copy bytes from a caller-owned vector onto Base's heap.
 
 BinaryData (std::vector< std::byte > &&bytes)
 Copy bytes from a caller-owned vector onto Base's heap, then empty bytes.
 
template<Type::ByteInputRange R>
 BinaryData (const R &range)
 Copy from an input range of byte-convertible values.
 
template<Type::ByteInputRange R>
 BinaryData (R &&range)
 Consume an rvalue range.
 
 BinaryData (const BinaryData &other)
 Copy construct.
 
 BinaryData (BinaryData &&other) noexcept
 Move construct.
 
 ~BinaryData () noexcept
 Destroy the sequence on Base's heap.
 
BinaryData & operator= (const BinaryData &other)
 Copy assign.
 
BinaryData & operator= (BinaryData &&other) noexcept
 Move assign.
 
BinaryData & operator= (std::initializer_list< std::byte > list)
 Replace contents with an initializer list.
 
bool operator== (const BinaryData &other) const noexcept
 Equality of byte contents.
 
bool operator!= (const BinaryData &other) const noexcept
 Inequality of byte contents.
 
std::strong_ordering operator<=> (const BinaryData &other) const noexcept
 Three-way lexicographical comparison (same order as std::vector).
 
bool operator== (std::span< const std::byte > bytes) const noexcept
 Equality with a byte span.
 
bool operator!= (std::span< const std::byte > bytes) const noexcept
 Inequality with a byte span.
 
std::strong_ordering operator<=> (std::span< const std::byte > bytes) const noexcept
 Three-way comparison with a byte span.
 
iterator begin () noexcept
 Mutable iterator to the first byte.
 
const_iterator begin () const noexcept
 Const iterator to the first byte.
 
iterator end () noexcept
 Mutable iterator one past the last byte.
 
const_iterator end () const noexcept
 Const iterator one past the last byte.
 
const_iterator cbegin () const noexcept
 Const iterator to the first byte.
 
const_iterator cend () const noexcept
 Const iterator one past the last byte.
 
reverse_iterator rbegin () noexcept
 Mutable reverse iterator to the last byte.
 
reverse_iterator rend () noexcept
 Mutable reverse iterator to before the first byte.
 
const_reverse_iterator rbegin () const noexcept
 Const reverse iterator to the last byte.
 
const_reverse_iterator rend () const noexcept
 Const reverse iterator to before the first byte.
 
const_reverse_iterator crbegin () const noexcept
 Const reverse iterator to the last byte.
 
const_reverse_iterator crend () const noexcept
 Const reverse iterator to before the first byte.
 
StormByte::ByteSize size () const noexcept
 Occupied length in bytes.
 
StormByte::ByteSize max_size () const noexcept
 Implementation maximum size in bytes.
 
StormByte::ByteSize capacity () const noexcept
 Allocated capacity in bytes.
 
bool empty () const noexcept
 Whether the sequence holds no bytes.
 
void reserve (const StormByte::ByteSize &new_cap)
 Request capacity of at least new_cap bytes.
 
void resize (const StormByte::ByteSize &new_size)
 Resize to new_size bytes.
 
void resize (const StormByte::ByteSize &new_size, std::byte value)
 Resize to new_size bytes.
 
void shrink_to_fit ()
 Release unused capacity when the implementation allows it.
 
void clear () noexcept
 Drop every byte.
 
std::byte & operator[] (const StormByte::ByteSize &index) noexcept
 Unchecked mutable subscript.
 
const std::byte & operator[] (const StormByte::ByteSize &index) const noexcept
 Unchecked const subscript.
 
std::byte & at (const StormByte::ByteSize &index)
 Checked mutable subscript.
 
const std::byte & at (const StormByte::ByteSize &index) const
 Checked const subscript.
 
std::byte & front ()
 First byte.
 
const std::byte & front () const
 First byte.
 
std::byte & back ()
 Last byte.
 
const std::byte & back () const
 Last byte.
 
std::byte * data () noexcept
 Mutable pointer to the first byte, or nullptr when empty.
 
const std::byte * data () const noexcept
 Const pointer to the first byte, or nullptr when empty.
 
std::span< std::byte > span () noexcept
 Mutable view of the occupied bytes.
 
std::span< const std::byte > span () const noexcept
 Const view of the occupied bytes.
 
 operator std::span< std::byte > () noexcept
 Implicit mutable span conversion.
 
 operator std::span< const std::byte > () const noexcept
 Implicit const span conversion.
 
STORMBYTE_FORCE_INLINE operator std::vector< std::byte > () const &
 Copy bytes onto the caller CRT as a std::vector.
 
STORMBYTE_FORCE_INLINE operator std::vector< std::byte > () &&
 Copy bytes onto the caller CRT, then release this object's storage.
 
void assign (const StormByte::ByteSize &count, std::byte value)
 Replace contents with count copies of value.
 
void assign (std::span< const std::byte > bytes)
 Replace contents with a copy of bytes.
 
void assign (std::initializer_list< std::byte > list)
 Replace contents with an initializer list.
 
template<typename InputIt >
void assign (InputIt first, InputIt last)
 Replace contents with the range [first, last).
 
void append (std::span< const std::byte > bytes)
 Append a copy of bytes.
 
void append (const std::byte *bytes, const StormByte::ByteSize &count)
 Append count bytes starting at bytes.
 
void append (const BinaryData &other)
 Append a copy of other.
 
void append (BinaryData &&other)
 Append other, then empty it.
 
BinaryData & operator+= (std::span< const std::byte > bytes)
 Append a copy of bytes.
 
BinaryData & operator+= (const BinaryData &other)
 Append a copy of other.
 
BinaryData & operator+= (BinaryData &&other)
 Append other, then empty it.
 
void push_back (std::byte value)
 Append one byte.
 
template<typename T >
reference emplace_back (T &&value)
 Append a byte constructed in place.
 
void pop_back ()
 Remove the last byte.
 
iterator insert (const_iterator pos, std::byte value)
 Insert one byte before pos.
 
iterator insert (const_iterator pos, const StormByte::ByteSize &count, std::byte value)
 Insert count copies of value before pos.
 
iterator insert (const_iterator pos, std::initializer_list< std::byte > list)
 Insert an initializer list before pos.
 
iterator insert (const_iterator pos, std::span< const std::byte > bytes)
 Insert a span before pos.
 
template<typename InputIt >
iterator insert (const_iterator pos, InputIt first, InputIt last)
 Insert the range [first, last) before pos.
 
iterator erase (const_iterator pos)
 Erase the byte at pos.
 
iterator erase (const_iterator first, const_iterator last)
 Erase [first, last).
 
void swap (BinaryData &other) noexcept
 Exchange storage with other.
 
CString HexDump () const
 Hexadecimal dump of the occupied bytes, sixteen bytes per row.
 
CString HexDump (Size columns) const
 Hexadecimal dump of the occupied bytes.
 

Detailed Description

DLL-boundary-safe owned contiguous sequence of std::byte.

Why this type exists
Suite modules must not put std::vector<std::byte> in a public signature that can cross a shared-library boundary (Windows DLL, or mismatched libc++ / libstdc++ on Unix).

A std::vector constructed in the application and mutated inside a StormByte shared library — or returned and destroyed on the other side — allocates and frees with two heaps. That is undefined behaviour whenever the two sides do not share one CRT.

BinaryData owns its bytes on Base's heap. Allocation, growth and destruction run in this library. The header exposes contiguous std::byte* iterators, std::span views and a vector-like API so <algorithm> and std::ranges keep working.

Occupied length, capacity and byte offsets are ByteSize. HexDump column width is Size (a count of columns, not a payload).

Member names are lowercase to match std::vector.

Construction from / conversion to std::vector
Bytes can be copied in from a caller-owned std::vector and copied out to a caller-owned std::vector. The rvalue overloads look like a move: the source is emptied after the copy. They are not a heap steal. BinaryData storage is allocated and freed by Base; std::vector storage is allocated and freed by the caller CRT. Donating the pointer across those heaps would reintroduce the boundary this type exists to close. Peak usage is two copies during the transfer; afterwards the emptied side can release its allocation.
Thread safety
Not thread-safe. Callers that share an instance must synchronise.

Member Typedef Documentation

◆ const_iterator

Contiguous const iterator.

◆ const_pointer

Const pointer and iterator.

◆ const_reference

Const reference to an element.

◆ const_reverse_iterator

Const reverse iterator.

◆ difference_type

Iterator difference.

◆ iterator

Contiguous mutable iterator.

◆ pointer

Mutable pointer and iterator.

◆ reference

Mutable reference to an element.

◆ reverse_iterator

Reverse iterator.

◆ size_type

STL size typedef; size() returns StormByte::ByteSize.

◆ value_type

Element type.

Constructor & Destructor Documentation

◆ BinaryData() [1/14]

StormByte::BinaryData::BinaryData ( )
noexcept

Construct an empty sequence.

◆ BinaryData() [2/14]

StormByte::BinaryData::BinaryData ( const StormByte::ByteSize &  count,
std::byte  value 
)

Construct count bytes filled with value.

Parameters
countElement count.
valueFill byte.

◆ BinaryData() [3/14]

StormByte::BinaryData::BinaryData ( const StormByte::ByteSize &  count)
explicit

Construct count zeroed bytes.

Parameters
countElement count.

◆ BinaryData() [4/14]

StormByte::BinaryData::BinaryData ( std::span< const std::byte >  bytes)
explicit

Copy bytes from a contiguous span.

Parameters
bytesSource view (not owned).

◆ BinaryData() [5/14]

StormByte::BinaryData::BinaryData ( const std::byte *  bytes,
const StormByte::ByteSize &  count 
)

Copy count bytes starting at bytes.

Parameters
bytesSource pointer; may be null when count is zero.
countByte count.

◆ BinaryData() [6/14]

StormByte::BinaryData::BinaryData ( std::initializer_list< std::byte >  list)

Copy from an initializer list.

Parameters
listSource bytes.

◆ BinaryData() [7/14]

StormByte::BinaryData::BinaryData ( std::string_view  sv)
explicit

Copy character bytes from a string view (no trailing NUL).

Parameters
svSource characters.

◆ BinaryData() [8/14]

StormByte::BinaryData::BinaryData ( const char *  s)
explicit

Copy character bytes from a C string (no trailing NUL).

Parameters
sSource; a null pointer yields an empty sequence.

◆ BinaryData() [9/14]

StormByte::BinaryData::BinaryData ( const std::vector< std::byte > &  bytes)
explicit

Copy bytes from a caller-owned vector onto Base's heap.

Parameters
bytesSource. Remains valid and unchanged.
Note
Not a heap steal. The vector stays on the caller CRT.

◆ BinaryData() [10/14]

StormByte::BinaryData::BinaryData ( std::vector< std::byte > &&  bytes)
explicit

Copy bytes from a caller-owned vector onto Base's heap, then empty bytes.

Parameters
bytesSource. Cleared and shrunk after the copy.
Note
Looks like a move. Not a heap steal: Base cannot adopt the caller pointer. Peak usage is two copies during the transfer.

◆ BinaryData() [11/14]

template<Type::ByteInputRange R>
StormByte::BinaryData::BinaryData ( const R &  range)
explicit

Copy from an input range of byte-convertible values.

Template Parameters
RRange type satisfying StormByte::Type::ByteInputRange.
Parameters
rangeSource range.

◆ BinaryData() [12/14]

template<Type::ByteInputRange R>
StormByte::BinaryData::BinaryData ( R &&  range)
explicit

Consume an rvalue range.

Moves when R is an rvalue BinaryData.

Template Parameters
RRange type satisfying StormByte::Type::ByteInputRange.
Parameters
rangeSource range.
Note
An lvalue BinaryData is copied. StormByte::Type::SameAs ignores references, so the implementation uses StormByte::Type::LvalueReference before moving.

◆ BinaryData() [13/14]

StormByte::BinaryData::BinaryData ( const BinaryData &  other)

Copy construct.

Allocation runs in Base.

Parameters
otherSource sequence.

◆ BinaryData() [14/14]

StormByte::BinaryData::BinaryData ( BinaryData &&  other)
noexcept

Move construct.

other is left empty.

Parameters
otherSource sequence.

◆ ~BinaryData()

StormByte::BinaryData::~BinaryData ( )
noexcept

Destroy the sequence on Base's heap.

Member Function Documentation

◆ append() [1/4]

void StormByte::BinaryData::append ( BinaryData &&  other)

Append other, then empty it.

Parameters
otherSource sequence. Empty afterwards when it is not *this.
Note
Same-heap move when *this is empty.

◆ append() [2/4]

void StormByte::BinaryData::append ( const BinaryData &  other)

Append a copy of other.

Parameters
otherSource sequence.

◆ append() [3/4]

void StormByte::BinaryData::append ( const std::byte *  bytes,
const StormByte::ByteSize &  count 
)

Append count bytes starting at bytes.

Parameters
bytesSource pointer; may be null when count is zero.
countByte count.

◆ append() [4/4]

void StormByte::BinaryData::append ( std::span< const std::byte >  bytes)

Append a copy of bytes.

Parameters
bytesSource view.

◆ assign() [1/4]

void StormByte::BinaryData::assign ( const StormByte::ByteSize &  count,
std::byte  value 
)

Replace contents with count copies of value.

Parameters
countNew size.
valueFill byte.

◆ assign() [2/4]

template<typename InputIt >
void StormByte::BinaryData::assign ( InputIt  first,
InputIt  last 
)

Replace contents with the range [first, last).

Template Parameters
InputItInput iterator whose value converts to std::byte.
Parameters
firstStart of the source range.
lastEnd of the source range.

◆ assign() [3/4]

void StormByte::BinaryData::assign ( std::initializer_list< std::byte >  list)

Replace contents with an initializer list.

Parameters
listSource bytes.

◆ assign() [4/4]

void StormByte::BinaryData::assign ( std::span< const std::byte >  bytes)

Replace contents with a copy of bytes.

Parameters
bytesSource view.

◆ at() [1/2]

std::byte & StormByte::BinaryData::at ( const StormByte::ByteSize &  index)

Checked mutable subscript.

Parameters
indexByte offset.
Returns
Reference to the byte at index.
Exceptions
StormByte::OutOfBoundsErrorWhen index is not less than size().

◆ at() [2/2]

const std::byte & StormByte::BinaryData::at ( const StormByte::ByteSize &  index) const

Checked const subscript.

Parameters
indexByte offset.
Returns
Const reference to the byte at index.
Exceptions
StormByte::OutOfBoundsErrorWhen index is not less than size().

◆ back() [1/2]

std::byte & StormByte::BinaryData::back ( )

Last byte.

Returns
Reference to the last byte.

◆ back() [2/2]

const std::byte & StormByte::BinaryData::back ( ) const

Last byte.

Returns
Const reference to the last byte.

◆ begin() [1/2]

const_iterator StormByte::BinaryData::begin ( ) const
noexcept

Const iterator to the first byte.

Returns
data() when non-empty; a valid empty iterator otherwise.

◆ begin() [2/2]

iterator StormByte::BinaryData::begin ( )
noexcept

Mutable iterator to the first byte.

Returns
data() when non-empty; a valid empty iterator otherwise.

◆ capacity()

StormByte::ByteSize StormByte::BinaryData::capacity ( ) const
noexcept

Allocated capacity in bytes.

Returns
StormByte::ByteSize.

◆ cbegin()

const_iterator StormByte::BinaryData::cbegin ( ) const
noexcept

Const iterator to the first byte.

Returns
Same as const begin().

◆ cend()

const_iterator StormByte::BinaryData::cend ( ) const
noexcept

Const iterator one past the last byte.

Returns
Same as const end().

◆ clear()

void StormByte::BinaryData::clear ( )
noexcept

Drop every byte.

Capacity may remain.

◆ crbegin()

const_reverse_iterator StormByte::BinaryData::crbegin ( ) const
noexcept

Const reverse iterator to the last byte.

Returns
Same as const rbegin().

◆ crend()

const_reverse_iterator StormByte::BinaryData::crend ( ) const
noexcept

Const reverse iterator to before the first byte.

Returns
Same as const rend().

◆ data() [1/2]

const std::byte * StormByte::BinaryData::data ( ) const
noexcept

Const pointer to the first byte, or nullptr when empty.

Returns
Contiguous storage.

◆ data() [2/2]

std::byte * StormByte::BinaryData::data ( )
noexcept

Mutable pointer to the first byte, or nullptr when empty.

Returns
Contiguous storage.

◆ emplace_back()

template<typename T >
BinaryData::reference StormByte::BinaryData::emplace_back ( T &&  value)

Append a byte constructed in place.

Template Parameters
TValue convertible to the integer stored in std::byte.
Parameters
valueArgument forwarded into std::byte.
Returns
Reference to the appended byte.

◆ empty()

bool StormByte::BinaryData::empty ( ) const
noexcept

Whether the sequence holds no bytes.

Returns
true when size() is zero.

◆ end() [1/2]

const_iterator StormByte::BinaryData::end ( ) const
noexcept

Const iterator one past the last byte.

Returns
data() + size.

◆ end() [2/2]

iterator StormByte::BinaryData::end ( )
noexcept

Mutable iterator one past the last byte.

Returns
data() + size.

◆ erase() [1/2]

iterator StormByte::BinaryData::erase ( const_iterator  first,
const_iterator  last 
)

Erase [first, last).

Parameters
firstStart of the range.
lastEnd of the range.
Returns
Iterator following the last erased byte.

◆ erase() [2/2]

iterator StormByte::BinaryData::erase ( const_iterator  pos)

Erase the byte at pos.

Parameters
posByte to erase.
Returns
Iterator following the erased byte.

◆ front() [1/2]

std::byte & StormByte::BinaryData::front ( )

First byte.

Returns
Reference to the first byte.

◆ front() [2/2]

const std::byte & StormByte::BinaryData::front ( ) const

First byte.

Returns
Const reference to the first byte.

◆ HexDump() [1/2]

CString StormByte::BinaryData::HexDump ( ) const

Hexadecimal dump of the occupied bytes, sixteen bytes per row.

Same as HexDump() with 16 columns.

Returns
Dump text owned by Base. Empty when this sequence is empty.

◆ HexDump() [2/2]

CString StormByte::BinaryData::HexDump ( Size  columns) const

Hexadecimal dump of the occupied bytes.

Each line is an 8-digit offset, columns bytes as hex, and the same bytes as ASCII (non-printable shown as '.'). columns is a row width, not a byte length: it is Size, not ByteSize. 0 prints every byte on one line (still with offset and ASCII).

Parameters
columnsBytes per row; 0 means a single row.
Returns
Dump text owned by Base. Empty when this sequence is empty.

◆ insert() [1/5]

iterator StormByte::BinaryData::insert ( const_iterator  pos,
const StormByte::ByteSize &  count,
std::byte  value 
)

Insert count copies of value before pos.

Parameters
posInsertion point.
countNumber of bytes.
valueFill byte.
Returns
Iterator to the first inserted byte, or pos when count is zero.

◆ insert() [2/5]

template<typename InputIt >
BinaryData::iterator StormByte::BinaryData::insert ( const_iterator  pos,
InputIt  first,
InputIt  last 
)

Insert the range [first, last) before pos.

Template Parameters
InputItInput iterator whose value converts to std::byte.
Parameters
posInsertion point.
firstStart of the source range.
lastEnd of the source range.
Returns
Iterator to the first inserted byte, or pos when the range is empty.

◆ insert() [3/5]

iterator StormByte::BinaryData::insert ( const_iterator  pos,
std::byte  value 
)

Insert one byte before pos.

Parameters
posInsertion point.
valueByte to insert.
Returns
Iterator to the inserted byte.

◆ insert() [4/5]

iterator StormByte::BinaryData::insert ( const_iterator  pos,
std::initializer_list< std::byte >  list 
)

Insert an initializer list before pos.

Parameters
posInsertion point.
listSource bytes.
Returns
Iterator to the first inserted byte, or pos when list is empty.

◆ insert() [5/5]

iterator StormByte::BinaryData::insert ( const_iterator  pos,
std::span< const std::byte >  bytes 
)

Insert a span before pos.

Parameters
posInsertion point.
bytesSource view.
Returns
Iterator to the first inserted byte, or pos when bytes is empty.

◆ max_size()

StormByte::ByteSize StormByte::BinaryData::max_size ( ) const
noexcept

Implementation maximum size in bytes.

Returns
StormByte::ByteSize.

◆ operator std::span< const std::byte >()

StormByte::BinaryData::operator std::span< const std::byte > ( ) const
noexcept

Implicit const span conversion.

Returns
Same as const span().

◆ operator std::span< std::byte >()

StormByte::BinaryData::operator std::span< std::byte > ( )
noexcept

Implicit mutable span conversion.

Returns
Same as span().

◆ operator std::vector< std::byte >() [1/2]

STORMBYTE_FORCE_INLINE StormByte::BinaryData::operator std::vector< std::byte > ( ) &&
inlineexplicit

Copy bytes onto the caller CRT, then release this object's storage.

Returns
New vector owned by the caller.
Note
Looks like a move. Not a heap steal: Base cannot hand its pointer to a foreign std::vector. Peak usage is two copies during the transfer; *this is empty afterwards.

◆ operator std::vector< std::byte >() [2/2]

STORMBYTE_FORCE_INLINE StormByte::BinaryData::operator std::vector< std::byte > ( ) const &
inlineexplicit

Copy bytes onto the caller CRT as a std::vector.

Returns
New vector owned by the caller. *this is unchanged.
Note
Not a heap steal. STORMBYTE_FORCE_INLINE so the vector is not allocated inside this DLL.

◆ operator!=() [1/2]

bool StormByte::BinaryData::operator!= ( const BinaryData &  other) const
noexcept

Inequality of byte contents.

Parameters
otherOther sequence.
Returns
Negation of equality with another sequence.

◆ operator!=() [2/2]

bool StormByte::BinaryData::operator!= ( std::span< const std::byte >  bytes) const
noexcept

Inequality with a byte span.

Parameters
bytesView to compare.
Returns
Negation of equality with a byte span.

◆ operator+=() [1/3]

Append other, then empty it.

Parameters
otherSource sequence.
Returns
*this.

◆ operator+=() [2/3]

Append a copy of other.

Parameters
otherSource sequence.
Returns
*this.

◆ operator+=() [3/3]

BinaryData & StormByte::BinaryData::operator+= ( std::span< const std::byte >  bytes)

Append a copy of bytes.

Parameters
bytesSource view.
Returns
*this.

◆ operator<=>() [1/2]

std::strong_ordering StormByte::BinaryData::operator<=> ( const BinaryData &  other) const
noexcept

Three-way lexicographical comparison (same order as std::vector).

Parameters
otherOther sequence.
Returns
std::strong_ordering.

◆ operator<=>() [2/2]

std::strong_ordering StormByte::BinaryData::operator<=> ( std::span< const std::byte >  bytes) const
noexcept

Three-way comparison with a byte span.

Parameters
bytesView to compare.
Returns
std::strong_ordering.

◆ operator=() [1/3]

Move assign.

other is left empty.

Parameters
otherSource sequence.
Returns
*this.

◆ operator=() [2/3]

Copy assign.

Allocation runs in Base.

Parameters
otherSource sequence.
Returns
*this.

◆ operator=() [3/3]

BinaryData & StormByte::BinaryData::operator= ( std::initializer_list< std::byte >  list)

Replace contents with an initializer list.

Parameters
listSource bytes.
Returns
*this.

◆ operator==() [1/2]

bool StormByte::BinaryData::operator== ( const BinaryData &  other) const
noexcept

Equality of byte contents.

Parameters
otherOther sequence.
Returns
true when sizes and bytes match.

◆ operator==() [2/2]

bool StormByte::BinaryData::operator== ( std::span< const std::byte >  bytes) const
noexcept

Equality with a byte span.

Parameters
bytesView to compare.
Returns
true when sizes and bytes match.

◆ operator[]() [1/2]

const std::byte & StormByte::BinaryData::operator[] ( const StormByte::ByteSize &  index) const
noexcept

Unchecked const subscript.

Parameters
indexByte offset.
Returns
Const reference to the byte at index.

◆ operator[]() [2/2]

std::byte & StormByte::BinaryData::operator[] ( const StormByte::ByteSize &  index)
noexcept

Unchecked mutable subscript.

Parameters
indexByte offset.
Returns
Reference to the byte at index.

◆ pop_back()

void StormByte::BinaryData::pop_back ( )

Remove the last byte.

◆ push_back()

void StormByte::BinaryData::push_back ( std::byte  value)

Append one byte.

Parameters
valueByte to append.

◆ rbegin() [1/2]

const_reverse_iterator StormByte::BinaryData::rbegin ( ) const
noexcept

Const reverse iterator to the last byte.

Returns
const_reverse_iterator(end()).

◆ rbegin() [2/2]

reverse_iterator StormByte::BinaryData::rbegin ( )
noexcept

Mutable reverse iterator to the last byte.

Returns
reverse_iterator(end()).

◆ rend() [1/2]

const_reverse_iterator StormByte::BinaryData::rend ( ) const
noexcept

Const reverse iterator to before the first byte.

Returns
const_reverse_iterator(begin()).

◆ rend() [2/2]

reverse_iterator StormByte::BinaryData::rend ( )
noexcept

Mutable reverse iterator to before the first byte.

Returns
reverse_iterator(begin()).

◆ reserve()

void StormByte::BinaryData::reserve ( const StormByte::ByteSize &  new_cap)

Request capacity of at least new_cap bytes.

Parameters
new_capRequested capacity.

◆ resize() [1/2]

void StormByte::BinaryData::resize ( const StormByte::ByteSize &  new_size)

Resize to new_size bytes.

Appended bytes are zero.

Parameters
new_sizeNew size.

◆ resize() [2/2]

void StormByte::BinaryData::resize ( const StormByte::ByteSize &  new_size,
std::byte  value 
)

Resize to new_size bytes.

Appended bytes are value.

Parameters
new_sizeNew size.
valueFill for new bytes.

◆ shrink_to_fit()

void StormByte::BinaryData::shrink_to_fit ( )

Release unused capacity when the implementation allows it.

◆ size()

StormByte::ByteSize StormByte::BinaryData::size ( ) const
noexcept

Occupied length in bytes.

Returns
StormByte::ByteSize.

◆ span() [1/2]

std::span< const std::byte > StormByte::BinaryData::span ( ) const
noexcept

Const view of the occupied bytes.

Returns
Span over [data(), data() + size()).

◆ span() [2/2]

std::span< std::byte > StormByte::BinaryData::span ( )
noexcept

Mutable view of the occupied bytes.

Returns
Span over [data(), data() + size()).

◆ swap()

void StormByte::BinaryData::swap ( BinaryData &  other)
noexcept

Exchange storage with other.

Parameters
otherOther sequence.

The documentation for this class was generated from the following file: