Qt 6.x
The Qt SDK
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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
4#ifndef QNONCONTIGUOUSBYTEDEVICE_P_H
5#define QNONCONTIGUOUSBYTEDEVICE_P_H
6
7//
8// W A R N I N G
9// -------------
10//
11// This file is not part of the Qt API. It exists for the convenience
12// of a number of Qt sources files. This header file may change from
13// version to version without notice, or even be removed.
14//
15// We mean it.
16//
17
18#include <QtCore/qobject.h>
19#include <QtCore/qbytearray.h>
20#include <QtCore/qbuffer.h>
21#include <QtCore/qiodevice.h>
22#include "private/qringbuffer_p.h"
23
24#include <memory>
25
27
28class Q_CORE_EXPORT QNonContiguousByteDevice : public QObject
29{
31public:
32 virtual const char *readPointer(qint64 maximumLength, qint64 &len) = 0;
33 virtual bool advanceReadPointer(qint64 amount) = 0;
34 virtual bool atEnd() const = 0;
35 virtual qint64 pos() const { return -1; }
36 virtual bool reset() = 0;
37 virtual qint64 size() const = 0;
38
40
41protected:
43
45 void readyRead();
46 void readProgress(qint64 current, qint64 total);
47};
48
50{
51public:
53 static std::shared_ptr<QNonContiguousByteDevice> createShared(QIODevice *device);
54
55 static QNonContiguousByteDevice *create(QByteArray *byteArray);
56 static std::shared_ptr<QNonContiguousByteDevice> createShared(QByteArray *byteArray);
57
58 static QNonContiguousByteDevice *create(std::shared_ptr<QRingBuffer> ringBuffer);
59 static std::shared_ptr<QNonContiguousByteDevice> createShared(std::shared_ptr<QRingBuffer> ringBuffer);
60
61 static QIODevice *wrap(QNonContiguousByteDevice *byteDevice);
62};
63
64// the actual implementations
65//
66
68{
69public:
72 const char *readPointer(qint64 maximumLength, qint64 &len) override;
73 bool advanceReadPointer(qint64 amount) override;
74 bool atEnd() const override;
75 bool reset() override;
76 qint64 size() const override;
77 qint64 pos() const override;
78
79protected:
82};
83
85{
86public:
87 explicit QNonContiguousByteDeviceRingBufferImpl(std::shared_ptr<QRingBuffer> rb);
89 const char *readPointer(qint64 maximumLength, qint64 &len) override;
90 bool advanceReadPointer(qint64 amount) override;
91 bool atEnd() const override;
92 bool reset() override;
93 qint64 size() const override;
94 qint64 pos() const override;
95
96protected:
97 std::shared_ptr<QRingBuffer> ringBuffer;
99};
100
102{
104public:
107 const char *readPointer(qint64 maximumLength, qint64 &len) override;
108 bool advanceReadPointer(qint64 amount) override;
109 bool atEnd() const override;
110 bool reset() override;
111 qint64 size() const override;
112 qint64 pos() const override;
113
114protected:
121 bool eof;
123};
124
126{
128public:
131 const char *readPointer(qint64 maximumLength, qint64 &len) override;
132 bool advanceReadPointer(qint64 amount) override;
133 bool atEnd() const override;
134 bool reset() override;
135 qint64 size() const override;
136
137protected:
141};
142
143// ... and the reverse thing
145{
146public:
149 bool isSequential() const override;
150 bool atEnd() const override;
151 bool reset() override;
152 qint64 size() const override;
153
154protected:
155 qint64 readData(char *data, qint64 maxSize) override;
156 qint64 writeData(const char *data, qint64 maxSize) override;
157
159};
160
162
163#endif
IOBluetoothDevice * device
\inmodule QtCore \reentrant
Definition qbuffer.h:16
\inmodule QtCore
Definition qbytearray.h:57
QNonContiguousByteDevice * byteDevice
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.
\inmodule QtCore \reentrant
Definition qiodevice.h:34
QNonContiguousByteDeviceByteArrayImpl * arrayImpl
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.
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 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.
virtual const char * readPointer(qint64 maximumLength, qint64 &len)=0
Return a byte pointer for at most maximumLength bytes of that device.
virtual qint64 size() const =0
Returns the size of the complete device or -1 if unknown.
virtual bool advanceReadPointer(qint64 amount)=0
will advance the internal read pointer by amount bytes.
virtual bool reset()=0
Moves the internal read pointer back to the beginning.
void readyRead()
Emitted when there is data available.
void readProgress(qint64 current, qint64 total)
Emitted when data has been "read" by advancing the read pointer.
virtual bool atEnd() const =0
Returns true if everything has been read and the read pointer cannot be advanced anymore.
\inmodule QtCore
Definition qobject.h:90
Combined button and popup list for selecting options.
GLboolean GLboolean GLboolean b
GLint GLsizei GLsizei GLenum GLenum GLsizei void * data
GLenum GLsizei len
static QT_BEGIN_NAMESPACE QAsn1Element wrap(quint8 type, const QAsn1Element &child)
#define Q_OBJECT
#define Q_SIGNALS
long long qint64
Definition qtypes.h:55
QByteArray ba
[0]
QByteArray readData()
view create()