annotate DEPENDENCIES/generic/include/boost/iostreams/stream_buffer.hpp @ 133:4acb5d8d80b6 tip

Don't fail environmental check if README.md exists (but .txt and no-suffix don't)
author Chris Cannam
date Tue, 30 Jul 2019 12:25:44 +0100
parents 2665513ce2d3
children
rev   line source
Chris@16 1 // (C) Copyright 2008 CodeRage, LLC (turkanis at coderage dot com)
Chris@16 2 // (C) Copyright 2003-2007 Jonathan Turkanis
Chris@16 3 // Distributed under the Boost Software License, Version 1.0. (See accompanying
Chris@16 4 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt.)
Chris@16 5
Chris@16 6 // See http://www.boost.org/libs/iostreams for documentation.
Chris@16 7
Chris@16 8 #ifndef BOOST_IOSTREAMS_STREAM_BUFFER_HPP_INCLUDED
Chris@16 9 #define BOOST_IOSTREAMS_STREAM_BUFFER_HPP_INCLUDED
Chris@16 10
Chris@16 11 #if defined(_MSC_VER) && (_MSC_VER >= 1020)
Chris@16 12 # pragma once
Chris@16 13 #endif
Chris@16 14
Chris@16 15 #include <memory> // allocator.
Chris@16 16 #include <boost/config.hpp> // BOOST_DEDUCED_TYPENAME.
Chris@16 17 #include <boost/iostreams/detail/char_traits.hpp>
Chris@16 18 #include <boost/iostreams/detail/config/overload_resolution.hpp>
Chris@16 19 #include <boost/iostreams/detail/forward.hpp>
Chris@16 20 #include <boost/iostreams/detail/ios.hpp> // failure, streamsize.
Chris@16 21 #include <boost/iostreams/detail/streambuf/direct_streambuf.hpp>
Chris@16 22 #include <boost/iostreams/detail/streambuf/indirect_streambuf.hpp>
Chris@16 23 #include <boost/iostreams/traits.hpp>
Chris@16 24 #include <boost/static_assert.hpp>
Chris@16 25 #include <boost/throw_exception.hpp>
Chris@16 26 #include <boost/type_traits/is_convertible.hpp>
Chris@16 27
Chris@16 28 // Must come last.
Chris@16 29 #include <boost/iostreams/detail/config/disable_warnings.hpp> // MSVC.
Chris@16 30
Chris@16 31 namespace boost { namespace iostreams { namespace detail {
Chris@16 32
Chris@16 33 template<typename T, typename Tr, typename Alloc, typename Mode>
Chris@16 34 struct stream_buffer_traits {
Chris@16 35 typedef typename
Chris@16 36 mpl::if_<
Chris@16 37 is_convertible<
Chris@16 38 BOOST_DEDUCED_TYPENAME category_of<T>::type,
Chris@16 39 direct_tag
Chris@16 40 >,
Chris@16 41 direct_streambuf<T, Tr>,
Chris@16 42 indirect_streambuf<T, Tr, Alloc, Mode>
Chris@16 43 >::type type;
Chris@16 44 };
Chris@16 45
Chris@16 46 } } } // End namespaces detail, iostreams, boost
Chris@16 47
Chris@16 48 #ifdef BOOST_IOSTREAMS_BROKEN_OVERLOAD_RESOLUTION
Chris@16 49 # include <boost/iostreams/detail/broken_overload_resolution/stream_buffer.hpp>
Chris@16 50 #else
Chris@16 51
Chris@16 52 namespace boost { namespace iostreams {
Chris@16 53
Chris@16 54 template< typename T,
Chris@16 55 typename Tr =
Chris@16 56 BOOST_IOSTREAMS_CHAR_TRAITS(
Chris@16 57 BOOST_DEDUCED_TYPENAME char_type_of<T>::type
Chris@16 58 ),
Chris@16 59 typename Alloc =
Chris@16 60 std::allocator<
Chris@16 61 BOOST_DEDUCED_TYPENAME char_type_of<T>::type
Chris@16 62 >,
Chris@16 63 typename Mode = BOOST_DEDUCED_TYPENAME mode_of<T>::type >
Chris@16 64 class stream_buffer
Chris@16 65 : public detail::stream_buffer_traits<T, Tr, Alloc, Mode>::type
Chris@16 66 {
Chris@16 67 private:
Chris@16 68 BOOST_STATIC_ASSERT((
Chris@16 69 is_convertible<
Chris@16 70 BOOST_DEDUCED_TYPENAME iostreams::category_of<T>::type, Mode
Chris@16 71 >::value
Chris@16 72 ));
Chris@16 73 typedef typename
Chris@16 74 detail::stream_buffer_traits<
Chris@16 75 T, Tr, Alloc, Mode
Chris@16 76 >::type base_type;
Chris@16 77 public:
Chris@16 78 typedef typename char_type_of<T>::type char_type;
Chris@16 79 struct category
Chris@16 80 : Mode,
Chris@16 81 closable_tag,
Chris@16 82 streambuf_tag
Chris@16 83 { };
Chris@16 84 BOOST_IOSTREAMS_STREAMBUF_TYPEDEFS(Tr)
Chris@16 85 public:
Chris@16 86 stream_buffer() { }
Chris@16 87 ~stream_buffer()
Chris@16 88 {
Chris@16 89 try {
Chris@16 90 if (this->is_open() && this->auto_close())
Chris@16 91 this->close();
Chris@16 92 } catch (...) { }
Chris@16 93 }
Chris@16 94 BOOST_IOSTREAMS_FORWARD( stream_buffer, open_impl, T,
Chris@16 95 BOOST_IOSTREAMS_PUSH_PARAMS,
Chris@16 96 BOOST_IOSTREAMS_PUSH_ARGS )
Chris@16 97 T& operator*() { return *this->component(); }
Chris@16 98 T* operator->() { return this->component(); }
Chris@16 99 private:
Chris@16 100 void open_impl(const T& t BOOST_IOSTREAMS_PUSH_PARAMS())
Chris@16 101 { // Used for forwarding.
Chris@16 102 if (this->is_open())
Chris@16 103 boost::throw_exception(
Chris@16 104 BOOST_IOSTREAMS_FAILURE("already open")
Chris@16 105 );
Chris@16 106 base_type::open(t BOOST_IOSTREAMS_PUSH_ARGS());
Chris@16 107 }
Chris@16 108 };
Chris@16 109
Chris@16 110 } } // End namespaces iostreams, boost.
Chris@16 111
Chris@16 112 #endif // #ifdef BOOST_IOSTREAMS_BROKEN_OVERLOAD_RESOLUTION
Chris@16 113
Chris@16 114 #include <boost/iostreams/detail/config/enable_warnings.hpp> // MSVC.
Chris@16 115
Chris@16 116 #endif // #ifndef BOOST_IOSTREAMS_STREAM_BUFFER_HPP_INCLUDED