catch_stream.h 1.2 KB

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