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_STRING_PARSE_APR_18_2006_1125PM)
8 #define BOOST_SPIRIT_X3_STRING_PARSE_APR_18_2006_1125PM
10 #include <boost/spirit/home/x3/support/traits/move_to.hpp>
12 namespace boost { namespace spirit { namespace x3 { namespace detail
14 template <typename Char, typename Iterator, typename Attribute, typename CaseCompareFunc>
15 inline bool string_parse(
17 , Iterator& first, Iterator const& last, Attribute& attr, CaseCompareFunc const& compare)
24 if (i == last || (compare(ch, *i) != 0))
29 x3::traits::move_to(first, i, attr);
34 template <typename String, typename Iterator, typename Attribute, typename CaseCompareFunc>
35 inline bool string_parse(
37 , Iterator& first, Iterator const& last, Attribute& attr, CaseCompareFunc const& compare)
40 typename String::const_iterator stri = str.begin();
41 typename String::const_iterator str_last = str.end();
43 for (; stri != str_last; ++stri, ++i)
44 if (i == last || (compare(*stri, *i) != 0))
46 x3::traits::move_to(first, i, attr);
51 template <typename Char, typename Iterator, typename Attribute>
52 inline bool string_parse(
53 Char const* uc_i, Char const* lc_i
54 , Iterator& first, Iterator const& last, Attribute& attr)
58 for (; *uc_i && *lc_i; ++uc_i, ++lc_i, ++i)
59 if (i == last || ((*uc_i != *i) && (*lc_i != *i)))
61 x3::traits::move_to(first, i, attr);
66 template <typename String, typename Iterator, typename Attribute>
67 inline bool string_parse(
68 String const& ucstr, String const& lcstr
69 , Iterator& first, Iterator const& last, Attribute& attr)
71 typename String::const_iterator uc_i = ucstr.begin();
72 typename String::const_iterator uc_last = ucstr.end();
73 typename String::const_iterator lc_i = lcstr.begin();
76 for (; uc_i != uc_last; ++uc_i, ++lc_i, ++i)
77 if (i == last || ((*uc_i != *i) && (*lc_i != *i)))
79 x3::traits::move_to(first, i, attr);