Back to home page

EIC code displayed by LXR

 
 

    


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

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_PUSH_HPP_INCLUDED
0009 #define BOOST_IOSTREAMS_DETAIL_PUSH_HPP_INCLUDED 
0010 
0011 #if defined(_MSC_VER)
0012 # pragma once
0013 #endif                    
0014  
0015 #include <boost/config.hpp> // BOOST_MSVC.
0016 #include <boost/detail/workaround.hpp>
0017 #include <boost/iostreams/categories.hpp>
0018 #include <boost/iostreams/categories.hpp>
0019 #include <boost/iostreams/detail/adapter/range_adapter.hpp>
0020 #include <boost/iostreams/detail/config/wide_streams.hpp>
0021 #include <boost/iostreams/detail/enable_if_stream.hpp>   
0022 #include <boost/iostreams/pipeline.hpp>   
0023 #include <boost/iostreams/detail/push_params.hpp>   
0024 #include <boost/iostreams/detail/resolve.hpp>
0025 #include <boost/mpl/bool.hpp>   
0026 #include <boost/preprocessor/cat.hpp> 
0027 #include <boost/preprocessor/control/iif.hpp>
0028 #include <boost/static_assert.hpp>
0029 #include <boost/type_traits/is_convertible.hpp>
0030 
0031 //
0032 // Macro: BOOST_IOSTREAMS_DEFINE_PUSH_CONSTRUCTOR(name, mode, ch, helper).
0033 // Description: Defines overloads with name 'name' which forward to a function
0034 //      'helper' which takes a filter or devide by const reference.
0035 //
0036 #define BOOST_IOSTREAMS_DEFINE_PUSH_CONSTRUCTOR(name, mode, ch, helper) \
0037     BOOST_IOSTREAMS_DEFINE_PUSH_IMPL(name, mode, ch, helper, 0, ?) \
0038     /**/
0039 
0040 //
0041 // Macro: BOOST_IOSTREAMS_DEFINE_PUSH(name, mode, ch, helper).
0042 // Description: Defines constructors which forward to a function
0043 //      'helper' which takes a filter or device by const reference.
0044 //
0045 #define BOOST_IOSTREAMS_DEFINE_PUSH(name, mode, ch, helper) \
0046     BOOST_IOSTREAMS_DEFINE_PUSH_IMPL(name, mode, ch, helper, 1, void) \
0047     /**/
0048 
0049 //--------------------Definition of BOOST_IOSTREAMS_DEFINE_PUSH_IMPL----------//
0050           
0051 #define BOOST_IOSTREAMS_ADAPT_STREAM(mode, ch, arg, helper, has_return) \
0052     this->helper( ::boost::iostreams::detail::resolve<mode, ch>(arg) \
0053                   BOOST_IOSTREAMS_PUSH_ARGS() ); \
0054     /**/
0055 
0056 #if !BOOST_WORKAROUND(BOOST_BORLANDC, < 0x600) \
0057     /**/
0058 # ifndef BOOST_IOSTREAMS_NO_STREAM_TEMPLATES
0059 #  define BOOST_IOSTREAMS_DEFINE_PUSH_IMPL(name, mode, ch, helper, has_return, result) \
0060     template<typename CharType, typename TraitsType> \
0061     BOOST_PP_IIF(has_return, result, explicit) \
0062     name(::std::basic_streambuf<CharType, TraitsType>& sb BOOST_IOSTREAMS_PUSH_PARAMS()) \
0063     { BOOST_IOSTREAMS_ADAPT_STREAM(mode, ch, sb, helper, has_return); } \
0064     template<typename CharType, typename TraitsType> \
0065     BOOST_PP_IIF(has_return, result, explicit) \
0066     name(::std::basic_istream<CharType, TraitsType>& is BOOST_IOSTREAMS_PUSH_PARAMS()) \
0067     { BOOST_STATIC_ASSERT((!is_convertible<mode, output>::value)); \
0068       BOOST_IOSTREAMS_ADAPT_STREAM(mode, ch, is, helper, has_return); } \
0069     template<typename CharType, typename TraitsType> \
0070     BOOST_PP_IIF(has_return, result, explicit) \
0071     name(::std::basic_ostream<CharType, TraitsType>& os BOOST_IOSTREAMS_PUSH_PARAMS()) \
0072     { BOOST_STATIC_ASSERT((!is_convertible<mode, input>::value)); \
0073       BOOST_IOSTREAMS_ADAPT_STREAM(mode, ch, os, helper, has_return); } \
0074     template<typename CharType, typename TraitsType> \
0075     BOOST_PP_IIF(has_return, result, explicit) \
0076     name(::std::basic_iostream<CharType, TraitsType>& io BOOST_IOSTREAMS_PUSH_PARAMS()) \
0077     { BOOST_IOSTREAMS_ADAPT_STREAM(mode, ch, io, helper, has_return); } \
0078     template<typename Iter> \
0079     BOOST_PP_IIF(has_return, result, explicit) \
0080     name(const iterator_range<Iter>& rng BOOST_IOSTREAMS_PUSH_PARAMS()) \
0081     { BOOST_PP_EXPR_IF(has_return, return) \
0082     this->helper( ::boost::iostreams::detail::range_adapter< \
0083                       mode, iterator_range<Iter> \
0084                   >(rng) \
0085                   BOOST_IOSTREAMS_PUSH_ARGS() ); } \
0086     template<typename Pipeline, typename Concept> \
0087     BOOST_PP_IIF(has_return, result, explicit) \
0088     name(const ::boost::iostreams::pipeline<Pipeline, Concept>& p) \
0089     { p.push(*this); } \
0090     template<typename T> \
0091     BOOST_PP_IIF(has_return, result, explicit) \
0092     name(const T& t BOOST_IOSTREAMS_PUSH_PARAMS() BOOST_IOSTREAMS_DISABLE_IF_STREAM(T)) \
0093     { this->helper( ::boost::iostreams::detail::resolve<mode, ch>(t) \
0094                     BOOST_IOSTREAMS_PUSH_ARGS() ); } \
0095     /**/
0096 # else // # ifndef BOOST_IOSTREAMS_NO_STREAM_TEMPLATES
0097 #  define BOOST_IOSTREAMS_DEFINE_PUSH_IMPL(name, mode, ch, helper, has_return, result) \
0098     BOOST_PP_IF(has_return, result, explicit) \
0099     name(::std::streambuf& sb BOOST_IOSTREAMS_PUSH_PARAMS()) \
0100     { BOOST_IOSTREAMS_ADAPT_STREAM(mode, ch, sb, helper, has_return); } \
0101     BOOST_PP_IF(has_return, result, explicit) \
0102     name(::std::istream& is BOOST_IOSTREAMS_PUSH_PARAMS()) \
0103     { BOOST_STATIC_ASSERT((!is_convertible<mode, output>::value)); \
0104       BOOST_IOSTREAMS_ADAPT_STREAM(mode, ch, is, helper, has_return); } \
0105     BOOST_PP_IF(has_return, result, explicit) \
0106     name(::std::ostream& os BOOST_IOSTREAMS_PUSH_PARAMS()) \
0107     { BOOST_STATIC_ASSERT((!is_convertible<mode, input>::value)); \
0108       BOOST_IOSTREAMS_ADAPT_STREAM(mode, ch, os, helper, has_return); } \
0109     BOOST_PP_IF(has_return, result, explicit) \
0110     name(::std::iostream& io BOOST_IOSTREAMS_PUSH_PARAMS()) \
0111     { BOOST_IOSTREAMS_ADAPT_STREAM(mode, ch, io, helper, has_return); } \
0112     template<typename Iter> \
0113     BOOST_PP_IF(has_return, result, explicit) \
0114     name(const iterator_range<Iter>& rng BOOST_IOSTREAMS_PUSH_PARAMS()) \
0115     { BOOST_PP_EXPR_IF(has_return, return) \
0116     this->helper( ::boost::iostreams::detail::range_adapter< \
0117                       mode, iterator_range<Iter> \
0118                   >(rng) \
0119                   BOOST_IOSTREAMS_PUSH_ARGS() ); } \
0120     template<typename Pipeline, typename Concept> \
0121     BOOST_PP_IF(has_return, result, explicit) \
0122     name(const ::boost::iostreams::pipeline<Pipeline, Concept>& p) \
0123     { p.push(*this); } \
0124     template<typename T> \
0125     BOOST_PP_EXPR_IF(has_return, result) \
0126     name(const T& t BOOST_IOSTREAMS_PUSH_PARAMS() BOOST_IOSTREAMS_DISABLE_IF_STREAM(T)) \
0127     { this->helper( ::boost::iostreams::detail::resolve<mode, ch>(t) \
0128                     BOOST_IOSTREAMS_PUSH_ARGS() ); } \
0129     /**/
0130 # endif // # ifndef BOOST_IOSTREAMS_NO_STREAM_TEMPLATES
0131 #else // #if VC6, VC7.0, Borland 5.x
0132 # define BOOST_IOSTREAMS_DEFINE_PUSH_IMPL(name, mode, ch, helper, has_return, result) \
0133     template<typename T> \
0134     void BOOST_PP_CAT(name, _msvc_impl) \
0135     ( ::boost::mpl::true_, const T& t BOOST_IOSTREAMS_PUSH_PARAMS() ) \
0136     { t.push(*this); } \
0137     template<typename T> \
0138     void BOOST_PP_CAT(name, _msvc_impl) \
0139     ( ::boost::mpl::false_, const T& t BOOST_IOSTREAMS_PUSH_PARAMS() ) \
0140     { this->helper( ::boost::iostreams::detail::resolve<mode, ch>(t) \
0141                     BOOST_IOSTREAMS_PUSH_ARGS() ); } \
0142     template<typename T> \
0143     BOOST_PP_IF(has_return, result, explicit) \
0144     name(const T& t BOOST_IOSTREAMS_PUSH_PARAMS()) \
0145     { \
0146         this->BOOST_PP_CAT(name, _msvc_impl) \
0147               ( ::boost::iostreams::detail::is_pipeline<T>(), \
0148                 t BOOST_IOSTREAMS_PUSH_ARGS() ); \
0149     } \
0150     /**/
0151 #endif // #if VC6, VC7.0, Borland 5.x
0152 
0153 #endif // #ifndef BOOST_IOSTREAMS_DETAIL_PUSH_HPP_INCLUDED