TQBuffer is used to read and write to a memory buffer. It is normally used with a TQTextStream or a TQDataStream. TQBuffer has an associated TQByteArray which holds the buffer data. The size() of the buffer is automatically adjusted as data is written.
The constructor \fCTQBuffer(TQByteArray)\fR creates a TQBuffer using an existing byte array. The byte array can also be set with setBuffer(). Writing to the TQBuffer will modify the original byte array because TQByteArray is explicitly shared.
Use open() to open the buffer before use and to set the mode (read-only, write-only, etc.). close() closes the buffer. The buffer must be closed before reopening or calling setBuffer().
A common way to use TQBuffer is through TQDataStream or TQTextStream, which have constructors that take a TQBuffer parameter. For convenience, there are also TQDataStream and TQTextStream constructors that take a TQByteArray parameter. These constructors create and open an internal TQBuffer.
You can also use TQBuffer directly through the standard TQIODevice functions readBlock(), writeBlock() readLine(), at(), getch(), putch() and ungetch().
If you open the buffer in write mode (<a href="tqfile.html#open">IO_WriteOnly</a> or IO_ReadWrite) and write something into the buffer, \fIbuf\fR will be modified.
Note that if you open the buffer in write mode (<a href="tqfile.html#open">IO_WriteOnly</a> or IO_ReadWrite) and write something into the buffer, \fIbuf\fR is also modified because TQByteArray is an explicitly shared class.
Writes \fIlen\fR bytes from \fIp\fR into the buffer at the current index position, overwriting any characters there and extending the buffer if necessary. Returns the number of bytes actually written.