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

A base interface for performing IO operations. More...

#include <bond/io/stream.h>

Inheritance diagram for Bond::Stream:
Bond::InputStream Bond::OutputStream Bond::MemoryInputStream Bond::StdioInputStream Bond::MemoryOutputStream Bond::StdioOutputStream Bond::StdInInputStream Bond::StdErrOutputStream Bond::StdOutOutputStream

Public Types

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.

Public Member Functions

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.

Static Public Attributes

static const int Eof = -1
 A special value returned by single-byte input functions to indicate end of stream.

Detailed Description

A base interface for performing IO operations.

Stream provides the common positioning and status operations shared by all Bond input and output streams. Concrete implementations may be backed by memory buffers, stdio FILE objects, or other storage mechanisms.

See also
InputStream, OutputStream

Member Typedef Documentation

◆ off_t

typedef long Bond::Stream::off_t

A type used to represent relative offsets within a stream.

◆ pos_t

typedef long Bond::Stream::pos_t

A type used to represent absolute positions within a stream.

Constructor & Destructor Documentation

◆ ~Stream()

virtual Bond::Stream::~Stream ( )
inlinevirtual

Destroys a Stream object.

Member Function Documentation

◆ AddOffset()

virtual void Bond::Stream::AddOffset ( off_t offset)
pure virtual

Advances the current position by the given offset.

Parameters
offsetThe signed amount by which the current position should be adjusted.

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

◆ ClearError()

virtual void Bond::Stream::ClearError ( )
pure virtual

Clears the current error state of the stream.

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

◆ Close()

virtual void Bond::Stream::Close ( )
inlinevirtual

Closes the stream.

The default implementation does nothing. Concrete stream implementations may override this function to release owned resources or detach from the underlying data source or sink.

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

◆ GetEndPosition()

virtual pos_t Bond::Stream::GetEndPosition ( ) const
pure virtual

Returns the end position of the stream.

Returns
The absolute position one past the last byte in the stream.

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

◆ GetPosition()

virtual pos_t Bond::Stream::GetPosition ( ) const
pure virtual

Returns the current position within the stream.

Returns
The current absolute stream position.

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

◆ HasError()

virtual bool Bond::Stream::HasError ( ) const
pure virtual

Tests whether the stream is currently in an error state.

Returns
True if an error has occurred on the underlying stream.

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

◆ IsEof()

virtual bool Bond::Stream::IsEof ( ) const
pure virtual

Tests whether the current position is at or beyond the end of the stream.

Returns
True if no more data can be read or written at the current position.

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

◆ SetPosition()

virtual void Bond::Stream::SetPosition ( off_t offset)
pure virtual

Sets the current position within the stream.

Parameters
offsetThe absolute position to which the stream should be moved.

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

◆ SetPositionFromEnd()

virtual void Bond::Stream::SetPositionFromEnd ( off_t offset)
pure virtual

Sets the current position relative to the end of the stream.

Parameters
offsetThe offset from the end position to which the stream should be moved.

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

Member Data Documentation

◆ Eof

const int Bond::Stream::Eof = -1
static

A special value returned by single-byte input functions to indicate end of stream.


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