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_IMBUE_HPP_INCLUDED
|
Chris@16
|
9 #define BOOST_IOSTREAMS_IMBUE_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> // DEDUCED_TYPENAME, MSVC.
|
Chris@16
|
16 #include <boost/detail/workaround.hpp>
|
Chris@16
|
17 #include <boost/iostreams/detail/dispatch.hpp>
|
Chris@16
|
18 #include <boost/iostreams/detail/streambuf.hpp>
|
Chris@16
|
19 #include <boost/iostreams/detail/wrap_unwrap.hpp>
|
Chris@16
|
20 #include <boost/iostreams/operations_fwd.hpp>
|
Chris@16
|
21 #include <boost/mpl/if.hpp>
|
Chris@16
|
22
|
Chris@16
|
23 // Must come last.
|
Chris@16
|
24 #include <boost/iostreams/detail/config/disable_warnings.hpp>
|
Chris@16
|
25
|
Chris@16
|
26 namespace boost { namespace iostreams {
|
Chris@16
|
27
|
Chris@16
|
28 namespace detail {
|
Chris@16
|
29
|
Chris@16
|
30 // Implementation templates for simulated tag dispatch.
|
Chris@16
|
31 template<typename T>
|
Chris@16
|
32 struct imbue_impl;
|
Chris@16
|
33
|
Chris@16
|
34 } // End namespace detail.
|
Chris@16
|
35
|
Chris@16
|
36 template<typename T, typename Locale>
|
Chris@16
|
37 void imbue(T& t, const Locale& loc)
|
Chris@16
|
38 { detail::imbue_impl<T>::imbue(detail::unwrap(t), loc); }
|
Chris@16
|
39
|
Chris@16
|
40 namespace detail {
|
Chris@16
|
41
|
Chris@16
|
42 //------------------Definition of imbue_impl----------------------------------//
|
Chris@16
|
43
|
Chris@16
|
44 template<typename T>
|
Chris@16
|
45 struct imbue_impl
|
Chris@16
|
46 : mpl::if_<
|
Chris@16
|
47 is_custom<T>,
|
Chris@16
|
48 operations<T>,
|
Chris@16
|
49 imbue_impl<
|
Chris@16
|
50 BOOST_DEDUCED_TYPENAME
|
Chris@16
|
51 dispatch<
|
Chris@16
|
52 T, streambuf_tag, localizable_tag, any_tag
|
Chris@16
|
53 >::type
|
Chris@16
|
54 >
|
Chris@16
|
55 >::type
|
Chris@16
|
56 { };
|
Chris@16
|
57
|
Chris@16
|
58 template<>
|
Chris@16
|
59 struct imbue_impl<any_tag> {
|
Chris@16
|
60 template<typename T, typename Locale>
|
Chris@16
|
61 static void imbue(T&, const Locale&) { }
|
Chris@16
|
62 };
|
Chris@16
|
63
|
Chris@16
|
64 template<>
|
Chris@16
|
65 struct imbue_impl<streambuf_tag> {
|
Chris@16
|
66 template<typename T, typename Locale>
|
Chris@16
|
67 static void imbue(T& t, const Locale& loc) { t.pubimbue(loc); }
|
Chris@16
|
68 };
|
Chris@16
|
69
|
Chris@16
|
70 template<>
|
Chris@16
|
71 struct imbue_impl<localizable_tag> {
|
Chris@16
|
72 template<typename T, typename Locale>
|
Chris@16
|
73 static void imbue(T& t, const Locale& loc) { t.imbue(loc); }
|
Chris@16
|
74 };
|
Chris@16
|
75
|
Chris@16
|
76 } // End namespace detail.
|
Chris@16
|
77
|
Chris@16
|
78 } } // End namespaces iostreams, boost.
|
Chris@16
|
79
|
Chris@16
|
80 #include <boost/iostreams/detail/config/enable_warnings.hpp>
|
Chris@16
|
81
|
Chris@16
|
82 #endif // #ifndef BOOST_IOSTREAMS_IMBUE_HPP_INCLUDED
|