// (C) Copyright 2008 CodeRage, LLC (turkanis at coderage dot com) // (C) Copyright 2003-2007 Jonathan Turkanis // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt.) // See http://www.boost.org/libs/iostreams for documentation. #ifndef BOOST_IOSTREAMS_DETAIL_PUSH_HPP_INCLUDED #define BOOST_IOSTREAMS_DETAIL_PUSH_HPP_INCLUDED #if defined(_MSC_VER) # pragma once #endif #include // BOOST_MSVC. #include #include #include #include #include #include #include #include #include #include #include #include #include #include // // Macro: BOOST_IOSTREAMS_DEFINE_PUSH_CONSTRUCTOR(name, mode, ch, helper). // Description: Defines overloads with name 'name' which forward to a function // 'helper' which takes a filter or devide by const reference. // #define BOOST_IOSTREAMS_DEFINE_PUSH_CONSTRUCTOR(name, mode, ch, helper) \ BOOST_IOSTREAMS_DEFINE_PUSH_IMPL(name, mode, ch, helper, 0, ?) \ /**/ // // Macro: BOOST_IOSTREAMS_DEFINE_PUSH(name, mode, ch, helper). // Description: Defines constructors which forward to a function // 'helper' which takes a filter or device by const reference. // #define BOOST_IOSTREAMS_DEFINE_PUSH(name, mode, ch, helper) \ BOOST_IOSTREAMS_DEFINE_PUSH_IMPL(name, mode, ch, helper, 1, void) \ /**/ //--------------------Definition of BOOST_IOSTREAMS_DEFINE_PUSH_IMPL----------// #define BOOST_IOSTREAMS_ADAPT_STREAM(mode, ch, arg, helper, has_return) \ this->helper( ::boost::iostreams::detail::resolve(arg) \ BOOST_IOSTREAMS_PUSH_ARGS() ); \ /**/ #if !BOOST_WORKAROUND(BOOST_BORLANDC, < 0x600) \ /**/ # ifndef BOOST_IOSTREAMS_NO_STREAM_TEMPLATES # define BOOST_IOSTREAMS_DEFINE_PUSH_IMPL(name, mode, ch, helper, has_return, result) \ template \ BOOST_PP_IIF(has_return, result, explicit) \ name(::std::basic_streambuf& sb BOOST_IOSTREAMS_PUSH_PARAMS()) \ { BOOST_IOSTREAMS_ADAPT_STREAM(mode, ch, sb, helper, has_return); } \ template \ BOOST_PP_IIF(has_return, result, explicit) \ name(::std::basic_istream& is BOOST_IOSTREAMS_PUSH_PARAMS()) \ { BOOST_STATIC_ASSERT((!is_convertible::value)); \ BOOST_IOSTREAMS_ADAPT_STREAM(mode, ch, is, helper, has_return); } \ template \ BOOST_PP_IIF(has_return, result, explicit) \ name(::std::basic_ostream& os BOOST_IOSTREAMS_PUSH_PARAMS()) \ { BOOST_STATIC_ASSERT((!is_convertible::value)); \ BOOST_IOSTREAMS_ADAPT_STREAM(mode, ch, os, helper, has_return); } \ template \ BOOST_PP_IIF(has_return, result, explicit) \ name(::std::basic_iostream& io BOOST_IOSTREAMS_PUSH_PARAMS()) \ { BOOST_IOSTREAMS_ADAPT_STREAM(mode, ch, io, helper, has_return); } \ template \ BOOST_PP_IIF(has_return, result, explicit) \ name(const iterator_range& rng BOOST_IOSTREAMS_PUSH_PARAMS()) \ { BOOST_PP_EXPR_IF(has_return, return) \ this->helper( ::boost::iostreams::detail::range_adapter< \ mode, iterator_range \ >(rng) \ BOOST_IOSTREAMS_PUSH_ARGS() ); } \ template \ BOOST_PP_IIF(has_return, result, explicit) \ name(const ::boost::iostreams::pipeline& p) \ { p.push(*this); } \ template \ BOOST_PP_IIF(has_return, result, explicit) \ name(const T& t BOOST_IOSTREAMS_PUSH_PARAMS() BOOST_IOSTREAMS_DISABLE_IF_STREAM(T)) \ { this->helper( ::boost::iostreams::detail::resolve(t) \ BOOST_IOSTREAMS_PUSH_ARGS() ); } \ /**/ # else // # ifndef BOOST_IOSTREAMS_NO_STREAM_TEMPLATES # define BOOST_IOSTREAMS_DEFINE_PUSH_IMPL(name, mode, ch, helper, has_return, result) \ BOOST_PP_IF(has_return, result, explicit) \ name(::std::streambuf& sb BOOST_IOSTREAMS_PUSH_PARAMS()) \ { BOOST_IOSTREAMS_ADAPT_STREAM(mode, ch, sb, helper, has_return); } \ BOOST_PP_IF(has_return, result, explicit) \ name(::std::istream& is BOOST_IOSTREAMS_PUSH_PARAMS()) \ { BOOST_STATIC_ASSERT((!is_convertible::value)); \ BOOST_IOSTREAMS_ADAPT_STREAM(mode, ch, is, helper, has_return); } \ BOOST_PP_IF(has_return, result, explicit) \ name(::std::ostream& os BOOST_IOSTREAMS_PUSH_PARAMS()) \ { BOOST_STATIC_ASSERT((!is_convertible::value)); \ BOOST_IOSTREAMS_ADAPT_STREAM(mode, ch, os, helper, has_return); } \ BOOST_PP_IF(has_return, result, explicit) \ name(::std::iostream& io BOOST_IOSTREAMS_PUSH_PARAMS()) \ { BOOST_IOSTREAMS_ADAPT_STREAM(mode, ch, io, helper, has_return); } \ template \ BOOST_PP_IF(has_return, result, explicit) \ name(const iterator_range& rng BOOST_IOSTREAMS_PUSH_PARAMS()) \ { BOOST_PP_EXPR_IF(has_return, return) \ this->helper( ::boost::iostreams::detail::range_adapter< \ mode, iterator_range \ >(rng) \ BOOST_IOSTREAMS_PUSH_ARGS() ); } \ template \ BOOST_PP_IF(has_return, result, explicit) \ name(const ::boost::iostreams::pipeline& p) \ { p.push(*this); } \ template \ BOOST_PP_EXPR_IF(has_return, result) \ name(const T& t BOOST_IOSTREAMS_PUSH_PARAMS() BOOST_IOSTREAMS_DISABLE_IF_STREAM(T)) \ { this->helper( ::boost::iostreams::detail::resolve(t) \ BOOST_IOSTREAMS_PUSH_ARGS() ); } \ /**/ # endif // # ifndef BOOST_IOSTREAMS_NO_STREAM_TEMPLATES #else // #if VC6, VC7.0, Borland 5.x # define BOOST_IOSTREAMS_DEFINE_PUSH_IMPL(name, mode, ch, helper, has_return, result) \ template \ void BOOST_PP_CAT(name, _msvc_impl) \ ( ::boost::mpl::true_, const T& t BOOST_IOSTREAMS_PUSH_PARAMS() ) \ { t.push(*this); } \ template \ void BOOST_PP_CAT(name, _msvc_impl) \ ( ::boost::mpl::false_, const T& t BOOST_IOSTREAMS_PUSH_PARAMS() ) \ { this->helper( ::boost::iostreams::detail::resolve(t) \ BOOST_IOSTREAMS_PUSH_ARGS() ); } \ template \ BOOST_PP_IF(has_return, result, explicit) \ name(const T& t BOOST_IOSTREAMS_PUSH_PARAMS()) \ { \ this->BOOST_PP_CAT(name, _msvc_impl) \ ( ::boost::iostreams::detail::is_pipeline(), \ t BOOST_IOSTREAMS_PUSH_ARGS() ); \ } \ /**/ #endif // #if VC6, VC7.0, Borland 5.x #endif // #ifndef BOOST_IOSTREAMS_DETAIL_PUSH_HPP_INCLUDED