2013-12-03 19:52:41 +01:00
|
|
|
/*
|
|
|
|
* Created by Phil on 2/12/2013.
|
|
|
|
* Copyright 2013 Two Blue Cubes Ltd. All rights reserved.
|
|
|
|
*
|
|
|
|
* Distributed under the Boost Software License, Version 1.0. (See accompanying
|
|
|
|
* file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
#ifndef TWOBLUECUBES_CATCH_STREAM_H_INCLUDED
|
|
|
|
#define TWOBLUECUBES_CATCH_STREAM_H_INCLUDED
|
|
|
|
|
2015-09-29 20:21:08 +02:00
|
|
|
#include "catch_compiler_capabilities.h"
|
|
|
|
#include "catch_streambuf.h"
|
2013-12-03 19:52:41 +01:00
|
|
|
|
2015-09-29 20:21:08 +02:00
|
|
|
#include <streambuf>
|
|
|
|
#include <ostream>
|
|
|
|
#include <fstream>
|
2016-11-28 15:47:20 +01:00
|
|
|
#include <memory>
|
2013-12-03 19:52:41 +01:00
|
|
|
|
|
|
|
namespace Catch {
|
|
|
|
|
2015-09-29 20:21:08 +02:00
|
|
|
std::ostream& cout();
|
|
|
|
std::ostream& cerr();
|
2017-08-09 15:28:40 +02:00
|
|
|
std::ostream& clog();
|
2015-09-29 20:21:08 +02:00
|
|
|
|
2015-11-04 19:01:28 +01:00
|
|
|
|
2015-09-29 20:21:08 +02:00
|
|
|
struct IStream {
|
|
|
|
virtual ~IStream() CATCH_NOEXCEPT;
|
|
|
|
virtual std::ostream& stream() const = 0;
|
|
|
|
};
|
|
|
|
|
|
|
|
class FileStream : public IStream {
|
|
|
|
mutable std::ofstream m_ofs;
|
2013-12-03 19:52:41 +01:00
|
|
|
public:
|
2015-09-29 20:21:08 +02:00
|
|
|
FileStream( std::string const& filename );
|
2015-11-03 18:37:43 +01:00
|
|
|
virtual ~FileStream() CATCH_NOEXCEPT;
|
2015-09-29 20:21:08 +02:00
|
|
|
public: // IStream
|
|
|
|
virtual std::ostream& stream() const CATCH_OVERRIDE;
|
|
|
|
};
|
2015-11-04 19:01:28 +01:00
|
|
|
|
2013-12-03 19:52:41 +01:00
|
|
|
|
2015-09-29 20:21:08 +02:00
|
|
|
class CoutStream : public IStream {
|
|
|
|
mutable std::ostream m_os;
|
|
|
|
public:
|
|
|
|
CoutStream();
|
2015-11-03 18:37:43 +01:00
|
|
|
virtual ~CoutStream() CATCH_NOEXCEPT;
|
2013-12-03 19:52:41 +01:00
|
|
|
|
2015-09-29 20:21:08 +02:00
|
|
|
public: // IStream
|
|
|
|
virtual std::ostream& stream() const CATCH_OVERRIDE;
|
2013-12-03 19:52:41 +01:00
|
|
|
};
|
2014-10-02 20:08:19 +02:00
|
|
|
|
2015-11-04 19:01:28 +01:00
|
|
|
|
2015-09-29 20:21:08 +02:00
|
|
|
class DebugOutStream : public IStream {
|
2016-06-08 20:14:54 +02:00
|
|
|
CATCH_AUTO_PTR( StreamBufBase ) m_streamBuf;
|
2015-09-29 20:21:08 +02:00
|
|
|
mutable std::ostream m_os;
|
|
|
|
public:
|
|
|
|
DebugOutStream();
|
2015-11-03 18:37:43 +01:00
|
|
|
virtual ~DebugOutStream() CATCH_NOEXCEPT;
|
2015-09-29 20:21:08 +02:00
|
|
|
|
|
|
|
public: // IStream
|
|
|
|
virtual std::ostream& stream() const CATCH_OVERRIDE;
|
|
|
|
};
|
2013-12-03 19:52:41 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif // TWOBLUECUBES_CATCH_STREAM_H_INCLUDED
|