File indexing completed on 2025-01-18 09:54:06
0001
0002
0003
0004
0005
0006
0007
0008 #ifndef CATCH_REUSABLE_STRING_STREAM_HPP_INCLUDED
0009 #define CATCH_REUSABLE_STRING_STREAM_HPP_INCLUDED
0010
0011 #include <catch2/internal/catch_noncopyable.hpp>
0012
0013 #include <iosfwd>
0014 #include <cstddef>
0015 #include <ostream>
0016 #include <string>
0017
0018 namespace Catch {
0019
0020 class ReusableStringStream : Detail::NonCopyable {
0021 std::size_t m_index;
0022 std::ostream* m_oss;
0023 public:
0024 ReusableStringStream();
0025 ~ReusableStringStream();
0026
0027
0028 std::string str() const;
0029
0030 void str(std::string const& str);
0031
0032 #if defined(__GNUC__) && !defined(__clang__)
0033 #pragma GCC diagnostic push
0034
0035 #pragma GCC diagnostic ignored "-Wpragmas"
0036
0037
0038
0039
0040 #pragma GCC diagnostic ignored "-Waddress"
0041 #pragma GCC diagnostic ignored "-Wnonnull-compare"
0042 #endif
0043
0044 template<typename T>
0045 auto operator << ( T const& value ) -> ReusableStringStream& {
0046 *m_oss << value;
0047 return *this;
0048 }
0049
0050 #if defined(__GNUC__) && !defined(__clang__)
0051 #pragma GCC diagnostic pop
0052 #endif
0053 auto get() -> std::ostream& { return *m_oss; }
0054 };
0055 }
0056
0057 #endif