1 // (C) Copyright 2008 CodeRage, LLC (turkanis at coderage dot com)
2 // (C) Copyright 2003-2007 Jonathan Turkanis
3 // Distributed under the Boost Software License, Version 1.0. (See accompanying
4 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt.)
5 
6 // See http://www.boost.org/libs/iostreams for documentation.
7 
8 #ifndef BOOST_IOSTREAMS_DETAIL_BROKEN_OVERLOAD_RESOLUTION_STREAM_HPP_INCLUDED
9 #define BOOST_IOSTREAMS_DETAIL_BROKEN_OVERLOAD_RESOLUTION_STREAM_HPP_INCLUDED
10 
11 #include <boost/iostreams/detail/broken_overload_resolution/forward.hpp>
12 
13 namespace boost { namespace iostreams {
14 
15 template< typename Device,
16           typename Tr =
17               BOOST_IOSTREAMS_CHAR_TRAITS(
18                   BOOST_DEDUCED_TYPENAME char_type_of<Device>::type
19               ),
20           typename Alloc =
21               std::allocator<
22                   BOOST_DEDUCED_TYPENAME char_type_of<Device>::type
23               > >
24 struct stream : detail::stream_base<Device, Tr, Alloc> {
25 public:
26     typedef typename char_type_of<Device>::type  char_type;
27     struct category
28         : mode_of<Device>::type,
29           closable_tag,
30           detail::stream_traits<Device, Tr>::stream_tag
31         { };
32     BOOST_IOSTREAMS_STREAMBUF_TYPEDEFS(Tr)
33 private:
34     typedef typename
35             detail::stream_traits<
36                 Device, Tr
37             >::stream_type                       stream_type;
38 public:
streamboost::iostreams::stream39     stream() { }
40     template<typename U0>
streamboost::iostreams::stream41     stream(const U0& u0)
42     {
43         open_impl(detail::forward<Device, U0>(), u0);
44     }
45     template<typename U0, typename U1>
streamboost::iostreams::stream46     stream(const U0& u0, const U1& u1)
47     {
48         open_impl(detail::forward<Device, U0>(), u0, u1);
49     }
50     template<typename U0, typename U1, typename U2>
streamboost::iostreams::stream51     stream(const U0& u0, const U1& u1, const U2& u2)
52     {
53         open_impl(detail::forward<Device, U0>(), u0, u1, u2);
54     }
55 #if !BOOST_WORKAROUND(BOOST_MSVC, <= 1300) //---------------------------------//
56     template<typename U0>
streamboost::iostreams::stream57     stream(U0& u0)
58     {
59         open_impl(detail::forward<Device, U0>(), u0);
60     }
61     template<typename U0, typename U1>
streamboost::iostreams::stream62     stream(U0& u0, const U1& u1)
63     {
64         open_impl(detail::forward<Device, U0>(), u0, u1);
65     }
66     template<typename U0, typename U1, typename U2>
streamboost::iostreams::stream67     stream(U0& u0, const U1& u1, const U2& u2)
68     {
69         open_impl(detail::forward<Device, U0>(), u0, u1, u2);
70     }
71 #endif // !BOOST_WORKAROUND(BOOST_MSVC, <= 1300) //---------------------------//
72     template<typename U0>
openboost::iostreams::stream73     void open(const U0& u0)
74     {
75         open_impl(detail::forward<Device, U0>(), u0);
76     }
77     template<typename U0, typename U1>
openboost::iostreams::stream78     void open(const U0& u0, const U1& u1)
79     {
80         open_impl(detail::forward<Device, U0>(), u0, u1);
81     }
82     template<typename U0, typename U1, typename U2>
openboost::iostreams::stream83     void open(const U0& u0, const U1& u1, const U2& u2)
84     {
85         open_impl(detail::forward<Device, U0>(), u0, u1, u2);
86     }
87 #if !BOOST_WORKAROUND(BOOST_MSVC, <= 1300) //---------------------------------//
88     template<typename U0>
openboost::iostreams::stream89     void open(U0& u0)
90     {
91         open_impl(detail::forward<Device, U0>(), u0);
92     }
93     template<typename U0, typename U1>
openboost::iostreams::stream94     void open(U0& u0, const U1& u1)
95     {
96         open_impl(detail::forward<Device, U0>(), u0, u1);
97     }
98     template<typename U0, typename U1, typename U2>
openboost::iostreams::stream99     void open(U0& u0, const U1& u1, const U2& u2)
100     {
101         open_impl(detail::forward<Device, U0>(), u0, u1, u2);
102     }
103 #endif // !BOOST_WORKAROUND(BOOST_MSVC, <= 1300) //---------------------------//
is_openboost::iostreams::stream104     bool is_open() const { return this->member.is_open(); }
closeboost::iostreams::stream105     void close() { this->member.close(); }
auto_closeboost::iostreams::stream106     bool auto_close() const { return this->member.auto_close(); }
set_auto_closeboost::iostreams::stream107     void set_auto_close(bool close) { this->member.set_auto_close(close); }
strict_syncboost::iostreams::stream108     bool strict_sync() { return this->member.strict_sync(); }
operator *boost::iostreams::stream109     Device& operator*() { return *this->member; }
operator ->boost::iostreams::stream110     Device* operator->() { return &*this->member; }
111 private:
112     template<typename U0>
open_implboost::iostreams::stream113     void open_impl(mpl::false_, const U0& u0)
114     {
115         this->clear();
116         this->member.open(u0);
117     }
118 #if !BOOST_WORKAROUND(BOOST_MSVC, <= 1300) //---------------------------------//
119     template<typename U0>
open_implboost::iostreams::stream120     void open_impl(mpl::false_, U0& u0)
121     {
122         this->clear();
123         this->member.open(detail::wrap(u0));
124     }
125 #endif // !BOOST_WORKAROUND(BOOST_MSVC, <= 1300) //---------------------------//
126     template<typename U0>
open_implboost::iostreams::stream127     void open_impl(mpl::true_, const U0& u0)
128     {
129         this->clear();
130         this->member.open(Device(const_cast<U0&>(u0)));
131     }
132 #if !BOOST_WORKAROUND(BOOST_MSVC, <= 1300) //---------------------------------//
133     template<typename U0>
open_implboost::iostreams::stream134     void open_impl(mpl::true_, U0& u0)
135     {
136         this->clear();
137         this->member.open(Device(u0));
138     }
139 #endif // !BOOST_WORKAROUND(BOOST_MSVC, <= 1300) //---------------------------//
140     template<typename U0, typename U1>
open_implboost::iostreams::stream141     void open_impl(mpl::false_, const U0& u0, const U1& u1)
142     {
143         this->clear();
144         this->member.open(u0, u1);
145     }
146     template<typename U0, typename U1>
open_implboost::iostreams::stream147     void open_impl(mpl::true_, const U0& u0, const U1& u1)
148     {
149         this->clear();
150         this->member.open(Device(const_cast<U0&>(u0), u1));
151     }
152 #if !BOOST_WORKAROUND(BOOST_MSVC, <= 1300) //---------------------------------//
153     template<typename U0, typename U1>
open_implboost::iostreams::stream154     void open_impl(mpl::true_, U0& u0, const U1& u1)
155     {
156         this->clear();
157         this->member.open(Device(u0, u1));
158     }
159 #endif // !BOOST_WORKAROUND(BOOST_MSVC, <= 1300) //---------------------------//
160     template<typename U0, typename U1, typename U2>
open_implboost::iostreams::stream161     void open_impl(mpl::false_, const U0& u0, const U1& u1, const U2& u2)
162     {
163         this->clear();
164         this->member.open(u0, u1, u2);
165     }
166     template<typename U0, typename U1, typename U2>
open_implboost::iostreams::stream167     void open_impl(mpl::true_, const U0& u0, const U1& u1, const U2& u2)
168     {
169         this->clear();
170         this->member.open(Device(const_cast<U0&>(u0), u1, u2));
171     }
172 #if !BOOST_WORKAROUND(BOOST_MSVC, <= 1300) //---------------------------------//
173     template<typename U0, typename U1, typename U2>
open_implboost::iostreams::stream174     void open_impl(mpl::true_, U0& u0, const U1& u1, const U2& u2)
175     {
176         this->clear();
177         this->member.open(Device(u0, u1, u2));
178     }
179 #endif
180 };
181 
182 } } // End namespaces iostreams, boost.
183 
184 #endif BOOST_IOSTREAMS_DETAIL_BROKEN_OVERLOAD_RESOLUTION_STREAM_HPP_INCLUDED
185