| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432 |
- // qiodevice.sip generated by MetaSIP
- //
- // This file is part of the QtCore Python extension module.
- //
- // Copyright (c) 2026 Riverbank Computing Limited <info@riverbankcomputing.com>
- //
- // This file is part of PyQt6.
- //
- // This file may be used under the terms of the GNU General Public License
- // version 3.0 as published by the Free Software Foundation and appearing in
- // the file LICENSE included in the packaging of this file. Please review the
- // following information to ensure the GNU General Public License version 3.0
- // requirements will be met: http://www.gnu.org/copyleft/gpl.html.
- //
- // If you do not wish to use this file under the terms of the GPL version 3.0
- // then you may purchase a commercial license. For more information contact
- // info@riverbankcomputing.com.
- //
- // This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
- // WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- class QIODevice : public QObject, public QIODeviceBase
- {
- %TypeHeaderCode
- #include <qiodevice.h>
- %End
- public:
- QIODevice();
- explicit QIODevice(QObject *parent /TransferThis/);
- virtual ~QIODevice();
- QIODeviceBase::OpenMode openMode() const;
- void setTextModeEnabled(bool enabled);
- bool isTextModeEnabled() const;
- bool isOpen() const;
- bool isReadable() const;
- bool isWritable() const;
- virtual bool isSequential() const;
- int readChannelCount() const;
- int writeChannelCount() const;
- int currentReadChannel() const;
- void setCurrentReadChannel(int channel);
- int currentWriteChannel() const;
- void setCurrentWriteChannel(int channel);
- virtual bool open(QIODeviceBase::OpenMode mode) /ReleaseGIL/;
- virtual void close() /ReleaseGIL/;
- virtual qint64 pos() const;
- virtual qint64 size() const;
- virtual bool seek(qint64 pos) /ReleaseGIL/;
- virtual bool atEnd() const;
- virtual bool reset();
- virtual qint64 bytesAvailable() const;
- virtual qint64 bytesToWrite() const;
- SIP_PYOBJECT read(qint64 maxlen) /ReleaseGIL,TypeHint="bytes"/;
- %MethodCode
- // Return the data read or None if there was an error.
- if (a0 < 0)
- {
- PyErr_SetString(PyExc_ValueError, "maximum length of data to be read cannot be negative");
- sipIsErr = 1;
- }
- else
- {
- char *s = new char[a0];
- qint64 len;
-
- Py_BEGIN_ALLOW_THREADS
- len = sipCpp->read(s, a0);
- Py_END_ALLOW_THREADS
-
- if (len < 0)
- {
- Py_INCREF(Py_None);
- sipRes = Py_None;
- }
- else
- {
- sipRes = PyBytes_FromStringAndSize(s, len);
-
- if (!sipRes)
- sipIsErr = 1;
- }
-
- delete[] s;
- }
- %End
- SIP_PYOBJECT readLine(qint64 maxlen) /ReleaseGIL,TypeHint="bytes"/;
- %MethodCode
- // Return a bytes object or None if there was an error.
- if (a0 < 0)
- {
- PyErr_SetString(PyExc_ValueError, "maximum length of data to be read cannot be negative");
- sipIsErr = 1;
- }
- else
- {
- char *s = new char[a0];
- qint64 len;
-
- Py_BEGIN_ALLOW_THREADS
- len = sipCpp->readLine(s, a0);
- Py_END_ALLOW_THREADS
-
- if (len < 0)
- {
- Py_INCREF(Py_None);
- sipRes = Py_None;
- }
- else
- {
- sipRes = PyBytes_FromStringAndSize(s, len);
-
- if (!sipRes)
- sipIsErr = 1;
- }
-
- delete[] s;
- }
- %End
- QByteArray readLine() /ReleaseGIL/;
- %MethodCode
- Py_BEGIN_ALLOW_THREADS
- sipRes = new QByteArray(sipCpp->readLine());
- Py_END_ALLOW_THREADS
- %End
- %If (Qt_6_9_0 -)
- bool readLineInto(QByteArray *result, qint64 maxSize = 0) /ReleaseGIL/;
- %End
- QByteArray readAll() /ReleaseGIL/;
- virtual bool canReadLine() const;
- void startTransaction();
- void commitTransaction();
- void rollbackTransaction();
- bool isTransactionStarted() const;
- qint64 write(SIP_PYBUFFER) /ReleaseGIL/;
- %MethodCode
- sipBufferInfoDef bi;
-
- if (sipGetBufferInfo(a0, &bi) > 0)
- {
- Py_BEGIN_ALLOW_THREADS
- sipRes = sipCpp->write(reinterpret_cast<char *>(bi.bi_buf), bi.bi_len);
- Py_END_ALLOW_THREADS
-
- sipReleaseBufferInfo(&bi);
- }
- else
- {
- sipIsErr = 1;
- }
- %End
- SIP_PYOBJECT peek(qint64 maxlen) /ReleaseGIL,TypeHint="bytes"/;
- %MethodCode
- // Return the data read or None if there was an error.
- if (a0 < 0)
- {
- PyErr_SetString(PyExc_ValueError, "maximum length of data to be read cannot be negative");
- sipIsErr = 1;
- }
- else
- {
- char *s = new char[a0];
- qint64 len;
-
- Py_BEGIN_ALLOW_THREADS
- len = sipCpp->peek(s, a0);
- Py_END_ALLOW_THREADS
-
- if (len < 0)
- {
- Py_INCREF(Py_None);
- sipRes = Py_None;
- }
- else
- {
- sipRes = PyBytes_FromStringAndSize(s, len);
-
- if (!sipRes)
- sipIsErr = 1;
- }
-
- delete[] s;
- }
- %End
- qint64 skip(qint64 maxSize) /ReleaseGIL/;
- virtual bool waitForReadyRead(int msecs) /ReleaseGIL/;
- virtual bool waitForBytesWritten(int msecs) /ReleaseGIL/;
- void ungetChar(char c /Encoding="None"/);
- bool putChar(char c /Encoding="None"/) /ReleaseGIL/;
- bool getChar(char *c /Encoding="None",Out/) /ReleaseGIL/;
- QString errorString() const;
- signals:
- void aboutToClose();
- void bytesWritten(qint64 bytes);
- void channelBytesWritten(int channel, qint64 bytes);
- void channelReadyRead(int channel);
- void readChannelFinished();
- void readyRead();
- protected:
- virtual SIP_PYOBJECT readData(qint64 maxlen) = 0 /ReleaseGIL,TypeHint="bytes"/ [qint64 (char *data, qint64 maxlen)];
- %MethodCode
- // Return the data read or None if there was an error.
- if (a0 < 0)
- {
- PyErr_SetString(PyExc_ValueError, "maximum length of data to be read cannot be negative");
- sipIsErr = 1;
- }
- else
- {
- char *s = new char[a0];
- qint64 len;
-
- Py_BEGIN_ALLOW_THREADS
- #if defined(SIP_PROTECTED_IS_PUBLIC)
- len = sipCpp->readData(s, a0);
- #else
- len = sipCpp->sipProtect_readData(s, a0);
- #endif
- Py_END_ALLOW_THREADS
-
- if (len < 0)
- {
- Py_INCREF(Py_None);
- sipRes = Py_None;
- }
- else
- {
- sipRes = PyBytes_FromStringAndSize(s, len);
-
- if (!sipRes)
- sipIsErr = 1;
- }
-
- delete[] s;
- }
- %End
- %VirtualCatcherCode
- PyObject *result = sipCallMethod(&sipIsErr, sipMethod, "n", a1);
-
- if (result)
- {
- PyObject *buf;
-
- if (sipParseResult(&sipIsErr, sipMethod, result, "$", &buf) == 0)
- {
- if (buf == Py_None)
- {
- sipRes = -1L;
- }
- else
- {
- sipBufferInfoDef bi;
-
- if (sipGetBufferInfo(buf, &bi) < 0)
- {
- sipBadCatcherResult(sipMethod);
- sipIsErr = 1;
- }
- else
- {
- sipRes = (a1 < bi.bi_len) ? a1 : bi.bi_len;
- memcpy(a0, bi.bi_buf, sipRes);
-
- sipReleaseBufferInfo(&bi);
- }
- }
-
- Py_DECREF(buf);
- }
-
- Py_DECREF(result);
- }
- %End
- virtual SIP_PYOBJECT readLineData(qint64 maxlen) /ReleaseGIL,TypeHint="bytes"/ [qint64 (char *data, qint64 maxlen)];
- %MethodCode
- // Return the data read or None if there was an error.
- if (a0 < 0)
- {
- PyErr_SetString(PyExc_ValueError, "maximum length of data to be read cannot be negative");
- sipIsErr = 1;
- }
- else
- {
- char *s = new char[a0];
- qint64 len;
-
- Py_BEGIN_ALLOW_THREADS
- #if defined(SIP_PROTECTED_IS_PUBLIC)
- len = sipSelfWasArg ? sipCpp->QIODevice::readLineData(s, a0) : sipCpp->readLineData(s, a0);
- #else
- len = sipCpp->sipProtectVirt_readLineData(sipSelfWasArg, s, a0);
- #endif
- Py_END_ALLOW_THREADS
-
- if (len < 0)
- {
- Py_INCREF(Py_None);
- sipRes = Py_None;
- }
- else
- {
- sipRes = PyBytes_FromStringAndSize(s, len);
-
- if (!sipRes)
- sipIsErr = 1;
- }
-
- delete[] s;
- }
- %End
- %VirtualCatcherCode
- PyObject *result = sipCallMethod(&sipIsErr, sipMethod, "n", a1);
-
- if (result)
- {
- PyObject *buf;
-
- if (sipParseResult(&sipIsErr, sipMethod, result, "$", &buf) == 0)
- {
- if (buf == Py_None)
- {
- sipRes = -1L;
- }
- else
- {
- sipBufferInfoDef bi;
-
- if (sipGetBufferInfo(buf, &bi) < 0)
- {
- sipBadCatcherResult(sipMethod);
- sipIsErr = 1;
- }
- else
- {
- sipRes = (a1 < bi.bi_len) ? a1 : bi.bi_len;
- memcpy(a0, bi.bi_buf, sipRes);
-
- sipReleaseBufferInfo(&bi);
- }
- }
-
- Py_DECREF(buf);
- }
-
- Py_DECREF(result);
- }
- %End
- virtual qint64 writeData(SIP_PYBUFFER) = 0 /ReleaseGIL/ [qint64 (const char *data, qint64 len)];
- %MethodCode
- sipBufferInfoDef bi;
-
- if (sipGetBufferInfo(a0, &bi) > 0)
- {
- Py_BEGIN_ALLOW_THREADS
- #if defined(SIP_PROTECTED_IS_PUBLIC)
- sipRes = sipCpp->writeData(reinterpret_cast<char *>(bi.bi_buf), bi.bi_len);
- #else
- sipRes = sipCpp->sipProtect_writeData(reinterpret_cast<char *>(bi.bi_buf),
- bi.bi_len);
- #endif
- Py_END_ALLOW_THREADS
-
- sipReleaseBufferInfo(&bi);
- }
- else
- {
- sipIsErr = 1;
- }
- %End
- %VirtualCatcherCode
- PyObject *result = sipCallMethod(&sipIsErr, sipMethod, "n", a1);
-
- if (result)
- {
- PyObject *buf;
-
- if (sipParseResult(&sipIsErr, sipMethod, result, "$", &buf) == 0)
- {
- if (buf == Py_None)
- {
- sipRes = -1L;
- }
- else
- {
- sipBufferInfoDef bi;
-
- if (sipGetBufferInfo(buf, &bi) < 0)
- {
- sipBadCatcherResult(sipMethod);
- sipIsErr = 1;
- }
- else
- {
- if (bi.bi_readonly)
- {
- sipBadCatcherResult(sipMethod);
- sipIsErr = 1;
- }
- else
- {
- sipRes = (a1 < bi.bi_len) ? a1 : bi.bi_len;
- memcpy(bi.bi_buf, a0, sipRes);
- }
-
- sipReleaseBufferInfo(&bi);
- }
- }
-
- Py_DECREF(buf);
- }
-
- Py_DECREF(result);
- }
- %End
- virtual qint64 skipData(qint64 maxSize) /ReleaseGIL/;
- void setOpenMode(QIODeviceBase::OpenMode openMode);
- void setErrorString(const QString &errorString);
- };
|