qaf::IntegerInputStream Class Reference

#include <qafIntegerInputStream.h>

Inheritance diagram for qaf::IntegerInputStream:

qaf::HgeInputStream List of all members.

Detailed Description

Encapsulates decoding of an integer stream.

The Qaf editors use a modified version of UTF-8 to store integers in their files, which allows any integer value (including negative numbers) to be written or read.

This class reads integers from one of those files. An exception will be thrown if the UTF-8 encoding in the file is invalid.


Public Member Functions

 IntegerInputStream (const char *filename)
 The constructor will open the specified file, preparing it for reading.
bool canRead ()
 
Returns:
true if the file has been successfully opened and/or there are more bytes to be read from it.

int readInt ()
 Reads the next integer from the stream.
std::string readNullTerminatedString ()
 Reads integers from the stream until a NUL value (zero) is found, converts them to characters and wraps them in a string.
virtual ~IntegerInputStream ()
 Destructor: If the file is open, it will be automatically closed before this object is destroyed.

Classes

class  EncodingException
 Represents an encoding error in the pseudo-UTF-8 stream. More...
class  EndOfFileException
 Represents an unexpected end-of-file during reading operations. More...


Constructor & Destructor Documentation

qaf::IntegerInputStream::IntegerInputStream ( const char *  filename  ) 

The constructor will open the specified file, preparing it for reading.

Before accessing the stream with its reading methods, it is advisable to check if the operation was successful with canRead().


Member Function Documentation

bool qaf::IntegerInputStream::canRead (  ) 

Returns:
true if the file has been successfully opened and/or there are more bytes to be read from it.

Warning:
This does not mean you can call readInt() without checking for exceptions. There may not be enough bytes in the stream, or there may be an error in their encoding.

Reimplemented from qaf::HgeInputStream.

int qaf::IntegerInputStream::readInt (  ) 

Reads the next integer from the stream.

Returns:
The integer value.
Exceptions:
EndOfFileException if the end of the file is reached.
EncodingException if the stream contains invalid encoding.

std::string qaf::IntegerInputStream::readNullTerminatedString (  ) 

Reads integers from the stream until a NUL value (zero) is found, converts them to characters and wraps them in a string.

Returns:
The string read.
Exceptions:
EndOfFileException if the end of the file is reached before a NUL value.
EncodingException if the stream contains invalid encoding.


The documentation for this class was generated from the following file:
Generated on Sun Mar 25 12:32:15 2007 for Qaf Framework by  doxygen 1.5.1-p1