![]() |
Spicy
|
#include <stream.h>
Classes | |
struct | Block |
Public Types | |
using | Byte = stream::Byte |
using | Chain = stream::detail::Chain |
using | ChainPtr = stream::detail::ChainPtr |
using | Chunk = stream::detail::Chunk |
using | Offset = stream::Offset |
using | Size = stream::Size |
using | UnsafeConstIterator = stream::detail::UnsafeConstIterator |
Public Member Functions | |
View ()=default | |
virtual | ~View () |
View (SafeConstIterator begin, SafeConstIterator end) | |
View (SafeConstIterator begin) | |
Offset | offset () const |
Size | size () const |
bool | isEmpty () const |
bool | isFrozen () const |
bool | isOpenEnded () const |
SafeConstIterator | find (Byte b) const |
SafeConstIterator | find (Byte b, const SafeConstIterator &n) const |
UnsafeConstIterator | find (Byte b, UnsafeConstIterator n) const |
std::tuple< bool, SafeConstIterator > | find (const View &v) const |
std::tuple< bool, SafeConstIterator > | find (const View &v, const SafeConstIterator &n) const |
std::tuple< bool, UnsafeConstIterator > | find (const View &v, UnsafeConstIterator n) const |
std::tuple< bool, SafeConstIterator > | find (const Bytes &v, Direction d=Direction::Forward) const |
std::tuple< bool, SafeConstIterator > | find (const Bytes &v, const SafeConstIterator &n, Direction d=Direction::Forward) const |
std::tuple< bool, UnsafeConstIterator > | find (const Bytes &v, UnsafeConstIterator n, Direction d=Direction::Forward) const |
View | advance (SafeConstIterator i) const |
View | advance (integer::safe< uint64_t > i) const |
View | sub (SafeConstIterator from, SafeConstIterator to) const |
View | sub (SafeConstIterator to) const |
View | sub (Offset from, Offset to) const |
View | sub (Offset to) const |
SafeConstIterator | at (Offset offset) const |
View | trim (const SafeConstIterator &nbegin) const |
View | limit (Offset incr) const |
template<int N> | |
View | extract (Byte(&dst)[N]) const |
void | copyRaw (Byte *dst) const |
Bytes | data () const |
detail::UnsafeConstIterator | unsafeBegin () const |
detail::UnsafeConstIterator | unsafeEnd () const |
const SafeConstIterator & | begin () const |
SafeConstIterator | end () const |
std::optional< Block > | firstBlock () const |
std::optional< Block > | nextBlock (std::optional< Block > current) const |
bool | startsWith (const Bytes &b) const |
bool | operator== (const Bytes &other) const |
bool | operator== (const Stream &other) const |
bool | operator== (const View &other) const |
bool | operator!= (const Bytes &other) const |
bool | operator!= (const Stream &other) const |
bool | operator!= (const View &other) const |
void | debugPrint (std::ostream &out) const |
A subrange of a stream instance. The view is maintained through two safe iterators; no data is copied. That makes the view cheap to create and pass around. Because of the use of safe containers, it'll also be caught if the underlying stream instances goes away, or if accesses outside of currendtly valid range occur.
|
default |
Constructor.
|
virtualdefault |
Destructor. Virtual to force creation of vtable for consistent RTTI.
|
inlineexplicit |
Constructor for static view bracketed through two iterators.
|
inlineexplicit |
Constructor for an expanding view that will always reflect a range up to the curent end of the underlying stream object, including when that expands.
|
inline |
Advances the view's starting position to a new place.
i | the new position, which must be inside the current view |
|
inline |
Advances the view's starting position by a given number of stream.
i | the number of stream to advance. |
|
inline |
Returns an iterator representing an offset inside the view's data
|
inline |
Returns an safe iterator pointint to the beginning of the view.
void View::copyRaw | ( | Byte * | dst | ) | const |
Copies the view into raw memory.
dst | destination to write to, which must have at least size() stream available(). |
Bytes stream::View::data | ( | ) | const |
Returns a copy of the data the view refers to.
void View::debugPrint | ( | std::ostream & | out | ) | const |
Prints out a debug rendering to the view's internal representation.
|
inline |
Returns a safe iterator representing the end of the instance.
|
inline |
Extracts a fixed number of stream from the view.
N | number of stream to extract |
dst | target array to write stream data into |
|
inline |
Returns the position of the first occurrence of a byte inside the view. Will return end() if not found.
b | byte to search |
|
inline |
Returns the position of the first occurrence of a byte inside the view. Will return end() if not found.
b | byte to search |
n | starting point, which must be inside the view |
UnsafeConstIterator View::find | ( | Byte | b, |
UnsafeConstIterator | n | ||
) | const |
Returns the position of the first occurrence of a byte inside the view. Will return unsafeEnd() if not found.
b | byte to search |
n | starting point, which must be inside the view |
|
inline |
Searches for the first occurrence of another view's data.
v | data to search for |
|
inline |
Searches for the first occurrence of another view's data.
v | data to search for |
n | starting point, which must be inside this view |
std::tuple< bool, UnsafeConstIterator > View::find | ( | const View & | v, |
UnsafeConstIterator | n | ||
) | const |
Searches for the first occurrence of another view's data.
v | data to search for |
n | starting point, which must be inside this view |
|
inline |
Searches for the first occurrence of data, either forward or backward.
v | data to search for |
d | direction to search: forward searches from the beginning, backward from the end of the view |
|
inline |
Searches for the first occurrence of data, either forward or backward.
v | data to search for |
n | starting point, which must be inside this view |
d | direction to search from starting point |
|
inline |
Searches for the first occurrence of data, either forward or backward.
v | data to search for |
n | starting point, which must be inside this view |
d | direction to search from starting point |
std::optional< View::Block > View::firstBlock | ( | ) | const |
Initialization method for block-wise iteration over raw data.
|
inline |
Returns true if the view's size is zero.
|
inline |
Returns true if the instance is currently frozen.
|
inline |
Returns true if the view was constructed without a fixed end offset, meaning it will expand as more data gets addedd to the underlying stream.
|
inline |
Returns a new view that keeps the current start but cuts off the end at a specified offset from that beginning. The returned view will not be able to expand any further.
std::optional< View::Block > View::nextBlock | ( | std::optional< Block > | current | ) | const |
Iterates to next block during block-wise iteration over raw data.
|
inline |
Returns the offset of the view's starting location within the associated stream instance.
Size View::size | ( | ) | const |
Returns the number of actual bytes available inside the view. If the view's end position is beyong the current end offset of the underlying stream, those missing bytes are not counted.
bool View::startsWith | ( | const Bytes & | b | ) | const |
Returns true if the view's data begins with a given, other stream instance.
|
inline |
Extracts a subrange of bytes from the view, returned as a new view.
from | iterator pointing to start of subrange |
to | iterator pointing to just beyond subrange |
|
inline |
Extracts subrange of bytes from the beginning of the view, returned as a new view.
to | iterator pointing to just beyond subrange |
|
inline |
Extracts subrange of bytes from the view, returned as a new view.
from | offset of start of subrange, relative to beginning of view |
to | offset of one beyond end of subrange, relative to beginning of view |
|
inline |
Extracts subrange of stream from the beginning of the view, returned as a new view.
to | of one beyond end of subrange, relative to beginning of view |
|
inline |
Returns a new view moves the beginning to a subsequent iterator while not changing the end. In particular, this maintains a view capability to expand to an underlying data instance's growth.
|
inline |
Returns an unsafe iterator pointing to the beginning of the view.
|
inline |
Returns an unsafe iterator representing the end of the instance.