Spicy
Public Types | Public Member Functions | Protected Member Functions | Friends | List of all members
hilti::rt::stream::SafeConstIterator Class Reference

#include <stream.h>

Public Types

using Byte = stream::Byte
 
using Chain = stream::detail::Chain
 
using ConstChainPtr = stream::detail::ConstChainPtr
 
using Chunk = stream::detail::Chunk
 
using Offset = stream::Offset
 
using Size = stream::Size
 
using UnsafeConstIterator = stream::detail::UnsafeConstIterator
 

Public Member Functions

 SafeConstIterator ()=default
 
 SafeConstIterator (const UnsafeConstIterator &i)
 
Offset offset () const
 
bool isFrozen () const
 
auto & operator++ ()
 
const auto operator++ (int)
 
auto & operator+= (integer::safe< uint64_t > i)
 
auto & operator-- ()
 
const auto operator-- (int)
 
auto & operator-= (integer::safe< uint64_t > i)
 
auto operator* () const
 
auto operator+ (integer::safe< uint64_t > i) const
 
auto operator- (integer::safe< uint64_t > i) const
 
integer::safe< int64_t > operator- (const SafeConstIterator &other) const
 
bool operator== (const SafeConstIterator &other) const
 
bool operator!= (const SafeConstIterator &other) const
 
bool operator< (const SafeConstIterator &other) const
 
bool operator<= (const SafeConstIterator &other) const
 
bool operator> (const SafeConstIterator &other) const
 
bool operator>= (const SafeConstIterator &other) const
 
 operator bool () const
 
std::ostream & operator<< (std::ostream &out) const
 
bool isUnset () const
 
bool isExpired () const
 
bool isValid () const
 
bool isEnd () const
 
void debugPrint (std::ostream &out) const
 

Protected Member Functions

const Chunkchunk () const
 
const Chainchain () const
 

Friends

class hilti::rt::stream::View
 
class hilti::rt::stream::detail::Chain
 
class hilti::rt::stream::detail::UnsafeConstIterator
 

Detailed Description

SafeConstIterator for traversing the content of a stream instance.

Unlike the STL-style iterators, this iterator protects against the stream instance being no longer available by throwing an InvalidIterator exception if it's still accessed. It will also catch attempts to dereference iterators that remain outside of the current valid range of the underlying stream. However, operations that only query/manipulate offsets will succeed even for out-of-range positions. That includes advancing an iterator beyond the end of a stream, which is well-defined: if the stream gets expanded later, the iterator will refer to any data ending up at the iterator's position now.

Constructor & Destructor Documentation

◆ SafeConstIterator() [1/2]

hilti::rt::stream::SafeConstIterator::SafeConstIterator ( )
default

Constructor.

◆ SafeConstIterator() [2/2]

hilti::rt::stream::SafeConstIterator::SafeConstIterator ( const UnsafeConstIterator i)
inlineexplicit

Constructor.

Member Function Documentation

◆ debugPrint()

void SafeConstIterator::debugPrint ( std::ostream &  out) const

Prints out a debug rendering to the iterator's internal representation.

◆ isEnd()

bool hilti::rt::stream::SafeConstIterator::isEnd ( ) const
inline

Returns true if the iterator is at or beyond the current end of the underlying stream instance. Also generally returns true for an unbound iterator.

◆ isExpired()

bool hilti::rt::stream::SafeConstIterator::isExpired ( ) const
inline

Returns true if the iterator was once valid but the underlying bytes instance has by now expired.

◆ isFrozen()

bool hilti::rt::stream::SafeConstIterator::isFrozen ( ) const
inline

Returns true if the stream instance that the iterator is bound to has been frozen.

◆ isUnset()

bool hilti::rt::stream::SafeConstIterator::isUnset ( ) const
inline

Returns true if the iterator remains unbound.

◆ isValid()

bool hilti::rt::stream::SafeConstIterator::isValid ( ) const
inline

Returns true if the iterator is bound to a stream object and that's not expired yet.

◆ offset()

Offset hilti::rt::stream::SafeConstIterator::offset ( ) const
inline

Returns the offset inside the stream that the iterator represents.

◆ operator bool()

hilti::rt::stream::SafeConstIterator::operator bool ( ) const
inlineexplicit

Returns true if the iterator is bound to a stream instance, even if expired.

◆ operator!=()

bool hilti::rt::stream::SafeConstIterator::operator!= ( const SafeConstIterator other) const
inline

Returns true if another iterator bound to the same stream instance does not refer to the same location. The result is undefined if the iterators aren't referring to the same stream instance.

◆ operator*()

auto hilti::rt::stream::SafeConstIterator::operator* ( ) const
inline

Returns the character at the iterator's position.

◆ operator+()

auto hilti::rt::stream::SafeConstIterator::operator+ ( integer::safe< uint64_t >  i) const
inline

Return a new iterator advanced by a given number of bytes.

◆ operator++() [1/2]

auto& hilti::rt::stream::SafeConstIterator::operator++ ( )
inline

Advances the iterator by one byte.

◆ operator++() [2/2]

const auto hilti::rt::stream::SafeConstIterator::operator++ ( int  )
inline

Advances the iterator by one byte.

◆ operator+=()

auto& hilti::rt::stream::SafeConstIterator::operator+= ( integer::safe< uint64_t >  i)
inline

Advances the iterator by a given number of stream.

◆ operator-() [1/2]

auto hilti::rt::stream::SafeConstIterator::operator- ( integer::safe< uint64_t >  i) const
inline

Returns a new iterator moved back by a given number of bytes.

◆ operator-() [2/2]

integer::safe<int64_t> hilti::rt::stream::SafeConstIterator::operator- ( const SafeConstIterator other) const
inline

Return the size of the range defined by the two iterators. The result will be negative if the instance's location comes before the argument's location.

◆ operator--() [1/2]

auto& hilti::rt::stream::SafeConstIterator::operator-- ( )
inline

Moves back the iterator by one byte.

◆ operator--() [2/2]

const auto hilti::rt::stream::SafeConstIterator::operator-- ( int  )
inline

Moves back the iterator by one byte.

◆ operator-=()

auto& hilti::rt::stream::SafeConstIterator::operator-= ( integer::safe< uint64_t >  i)
inline

Moves back the iterator by a given number of stream.

◆ operator<()

bool hilti::rt::stream::SafeConstIterator::operator< ( const SafeConstIterator other) const
inline

Compares the offset of two iterators referring to the same stream instance.

◆ operator<=()

bool hilti::rt::stream::SafeConstIterator::operator<= ( const SafeConstIterator other) const
inline

Compares the offset of two iterators referring to the same stream instance.

◆ operator==()

bool hilti::rt::stream::SafeConstIterator::operator== ( const SafeConstIterator other) const
inline

Returns true if another iterator bound to the same stream instance refers to the same location. The result is undefined if the iterators aren't referring to the same stream instance.

◆ operator>()

bool hilti::rt::stream::SafeConstIterator::operator> ( const SafeConstIterator other) const
inline

Compares the offset of two iterators referring to the same stream instance.

◆ operator>=()

bool hilti::rt::stream::SafeConstIterator::operator>= ( const SafeConstIterator other) const
inline

Compares the offset of two iterators referring to the same stream instance.


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