Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
qpacket.cpp
Go to the documentation of this file.
1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#include "qpacket_p.h"
5
7
56QPacket::QPacket(int version)
57{
59 setDevice(&buf);
61}
62
66QPacket::QPacket(int version, const QByteArray &data)
67{
68 buf.setData(data);
70 setDevice(&buf);
72}
73
78{
79 return buf.data();
80}
81
87{
89 ret.squeeze();
90 return ret;
91}
92
97{
98 buf.reset();
99 QByteArray &buffer = buf.buffer();
100 // Keep the old size to prevent unnecessary allocations
101 buffer.reserve(buffer.capacity());
102 buffer.truncate(0);
103}
104
\inmodule QtCore
Definition qbytearray.h:57
char * data()
\macro QT_NO_CAST_FROM_BYTEARRAY
Definition qbytearray.h:611
void reserve(qsizetype size)
Attempts to allocate memory for at least size bytes.
Definition qbytearray.h:634
void setDevice(QIODevice *)
void QDataStream::setDevice(QIODevice *d)
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.
QByteArray squeezedData() const
Returns a copy of the raw packet data, with extra reserved space removed.
Definition qpacket.cpp:86
QPacket(int version)
Constructs an empty write-only packet.
Definition qpacket.cpp:56
void clear()
Clears the packet, discarding any data.
Definition qpacket.cpp:96
const QByteArray & data() const
Returns a reference to the raw packet data.
Definition qpacket.cpp:77
Combined button and popup list for selecting options.
return ret
GLint GLsizei GLsizei GLenum GLenum GLsizei void * data
GLenum GLuint buffer
GLenum GLuint GLenum GLsizei const GLchar * buf