Refactored StreamRedirect classes

This commit is contained in:
Phil Nash
2017-12-05 23:19:28 +00:00
parent 7c5a21fb7d
commit aa9d635014
2 changed files with 43 additions and 50 deletions

View File

@@ -28,33 +28,6 @@ namespace Catch {
struct IMutableContext;
class StreamRedirect {
public:
StreamRedirect(std::ostream& stream, std::string& targetString);
~StreamRedirect();
private:
std::ostream& m_stream;
std::streambuf* m_prevBuf;
ReusableStringStream m_oss;
std::string& m_targetString;
};
// StdErr has two constituent streams in C++, std::cerr and std::clog
// This means that we need to redirect 2 streams into 1 to keep proper
// order of writes and cannot use StreamRedirect on its own
class StdErrRedirect {
public:
explicit StdErrRedirect( std::string& targetString );
~StdErrRedirect();
private:
std::streambuf* m_cerrBuf;
std::streambuf* m_clogBuf;
ReusableStringStream m_oss;
std::string& m_targetString;
};
///////////////////////////////////////////////////////////////////////////
class RunContext : public IResultCapture, public IRunner {