5#ifndef QNONCONTIGUOUSBYTEDEVICE_P_H
6#define QNONCONTIGUOUSBYTEDEVICE_P_H
19#include <QtCore/qobject.h>
20#include <QtCore/qbytearray.h>
21#include <QtCore/qbuffer.h>
22#include <QtCore/qiodevice.h>
23#include "private/qringbuffer_p.h"
33 virtual const char *readPointer(qint64 maximumLength, qint64 &len) = 0;
34 virtual bool advanceReadPointer(qint64 amount) = 0;
35 virtual bool atEnd()
const = 0;
36 virtual qint64 pos()
const {
return -1; }
37 virtual bool reset() = 0;
38 virtual qint64 size()
const = 0;
40 virtual ~QNonContiguousByteDevice();
43 QNonContiguousByteDevice();
47 void readProgress(qint64 current, qint64 total);
53 static QNonContiguousByteDevice *create(QIODevice *device);
54 static std::shared_ptr<QNonContiguousByteDevice> createShared(QIODevice *device);
56 static QNonContiguousByteDevice *create(
const QByteArray &byteArray);
57 static std::shared_ptr<QNonContiguousByteDevice> createShared(
const QByteArray &byteArray);
59 static QNonContiguousByteDevice *create(std::shared_ptr<QRingBuffer> ringBuffer);
60 static std::shared_ptr<QNonContiguousByteDevice> createShared(std::shared_ptr<QRingBuffer> ringBuffer);
62 static QIODevice *wrap(QNonContiguousByteDevice *byteDevice);
75 const char *
readPointer(qint64 maximumLength, qint64 &len)
override;
94 const char *
readPointer(qint64 maximumLength, qint64 &len)
override;
112 const char *
readPointer(qint64 maximumLength, qint64 &len)
override;
~QByteDeviceWrappingIoDevice()
QNonContiguousByteDevice * byteDevice
qint64 readData(char *data, qint64 maxSize) override
Reads up to maxSize bytes from the device into data, and returns the number of bytes read or -1 if an...
qint64 size() const override
For open random-access devices, this function returns the size of the device.
bool isSequential() const override
Returns true if this device is sequential; otherwise returns false.
bool atEnd() const override
Returns true if the current read and write position is at the end of the device (i....
bool reset() override
Seeks to the start of input for random-access devices.
qint64 writeData(const char *data, qint64 maxSize) override
Writes up to maxSize bytes from data to the device.
~QNonContiguousByteDeviceByteArrayImpl()
bool reset() override
Moves the internal read pointer back to the beginning.
qint64 size() const override
Returns the size of the complete device or -1 if unknown.
qint64 pos() const override
bool advanceReadPointer(qint64 amount) override
will advance the internal read pointer by amount bytes.
const char * readPointer(qint64 maximumLength, qint64 &len) override
Return a byte pointer for at most maximumLength bytes of that device.
bool atEnd() const override
Returns true if everything has been read and the read pointer cannot be advanced anymore.
QNonContiguousByteDeviceByteArrayImpl(QBuffer *buffer)
QByteArray * currentReadBuffer
qint64 currentReadBufferAmount
~QNonContiguousByteDeviceIoDeviceImpl()
qint64 pos() const override
bool atEnd() const override
Returns true if everything has been read and the read pointer cannot be advanced anymore.
qint64 size() const override
Returns the size of the complete device or -1 if unknown.
bool advanceReadPointer(qint64 amount) override
will advance the internal read pointer by amount bytes.
bool reset() override
Moves the internal read pointer back to the beginning.
qint64 currentReadBufferPosition
const char * readPointer(qint64 maximumLength, qint64 &len) override
Return a byte pointer for at most maximumLength bytes of that device.
qint64 currentReadBufferSize
qint64 size() const override
Returns the size of the complete device or -1 if unknown.
qint64 pos() const override
bool atEnd() const override
Returns true if everything has been read and the read pointer cannot be advanced anymore.
bool advanceReadPointer(qint64 amount) override
will advance the internal read pointer by amount bytes.
bool reset() override
Moves the internal read pointer back to the beginning.
const char * readPointer(qint64 maximumLength, qint64 &len) override
Return a byte pointer for at most maximumLength bytes of that device.
std::shared_ptr< QRingBuffer > ringBuffer
~QNonContiguousByteDeviceRingBufferImpl()