Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-31 10:02:39

0001 /*=============================================================================
0002     Copyright (c) 2001-2014 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_X3_SUPPORT_NO_CASE_SEPT_24_2014_1125PM)
0008 #define BOOST_SPIRIT_X3_SUPPORT_NO_CASE_SEPT_24_2014_1125PM
0009 
0010 #include <boost/spirit/home/x3/support/unused.hpp>
0011 #include <boost/spirit/home/x3/support/context.hpp>
0012 #include <boost/spirit/home/x3/char/char_class_tags.hpp>
0013 
0014 namespace boost { namespace spirit { namespace x3
0015 {
0016     struct no_case_tag {};
0017 
0018     template <typename Encoding>
0019     struct case_compare
0020     {
0021         template <typename Char, typename CharSet>
0022         bool in_set(Char ch, CharSet const& set)
0023         {
0024             return set.test(ch);
0025         }
0026 
0027         template <typename Char>
0028         int32_t operator()(Char lc, Char rc) const
0029         {
0030             return lc - rc;
0031         }
0032 
0033         template <typename CharClassTag>
0034         CharClassTag get_char_class_tag(CharClassTag tag) const
0035         {
0036             return tag;
0037         }
0038     };
0039 
0040     template <typename Encoding>
0041     struct no_case_compare
0042     {
0043         template <typename Char, typename CharSet>
0044         bool in_set(Char ch_, CharSet const& set)
0045         {
0046             using char_type = typename Encoding::classify_type;
0047             auto ch = char_type(ch_);
0048             return set.test(ch)
0049                 || set.test(Encoding::islower(ch)
0050                     ? Encoding::toupper(ch) : Encoding::tolower(ch));
0051         }
0052 
0053         template <typename Char>
0054         int32_t operator()(Char lc_, Char const rc_) const
0055         {
0056             using char_type = typename Encoding::classify_type;
0057             auto lc = char_type(lc_);
0058             auto rc = char_type(rc_);
0059             return Encoding::islower(rc)
0060                 ? Encoding::tolower(lc) - rc : Encoding::toupper(lc) - rc;
0061         }
0062 
0063         template <typename CharClassTag>
0064         CharClassTag get_char_class_tag(CharClassTag tag) const
0065         {
0066             return tag;
0067         }
0068 
0069         alpha_tag get_char_class_tag(lower_tag ) const
0070         {
0071             return {};
0072         }
0073 
0074         alpha_tag get_char_class_tag(upper_tag ) const
0075         {
0076             return {};
0077         }
0078 
0079     };
0080 
0081     template <typename Encoding>
0082     case_compare<Encoding> get_case_compare_impl(unused_type const&)
0083     {
0084         return {};
0085     }
0086 
0087     template <typename Encoding>
0088     no_case_compare<Encoding> get_case_compare_impl(no_case_tag const&)
0089     {
0090         return {};
0091     }
0092 
0093     template <typename Encoding, typename Context>
0094     inline decltype(auto) get_case_compare(Context const& context)
0095     {
0096         return get_case_compare_impl<Encoding>(x3::get<no_case_tag>(context));
0097     }
0098 
0099     auto const no_case_compare_ = no_case_tag{};
0100 
0101 }}}
0102 
0103 #endif