Main Page   Namespace List   Class Hierarchy   Compound List   File List   Namespace Members   Compound Members   File Members  

lrt::InputStream Class Reference

InputStream is the base class of all input streams (such as files opened for reading) in libRT. More...

#include <rtstreams.h>

Inheritance diagram for lrt::InputStream:

Inheritance graph
[legend]
List of all members.

Public Methods

virtual bool markSupported ()
 Returns whether marking and resetting a position in the stream is supported. More...

virtual void mark ()
 Saves the current position in the stream for later restoring it. More...

virtual void reset ()
 If possible, restores the stream position saved by mark(). More...

virtual int read ()=0
 Reads a byte from the stream. More...

virtual int read (Array< char > &b, int off, int len)
 Reads up to len bytes from the stream, storing them in b, beginning at position off. More...

int read (Array< char > &b)
 Tries to fill the array b with bytes from the stream. More...

virtual bool eos ()=0
 Checks if this stream's end has been reached. More...

virtual bool fail ()
 Returns true if there was some system failure for this stream (such as, it couldn't be opened).

virtual void close ()
 Closes the stream, and releases any system resources. More...

virtual ~InputStream ()
 Destroys the stream. More...


Protected Methods

 InputStream ()
 protected ////. More...


Protected Attributes

bool _fail
 Set _fail, if a system-dependent operation for this stream (such as opening) fails.


Detailed Description

InputStream is the base class of all input streams (such as files opened for reading) in libRT.

Since this abstract input stream does not implement any source of data, it is impossible to construct one. For useful concrete input streams, look at the following classes:

See also:
FileInputStream , ParseInputStream


Constructor & Destructor Documentation

lrt::InputStream::~InputStream (    )  [virtual]
 

Destroys the stream.

The destructor of class InputStream just calls the close method.

lrt::InputStream::InputStream (    )  [protected]
 

protected ////.

The constructor of class InputStream just does nothing and is only present to avoid construction of plain InputStreams.


Member Function Documentation

void lrt::InputStream::close (    )  [virtual]
 

Closes the stream, and releases any system resources.

Closed streams cannot be re-opened. The close method of class InputStream does nothing.

Reimplemented in rt::DefineInputStream.

virtual bool lrt::InputStream::eos (    )  [pure virtual]
 

Checks if this stream's end has been reached.

This method must be implemented by subclassers!

Returns:
true if the stream has ended, false if there is still some data to read.

Implemented in rt::DefineInputStream.

void lrt::InputStream::mark (    )  [virtual]
 

Saves the current position in the stream for later restoring it.

Note that if marking is not supported, mark() has no effect.

See also:
markSupported() , reset()

Reimplemented in rt::DefineInputStream.

bool lrt::InputStream::markSupported (    )  [virtual]
 

Returns whether marking and resetting a position in the stream is supported.

The markSupported method of class InputStream always returns false.

See also:
mark()

Reimplemented in rt::DefineInputStream.

int lrt::InputStream::read (  Array< char > &    b ) 
 

Tries to fill the array b with bytes from the stream.

Note: You need never subclass this method.

Returns:
The number of bytes actually read, or -1 if the stream's end was reached.

int lrt::InputStream::read (  Array< char > &    b,
int    off,
int    len
)  [virtual]
 

Reads up to len bytes from the stream, storing them in b, beginning at position off.

Note that b must be large enough.

Returns:
The number of bytes actually read, or -1 if the stream's end was reached.

Reimplemented in lrt::NetworkInputStream.

virtual int lrt::InputStream::read (    )  [pure virtual]
 

Reads a byte from the stream.

If the stream cannot be read (or is EOF), this method returns -1. This method must be implemented by subclassers!

Returns:
The byte (in the lowest 8 bits of the returned integer), or -1 if the stream has ended.

Implemented in rt::DefineInputStream.

void lrt::InputStream::reset (    )  [virtual]
 

If possible, restores the stream position saved by mark().

If marking is not supported, reset() has no effect.

See also:
markSupported() , mark()

Reimplemented in rt::DefineInputStream.


The documentation for this class was generated from the following files:
This is the RoboTour API documentation version 0.1 • Copyright (C) by Florian Fischer