KPty 5.109.0
kptydevice.h
1/*
2 This file is part of the KDE libraries
3 SPDX-FileCopyrightText: 2007 Oswald Buddenhagen <ossi@kde.org>
4
5 SPDX-License-Identifier: LGPL-2.0-or-later
6*/
7
8#ifndef kptydev_h
9#define kptydev_h
10
11#include "kpty.h"
12
13#include <QIODevice>
14
15class KPtyDevicePrivate;
16
20class KPTY_EXPORT KPtyDevice : public QIODevice, public KPty // krazy:exclude=dpointer (via macro)
21{
22 Q_OBJECT
23 Q_DECLARE_PRIVATE_D(KPty::d_ptr, KPtyDevice)
24
25public:
29 explicit KPtyDevice(QObject *parent = nullptr);
30
37 ~KPtyDevice() override;
38
44 bool open(OpenMode mode = ReadWrite | Unbuffered) override;
45
59 bool open(int fd, OpenMode mode = ReadWrite | Unbuffered);
60
64 void close() override;
65
78 void setSuspended(bool suspended);
79
88 bool isSuspended() const;
89
93 bool isSequential() const override;
94
98 bool canReadLine() const override;
99
103 bool atEnd() const override;
104
108 qint64 bytesAvailable() const override;
109
113 qint64 bytesToWrite() const override;
114
115 bool waitForBytesWritten(int msecs = -1) override;
116 bool waitForReadyRead(int msecs = -1) override;
117
118Q_SIGNALS:
124 void readEof();
125
126protected:
127 qint64 readData(char *data, qint64 maxSize) override;
128 qint64 readLineData(char *data, qint64 maxSize) override;
129 qint64 writeData(const char *data, qint64 maxSize) override;
130
131private:
132 Q_PRIVATE_SLOT(d_func(), bool _k_canRead())
133 Q_PRIVATE_SLOT(d_func(), bool _k_canWrite())
134};
135
136#endif
Encapsulates KPty into a QIODevice, so it can be used with Q*Stream, etc.
Definition kptydevice.h:21
void readEof()
Emitted when EOF is read from the PTY.
void setSuspended(bool suspended)
Sets whether the KPtyDevice monitors the pty for incoming data.
qint64 bytesAvailable() const override
bool isSequential() const override
bool canReadLine() const override
KPtyDevice(QObject *parent=nullptr)
Constructor.
qint64 bytesToWrite() const override
bool open(int fd, OpenMode mode=ReadWrite|Unbuffered)
Open using an existing pty master.
bool open(OpenMode mode=ReadWrite|Unbuffered) override
Create a pty master/slave pair.
bool isSuspended() const
Returns true if the KPtyDevice is not monitoring the pty for incoming data.
void close() override
Close the pty master/slave pair.
bool atEnd() const override
~KPtyDevice() override
Destructor:
Provides primitives for opening & closing a pseudo TTY pair, assigning the controlling TTY,...
Definition kpty.h:26