#include <miodevice.h>
Inheritance diagram for Buffer:
Public Methods | |
Buffer (int mode=IO_ReadWrite) | |
Buffer (String &buffer, int mode=IO_ReadWrite) | |
virtual bool | open (int mode) |
virtual uint | size () const |
virtual int | at () const |
bool | reset () |
virtual bool | atEnd () const |
virtual int | readBlock (char *data, uint maxlen) 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 | readLine (char *data, uint maxlen) 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) |
@example
String myString; Buffer myBuffer (myString); // Attach buffer to a string (buffer) TextOStream myStream (myBuffer); // Attach stream to the buffer myStream << "Hello, world!"; // Put something in the stream cout << myString << newl; // Prints out "Hello, world!\n"
Definition at line 244 of file miodevice.h.
|
Default constructor for Buffer.
Definition at line 779 of file miodevice.cc. References MagiC::i18n(), and open(). |
|
Constructs a buffer to use a given string as the buffer. Notice that the string is _not_ destructed along with the Buffer. Definition at line 796 of file miodevice.cc. References MagiC::i18n(), and open(). |
|
Returns the current position in device. Only meaningful for "block devices", which have a defined size. Reimplemented from IODevice. Definition at line 252 of file miodevice.h. |
|
Returns true if currently at end of file, and false if not. This is useful for iterating over a device. Reimplemented from IODevice. Definition at line 841 of file miodevice.cc. References size(). |
|
Reads and returns one character from device.
Reimplemented from IODevice. Definition at line 907 of file miodevice.cc. |
|
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 from IODevice. Definition at line 815 of file miodevice.cc. References String::empty(), IO_Append, IO_Truncate, String::length(), and reset(). Referenced by Buffer(). |
|
Writes one character to device.
Reimplemented from IODevice. Definition at line 917 of file miodevice.cc. |
|
Reads a data block from the device.
Reimplemented from IODevice. Definition at line 849 of file miodevice.cc. |
|
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 from IODevice. Definition at line 872 of file miodevice.cc. |
|
Resets the state of the device to a newly opened state.
Reimplemented from IODevice. Definition at line 832 of file miodevice.cc. References IODevice::reset(). Referenced by open(). |
|
Returns the size of the file in bytes. Only meaningful for "block devices", which have a defined size. Reimplemented from IODevice. Definition at line 251 of file miodevice.h. References String::length(). Referenced by atEnd(). |
|
Unreads one character from device. The function has no meaning if the device is already at beginning. Reimplemented from IODevice. Definition at line 930 of file miodevice.cc. |
|
Writes a data block to device.
Reimplemented from IODevice. Definition at line 900 of file miodevice.cc. |
|
Writes a data block to device.
Reimplemented from IODevice. Definition at line 864 of file miodevice.cc. |