8#include <QtCore/qdeadlinetimer.h>
9#include <QtCore/qiodevicebase.h>
11#include <QtCore/qobject.h>
13#include <QtCore/qobjectdefs.h>
14#include <QtCore/qscopedpointer.h>
16#include <QtCore/qspan.h>
17#include <QtCore/qstring.h>
20#error qiodevice.h must be included before any header file that defines open
29class QIODevicePrivate;
43 struct WaitForVirtualParametersChanged {
45 Q_IMPLICIT
constexpr WaitForVirtualParametersChanged(
bool b) : value(b) {}
46 constexpr Q_IMPLICIT operator
bool()
const noexcept {
return value; }
47 constexpr bool operator!()
const noexcept {
return !value; }
53 explicit QIODevice(QObject *parent);
57 QIODeviceBase::OpenMode openMode()
const;
59 void setTextModeEnabled(
bool enabled);
60 bool isTextModeEnabled()
const;
63 bool isReadable()
const;
64 bool isWritable()
const;
65 virtual bool isSequential()
const;
67 int readChannelCount()
const;
68 int writeChannelCount()
const;
69 int currentReadChannel()
const;
70 void setCurrentReadChannel(
int channel);
71 int currentWriteChannel()
const;
72 void setCurrentWriteChannel(
int channel);
74 virtual bool open(QIODeviceBase::OpenMode mode);
79 virtual qint64 pos()
const;
80 virtual qint64 size()
const;
81 virtual bool seek(qint64 pos);
82 virtual bool atEnd()
const;
85 virtual qint64 bytesAvailable()
const;
86 virtual qint64 bytesToWrite()
const;
88 qint64 read(
char *data, qint64 maxlen);
89 QByteArray read(qint64 maxlen);
91 qint64 readLine(
char *data, qint64 maxlen);
92 QByteArray readLine(qint64 maxlen = 0);
93 bool readLineInto(QByteArray *result, qint64 maxlen = 0);
95 QByteArrayView readLineInto(QSpan<
char> buffer)
96 {
return readLineInto(as_writable_bytes(buffer)); }
97 QByteArrayView readLineInto(QSpan<uchar> buffer)
98 {
return readLineInto(as_writable_bytes(buffer)); }
99 QByteArrayView readLineInto(QSpan<std::byte> buffer);
101 virtual bool canReadLine()
const;
103 void startTransaction();
104 void commitTransaction();
105 void rollbackTransaction();
106 bool isTransactionStarted()
const;
108 qint64 write(
const char *data, qint64 len);
109 qint64 write(
const char *data);
110 qint64 write(
const QByteArray &data);
112 qint64 peek(
char *data, qint64 maxlen);
113 QByteArray peek(qint64 maxlen);
114 qint64 skip(qint64 maxSize);
116 QT7_ONLY(
virtual)
bool waitForReadyRead(QDeadlineTimer deadline);
117 QT7_ONLY(
virtual)
bool waitForBytesWritten(QDeadlineTimer deadline);
118#if QT_VERSION < QT_VERSION_CHECK(7
, 0
, 0
) && !defined(QT_BOOTSTRAPPED)
119 virtual bool waitForReadyRead(
int msecs);
120 virtual bool waitForBytesWritten(
int msecs);
122 WaitForVirtualParametersChanged waitForReadyRead(
int msecs)
123 {
return waitForReadyRead(QDeadlineTimer(msecs)); }
124 WaitForVirtualParametersChanged waitForBytesWritten(
int msecs)
125 {
return waitForBytesWritten(QDeadlineTimer(msecs)); }
128 void ungetChar(
char c);
129 bool putChar(
char c);
130 bool getChar(
char *c);
132 QString errorString()
const;
137 void channelReadyRead(
int channel);
138 void bytesWritten(qint64 bytes);
139 void channelBytesWritten(
int channel, qint64 bytes);
141 void readChannelFinished();
146 QIODevice(QIODevicePrivate &dd);
148 QIODevice(QIODevicePrivate &dd, QObject *parent =
nullptr);
150 virtual qint64 readData(
char *data, qint64 maxlen) = 0;
151 virtual qint64 readLineData(
char *data, qint64 maxlen);
152 virtual qint64 skipData(qint64 maxSize);
153 virtual qint64 writeData(
const char *data, qint64 len) = 0;
155 void setOpenMode(QIODeviceBase::OpenMode openMode);
157 void setErrorString(
const QString &errorString);
160 std::unique_ptr<QIODevicePrivate> d_ptr;
164 Q_DECLARE_PRIVATE(QIODevice)
165 Q_DISABLE_COPY(QIODevice)
168Q_DECLARE_OPERATORS_FOR_FLAGS(QIODevice::OpenMode)
170#if !defined(QT_NO_DEBUG_STREAM)
172Q_CORE_EXPORT
QDebug operator<<(QDebug debug, QIODevice::OpenMode modes);
\inmodule QtCore \reentrant
ImageOption
This enum describes the different options supported by QImageIOHandler.
The QJp2Handler class provides support for reading and writing JPEG 2000 image files with the Qt plug...
~QJp2Handler()
Destructor for QJp2Handler.
QJp2Handler()
Constructs an instance of QJp2Handler.
static bool canRead(QIODevice *iod, QByteArray *subType)
Verifies if some values (magic bytes) are set as expected in the header of the file.
void setOption(ImageOption option, const QVariant &value) override
The JPEG 2000 handler supports two options.
bool write(const QImage &image) override
\reimp
bool read(QImage *image) override
\reimp
bool supportsOption(ImageOption option) const override
This function will return true if option is set to either QImageIOHandler::Quality or QImageIOHandler...
QVariant option(ImageOption option) const override
Get the value associated with option.
bool canRead() const override
\reimp
QImageIOHandler * create(QIODevice *device, const QByteArray &format=QByteArray()) const override
Creates and returns a QImageIOHandler subclass, with device and format set.
Combined button and popup list for selecting options.
Q_CORE_EXPORT QDebug operator<<(QDebug debug, QDir::Filters filters)