#include <iodevice.h>
Inheritance diagram for IODevice:
Public Methods | |
IODevice () | |
A constructor. More... | |
virtual void | prepare (void)=0 throw (ExaltIOException) |
Prepare the device. More... | |
virtual void | flush (void)=0 throw (ExaltIOException) |
Flush the device. More... | |
virtual void | finish (void)=0 throw (ExaltIOException) |
Finish the work with the device. More... | |
virtual IOState | readData (char *buf, IOSize length)=0 throw (ExaltIOException) |
Read up to the specified number of bytes into the buffer. More... | |
virtual IOState | getChar (int *c)=0 throw (ExaltIOException) |
Read one char. More... | |
virtual IOState | writeData (const char *buf, IOSize length)=0 throw (ExaltIOException) |
Write the specified number of bytes from the buffer. More... | |
virtual IOState | putChar (int c)=0 throw (ExaltIOException) |
Write one char. More... | |
virtual IOSize | bytesReadTotal (void)=0 |
Return the number of bytes read so far. More... | |
virtual IOSize | bytesRead (void)=0 |
Return the number of bytes read by the last read operation. More... | |
virtual IOSize | bytesWritten (void)=0 |
Return the number of bytes written so far. More... | |
virtual bool | errorOccurred (void)=0 |
Informs whether an error occurred. More... | |
virtual bool | eof (void)=0 |
Informs whether the end of file occurred. More... | |
virtual bool | isPrepared (void) |
Informs whether the device is prepared. More... | |
Protected Attributes | |
bool | prepared |
Indication whether the device is prepared. |
Libexalt is designed to support various kinds of inputs and outputs. In order to make this possible, it provides an abstraction of an input/output device. This generic device defines an interface that has to be implemented by all the devices used for the input/output.
The IODevice class defines also the style of the work with the devices. A typical example would look as follows (using FileDevice, which represents a file input/output):
... FileDevice file; char buffer[BUFFER_SIZE] file.prepare("filename.txt"); while (file.readData(buffer, BUFFER_SIZE) == ReadOk) { //...do something with the buffer } if (file.errorOccurred()) { //...an error occurred. } file.finish(); ...
The device uses the C++ exceptions to report errors (see exceptions.h).
Definition at line 103 of file iodevice.h.
|
A constructor.
Initializes the device as unprepared. Definition at line 111 of file iodevice.h. References prepared. |
|
Return the number of bytes read by the last read operation.
Returns the number of bytes read from the device by the last read operation.
Implemented in FileDevice. |
|
Return the number of bytes read so far.
Returns the total number of bytes read from the device.
Implemented in FileDevice. |
|
Return the number of bytes written so far.
Returns the total number of bytes written to the device.
Implemented in FileDevice. |
|
Informs whether the end of file occurred.
This method can be used for tests of the "end of file".
Implemented in FileDevice. Referenced by XmlCodec::decode. |
|
Informs whether an error occurred.
If any of the IO operations was unsuccessful, this method can be used to test it.
Implemented in FileDevice. Referenced by XmlCodec::decode. |
|
Finish the work with the device.
This method ends the work with the device. In a case of a file device, for example, it may close a file. An attempt to work with finished device will cause an ExaltIOException to be raised. Implemented in FileDevice. |
|
Flush the device.
Ensures that all the data is written to the device. Implemented in FileDevice. |
|
Read one char.
Reads one character from the device. If an error occurred, ExaltIOException is raised.
Implemented in FileDevice. Referenced by XmlCodec::decode. |
|
Informs whether the device is prepared.
If the device is prepared, this method returns TRUE.
Definition at line 236 of file iodevice.h. References prepared. Referenced by FileDevice::~FileDevice. |
|
Prepare the device.
This method prepares the device for further work. In a case of a file device, for example, it can open a file. An attempt to work with unprepared device will cause an ExaltIOException to be raised. Implemented in FileDevice. |
|
Write one char.
Writes one character to the device. If an error occurred, ExaltIOException is raised.
Implemented in FileDevice. Referenced by ArithCodec::doneOutputtingBits, XmlCodec::encode, and XmlCodec::initializePushCoder. |
|
Read up to the specified number of bytes into the buffer.
Reads up to length bytes from the device and stores them in buffer. If an error occurred, ExaltIOException is raised.
Implemented in FileDevice. Referenced by XmlCodec::decode. |
|
Write the specified number of bytes from the buffer.
Writes length bytes from the buffer buf to the device. If an error occurred, ExaltIOException is raised.
Implemented in FileDevice. Referenced by KYGrammar::appendToRootRule, XmlCodec::encode, XmlCodec::initializePushCoder, KYGrammar::reconstructRule, and KYGrammar::setAlphabetBaseSize. |