⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 qdatastream.3qt

📁 Linux下的基于X11的图形开发环境。
💻 3QT
📖 第 1 页 / 共 2 页
字号:
.br    if ( version > 120 ).br        stream >> [data new in XXX version 1.2];.br    stream >> [other interesting data];.br.fi.PPYou can select which byte order to use when serializing data. The default setting is big endian (MSB first). Changing it to little endian breaks the portability (unless the reader also changes to little endian). We recommend keeping this setting unless you have special requirements..SH "Reading and writing raw binary data"You may wish to read/write your own raw binary data to/from the data stream directly. Data may be read from the stream into a preallocated char* using readRawBytes(). Similarly data can be written to the stream using writeRawBytes(). Notice that any encoding/decoding of the data must be done by you..PPA similar pair of functions is readBytes() and writeBytes(). These differ from their \fIraw\fR counterparts as follows: readBytes() reads a Q_UINT32 which is taken to be the length of the data to be read, then that number of bytes is read into the preallocated char*; writeBytes() writes a Q_UINT32 containing the length of the data, followed by the data. Notice that any encoding/decoding of the data (apart from the length Q_UINT32) must be done by you..PPSee also QTextStream, QVariant, and Input/Output and Networking..SS "Member Type Documentation".SH "QDataStream::ByteOrder"The byte order used for reading/writing the data..TP\fCQDataStream::BigEndian\fR - the default.TP\fCQDataStream::LittleEndian\fR.SH MEMBER FUNCTION DOCUMENTATION.SH "QDataStream::QDataStream ()"Constructs a data stream that has no IO device..PPSee also setDevice()..SH "QDataStream::QDataStream ( QIODevice * d )"Constructs a data stream that uses the IO device \fId\fR..PP\fBWarning:\fR If you use QSocket or QSocketDevice as the IO device \fId\fR for reading data, you must make sure that enough data is available on the socket for the operation to successfully proceed; QDataStream does not have any means to handle or recover from short-reads..PPSee also setDevice() and device()..SH "QDataStream::QDataStream ( QByteArray a, int mode )"Constructs a data stream that operates on a byte array, \fIa\fR, through an internal QBuffer device. The \fImode\fR is a QIODevice::mode(), usually either IO_ReadOnly or IO_WriteOnly..PPExample:.PP.nf.br    static char bindata[] = { 231, 1, 44, ... };.br    QByteArray a;.br    a.setRawData( bindata, sizeof(bindata) );   // a points to bindata.br    QDataStream stream( a, IO_ReadOnly );       // open on a's data.br    stream >> [something];                      // read raw bindata.br    a.resetRawData( bindata, sizeof(bindata) ); // finished.br.fi.PPThe QByteArray::setRawData() function is not for the inexperienced..SH "QDataStream::~QDataStream ()\fC [virtual]\fR"Destroys the data stream..PPThe destructor will not affect the current IO device, unless it is an internal IO device processing a QByteArray passed in the \fIconstructor\fR, in which case the internal IO device is destroyed..SH "bool QDataStream::atEnd () const"Returns TRUE if the IO device has reached the end position (end of the stream or file) or if there is no IO device set; otherwise returns FALSE, i.e. if the current position of the IO device is before the end position..PPSee also QIODevice::atEnd()..SH "int QDataStream::byteOrder () const"Returns the current byte order setting -- either BigEndian or LittleEndian..PPSee also setByteOrder()..SH "QIODevice * QDataStream::device () const"Returns the IO device currently set..PPSee also setDevice() and unsetDevice()..SH "bool QDataStream::eof () const"\fBThis function is obsolete.\fR It is provided to keep old source working. We strongly advise against using it in new code..PPReturns TRUE if the IO device has reached the end position (end of stream or file) or if there is no IO device set..PPReturns FALSE if the current position of the read/write head of the IO device is somewhere before the end position..PPSee also QIODevice::atEnd()..SH "bool QDataStream::isPrintableData () const"Returns TRUE if the printable data flag has been set; otherwise returns FALSE..PPSee also setPrintableData()..SH "QDataStream & QDataStream::operator<< ( Q_INT8 i )"Writes a signed byte, \fIi\fR, to the stream and returns a reference to the stream..SH "QDataStream & QDataStream::operator<< ( Q_UINT8 i )"This is an overloaded member function, provided for convenience. It behaves essentially like the above function..PPWrites an unsigned byte, \fIi\fR, to the stream and returns a reference to the stream..SH "QDataStream & QDataStream::operator<< ( Q_INT16 i )"This is an overloaded member function, provided for convenience. It behaves essentially like the above function..PPWrites a signed 16-bit integer, \fIi\fR, to the stream and returns a reference to the stream..SH "QDataStream & QDataStream::operator<< ( Q_UINT16 i )"This is an overloaded member function, provided for convenience. It behaves essentially like the above function..PPWrites an unsigned 16-bit integer, \fIi\fR, to the stream and returns a reference to the stream..SH "QDataStream & QDataStream::operator<< ( Q_INT32 i )"This is an overloaded member function, provided for convenience. It behaves essentially like the above function..PPWrites a signed 32-bit integer, \fIi\fR, to the stream and returns a reference to the stream..SH "QDataStream & QDataStream::operator<< ( Q_UINT32 i )"This is an overloaded member function, provided for convenience. It behaves essentially like the above function..PPWrites an unsigned integer, \fIi\fR, to the stream as a 32-bit unsigned integer (Q_UINT32). Returns a reference to the stream..SH "QDataStream & QDataStream::operator<< ( Q_LONG i )"This is an overloaded member function, provided for convenience. It behaves essentially like the above function..PPWrites a signed integer \fIi\fR, of the system's word length, to the stream and returns a reference to the stream..SH "QDataStream & QDataStream::operator<< ( Q_ULONG i )"This is an overloaded member function, provided for convenience. It behaves essentially like the above function..PPWrites an unsigned integer \fIi\fR, of the system's word length, to the stream and returns a reference to the stream..SH "QDataStream & QDataStream::operator<< ( float f )"This is an overloaded member function, provided for convenience. It behaves essentially like the above function..PPWrites a 32-bit floating point number, \fIf\fR, to the stream using the standard IEEE754 format. Returns a reference to the stream..SH "QDataStream & QDataStream::operator<< ( double f )"This is an overloaded member function, provided for convenience. It behaves essentially like the above function..PPWrites a 64-bit floating point number, \fIf\fR, to the stream using the standard IEEE754 format. Returns a reference to the stream..SH "QDataStream & QDataStream::operator<< ( const char * s )"This is an overloaded member function, provided for convenience. It behaves essentially like the above function..PPWrites the '&#92;0'-terminated string \fIs\fR to the stream and returns a reference to the stream..PPThe string is serialized using writeBytes()..SH "QDataStream & QDataStream::operator>> ( Q_INT8 & i )"Reads a signed byte from the stream into \fIi\fR, and returns a reference to the stream..SH "QDataStream & QDataStream::operator>> ( Q_UINT8 & i )"This is an overloaded member function, provided for convenience. It behaves essentially like the above function..PPReads an unsigned byte from the stream into \fIi\fR, and returns a reference to the stream..SH "QDataStream & QDataStream::operator>> ( Q_INT16 & i )"This is an overloaded member function, provided for convenience. It behaves essentially like the above function..PPReads a signed 16-bit integer from the stream into \fIi\fR, and returns a reference to the stream..SH "QDataStream & QDataStream::operator>> ( Q_UINT16 & i )"This is an overloaded member function, provided for convenience. It behaves essentially like the above function..PPReads an unsigned 16-bit integer from the stream into \fIi\fR, and returns a reference to the stream..SH "QDataStream & QDataStream::operator>> ( Q_INT32 & i )"This is an overloaded member function, provided for convenience. It behaves essentially like the above function..PPReads a signed 32-bit integer from the stream into \fIi\fR, and returns a reference to the stream..SH "QDataStream & QDataStream::operator>> ( Q_UINT32 & i )"This is an overloaded member function, provided for convenience. It behaves essentially like the above function..PPReads an unsigned 32-bit integer from the stream into \fIi\fR, and returns a reference to the stream..SH "QDataStream & QDataStream::operator>> ( Q_LONG & i )"This is an overloaded member function, provided for convenience. It behaves essentially like the above function..PPReads a signed integer of the system's word length from the stream into \fIi\fR, and returns a reference to the stream..SH "QDataStream & QDataStream::operator>> ( Q_ULONG & i )"This is an overloaded member function, provided for convenience. It behaves essentially like the above function..PPReads an unsigned integer of the system's word length from the stream, into \fIi\fR, and returns a reference to the stream..SH "QDataStream & QDataStream::operator>> ( float & f )"This is an overloaded member function, provided for convenience. It behaves essentially like the above function..PPReads a 32-bit floating point number from the stream into \fIf\fR, using the standard IEEE754 format. Returns a reference to the stream..SH "QDataStream & QDataStream::operator>> ( double & f )"This is an overloaded member function, provided for convenience. It behaves essentially like the above function..PPReads a 64-bit floating point number from the stream into \fIf\fR, using the standard IEEE754 format. Returns a reference to the stream..SH "QDataStream & QDataStream::operator>> ( char *& s )"This is an overloaded member function, provided for convenience. It behaves essentially like the above function..PPReads the '&#92;0'-terminated string \fIs\fR from the stream and returns a reference to the stream..PPSpace for the string is allocated using \fCnew\fR -- the caller must destroy it with delete[]..SH "QDataStream & QDataStream::readBytes ( char *& s, uint & l )"Reads the buffer \fIs\fR from the stream and returns a reference to the stream..PPThe buffer \fIs\fR is allocated using \fCnew\fR. Destroy it with the \fCdelete[]\fR operator. If the length is zero or \fIs\fR cannot be allocated, \fIs\fR is set to 0..PPThe \fIl\fR parameter will be set to the length of the buffer..PPThe serialization format is a Q_UINT32 length specifier first, then \fIl\fR bytes of data. Note that the data is \fInot\fR encoded..PPSee also readRawBytes() and writeBytes()..SH "QDataStream & QDataStream::readRawBytes ( char * s, uint len )"Reads \fIlen\fR bytes from the stream into \fIs\fR and returns a reference to the stream..PPThe buffer \fIs\fR must be preallocated. The data is \fInot\fR encoded..PPSee also readBytes(), QIODevice::readBlock(), and writeRawBytes()..SH "void QDataStream::setByteOrder ( int bo )"Sets the serialization byte order to \fIbo\fR..PPThe \fIbo\fR parameter can be QDataStream::BigEndian or QDataStream::LittleEndian..PPThe default setting is big endian. We recommend leaving this setting unless you have special requirements..PPSee also byteOrder()..SH "void QDataStream::setDevice ( QIODevice * d )"void QDataStream::setDevice(QIODevice *d ).PPSets the IO device to \fId\fR..PPSee also device() and unsetDevice()..SH "void QDataStream::setPrintableData ( bool enable )"If \fIenable\fR is TRUE, data will be output in a human readable format. If \fIenable\fR is FALSE, data will be output in a binary format..PPIf \fIenable\fR is TRUE, the write functions will generate output that consists of printable characters (7 bit ASCII). This output will typically be a lot larger than the default binary output, and consequently slower to write..PPWe recommend only enabling printable data for debugging purposes..SH "void QDataStream::setVersion ( int v )"Sets the version number of the data serialization format to \fIv\fR..PPYou don't need to set a version if you are using the current version of Qt..PPIn order to accommodate new functionality, the datastream serialization format of some Qt classes has changed in some versions of Qt. If you want to read data that was created by an earlier version of Qt, or write data that can be read by a program that was compiled with an earlier version of Qt, use this function to modify the serialization format of QDataStream..PP<center>.nf.TSl - l. Qt Version QDataStream Version Qt 3.1 5 Qt 3.0 4 Qt 2.1.x and Qt 2.2.x 3 Qt 2.0.x 2 Qt 1.x.TE.fi</center>.PPSee also version()..SH "void QDataStream::unsetDevice ()"Unsets the IO device. This is the same as calling setDevice( 0 )..PPSee also device() and setDevice()..SH "int QDataStream::version () const"Returns the version number of the data serialization format. In Qt 3.1, this number is 5..PPSee also setVersion()..SH "QDataStream & QDataStream::writeBytes ( const char * s, uint len )"Writes the length specifier \fIlen\fR and the buffer \fIs\fR to the stream and returns a reference to the stream..PPThe \fIlen\fR is serialized as a Q_UINT32, followed by \fIlen\fR bytes from \fIs\fR. Note that the data is \fInot\fR encoded..PPSee also writeRawBytes() and readBytes()..SH "QDataStream & QDataStream::writeRawBytes ( const char * s, uint len )"Writes \fIlen\fR bytes from \fIs\fR to the stream and returns a reference to the stream. The data is \fInot\fR encoded..PPSee also writeBytes(), QIODevice::writeBlock(), and readRawBytes()..SH "SEE ALSO".BR http://doc.trolltech.com/qdatastream.html.BR http://www.trolltech.com/faq/tech.html.SH COPYRIGHTCopyright 1992-2001 Trolltech AS, http://www.trolltech.com.  See thelicense file included in the distribution for a complete licensestatement..SH AUTHORGenerated automatically from the source code..SH BUGSIf you find a bug in Qt, please report it as described in.BR http://doc.trolltech.com/bughowto.html .Good bug reports help us to help you. Thank you..PThe definitive Qt documentation is provided in HTML format; it islocated at $QTDIR/doc/html and can be read using Qt Assistant or witha web browser. This man page is provided as a convenience for thoseusers who prefer man pages, although this format is not officiallysupported by Trolltech. .PIf you find errors in this manual page, please report them to.BR qt-bugs@trolltech.com .Please include the name of the manual page (qdatastream.3qt) and the Qtversion (3.1.1).

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -