NAMEQBuffer - I/O device that operates on a QByteArray
SYNOPSISAll the functions in this class are reentrant when Qt is built with thread support.</p> #include <qbuffer.h> Inherits QIODevice. Public Members QBuffer () QBuffer ( QByteArray buf ) ~QBuffer () QByteArray buffer () const bool setBuffer ( QByteArray buf ) virtual Q_LONG writeBlock ( const char * p, Q_ULONG len ) Q_LONG writeBlock ( const QByteArray & data )
DESCRIPTIONThe QBuffer class is an I/O device that operates on a QByteArray. QBuffer is used to read and write to a memory buffer. It is normally used with a QTextStream or a QDataStream. QBuffer has an associated QByteArray which holds the buffer data. The size() of the buffer is automatically adjusted as data is written. The constructor QBuffer(QByteArray) creates a QBuffer using an existing byte array. The byte array can also be set with setBuffer(). Writing to the QBuffer will modify the original byte array because QByteArray 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 QBuffer is through QDataStream or QTextStream, which have constructors that take a QBuffer parameter. For convenience, there are also QDataStream and QTextStream constructors that take a QByteArray parameter. These constructors create and open an internal QBuffer. Note that QTextStream can also operate on a QString (a Unicode string); a QBuffer cannot. You can also use QBuffer directly through the standard QIODevice functions readBlock(), writeBlock() readLine(), at(), getch(), putch() and ungetch(). See also QFile, QDataStream, QTextStream, QByteArray, Shared Classes, Collection Classes, and Input/Output and Networking.
MEMBER FUNCTION DOCUMENTATION
QBUFFER::QBUFFER ()Constructs an empty buffer.
QBUFFER::QBUFFER ( QBYTEARRAY BUF )Constructs a buffer that operates on buf. If you open the buffer in write mode (<a href="qfile.html#open">IO_WriteOnly</a> or IO_ReadWrite) and write something into the buffer, buf will be modified. Example: QCString str = "abc"; QBuffer b( str ); b.open( IO_WriteOnly ); b.at( 3 ); // position at the 4th character (the terminating \0) b.writeBlock( "def", 4 ); // write "def" including the terminating \0 b.close(); // Now, str == "abcdef" with a terminating \0 See also setBuffer().
QBUFFER::~QBUFFER ()Destroys the buffer.
QBYTEARRAY QBUFFER::BUFFER () CONSTReturns this buffer's byte array. See also setBuffer().
BOOL QBUFFER::SETBUFFER ( QBYTEARRAY BUF )Replaces the buffer's contents with buf and returns TRUE. Does nothing (and returns FALSE) if isOpen() is TRUE. Note that if you open the buffer in write mode (<a href="qfile.html#open">IO_WriteOnly</a> or IO_ReadWrite) and write something into the buffer, buf is also modified because QByteArray is an explicitly shared class. See also buffer(), open(), and close().
Q_LONG QBUFFER::WRITEBLOCK ( CONST CHAR * P, Q_ULONG LEN ) [VIRTUAL]Writes len bytes from p 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. Returns -1 if an error occurred. See also readBlock(). Reimplemented from QIODevice.
Q_LONG QBUFFER::WRITEBLOCK ( CONST QBYTEARRAY & DATA )This is an overloaded member function, provided for convenience. It behaves essentially like the above function. This convenience function is the same as calling writeBlock( data.data(), data.size() ) with data.
SEE ALSO//doc.trolltech.com/qbuffer.html //www.trolltech.com/faq/tech.html
COPYRIGHTCopyright 1992-2007 Trolltech ASA, //www.trolltech.com. See the license file included in the distribution for a complete license statement.
AUTHORGenerated automatically from the source code.
BUGSIf you find a bug in Qt, please report it as described in //doc.trolltech.com/bughowto.html. Good bug reports help us to help you. Thank you. The definitive Qt documentation is provided in HTML format; it is located at $QTDIR/doc/html and can be read using Qt Assistant or with a web browser. This man page is provided as a convenience for those users who prefer man pages, although this format is not officially supported by Trolltech. If you find errors in this manual page, please report them to qt- firstname.lastname@example.org. Please include the name of the manual page (qbuffer.3qt) and the Qt version (3.3.8). QBUFFER(3)