41 #include "private/qringbuffer_p.h"
42 #include "private/qbytearray_p.h"
44 #include <type_traits>
50 static_assert(std::is_nothrow_default_constructible_v<QRingChunk>);
51 static_assert(std::is_nothrow_move_constructible_v<QRingChunk>);
52 static_assert(std::is_nothrow_move_assignable_v<QRingChunk>);
67 chunk =
QByteArray(std::as_const(*this).data(), chunkSize);
69 tailOffset = chunkSize;
74 if (headOffset != 0 || tailOffset != chunk.
size()) {
76 return chunk.
mid(headOffset,
size());
78 if (headOffset != 0) {
79 char *ptr = chunk.
data();
81 tailOffset -= headOffset;
128 if (bufferSize == bytes) {
129 if (
chunk.capacity() <= basicBlockSize && !
chunk.isShared()) {
137 chunk.advance(bytes);
155 if (bufferSize == 0) {
163 if (basicBlockSize == 0 ||
chunk.isShared() || bytes >
chunk.available())
171 return buffers.last().data() + tail;
184 if (bufferSize == 0) {
194 if (basicBlockSize == 0 ||
chunk.isShared() || bytes >
chunk.head()) {
199 buffers.first().advance(-bytes);
219 if (bufferSize == bytes) {
220 if (
chunk.capacity() <= basicBlockSize && !
chunk.isShared()) {
261 if (nextBlockIndex > 0) {
262 const char *ptr =
chunk.data();
268 const char *findPtr =
reinterpret_cast<const char *
>(memchr(ptr,
c,
269 nextBlockIndex -
index));
276 index = nextBlockIndex;
285 while (readSoFar < bytesToRead) {
286 const qint64 bytesToReadFromThisBlock = qMin(bytesToRead - readSoFar,
290 readSoFar += bytesToReadFromThisBlock;
291 free(bytesToReadFromThisBlock);
306 bufferSize -=
buffers.constFirst().size();
307 return buffers.takeFirst().toByteArray();
325 if (
pos < blockLength) {
326 blockLength = qMin(blockLength -
pos,
maxLength - readSoFar);
327 memcpy(
data + readSoFar,
chunk.data() +
pos, blockLength);
328 readSoFar += blockLength;
352 *writePointer = *
data;
364 if (bufferSize != 0 ||
buffers.isEmpty())
368 bufferSize += qba.
size();
378 const auto qbaSize = qba.size();
379 if (bufferSize != 0 ||
buffers.isEmpty())
380 buffers.emplace_back(std::move(qba));
382 buffers.last().assign(std::move(qba));
383 bufferSize += qbaSize;
small capitals from c petite p scientific i
[1]
The QByteArray class provides an array of bytes.
qsizetype size() const noexcept
void reserve(qsizetype size)
void resize(qsizetype size)
QByteArray mid(qsizetype index, qsizetype len=-1) const
Q_CORE_EXPORT void free(qint64 bytes)
Q_CORE_EXPORT QByteArray read()
Q_CORE_EXPORT qint64 peek(char *data, qint64 maxLength, qint64 pos=0) const
Q_CORE_EXPORT qint64 readLine(char *data, qint64 maxLength)
Q_CORE_EXPORT const char * readPointerAtPosition(qint64 pos, qint64 &length) const
Q_CORE_EXPORT void chop(qint64 bytes)
Q_CORE_EXPORT char * reserve(qint64 bytes)
Q_CORE_EXPORT void append(const char *data, qint64 size)
Q_CORE_EXPORT char * reserveFront(qint64 bytes)
qint64 indexOf(char c) const
const char * readPointer() const
Q_CORE_EXPORT void clear()
qint64 nextDataBlockSize() const
void allocate(qsizetype alloc)
Q_CORE_EXPORT void detach()
GeneratorWrapper< std::vector< T > > chunk(size_t size, GeneratorWrapper< T > &&generator)
constexpr Initialization Uninitialized
void *PRIV() memmove(void *d, const void *s, size_t n)
constexpr QT_BEGIN_NAMESPACE qsizetype MaxByteArraySize
typedef QByteArray(EGLAPIENTRYP PFNQGSGETDISPLAYSPROC)()
GLenum GLuint GLenum GLsizei length
GLuint const GLuint * buffers
GLenum GLuint GLintptr GLsizeiptr size
[1]
GLint GLsizei GLsizei GLenum GLenum GLsizei void * data