annotate DEPENDENCIES/generic/include/boost/iostreams/stream.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_HPP_INCLUDED
Chris@16 9 #define BOOST_IOSTREAMS_STREAM_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 <boost/iostreams/constants.hpp>
Chris@16 16 #include <boost/iostreams/detail/char_traits.hpp>
Chris@16 17 #include <boost/iostreams/detail/config/overload_resolution.hpp>
Chris@16 18 #include <boost/iostreams/detail/forward.hpp>
Chris@16 19 #include <boost/iostreams/detail/iostream.hpp> // standard streams.
Chris@16 20 #include <boost/iostreams/detail/select.hpp>
Chris@16 21 #include <boost/iostreams/stream_buffer.hpp>
Chris@16 22 #include <boost/mpl/and.hpp>
Chris@16 23 #include <boost/type_traits/is_convertible.hpp>
Chris@16 24 #include <boost/utility/base_from_member.hpp>
Chris@16 25
Chris@16 26 namespace boost { namespace iostreams { namespace detail {
Chris@16 27
Chris@16 28 template<typename Device, typename Tr>
Chris@16 29 struct stream_traits {
Chris@16 30 typedef typename char_type_of<Device>::type char_type;
Chris@16 31 typedef Tr traits_type;
Chris@16 32 typedef typename category_of<Device>::type mode;
Chris@16 33 typedef typename
Chris@16 34 iostreams::select< // Disambiguation required for Tru64.
Chris@16 35 mpl::and_<
Chris@16 36 is_convertible<mode, input>,
Chris@16 37 is_convertible<mode, output>
Chris@16 38 >,
Chris@16 39 BOOST_IOSTREAMS_BASIC_IOSTREAM(char_type, traits_type),
Chris@16 40 is_convertible<mode, input>,
Chris@16 41 BOOST_IOSTREAMS_BASIC_ISTREAM(char_type, traits_type),
Chris@16 42 else_,
Chris@16 43 BOOST_IOSTREAMS_BASIC_OSTREAM(char_type, traits_type)
Chris@16 44 >::type stream_type;
Chris@16 45 typedef typename
Chris@16 46 iostreams::select< // Disambiguation required for Tru64.
Chris@16 47 mpl::and_<
Chris@16 48 is_convertible<mode, input>,
Chris@16 49 is_convertible<mode, output>
Chris@16 50 >,
Chris@16 51 iostream_tag,
Chris@16 52 is_convertible<mode, input>,
Chris@16 53 istream_tag,
Chris@16 54 else_,
Chris@16 55 ostream_tag
Chris@16 56 >::type stream_tag;
Chris@16 57 };
Chris@16 58
Chris@16 59 // By encapsulating initialization in a base, we can define the macro
Chris@16 60 // BOOST_IOSTREAMS_DEFINE_FORWARDING_FUNCTIONS to generate constructors
Chris@16 61 // without base member initializer lists.
Chris@16 62 template< typename Device,
Chris@16 63 typename Tr =
Chris@16 64 BOOST_IOSTREAMS_CHAR_TRAITS(
Chris@16 65 BOOST_DEDUCED_TYPENAME char_type_of<Device>::type
Chris@16 66 ),
Chris@16 67 typename Alloc =
Chris@16 68 std::allocator<
Chris@16 69 BOOST_DEDUCED_TYPENAME char_type_of<Device>::type
Chris@16 70 >,
Chris@16 71 typename Base = // VC6 Workaround.
Chris@16 72 BOOST_DEDUCED_TYPENAME
Chris@16 73 detail::stream_traits<Device, Tr>::stream_type >
Chris@16 74 class stream_base
Chris@16 75 : protected base_from_member< stream_buffer<Device, Tr, Alloc> >,
Chris@16 76 public Base
Chris@16 77 {
Chris@16 78 private:
Chris@16 79 typedef base_from_member< stream_buffer<Device, Tr, Alloc> > pbase_type;
Chris@16 80 typedef typename stream_traits<Device, Tr>::stream_type stream_type;
Chris@16 81 protected:
Chris@16 82 using pbase_type::member; // Avoid warning about 'this' in initializer list.
Chris@16 83 public:
Chris@16 84 stream_base() : pbase_type(), stream_type(&member) { }
Chris@16 85 };
Chris@16 86
Chris@16 87 } } } // End namespaces detail, iostreams, boost.
Chris@16 88
Chris@16 89 #ifdef BOOST_IOSTREAMS_BROKEN_OVERLOAD_RESOLUTION
Chris@16 90 # include <boost/iostreams/detail/broken_overload_resolution/stream.hpp>
Chris@16 91 #else
Chris@16 92
Chris@16 93 namespace boost { namespace iostreams {
Chris@16 94
Chris@16 95 //
Chris@16 96 // Template name: stream.
Chris@16 97 // Description: A iostream which reads from and writes to an instance of a
Chris@16 98 // designated device type.
Chris@16 99 // Template parameters:
Chris@16 100 // Device - A device type.
Chris@16 101 // Alloc - The allocator type.
Chris@16 102 //
Chris@16 103 template< typename Device,
Chris@16 104 typename Tr =
Chris@16 105 BOOST_IOSTREAMS_CHAR_TRAITS(
Chris@16 106 BOOST_DEDUCED_TYPENAME char_type_of<Device>::type
Chris@16 107 ),
Chris@16 108 typename Alloc =
Chris@16 109 std::allocator<
Chris@16 110 BOOST_DEDUCED_TYPENAME char_type_of<Device>::type
Chris@16 111 > >
Chris@16 112 struct stream : detail::stream_base<Device, Tr, Alloc> {
Chris@16 113 public:
Chris@16 114 typedef typename char_type_of<Device>::type char_type;
Chris@16 115 struct category
Chris@16 116 : mode_of<Device>::type,
Chris@16 117 closable_tag,
Chris@16 118 detail::stream_traits<Device, Tr>::stream_tag
Chris@16 119 { };
Chris@16 120 BOOST_IOSTREAMS_STREAMBUF_TYPEDEFS(Tr)
Chris@16 121 private:
Chris@16 122 typedef typename
Chris@16 123 detail::stream_traits<
Chris@16 124 Device, Tr
Chris@16 125 >::stream_type stream_type;
Chris@16 126 public:
Chris@16 127 stream() { }
Chris@16 128 BOOST_IOSTREAMS_FORWARD( stream, open_impl, Device,
Chris@16 129 BOOST_IOSTREAMS_PUSH_PARAMS,
Chris@16 130 BOOST_IOSTREAMS_PUSH_ARGS )
Chris@16 131 bool is_open() const { return this->member.is_open(); }
Chris@16 132 void close() { this->member.close(); }
Chris@16 133 bool auto_close() const { return this->member.auto_close(); }
Chris@16 134 void set_auto_close(bool close) { this->member.set_auto_close(close); }
Chris@16 135 bool strict_sync() { return this->member.strict_sync(); }
Chris@16 136 Device& operator*() { return *this->member; }
Chris@16 137 Device* operator->() { return &*this->member; }
Chris@16 138 Device* component() { return this->member.component(); }
Chris@16 139 private:
Chris@16 140 void open_impl(const Device& dev BOOST_IOSTREAMS_PUSH_PARAMS()) // For forwarding.
Chris@16 141 {
Chris@16 142 this->clear();
Chris@16 143 this->member.open(dev BOOST_IOSTREAMS_PUSH_ARGS());
Chris@16 144 }
Chris@16 145 };
Chris@16 146
Chris@16 147 } } // End namespaces iostreams, boost.
Chris@16 148
Chris@16 149 #endif // #ifdef BOOST_IOSTREAMS_BROKEN_OVERLOAD_RESOLUTION
Chris@16 150
Chris@16 151 #endif // #ifndef BOOST_IOSTREAMS_stream_HPP_INCLUDED