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

#include <null_input_stream.h>

Inheritance diagram for roo_io::NullInputStream:
[legend]
Collaboration diagram for roo_io::NullInputStream:
[legend]

Public Member Functions

 NullInputStream (Status error=kClosed)
 
bool isOpen () const override
 Returns whether stream is considered open.
 
void close () override
 Closes this stream.
 
size_t read (byte *buf, size_t count) override
 Attempts to read up to count bytes into result.
 
void skip (uint64_t count) override
 Skips over count bytes, updating status().
 
Status status () const override
 Returns status of the most recent I/O operation.
 
uint64_t size () override
 Returns stream size in bytes from beginning.
 
uint64_t position () const override
 Returns current byte offset from beginning of stream.
 
void seek (uint64_t offset) override
 Seeks to byte offset from beginning.
 
- Public Member Functions inherited from roo_io::MultipassInputStream
virtual void rewind ()
 Resets stream to starting position.
 
- Public Member Functions inherited from roo_io::InputStream
virtual ~InputStream ()
 
virtual size_t tryRead (byte *result, size_t count)
 Attempts to read up to count bytes into result without indefinitely blocking.
 
virtual size_t readFully (byte *buf, size_t count)
 Attempts to read count bytes into buf; blocks as needed.
 

Detailed Description

Definition at line 7 of file null_input_stream.h.

Constructor & Destructor Documentation

◆ NullInputStream()

roo_io::NullInputStream::NullInputStream ( Status  error = kClosed)
inline

Definition at line 9 of file null_input_stream.h.

Member Function Documentation

◆ close()

void roo_io::NullInputStream::close ( )
inlineoverridevirtual

Closes this stream.

Updates status.

If previous status was kOk or kEndOfStream, status transitions to kClosed.

After close, read operations should return zero bytes.

Reimplemented from roo_io::InputStream.

Definition at line 13 of file null_input_stream.h.

◆ isOpen()

bool roo_io::NullInputStream::isOpen ( ) const
inlineoverridevirtual

Returns whether stream is considered open.

Returns
true when status() is kOk or kEndOfStream.

Reimplemented from roo_io::InputStream.

Definition at line 11 of file null_input_stream.h.

◆ position()

uint64_t roo_io::NullInputStream::position ( ) const
inlineoverridevirtual

Returns current byte offset from beginning of stream.

If status is neither kOk nor kEndOfStream, return value is unspecified.

Implements roo_io::MultipassInputStream.

Definition at line 23 of file null_input_stream.h.

◆ read()

size_t roo_io::NullInputStream::read ( byte result,
size_t  count 
)
inlineoverridevirtual

Attempts to read up to count bytes into result.

Updates status.

Contract:

  • On success (status() == kOk), returns at least one byte.
  • On end-of-stream (status() == kEndOfStream), returns zero.
  • On error, may return zero or number of bytes read before failure.

If status before call is not kOk, leaves it unchanged and returns zero.

Implementations may return fewer than count bytes even when more data is available. Use readFully() if that is not the desired behavior.

Returns
Number of bytes read.

Implements roo_io::InputStream.

Definition at line 15 of file null_input_stream.h.

◆ seek()

void roo_io::NullInputStream::seek ( uint64_t  offset)
inlineoverridevirtual

Seeks to byte offset from beginning.

Offset may be greater than current size().

If pre-call status is neither kOk nor kEndOfStream, status is unchanged.

On success, status becomes kOk and position() equals offset. On error, status updates accordingly.

Implements roo_io::MultipassInputStream.

Definition at line 25 of file null_input_stream.h.

◆ size()

uint64_t roo_io::NullInputStream::size ( )
inlineoverridevirtual

Returns stream size in bytes from beginning.

Value may differ across calls when underlying source mutates.

If pre-call status is neither kOk nor kEndOfStream, status is unchanged and return value is 0.

On error, status updates accordingly and return value is 0.

Implements roo_io::MultipassInputStream.

Definition at line 21 of file null_input_stream.h.

◆ skip()

void roo_io::NullInputStream::skip ( uint64_t  count)
inlineoverridevirtual

Skips over count bytes, updating status().

Conceptually equivalent to readFully(tmp, count) and discarding data.

If pre-call status is not kOk, leaves status unchanged and returns.

If skip ends exactly at stream end, status remains kOk. If skip ends before stream end, status remains kOk. If skip crosses stream end, status becomes kEndOfStream.

Any I/O error updates status accordingly.

Reimplemented from roo_io::InputStream.

Definition at line 17 of file null_input_stream.h.

◆ status()

Status roo_io::NullInputStream::status ( ) const
inlineoverridevirtual

Returns status of the most recent I/O operation.

Implements roo_io::InputStream.

Definition at line 19 of file null_input_stream.h.


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