LibQuicR
quicr::DataStorageDynView Class Reference

Non-owning-position view that shares ownership of a DataStorage<>. More...

#include <data_storage.h>

Public Member Functions

 DataStorageDynView (std::shared_ptr< DataStorage<>> storage, std::size_t start_pos=0, std::optional< std::size_t > end_pos=std::nullopt)
 Constructs a view over an absolute half-open range. More...
 
 DataStorageDynView (const DataStorageDynView &other)=default
 Copies the view and shares ownership of its storage. More...
 
 DataStorageDynView (DataStorageDynView &&other)=default
 Moves the view. More...
 
DataStorageDynView & operator= (const DataStorageDynView &other)=default
 Copies the view and shares ownership of its storage. More...
 
DataStorageDynView & operator= (DataStorageDynView &&other)=default
 Moves the view. More...
 
DataStorageDynView Subspan (std::size_t start_pos, std::optional< std::size_t > end_pos=std::nullopt) const noexcept
 Creates another absolute view of the same storage. More...
 
std::size_t size () const noexcept
 
DataStorage ::iterator begin () noexcept
 
DataStorage ::iterator end () noexcept
 
DataStorage ::const_iterator begin () const noexcept
 
DataStorage ::const_iterator end () const noexcept
 

Detailed Description

Non-owning-position view that shares ownership of a DataStorage<>.

Positions are absolute flattened byte offsets into the underlying storage. The storage object remains alive with the view, but mutation is not synchronized and front erasure changes what offsets identify.

Constructor & Destructor Documentation

◆ DataStorageDynView() [1/3]

quicr::DataStorageDynView::DataStorageDynView ( std::shared_ptr< DataStorage<>>  storage,
std::size_t  start_pos = 0,
std::optional< std::size_t >  end_pos = std::nullopt 
)
inline

Constructs a view over an absolute half-open range.

Parameters
storageStorage retained by shared ownership.
start_posAbsolute inclusive byte offset.
end_posOptional absolute exclusive byte offset; no value tracks the storage's current end.
Precondition
storage is non-null, start_pos is within its flattened size, and a supplied end_pos is between start_pos and the storage size.

◆ DataStorageDynView() [2/3]

quicr::DataStorageDynView::DataStorageDynView ( const DataStorageDynView &  other)
default

Copies the view and shares ownership of its storage.

Parameters
otherView to copy.

◆ DataStorageDynView() [3/3]

quicr::DataStorageDynView::DataStorageDynView ( DataStorageDynView &&  other)
default

Moves the view.

Parameters
otherView to move.

Member Function Documentation

◆ begin() [1/2]

DataStorage ::const_iterator quicr::DataStorageDynView::begin ( ) const
inlinenoexcept
Returns
Const iterator at the absolute start offset.

◆ begin() [2/2]

DataStorage ::iterator quicr::DataStorageDynView::begin ( )
inlinenoexcept
Returns
Mutable iterator at the absolute start offset.

◆ end() [1/2]

DataStorage ::const_iterator quicr::DataStorageDynView::end ( ) const
inlinenoexcept
Returns
Const iterator at the current exclusive end offset.

◆ end() [2/2]

DataStorage ::iterator quicr::DataStorageDynView::end ( )
inlinenoexcept
Returns
Mutable iterator at the current exclusive end offset.

◆ operator=() [1/2]

DataStorageDynView& quicr::DataStorageDynView::operator= ( const DataStorageDynView &  other)
default

Copies the view and shares ownership of its storage.

Parameters
otherView to copy.
Returns
*this.

◆ operator=() [2/2]

DataStorageDynView& quicr::DataStorageDynView::operator= ( DataStorageDynView &&  other)
default

Moves the view.

Parameters
otherView to move.
Returns
*this.

◆ size()

std::size_t quicr::DataStorageDynView::size ( ) const
inlinenoexcept
Returns
Current view length. A dynamic end reflects subsequent appends to storage.

◆ Subspan()

DataStorageDynView quicr::DataStorageDynView::Subspan ( std::size_t  start_pos,
std::optional< std::size_t >  end_pos = std::nullopt 
) const
inlinenoexcept

Creates another absolute view of the same storage.

Parameters
start_posAbsolute inclusive storage offset, not relative to this view.
end_posOptional absolute exclusive offset; absent or beyond the current storage size is clamped to the current storage size.
Returns
View with a fixed end position.
Precondition
start_pos does not exceed the selected end position.

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