#include <qafIntegerInputStream.h>
Inheritance diagram for qaf::IntegerInputStream:
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 () |
| |
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... |
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()
.
bool qaf::IntegerInputStream::canRead | ( | ) |
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.
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
.
EndOfFileException | if the end of the file is reached before a NUL value. | |
EncodingException | if the stream contains invalid encoding. |