iceberg-cpp
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | Protected Member Functions | List of all members
iceberg::Stream< T > Class Template Referenceabstract

A pull-based stream whose reads may fail. More...

#include <stream.h>

Public Member Functions

virtual ~Stream ()=default
 Destroy this stream and release its producer resources.
 
 Stream ()=default
 Construct a stream in its initial state.
 
 Stream (const Stream &)=delete
 Streams cannot be copied.
 
Stream & operator= (const Stream &)=delete
 Streams cannot be copy-assigned.
 
 Stream (Stream &&) noexcept=default
 Move a stream and its terminal state.
 
Stream & operator= (Stream &&) noexcept=default
 Move-assign a stream and its terminal state.
 
Result< std::optional< T > > Next ()
 Return the next value, or std::nullopt when the stream is exhausted.
 
Result< std::vector< T > > ToVector ()
 Consume the remaining values into a vector.
 

Static Public Member Functions

static std::unique_ptr< Stream< T > > FromVector (std::vector< T > values)
 Create a stream that owns and consumes the given values in order.
 

Protected Member Functions

virtual Result< std::optional< T > > NextImpl ()=0
 Produce the next value for Next().
 

Detailed Description

template<typename T>
class iceberg::Stream< T >

A pull-based stream whose reads may fail.

Stream implementations own any resources needed to produce values. Destroying a stream releases those resources, including when consumption stops before reaching the end. Streams are not thread-safe unless an implementation explicitly says otherwise. Once Next() returns an error or std::nullopt, the stream is terminal. Subsequent calls return the same terminal result without invoking the implementation again.

Template Parameters
TValue returned by the stream.

Member Function Documentation

◆ Next()

template<typename T >
Result< std::optional< T > > iceberg::Stream< T >::Next ( )
inline

Return the next value, or std::nullopt when the stream is exhausted.

After this method returns an error or std::nullopt, subsequent calls return the same terminal result without invoking NextImpl().

◆ NextImpl()

template<typename T >
virtual Result< std::optional< T > > iceberg::Stream< T >::NextImpl ( )
protectedpure virtual

Produce the next value for Next().

Implementations must return std::nullopt when exhausted. Next() makes the terminal state sticky, so implementations are not called after exhaustion or error.


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