Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-19 09:47:50

0001 //  Copyright (c) 2001-2011 Hartmut Kaiser
0002 //  Copyright (c) 2001-2011 Joel de Guzman
0003 //
0004 //  Distributed under the Boost Software License, Version 1.0. (See accompanying
0005 //  file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
0006 
0007 #if !defined(BOOST_SPIRIT_GET_ENCODING_JANUARY_13_2009_1255PM)
0008 #define BOOST_SPIRIT_GET_ENCODING_JANUARY_13_2009_1255PM
0009 
0010 #if defined(_MSC_VER)
0011 #pragma once
0012 #endif
0013 
0014 #include <boost/mpl/identity.hpp>
0015 #include <boost/type_traits/is_same.hpp>
0016 
0017 namespace boost { namespace spirit { namespace detail
0018 {
0019     template <typename Modifiers, typename Encoding>
0020     struct get_implicit_encoding
0021     {
0022         // Extract the implicit encoding from the Modifiers
0023         // If one is not found, Encoding is used. The explicit
0024         // encoding is the first viable encoding that can be
0025         // extracted from the Modifiers (there can be more than one).
0026 
0027         typedef typename
0028             mpl::find_if<
0029                 char_encodings,
0030                 has_modifier<Modifiers, tag::char_encoding_base<mpl::_1> >
0031             >::type
0032         iter;
0033 
0034         typedef typename
0035             mpl::eval_if<
0036                 is_same<iter, typename mpl::end<char_encodings>::type>,
0037                 mpl::identity<Encoding>,
0038                 mpl::deref<iter>
0039             >::type
0040         type;
0041     };
0042 
0043     template <typename Modifiers, typename Encoding>
0044     struct get_encoding
0045     {
0046         // Extract the explicit encoding from the Modifiers
0047         // If one is not found, get implicit encoding (see above).
0048         // Explicit encoding is the encoding explicitly declared
0049         // using the encoding[c] directive.
0050 
0051         typedef typename
0052             mpl::find_if<
0053                 char_encodings,
0054                 has_modifier<Modifiers, tag::char_code<tag::encoding, mpl::_1> >
0055             >::type
0056         iter;
0057 
0058         typedef typename
0059             mpl::eval_if<
0060                 is_same<iter, typename mpl::end<char_encodings>::type>,
0061                 get_implicit_encoding<Modifiers, Encoding>,
0062                 mpl::deref<iter>
0063             >::type
0064         type;
0065     };
0066 
0067     template <typename Modifiers, typename Encoding, bool case_modifier = false>
0068     struct get_encoding_with_case : mpl::identity<Encoding> {};
0069 
0070     template <typename Modifiers, typename Encoding>
0071     struct get_encoding_with_case<Modifiers, Encoding, true>
0072         : get_encoding<Modifiers, Encoding> {};
0073 }}}
0074 
0075 #endif