Chris@16
|
1 // (C) Copyright 2008 CodeRage, LLC (turkanis at coderage dot com)
|
Chris@16
|
2 // (C) Copyright 2003-2007 Jonathan Turkanis
|
Chris@16
|
3 // Distributed under the Boost Software License, Version 1.0. (See accompanying
|
Chris@16
|
4 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt.)
|
Chris@16
|
5
|
Chris@16
|
6 // See http://www.boost.org/libs/iostreams for documentation.
|
Chris@16
|
7
|
Chris@16
|
8 #ifndef BOOST_IOSTREAMS_CONCEPTS_HPP_INCLUDED
|
Chris@16
|
9 #define BOOST_IOSTREAMS_CONCEPTS_HPP_INCLUDED
|
Chris@16
|
10
|
Chris@16
|
11 #if defined(_MSC_VER) && (_MSC_VER >= 1020)
|
Chris@16
|
12 # pragma once
|
Chris@16
|
13 #endif
|
Chris@16
|
14
|
Chris@16
|
15 #include <boost/config.hpp> // BOOST_MSVC
|
Chris@16
|
16 #include <boost/detail/workaround.hpp>
|
Chris@16
|
17 #include <boost/iostreams/categories.hpp>
|
Chris@16
|
18 #include <boost/iostreams/detail/default_arg.hpp>
|
Chris@16
|
19 #include <boost/iostreams/detail/ios.hpp> // openmode.
|
Chris@16
|
20 #include <boost/iostreams/positioning.hpp>
|
Chris@16
|
21 #include <boost/static_assert.hpp>
|
Chris@16
|
22 #include <boost/type_traits/is_convertible.hpp>
|
Chris@16
|
23
|
Chris@16
|
24 namespace boost { namespace iostreams {
|
Chris@16
|
25
|
Chris@16
|
26 //--------------Definitions of helper templates for device concepts-----------//
|
Chris@16
|
27
|
Chris@16
|
28 template<typename Mode, typename Ch = BOOST_IOSTREAMS_DEFAULT_ARG(char)>
|
Chris@16
|
29 struct device {
|
Chris@16
|
30 typedef Ch char_type;
|
Chris@16
|
31 struct category
|
Chris@16
|
32 : Mode,
|
Chris@16
|
33 device_tag,
|
Chris@16
|
34 closable_tag,
|
Chris@16
|
35 localizable_tag
|
Chris@16
|
36 { };
|
Chris@16
|
37
|
Chris@16
|
38 void close()
|
Chris@16
|
39 {
|
Chris@16
|
40 using namespace detail;
|
Chris@16
|
41 BOOST_STATIC_ASSERT((!is_convertible<Mode, two_sequence>::value));
|
Chris@16
|
42 }
|
Chris@16
|
43
|
Chris@16
|
44 void close(BOOST_IOS::openmode)
|
Chris@16
|
45 {
|
Chris@16
|
46 using namespace detail;
|
Chris@16
|
47 BOOST_STATIC_ASSERT((is_convertible<Mode, two_sequence>::value));
|
Chris@16
|
48 }
|
Chris@16
|
49
|
Chris@16
|
50 template<typename Locale>
|
Chris@16
|
51 void imbue(const Locale&) { }
|
Chris@16
|
52 };
|
Chris@16
|
53
|
Chris@16
|
54 template<typename Mode, typename Ch = BOOST_IOSTREAMS_DEFAULT_ARG(wchar_t)>
|
Chris@16
|
55 struct wdevice : device<Mode, Ch> { };
|
Chris@16
|
56
|
Chris@16
|
57 typedef device<input> source;
|
Chris@16
|
58 typedef wdevice<input> wsource;
|
Chris@16
|
59 typedef device<output> sink;
|
Chris@16
|
60 typedef wdevice<output> wsink;
|
Chris@16
|
61
|
Chris@16
|
62 //--------------Definitions of helper templates for simple filter concepts----//
|
Chris@16
|
63
|
Chris@16
|
64 template<typename Mode, typename Ch = BOOST_IOSTREAMS_DEFAULT_ARG(char)>
|
Chris@16
|
65 struct filter {
|
Chris@16
|
66 typedef Ch char_type;
|
Chris@16
|
67 struct category
|
Chris@16
|
68 : Mode,
|
Chris@16
|
69 filter_tag,
|
Chris@16
|
70 closable_tag,
|
Chris@16
|
71 localizable_tag
|
Chris@16
|
72 { };
|
Chris@16
|
73
|
Chris@16
|
74 template<typename Device>
|
Chris@16
|
75 void close(Device&)
|
Chris@16
|
76 {
|
Chris@16
|
77 using namespace detail;
|
Chris@16
|
78 BOOST_STATIC_ASSERT((!is_convertible<Mode, two_sequence>::value));
|
Chris@16
|
79 BOOST_STATIC_ASSERT((!is_convertible<Mode, dual_use>::value));
|
Chris@16
|
80 }
|
Chris@16
|
81
|
Chris@16
|
82 template<typename Device>
|
Chris@16
|
83 void close(Device&, BOOST_IOS::openmode)
|
Chris@16
|
84 {
|
Chris@16
|
85 using namespace detail;
|
Chris@16
|
86 BOOST_STATIC_ASSERT(
|
Chris@16
|
87 (is_convertible<Mode, two_sequence>::value) ||
|
Chris@16
|
88 (is_convertible<Mode, dual_use>::value)
|
Chris@16
|
89 );
|
Chris@16
|
90 }
|
Chris@16
|
91
|
Chris@16
|
92 template<typename Locale>
|
Chris@16
|
93 void imbue(const Locale&) { }
|
Chris@16
|
94 };
|
Chris@16
|
95
|
Chris@16
|
96 template<typename Mode, typename Ch = BOOST_IOSTREAMS_DEFAULT_ARG(wchar_t)>
|
Chris@16
|
97 struct wfilter : filter<Mode, Ch> { };
|
Chris@16
|
98
|
Chris@16
|
99 typedef filter<input> input_filter;
|
Chris@16
|
100 typedef wfilter<input> input_wfilter;
|
Chris@16
|
101 typedef filter<output> output_filter;
|
Chris@16
|
102 typedef wfilter<output> output_wfilter;
|
Chris@16
|
103 typedef filter<seekable> seekable_filter;
|
Chris@16
|
104 typedef wfilter<seekable> seekable_wfilter;
|
Chris@16
|
105 typedef filter<dual_use> dual_use_filter;
|
Chris@16
|
106 typedef wfilter<dual_use> dual_use_wfilter;
|
Chris@16
|
107
|
Chris@16
|
108 //------Definitions of helper templates for multi-character filter cncepts----//
|
Chris@16
|
109
|
Chris@16
|
110 template<typename Mode, typename Ch = char>
|
Chris@16
|
111 struct multichar_filter : filter<Mode, Ch> {
|
Chris@16
|
112 struct category : filter<Mode, Ch>::category, multichar_tag { };
|
Chris@16
|
113 };
|
Chris@16
|
114
|
Chris@16
|
115 template<typename Mode, typename Ch = wchar_t>
|
Chris@16
|
116 struct multichar_wfilter : multichar_filter<Mode, Ch> { };
|
Chris@16
|
117
|
Chris@16
|
118 typedef multichar_filter<input> multichar_input_filter;
|
Chris@16
|
119 typedef multichar_wfilter<input> multichar_input_wfilter;
|
Chris@16
|
120 typedef multichar_filter<output> multichar_output_filter;
|
Chris@16
|
121 typedef multichar_wfilter<output> multichar_output_wfilter;
|
Chris@16
|
122 typedef multichar_filter<dual_use> multichar_dual_use_filter;
|
Chris@16
|
123 typedef multichar_wfilter<dual_use> multichar_dual_use_wfilter;
|
Chris@16
|
124
|
Chris@16
|
125 //----------------------------------------------------------------------------//
|
Chris@16
|
126
|
Chris@16
|
127 } } // End namespaces iostreams, boost.
|
Chris@16
|
128
|
Chris@16
|
129 #endif // #ifndef BOOST_IOSTREAMS_CONCEPTS_HPP_INCLUDED
|