Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:38:54

0001 // (C) Copyright 2008 CodeRage, LLC (turkanis at coderage dot com)
0002 // (C) Copyright 2003-2007 Jonathan Turkanis
0003 // Distributed under the Boost Software License, Version 1.0. (See accompanying
0004 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt.)
0005 
0006 // See http://www.boost.org/libs/iostreams for documentation.
0007 
0008 #ifndef BOOST_IOSTREAMS_STREAM_HPP_INCLUDED
0009 #define BOOST_IOSTREAMS_STREAM_HPP_INCLUDED
0010 
0011 #if defined(_MSC_VER)
0012 # pragma once
0013 #endif
0014 
0015 #include <boost/iostreams/constants.hpp>
0016 #include <boost/iostreams/detail/char_traits.hpp>
0017 #include <boost/iostreams/detail/config/overload_resolution.hpp>
0018 #include <boost/iostreams/detail/forward.hpp>
0019 #include <boost/iostreams/detail/iostream.hpp>  // standard streams.
0020 #include <boost/iostreams/detail/select.hpp>
0021 #include <boost/iostreams/stream_buffer.hpp>
0022 #include <boost/mpl/and.hpp>
0023 #include <boost/type_traits/is_convertible.hpp>
0024 #include <boost/utility/base_from_member.hpp>
0025 
0026 namespace boost { namespace iostreams { namespace detail {
0027 
0028 template<typename Device, typename Tr>
0029 struct stream_traits {
0030     typedef typename char_type_of<Device>::type                char_type;
0031     typedef Tr                                                 traits_type;
0032     typedef typename category_of<Device>::type                 mode;
0033     typedef typename
0034             iostreams::select< // Disambiguation required for Tru64.
0035                 mpl::and_<
0036                     is_convertible<mode, input>,
0037                     is_convertible<mode, output>
0038                 >,
0039                 BOOST_IOSTREAMS_BASIC_IOSTREAM(char_type, traits_type),
0040                 is_convertible<mode, input>,
0041                 BOOST_IOSTREAMS_BASIC_ISTREAM(char_type, traits_type),
0042                 else_,
0043                 BOOST_IOSTREAMS_BASIC_OSTREAM(char_type, traits_type)
0044             >::type stream_type;
0045     typedef typename
0046             iostreams::select< // Disambiguation required for Tru64.
0047                 mpl::and_<
0048                     is_convertible<mode, input>,
0049                     is_convertible<mode, output>
0050                 >,
0051                 iostream_tag,
0052                 is_convertible<mode, input>,
0053                 istream_tag,
0054                 else_,
0055                 ostream_tag
0056             >::type stream_tag;
0057 };
0058 
0059 #if defined(BOOST_MSVC) && (BOOST_MSVC == 1700)
0060 # pragma warning(push)
0061 // https://connect.microsoft.com/VisualStudio/feedback/details/733720/
0062 # pragma warning(disable: 4250)
0063 #endif
0064 
0065 // By encapsulating initialization in a base, we can define the macro
0066 // BOOST_IOSTREAMS_DEFINE_FORWARDING_FUNCTIONS to generate constructors
0067 // without base member initializer lists.
0068 template< typename Device,
0069           typename Tr =
0070               BOOST_IOSTREAMS_CHAR_TRAITS(
0071                   BOOST_DEDUCED_TYPENAME char_type_of<Device>::type
0072               ),
0073           typename Alloc =
0074               std::allocator<
0075                   BOOST_DEDUCED_TYPENAME char_type_of<Device>::type
0076               >,
0077           typename Base = // VC6 Workaround.
0078               BOOST_DEDUCED_TYPENAME
0079               detail::stream_traits<Device, Tr>::stream_type >
0080 class stream_base
0081     : protected base_from_member< stream_buffer<Device, Tr, Alloc> >,
0082       public Base
0083 {
0084 private:
0085     typedef base_from_member< stream_buffer<Device, Tr, Alloc> >  pbase_type;
0086     typedef typename stream_traits<Device, Tr>::stream_type       stream_type;
0087 protected:
0088     using pbase_type::member; // Avoid warning about 'this' in initializer list.
0089 public:
0090     stream_base() : pbase_type(), stream_type(&member) { }
0091 };
0092 
0093 #if defined(BOOST_MSVC) && (BOOST_MSVC == 1700)
0094 # pragma warning(pop)
0095 #endif
0096 
0097 } } } // End namespaces detail, iostreams, boost.
0098 
0099 #ifdef BOOST_IOSTREAMS_BROKEN_OVERLOAD_RESOLUTION
0100 # include <boost/iostreams/detail/broken_overload_resolution/stream.hpp>
0101 #else
0102 
0103 namespace boost { namespace iostreams {
0104 
0105 #if defined(BOOST_MSVC) && (BOOST_MSVC == 1700)
0106 # pragma warning(push)
0107 // https://connect.microsoft.com/VisualStudio/feedback/details/733720/
0108 # pragma warning(disable: 4250)
0109 #endif
0110 
0111 //
0112 // Template name: stream.
0113 // Description: A iostream which reads from and writes to an instance of a
0114 //      designated device type.
0115 // Template parameters:
0116 //      Device - A device type.
0117 //      Alloc - The allocator type.
0118 //
0119 template< typename Device,
0120           typename Tr =
0121               BOOST_IOSTREAMS_CHAR_TRAITS(
0122                   BOOST_DEDUCED_TYPENAME char_type_of<Device>::type
0123               ),
0124           typename Alloc =
0125               std::allocator<
0126                   BOOST_DEDUCED_TYPENAME char_type_of<Device>::type
0127               > >
0128 struct stream : detail::stream_base<Device, Tr, Alloc> {
0129 public:
0130     typedef typename char_type_of<Device>::type  char_type;
0131     struct category 
0132         : mode_of<Device>::type,
0133           closable_tag,
0134           detail::stream_traits<Device, Tr>::stream_tag
0135         { };
0136     BOOST_IOSTREAMS_STREAMBUF_TYPEDEFS(Tr)
0137 private:
0138     typedef typename
0139             detail::stream_traits<
0140                 Device, Tr
0141             >::stream_type                       stream_type;
0142 public:
0143     stream() { }
0144     BOOST_IOSTREAMS_FORWARD( stream, open_impl, Device,
0145                              BOOST_IOSTREAMS_PUSH_PARAMS,
0146                              BOOST_IOSTREAMS_PUSH_ARGS )
0147     bool is_open() const { return this->member.is_open(); }
0148     void close() { this->member.close(); }
0149     bool auto_close() const { return this->member.auto_close(); }
0150     void set_auto_close(bool close) { this->member.set_auto_close(close); }
0151     bool strict_sync() { return this->member.strict_sync(); }
0152     Device& operator*() { return *this->member; }
0153     Device* operator->() { return &*this->member; }
0154     Device* component() { return this->member.component(); }
0155 private:
0156     void open_impl(const Device& dev BOOST_IOSTREAMS_PUSH_PARAMS()) // For forwarding.
0157     { 
0158         this->clear(); 
0159         this->member.open(dev BOOST_IOSTREAMS_PUSH_ARGS()); 
0160     }
0161 };
0162 
0163 #if defined(BOOST_MSVC) && (BOOST_MSVC == 1700)
0164 # pragma warning(pop)
0165 #endif
0166 
0167 } } // End namespaces iostreams, boost.
0168 
0169 #endif // #ifdef BOOST_IOSTREAMS_BROKEN_OVERLOAD_RESOLUTION
0170 
0171 #endif // #ifndef BOOST_IOSTREAMS_stream_HPP_INCLUDED