📄 qbuffer.3qt
字号:
.TH QBuffer 3qt "10 November 2000" "Trolltech AS" \" -*- nroff -*-.\" Copyright 1992-2000 Trolltech AS. All rights reserved. See the.\" license file included in the distribution for a complete license.\" statement..\".ad l.nh.SH NAMEQBuffer \- I/O device that operates on a QByteArray.SH SYNOPSIS.br.PP\fC#include <qbuffer.h>\fR.PPInherits QIODevice..PP.SS "Public Members".in +1c.ti -1c.BI "\fBQBuffer\fR () ".br.ti -1c.BI "\fBQBuffer\fR ( QByteArray ) ".br.ti -1c.BI "\fB~QBuffer\fR () ".br.ti -1c.BI "QByteArray \fBbuffer\fR () const".br.ti -1c.BI "bool \fBsetBuffer\fR ( QByteArray ) ".br.in -1c.SH DESCRIPTIONThe QBuffer class is an I/O device that operates on a QByteArray.PPQBuffer allows reading and writing a memory buffer. It is normally used together 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..PPThe constructor \fCQBuffer(QByteArray)\fR creates a QBuffer with an existing byte array. The byte array can also be set with setBuffer(). Writing to the QBuffer will modify the original byte array, since QByteArray is explicitly shared..PPUse 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()..PPThe 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..PPNote that QTextStream can also operate on a QString (a Unicode string); a QBuffer cannot..PPYou can also use QBuffer directly through the standard QIODevice functions readBlock(), writeBlock() readLine(), at(), getch(), putch() and ungetch()..PPSee also QFile, QDataStream, QTextStream, QByteArray and Shared Classes.PPExamples:.(lgrapher/grapher.cpp.)l.SH MEMBER FUNCTION DOCUMENTATION.SH "QBuffer::QBuffer ()"Constructs an empty buffer..SH "QBuffer::QBuffer ( QByteArray buf )"Constructs a buffer that operates on \fIbuf.\fR If you open the buffer in write mode (\fCIO_WriteOnly\fR or \fCIO_ReadWrite)\fR and write something into the buffer, \fIbuf\fR will be modified..PPExample:.PP.nf.br QCString str = "abc";.br QBuffer b( str );.br b.open( IO_WriteOnly );.br b.at( 3 ); // position at \\0.br b.writeBlock( "def", 4 ); // write including \\0.br b.close();.br // Now, str == "abcdef".fi.PPSee also setBuffer()..SH "QBuffer::~QBuffer ()"Destructs the buffer..SH "bool QBuffer::at ( int pos ) \fC[virtual]\fR"Reimplemented for internal reasons; the API is not affected..PPReimplemented from QIODevice..SH "int QBuffer::at () const \fC[virtual]\fR"Reimplemented for internal reasons; the API is not affected..PPReimplemented from QIODevice..SH "QByteArray QBuffer::buffer () const"Returns this buffer's byte array..PPSee also setBuffer()..SH "void QBuffer::close () \fC[virtual]\fR"Reimplemented for internal reasons; the API is not affected. Closes an open buffer..PPSee also open()..PPExamples:.(lgrapher/grapher.cpp.)l.PPReimplemented from QIODevice..SH "void QBuffer::flush () \fC[virtual]\fR"Reimplemented for internal reasons; the API is not affected. The flush function does nothing for a QBuffer..PPReimplemented from QIODevice..SH "int QBuffer::getch () \fC[virtual]\fR"Reimplemented for internal reasons; the API is not affected..PPReimplemented from QIODevice..SH "bool QBuffer::open ( int m ) \fC[virtual]\fR"Reimplemented for internal reasons; the API is not affected. Opens the buffer in the mode \fIm.\fR Returns TRUE if successful, otherwise FALSE. The buffer must be opened before use..PPThe mode parameter \fIm\fR must be a combination of the following flags..TP\fCIO_ReadOnly\fR opens a buffer in read-only mode..TP\fCIO_WriteOnly\fR opens a buffer in write-only mode..TP\fCIO_ReadWrite\fR opens a buffer in read/write mode..TP\fCIO_Append\fR sets the buffer index to the end of the buffer..TP\fCIO_Truncate\fR truncates the buffer..PPSee also close() and isOpen()..PPExamples:.(lgrapher/grapher.cpp.)l.PPReimplemented from QIODevice..SH "int QBuffer::putch ( int ch ) \fC[virtual]\fR"Reimplemented for internal reasons; the API is not affected. Writes the character \fIch\fR into the buffer, overwriting the character at the current index, extending the buffer if necessary..PPReturns \fIch,\fR or -1 if some error occurred..PPSee also getch() and ungetch()..PPExamples:.(lgrapher/grapher.cpp.)l.PPReimplemented from QIODevice..SH "int QBuffer::readBlock ( char * p, uint len ) \fC[virtual]\fR"Reimplemented for internal reasons; the API is not affected..PPReimplemented from QIODevice..SH "int QBuffer::readLine ( char * p, uint maxlen ) \fC[virtual]\fR"Reimplemented for internal reasons; the API is not affected..PPReimplemented from QIODevice..SH "bool QBuffer::setBuffer ( QByteArray buf )"Replaces the buffer's contents with \fIbuf.\fR.PPThis may not be done when isOpen() is TRUE..PPNote that if you open the buffer in write mode (\fCIO_WriteOnly\fR or IO_ReadWrite) and write something into the buffer, \fIbuf\fR is also modified because QByteArray is an explicitly shared class..PPSee also buffer(), open() and close()..SH "uint QBuffer::size () const \fC[virtual]\fR"Reimplemented for internal reasons; the API is not affected..PPReimplemented from QIODevice..SH "int QBuffer::ungetch ( int ch ) \fC[virtual]\fR"Reimplemented for internal reasons; the API is not affected..PPReimplemented from QIODevice..SH "int QBuffer::writeBlock ( const char * p, uint len ) \fC[virtual]\fR"Reimplemented for internal reasons; the API is not affected..PPWrites \fIlen\fR bytes from \fIp\fR into the buffer at the current index, overwriting any characters there and extending the buffer if necessary. Returns the number of bytes actually written..PPReturns -1 if a serious error occurred..PPSee also readBlock()..PPReimplemented from QIODevice..SH "SEE ALSO".BR http://doc.trolltech.com/qbuffer.html.SH COPYRIGHTCopyright 1992-2000 Trolltech AS, http://www.trolltech.com/. See thelicense file included in the distribution for a complete licensestatement..SH AUTHORGenerated automatically from the source code.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -