source: NonGTP/Boost/boost/iostreams/detail/forward.hpp @ 857

Revision 857, 4.6 KB checked in by igarcia, 19 years ago (diff)
RevLine 
[857]1// (C) Copyright Jonathan Turkanis 2003.
2// Distributed under the Boost Software License, Version 1.0. (See accompanying
3// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt.)
4
5// See http://www.boost.org/libs/iostreams for documentation.
6
7#ifndef BOOST_IOSTREAMS_DETAIL_FORWARD_HPP_INCLUDED
8#define BOOST_IOSTREAMS_DETAIL_FORWARD_HPP_INCLUDED   
9
10#if defined(_MSC_VER) && (_MSC_VER >= 1020)
11# pragma once
12#endif                 
13 
14#include <boost/config.hpp> // BOOST_MSVC
15#include <boost/detail/workaround.hpp>
16#include <boost/iostreams/detail/config/limits.hpp>
17#include <boost/iostreams/detail/push_params.hpp>
18#include <boost/preprocessor/arithmetic/dec.hpp>
19#include <boost/preprocessor/arithmetic/inc.hpp>
20#include <boost/preprocessor/punctuation/comma_if.hpp>
21#include <boost/preprocessor/repetition/enum_binary_params.hpp>
22#include <boost/preprocessor/repetition/enum_params.hpp>
23#include <boost/preprocessor/repetition/repeat_from_to.hpp>
24#include <boost/preprocessor/tuple/elem.hpp>
25
26//------Macros for defining forwarding constructors and open overloads--------//
27   
28//
29// Macro: BOOST_IOSTREAMS_DEFINE_FORWARDING_FUNCTIONS(mode, name, helper).
30// Description: Defines constructors and overloads of 'open' which construct
31//      a device using the given argument list and pass it to 'open_impl'.
32//      Assumes that 'policy_type' is an alias for the device type.
33//      Not supported on Intel 7.1 and VC6.5.
34//
35#define BOOST_IOSTREAMS_FORWARD(class, impl, policy, params, args) \
36    class(const policy& t params()) \
37    { this->impl(::boost::iostreams::detail::wrap(t) args()); } \
38    class(policy& t params()) \
39    { this->impl(::boost::iostreams::detail::wrap(t) args()); } \
40    class(const ::boost::reference_wrapper<policy>& ref params()) \
41    { this->impl(ref args()); } \
42    void open(const policy& t params()) \
43    { this->impl(::boost::iostreams::detail::wrap(t) args()); } \
44    void open(policy& t params()) \
45    { this->impl(::boost::iostreams::detail::wrap(t) args()); } \
46    void open(const ::boost::reference_wrapper<policy>& ref params()) \
47    { this->impl(ref args()); } \
48    BOOST_PP_REPEAT_FROM_TO( \
49        1, BOOST_PP_INC(BOOST_IOSTREAMS_MAX_FORWARDING_ARITY), \
50        BOOST_IOSTREAMS_FORWARDING_CTOR, (class, impl, policy) \
51    ) \
52    BOOST_PP_REPEAT_FROM_TO( \
53        1, BOOST_PP_INC(BOOST_IOSTREAMS_MAX_FORWARDING_ARITY), \
54        BOOST_IOSTREAMS_FORWARDING_FN, (class, impl, policy) \
55    ) \
56    /**/
57#if !BOOST_WORKAROUND(BOOST_MSVC, < 1300)
58# define BOOST_IOSTREAMS_FORWARDING_CTOR_I(z, n, tuple) \
59    template< typename U100 BOOST_PP_COMMA_IF(BOOST_PP_DEC(n)) \
60              BOOST_PP_ENUM_PARAMS_Z(z, BOOST_PP_DEC(n), typename U) > \
61    BOOST_PP_TUPLE_ELEM(3, 0, tuple) \
62    ( U100& u100 BOOST_PP_COMMA_IF(BOOST_PP_DEC(n)) \
63      BOOST_PP_ENUM_BINARY_PARAMS_Z(z, BOOST_PP_DEC(n), const U, &u)) \
64    { this->BOOST_PP_TUPLE_ELEM(3, 1, tuple) \
65      ( BOOST_PP_TUPLE_ELEM(3, 2, tuple) \
66        ( u100 BOOST_PP_COMMA_IF(BOOST_PP_DEC(n)) \
67          BOOST_PP_ENUM_PARAMS_Z(z, BOOST_PP_DEC(n), u)) ); } \
68    /**/
69# define BOOST_IOSTREAMS_FORWARDING_FN_I(z, n, tuple) \
70    template< typename U100 BOOST_PP_COMMA_IF(BOOST_PP_DEC(n)) \
71              BOOST_PP_ENUM_PARAMS_Z(z, BOOST_PP_DEC(n), typename U) > \
72    void open \
73    ( U100& u100 BOOST_PP_COMMA_IF(BOOST_PP_DEC(n)) \
74      BOOST_PP_ENUM_BINARY_PARAMS_Z(z, BOOST_PP_DEC(n), const U, &u)) \
75    { this->BOOST_PP_TUPLE_ELEM(3, 1, tuple) \
76      ( u100 BOOST_PP_COMMA_IF(BOOST_PP_DEC(n)) \
77        BOOST_PP_ENUM_PARAMS_Z(z, BOOST_PP_DEC(n), u) ); } \
78    /**/
79#else
80# define BOOST_IOSTREAMS_FORWARDING_CTOR_I(z, n, tuple)
81# define BOOST_IOSTREAMS_FORWARDING_FN_I(z, n, tuple)
82#endif
83#define BOOST_IOSTREAMS_FORWARDING_CTOR(z, n, tuple) \
84    template<BOOST_PP_ENUM_PARAMS_Z(z, n, typename U)> \
85    BOOST_PP_TUPLE_ELEM(3, 0, tuple) \
86    (BOOST_PP_ENUM_BINARY_PARAMS_Z(z, n, const U, &u)) \
87    { this->BOOST_PP_TUPLE_ELEM(3, 1, tuple) \
88      ( BOOST_PP_TUPLE_ELEM(3, 2, tuple) \
89        (BOOST_PP_ENUM_PARAMS_Z(z, n, u)) ); } \
90    BOOST_IOSTREAMS_FORWARDING_CTOR_I(z, n, tuple) \
91    /**/
92#define BOOST_IOSTREAMS_FORWARDING_FN(z, n, tuple) \
93    template<BOOST_PP_ENUM_PARAMS_Z(z, n, typename U)> \
94    void open(BOOST_PP_ENUM_BINARY_PARAMS_Z(z, n, const U, &u)) \
95    { this->BOOST_PP_TUPLE_ELEM(3, 1, tuple) \
96      ( BOOST_PP_TUPLE_ELEM(3, 2, tuple) \
97        (BOOST_PP_ENUM_PARAMS_Z(z, n, u)) ); } \
98    BOOST_IOSTREAMS_FORWARDING_FN_I(z, n, tuple) \
99    /**/
100
101#endif // #ifndef BOOST_IOSTREAMS_DETAIL_FORWARD_HPP_INCLUDED
Note: See TracBrowser for help on using the repository browser.