MCPcopy Create free account
hub / github.com/Open-GD/OpenGD / scan_string

Method scan_string

Source/external/json.hpp:7555–8139  ·  view source on GitHub ↗

! @brief scan a string literal This function scans a string according to Sect. 7 of RFC 8259. 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 string could be succ

Source from the content-addressed store, hash-verified

7553 description.
7554 */
7555 token_type scan_string()
7556 {
7557 // reset token_buffer (ignore opening quote)
7558 reset();
7559
7560 // we entered the function by reading an open quote
7561 JSON_ASSERT(current == '\"');
7562
7563 while (true)
7564 {
7565 // get next character
7566 switch (get())
7567 {
7568 // end of file while parsing string
7569 case std::char_traits<char_type>::eof():
7570 {
7571 error_message = "invalid string: missing closing quote";
7572 return token_type::parse_error;
7573 }
7574
7575 // closing quote
7576 case '\"':
7577 {
7578 return token_type::value_string;
7579 }
7580
7581 // escapes
7582 case '\\':
7583 {
7584 switch (get())
7585 {
7586 // quotation mark
7587 case '\"':
7588 add('\"');
7589 break;
7590 // reverse solidus
7591 case '\\':
7592 add('\\');
7593 break;
7594 // solidus
7595 case '/':
7596 add('/');
7597 break;
7598 // backspace
7599 case 'b':
7600 add('\b');
7601 break;
7602 // form feed
7603 case 'f':
7604 add('\f');
7605 break;
7606 // line feed
7607 case 'n':
7608 add('\n');
7609 break;
7610 // carriage return
7611 case 'r':
7612 add('\r');

Callers

nothing calls this directly

Calls 3

resetFunction · 0.85
getFunction · 0.85
addFunction · 0.85

Tested by

no test coverage detected