62 inline void append(QByteDataBuffer &&other)
67 auto otherBufferCount = other.bufferCount();
68 auto otherByteAmount = other.byteAmount();
69 buffers.append(std::move(other.buffers));
70 bufferCompleteSize += otherByteAmount;
72 if (other.firstPos > 0)
73 popFront(buffers[bufferCount() - otherBufferCount], other.firstPos);
125 inline QByteArray read(qint64 amount)
127 amount = qMin(byteAmount(), amount);
128 if constexpr (
sizeof(qsizetype) ==
sizeof(
int)) {
132 if (amount > INT_MAX)
136 byteData.resize(qsizetype(amount));
137 read(byteData.data(), byteData.size());
143 qint64 read(
char* dst, qint64 amount)
145 amount = qMin(amount, byteAmount());
146 qint64 originalAmount = amount;
147 char *writeDst = dst;
150 const QByteArray &first = buffers.first();
151 qint64 firstSize = first.size() - firstPos;
152 if (amount >= firstSize) {
154 bufferCompleteSize -= firstSize;
156 memcpy(writeDst, first.constData() + firstPos, firstSize);
157 writeDst += firstSize;
162 bufferCompleteSize -= amount;
163 memcpy(writeDst, first.constData() + firstPos, amount);
169 return originalAmount;
197 void advanceReadPointer(qint64 distance)
199 qint64 newPos = firstPos + distance;
202 }
else if (
auto size = buffers.first().size(); newPos >= size) {
203 while (newPos >= size) {
204 bufferCompleteSize -= (size - firstPos);
212 size = buffers.front().size();
214 bufferCompleteSize -= newPos;
216 bufferCompleteSize -= newPos - firstPos;