blob: 6485f1f5b5d45d847533cb3563c14ab3d520bf9d [file] [log] [blame]
Jeff Thompson86b6d642013-10-17 15:01:56 -07001// (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 NDNBOOST_IOSTREAMS_DETAIL_BROKEN_OVERLOAD_RESOLUTION_STREAM_HPP_INCLUDED
9#define NDNBOOST_IOSTREAMS_DETAIL_BROKEN_OVERLOAD_RESOLUTION_STREAM_HPP_INCLUDED
10
11#include <ndnboost/iostreams/detail/broken_overload_resolution/forward.hpp>
12
13namespace ndnboost { namespace iostreams {
14
15template< typename Device,
16 typename Tr =
17 NDNBOOST_IOSTREAMS_CHAR_TRAITS(
18 NDNBOOST_DEDUCED_TYPENAME char_type_of<Device>::type
19 ),
20 typename Alloc =
21 std::allocator<
22 NDNBOOST_DEDUCED_TYPENAME char_type_of<Device>::type
23 > >
24struct stream : detail::stream_base<Device, Tr, Alloc> {
25public:
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 NDNBOOST_IOSTREAMS_STREAMBUF_TYPEDEFS(Tr)
33private:
34 typedef typename
35 detail::stream_traits<
36 Device, Tr
37 >::stream_type stream_type;
38public:
39 stream() { }
40 template<typename U0>
41 stream(const U0& u0)
42 {
43 open_impl(detail::forward<Device, U0>(), u0);
44 }
45 template<typename U0, typename U1>
46 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>
51 stream(const U0& u0, const U1& u1, const U2& u2)
52 {
53 open_impl(detail::forward<Device, U0>(), u0, u1, u2);
54 }
55#if !NDNBOOST_WORKAROUND(NDNBOOST_MSVC, <= 1300) //---------------------------------//
56 template<typename U0>
57 stream(U0& u0)
58 {
59 open_impl(detail::forward<Device, U0>(), u0);
60 }
61 template<typename U0, typename U1>
62 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>
67 stream(U0& u0, const U1& u1, const U2& u2)
68 {
69 open_impl(detail::forward<Device, U0>(), u0, u1, u2);
70 }
71#endif // !NDNBOOST_WORKAROUND(NDNBOOST_MSVC, <= 1300) //---------------------------//
72 template<typename U0>
73 void open(const U0& u0)
74 {
75 open_impl(detail::forward<Device, U0>(), u0);
76 }
77 template<typename U0, typename U1>
78 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>
83 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 !NDNBOOST_WORKAROUND(NDNBOOST_MSVC, <= 1300) //---------------------------------//
88 template<typename U0>
89 void open(U0& u0)
90 {
91 open_impl(detail::forward<Device, U0>(), u0);
92 }
93 template<typename U0, typename U1>
94 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>
99 void open(U0& u0, const U1& u1, const U2& u2)
100 {
101 open_impl(detail::forward<Device, U0>(), u0, u1, u2);
102 }
103#endif // !NDNBOOST_WORKAROUND(NDNBOOST_MSVC, <= 1300) //---------------------------//
104 bool is_open() const { return this->member.is_open(); }
105 void close() { this->member.close(); }
106 bool auto_close() const { return this->member.auto_close(); }
107 void set_auto_close(bool close) { this->member.set_auto_close(close); }
108 bool strict_sync() { return this->member.strict_sync(); }
109 Device& operator*() { return *this->member; }
110 Device* operator->() { return &*this->member; }
111private:
112 template<typename U0>
113 void open_impl(mpl::false_, const U0& u0)
114 {
115 this->clear();
116 this->member.open(u0);
117 }
118#if !NDNBOOST_WORKAROUND(NDNBOOST_MSVC, <= 1300) //---------------------------------//
119 template<typename U0>
120 void open_impl(mpl::false_, U0& u0)
121 {
122 this->clear();
123 this->member.open(detail::wrap(u0));
124 }
125#endif // !NDNBOOST_WORKAROUND(NDNBOOST_MSVC, <= 1300) //---------------------------//
126 template<typename U0>
127 void open_impl(mpl::true_, const U0& u0)
128 {
129 this->clear();
130 this->member.open(Device(const_cast<U0&>(u0)));
131 }
132#if !NDNBOOST_WORKAROUND(NDNBOOST_MSVC, <= 1300) //---------------------------------//
133 template<typename U0>
134 void open_impl(mpl::true_, U0& u0)
135 {
136 this->clear();
137 this->member.open(Device(u0));
138 }
139#endif // !NDNBOOST_WORKAROUND(NDNBOOST_MSVC, <= 1300) //---------------------------//
140 template<typename U0, typename U1>
141 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>
147 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 !NDNBOOST_WORKAROUND(NDNBOOST_MSVC, <= 1300) //---------------------------------//
153 template<typename U0, typename U1>
154 void open_impl(mpl::true_, U0& u0, const U1& u1)
155 {
156 this->clear();
157 this->member.open(Device(u0, u1));
158 }
159#endif // !NDNBOOST_WORKAROUND(NDNBOOST_MSVC, <= 1300) //---------------------------//
160 template<typename U0, typename U1, typename U2>
161 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>
167 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 !NDNBOOST_WORKAROUND(NDNBOOST_MSVC, <= 1300) //---------------------------------//
173 template<typename U0, typename U1, typename U2>
174 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 NDNBOOST_IOSTREAMS_DETAIL_BROKEN_OVERLOAD_RESOLUTION_STREAM_HPP_INCLUDED