#include <miodevice.h>
Inheritance diagram for IODevice:
Public Methods | |
IODevice () | |
virtual | ~IODevice () |
bool | isDirectAccess () const |
bool | isSequentialAccess () const |
bool | isSynchronous () const |
bool | isAsynchronous () const |
virtual bool | open (int mode) |
virtual void | close () |
virtual void | flush () |
virtual uint | size () const |
virtual int | at () const |
virtual bool | atEnd () const |
virtual bool | seek (int) |
bool | reset () |
virtual int | readBlock (char *data, uint maxlen) throw (device_not_open) |
virtual int | readLine (char *data, uint maxlen) throw (device_not_open) |
Ref< String > | readAll () throw (device_not_open) |
List< String > * | readLines () throw (device_not_open) |
virtual int | writeBlock (const char *data, uint len) throw (device_not_open) |
int | writeBlock (const String &) throw (device_not_open) |
virtual int | getch () throw (device_not_open) |
virtual void | putch (char ch) throw (device_not_open) |
virtual void | ungetch (char ch) throw (device_not_open) |
Definition at line 96 of file miodevice.h.
|
Default constructor for IODevice.
Definition at line 48 of file miodevice.cc. |
|
Virtual destructor for IODevice.
Definition at line 58 of file miodevice.cc. |
|
Returns the current position in device. Only meaningful for "block devices", which have a defined size. Reimplemented in File, Buffer, and Socket. Definition at line 156 of file miodevice.cc. |
|
Returns true if currently at end of file, and false if not. This is useful for iterating over a device. Reimplemented in File, and Buffer. Definition at line 166 of file miodevice.cc. Referenced by TextIStream::operator>>(), and TextIStream::readLine(). |
|
Closes the device. Flushes open buffers. Reimplemented in File. Definition at line 122 of file miodevice.cc. |
|
Flushes (writes) the buffers. Flushing ensures that all data that has been written to the device is really written, and does not wait in a buffer. This is important if an application crashes unexpectedly, or if we just want to be able to read it immediately. This has only effect if the device has been opened for buffered writing. Reimplemented in File. Definition at line 137 of file miodevice.cc. Referenced by OStream::flush(), and TextOStream::printf(). |
|
Reads and returns one character from device.
Reimplemented in File, Buffer, and Socket. Definition at line 309 of file miodevice.cc. Referenced by TextIStream::operator>>(). |
|
Returns true if the device is asynchronous, i.e., buffered.
Definition at line 85 of file miodevice.cc. References IO_Raw. |
|
Returns true if the device is capable of direct access.
Definition at line 64 of file miodevice.cc. |
|
Returns true if the device is capable of sequential access.
Definition at line 71 of file miodevice.cc. |
|
Returns true if the device is synchronous, i.e., raw or unbuffered.
Definition at line 78 of file miodevice.cc. References IO_Raw. |
|
Opens device with given I/O mode. Typical usage: File myFile ("/path/file.ext"); myFile.open (IO_Readable); String myFileContents = myFile.readAll (); myFile.close ();
Reimplemented in File, Buffer, and Socket. Definition at line 112 of file miodevice.cc. Referenced by IStream::IStream(). |
|
Writes one character to device.
Reimplemented in File, Buffer, and Socket. Definition at line 318 of file miodevice.cc. |
|
Reads the entire device into a string buffer.
Definition at line 276 of file miodevice.cc. |
|
Reads a data block from the device.
Reimplemented in File, Buffer, and Socket. Definition at line 196 of file miodevice.cc. Referenced by DataIStream::operator>>(), TextIStream::readRawBytes(), and DataIStream::readRawBytes(). |
|
Reads a newline (\n) terminated line from device. The buffer must be allocated to contain the given length of bytes. The function spares one byte for the terminating zero, so the actual maximum number of bytes read is one less than the maxlen parameter. Example: // Read in chunks char buffer [1024]; int bytesRead = 0; int totalRead = 0; while (bytesRead = mpDevice->readLine (buffer, 1024)) { linebuf.append (buffer); totalRead += bytesRead; }
Reimplemented in File, Buffer, and Socket. Definition at line 242 of file miodevice.cc. Referenced by TextIStream::readLine(). |
|
Reads all newline (\n) terminated lines from device.
Definition at line 297 of file miodevice.cc. |
|
Resets the state of the device to a newly opened state.
Reimplemented in Buffer, and Socket. Definition at line 187 of file miodevice.cc. Referenced by Buffer::reset(). |
|
Changes the current position in device. The function has meaning only if the device is capable of direct access.
Reimplemented in File. Definition at line 178 of file miodevice.cc. |
|
Returns the size of the file in bytes. Only meaningful for "block devices", which have a defined size. Reimplemented in File, Buffer, and Socket. Definition at line 146 of file miodevice.cc. |
|
Unreads one character from device. The function has no meaning if the device is already at beginning. Reimplemented in File, Buffer, and Socket. Definition at line 329 of file miodevice.cc. Referenced by TextIStream::operator>>(). |
|
Writes a data block to device.
Reimplemented in Buffer, and Socket. Definition at line 266 of file miodevice.cc. |
|
Writes a data block to device.
Reimplemented in File, Buffer, and Socket. Definition at line 208 of file miodevice.cc. Referenced by TextOStream::operator<<(), and TextOStream::printf(). |