Class jac::Duplexify
A duplex stream that wraps an input and output stream.
#include <stream.h>
Inherits the following classes: jac::Duplex
Public Functions
Type | Name |
---|---|
Duplexify (std::unique_ptr< InputStream > in, std::unique_ptr< OutputStream > out) |
|
virtual bool | flush () override |
virtual int | get () override Get a single byte from the stream. |
virtual void | onData (std::function< void(void)>) override Register a callback to be called when data is available. |
virtual bool | put (uint8_t c) override Write a single byte to the stream. |
virtual size_t | read (std::span< uint8_t > data) override Read data from the stream. |
virtual size_t | write (std::span< const uint8_t > data) override Write a buffer to the stream. |
Public Functions inherited from jac::InputStream
See jac::InputStream
Type | Name |
---|---|
virtual int | get () = 0 Get a single byte from the stream. |
virtual void | onData (std::function< void(void)>) = 0 Register a callback to be called when data is available. |
virtual size_t | read (std::span< uint8_t > data) = 0 Read data from the stream. |
virtual | ~InputStream () = default |
Public Functions inherited from jac::OutputStream
Type | Name |
---|---|
virtual bool | flush () = 0 |
virtual bool | put (uint8_t c) = 0 Write a single byte to the stream. |
virtual size_t | write (std::span< const uint8_t > data) = 0 Write a buffer to the stream. |
virtual | ~OutputStream () = default |
Public Functions Documentation
function Duplexify
inline jac::Duplexify::Duplexify (
std::unique_ptr< InputStream > in,
std::unique_ptr< OutputStream > out
)
function flush
Implements jac::OutputStream::flush
function get
Get a single byte from the stream.
Note:
This method should not block.
Returns:
The byte or -1 if no data is available
Implements jac::InputStream::get
function onData
Register a callback to be called when data is available.
Note:
The callback will not be called in parallel.
Parameters:
onData
the callback
Implements jac::InputStream::onData
function put
Write a single byte to the stream.
Note:
This method should not block.
Parameters:
c
the byte
Returns:
true if the byte was written, false otherwise
Implements jac::OutputStream::put
function read
Read data from the stream.
Note:
This method should not block.
Parameters:
data
the buffer to read into
Returns:
The number of bytes read
Implements jac::InputStream::read
function write
Write a buffer to the stream.
Note:
This method should not block.
Parameters:
data
the buffer to write
Returns:
The number of bytes written
Implements jac::OutputStream::write
The documentation for this class was generated from the following file src/jac/link/stream.h