Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:07:25

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