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
qsequentialfileadaptor_p.h
Go to the documentation of this file.
1// Copyright (C) 2024 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
3
4#ifndef QSEQUENTIALFILEADAPTOR_P
5#define QSEQUENTIALFILEADAPTOR_P
6
7//
8// W A R N I N G
9// -------------
10//
11// This file is not part of the Qt API. It exists purely as an
12// implementation detail. This header file may change from version to
13// version without notice, or even be removed.
14//
15// We mean it.
16//
17
18#include <QtCore/qfile.h>
19
21{
22 template <typename... Args>
23 explicit QSequentialFileAdaptor(Args... args) : m_file(args...)
24 {
25 }
26
27 bool open(QIODeviceBase::OpenMode mode) override
28 {
29 QIODevice::open(mode);
30 return m_file.open(mode);
31 }
32
34 {
35 m_file.close();
36 QIODevice::close();
37 }
38
39 qint64 pos() const override { return m_file.pos(); }
40 qint64 size() const override { return m_file.size(); }
41 bool seek(qint64 pos) override { return m_file.seek(pos); }
42 bool atEnd() const override { return m_file.atEnd(); }
43 bool reset() override { return m_file.reset(); }
44
45 qint64 bytesAvailable() const override { return m_file.bytesAvailable(); }
46
47 bool isSequential() const override { return true; }
48
49 qint64 readData(char *data, qint64 maxlen) override { return m_file.read(data, maxlen); }
50 qint64 writeData(const char *data, qint64 len) override { return m_file.write(data, len); }
51
53};
54
55#endif // QSEQUENTIALFILEADAPTOR_P
qint64 readData(char *data, qint64 maxlen) override
Reads up to maxSize bytes from the device into data, and returns the number of bytes read or -1 if an...
bool seek(qint64 pos) override
For random-access devices, this function sets the current position to pos, returning true on success,...
bool atEnd() const override
Returns true if the current read and write position is at the end of the device (i....
qint64 writeData(const char *data, qint64 len) override
Writes up to maxSize bytes from data to the device.
qint64 bytesAvailable() const override
Returns the number of bytes that are available for reading.
bool reset() override
Seeks to the start of input for random-access devices.
void close() override
First emits aboutToClose(), then closes the device and sets its OpenMode to NotOpen.
bool open(QIODeviceBase::OpenMode mode) override
Opens the device and sets its OpenMode to mode.
qint64 pos() const override
For random-access devices, this function returns the position that data is written to or read from.
bool isSequential() const override
Returns true if this device is sequential; otherwise returns false.
qint64 size() const override
For open random-access devices, this function returns the size of the device.