Alphabetic Class Index   |   Class Inheritance Tree Index   |   Tool Index

Class: Reader

Parent class: Interpreter

Description:
This class wraps around an istream and provides a machine-independant framework for reading various binary encoded data types. Sub-classes of this class may be optimized for individual platforms.

Data Fields
privateistream*in

Constructors / Destructor
public Reader(istream& in)
Constructor from istream passed by reference.
public Reader(istream* in)
Constructor from istream passed as a pointer .
public ~Reader()
Destructor .

Methods
public virtual istream* getStream()
Returns a pointer to the underlying istream.
public virtual unsigned char readByte()
Read a single byte.
Throws: Exception
public virtual int readBytes(unsigned char* buffer, int n)
Read a given number of bytes into an array. Returns the number of bytes actually read Note this method will throw an IOException (e.g. EOFException) only if no bytes can be read from the underlying stream.
Throws: Exception
public virtual int readBytes(unsigned char* buffer, int n, int min)
Read a given number of bytes into an array. Returns the number of bytes actually read This method will throw an IOException (e.g. EOFException) if fewer than "min" bytes were read from the underlying stream.
Throws: Exception
public virtual int readInt(int bytes)
Read a twos compliment signed integer of a a given number of bytes. The most significant bytes are read first.
Throws: Exception
public virtual unsigned int readUnsignedInt(int bytes)
Read an unsigned integer of a given number of bytes. The most significant bytes are read first.
Throws:
public virtual unsigned int readUnsignedBits(int n_bits_needed)
Read a given number of bits as an unsigned integer.
Throws: Exception
public virtual int readSignedBits(int n_bits_needed)
Read a given number of bits as a twos compliment signed integer.
Throws: Exception
public virtual float readFloat()
Read a 4 byte IEEE-754 format floating point number.
Throws: Exception
public virtual double readDouble()
Read a 8 byte IEEE-754 format floating point number.
Throws: Exception
public static void checkMachine()
Test whether the machine running this code stores variables in a way consistent with the assumptions made when writing this class. This particular class makes no assumptions, so this method does nothing.
Throws: HardwareException
public virtual void readTestPattern()
Read the set of values written by Writer::writeTestPattern. Throws a HardwareException if there was an inconsistency.
Throws: Exception

Operators


Alphabetic Class Index   |   Class Inheritance Tree Index   |   Tool Index