Qt 4.8
|
The QPacket class encapsulates an unfragmentable packet of data to be transmitted by QPacketProtocol. More...
#include <qpacketprotocol_p.h>
Public Functions | |
void | clear () |
Clears data in the packet. More... | |
QByteArray | data () const |
Returns raw packet data. More... | |
bool | isEmpty () const |
Returns true if this packet is empty - that is, contains no data. More... | |
QPacket () | |
Constructs an empty write-only packet. More... | |
QPacket (const QPacket &) | |
Creates a copy of other. More... | |
virtual | ~QPacket () |
Destroys the QPacket instance. More... | |
Public Functions inherited from QDataStream | |
bool | atEnd () const |
Returns true if the I/O device has reached the end position (end of the stream or file) or if there is no I/O device set; otherwise returns false. More... | |
ByteOrder | byteOrder () const |
Returns the current byte order setting – either BigEndian or LittleEndian. More... | |
QIODevice * | device () const |
Returns the I/O device currently set, or 0 if no device is currently set. More... | |
FloatingPointPrecision | floatingPointPrecision () const |
Returns the floating point precision of the data stream. More... | |
QDataStream & | operator<< (qint8 i) |
Writes a signed byte, i, to the stream and returns a reference to the stream. More... | |
QDataStream & | operator<< (quint8 i) |
Writes an unsigned byte, i, to the stream and returns a reference to the stream. More... | |
QDataStream & | operator<< (qint16 i) |
Writes a signed 16-bit integer, i, to the stream and returns a reference to the stream. More... | |
QDataStream & | operator<< (quint16 i) |
Writes an unsigned 16-bit integer, i, to the stream and returns a reference to the stream. More... | |
QDataStream & | operator<< (qint32 i) |
Writes a signed 32-bit integer, i, to the stream and returns a reference to the stream. More... | |
QDataStream & | operator<< (quint32 i) |
Writes an unsigned integer, i, to the stream as a 32-bit unsigned integer (quint32). More... | |
QDataStream & | operator<< (qint64 i) |
Writes a signed 64-bit integer, i, to the stream and returns a reference to the stream. More... | |
QDataStream & | operator<< (quint64 i) |
Writes an unsigned 64-bit integer, i, to the stream and returns a reference to the stream. More... | |
QDataStream & | operator<< (bool i) |
Writes a boolean value, i, to the stream. More... | |
QDataStream & | operator<< (float f) |
Writes a floating point number, f, to the stream using the standard IEEE 754 format. More... | |
QDataStream & | operator<< (double f) |
Writes a floating point number, f, to the stream using the standard IEEE 754 format. More... | |
QDataStream & | operator<< (const char *str) |
Writes the '\0'-terminated string s to the stream and returns a reference to the stream. More... | |
QDataStream & | operator>> (qint8 &i) |
Reads a signed byte from the stream into i, and returns a reference to the stream. More... | |
QDataStream & | operator>> (quint8 &i) |
Reads an unsigned byte from the stream into i, and returns a reference to the stream. More... | |
QDataStream & | operator>> (qint16 &i) |
Reads a signed 16-bit integer from the stream into i, and returns a reference to the stream. More... | |
QDataStream & | operator>> (quint16 &i) |
Reads an unsigned 16-bit integer from the stream into i, and returns a reference to the stream. More... | |
QDataStream & | operator>> (qint32 &i) |
Reads a signed 32-bit integer from the stream into i, and returns a reference to the stream. More... | |
QDataStream & | operator>> (quint32 &i) |
Reads an unsigned 32-bit integer from the stream into i, and returns a reference to the stream. More... | |
QDataStream & | operator>> (qint64 &i) |
Reads a signed 64-bit integer from the stream into i, and returns a reference to the stream. More... | |
QDataStream & | operator>> (quint64 &i) |
Reads an unsigned 64-bit integer from the stream, into i, and returns a reference to the stream. More... | |
QDataStream & | operator>> (bool &i) |
Reads a boolean value from the stream into i. More... | |
QDataStream & | operator>> (float &f) |
Reads a floating point number from the stream into f, using the standard IEEE 754 format. More... | |
QDataStream & | operator>> (double &f) |
Reads a floating point number from the stream into f, using the standard IEEE 754 format. More... | |
QDataStream & | operator>> (char *&str) |
Reads the '\0'-terminated string s from the stream and returns a reference to the stream. More... | |
QDataStream () | |
Constructs a data stream that has no I/O device. More... | |
QDataStream (QIODevice *) | |
Constructs a data stream that uses the I/O device d. More... | |
QDataStream (QByteArray *, QIODevice::OpenMode flags) | |
Constructs a data stream that operates on a byte array, a. More... | |
QDataStream (const QByteArray &) | |
Constructs a read-only data stream that operates on byte array a. More... | |
QDataStream & | readBytes (char *&, uint &len) |
Reads the buffer s from the stream and returns a reference to the stream. More... | |
int | readRawData (char *, int len) |
Reads at most len bytes from the stream into s and returns the number of bytes read. More... | |
void | resetStatus () |
Resets the status of the data stream. More... | |
void | setByteOrder (ByteOrder) |
Sets the serialization byte order to bo. More... | |
void | setDevice (QIODevice *) |
void QDataStream::setDevice(QIODevice *d) More... | |
void | setFloatingPointPrecision (FloatingPointPrecision precision) |
Sets the floating point precision of the data stream to precision. More... | |
void | setStatus (Status status) |
Sets the status of the data stream to the status given. More... | |
void | setVersion (int) |
Sets the version number of the data serialization format to v. More... | |
int | skipRawData (int len) |
Skips len bytes from the device. More... | |
Status | status () const |
Returns the status of the data stream. More... | |
void | unsetDevice () |
Unsets the I/O device. More... | |
int | version () const |
Returns the version number of the data serialization format. More... | |
QDataStream & | writeBytes (const char *, uint len) |
Writes the length specifier len and the buffer s to the stream and returns a reference to the stream. More... | |
int | writeRawData (const char *, int len) |
Writes len bytes from s to the stream. More... | |
virtual | ~QDataStream () |
Destroys the data stream. More... | |
Protected Functions | |
QPacket (const QByteArray &ba) | |
Protected Variables | |
QByteArray | b |
QBuffer * | buf |
Friends | |
class | QPacketProtocol |
Additional Inherited Members | |
Public Types inherited from QDataStream | |
enum | ByteOrder { BigEndian = QSysInfo::BigEndian, LittleEndian = QSysInfo::LittleEndian } |
The byte order used for reading/writing the data. More... | |
enum | FloatingPointPrecision { SinglePrecision, DoublePrecision } |
The precision of floating point numbers used for reading/writing the data. More... | |
enum | Status { Ok, ReadPastEnd, ReadCorruptData, WriteFailed } |
This enum describes the current status of the data stream. More... | |
enum | Version { Qt_1_0 = 1, Qt_2_0 = 2, Qt_2_1 = 3, Qt_3_0 = 4, Qt_3_1 = 5, Qt_3_3 = 6, Qt_4_0 = 7, Qt_4_1 = Qt_4_0, Qt_4_2 = 8, Qt_4_3 = 9, Qt_4_4 = 10, Qt_4_5 = 11, Qt_4_6 = 12, Qt_4_7 = Qt_4_6, Qt_4_8 = Qt_4_7 } |
This enum provides symbolic synonyms for the data serialization format version numbers. More... | |
The QPacket class encapsulates an unfragmentable packet of data to be transmitted by QPacketProtocol.
The QPacket class works together with QPacketProtocol to make it simple to send arbitrary sized data "packets" across fragmented transports such as TCP and UDP.
QPacket provides a QDataStream interface to an unfragmentable packet. Applications should construct a QPacket, propagate it with data and then transmit it over a QPacketProtocol instance. For example:
As long as both ends of the connection are using the QPacketProtocol class, the data within this packet will be delivered unfragmented at the other end, ready for extraction.
Only packets returned from QPacketProtocol::read() may be read from. QPacket instances constructed by directly by applications are for transmission only and are considered "write only". Attempting to read data from them will result in undefined behavior.
Definition at line 94 of file qpacketprotocol_p.h.
QPacket::QPacket | ( | ) |
Constructs an empty write-only packet.
Definition at line 472 of file qpacketprotocol.cpp.
QPacket::QPacket | ( | const QPacket & | other | ) |
Creates a copy of other.
The initial stream positions are shared, but the two packets are otherwise independent.
Definition at line 496 of file qpacketprotocol.cpp.
|
virtual |
|
protected |
Definition at line 507 of file qpacketprotocol.cpp.
void QPacket::clear | ( | ) |
Clears data in the packet.
This is useful for reusing one writable packet. For example
Definition at line 547 of file qpacketprotocol.cpp.
QByteArray QPacket::data | ( | ) | const |
Returns raw packet data.
Definition at line 526 of file qpacketprotocol.cpp.
Referenced by QmlOstPlugin::readyRead(), QTcpServerConnection::readyRead(), and QTcpServerConnection::waitForMessage().
bool QPacket::isEmpty | ( | ) | const |
Returns true if this packet is empty - that is, contains no data.
Definition at line 518 of file qpacketprotocol.cpp.
|
friend |
Definition at line 106 of file qpacketprotocol_p.h.
|
protected |
Definition at line 108 of file qpacketprotocol_p.h.
Referenced by clear(), data(), isEmpty(), QPacket(), QPacketProtocol::send(), and QPacketAutoSend::~QPacketAutoSend().
|
protected |
Definition at line 109 of file qpacketprotocol_p.h.
Referenced by clear(), QPacket(), and ~QPacket().