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.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_H
6#define QRANDOMACCESSASYNCFILE_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 "qiooperation_p.h"
20
21#include <QtCore/qobject.h>
22#include <QtCore/qspan.h>
23
25
27class Q_CORE_EXPORT QRandomAccessAsyncFile : public QObject
28{
29 Q_OBJECT
30public:
31 explicit QRandomAccessAsyncFile(QObject *parent = nullptr);
32 ~QRandomAccessAsyncFile() override;
33
34 // sync APIs
35 void close();
36 qint64 size() const;
37
38 [[nodiscard]] QIOOperation *open(const QString &filePath, QIODeviceBase::OpenMode mode);
39 [[nodiscard]] QIOOperation *flush();
40
41 // owning APIs: we are responsible for storing the data
42 [[nodiscard]] QIOReadOperation *read(qint64 offset, qint64 maxSize);
43 [[nodiscard]] QIOWriteOperation *write(qint64 offset, const QByteArray &data);
44 [[nodiscard]] QIOWriteOperation *write(qint64 offset, QByteArray &&data);
45
46 // non-owning APIs: the user has to control the lifetime of buffers
47 [[nodiscard]] QIOVectoredReadOperation *
48 readInto(qint64 offset, QSpan<std::byte> buffer);
49 [[nodiscard]] QIOVectoredWriteOperation *
50 writeFrom(qint64 offset, QSpan<const std::byte> buffer);
51
52 // vectored IO APIs, also non-owning
53 [[nodiscard]] QIOVectoredReadOperation *
54 readInto(qint64 offset, QSpan<const QSpan<std::byte>> buffers);
55 [[nodiscard]] QIOVectoredWriteOperation *
56 writeFrom(qint64 offset, QSpan<const QSpan<const std::byte>> buffers);
57
58Q_SIGNALS:
59
60private:
61 Q_DECLARE_PRIVATE(QRandomAccessAsyncFile)
62 Q_DISABLE_COPY_MOVE(QRandomAccessAsyncFile)
63};
64
65QT_END_NAMESPACE
66
67#endif // QRANDOMACCESSASYNCFILE_P_H
void setError(QIOOperation::Error err)
void operationComplete(QIOOperation::Error err)
QPointer< QRandomAccessAsyncFile > file
std::unique_ptr< QtPrivate::QIOOperationDataStorage > dataStorage
void appendBytesProcessed(qint64 num)
QIOOperationPrivate(QtPrivate::QIOOperationDataStorage *storage)
static QIOOperationPrivate * get(QIOOperation *op)
static constexpr qsizetype DefaultNumOfBuffers
QSpan< const QSpan< std::byte > > getValue() const