MCPcopy Create free account
hub / github.com/InteractiveComputerGraphics/SPlisHSPlasH / scan_string

Method scan_string

extern/json/json.hpp:7559–8143  ·  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

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 3

resetFunction · 0.70
getFunction · 0.70
addFunction · 0.70

Tested by

no test coverage detected