Back to home page

EIC code displayed by LXR

 
 

    


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

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_DETAIL_MODE_ADAPTER_HPP_INCLUDED
0009 #define BOOST_IOSTREAMS_DETAIL_MODE_ADAPTER_HPP_INCLUDED
0010 
0011 #if defined(_MSC_VER)
0012 # pragma once
0013 #endif              
0014 
0015 // Contains the definition of the class template mode_adapter, which allows
0016 // a filter or device to function as if it has a different i/o mode than that
0017 // deduced by the metafunction mode_of.
0018 
0019 #include <boost/config.hpp>                // BOOST_MSVC.
0020 #include <boost/detail/workaround.hpp>
0021 #include <boost/iostreams/categories.hpp>
0022 #include <boost/iostreams/detail/ios.hpp>  // openmode, seekdir, int types. 
0023 #include <boost/iostreams/traits.hpp>
0024 #include <boost/iostreams/operations.hpp> 
0025 #include <boost/mpl/if.hpp> 
0026 
0027 namespace boost { namespace iostreams { namespace detail {
0028 
0029 template<typename Mode, typename T>
0030 class mode_adapter {
0031 private:
0032     struct empty_base { };
0033 public:
0034     typedef typename wrapped_type<T>::type  component_type;
0035     typedef typename char_type_of<T>::type  char_type;
0036     struct category 
0037         : Mode, 
0038           device_tag,
0039           mpl::if_<is_filter<T>, filter_tag, device_tag>,
0040           mpl::if_<is_filter<T>, multichar_tag, empty_base>,
0041           closable_tag,
0042           localizable_tag
0043         { };
0044     explicit mode_adapter(const component_type& t) : t_(t) { }
0045 
0046         // Device member functions.
0047 
0048     std::streamsize read(char_type* s, std::streamsize n);
0049     std::streamsize write(const char_type* s, std::streamsize n);
0050     std::streampos seek( stream_offset off, BOOST_IOS::seekdir way,
0051                          BOOST_IOS::openmode which = 
0052                              BOOST_IOS::in | BOOST_IOS::out );
0053     void close();
0054     void close(BOOST_IOS::openmode which);
0055 
0056         // Filter member functions.
0057 
0058     template<typename Source>
0059     std::streamsize read(Source& src, char_type* s, std::streamsize n)
0060     { return iostreams::read(t_, src, s, n); }
0061 
0062     template<typename Sink>
0063     std::streamsize write(Sink& snk, const char_type* s, std::streamsize n)
0064     { return iostreams::write(t_, snk, s, n); }
0065 
0066     template<typename Device>
0067     std::streampos seek(Device& dev, stream_offset off, BOOST_IOS::seekdir way)
0068     { return iostreams::seek(t_, dev, off, way); }
0069 
0070     template<typename Device>
0071     std::streampos seek( Device& dev, stream_offset off, 
0072                          BOOST_IOS::seekdir way, BOOST_IOS::openmode which  )
0073     { return iostreams::seek(t_, dev, off, way, which); }
0074 
0075     template<typename Device>
0076     void close(Device& dev)
0077     { detail::close_all(t_, dev); }
0078 
0079     template<typename Device>
0080     void close(Device& dev, BOOST_IOS::openmode which)
0081     { iostreams::close(t_, dev, which); }
0082 
0083     template<typename Locale>
0084     void imbue(const Locale& loc)
0085     { iostreams::imbue(t_, loc); }
0086 private:
0087     component_type t_;
0088 };
0089                     
0090 //------------------Implementation of mode_adapter----------------------------//
0091 
0092 template<typename Mode, typename T>
0093 std::streamsize mode_adapter<Mode, T>::read
0094     (char_type* s, std::streamsize n)
0095 { return boost::iostreams::read(t_, s, n); }
0096 
0097 template<typename Mode, typename T>
0098 std::streamsize mode_adapter<Mode, T>::write
0099     (const char_type* s, std::streamsize n)
0100 { return boost::iostreams::write(t_, s, n); }
0101 
0102 template<typename Mode, typename T>
0103 std::streampos mode_adapter<Mode, T>::seek
0104     (stream_offset off, BOOST_IOS::seekdir way, BOOST_IOS::openmode which)
0105 { return boost::iostreams::seek(t_, off, way, which); }
0106 
0107 template<typename Mode, typename T>
0108 void mode_adapter<Mode, T>::close()
0109 { detail::close_all(t_); }
0110 
0111 template<typename Mode, typename T>
0112 void mode_adapter<Mode, T>::close(BOOST_IOS::openmode which)
0113 { iostreams::close(t_, which); }
0114 
0115 } } } // End namespaces detail, iostreams, boost.
0116 
0117 #endif // #ifndef BOOST_IOSTREAMS_DETAIL_MODE_ADAPTER_HPP_INCLUDED //-----//