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
qrandomaccessasyncfile_p_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 QRANDOMACCESSASYNCFILE_P_P_H
6#define QRANDOMACCESSASYNCFILE_P_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
20
21#include <QtCore/private/qobject_p.h>
22
23#include <QtCore/qstring.h>
24
25#ifdef QT_RANDOMACCESSASYNCFILE_THREAD
26
27#include <QtCore/private/qfsfileengine_p.h>
28
29#include <QtCore/qfuturewatcher.h>
30#include <QtCore/qmutex.h>
31#include <QtCore/qqueue.h>
32
33#endif // QT_RANDOMACCESSASYNCFILE_THREAD
34
36
38{
39 Q_DECLARE_PUBLIC(QRandomAccessAsyncFile)
41public:
44
45 static QRandomAccessAsyncFilePrivate *get(QRandomAccessAsyncFile *file)
46 { return file->d_func(); }
47
48 void init();
49 void cancelAndWait(QIOOperation *op);
50
51 void close();
52 qint64 size() const;
53
54 [[nodiscard]] QIOOperation *open(const QString &path, QIODeviceBase::OpenMode mode);
56
57 [[nodiscard]] QIOReadOperation *read(qint64 offset, qint64 maxSize);
58 [[nodiscard]] QIOWriteOperation *write(qint64 offset, const QByteArray &data);
59 [[nodiscard]] QIOWriteOperation *write(qint64 offset, QByteArray &&data);
60
62 readInto(qint64 offset, QSpan<std::byte> buffer);
64 writeFrom(qint64 offset, QSpan<const std::byte> buffer);
65
67 readInto(qint64 offset, QSpan<const QSpan<std::byte>> buffers);
69 writeFrom(qint64 offset, QSpan<const QSpan<const std::byte>> buffers);
70
71private:
72#ifdef QT_RANDOMACCESSASYNCFILE_THREAD
73public:
74 struct OperationResult
75 {
76 qint64 bytesProcessed; // either read or written
78 };
79
80private:
81 enum class FileState : quint8
82 {
83 Closed,
84 OpenPending, // already got an open request
85 Opened,
86 };
87
91
95
99
102 void processFlush();
103 void processOpen();
104 void operationComplete();
105#endif
106};
107
108QT_END_NAMESPACE
109
110#endif // QRANDOMACCESSASYNCFILE_P_P_H
static QRandomAccessAsyncFilePrivate * get(QRandomAccessAsyncFile *file)
QIOOperation * open(const QString &path, QIODeviceBase::OpenMode mode)
QIOReadOperation * read(qint64 offset, qint64 maxSize)
QIOVectoredWriteOperation * writeFrom(qint64 offset, QSpan< const std::byte > buffer)
QIOWriteOperation * write(qint64 offset, QByteArray &&data)
QIOWriteOperation * write(qint64 offset, const QByteArray &data)
QIOVectoredReadOperation * readInto(qint64 offset, QSpan< std::byte > buffer)