32 #include <boost/utility/string_ref.hpp> 46 static const constexpr
uint8_t lut[256]={
47 0, 0, 0, 0, 0, 0, 0, 0, 0, 8, 8, 8, 8, 8, 0, 0,
48 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
49 8, 0, 32, 0, 0, 0, 0, 0, 0, 0, 0, 16, 0, 16, 18, 0,
50 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 0, 0, 0, 0, 0, 0,
51 0, 4, 4, 4, 4, 22, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
52 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 0, 32, 0, 0, 0,
53 0, 4, 4, 4, 4, 22, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
54 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 0, 0, 0, 0, 0,
55 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
56 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
57 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
58 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
59 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
60 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
61 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
62 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
77 static const char escaped[] =
"\b\f\n\r\t\v\"\\/";
78 std::string::const_iterator it = std::find_first_of(src.begin(), src.end(), escaped, escaped +
sizeof(escaped));
83 res.reserve(2 * src.size());
84 res.assign(src.begin(), it);
85 for(; it!=src.end(); ++it)
130 bool escape_mode =
false;
131 std::string::const_iterator it = star_end_string;
133 std::string::const_iterator fi = it;
134 while (fi != buf_end && ((lut[(
uint8_t)*fi] & 32)) == 0)
137 val.reserve(std::distance(star_end_string, buf_end));
139 for(;it != buf_end;it++)
146 val.push_back(0x08);
break;
148 val.push_back(0x0C);
break;
150 val.push_back(
'\n');
break;
152 val.push_back(
'\r');
break;
154 val.push_back(
'\t');
break;
156 val.push_back(
'\v');
break;
158 val.push_back(
'\'');
break;
160 val.push_back(
'"');
break;
162 val.push_back(
'\\');
break;
164 val.push_back(
'/');
break;
167 LOG_PRINT_L0(
"Unknown escape sequence :\"\\" << *it <<
"\"");
172 star_end_string = it;
174 }
else if(*it ==
'\\')
198 inline void match_number2(std::string::const_iterator& star_end_string, std::string::const_iterator buf_end, boost::string_ref& val,
bool& is_float_val,
bool& is_signed_val)
202 is_signed_val =
false;
204 std::string::const_iterator it = star_end_string;
205 if (it != buf_end && *it ==
'-')
207 is_signed_val =
true;
211 for(;it != buf_end;it++)
221 val = boost::string_ref(&*star_end_string, chars);
224 star_end_string = --it;
225 is_float_val = !!(float_flag & 2);
234 inline bool match_number(std::string::const_iterator& star_end_string, std::string::const_iterator buf_end, boost::string_ref& val)
238 bool is_v_float =
false;
bool is_signed_val =
false;
239 match_number2(star_end_string, buf_end, val, is_v_float, is_signed_val);
247 inline void match_word2(std::string::const_iterator& star_end_string, std::string::const_iterator buf_end, boost::string_ref& val)
251 for(std::string::const_iterator it = star_end_string;it != buf_end;it++)
255 val = boost::string_ref(&*star_end_string, std::distance(star_end_string, it));
258 star_end_string = --it;
266 inline bool match_word(std::string::const_iterator& star_end_string, std::string::const_iterator buf_end, boost::string_ref& val)
282 for(std::string::const_iterator it = star_end_string;it != buf_end;it++)
284 if(!isalnum(*it) && *it !=
'-' && *it !=
'_')
286 val.assign(star_end_string, it);
289 star_end_string = --it;
297 inline bool match_word_til_equal_mark(std::string::const_iterator& star_end_string, std::string::const_iterator buf_end, std::string::const_iterator& word_end)
299 word_end = star_end_string;
301 for(std::string::const_iterator it = star_end_string;it != buf_end;it++)
307 }
else if( *it ==
'=' )
309 star_end_string = it;
#define ASSERT_MES_AND_THROW(message)
bool match_word(std::string::const_iterator &star_end_string, std::string::const_iterator buf_end, boost::string_ref &val)
bool match_word_til_equal_mark(std::string::const_iterator &star_end_string, std::string::const_iterator buf_end, std::string::const_iterator &word_end)
void match_string2(std::string::const_iterator &star_end_string, std::string::const_iterator buf_end, std::string &val)
std::string transform_to_escape_sequence(const std::string &src)
void match_number2(std::string::const_iterator &star_end_string, std::string::const_iterator buf_end, boost::string_ref &val, bool &is_float_val, bool &is_signed_val)
bool match_string(std::string::const_iterator &star_end_string, std::string::const_iterator buf_end, std::string &val)
void match_word2(std::string::const_iterator &star_end_string, std::string::const_iterator buf_end, boost::string_ref &val)
bool match_number(std::string::const_iterator &star_end_string, std::string::const_iterator buf_end, boost::string_ref &val)
bool match_word_with_extrasymb(std::string::const_iterator &star_end_string, std::string::const_iterator buf_end, std::string &val)