ostream_buffer.hpp 925 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. // (C) Copyright 2013 Vicente J. Botet Escriba
  2. // Distributed under the Boost Software License, Version 1.0. (See
  3. // accompanying file LICENSE_1_0.txt or copy at
  4. // http://www.boost.org/LICENSE_1_0.txt)
  5. #ifndef BOOST_THREAD_OSTREAM_BUFFER_HPP
  6. #define BOOST_THREAD_OSTREAM_BUFFER_HPP
  7. #include <boost/thread/detail/config.hpp>
  8. #include <boost/thread/detail/delete.hpp>
  9. #include <sstream>
  10. #include <boost/config/abi_prefix.hpp>
  11. namespace boost
  12. {
  13. template <typename OStream>
  14. class ostream_buffer
  15. {
  16. public:
  17. typedef std::basic_ostringstream<typename OStream::char_type, typename OStream::traits_type> stream_type;
  18. ostream_buffer(OStream& os) :
  19. os_(os)
  20. {
  21. }
  22. ~ostream_buffer()
  23. {
  24. os_ << o_str_.str();
  25. }
  26. stream_type& stream()
  27. {
  28. return o_str_;
  29. }
  30. private:
  31. OStream& os_;
  32. stream_type o_str_;
  33. };
  34. }
  35. #include <boost/config/abi_suffix.hpp>
  36. #endif // header