TSDuck v3.40-3963
MPEG Transport Stream Toolkit
|
A class to redirect an output stream. More...
#include <tsOutputRedirector.h>
Public Member Functions | |
OutputRedirector (const fs::path &name, Args &args, std::ostream &stream=std::cout, std::ios::openmode mode=std::ios::binary) | |
Constructor, the output redirection is automatically started. | |
~OutputRedirector () | |
Destructor, the output redirection is terminated and restore the previous stream. | |
A class to redirect an output stream.
The constructor redirects a specific output stream (std::cout
by default) to a given file. The destructor automatically restores the previous output stream.
If the file name is empty, no redirection occurs, making this mechanism quite useful for optional redirection based on command line arguments.
ts::OutputRedirector::OutputRedirector | ( | const fs::path & | name, |
Args & | args, | ||
std::ostream & | stream = std::cout , |
||
std::ios::openmode | mode = std::ios::binary |
||
) |
Constructor, the output redirection is automatically started.
[in] | name | File name to which the output is redirected. If empty, the output stream stream is not redirected. |
[in,out] | args | Used to report errors and exit application on error. |
[in,out] | stream | The output stream to redirect, std::cout by default. |
[in,out] | mode | Mode to use to open the file, std::ios::binary by default. |