]> git.lyx.org Git - lyx.git/blob - boost/boost/iostreams/concepts.hpp
Replace gzstream by boost::iostreams::gzip_(de)compressor: by Bo Peng (ben.bob@gmail...
[lyx.git] / boost / boost / iostreams / concepts.hpp
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_CONCEPTS_HPP_INCLUDED
8 #define BOOST_IOSTREAMS_CONCEPTS_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/categories.hpp>
17 #include <boost/iostreams/detail/default_arg.hpp>
18 #include <boost/iostreams/detail/ios.hpp>  // openmode.
19 #include <boost/iostreams/positioning.hpp>
20 #include <boost/static_assert.hpp>
21 #include <boost/type_traits/is_convertible.hpp>
22
23 namespace boost { namespace iostreams {
24
25 //--------------Definitions of helper templates for device concepts-----------//
26
27 template<typename Mode, typename Ch = BOOST_IOSTREAMS_DEFAULT_ARG(char)>
28 struct device {
29     typedef Ch char_type;
30     struct category
31         : Mode,
32           device_tag,
33           closable_tag,
34           localizable_tag
35         { };
36
37     void close()
38     {
39         using namespace detail;
40         BOOST_STATIC_ASSERT((!is_convertible<Mode, two_sequence>::value));
41     }
42
43     void close(BOOST_IOS::openmode)
44     {
45         using namespace detail;
46         BOOST_STATIC_ASSERT((is_convertible<Mode, two_sequence>::value));
47     }
48
49     template<typename Locale>
50     void imbue(const Locale&) { }
51 };
52
53 template<typename Mode, typename Ch = BOOST_IOSTREAMS_DEFAULT_ARG(wchar_t)>
54 struct wdevice : device<Mode, Ch> { };
55
56 typedef device<input>    source;
57 typedef wdevice<input>   wsource;
58 typedef device<output>   sink;
59 typedef wdevice<output>  wsink;
60
61 //--------------Definitions of helper templates for simple filter concepts----//
62
63 template<typename Mode, typename Ch = BOOST_IOSTREAMS_DEFAULT_ARG(char)>
64 struct filter {
65     typedef Ch char_type;
66     struct category
67         : Mode,
68           filter_tag,
69           closable_tag,
70           localizable_tag
71         { };
72
73     template<typename Device>
74     void close(Device&)
75     {
76         using namespace detail;
77         BOOST_STATIC_ASSERT((!is_convertible<Mode, two_sequence>::value));
78         BOOST_STATIC_ASSERT((!is_convertible<Mode, dual_use>::value));
79     }
80
81     template<typename Device>
82     void close(Device&, BOOST_IOS::openmode)
83     {
84         using namespace detail;
85         BOOST_STATIC_ASSERT(
86             (is_convertible<Mode, two_sequence>::value) ||
87             (is_convertible<Mode, dual_use>::value)
88         );
89     }
90
91     template<typename Locale>
92     void imbue(const Locale&) { }
93 };
94
95 template<typename Mode, typename Ch = BOOST_IOSTREAMS_DEFAULT_ARG(wchar_t)>
96 struct wfilter : filter<Mode, Ch> { };
97
98 typedef filter<input>      input_filter;
99 typedef wfilter<input>     input_wfilter;
100 typedef filter<output>     output_filter;
101 typedef wfilter<output>    output_wfilter;
102 typedef filter<seekable>   seekable_filter;
103 typedef wfilter<seekable>  seekable_wfilter;
104 typedef filter<dual_use>   dual_use_filter;
105 typedef wfilter<dual_use>  dual_use_wfilter;
106         
107 //------Definitions of helper templates for multi-character filter cncepts----//
108
109 template<typename Mode, typename Ch = char>
110 struct multichar_filter : filter<Mode, Ch> {
111     struct category : filter<Mode, Ch>::category, multichar_tag { };
112 };
113
114 template<typename Mode, typename Ch = wchar_t>
115 struct multichar_wfilter : multichar_filter<Mode, Ch> { };
116
117 typedef multichar_filter<input>     multichar_input_filter;
118 typedef multichar_filter<input>     multichar_input_wfilter;
119 typedef multichar_filter<output>    multichar_output_filter;
120 typedef multichar_filter<output>    multichar_output_wfilter;
121 typedef multichar_filter<dual_use>  multichar_dual_use_filter;
122 typedef multichar_filter<dual_use>  multichar_dual_use_wfilter;
123
124 //----------------------------------------------------------------------------//
125
126 } } // End namespaces iostreams, boost.
127
128 #endif // #ifndef BOOST_IOSTREAMS_CONCEPTS_HPP_INCLUDED