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 <iosfwd> 13 #include <cstddef> 14 #include <ostream> 15 16 namespace Catch { 17 18 std::ostream& cout(); 19 std::ostream& cerr(); 20 std::ostream& clog(); 21 22 class StringRef; 23 24 struct IStream { 25 virtual ~IStream(); 26 virtual std::ostream& stream() const = 0; 27 }; 28 29 auto makeStream( StringRef const &filename ) -> IStream const*; 30 31 class ReusableStringStream { 32 std::size_t m_index; 33 std::ostream* m_oss; 34 public: 35 ReusableStringStream(); 36 ~ReusableStringStream(); 37 38 auto str() const -> std::string; 39 40 template<typename T> 41 auto operator << ( T const& value ) -> ReusableStringStream& { 42 *m_oss << value; 43 return *this; 44 } 45 auto get() -> std::ostream& { return *m_oss; } 46 }; 47 } 48 49 #endif // TWOBLUECUBES_CATCH_STREAM_H_INCLUDED 50