yat
0.20.3pre
|
Redirect a stream to another stream. More...
#include <yat/utility/StreamRedirect.h>
Public Member Functions | |
BasicStreamRedirect (std::basic_istream< charT, traits > &is1, std::basic_istream< charT, traits > &is2, bool active=true) | |
redirect istream to another istream More... | |
BasicStreamRedirect (std::basic_istream< charT, traits > &is, const std::string &file, bool active=true) | |
redirect istream to ifstream. More... | |
BasicStreamRedirect (std::basic_ostream< charT, traits > &os1, std::basic_ostream< charT, traits > &os2, bool active=true) | |
redirect ostream to another ostream More... | |
BasicStreamRedirect (std::basic_ostream< charT, traits > &os, const std::string &file, bool active=true) | |
redirect ostream to ofstream. More... | |
~BasicStreamRedirect (void) | |
Destructor - resets the redirect. More... | |
Redirect a stream to another stream.
This class can be used to redirect a stream so it uses the buffer of another stream. This another stream is either a stream provided by the caller or if the caller provide a string the an internal fstream is created. In the destructor the stream is restored to use its own buffer. See documentation of CommandLine for an example of usage.
theplu::yat::utility::BasicStreamRedirect< charT, traits >::BasicStreamRedirect | ( | std::basic_istream< charT, traits > & | is1, |
std::basic_istream< charT, traits > & | is2, | ||
bool | active = true |
||
) |
redirect istream to another istream
is1 is redirected to get its input from the buffer of is2 (rather than its own buffer). A reference to is1 and its buffer is stored, so is1 can be restored in the destructor.
If active is false, the class does nothing.
theplu::yat::utility::BasicStreamRedirect< charT, traits >::BasicStreamRedirect | ( | std::basic_istream< charT, traits > & | is, |
const std::string & | file, | ||
bool | active = true |
||
) |
redirect istream to ifstream.
An ifstream with path file is created, and is is redirected to get its input from the buffer of this ifstream.
If active is false, the class does nothing.
theplu::yat::utility::BasicStreamRedirect< charT, traits >::BasicStreamRedirect | ( | std::basic_ostream< charT, traits > & | os1, |
std::basic_ostream< charT, traits > & | os2, | ||
bool | active = true |
||
) |
redirect ostream to another ostream
os1 is redirected to send its output to the buffer of os2 (rather than its own buffer). A reference to os1 and its buffer is stored, so os1 can be restored in the destructor.
If active is false, the class does nothing.
theplu::yat::utility::BasicStreamRedirect< charT, traits >::BasicStreamRedirect | ( | std::basic_ostream< charT, traits > & | os, |
const std::string & | file, | ||
bool | active = true |
||
) |
redirect ostream to ofstream.
An ofstream with path file is created, and os is redirected to send its output to the buffer of this ofstream.
If active is false, the class does nothing.
theplu::yat::utility::BasicStreamRedirect< charT, traits >::~BasicStreamRedirect | ( | void | ) |
Destructor - resets the redirect.
The stream (first argument in constructor) is restored to use its original buffer.