Bond 0.9
C++ Bond Runtime Library API Documentation
Loading...
Searching...
No Matches
Bond::InputStream Class Referenceabstract

An abstract interface for performing both unformatted and formatted input operations. More...

#include <bond/io/inputstream.h>

Inheritance diagram for Bond::InputStream:
Bond::Stream Bond::MemoryInputStream Bond::StdioInputStream Bond::StdInInputStream

Public Member Functions

virtual ~InputStream ()
 Destroys an InputStream object.
virtual void Scan (const char *format,...)
 Reads formatted input from the stream.
virtual void VScan (const char *format, va_list argList)=0
 Reads formatted input from the stream using a variable argument list.
size_t Read (char *bytes, size_t numBytes)
 Reads a sequence of bytes from the stream into a character buffer.
virtual size_t Read (uint8_t *bytes, size_t numBytes)
 Reads a sequence of bytes from the stream.
virtual int Read ()=0
 Reads a single byte from the stream.
Public Member Functions inherited from Bond::Stream
virtual ~Stream ()
 Destroys a Stream object.
virtual void Close ()
 Closes the stream.
virtual pos_t GetPosition () const =0
 Returns the current position within the stream.
virtual pos_t GetEndPosition () const =0
 Returns the end position of the stream.
virtual void SetPosition (off_t offset)=0
 Sets the current position within the stream.
virtual void SetPositionFromEnd (off_t offset)=0
 Sets the current position relative to the end of the stream.
virtual void AddOffset (off_t offset)=0
 Advances the current position by the given offset.
virtual bool IsEof () const =0
 Tests whether the current position is at or beyond the end of the stream.
virtual bool HasError () const =0
 Tests whether the stream is currently in an error state.
virtual void ClearError ()=0
 Clears the current error state of the stream.

Additional Inherited Members

Public Types inherited from Bond::Stream
typedef long pos_t
 A type used to represent absolute positions within a stream.
typedef long off_t
 A type used to represent relative offsets within a stream.
Static Public Attributes inherited from Bond::Stream
static const int Eof = -1
 A special value returned by single-byte input functions to indicate end of stream.

Detailed Description

An abstract interface for performing both unformatted and formatted input operations.

InputStream extends Stream with functions for reading data either as raw bytes or according to a scanf-style format string.

See also
OutputStream, Stream

Constructor & Destructor Documentation

◆ ~InputStream()

virtual Bond::InputStream::~InputStream ( )
inlinevirtual

Destroys an InputStream object.

Member Function Documentation

◆ Read() [1/3]

virtual int Bond::InputStream::Read ( )
pure virtual

Reads a single byte from the stream.

Returns
The next byte in the stream, or Stream::Eof if the end of the stream is reached.

Implemented in Bond::MemoryInputStream, and Bond::StdioInputStream.

◆ Read() [2/3]

size_t Bond::InputStream::Read ( char * bytes,
size_t numBytes )
inline

Reads a sequence of bytes from the stream into a character buffer.

Parameters
bytesThe destination buffer where the bytes will be written.
numBytesThe maximum number of bytes to read.
Returns
The number of bytes actually read from the stream.

◆ Read() [3/3]

virtual size_t Bond::InputStream::Read ( uint8_t * bytes,
size_t numBytes )
virtual

Reads a sequence of bytes from the stream.

Parameters
bytesThe destination buffer where the bytes will be written.
numBytesThe maximum number of bytes to read.
Returns
The number of bytes actually read from the stream.

Reimplemented in Bond::MemoryInputStream, and Bond::StdioInputStream.

◆ Scan()

virtual void Bond::InputStream::Scan ( const char * format,
... )
virtual

Reads formatted input from the stream.

Parameters
formatA scanf-style format string describing the values to be read.
...Pointers to locations where the parsed values will be stored.

◆ VScan()

virtual void Bond::InputStream::VScan ( const char * format,
va_list argList )
pure virtual

Reads formatted input from the stream using a variable argument list.

Parameters
formatA scanf-style format string describing the values to be read.
argListA variable argument list containing pointers to storage for the parsed values.

Implemented in Bond::MemoryInputStream, and Bond::StdioInputStream.


The documentation for this class was generated from the following file:
  • include/bond/io/inputstream.h