Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
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
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{
70public:
73 const char *readPointer(qint64 maximumLength, qint64 &len) override;
74 bool advanceReadPointer(qint64 amount) override;
75 bool atEnd() const override;
76 bool reset() override;
77 qint64 size() const override;
78 qint64 pos() const override;
79
80protected:
83};
84
86{
88public:
89 explicit QNonContiguousByteDeviceRingBufferImpl(std::shared_ptr<QRingBuffer> rb);
91 const char *readPointer(qint64 maximumLength, qint64 &len) override;
92 bool advanceReadPointer(qint64 amount) override;
93 bool atEnd() const override;
94 bool reset() override;
95 qint64 size() const override;
96 qint64 pos() const override;
97
98protected:
99 std::shared_ptr<QRingBuffer> ringBuffer;
101};
102
126
128{
130public:
133 const char *readPointer(qint64 maximumLength, qint64 &len) override;
134 bool advanceReadPointer(qint64 amount) override;
135 bool atEnd() const override;
136 bool reset() override;
137 qint64 size() const override;
138
139protected:
143};
144
145// ... and the reverse thing
147{
149public:
152 bool isSequential() const override;
153 bool atEnd() const override;
154 bool reset() override;
155 qint64 size() const override;
156
157protected:
158 qint64 readData(char *data, qint64 maxSize) override;
159 qint64 writeData(const char *data, qint64 maxSize) override;
160
162};
163
165
166#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.
QByteDeviceWrappingIoDevice(QNonContiguousByteDevice *bd)
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.
QNonContiguousByteDeviceRingBufferImpl(std::shared_ptr< QRingBuffer > rb)
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:103
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:60
QByteArray ba
[0]
QByteArray readData()
view create()