]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
1 | /*============================================================================= |
2 | Copyright (c) 2001-2011 Joel de Guzman | |
3 | ||
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_STRING_PARSE_APR_18_2006_1125PM) | |
8 | #define BOOST_SPIRIT_STRING_PARSE_APR_18_2006_1125PM | |
9 | ||
10 | #if defined(_MSC_VER) | |
11 | #pragma once | |
12 | #endif | |
13 | ||
14 | #include <boost/spirit/home/qi/detail/assign_to.hpp> | |
15 | ||
16 | namespace boost { namespace spirit { namespace qi { namespace detail | |
17 | { | |
18 | template <typename Char, typename Iterator, typename Attribute> | |
19 | inline bool string_parse( | |
20 | Char const* str | |
21 | , Iterator& first, Iterator const& last, Attribute& attr) | |
22 | { | |
23 | Iterator i = first; | |
24 | Char ch = *str; | |
25 | ||
26 | for (; !!ch; ++i) | |
27 | { | |
28 | if (i == last || (ch != *i)) | |
29 | return false; | |
30 | ch = *++str; | |
31 | } | |
32 | ||
33 | spirit::traits::assign_to(first, i, attr); | |
34 | first = i; | |
35 | return true; | |
36 | } | |
37 | ||
38 | template <typename String, typename Iterator, typename Attribute> | |
39 | inline bool string_parse( | |
40 | String const& str | |
41 | , Iterator& first, Iterator const& last, Attribute& attr) | |
42 | { | |
43 | Iterator i = first; | |
44 | typename String::const_iterator stri = str.begin(); | |
45 | typename String::const_iterator str_last = str.end(); | |
46 | ||
47 | for (; stri != str_last; ++stri, ++i) | |
48 | if (i == last || (*stri != *i)) | |
49 | return false; | |
50 | spirit::traits::assign_to(first, i, attr); | |
51 | first = i; | |
52 | return true; | |
53 | } | |
54 | ||
55 | template <typename Char, typename Iterator, typename Attribute> | |
56 | inline bool string_parse( | |
57 | Char const* uc_i, Char const* lc_i | |
58 | , Iterator& first, Iterator const& last, Attribute& attr) | |
59 | { | |
60 | Iterator i = first; | |
61 | ||
62 | for (; *uc_i && *lc_i; ++uc_i, ++lc_i, ++i) | |
63 | if (i == last || ((*uc_i != *i) && (*lc_i != *i))) | |
64 | return false; | |
65 | spirit::traits::assign_to(first, i, attr); | |
66 | first = i; | |
67 | return true; | |
68 | } | |
69 | ||
70 | template <typename String, typename Iterator, typename Attribute> | |
71 | inline bool string_parse( | |
72 | String const& ucstr, String const& lcstr | |
73 | , Iterator& first, Iterator const& last, Attribute& attr) | |
74 | { | |
75 | typename String::const_iterator uc_i = ucstr.begin(); | |
76 | typename String::const_iterator uc_last = ucstr.end(); | |
77 | typename String::const_iterator lc_i = lcstr.begin(); | |
78 | Iterator i = first; | |
79 | ||
80 | for (; uc_i != uc_last; ++uc_i, ++lc_i, ++i) | |
81 | if (i == last || ((*uc_i != *i) && (*lc_i != *i))) | |
82 | return false; | |
83 | spirit::traits::assign_to(first, i, attr); | |
84 | first = i; | |
85 | return true; | |
86 | } | |
87 | }}}} | |
88 | ||
89 | #endif |