Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qnoncontiguousbytedevice_p.h
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// Qt-Security score:significant reason:default
4
5#ifndef QNONCONTIGUOUSBYTEDEVICE_P_H
6#define QNONCONTIGUOUSBYTEDEVICE_P_H
7
8//
9// W A R N I N G
10// -------------
11//
12// This file is not part of the Qt API. It exists for the convenience
13// of a number of Qt sources files. This header file may change from
14// version to version without notice, or even be removed.
15//
16// We mean it.
17//
18
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"
24
25#include <memory>
26
28
30{
31 Q_OBJECT
32public:
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;
39
40 virtual ~QNonContiguousByteDevice();
41
42protected:
43 QNonContiguousByteDevice();
44
45Q_SIGNALS:
46 void readyRead();
47 void readProgress(qint64 current, qint64 total);
48};
49
51{
52public:
53 static QNonContiguousByteDevice *create(QIODevice *device);
54 static std::shared_ptr<QNonContiguousByteDevice> createShared(QIODevice *device);
55
56 static QNonContiguousByteDevice *create(const QByteArray &byteArray);
57 static std::shared_ptr<QNonContiguousByteDevice> createShared(const QByteArray &byteArray);
58
59 static QNonContiguousByteDevice *create(std::shared_ptr<QRingBuffer> ringBuffer);
60 static std::shared_ptr<QNonContiguousByteDevice> createShared(std::shared_ptr<QRingBuffer> ringBuffer);
61
62 static QIODevice *wrap(QNonContiguousByteDevice *byteDevice);
63};
64
65// the actual implementations
66//
67
69{
71public:
73 explicit QNonContiguousByteDeviceByteArrayImpl(QBuffer *buffer);
75 const char *readPointer(qint64 maximumLength, qint64 &len) override;
76 bool advanceReadPointer(qint64 amount) override;
77 bool atEnd() const override;
78 bool reset() override;
79 qint64 size() const override;
80 qint64 pos() const override;
81
82protected:
86};
87
89{
91public:
94 const char *readPointer(qint64 maximumLength, qint64 &len) override;
95 bool advanceReadPointer(qint64 amount) override;
96 bool atEnd() const override;
97 bool reset() override;
98 qint64 size() const override;
99 qint64 pos() const override;
100
101protected:
104};
105
107{
109public:
112 const char *readPointer(qint64 maximumLength, qint64 &len) override;
113 bool advanceReadPointer(qint64 amount) override;
114 bool atEnd() const override;
115 bool reset() override;
116 qint64 size() const override;
117 qint64 pos() const override;
118
119protected:
126 bool eof;
128};
129
130// ... and the reverse thing
132{
134public:
137 bool isSequential() const override;
138 bool atEnd() const override;
139 bool reset() override;
140 qint64 size() const override;
141
142protected:
143 qint64 readData(char *data, qint64 maxSize) override;
144 qint64 writeData(const char *data, qint64 maxSize) override;
145
147};
148
149QT_END_NAMESPACE
150
151#endif
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.
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.
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.
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.
const char * readPointer(qint64 maximumLength, qint64 &len) override
Return a byte pointer for at most maximumLength bytes of that device.
qint64 size() const override
Returns the size of the complete device or -1 if unknown.
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.