MCPcopy Create free account
hub / github.com/bytedance/Fastbot_Android / scan_string

Method scan_string

native/thirdpart/json/json.hpp:7365–7949  ·  view source on GitHub ↗

! @brief scan a string literal This function scans a string according to Sect. 7 of RFC 7159. While scanning, bytes are escaped and copied into buffer token_buffer. Then the function returns successfully, token_buffer is *not* null-terminated (as it may contain \0 bytes), and token_buffer.size() is the number of bytes in the string. @return token_type::value_string if

Source from the content-addressed store, hash-verified

7363 description.
7364 */
7365 token_type scan_string()
7366 {
7367 // reset token_buffer (ignore opening quote)
7368 reset();
7369
7370 // we entered the function by reading an open quote
7371 assert(current == '\"');
7372
7373 while (true)
7374 {
7375 // get next character
7376 switch (get())
7377 {
7378 // end of file while parsing string
7379 case std::char_traits<char>::eof():
7380 {
7381 error_message = "invalid string: missing closing quote";
7382 return token_type::parse_error;
7383 }
7384
7385 // closing quote
7386 case '\"':
7387 {
7388 return token_type::value_string;
7389 }
7390
7391 // escapes
7392 case '\\':
7393 {
7394 switch (get())
7395 {
7396 // quotation mark
7397 case '\"':
7398 add('\"');
7399 break;
7400 // reverse solidus
7401 case '\\':
7402 add('\\');
7403 break;
7404 // solidus
7405 case '/':
7406 add('/');
7407 break;
7408 // backspace
7409 case 'b':
7410 add('\b');
7411 break;
7412 // form feed
7413 case 'f':
7414 add('\f');
7415 break;
7416 // line feed
7417 case 'n':
7418 add('\n');
7419 break;
7420 // carriage return
7421 case 'r':
7422 add('\r');

Callers

nothing calls this directly

Calls 2

resetFunction · 0.85
getFunction · 0.85

Tested by

no test coverage detected