Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-09-15 09:07:28

0001 // Copyright (C) 2020 The Qt Company Ltd.
0002 // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
0003 
0004 #ifndef QIODEVICE_H
0005 #define QIODEVICE_H
0006 
0007 #include <QtCore/qglobal.h>
0008 #include <QtCore/qiodevicebase.h>
0009 #ifndef QT_NO_QOBJECT
0010 #include <QtCore/qobject.h>
0011 #else
0012 #include <QtCore/qobjectdefs.h>
0013 #include <QtCore/qscopedpointer.h>
0014 #endif
0015 #include <QtCore/qspan.h>
0016 #include <QtCore/qstring.h>
0017 
0018 #ifdef open
0019 #error qiodevice.h must be included before any header file that defines open
0020 #endif
0021 
0022 #include <memory>
0023 
0024 QT_BEGIN_NAMESPACE
0025 
0026 
0027 class QByteArray;
0028 class QIODevicePrivate;
0029 
0030 class Q_CORE_EXPORT QIODevice
0031 #ifndef QT_NO_QOBJECT
0032     : public QObject,
0033 #else
0034     :
0035 #endif
0036       public QIODeviceBase
0037 {
0038 #ifndef QT_NO_QOBJECT
0039     Q_OBJECT
0040 #endif
0041 public:
0042     QIODevice();
0043 #ifndef QT_NO_QOBJECT
0044     explicit QIODevice(QObject *parent);
0045 #endif
0046     virtual ~QIODevice();
0047 
0048     QIODeviceBase::OpenMode openMode() const;
0049 
0050     void setTextModeEnabled(bool enabled);
0051     bool isTextModeEnabled() const;
0052 
0053     bool isOpen() const;
0054     bool isReadable() const;
0055     bool isWritable() const;
0056     virtual bool isSequential() const;
0057 
0058     int readChannelCount() const;
0059     int writeChannelCount() const;
0060     int currentReadChannel() const;
0061     void setCurrentReadChannel(int channel);
0062     int currentWriteChannel() const;
0063     void setCurrentWriteChannel(int channel);
0064 
0065     virtual bool open(QIODeviceBase::OpenMode mode);
0066     virtual void close();
0067 
0068     // ### Qt 7 - QTBUG-76492: pos() and seek() should not be virtual, and
0069     // ### seek() should call a virtual seekData() function.
0070     virtual qint64 pos() const;
0071     virtual qint64 size() const;
0072     virtual bool seek(qint64 pos);
0073     virtual bool atEnd() const;
0074     virtual bool reset();
0075 
0076     virtual qint64 bytesAvailable() const;
0077     virtual qint64 bytesToWrite() const;
0078 
0079     qint64 read(char *data, qint64 maxlen);
0080     QByteArray read(qint64 maxlen);
0081     QByteArray readAll();
0082     qint64 readLine(char *data, qint64 maxlen);
0083     QByteArray readLine(qint64 maxlen = 0);
0084     bool readLineInto(QByteArray *result, qint64 maxlen = 0);
0085 
0086     QByteArrayView readLineInto(QSpan<char> buffer)
0087     { return readLineInto(as_writable_bytes(buffer)); }
0088     QByteArrayView readLineInto(QSpan<uchar> buffer)
0089     { return readLineInto(as_writable_bytes(buffer)); }
0090     QByteArrayView readLineInto(QSpan<std::byte> buffer);
0091 
0092     virtual bool canReadLine() const;
0093 
0094     void startTransaction();
0095     void commitTransaction();
0096     void rollbackTransaction();
0097     bool isTransactionStarted() const;
0098 
0099     qint64 write(const char *data, qint64 len);
0100     qint64 write(const char *data);
0101     qint64 write(const QByteArray &data);
0102 
0103     qint64 peek(char *data, qint64 maxlen);
0104     QByteArray peek(qint64 maxlen);
0105     qint64 skip(qint64 maxSize);
0106 
0107     virtual bool waitForReadyRead(int msecs);
0108     virtual bool waitForBytesWritten(int msecs);
0109 
0110     void ungetChar(char c);
0111     bool putChar(char c);
0112     bool getChar(char *c);
0113 
0114     QString errorString() const;
0115 
0116 #ifndef QT_NO_QOBJECT
0117 Q_SIGNALS:
0118     void readyRead();
0119     void channelReadyRead(int channel);
0120     void bytesWritten(qint64 bytes);
0121     void channelBytesWritten(int channel, qint64 bytes);
0122     void aboutToClose();
0123     void readChannelFinished();
0124 #endif
0125 
0126 protected:
0127 #ifdef QT_NO_QOBJECT
0128     QIODevice(QIODevicePrivate &dd);
0129 #else
0130     QIODevice(QIODevicePrivate &dd, QObject *parent = nullptr);
0131 #endif
0132     virtual qint64 readData(char *data, qint64 maxlen) = 0;
0133     virtual qint64 readLineData(char *data, qint64 maxlen);
0134     virtual qint64 skipData(qint64 maxSize);
0135     virtual qint64 writeData(const char *data, qint64 len) = 0;
0136 
0137     void setOpenMode(QIODeviceBase::OpenMode openMode);
0138 
0139     void setErrorString(const QString &errorString);
0140 
0141 #ifdef QT_NO_QOBJECT
0142     std::unique_ptr<QIODevicePrivate> d_ptr;
0143 #endif
0144 
0145 private:
0146     Q_DECLARE_PRIVATE(QIODevice)
0147     Q_DISABLE_COPY(QIODevice)
0148 };
0149 
0150 Q_DECLARE_OPERATORS_FOR_FLAGS(QIODevice::OpenMode)
0151 
0152 #if !defined(QT_NO_DEBUG_STREAM)
0153 class QDebug;
0154 Q_CORE_EXPORT QDebug operator<<(QDebug debug, QIODevice::OpenMode modes);
0155 #endif
0156 
0157 QT_END_NAMESPACE
0158 
0159 #endif // QIODEVICE_H