Back to home page

EIC code displayed by LXR

 
 

    


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

0001 // (C) Copyright 2008 CodeRage, LLC (turkanis at coderage dot com)
0002 // (C) Copyright 2004-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_FILTER_STREAM_HPP_INCLUDED
0009 #define BOOST_IOSTREAMS_FILTER_STREAM_HPP_INCLUDED
0010 
0011 #if defined(_MSC_VER)
0012 # pragma once
0013 #endif              
0014 
0015 #include <memory>                                     // allocator.
0016 #include <boost/iostreams/detail/access_control.hpp>
0017 #include <boost/iostreams/detail/char_traits.hpp>
0018 #include <boost/iostreams/detail/iostream.hpp>        // standard streams.
0019 #include <boost/iostreams/detail/push.hpp>
0020 #include <boost/iostreams/detail/select.hpp>
0021 #include <boost/iostreams/detail/streambuf.hpp>       // pubsync.
0022 #include <boost/iostreams/filtering_streambuf.hpp>
0023 #include <boost/mpl/and.hpp>
0024 #include <boost/mpl/bool.hpp>
0025 #include <boost/static_assert.hpp>
0026 #include <boost/type_traits/is_convertible.hpp>
0027 
0028 // Must come last.
0029 #include <boost/iostreams/detail/config/disable_warnings.hpp>  // MSVC.
0030 
0031 namespace boost { namespace iostreams {
0032 
0033 //--------------Definition of filtered_istream--------------------------------//
0034 
0035 namespace detail {
0036 
0037 template<typename Mode, typename Ch, typename Tr>
0038 struct filtering_stream_traits {
0039     typedef typename 
0040             iostreams::select<  // Disambiguation for Tru64  
0041                 mpl::and_< 
0042                     is_convertible<Mode, input>, 
0043                     is_convertible<Mode, output> 
0044                 >,          
0045                 BOOST_IOSTREAMS_BASIC_IOSTREAM(Ch, Tr),
0046                 is_convertible<Mode, input>, 
0047                 BOOST_IOSTREAMS_BASIC_ISTREAM(Ch, Tr),
0048                 else_,        
0049                 BOOST_IOSTREAMS_BASIC_OSTREAM(Ch, Tr)
0050             >::type stream_type;
0051     typedef typename
0052             iostreams::select< // Dismbiguation required for Tru64.
0053                 mpl::and_<
0054                     is_convertible<Mode, input>,
0055                     is_convertible<Mode, output>
0056                 >,
0057                 iostream_tag,
0058                 is_convertible<Mode, input>,
0059                 istream_tag,
0060                 else_,
0061                 ostream_tag
0062             >::type stream_tag;
0063 };
0064 
0065 #if defined(BOOST_MSVC) && (BOOST_MSVC == 1700)
0066 # pragma warning(push)
0067 // https://connect.microsoft.com/VisualStudio/feedback/details/733720/
0068 # pragma warning(disable: 4250)
0069 #endif
0070 
0071 template<typename Chain, typename Access>
0072 class filtering_stream_base 
0073     : public access_control<
0074                  boost::iostreams::detail::chain_client<Chain>,
0075                  Access
0076              >,
0077       public filtering_stream_traits<
0078                  typename Chain::mode, 
0079                  typename Chain::char_type, 
0080                  typename Chain::traits_type
0081              >::stream_type
0082 {
0083 public:
0084     typedef Chain                                         chain_type;
0085     typedef access_control<
0086                  boost::iostreams::detail::chain_client<Chain>,
0087                  Access
0088              >                                            client_type;
0089 protected:
0090     typedef typename 
0091             filtering_stream_traits<
0092                  typename Chain::mode, 
0093                  typename Chain::char_type, 
0094                  typename Chain::traits_type
0095             >::stream_type                                stream_type;
0096     filtering_stream_base() : stream_type(0) { this->set_chain(&chain_); }
0097 private:
0098     void notify() { this->rdbuf(chain_.empty() ? 0 : &chain_.front()); }
0099     Chain chain_;
0100 };
0101 
0102 #if defined(BOOST_MSVC) && (BOOST_MSVC == 1700)
0103 # pragma warning(pop)
0104 #endif
0105 
0106 } // End namespace detail.
0107 
0108 //
0109 // Macro: BOOST_IOSTREAMS_DEFINE_FILTER_STREAM(name_, chain_type_, default_char_)
0110 // Description: Defines a template derived from std::basic_streambuf which uses
0111 //      a chain to perform i/o. The template has the following parameters:
0112 //      Mode - the i/o mode.
0113 //      Ch - The character type.
0114 //      Tr - The character traits type.
0115 //      Alloc - The allocator type.
0116 //      Access - Indicates accessibility of the chain interface; must be either
0117 //          public_ or protected_; defaults to public_.
0118 // Macro parameters:
0119 //      name_ - The name of the template to be defined.
0120 //      chain_type_ - The name of the chain template.
0121 //      default_char_ - The default value for the char template parameter.
0122 //
0123 #define BOOST_IOSTREAMS_DEFINE_FILTER_STREAM(name_, chain_type_, default_char_) \
0124     template< typename Mode, \
0125               typename Ch = default_char_, \
0126               typename Tr = BOOST_IOSTREAMS_CHAR_TRAITS(Ch), \
0127               typename Alloc = std::allocator<Ch>, \
0128               typename Access = public_ > \
0129     class name_ \
0130         : public boost::iostreams::detail::filtering_stream_base< \
0131                      chain_type_<Mode, Ch, Tr, Alloc>, Access \
0132                  > \
0133     { \
0134     public: \
0135         typedef Ch                                char_type; \
0136         struct category \
0137             : Mode, \
0138               closable_tag, \
0139               detail::filtering_stream_traits<Mode, Ch, Tr>::stream_tag \
0140             { }; \
0141         BOOST_IOSTREAMS_STREAMBUF_TYPEDEFS(Tr) \
0142         typedef Mode                              mode; \
0143         typedef chain_type_<Mode, Ch, Tr, Alloc>  chain_type; \
0144         name_() { } \
0145         BOOST_IOSTREAMS_DEFINE_PUSH_CONSTRUCTOR(name_, mode, Ch, push_impl) \
0146         ~name_() { \
0147             if (this->is_complete()) \
0148                  this->rdbuf()->BOOST_IOSTREAMS_PUBSYNC(); \
0149         } \
0150     private: \
0151         typedef access_control< \
0152                     boost::iostreams::detail::chain_client< \
0153                         chain_type_<Mode, Ch, Tr, Alloc> \
0154                     >, \
0155                     Access \
0156                 > client_type; \
0157         template<typename T> \
0158         void push_impl(const T& t BOOST_IOSTREAMS_PUSH_PARAMS()) \
0159         { client_type::push(t BOOST_IOSTREAMS_PUSH_ARGS()); } \
0160     }; \
0161     /**/    
0162 
0163 #if defined(BOOST_MSVC) && (BOOST_MSVC == 1700)
0164 # pragma warning(push)
0165 // https://connect.microsoft.com/VisualStudio/feedback/details/733720/
0166 # pragma warning(disable: 4250)
0167 #endif
0168 
0169 BOOST_IOSTREAMS_DEFINE_FILTER_STREAM(filtering_stream, boost::iostreams::chain, char)
0170 BOOST_IOSTREAMS_DEFINE_FILTER_STREAM(wfiltering_stream, boost::iostreams::chain, wchar_t)
0171 
0172 #if defined(BOOST_MSVC) && (BOOST_MSVC == 1700)
0173 # pragma warning(pop)
0174 #endif
0175 
0176 typedef filtering_stream<input>    filtering_istream;
0177 typedef filtering_stream<output>   filtering_ostream;
0178 typedef wfiltering_stream<input>   filtering_wistream;
0179 typedef wfiltering_stream<output>  filtering_wostream;
0180 
0181 //----------------------------------------------------------------------------//
0182 
0183 } } // End namespace iostreams, boost
0184 
0185 #include <boost/iostreams/detail/config/enable_warnings.hpp> // MSVC
0186 
0187 #endif // #ifndef BOOST_IOSTREAMS_FILTER_STREAM_HPP_INCLUDED