Bond 0.9
C++ Bond Runtime Library API Documentation
Loading...
Searching...
No Matches
Bond::StdioInputStream Class Reference

A concrete implementation of InputStream that performs input operations from a stdio FILE*. More...

#include <bond/io/stdioinputstream.h>

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

Public Member Functions

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

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

A concrete implementation of InputStream that performs input operations from a stdio FILE*.

StdioInputStream adapts a C stdio FILE object to the InputStream interface. The stream may be bound either to an existing FILE pointer or to a file opened and owned through a StdioFileHandle.

See also
InputStream, StdioOutputStream

Constructor & Destructor Documentation

◆ StdioInputStream() [1/5]

Bond::StdioInputStream::StdioInputStream ( FILE * file)
inlineexplicit

Constructs a StdioInputStream object.

Parameters
fileThe stdio FILE object from which input will be read. The file is not owned by the StdioInputStream unless it is later replaced by an owning handle.

◆ StdioInputStream() [2/5]

Bond::StdioInputStream::StdioInputStream ( const char * fileName)
explicit

Constructs a StdioInputStream object.

Parameters
fileNameThe name of the file to open for reading.

◆ StdioInputStream() [3/5]

Bond::StdioInputStream::StdioInputStream ( StdioFileHandle && handle)
inlineexplicit

Constructs a StdioInputStream object.

Parameters
handleAn owning file handle whose FILE object will be used for input operations.

◆ StdioInputStream() [4/5]

Bond::StdioInputStream::StdioInputStream ( StdioInputStream && other)
inline

Move-constructs a StdioInputStream object.

Parameters
otherThe StdioInputStream object from which resources will be moved.

◆ ~StdioInputStream()

virtual Bond::StdioInputStream::~StdioInputStream ( )
inlinevirtual

◆ StdioInputStream() [5/5]

Bond::StdioInputStream::StdioInputStream ( const StdioInputStream & other)
delete

Member Function Documentation

◆ AddOffset()

virtual void Bond::StdioInputStream::AddOffset ( off_t offset)
inlineoverridevirtual

Advances the current position by the given offset.

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

Implements Bond::Stream.

◆ ClearError()

virtual void Bond::StdioInputStream::ClearError ( )
inlineoverridevirtual

Clears the current error state of the stream.

Implements Bond::Stream.

◆ Close()

virtual void Bond::StdioInputStream::Close ( )
overridevirtual

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 from Bond::Stream.

◆ GetEndPosition()

virtual pos_t Bond::StdioInputStream::GetEndPosition ( ) const
overridevirtual

Returns the end position of the stream.

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

Implements Bond::Stream.

◆ GetPosition()

virtual pos_t Bond::StdioInputStream::GetPosition ( ) const
inlineoverridevirtual

Returns the current position within the stream.

Returns
The current absolute stream position.

Implements Bond::Stream.

◆ HasError()

virtual bool Bond::StdioInputStream::HasError ( ) const
inlineoverridevirtual

Tests whether the stream is currently in an error state.

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

Implements Bond::Stream.

◆ IsBound()

bool Bond::StdioInputStream::IsBound ( ) const
inline

Tests whether this stream is currently bound to a FILE object.

Returns
True if this stream is bound to a FILE object.

◆ IsEof()

virtual bool Bond::StdioInputStream::IsEof ( ) const
inlineoverridevirtual

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.

Implements Bond::Stream.

◆ operator=() [1/2]

StdioInputStream & Bond::StdioInputStream::operator= ( const StdioInputStream & other)
delete

◆ operator=() [2/2]

StdioInputStream & Bond::StdioInputStream::operator= ( StdioInputStream && other)

◆ Read() [1/2]

virtual int Bond::StdioInputStream::Read ( )
inlineoverridevirtual

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.

Implements Bond::InputStream.

◆ Read() [2/2]

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

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 from Bond::InputStream.

◆ SetPosition()

virtual void Bond::StdioInputStream::SetPosition ( off_t offset)
inlineoverridevirtual

Sets the current position within the stream.

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

Implements Bond::Stream.

◆ SetPositionFromEnd()

virtual void Bond::StdioInputStream::SetPositionFromEnd ( off_t offset)
inlineoverridevirtual

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.

Implements Bond::Stream.

◆ VScan()

virtual void Bond::StdioInputStream::VScan ( const char * format,
va_list argList )
inlineoverridevirtual

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.

Implements Bond::InputStream.


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