Async 1.8.0
|
A wrapper class for using a PTY. More...
#include <AsyncPty.h>
Public Member Functions | |
Pty (const std::string &slave_link="") | |
Constructor. | |
~Pty (void) | |
Destructor. | |
void | setLineBuffered (bool line_buffered) |
Turn line buffering on or off. | |
bool | open (void) |
Open the PTY. | |
void | close (void) |
Close the PTY if it's open. | |
bool | reopen (void) |
Reopen the PTY. | |
ssize_t | write (const void *buf, size_t count) |
Write data to the PTY. | |
ssize_t | write (const std::string &str) |
Write a string to the PTY. | |
bool | isOpen (void) const |
Check if the PTY is open or not. | |
const std::string & | slavePath (void) const |
Get the path to the slave PTS device. | |
Public Attributes | |
sigc::signal< void, const void *, size_t > | dataReceived |
Signal that is emitted when data has been received. | |
A wrapper class for using a PTY.
This class wrap up some functionality that is nice to have when using a PTY.
The PTY is opened in raw mode.
If the slave end of the PTY is not open, the master file descriptor will be continuously polled to detect when it is opened. When the slave end of the PTY is open, an FdWatch will be used to check for activity instead of polling.
Data written to the master end will be discarded if the slave end is not open.
Definition at line 124 of file AsyncPty.h.
Async::Pty::Pty | ( | const std::string & | slave_link = "" | ) |
Constructor.
slave_link | Path to the slave softlink |
Async::Pty::~Pty | ( | void | ) |
Destructor.
void Async::Pty::close | ( | void | ) |
Close the PTY if it's open.
Close the PTY if it's open. This function is safe to call even if the PTY is not open or if it's just partly opened.
|
inline |
Check if the PTY is open or not.
Definition at line 208 of file AsyncPty.h.
bool Async::Pty::open | ( | void | ) |
Open the PTY.
Use this function to open the PTY. If the PTY is already open it will be closed first.
bool Async::Pty::reopen | ( | void | ) |
Reopen the PTY.
Try to reopen the PTY. On failure an error message will be printed and the PTY will stay closed.
|
inline |
Turn line buffering on or off.
line_buffered | Set to be line buffered if true |
Definition at line 142 of file AsyncPty.h.
|
inline |
Get the path to the slave PTS device.
Definition at line 214 of file AsyncPty.h.
|
inline |
Write a string to the PTY.
str | A string to write |
Use this function to write a string to the PTY. If the slave end of the PTY is not open, the written string will just be discarded and the string length is used as the return value.
Definition at line 199 of file AsyncPty.h.
References write().
ssize_t Async::Pty::write | ( | const void * | buf, |
size_t | count ) |
Write data to the PTY.
buf | A buffer containing the data to write |
count | The number of bytes to write |
Use this function to write data to the PTY. If the slave end of the PTY is not open, the written data will just be discarded and count is used as the return value.
Referenced by write().
sigc::signal<void, const void*, size_t> Async::Pty::dataReceived |
Signal that is emitted when data has been received.
buf | A buffer containing the received data |
count | The number of bytes in the buffer |
Definition at line 221 of file AsyncPty.h.