1 /* 2 * Created by Phil on 2/12/2013. 3 * Copyright 2013 Two Blue Cubes Ltd. All rights reserved. 4 * 5 * Distributed under the Boost Software License, Version 1.0. (See accompanying 6 * file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 7 * 8 */ 9 #ifndef TWOBLUECUBES_CATCH_STREAM_H_INCLUDED 10 #define TWOBLUECUBES_CATCH_STREAM_H_INCLUDED 11 12 #include "catch_compiler_capabilities.h" 13 #include "catch_streambuf.h" 14 15 #include <streambuf> 16 #include <ostream> 17 #include <fstream> 18 #include <memory> 19 20 namespace Catch { 21 22 std::ostream& cout(); 23 std::ostream& cerr(); 24 std::ostream& clog(); 25 26 27 struct IStream { 28 virtual ~IStream() CATCH_NOEXCEPT; 29 virtual std::ostream& stream() const = 0; 30 }; 31 32 class FileStream : public IStream { 33 mutable std::ofstream m_ofs; 34 public: 35 FileStream( std::string const& filename ); 36 virtual ~FileStream() CATCH_NOEXCEPT; 37 public: // IStream 38 virtual std::ostream& stream() const CATCH_OVERRIDE; 39 }; 40 41 42 class CoutStream : public IStream { 43 mutable std::ostream m_os; 44 public: 45 CoutStream(); 46 virtual ~CoutStream() CATCH_NOEXCEPT; 47 48 public: // IStream 49 virtual std::ostream& stream() const CATCH_OVERRIDE; 50 }; 51 52 53 class DebugOutStream : public IStream { 54 CATCH_AUTO_PTR( StreamBufBase ) m_streamBuf; 55 mutable std::ostream m_os; 56 public: 57 DebugOutStream(); 58 virtual ~DebugOutStream() CATCH_NOEXCEPT; 59 60 public: // IStream 61 virtual std::ostream& stream() const CATCH_OVERRIDE; 62 }; 63 } 64 65 #endif // TWOBLUECUBES_CATCH_STREAM_H_INCLUDED 66