TSDuck v3.40-3963
MPEG Transport Stream Toolkit
Loading...
Searching...
No Matches
ts::OutputRedirector Class Reference

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.
 

Detailed Description

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.

Constructor & Destructor Documentation

◆ OutputRedirector()

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.

Parameters
[in]nameFile name to which the output is redirected. If empty, the output stream stream is not redirected.
[in,out]argsUsed to report errors and exit application on error.
[in,out]streamThe output stream to redirect, std::cout by default.
[in,out]modeMode to use to open the file, std::ios::binary by default.

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