qdatastream.3qt

来自「tmark1.11:用于生成QT/EMBEDDED应用工程的Markfile文件」· 3QT 代码 · 共 345 行

3QT
345
字号
.TH QDataStream 3qt "6 July 1999" "Troll Tech AS" \" -*- nroff -*-.\" Copyright 1992-1999 Troll Tech AS.  All rights reserved.  See the.\" license file included in the distribution for a complete license.\" statement..\".ad l.nh.SH NAMEQDataStream \- Basic functions for serialization of binary data to a QIODevice.SH SYNOPSIS.br.PP\fC#include <qdatastream.h>\fR.PP.SS "Public Members".in +1c.ti -1c.BI "\fBQDataStream\fR ()".br.ti -1c.BI "\fBQDataStream\fR ( QIODevice * )".br.ti -1c.BI "\fBQDataStream\fR ( QByteArray, int mode )".br.ti -1c.BI "virtual \fB~QDataStream\fR ()".br.ti -1c.BI "QIODevice* \fBdevice\fR () const".br.ti -1c.BI "void \fBsetDevice\fR ( QIODevice * )".br.ti -1c.BI "void \fBunsetDevice\fR ()".br.ti -1c.BI "bool \fBatEnd\fR () const".br.ti -1c.BI "bool \fBeof\fR () const".br.ti -1c.BI "enum \fBByteOrder\fR { BigEndian, LittleEndian }".br.ti -1c.BI "int \fBbyteOrder\fR () const".br.ti -1c.BI "void \fBsetByteOrder\fR ( int )".br.ti -1c.BI "bool \fBisPrintableData\fR () const".br.ti -1c.BI "void \fBsetPrintableData\fR ( bool )".br.ti -1c.BI "int \fBversion\fR () const".br.ti -1c.BI "void \fBsetVersion\fR ( int )".br.ti -1c.BI "QDataStream& \fBoperator>>\fR ( Q_INT8 & i )".br.ti -1c.BI "QDataStream& \fBoperator>>\fR ( Q_UINT8 & i )".br.ti -1c.BI "QDataStream& \fBoperator>>\fR ( Q_INT16 & i )".br.ti -1c.BI "QDataStream& \fBoperator>>\fR ( Q_UINT16 & i )".br.ti -1c.BI "QDataStream& \fBoperator>>\fR ( Q_INT32 & i )".br.ti -1c.BI "QDataStream& \fBoperator>>\fR ( Q_UINT32 & i )".br.ti -1c.BI "QDataStream& \fBoperator>>\fR ( float & f )".br.ti -1c.BI "QDataStream& \fBoperator>>\fR ( double & f )".br.ti -1c.BI "QDataStream& \fBoperator>>\fR ( char *& str )".br.ti -1c.BI "QDataStream& \fBoperator<<\fR ( Q_INT8 i )".br.ti -1c.BI "QDataStream& \fBoperator<<\fR ( Q_UINT8 i )".br.ti -1c.BI "QDataStream& \fBoperator<<\fR ( Q_INT16 i )".br.ti -1c.BI "QDataStream& \fBoperator<<\fR ( Q_UINT16 i )".br.ti -1c.BI "QDataStream& \fBoperator<<\fR ( Q_INT32 i )".br.ti -1c.BI "QDataStream& \fBoperator<<\fR ( Q_UINT32 i )".br.ti -1c.BI "QDataStream& \fBoperator<<\fR ( float f )".br.ti -1c.BI "QDataStream& \fBoperator<<\fR ( double f )".br.ti -1c.BI "QDataStream& \fBoperator<<\fR ( const char * str )".br.ti -1c.BI "QDataStream& \fBreadBytes\fR ( char *&, uint & len )".br.ti -1c.BI "QDataStream& \fBreadRawBytes\fR ( char *, uint len )".br.ti -1c.BI "QDataStream& \fBwriteBytes\fR ( const char *, uint len )".br.ti -1c.BI "QDataStream& \fBwriteRawBytes\fR ( const char *, uint len )".br.in -1c.SH DESCRIPTIONThe QDataStream class provides basic functions for serialization of binary data to a QIODevice..PPA data stream is a binary stream of encoded information which is 100% independent of the host computer operation system, CPU or byte order. A stream that is written by a PC under DOS/Windows can easily be read by a Sun SPARC running Solaris..PPThe QDataStream class implements serialization of primitive types, like \fCchar, short, int, char*\fR etc. Serialization of more complex data is accomplished by breaking up the data into primitive units..PPThe programmer 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. We therefore recommend keeping this setting unless you have special needs or requirements..PPA data stream cooperates closely with a QIODevice. A QIODevice represents an input/output medium one can read data from and write data to. The QFile class is an example of an IO device..PPExample (write data to a stream):.PP.nf.br    QFile f( "file.dta" );.br    f.open( IO_WriteOnly );                     // open file for writing.br    QDataStream s( &f );                        // serialize using f.br    s << "the answer is";                       // serialize string.br    s << (Q_INT32)42;                           // serialize integer.br    f.close();                                  // done.fi.PPExample (read data from a stream):.PP.nf.br    QFile f( "file.dta" );.br    f.open( IO_ReadOnly );                      // open file for reading.br    QDataStream s( &f );                        // serialize using f.br    char   *str;.br    Q_INT32 a;.br    s >> str >> a;                              // "the answer is" and 42.br    f.close();                                  // done.br    delete str;                                 // delete string.fi.PPIn the last example, if you read into a QString instead of a \fCchar*\fR you do not have to delete it..PPSee also: QTextStream..SH MEMBER FUNCTION DOCUMENTATION.SH "QDataStream::QDataStream ()"Constructs a data stream that has no IO device..SH "QDataStream::QDataStream ( QIODevice * d )"Constructs a data stream that uses the IO device \fId.\fR.SH "QDataStream::QDataStream ( QByteArray a, int mode )"Constructs a data stream that operates on a byte array through an internal QBuffer device..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 s( a, IO_ReadOnly );            // open on a's data.br    s >> <something>;                           // read raw bindata.br    a.resetRawData( bindata, sizeof(bindata) ); // finished.fi.PPThe QArray::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 constructor..SH "bool QDataStream::atEnd () const"Returns 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 "int QDataStream::byteOrder () const"Returns the current byte order setting..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 programs 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..PPSee also: setPrintableData()..SH "QDataStream & QDataStream::operator<< ( Q_INT16 i )"Writes a signed 16-bit integer to the stream and returns a reference to the stream..SH "QDataStream & QDataStream::operator<< ( Q_INT32 i )"Writes a signed 32-bit integer to the stream and returns a reference to the stream..SH "QDataStream & QDataStream::operator<< ( Q_INT8 i )"Writes a signed byte to the stream..SH "QDataStream & QDataStream::operator<< ( Q_UINT16 i )"Writes an unsigned 16-bit integer to the stream and returns a reference to the stream..SH "QDataStream & QDataStream::operator<< ( Q_UINT32 i )"Writes an unsigned 32-bit integer to the stream and returns a reference to the stream..SH "QDataStream & QDataStream::operator<< ( Q_UINT8 i )"Writes an unsigned byte to the stream and returns a reference to the stream..SH "QDataStream & QDataStream::operator<< ( const char * s )"Writes the '\\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<< ( double f )"Writes a 64-bit floating point number to the stream using the standard IEEE754 format. Returns a reference to the stream..SH "QDataStream & QDataStream::operator<< ( float f )"Writes a 32-bit floating point number to the stream using the standard IEEE754 format. Returns a reference to the stream..SH "QDataStream & QDataStream::operator>> ( Q_INT16 & i )"Reads a signed 16-bit integer from the stream and returns a reference to the stream..SH "QDataStream & QDataStream::operator>> ( Q_INT32 & i )"Reads a signed 32-bit integer from the stream and returns a reference to the stream..SH "QDataStream & QDataStream::operator>> ( Q_INT8 & i )"Reads a signed byte from the stream..SH "QDataStream & QDataStream::operator>> ( Q_UINT16 & i )"Reads an unsigned 16-bit integer from the stream and returns a reference to the stream..SH "QDataStream & QDataStream::operator>> ( Q_UINT32 & i )"Reads an unsigned 32-bit integer from the stream and returns a reference to the stream..SH "QDataStream & QDataStream::operator>> ( Q_UINT8 & i )"Reads an unsigned byte from the stream and returns a reference to the stream..SH "QDataStream & QDataStream::operator>> ( char *& s )"Reads the '\\0'-terminated string \fIs\fR from the stream and returns a reference to the stream..PPThe string is read using readBytes(), which allocates space using \fCnew.\fR.SH "QDataStream & QDataStream::operator>> ( double & f )"Reads a 64-bit floating point number from the stream using the standard IEEE754 format. Returns a reference to the stream..SH "QDataStream & QDataStream::operator>> ( float & f )"Reads a 32-bit floating point number from the stream using the standard IEEE754 format. Returns a reference to the stream..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 an Q_UINT32 length specifier first, then the data (\fIlength\fR bytes)..PPSee also: readRawBytes() and writeBytes()..SH "QDataStream & QDataStream::readRawBytes ( char * s, uint len )"Reads \fIlen\fR bytes from the stream into \fIe\fR s and returns a reference to the stream..PPThe buffer \fIs\fR must be preallocated..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 \fCQDataStream::BigEndian\fR or \fCQDataStream::LittleEndian.\fR.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 ) Sets the IO device to \fId.\fR.PPSee also: device() and unsetDevice()..SH "void QDataStream::setPrintableData ( bool enable )"Sets or clears the printable data flag..PPIf this flag is set, the write functions will generate output that consists of printable characters (7 bit ASCII)..PPWe recommend enabling printable data only for debugging purposes (it is slower and creates bigger output)..SH "void QDataStream::setVersion ( int v )"Sets the version number of the data serialization format..PPIn Qt 2.0, the datastream serialization format of many Qt classes was changed. In order to read data that was created with the QDatastream of Qt 1.x, call this function with the version number \\v set to 1..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 2.0, this number is 2..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 an Q_UINT32, followed by \fIlen\fR bytes from \fIs.\fR.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..PPSee also:  writeBytes(), QIODevice::writeBlock() and readRawBytes()..SH "SEE ALSO".BR http://www.troll.no/qt/qdatastream.html.SH COPYRIGHTCopyright 1992-1999 Troll Tech AS.  See the license file included inthe distribution for a complete license statement..SH AUTHORGenerated automatically from the source code.

⌨️ 快捷键说明

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