![]() |
Qt 6.x
The Qt SDK
|
The QPacket class encapsulates an unfragmentable packet of data to be transmitted by QPacketProtocol. More...
#include <qpacket_p.h>
Public Member Functions | |
QPacket (int version) | |
Constructs an empty write-only packet. | |
QPacket (int version, const QByteArray &ba) | |
Constructs a read-only packet. | |
const QByteArray & | data () const |
Returns a reference to the raw packet data. | |
QByteArray | squeezedData () const |
Returns a copy of the raw packet data, with extra reserved space removed. | |
void | clear () |
Clears the packet, discarding any data. | |
![]() | |
QDataStream () | |
Constructs a data stream that has no I/O device. | |
QDataStream (QIODevice *) | |
Constructs a data stream that uses the I/O device d. | |
QDataStream (QByteArray *, OpenMode flags) | |
Constructs a data stream that operates on a byte array, a. | |
QDataStream (const QByteArray &) | |
Constructs a read-only data stream that operates on byte array a. | |
~QDataStream () | |
Destroys the data stream. | |
QIODevice * | device () const |
Returns the I/O device currently set, or \nullptr if no device is currently set. | |
void | setDevice (QIODevice *) |
void QDataStream::setDevice(QIODevice *d) | |
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 . | |
Status | status () const |
Returns the status of the data stream. | |
void | setStatus (Status status) |
Sets the status of the data stream to the status given. | |
void | resetStatus () |
Resets the status of the data stream. | |
FloatingPointPrecision | floatingPointPrecision () const |
Returns the floating point precision of the data stream. | |
void | setFloatingPointPrecision (FloatingPointPrecision precision) |
Sets the floating point precision of the data stream to precision. | |
ByteOrder | byteOrder () const |
Returns the current byte order setting – either BigEndian or LittleEndian. | |
void | setByteOrder (ByteOrder) |
Sets the serialization byte order to bo. | |
int | version () const |
Returns the version number of the data serialization format. | |
void | setVersion (int) |
Sets the version number of the data serialization format to v, a value of the \l Version enum. | |
QDataStream & | operator>> (char &i) |
QDataStream & | operator>> (qint8 &i) |
Reads a signed byte from the stream into i, and returns a reference to the stream. | |
QDataStream & | operator>> (quint8 &i) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Reads an unsigned byte from the stream into i, and returns a reference to the stream. | |
QDataStream & | operator>> (qint16 &i) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Reads a signed 16-bit integer from the stream into i, and returns a reference to the stream. | |
QDataStream & | operator>> (quint16 &i) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Reads an unsigned 16-bit integer from the stream into i, and returns a reference to the stream. | |
QDataStream & | operator>> (qint32 &i) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Reads a signed 32-bit integer from the stream into i, and returns a reference to the stream. | |
QDataStream & | operator>> (quint32 &i) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Reads an unsigned 32-bit integer from the stream into i, and returns a reference to the stream. | |
QDataStream & | operator>> (qint64 &i) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Reads a signed 64-bit integer from the stream into i, and returns a reference to the stream. | |
QDataStream & | operator>> (quint64 &i) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Reads an unsigned 64-bit integer from the stream, into i, and returns a reference to the stream. | |
QDataStream & | operator>> (std::nullptr_t &ptr) |
QDataStream & | operator>> (bool &i) |
Reads a boolean value from the stream into i. | |
QDataStream & | operator>> (float &f) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Reads a floating point number from the stream into f, using the standard IEEE 754 format. | |
QDataStream & | operator>> (double &f) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Reads a floating point number from the stream into f, using the standard IEEE 754 format. | |
QDataStream & | operator>> (char *&str) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Reads the '\0'-terminated string s from the stream and returns a reference to the stream. | |
QDataStream & | operator>> (char16_t &c) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |
QDataStream & | operator>> (char32_t &c) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |
QDataStream & | operator<< (char i) |
QDataStream & | operator<< (qint8 i) |
Writes a signed byte, i, to the stream and returns a reference to the stream. | |
QDataStream & | operator<< (quint8 i) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Writes an unsigned byte, i, to the stream and returns a reference to the stream. | |
QDataStream & | operator<< (qint16 i) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Writes a signed 16-bit integer, i, to the stream and returns a reference to the stream. | |
QDataStream & | operator<< (quint16 i) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Writes an unsigned 16-bit integer, i, to the stream and returns a reference to the stream. | |
QDataStream & | operator<< (qint32 i) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Writes a signed 32-bit integer, i, to the stream and returns a reference to the stream. | |
QDataStream & | operator<< (quint32 i) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Writes an unsigned integer, i, to the stream as a 32-bit unsigned integer (quint32). | |
QDataStream & | operator<< (qint64 i) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Writes a signed 64-bit integer, i, to the stream and returns a reference to the stream. | |
QDataStream & | operator<< (quint64 i) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Writes an unsigned 64-bit integer, i, to the stream and returns a reference to the stream. | |
QDataStream & | operator<< (std::nullptr_t) |
QDataStream & | operator<< (bool i) |
Writes a boolean value, i, to the stream. | |
QDataStream & | operator<< (float f) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Writes a floating point number, f, to the stream using the standard IEEE 754 format. | |
QDataStream & | operator<< (double f) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Writes a floating point number, f, to the stream using the standard IEEE 754 format. | |
QDataStream & | operator<< (const char *str) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Writes the '\0'-terminated string s to the stream and returns a reference to the stream. | |
QDataStream & | operator<< (char16_t c) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |
QDataStream & | operator<< (char32_t c) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |
QDataStream & | readBytes (char *&, uint &len) |
Reads the buffer s from the stream and returns a reference to the stream. | |
int | readRawData (char *, int len) |
Reads at most len bytes from the stream into s and returns the number of bytes read. | |
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. | |
int | writeRawData (const char *, int len) |
Writes len bytes from s to the stream. | |
int | skipRawData (int len) |
void | startTransaction () |
bool | commitTransaction () |
void | rollbackTransaction () |
void | abortTransaction () |
bool | isDeviceTransactionStarted () const |
Additional Inherited Members | |
![]() | |
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 , Qt_4_9 = Qt_4_8 , Qt_5_0 = 13 , Qt_5_1 = 14 , Qt_5_2 = 15 , Qt_5_3 = Qt_5_2 , Qt_5_4 = 16 , Qt_5_5 = Qt_5_4 , Qt_5_6 = 17 , Qt_5_7 = Qt_5_6 , Qt_5_8 = Qt_5_7 , Qt_5_9 = Qt_5_8 , Qt_5_10 = Qt_5_9 , Qt_5_11 = Qt_5_10 , Qt_5_12 = 18 , Qt_5_13 = 19 , Qt_5_14 = Qt_5_13 , Qt_5_15 = Qt_5_14 , Qt_6_0 = 20 , Qt_6_1 = Qt_6_0 , Qt_6_2 = Qt_6_0 , Qt_6_3 = Qt_6_0 , Qt_6_4 = Qt_6_0 , Qt_6_5 = Qt_6_0 , Qt_6_6 = 21 , Qt_6_7 = Qt_6_6 , Qt_DefaultCompiledVersion = Qt_6_7 } |
This enum provides symbolic synonyms for the data serialization format version numbers. More... | |
enum | ByteOrder { BigEndian = QSysInfo::BigEndian , LittleEndian = QSysInfo::LittleEndian } |
The byte order 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 | FloatingPointPrecision { SinglePrecision , DoublePrecision } |
The precision of floating point numbers used for reading/writing the data. More... | |
![]() | |
enum | OpenModeFlag { NotOpen = 0x0000 , ReadOnly = 0x0001 , WriteOnly = 0x0002 , ReadWrite = ReadOnly | WriteOnly , Append = 0x0004 , Truncate = 0x0008 , Text = 0x0010 , Unbuffered = 0x0020 , NewOnly = 0x0040 , ExistingOnly = 0x0080 } |
This enum is used with QIODevice::open() to describe the mode in which a device is opened. More... | |
![]() | |
~QIODeviceBase ()=default | |
![]() | |
operator<< (QDataStream &ds, qfloat16 f) | |
operator>> (QDataStream &ds, qfloat16 &f) | |
template< class T1, class T2 > QDataStream & | operator>> (QDataStream &in, std::pair< T1, T2 > &pair) |
template< class T1, class T2 > QDataStream & | operator<< (QDataStream &out, const std::pair< T1, T2 > &pair) |
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 and the same data stream version, the data within this packet will be delivered unfragmented at the other end, ready for extraction.
Only packets constructed from raw byte arrays may be read from. Empty QPacket instances are for transmission only and are considered "write only". Attempting to read data from them will result in undefined behavior.
Definition at line 23 of file qpacket_p.h.
QPacket::QPacket | ( | int | version | ) |
Constructs an empty write-only packet.
Definition at line 56 of file qpacket.cpp.
References QDataStream::setDevice(), QDataStream::setVersion(), QDataStream::version(), and QIODeviceBase::WriteOnly.
|
explicit |
Constructs a read-only packet.
Definition at line 66 of file qpacket.cpp.
References QIODeviceBase::ReadOnly, QDataStream::setDevice(), QDataStream::setVersion(), and QDataStream::version().
void QPacket::clear | ( | ) |
Clears the packet, discarding any data.
Definition at line 96 of file qpacket.cpp.
References QByteArray::reserve().
Referenced by qQmlProfilerDataToByteArrays(), QQuick3DProfilerDataToByteArrays(), and qQuickProfilerDataToByteArrays().
const QByteArray & QPacket::data | ( | ) | const |
Returns a reference to the raw packet data.
Definition at line 77 of file qpacket.cpp.
References QByteArray::data().
Referenced by QQmlEngineDebugClient::addWatch(), QQmlEngineDebugClient::addWatch(), QQmlEngineDebugClient::addWatch(), QQmlDebugConnectionPrivate::advertisePlugins(), QQmlInspectorClient::createObject(), QQmlInspectorClient::destroyObject(), encodeFrame(), QQmlPreviewServiceImpl::forwardError(), QQmlPreviewServiceImpl::forwardFps(), QQmlPreviewServiceImpl::forwardRequest(), QQmlInspectorClient::moveObject(), QQmlEngineDebugServiceImpl::objectCreated(), QV4DebugClientPrivate::packMessage(), QQmlEngineDebugClient::queryAvailableEngines(), QQmlEngineDebugClient::queryExpressionResult(), QQmlEngineDebugClient::queryExpressionResultBC(), QQmlEngineDebugClient::queryObject(), QQmlEngineDebugClient::queryObjectRecursive(), QQmlEngineDebugClient::queryObjectsForLocation(), QQmlEngineDebugClient::queryObjectsForLocationRecursive(), QQmlEngineDebugClient::queryRootContexts(), QQmlEngineDebugClient::removeWatch(), QQmlEngineDebugClient::resetBindingForObject(), QQmlInspectorClient::select(), QQmlPreviewClient::sendDirectory(), QQmlPreviewClient::sendError(), QQmlPreviewClient::sendFile(), QQmlDebugTranslationServicePrivate::sendLanguageChanged(), QQmlDebugConnection::sendMessage(), QV4DebugServiceImpl::sendSomethingToSomebody(), QQmlDebugTranslationServicePrivate::sendStateChanged(), QQmlDebugTranslationServicePrivate::sendStateList(), QQmlDebugTranslationServicePrivate::sendTranslatableTextOccurrences(), QQmlDebugTranslationServicePrivate::sendTranslationIssues(), QQmlInspectorClient::setAnimationSpeed(), QQmlEngineDebugClient::setBindingForObject(), QQmlInspectorClient::setInspectToolEnabled(), QQmlEngineDebugClient::setMethodBody(), QQmlInspectorClient::setShowAppOnTop(), QQmlPreviewClient::triggerLoad(), QQmlPreviewClient::triggerRerun(), and QQmlPreviewClient::triggerZoom().
QByteArray QPacket::squeezedData | ( | ) | const |
Returns a copy of the raw packet data, with extra reserved space removed.
Mind that this triggers a deep copy. Use it if you anticipate the data to be detached soon anyway.
Definition at line 86 of file qpacket.cpp.
References ret.
Referenced by qQmlProfilerDataToByteArrays(), QQuick3DProfilerDataToByteArrays(), and qQuickProfilerDataToByteArrays().