Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
qiodevice.h
Go to the documentation of this file.
1// Copyright (C) 2020 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#ifndef QIODEVICE_H
5#define QIODEVICE_H
6
7#include <QtCore/qglobal.h>
8#include <QtCore/qiodevicebase.h>
9#ifndef QT_NO_QOBJECT
10#include <QtCore/qobject.h>
11#else
12#include <QtCore/qobjectdefs.h>
13#include <QtCore/qscopedpointer.h>
14#endif
15#include <QtCore/qstring.h>
16
17#ifdef open
18#error qiodevice.h must be included before any header file that defines open
19#endif
20
22
23
24class QByteArray;
26
27class Q_CORE_EXPORT QIODevice
28#ifndef QT_NO_QOBJECT
29 : public QObject,
30#else
31 :
32#endif
33 public QIODeviceBase
34{
35#ifndef QT_NO_QOBJECT
37#endif
38public:
39 QIODevice();
40#ifndef QT_NO_QOBJECT
41 explicit QIODevice(QObject *parent);
42#endif
43 virtual ~QIODevice();
44
45 QIODeviceBase::OpenMode openMode() const;
46
47 void setTextModeEnabled(bool enabled);
48 bool isTextModeEnabled() const;
49
50 bool isOpen() const;
51 bool isReadable() const;
52 bool isWritable() const;
53 virtual bool isSequential() const;
54
55 int readChannelCount() const;
56 int writeChannelCount() const;
57 int currentReadChannel() const;
58 void setCurrentReadChannel(int channel);
59 int currentWriteChannel() const;
60 void setCurrentWriteChannel(int channel);
61
62 virtual bool open(QIODeviceBase::OpenMode mode);
63 virtual void close();
64
65 // ### Qt 7 - QTBUG-76492: pos() and seek() should not be virtual, and
66 // ### seek() should call a virtual seekData() function.
67 virtual qint64 pos() const;
68 virtual qint64 size() const;
69 virtual bool seek(qint64 pos);
70 virtual bool atEnd() const;
71 virtual bool reset();
72
73 virtual qint64 bytesAvailable() const;
74 virtual qint64 bytesToWrite() const;
75
76 qint64 read(char *data, qint64 maxlen);
77 QByteArray read(qint64 maxlen);
78 QByteArray readAll();
79 qint64 readLine(char *data, qint64 maxlen);
80 QByteArray readLine(qint64 maxlen = 0);
81 virtual bool canReadLine() const;
82
83 void startTransaction();
84 void commitTransaction();
85 void rollbackTransaction();
86 bool isTransactionStarted() const;
87
88 qint64 write(const char *data, qint64 len);
89 qint64 write(const char *data);
91
92 qint64 peek(char *data, qint64 maxlen);
93 QByteArray peek(qint64 maxlen);
94 qint64 skip(qint64 maxSize);
95
96 virtual bool waitForReadyRead(int msecs);
97 virtual bool waitForBytesWritten(int msecs);
98
99 void ungetChar(char c);
100 bool putChar(char c);
101 bool getChar(char *c);
102
103 QString errorString() const;
104
105#ifndef QT_NO_QOBJECT
107 void readyRead();
109 void bytesWritten(qint64 bytes);
113#endif
114
115protected:
116#ifdef QT_NO_QOBJECT
118#else
119 QIODevice(QIODevicePrivate &dd, QObject *parent = nullptr);
120#endif
121 virtual qint64 readData(char *data, qint64 maxlen) = 0;
122 virtual qint64 readLineData(char *data, qint64 maxlen);
123 virtual qint64 skipData(qint64 maxSize);
124 virtual qint64 writeData(const char *data, qint64 len) = 0;
125
126 void setOpenMode(QIODeviceBase::OpenMode openMode);
127
128 void setErrorString(const QString &errorString);
129
130#ifdef QT_NO_QOBJECT
131 QScopedPointer<QIODevicePrivate> d_ptr;
132#endif
133
134private:
135 Q_DECLARE_PRIVATE(QIODevice)
136 Q_DISABLE_COPY(QIODevice)
137};
138
139Q_DECLARE_OPERATORS_FOR_FLAGS(QIODevice::OpenMode)
140
141#if !defined(QT_NO_DEBUG_STREAM)
142class QDebug;
143Q_CORE_EXPORT QDebug operator<<(QDebug debug, QIODevice::OpenMode modes);
144#endif
145
147
148#endif // QIODEVICE_H
IOBluetoothL2CAPChannel * channel
\inmodule QtCore
Definition qbytearray.h:57
\inmodule QtCore
\inheaderfile QIODevice \inmodule QtCore
\inmodule QtCore \reentrant
Definition qiodevice.h:34
void readyRead()
This signal is emitted once every time new data is available for reading from the device's current re...
void channelReadyRead(int channel)
void bytesWritten(qint64 bytes)
This signal is emitted every time a payload of data has been written to the device's current write ch...
void channelBytesWritten(int channel, qint64 bytes)
virtual qint64 writeData(const char *data, qint64 len)=0
Writes up to maxSize bytes from data to the device.
virtual qint64 readData(char *data, qint64 maxlen)=0
Reads up to maxSize bytes from the device into data, and returns the number of bytes read or -1 if an...
void aboutToClose()
This signal is emitted when the device is about to close.
void readChannelFinished()
\inmodule QtCore
Definition qobject.h:103
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:129
Combined button and popup list for selecting options.
#define Q_DECLARE_OPERATORS_FOR_FLAGS(Flags)
Definition qflags.h:194
Q_CORE_EXPORT QDebug operator<<(QDebug debug, QIODevice::OpenMode modes)
GLenum mode
GLenum GLuint GLintptr GLsizeiptr size
[1]
GLint GLsizei GLsizei GLenum GLenum GLsizei void * data
GLenum GLenum GLsizei const GLuint GLboolean enabled
GLboolean reset
const GLubyte * c
GLenum GLsizei len
return device isReadable() ? device -> read(static_cast< char * >(buf), size) :-1
#define Q_OBJECT
#define Q_SIGNALS
long long qint64
Definition qtypes.h:60
ReturnedValue read(const char *data)
file open(QIODevice::ReadOnly)
gzip write("uncompressed data")
device waitForReadyRead(deadline)