42 #ifndef QRINGBUFFER_P_H 43 #define QRINGBUFFER_P_H 56 #include <QtCore/qbytearray.h> 57 #include <QtCore/qlist.h> 93 if (pos -
head < nextDataBlockSizeValue) {
94 length = nextDataBlockSizeValue - pos;
105 pos -= nextDataBlockSizeValue;
115 return buffers[i].constData() + pos;
130 if (bytes < nextBlockSize) {
137 bytes -= nextBlockSize;
236 return int(
uchar(c));
281 for (
int j = start; j <
end; ++j) {
292 int remain =
qMin(
size(), maxLength);
293 for (
int i = 0; remain && i <
buffers.
size(); ++i) {
301 if (remain < end - start) {
302 end = start + remain;
305 remain -= end - start;
308 for (
int j = start; j <
end; ++j) {
318 int bytesToRead =
qMin(
size(), maxLength);
320 while (readSoFar < bytesToRead) {
324 memcpy(data + readSoFar, ptr, bytesToReadFromThisBlock);
325 readSoFar += bytesToReadFromThisBlock;
326 free(bytesToReadFromThisBlock);
391 int bytesToRead =
qMin(
size(), maxLength);
397 for (
int i = 0; readSoFar < bytesToRead && i <
buffers.
size(); ++i) {
404 const int len =
qMin(ret.
size()-readSoFar, end-start);
413 return read(0, length);
419 return read(data, maxLength);
424 while (readSoFar < index + 1 && readSoFar < maxLength - 1) {
426 bytesToRead =
qMin(bytesToRead, (maxLength - 1) - readSoFar);
427 memcpy(data + readSoFar,
readPointer(), bytesToRead);
428 readSoFar += bytesToRead;
433 data[readSoFar] =
'\0';
451 #endif // QRINGBUFFER_P_H
Q_DECL_CONSTEXPR const T & qMin(const T &a, const T &b)
#define QT_END_NAMESPACE
This macro expands to.
char * data()
Returns a pointer to the data stored in the byte array.
const char * readPointer() const
int indexOf(char c, int maxLength) const
void append(const QByteArray &qba)
int nextDataBlockSize() const
The QByteArray class provides an array of bytes.
QByteArray peek(int maxLength) const
iterator begin()
Returns an STL-style iterator pointing to the first item in the list.
int count(const T &t) const
Returns the number of occurrences of value in the list.
Q_DECL_CONSTEXPR const T & qMax(const T &a, const T &b)
bool isEmpty() const
Returns true if the list contains no items; otherwise returns false.
char * reserve(int bytes)
#define QT_BEGIN_NAMESPACE
This macro expands to.
T takeFirst()
Removes the first item in the list and returns it.
iterator end()
Returns an STL-style iterator pointing to the imaginary item after the last item in the list...
void prepend(const T &t)
Inserts value at the beginning of the list.
const T & at(int i) const
Returns the item at index position i in the list.
static const char * data(const QByteArray &arr)
void removeFirst()
Removes the first item in the list.
const T * ptr(const T &t)
int length() const
Same as size().
T & first()
Returns a reference to the first item in the list.
const char * constData() const
Returns a pointer to the data stored in the byte array.
iterator erase(iterator pos)
Removes the item associated with the iterator pos from the list, and returns an iterator to the next ...
int readLine(char *data, int maxLength)
const char * readPointerAtPosition(qint64 pos, qint64 &length) const
QByteArray read(int maxLength)
int length() const
This function is identical to count().
void resize(int size)
Sets the size of the byte array to size bytes.
int size() const
Returns the number of items in the list.
int size() const
Returns the number of bytes in this byte array.
int read(char *data, int maxLength)
int indexOf(char c) const
QList< QByteArray > buffers
static const KeyPair *const end
QRingBuffer(int growth=4096)
void removeAt(int i)
Removes the item at index position i.