MCPcopy Create free account
hub / github.com/Tracktion/choc / parseString

Method parseString

choc/text/choc_JSON.h:457–499  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

455 }
456
457 std::string parseString()
458 {
459 std::ostringstream s (std::ios::binary);
460
461 for (;;)
462 {
463 auto charStart = current;
464 auto c = pop();
465
466 if (c == '"')
467 break;
468
469 if (c == '\\')
470 {
471 auto errorPos = current;
472 c = pop();
473
474 switch (c)
475 {
476 case 'a': c = '\a'; break;
477 case 'b': c = '\b'; break;
478 case 'f': c = '\f'; break;
479 case 'n': c = '\n'; break;
480 case 'r': c = '\r'; break;
481 case 't': c = '\t'; break;
482 case 'u': c = parseUnicodeCharacterNumber (false); break;
483 case 0: throwError ("Unexpected EOF in string constant", errorPos);
484 default: break;
485 }
486 }
487
488 if (c == 0)
489 throwError ("Unexpected EOF in string constant", charStart);
490
491 char utf8Bytes[8];
492 auto numBytes = text::convertUnicodeCodepointToUTF8 (utf8Bytes, c);
493
494 for (uint32_t i = 0; i < numBytes; ++i)
495 s << utf8Bytes[i];
496 }
497
498 return s.str();
499 }
500
501 uint32_t parseUnicodeCharacterNumber (bool isLowSurrogate)
502 {

Callers

nothing calls this directly

Calls 2

throwErrorFunction · 0.85

Tested by

no test coverage detected