Files
Catch2/include/internal/catch_stream.h
T

65 lines
1.5 KiB
C++
Raw Normal View History

/*
* 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 19:21:08 +01:00
#include "catch_compiler_capabilities.h"
#include "catch_streambuf.h"
2015-09-29 19:21:08 +01:00
#include <streambuf>
#include <ostream>
#include <fstream>
#include <memory>
namespace Catch {
std::ostream& cout();
std::ostream& cerr();
2015-09-29 19:21:08 +01:00
2015-09-29 19:21:08 +01:00
struct IStream {
2017-04-25 12:41:30 +02:00
virtual ~IStream() noexcept;
2015-09-29 19:21:08 +01:00
virtual std::ostream& stream() const = 0;
};
class FileStream : public IStream {
mutable std::ofstream m_ofs;
public:
FileStream( std::string const& filename );
2017-04-25 12:41:30 +02:00
virtual ~FileStream() noexcept;
2015-09-29 19:21:08 +01:00
public: // IStream
2017-04-25 12:41:30 +02:00
virtual std::ostream& stream() const override;
2015-09-29 19:21:08 +01:00
};
2015-09-29 19:21:08 +01:00
class CoutStream : public IStream {
mutable std::ostream m_os;
public:
CoutStream();
2017-04-25 12:41:30 +02:00
virtual ~CoutStream() noexcept;
2015-09-29 19:21:08 +01:00
public: // IStream
2017-04-25 12:41:30 +02:00
virtual std::ostream& stream() const override;
2015-09-29 19:21:08 +01:00
};
2015-09-29 19:21:08 +01:00
class DebugOutStream : public IStream {
2017-04-25 12:41:30 +02:00
std::unique_ptr<StreamBufBase> m_streamBuf;
2015-09-29 19:21:08 +01:00
mutable std::ostream m_os;
public:
DebugOutStream();
2017-04-25 12:41:30 +02:00
virtual ~DebugOutStream() noexcept;
2015-09-29 19:21:08 +01:00
public: // IStream
2017-04-25 12:41:30 +02:00
virtual std::ostream& stream() const override;
2015-09-29 19:21:08 +01:00
};
}
#endif // TWOBLUECUBES_CATCH_STREAM_H_INCLUDED