1 // Copyright (c) 2001-2011 Hartmut Kaiser
2 // Copyright (c) 2001-2011 Joel de Guzman
4 // Distributed under the Boost Software License, Version 1.0. (See accompanying
5 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
7 #if !defined(BOOST_SPIRIT_GET_ENCODING_JANUARY_13_2009_1255PM)
8 #define BOOST_SPIRIT_GET_ENCODING_JANUARY_13_2009_1255PM
14 #include <boost/mpl/identity.hpp>
15 #include <boost/type_traits/is_same.hpp>
17 namespace boost { namespace spirit { namespace detail
19 template <typename Modifiers, typename Encoding>
20 struct get_implicit_encoding
22 // Extract the implicit encoding from the Modifiers
23 // If one is not found, Encoding is used. The explicit
24 // encoding is the first viable encoding that can be
25 // extracted from the Modifiers (there can be more than one).
30 has_modifier<Modifiers, tag::char_encoding_base<mpl::_1> >
36 is_same<iter, typename mpl::end<char_encodings>::type>,
37 mpl::identity<Encoding>,
43 template <typename Modifiers, typename Encoding>
46 // Extract the explicit encoding from the Modifiers
47 // If one is not found, get implicit encoding (see above).
48 // Explicit encoding is the encoding explicitly declared
49 // using the encoding[c] directive.
54 has_modifier<Modifiers, tag::char_code<tag::encoding, mpl::_1> >
60 is_same<iter, typename mpl::end<char_encodings>::type>,
61 get_implicit_encoding<Modifiers, Encoding>,
67 template <typename Modifiers, typename Encoding, bool case_modifier = false>
68 struct get_encoding_with_case : mpl::identity<Encoding> {};
70 template <typename Modifiers, typename Encoding>
71 struct get_encoding_with_case<Modifiers, Encoding, true>
72 : get_encoding<Modifiers, Encoding> {};