![]() |
TSDuck v3.46-4930
MPEG Transport Stream Toolkit
|
#include <tsTextStream.h>


Public Member Functions | |
| TextStream (StreamInterface &stream, const std::string &eol=DEFAULT_EOL, const std::string &prompt=std::string()) | |
| bool | debug () const |
| template<class... Args> | |
| void | debug (const UChar *fmt, Args &&... args) |
| void | debug (const UChar *msg) |
| template<class... Args> | |
| void | debug (const UString &fmt, Args &&... args) |
| void | debug (const UString &msg) |
| Report * | delegateReport (Report *report) |
| template<class... Args> | |
| void | error (const UChar *fmt, Args &&... args) |
| void | error (const UChar *msg) |
| template<class... Args> | |
| void | error (const UString &fmt, Args &&... args) |
| void | error (const UString &msg) |
| template<class... Args> | |
| void | fatal (const UChar *fmt, Args &&... args) |
| void | fatal (const UChar *msg) |
| template<class... Args> | |
| void | fatal (const UString &fmt, Args &&... args) |
| void | fatal (const UString &msg) |
| void | getAndFlush (ByteBlock &data) |
| bool | gotErrors () const |
| template<class... Args> | |
| void | info (const UChar *fmt, Args &&... args) |
| void | info (const UChar *msg) |
| template<class... Args> | |
| void | info (const UString &fmt, Args &&... args) |
| void | info (const UString &msg) |
| template<class... Args> | |
| void | log (int severity, const UChar *fmt, Args &&... args) |
| template<class... Args> | |
| void | log (int severity, const UString &fmt, Args &&... args) |
| void | log (int severity, const UString &msg) |
| int | maxSeverity () const |
| void | raiseMaxSeverity (int level) |
| bool | readLine (std::string &line, const AbortInterface *abort=nullptr) |
| bool | readLine (UString &line, const AbortInterface *abort=nullptr) |
| bool | readText (std::string &data, const AbortInterface *abort=nullptr) |
| bool | readText (UString &data, const AbortInterface *abort=nullptr) |
| UString | reportPrefix () const |
| void | reset () |
| void | resetErrors () |
| void | setEOL (const std::string &eol) |
| void | setMaxSeverity (int level) |
| void | setReportPrefix (const UString &prefix) |
| template<class... Args> | |
| void | severe (const UChar *fmt, Args &&... args) |
| void | severe (const UChar *msg) |
| template<class... Args> | |
| void | severe (const UString &fmt, Args &&... args) |
| void | severe (const UString &msg) |
| StreamInterface & | stream () |
| bool | verbose () const |
| template<class... Args> | |
| void | verbose (const UChar *fmt, Args &&... args) |
| void | verbose (const UChar *msg) |
| template<class... Args> | |
| void | verbose (const UString &fmt, Args &&... args) |
| void | verbose (const UString &msg) |
| bool | waitForPrompt (const AbortInterface *abort=nullptr) |
| template<class... Args> | |
| void | warning (const UChar *fmt, Args &&... args) |
| void | warning (const UChar *msg) |
| template<class... Args> | |
| void | warning (const UString &fmt, Args &&... args) |
| void | warning (const UString &msg) |
| bool | writeLine (const std::string &str) |
| bool | writeLine (const UString &str) |
| bool | writeText (const std::string &str) |
| bool | writeText (const UString &str) |
Static Public Attributes | |
| static const std::string | DEFAULT_EOL |
Protected Member Functions | |
| virtual void | writeLog (int severity, const UString &msg) override |
Implementation of a half-duplex line-oriented Telnet-like connection.
This class supports the communication with a half-duplex line-oriented Telnet-like server:
From the client point of view the interface must allow:
This class is also a subclass of Report, allowing it to be used to send log messages.
Although this class is typically used on a TCPConnection (or a subclass of it), it can be used on any class implementing StreamInterface. It the underlying device is not interactive (a file for instance), don't try to use a prompt of course.
|
explicit |
Constructor.
| [in,out] | stream | Associated stream device. The device object must remain valid as long as this object is valid. |
| [in] | eol | End-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. |
| [in] | prompt | Prompt string to send to the client. |
|
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.
| [in] | eol | End-of-file sequence to send at end of each line. |
|
inline |
Get a reference to the associated stream device.
|
inline |
Reset the internal buffer.
If the underlying stream device is reused for several connections or session, reset() should be called each time a new connection is established. Otherwise, the new connection would reuse unread bytes from the previous connection.
Note that if the stream device is a TCPConnection or a subclass of it, the reset is automatically performed when the socket connects or disconnects.
| bool ts::TextStream::writeText | ( | const std::string & | str | ) |
Send a string to the server.
| [in] | str | The string to writeText to the server. |
| bool ts::TextStream::writeText | ( | const UString & | str | ) |
Send a string to the server.
| [in] | str | The string to writeText to the server. |
| bool ts::TextStream::writeLine | ( | const std::string & | str | ) |
Send a text line to the server.
| [in] | str | The line to send to the server. |
| bool ts::TextStream::writeLine | ( | const UString & | str | ) |
Send a text line to the server.
| [in] | str | The line to send to the server. |
| bool ts::TextStream::readText | ( | std::string & | data, |
| const AbortInterface * | abort = nullptr ) |
Receive character data.
| [out] | data | The received data. |
| [in] | abort | If non-zero, invoked when I/O is interrupted (in case of user-interrupt, return, otherwise retry). |
| bool ts::TextStream::readText | ( | UString & | data, |
| const AbortInterface * | abort = nullptr ) |
Receive character data.
| [out] | data | The received data. |
| [in] | abort | If non-zero, invoked when I/O is interrupted (in case of user-interrupt, return, otherwise retry). |
| bool ts::TextStream::readLine | ( | std::string & | line, |
| const AbortInterface * | abort = nullptr ) |
Receive a line.
| [out] | line | The received line. |
| [in] | abort | If non-zero, invoked when I/O is interrupted (in case of user-interrupt, return, otherwise retry). |
| bool ts::TextStream::readLine | ( | UString & | line, |
| const AbortInterface * | abort = nullptr ) |
Receive a line.
| [out] | line | The received line. |
| [in] | abort | If non-zero, invoked when I/O is interrupted (in case of user-interrupt, return, otherwise retry). |
| bool ts::TextStream::waitForPrompt | ( | const AbortInterface * | abort = nullptr | ) |
Receive a prompt. Do not wait if the prompt is empty.
| [in] | abort | If non-zero, invoked when I/O is interrupted (in case of user-interrupt, return, otherwise retry). |
| void ts::TextStream::getAndFlush | ( | ByteBlock & | data | ) |
Get currently buffered input data and flush that buffer. This method is useful when TCP connection switches from text mode (Telnet protocol) to binary mode. The returned data are the start of the input binary data. The remaining data can be received using methods from the parent class TCPConnection.
| [out] | data | Currently buffered data. |
|
overrideprotectedvirtual |
Actual message reporting method. The method is called only when a message passed the severity filter. It is not necessary to recheck the maximum severity inside the method. By default, does nothing.
| [in] | severity | Message severity. |
| [in] | msg | Message text. |
Reimplemented from ts::Report.
|
inherited |
Set maximum severity level. Messages with higher severities are not reported.
| [in] | level | Set report to that level. |
|
inherited |
Raise maximum severity level. The severity can only be increased (more verbose, more debug), never decreased.
| [in] | level | Set report at least to that level. |
|
inlineinherited |
Get maximum severity level.
|
inlineinherited |
Check if errors (or worse) were reported through this object. Errors which were reported through delegated reports are ignored.
|
inlineinherited |
Reset the error indicator.
|
inlineinherited |
Set the prefix to display before each message.
| [in] | prefix | The prefix to prepend to all messages. |
|
inlineinherited |
Get the current prefix to display.
Delegate message logging to another report object.
| [in] | report | New report object to which messages are delegated. Use nullptr to remove the delegation and return to normal logging. |
|
inlineinherited |
Check if debugging is active.
|
inlineinherited |
Report a debug message.
| [in] | msg | Message line. |
|
inlineinherited |
Report a debug message.
| [in] | msg | Message line. |
|
inlineinherited |
Report a debug message with a printf-like interface.
| [in] | fmt | Format string with embedded '%' sequences. |
| [in] | args | List of arguments to substitute in the format string. |
|
inlineinherited |
Report a debug message with a printf-like interface.
| [in] | fmt | Format string with embedded '%' sequences. |
| [in] | args | List of arguments to substitute in the format string. |
|
inlineinherited |
Check if verbose reporting is active.
|
inlineinherited |
Report a verbose message.
| [in] | msg | Message line. |
|
inlineinherited |
Report a verbose message.
| [in] | msg | Message line. |
|
inlineinherited |
Report a verbose message with a printf-like interface.
| [in] | fmt | Format string with embedded '%' sequences. |
| [in] | args | List of arguments to substitute in the format string. |
|
inlineinherited |
Report a verbose message with a printf-like interface.
| [in] | fmt | Format string with embedded '%' sequences. |
| [in] | args | List of arguments to substitute in the format string. |
|
inherited |
Report a message with an explicit severity.
| [in] | severity | Message severity. |
| [in] | msg | Message line. |
|
inlineinherited |
Report a message with an explicit severity and a printf-like interface.
| [in] | severity | Message severity. |
| [in] | fmt | Format string with embedded '%' sequences. |
| [in] | args | List of arguments to substitute in the format string. |
|
inlineinherited |
Report a message with an explicit severity and a printf-like interface.
| [in] | severity | Message severity. |
| [in] | fmt | Format string with embedded '%' sequences. |
| [in] | args | List of arguments to substitute in the format string. |
|
inlineinherited |
Report a fatal error message.
| [in] | msg | Message line. |
|
inlineinherited |
Report a fatal error message.
| [in] | msg | Message line. |
|
inlineinherited |
Report a fatal error message with a printf-like interface.
| [in] | fmt | Format string with embedded '%' sequences. |
| [in] | args | List of arguments to substitute in the format string. |
|
inlineinherited |
Report a fatal error message with a printf-like interface.
| [in] | fmt | Format string with embedded '%' sequences. |
| [in] | args | List of arguments to substitute in the format string. |
|
inlineinherited |
Report a severe error message.
| [in] | msg | Message line. |
|
inlineinherited |
Report a severe error message.
| [in] | msg | Message line. |
|
inlineinherited |
Report a severe error message with a printf-like interface.
| [in] | fmt | Format string with embedded '%' sequences. |
| [in] | args | List of arguments to substitute in the format string. |
|
inlineinherited |
Report a severe error message with a printf-like interface.
| [in] | fmt | Format string with embedded '%' sequences. |
| [in] | args | List of arguments to substitute in the format string. |
|
inlineinherited |
Report an error message.
| [in] | msg | Message line. |
|
inlineinherited |
Report an error message.
| [in] | msg | Message line. |
|
inlineinherited |
Report an error message with a printf-like interface.
| [in] | fmt | Format string with embedded '%' sequences. |
| [in] | args | List of arguments to substitute in the format string. |
|
inlineinherited |
Report an error message with a printf-like interface.
| [in] | fmt | Format string with embedded '%' sequences. |
| [in] | args | List of arguments to substitute in the format string. |
|
inlineinherited |
Report a warning error message.
| [in] | msg | Message line. |
|
inlineinherited |
Report a warning error message.
| [in] | msg | Message line. |
|
inlineinherited |
Report a warning message with a printf-like interface.
| [in] | fmt | Format string with embedded '%' sequences. |
| [in] | args | List of arguments to substitute in the format string. |
|
inlineinherited |
Report a warning message with a printf-like interface.
| [in] | fmt | Format string with embedded '%' sequences. |
| [in] | args | List of arguments to substitute in the format string. |
|
inlineinherited |
Report an informational message.
| [in] | msg | Message line. |
|
inlineinherited |
Report an informational message.
| [in] | msg | Message line. |
|
inlineinherited |
Report an informational message with a printf-like interface.
| [in] | fmt | Format string with embedded '%' sequences. |
| [in] | args | List of arguments to substitute in the format string. |
|
inlineinherited |
Report an informational message with a printf-like interface.
| [in] | fmt | Format string with embedded '%' sequences. |
| [in] | args | List of arguments to substitute in the format string. |
|
static |
Default end-of-line sequence (CR-LF). The Telnet protocol defines CR-LF as end-of-line sequence.