1 /*=============================================================================
2 Copyright (c) 2001-2014 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)
6 ==============================================================================*/
7 #if !defined(BOOST_SPIRIT_X3_SUPPORT_NO_CASE_SEPT_24_2014_1125PM)
8 #define BOOST_SPIRIT_X3_SUPPORT_NO_CASE_SEPT_24_2014_1125PM
10 #include <boost/spirit/home/x3/support/unused.hpp>
11 #include <boost/spirit/home/x3/support/context.hpp>
12 #include <boost/spirit/home/x3/char/char_class_tags.hpp>
14 namespace boost { namespace spirit { namespace x3
16 struct no_case_tag {};
18 template <typename Encoding>
21 template < template <typename> class basic_charset>
22 typename Encoding::char_type
23 in_set( typename Encoding::char_type const ch
24 , basic_charset<typename Encoding::char_type> const &set)
30 typename Encoding::char_type const lc
31 , typename Encoding::char_type const rc) const
37 template <typename CharClassTag>
38 CharClassTag get_char_class_tag(CharClassTag tag) const
44 template <typename Encoding>
45 struct no_case_compare
47 template < template <typename> class basic_charset>
48 typename Encoding::char_type
49 in_set( typename Encoding::char_type const ch
50 , basic_charset<typename Encoding::char_type> const &set)
53 || set.test(Encoding::islower(ch) ? Encoding::toupper(ch) : Encoding::tolower(ch));
57 typename Encoding::char_type const lc
58 , typename Encoding::char_type const rc) const
60 return Encoding::islower(rc) ? Encoding::tolower(lc) - rc : Encoding::toupper(lc) - rc;
63 template <typename CharClassTag>
64 CharClassTag get_char_class_tag(CharClassTag tag) const
69 alpha_tag get_char_class_tag(lower_tag ) const
74 alpha_tag get_char_class_tag(upper_tag ) const
81 template <typename Encoding>
82 case_compare<Encoding> get_case_compare_impl(unused_type const&)
87 template <typename Encoding>
88 no_case_compare<Encoding> get_case_compare_impl(no_case_tag const&)
93 template <typename Encoding, typename Context>
94 inline decltype(auto) get_case_compare(Context const& context)
96 return get_case_compare_impl<Encoding>(x3::get<no_case_tag>(context));
98 auto const no_case_compare_ = no_case_tag{};