Pixie
Loading...
Searching...
No Matches
pixie::StorageBase< Impl > Class Template Reference

CRTP facade for byte-addressable storage. More...

#include <storage.h>

Public Member Functions

std::size_t size_bytes () const
 Return the exposed storage size in bytes.
 
std::size_t size_bits () const
 Return the exposed storage size in bits.
 
bool empty () const
 Check whether the storage is empty.
 
std::span< const std::byte > as_bytes () const
 Return a read-only view of all exposed bytes.
 
std::span< const std::uint16_t > as_words16 () const
 Return a read-only view as 16-bit words.
 
std::span< const std::uint64_t > as_words64 () const
 Return a read-only view as 64-bit words.
 
auto view () const
 Return a non-owning read-only view of all exposed bytes.
 
auto view (std::size_t offset_bytes, std::size_t count_bytes) const
 Return a non-owning read-only byte subrange.
 
void serialize (OutputBitStream &stream) const
 Serialize the exposed byte sequence with a size prefix.
 
void resize (std::size_t size_bits)
 Resize mutable storage to hold at least size_bits bits.
 
auto writable_bytes ()
 Return writable storage bytes.
 
auto writable_words16 ()
 Return writable storage as 16-bit words.
 
auto writable_words64 ()
 Return writable storage as 64-bit words.
 
std::size_t allocated_bytes () const
 Return bytes reserved by an owning storage implementation.
 
void shrink_to_fit ()
 Request release of unused reserved storage.
 

Detailed Description

template<class Impl>
class pixie::StorageBase< Impl >

CRTP facade for byte-addressable storage.

Template Parameters
ImplConcrete storage implementation.

Member Function Documentation

◆ as_words16()

template<class Impl>
std::span< const std::uint16_t > pixie::StorageBase< Impl >::as_words16 ( ) const
inline

Return a read-only view as 16-bit words.

Exceptions
std::invalid_argumentif the data is misaligned or its size is not divisible by the word size.

◆ as_words64()

template<class Impl>
std::span< const std::uint64_t > pixie::StorageBase< Impl >::as_words64 ( ) const
inline

Return a read-only view as 64-bit words.

Exceptions
std::invalid_argumentif the data is misaligned or its size is not divisible by the word size.

◆ view()

template<class Impl>
auto pixie::StorageBase< Impl >::view ( std::size_t offset_bytes,
std::size_t count_bytes ) const
inline

Return a non-owning read-only byte subrange.

Parameters
offset_bytesFirst byte in the view.
count_bytesNumber of bytes in the view.
Exceptions
std::out_of_rangeif the subrange is outside this storage.

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