File indexing completed on 2025-01-31 10:02:37
0001
0002
0003
0004
0005
0006
0007 #if !defined(BOOST_SPIRIT_X3_STRING_PARSE_APR_18_2006_1125PM)
0008 #define BOOST_SPIRIT_X3_STRING_PARSE_APR_18_2006_1125PM
0009
0010 #include <boost/spirit/home/x3/support/traits/move_to.hpp>
0011
0012 namespace boost { namespace spirit { namespace x3 { namespace detail
0013 {
0014 template <typename Char, typename Iterator, typename Attribute, typename CaseCompareFunc>
0015 inline bool string_parse(
0016 Char const* str
0017 , Iterator& first, Iterator const& last, Attribute& attr, CaseCompareFunc const& compare)
0018 {
0019 Iterator i = first;
0020 Char ch = *str;
0021
0022 for (; !!ch; ++i)
0023 {
0024 if (i == last || (compare(ch, *i) != 0))
0025 return false;
0026 ch = *++str;
0027 }
0028
0029 x3::traits::move_to(first, i, attr);
0030 first = i;
0031 return true;
0032 }
0033
0034 template <typename String, typename Iterator, typename Attribute, typename CaseCompareFunc>
0035 inline bool string_parse(
0036 String const& str
0037 , Iterator& first, Iterator const& last, Attribute& attr, CaseCompareFunc const& compare)
0038 {
0039 Iterator i = first;
0040 typename String::const_iterator stri = str.begin();
0041 typename String::const_iterator str_last = str.end();
0042
0043 for (; stri != str_last; ++stri, ++i)
0044 if (i == last || (compare(*stri, *i) != 0))
0045 return false;
0046 x3::traits::move_to(first, i, attr);
0047 first = i;
0048 return true;
0049 }
0050
0051 template <typename Char, typename Iterator, typename Attribute>
0052 inline bool string_parse(
0053 Char const* uc_i, Char const* lc_i
0054 , Iterator& first, Iterator const& last, Attribute& attr)
0055 {
0056 Iterator i = first;
0057
0058 for (; *uc_i && *lc_i; ++uc_i, ++lc_i, ++i)
0059 if (i == last || ((*uc_i != *i) && (*lc_i != *i)))
0060 return false;
0061 x3::traits::move_to(first, i, attr);
0062 first = i;
0063 return true;
0064 }
0065
0066 template <typename String, typename Iterator, typename Attribute>
0067 inline bool string_parse(
0068 String const& ucstr, String const& lcstr
0069 , Iterator& first, Iterator const& last, Attribute& attr)
0070 {
0071 typename String::const_iterator uc_i = ucstr.begin();
0072 typename String::const_iterator uc_last = ucstr.end();
0073 typename String::const_iterator lc_i = lcstr.begin();
0074 Iterator i = first;
0075
0076 for (; uc_i != uc_last; ++uc_i, ++lc_i, ++i)
0077 if (i == last || ((*uc_i != *i) && (*lc_i != *i)))
0078 return false;
0079 x3::traits::move_to(first, i, attr);
0080 first = i;
0081 return true;
0082 }
0083 }}}}
0084
0085 #endif