1 /* 2 * DQt - D bindings for the Qt Toolkit 3 * 4 * GNU Lesser General Public License Usage 5 * This file may be used under the terms of the GNU Lesser 6 * General Public License version 3 as published by the Free Software 7 * Foundation and appearing in the file LICENSE.LGPL3 included in the 8 * packaging of this file. Please review the following information to 9 * ensure the GNU Lesser General Public License version 3 requirements 10 * will be met: https://www.gnu.org/licenses/lgpl-3.0.html. 11 */ 12 module qt.core.iodevice; 13 extern(C++): 14 15 import qt.config; 16 import qt.core.bytearray; 17 import qt.core.flags; 18 import qt.core.global; 19 import qt.core.iodevicebase; 20 import qt.core.object; 21 import qt.core.string; 22 import qt.helpers; 23 24 /+ #ifndef QT_NO_QOBJECT 25 #else 26 #endif 27 #ifdef open 28 #error qiodevice.h must be included before any header file that defines open 29 #endif +/ 30 31 32 33 extern(C++, class) struct QIODevicePrivate; 34 35 /// Binding for C++ class [QIODevice](https://doc.qt.io/qt-6/qiodevice.html). 36 abstract class /+ Q_CORE_EXPORT +/ QIODevice 37 /+ #ifndef QT_NO_QOBJECT +/ 38 : QObject 39 /+ #else 40 : 41 #endif +/ 42 // QIODeviceBase 43 { 44 /+ #ifndef QT_NO_QOBJECT +/ 45 mixin(Q_OBJECT); 46 /+ #endif +/ 47 alias OpenModeFlag = QIODeviceBase.OpenModeFlag; 48 alias OpenMode = QIODeviceBase.OpenMode; 49 public: 50 51 mixin(changeItaniumMangling(q{mangleConstructorBaseObject}, q{ 52 this(); 53 })); 54 /+ #ifndef QT_NO_QOBJECT +/ 55 mixin(changeItaniumMangling(q{mangleConstructorBaseObject}, q{ 56 /+ explicit +/this(QObject parent); 57 })); 58 /+ #endif +/ 59 /+ virtual +/~this(); 60 61 final QIODeviceBase.OpenMode openMode() const; 62 63 final void setTextModeEnabled(bool enabled); 64 final bool isTextModeEnabled() const; 65 66 final bool isOpen() const; 67 final bool isReadable() const; 68 final bool isWritable() const; 69 /+ virtual +/ bool isSequential() const; 70 71 final int readChannelCount() const; 72 final int writeChannelCount() const; 73 final int currentReadChannel() const; 74 final void setCurrentReadChannel(int channel); 75 final int currentWriteChannel() const; 76 final void setCurrentWriteChannel(int channel); 77 78 /+ virtual +/ bool open(QIODeviceBase.OpenMode mode); 79 /+ virtual +/ void close(); 80 81 // ### Qt 7 - QTBUG-76492: pos() and seek() should not be virtual, and 82 // ### seek() should call a virtual seekData() function. 83 /+ virtual +/ qint64 pos() const; 84 /+ virtual +/ qint64 size() const; 85 /+ virtual +/ bool seek(qint64 pos); 86 /+ virtual +/ bool atEnd() const; 87 /+ virtual +/ bool reset(); 88 89 /+ virtual +/ qint64 bytesAvailable() const; 90 /+ virtual +/ qint64 bytesToWrite() const; 91 92 final qint64 read(char* data, qint64 maxlen); 93 final QByteArray read(qint64 maxlen); 94 final QByteArray readAll(); 95 final qint64 readLine(char* data, qint64 maxlen); 96 final QByteArray readLine(qint64 maxlen = 0); 97 /+ virtual +/ bool canReadLine() const; 98 99 final void startTransaction(); 100 final void commitTransaction(); 101 final void rollbackTransaction(); 102 final bool isTransactionStarted() const; 103 104 final qint64 write(const(char)* data, qint64 len); 105 final qint64 write(const(char)* data); 106 final qint64 write(ref const(QByteArray) data); 107 108 final qint64 peek(char* data, qint64 maxlen); 109 final QByteArray peek(qint64 maxlen); 110 final qint64 skip(qint64 maxSize); 111 112 /+ virtual +/ bool waitForReadyRead(int msecs); 113 /+ virtual +/ bool waitForBytesWritten(int msecs); 114 115 final void ungetChar(char c); 116 final bool putChar(char c); 117 final bool getChar(char* c); 118 119 final QString errorString() const; 120 121 /+ #ifndef QT_NO_QOBJECT +/ 122 /+ Q_SIGNALS +/public: 123 @QSignal final void readyRead(); 124 @QSignal final void channelReadyRead(int channel); 125 @QSignal final void bytesWritten(qint64 bytes); 126 @QSignal final void channelBytesWritten(int channel, qint64 bytes); 127 @QSignal final void aboutToClose(); 128 @QSignal final void readChannelFinished(); 129 /+ #endif +/ 130 131 protected: 132 /+ #ifdef QT_NO_QOBJECT 133 QIODevice(QIODevicePrivate &dd); 134 #else +/ 135 mixin(changeItaniumMangling(q{mangleConstructorBaseObject}, q{ 136 this(ref QIODevicePrivate dd, QObject parent = null); 137 })); 138 /+ #endif +/ 139 /+ virtual +/ abstract qint64 readData(char* data, qint64 maxlen); 140 /+ virtual +/ qint64 readLineData(char* data, qint64 maxlen); 141 /+ virtual +/ qint64 skipData(qint64 maxSize); 142 /+ virtual +/ abstract qint64 writeData(const(char)* data, qint64 len); 143 144 final void setOpenMode(QIODeviceBase.OpenMode openMode); 145 146 final void setErrorString(ref const(QString) errorString); 147 148 /+ #ifdef QT_NO_QOBJECT 149 QScopedPointer<QIODevicePrivate> d_ptr; 150 #endif +/ 151 152 private: 153 /+ Q_DECLARE_PRIVATE(QIODevice) +/ 154 /+ Q_DISABLE_COPY(QIODevice) +/ 155 mixin(CREATE_CONVENIENCE_WRAPPERS); 156 } 157 /+pragma(inline, true) QFlags!(QIODevice.OpenMode.enum_type) operator |(QIODevice.OpenMode.enum_type f1, QIODevice.OpenMode.enum_type f2)/+noexcept+/{return QFlags!(QIODevice.OpenMode.enum_type)(f1)|f2;}+/ 158 /+pragma(inline, true) QFlags!(QIODevice.OpenMode.enum_type) operator |(QIODevice.OpenMode.enum_type f1, QFlags!(QIODevice.OpenMode.enum_type) f2)/+noexcept+/{return f2|f1;}+/ 159 /+pragma(inline, true) QFlags!(QIODevice.OpenMode.enum_type) operator &(QIODevice.OpenMode.enum_type f1, QIODevice.OpenMode.enum_type f2)/+noexcept+/{return QFlags!(QIODevice.OpenMode.enum_type)(f1)&f2;}+/ 160 /+pragma(inline, true) QFlags!(QIODevice.OpenMode.enum_type) operator &(QIODevice.OpenMode.enum_type f1, QFlags!(QIODevice.OpenMode.enum_type) f2)/+noexcept+/{return f2&f1;}+/ 161 /+pragma(inline, true) void operator +(QIODevice.OpenMode.enum_type f1, QIODevice.OpenMode.enum_type f2)/+noexcept+/;+/ 162 /+pragma(inline, true) void operator +(QIODevice.OpenMode.enum_type f1, QFlags!(QIODevice.OpenMode.enum_type) f2)/+noexcept+/;+/ 163 /+pragma(inline, true) void operator +(int f1, QFlags!(QIODevice.OpenMode.enum_type) f2)/+noexcept+/;+/ 164 /+pragma(inline, true) void operator -(QIODevice.OpenMode.enum_type f1, QIODevice.OpenMode.enum_type f2)/+noexcept+/;+/ 165 /+pragma(inline, true) void operator -(QIODevice.OpenMode.enum_type f1, QFlags!(QIODevice.OpenMode.enum_type) f2)/+noexcept+/;+/ 166 /+pragma(inline, true) void operator -(int f1, QFlags!(QIODevice.OpenMode.enum_type) f2)/+noexcept+/;+/ 167 /+pragma(inline, true) QIncompatibleFlag operator |(QIODevice.OpenMode.enum_type f1, int f2)/+noexcept+/{return QIncompatibleFlag(int(f1)|f2);}+/ 168 /+pragma(inline, true) void operator +(int f1, QIODevice.OpenMode.enum_type f2)/+noexcept+/;+/ 169 /+pragma(inline, true) void operator +(QIODevice.OpenMode.enum_type f1, int f2)/+noexcept+/;+/ 170 /+pragma(inline, true) void operator -(int f1, QIODevice.OpenMode.enum_type f2)/+noexcept+/;+/ 171 /+pragma(inline, true) void operator -(QIODevice.OpenMode.enum_type f1, int f2)/+noexcept+/;+/ 172 173 /+ Q_DECLARE_OPERATORS_FOR_FLAGS(QIODevice::OpenMode) 174 #if !defined(QT_NO_DEBUG_STREAM) 175 class QDebug; 176 Q_CORE_EXPORT QDebug operator<<(QDebug debug, QIODevice::OpenMode modes); 177 #endif +/ 178