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_NO_CASE_STRING_PARSE_APR_18_2014_1125PM)
8 #define BOOST_SPIRIT_X3_NO_CASE_STRING_PARSE_APR_18_2014_1125PM
10 #include <boost/spirit/home/x3/char/char.hpp>
11 #include <boost/spirit/home/x3/support/traits/move_to.hpp>
13 namespace boost { namespace spirit { namespace x3 { namespace detail
15 template <typename Char, typename Encoding>
18 typedef std::basic_string< Char > string_type;
19 typedef typename string_type::const_iterator const_iterator;
21 no_case_string(char_type const* str)
25 typename string_type::iterator loi = lower.begin();
26 typename string_type::iterator upi = upper.begin();
28 typedef typename Encoding::char_type encoded_char_type;
30 for (; loi != lower.end(); ++loi, ++upi)
32 *loi = static_cast<char_type>(encoding.tolower(encoded_char_type(*loi)));
33 *upi = static_cast<char_type>(encoding.toupper(encoded_char_type(*upi)));
41 template <typename String, typename Iterator, typename Attribute>
42 inline bool no_case_string_parse(
44 , Iterator& first, Iterator const& last, Attribute& attr)
46 typename String::const_iterator uc_i = str.upper.begin();
47 typename String::const_iterator uc_last = str.upper.end();
48 typename String::const_iterator lc_i = str.lower.begin();
51 for (; uc_i != uc_last; ++uc_i, ++lc_i, ++i)
52 if (i == last || ((*uc_i != *i) && (*lc_i != *i)))
54 x3::traits::move_to(first, i, attr);