Celeritas
0.5.0-56+6b053cd
|
Redirect the given stream to an internal stringstream. More...
#include <ScopedStreamRedirect.hh>
Public Member Functions | |
ScopedStreamRedirect (std::ostream *os) | |
Construct with pointer to a stream such as cout. | |
~ScopedStreamRedirect () | |
Restore stream on destruction. | |
std::string | str () |
Get redirected output with trailing whitespaces removed. More... | |
std::stringstream & | get () |
Get the raw stream after flushing the input. More... | |
CELER_DELETE_COPY_MOVE (ScopedStreamRedirect) | |
Static Public Member Functions | |
static bool | allow_redirect () |
Whether signal handling is enabled. | |
Redirect the given stream to an internal stringstream.
This is primarily for interfacing with poorly-behaved external libraries that write to cout/cerr by default.
The environment variable CELER_DISABLE_REDIRECT
will prevent stream redirection, which might be needed if the code segfaults/aborts before this class's destructor is reached.
celeritas::ScopedStreamRedirect::CELER_DELETE_COPY_MOVE | ( | ScopedStreamRedirect | ) |
Prevent copying and moving for RAII class
std::stringstream & celeritas::ScopedStreamRedirect::get | ( | ) |
Get the raw stream after flushing the input.
If redirection is disabled, this will be an empty stream.
std::string celeritas::ScopedStreamRedirect::str | ( | ) |
Get redirected output with trailing whitespaces removed.
If redirection is disabled, this will be an empty string.