TSDuck v3.45-4766
MPEG Transport Stream Toolkit
Loading...
Searching...
No Matches
ts::ReactiveTextStream Class Reference

Line-oriented Telnet-like connection for use in a Reactor environment. More...

#include <tsReactiveTextStream.h>

Inheritance diagram for ts::ReactiveTextStream:
Collaboration diagram for ts::ReactiveTextStream:

Public Member Functions

 ReactiveTextStream (ReactiveStream &stream, const std::string &eol=TextStream::DEFAULT_EOL)
 Constructor.
 
virtual ~ReactiveTextStream () override
 Destructor.
 
void setEOL (const std::string &eol)
 Set a new end-of-line sequence for output lines.
 
bool startReadText (ReactiveTextStreamHandlerInterface *handler, size_t buffer_size=ReactiveStream::DEFAULT_RECEIVE_BUFFER_SIZE, const ObjectPtr &user_data=ObjectPtr())
 Start the operation of receiving messages from the socket.
 
bool startWriteLine (ReactiveTextStreamHandlerInterface *handler, const std::string &line, bool flush=true, const ObjectPtr &user_data=ObjectPtr())
 Start the operation of sending a line of text over the stream device.
 
bool startWriteLine (ReactiveTextStreamHandlerInterface *handler, const UString &line, bool flush=true, const ObjectPtr &user_data=ObjectPtr())
 Start the operation of sending a line of text over the stream device.
 
bool startWriteText (ReactiveTextStreamHandlerInterface *handler, const std::string &text, bool flush=true, const ObjectPtr &user_data=ObjectPtr())
 Start the operation of sending text over the stream device.
 
bool startWriteText (ReactiveTextStreamHandlerInterface *handler, const UString &text, bool flush=true, const ObjectPtr &user_data=ObjectPtr())
 Start the operation of sending text over the stream device.
 
ReactiveStreamstream ()
 Get a reference to the associated reactive stream device.
 

Detailed Description

Line-oriented Telnet-like connection for use in a Reactor environment.

The class ReactiveTextStream is a wrapper around ReactiveStream to handle reactive I/O.

Constructor & Destructor Documentation

◆ ReactiveTextStream()

ts::ReactiveTextStream::ReactiveTextStream ( ReactiveStream stream,
const std::string &  eol = TextStream::DEFAULT_EOL 
)
explicit

Constructor.

Parameters
[in,out]streamAssociated stream device. The device object must remain valid as long as this object is valid.
[in]eolEnd-of-file sequence to send at end of each line. Input is auto-adaptive: a line is always read up to a LF character and all previous CR characters are discarded.

Member Function Documentation

◆ setEOL()

void ts::ReactiveTextStream::setEOL ( const std::string &  eol)
inline

Set a new end-of-line sequence for output lines.

Input is auto-adaptive: a line is always read up to a LF character and all previous CR characters are discarded.

Parameters
[in]eolEnd-of-file sequence to send at end of each line.

◆ stream()

ReactiveStream & ts::ReactiveTextStream::stream ( )
inline

Get a reference to the associated reactive stream device.

Returns
A reference to the associated reactive stream device.

◆ startWriteLine() [1/2]

bool ts::ReactiveTextStream::startWriteLine ( ReactiveTextStreamHandlerInterface handler,
const std::string &  line,
bool  flush = true,
const ObjectPtr user_data = ObjectPtr() 
)

Start the operation of sending a line of text over the stream device.

Parameters
[in]handlerHandler class to call when the write operation is complete. Ignored when flush is false.
[in]lineText line to send. The corresponding memory area is no longer used upon return. An end-of-line marker is automatically added.
[in]flushIf false, data are buffered into the ReactiveTextStream and no completion handler will be called. When true, all previously buffered data are sent with data from this call.
[in]user_dataA shared pointer which will be passed unmodified to handler.
Returns
True on success, false on error. Success means that the I/O was successfully started.

◆ startWriteLine() [2/2]

bool ts::ReactiveTextStream::startWriteLine ( ReactiveTextStreamHandlerInterface handler,
const UString line,
bool  flush = true,
const ObjectPtr user_data = ObjectPtr() 
)

Start the operation of sending a line of text over the stream device.

Parameters
[in]handlerHandler class to call when the write operation is complete. Ignored when flush is false.
[in]lineText line to send. The corresponding memory area is no longer used upon return. An end-of-line marker is automatically added.
[in]flushIf false, data are buffered into the ReactiveTextStream and no completion handler will be called. When true, all previously buffered data are sent with data from this call.
[in]user_dataA shared pointer which will be passed unmodified to handler.
Returns
True on success, false on error. Success means that the I/O was successfully started.

◆ startWriteText() [1/2]

bool ts::ReactiveTextStream::startWriteText ( ReactiveTextStreamHandlerInterface handler,
const std::string &  text,
bool  flush = true,
const ObjectPtr user_data = ObjectPtr() 
)

Start the operation of sending text over the stream device.

Parameters
[in]handlerHandler class to call when the write operation is complete. Ignored when flush is false.
[in]textText to send. The corresponding memory area is no longer used upon return. No end-of-line marker is added.
[in]flushIf false, data are buffered into the ReactiveTextStream and no completion handler will be called. When true, all previously buffered data are sent with data from this call.
[in]user_dataA shared pointer which will be passed unmodified to handler.
Returns
True on success, false on error. Success means that the I/O was successfully started.

◆ startWriteText() [2/2]

bool ts::ReactiveTextStream::startWriteText ( ReactiveTextStreamHandlerInterface handler,
const UString text,
bool  flush = true,
const ObjectPtr user_data = ObjectPtr() 
)

Start the operation of sending text over the stream device.

Parameters
[in]handlerHandler class to call when the write operation is complete. Ignored when flush is false.
[in]textText to send. The corresponding memory area is no longer used upon return. No end-of-line marker is added.
[in]flushIf false, data are buffered into the ReactiveTextStream and no completion handler will be called. When true, all previously buffered data are sent with data from this call.
[in]user_dataA shared pointer which will be passed unmodified to handler.
Returns
True on success, false on error. Success means that the I/O was successfully started.

◆ startReadText()

bool ts::ReactiveTextStream::startReadText ( ReactiveTextStreamHandlerInterface handler,
size_t  buffer_size = ReactiveStream::DEFAULT_RECEIVE_BUFFER_SIZE,
const ObjectPtr user_data = ObjectPtr() 
)

Start the operation of receiving messages from the socket.

Parameters
[in]handlerHandler class to call each time a text line is received. The method handleTextLine() will be called on each received line. Cannot be null. If a previous receive handler was registered, it is replaced.
[in]buffer_sizeSize of input buffers to receive data.
[in]user_dataA shared pointer which will be passed unmodified to handler.
Returns
True on success, false on error. Success means that the I/O was successfully started. The final status of the I/O will be transmitted in the handler.

The documentation for this class was generated from the following file: