roo_io
API Documentation for roo_io
Loading...
Searching...
No Matches
roo_io::BufferedInputStreamIterator Class Reference

#include <buffered_input_stream_iterator.h>

Public Member Functions

 BufferedInputStreamIterator ()
 Creates a detached iterator with kClosed status.
 
 BufferedInputStreamIterator (roo_io::InputStream &input)
 Creates iterator over input.
 
 BufferedInputStreamIterator (BufferedInputStreamIterator &&other)
 Move-constructs iterator state.
 
BufferedInputStreamIteratoroperator= (BufferedInputStreamIterator &&other)
 Move-assigns iterator state.
 
byte read ()
 Reads one byte.
 
size_t read (byte *buf, size_t count)
 Reads up to count bytes into buf.
 
void skip (size_t count)
 Skips up to count bytes.
 
Status status () const
 Returns current iterator status.
 
bool ok () const
 Returns whether status() == kOk.
 
bool eos () const
 Returns whether status() == kEndOfStream.
 
void reset (roo_io::InputStream &input)
 Rebinds iterator to input and clears buffered state.
 
void reset ()
 Detaches from stream and releases internal buffer.
 

Detailed Description

Definition at line 13 of file buffered_input_stream_iterator.h.

Constructor & Destructor Documentation

◆ BufferedInputStreamIterator() [1/3]

roo_io::BufferedInputStreamIterator::BufferedInputStreamIterator ( )
inline

Creates a detached iterator with kClosed status.

Definition at line 16 of file buffered_input_stream_iterator.h.

◆ BufferedInputStreamIterator() [2/3]

roo_io::BufferedInputStreamIterator::BufferedInputStreamIterator ( roo_io::InputStream input)
inline

Creates iterator over input.

Initializes status() from input.status(). Allocates internal buffer only when initial status is kOk.

Definition at line 27 of file buffered_input_stream_iterator.h.

References roo_io::kInputStreamIteratorBufferSize, and roo_io::kOk.

◆ BufferedInputStreamIterator() [3/3]

roo_io::BufferedInputStreamIterator::BufferedInputStreamIterator ( BufferedInputStreamIterator &&  other)
inline

Move-constructs iterator state.

Source iterator becomes detached with kClosed status.

Definition at line 38 of file buffered_input_stream_iterator.h.

References roo_io::kClosed.

Member Function Documentation

◆ eos()

bool roo_io::BufferedInputStreamIterator::eos ( ) const
inline

Returns whether status() == kEndOfStream.

Returns
true iff current status is kEndOfStream.

Definition at line 170 of file buffered_input_stream_iterator.h.

References roo_io::kEndOfStream, and status().

◆ ok()

bool roo_io::BufferedInputStreamIterator::ok ( ) const
inline

Returns whether status() == kOk.

Returns
true iff current status is kOk.

Definition at line 165 of file buffered_input_stream_iterator.h.

References roo_io::kOk, and status().

◆ operator=()

BufferedInputStreamIterator & roo_io::BufferedInputStreamIterator::operator= ( BufferedInputStreamIterator &&  other)
inline

Move-assigns iterator state.

Source iterator becomes detached with kClosed status.

Definition at line 53 of file buffered_input_stream_iterator.h.

References roo_io::kClosed.

◆ read() [1/2]

byte roo_io::BufferedInputStreamIterator::read ( )
inline

Reads one byte.

If buffered data is available, returns it without changing status(). If status() != kOk, returns zero byte and leaves status unchanged. Otherwise reads from underlying stream; when that read returns zero, updates status() from input.status().

Returns
Read byte, or zero byte when no byte can be read.

Definition at line 76 of file buffered_input_stream_iterator.h.

References roo_io::kInputStreamIteratorBufferSize, roo_io::kOk, roo_io::InputStream::read(), and roo_io::InputStream::status().

Referenced by roo_io::InputStreamReader::read().

◆ read() [2/2]

size_t roo_io::BufferedInputStreamIterator::read ( byte buf,
size_t  count 
)
inline

Reads up to count bytes into buf.

Uses buffered bytes first. If status() != kOk, returns zero and leaves status unchanged. When delegated stream read returns zero, updates status() from input.status().

Returns
Number of bytes read.

Definition at line 100 of file buffered_input_stream_iterator.h.

References roo_io::count, roo_io::kInputStreamIteratorBufferSize, roo_io::kOk, roo_io::InputStream::read(), and roo_io::InputStream::status().

◆ reset() [1/2]

void roo_io::BufferedInputStreamIterator::reset ( )
inline

Detaches from stream and releases internal buffer.

Sets status to kClosed.

Definition at line 190 of file buffered_input_stream_iterator.h.

References roo_io::kClosed.

◆ reset() [2/2]

void roo_io::BufferedInputStreamIterator::reset ( roo_io::InputStream input)
inline

Rebinds iterator to input and clears buffered state.

Updates status() to input.status(). Allocates buffer lazily when needed and status is kOk.

Definition at line 176 of file buffered_input_stream_iterator.h.

References roo_io::kInputStreamIteratorBufferSize, and roo_io::kOk.

Referenced by roo_io::InputStreamReader::close(), roo_io::InputStreamReader::reset(), and roo_io::InputStreamReader::reset().

◆ skip()

void roo_io::BufferedInputStreamIterator::skip ( size_t  count)
inline

Skips up to count bytes.

If skip is satisfied from buffered bytes, status() is unchanged. Otherwise clears local buffer state and, when status() == kOk, delegates remaining skip to underlying stream and updates status() from input.status().

Definition at line 144 of file buffered_input_stream_iterator.h.

References roo_io::count, roo_io::kOk, roo_io::InputStream::skip(), and roo_io::InputStream::status().

Referenced by roo_io::InputStreamReader::skip().

◆ status()

Status roo_io::BufferedInputStreamIterator::status ( ) const
inline

Returns current iterator status.

Returns
Current status value.

Definition at line 160 of file buffered_input_stream_iterator.h.

Referenced by eos(), ok(), and roo_io::InputStreamReader::status().


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