|
Celeritas 0.7.0-dev.196+develop.8d0d9047c
|
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. | |
| std::stringstream & | get () |
| Get the raw stream after flushing the input. | |
| CELER_DELETE_COPY_MOVE (ScopedStreamRedirect) | |
Static Public Member Functions | |
| static bool | enabled () |
| 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.