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};
76
77class Q_CORE_EXPORT QIOReadWriteOperationBase : public QIOOperation
78{
79public:
80 ~QIOReadWriteOperationBase() override;
81
82 qint64 offset() const;
83 qint64 numBytesProcessed() const;
84
85protected:
86 QIOReadWriteOperationBase() = delete;
87 Q_DISABLE_COPY_MOVE(QIOReadWriteOperationBase)
88 explicit QIOReadWriteOperationBase(QIOOperationPrivate &dd, QObject *parent = nullptr);
89};
90
91class Q_CORE_EXPORT QIOReadOperation : public QIOReadWriteOperationBase
92{
93public:
94 ~QIOReadOperation() override;
95
96 QByteArray data() const;
97
98protected:
99 QIOReadOperation() = delete;
100 Q_DISABLE_COPY_MOVE(QIOReadOperation)
101 explicit QIOReadOperation(QIOOperationPrivate &dd, QObject *parent = nullptr);
102
103 friend class QRandomAccessAsyncFilePrivate;
104};
105
106class Q_CORE_EXPORT QIOWriteOperation : public QIOReadWriteOperationBase
107{
108public:
109 ~QIOWriteOperation() override;
110
111 QByteArray data() const;
112
113protected:
114 QIOWriteOperation() = delete;
115 Q_DISABLE_COPY_MOVE(QIOWriteOperation)
116 explicit QIOWriteOperation(QIOOperationPrivate &dd, QObject *parent = nullptr);
117
118 friend class QRandomAccessAsyncFilePrivate;
119};
120
121class Q_CORE_EXPORT QIOVectoredReadOperation : public QIOReadWriteOperationBase
122{
123public:
124 ~QIOVectoredReadOperation() override;
125
126 QSpan<const QSpan<std::byte>> data() const;
127
128protected:
129 QIOVectoredReadOperation() = delete;
130 Q_DISABLE_COPY_MOVE(QIOVectoredReadOperation)
131 explicit QIOVectoredReadOperation(QIOOperationPrivate &dd, QObject *parent = nullptr);
132
133 friend class QRandomAccessAsyncFilePrivate;
134};
135
136class Q_CORE_EXPORT QIOVectoredWriteOperation : public QIOReadWriteOperationBase
137{
138public:
139 ~QIOVectoredWriteOperation() override;
140
141 QSpan<const QSpan<const std::byte>> data() const;
142
143protected:
144 QIOVectoredWriteOperation() = delete;
145 Q_DISABLE_COPY_MOVE(QIOVectoredWriteOperation)
146 explicit QIOVectoredWriteOperation(QIOOperationPrivate &dd, QObject *parent = nullptr);
147
148 friend class QRandomAccessAsyncFilePrivate;
149};
150
151QT_END_NAMESPACE
152
153#endif // QIOOPERATION_P_H
void setError(QIOOperation::Error err)
void operationComplete(QIOOperation::Error err)
void appendBytesProcessed(qint64 num)