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