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
qiooperation_p.h
Go to the documentation of this file.
1// Copyright (C) 2025 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 QIOOPERATION_P_H
6#define QIOOPERATION_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 purely as an
13// implementation detail. This header file may change from version to
14// version without notice, or even be removed.
15//
16// We mean it.
17//
18
19#include <QtCore/private/qglobal_p.h>
20
21#include <QtCore/qobject.h>
22#include <QtCore/qspan.h>
23
24QT_BEGIN_NAMESPACE
25
26class QIOOperationPrivate;
27class Q_CORE_EXPORT QIOOperation : public QObject
28{
29 Q_OBJECT
30public:
31 // TODO: more specific error codes?
32 enum class Error
33 {
34 None,
35 FileNotOpen,
36 IncorrectOffset,
37 Read,
38 Write,
39 Flush,
40 Open,
41 Aborted,
42 };
43 Q_ENUM(Error)
44
45 enum class Type : quint8
46 {
47 Unknown,
48 Read,
49 Write,
50 Flush,
51 Open,
52 };
53 Q_ENUM(Type)
54
55 ~QIOOperation() override;
56
57 Type type() const;
58 Error error() const;
59 bool isFinished() const;
60
61Q_SIGNALS:
62 void finished();
63 void errorOccurred(Error err);
64
65protected:
66 QIOOperation() = delete;
67 Q_DISABLE_COPY_MOVE(QIOOperation)
68 explicit QIOOperation(QIOOperationPrivate &dd, QObject *parent = nullptr);
69
70 void ensureCompleteOrCanceled();
71
72 Q_DECLARE_PRIVATE(QIOOperation)
73
74 friend class QRandomAccessAsyncFilePrivate;
75 friend class QRandomAccessAsyncFileBackend;
76 friend class QRandomAccessAsyncFileNativeBackend;
77 friend class QRandomAccessAsyncFileThreadPoolBackend;
78};
79
80class Q_CORE_EXPORT QIOReadWriteOperationBase : public QIOOperation
81{
82public:
83 ~QIOReadWriteOperationBase() override;
84
85 qint64 offset() const;
86 qint64 numBytesProcessed() const;
87
88protected:
89 QIOReadWriteOperationBase() = delete;
90 Q_DISABLE_COPY_MOVE(QIOReadWriteOperationBase)
91 explicit QIOReadWriteOperationBase(QIOOperationPrivate &dd, QObject *parent = nullptr);
92
93 friend class QRandomAccessAsyncFilePrivate;
94 friend class QRandomAccessAsyncFileBackend;
95 friend class QRandomAccessAsyncFileNativeBackend;
96 friend class QRandomAccessAsyncFileThreadPoolBackend;
97};
98
99class Q_CORE_EXPORT QIOReadOperation : public QIOReadWriteOperationBase
100{
101public:
102 ~QIOReadOperation() override;
103
104 QByteArray data() const;
105
106protected:
107 QIOReadOperation() = delete;
108 Q_DISABLE_COPY_MOVE(QIOReadOperation)
109 explicit QIOReadOperation(QIOOperationPrivate &dd, QObject *parent = nullptr);
110
111 friend class QRandomAccessAsyncFilePrivate;
112 friend class QRandomAccessAsyncFileBackend;
113 friend class QRandomAccessAsyncFileNativeBackend;
114 friend class QRandomAccessAsyncFileThreadPoolBackend;
115};
116
117class Q_CORE_EXPORT QIOWriteOperation : public QIOReadWriteOperationBase
118{
119public:
120 ~QIOWriteOperation() override;
121
122 QByteArray data() const;
123
124protected:
125 QIOWriteOperation() = delete;
126 Q_DISABLE_COPY_MOVE(QIOWriteOperation)
127 explicit QIOWriteOperation(QIOOperationPrivate &dd, QObject *parent = nullptr);
128
129 friend class QRandomAccessAsyncFilePrivate;
130 friend class QRandomAccessAsyncFileBackend;
131 friend class QRandomAccessAsyncFileNativeBackend;
132 friend class QRandomAccessAsyncFileThreadPoolBackend;
133};
134
135class Q_CORE_EXPORT QIOVectoredReadOperation : public QIOReadWriteOperationBase
136{
137public:
138 ~QIOVectoredReadOperation() override;
139
140 QSpan<const QSpan<std::byte>> data() const;
141
142protected:
143 QIOVectoredReadOperation() = delete;
144 Q_DISABLE_COPY_MOVE(QIOVectoredReadOperation)
145 explicit QIOVectoredReadOperation(QIOOperationPrivate &dd, QObject *parent = nullptr);
146
147 friend class QRandomAccessAsyncFilePrivate;
148 friend class QRandomAccessAsyncFileBackend;
149 friend class QRandomAccessAsyncFileNativeBackend;
150 friend class QRandomAccessAsyncFileThreadPoolBackend;
151};
152
153class Q_CORE_EXPORT QIOVectoredWriteOperation : public QIOReadWriteOperationBase
154{
155public:
156 ~QIOVectoredWriteOperation() override;
157
158 QSpan<const QSpan<const std::byte>> data() const;
159
160protected:
161 QIOVectoredWriteOperation() = delete;
162 Q_DISABLE_COPY_MOVE(QIOVectoredWriteOperation)
163 explicit QIOVectoredWriteOperation(QIOOperationPrivate &dd, QObject *parent = nullptr);
164
165 friend class QRandomAccessAsyncFilePrivate;
166 friend class QRandomAccessAsyncFileBackend;
167 friend class QRandomAccessAsyncFileNativeBackend;
168 friend class QRandomAccessAsyncFileThreadPoolBackend;
169};
170
171QT_END_NAMESPACE
172
173#endif // QIOOPERATION_P_H
void setError(QIOOperation::Error err)
void operationComplete(QIOOperation::Error err)
void appendBytesProcessed(qint64 num)
Combined button and popup list for selecting options.