Description:
This class wraps around an ostream and provides a machine-independant framework for writing various binary encoded data types. Sub-classes may be optimized for individual platforms.
Data Fields | ||
private | ostream* | out |
Constructors / Destructor | |
public | Writer(ostream& out)Constructor from ostream passed by reference. |
public | Writer(ostream* out)Constructor from ostream passed as a pointer . |
public | ~Writer()Destructor. This method flushes the ostream, but does not close or delete it. |
Methods | |||
public | virtual | ostream* | getStream()Return a pointer to the underlying ostream. |
public | virtual | void | writeByte(unsigned char value)Write a single byte . |
public | virtual | void | writeBytes(unsigned char* buffer, int n)Write a given number of bytes . |
public | virtual | void | writeInt(int value, int bytes)Write an twos complement, big-endian integer a given number of bytes in length . |
public | virtual | void | writeUnsignedInt(unsigned int value, int bytes)Write an unsigned big-endian integer a given number of bytes in length . |
public | virtual | void | writeUnsignedBits(unsigned int value, int n)Write a given unsigned integer represented by a given number of bits. |
public | virtual | void | writeSignedBits(int value, int n)Write a given twos compliment signed integer represented by a given number of bits . |
public | virtual | void | writeFloat(float value)Write a 4 byte IEEE format floating point number. |
public | virtual | void | writeDouble(double value)Write a 8 byte IEEE format floating point number. |
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 makes no assumptions so this method does nothing. |
public | virtual | void | writeTestPattern()Write a fixed set of values. These can then be read back with the readTestPattern method to check a reader and writer for self-consistency. |
Operators |