MCPcopy Create free account
hub / github.com/OpenStarbound/OpenStarbound / parseString

Method parseString

source/core/StarJsonParser.hpp:364–437  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

362 }
363
364 CharArray parseString() {
365 if (m_char != '"')
366 error("bad string, should be '\"'");
367 next();
368
369 CharArray str;
370
371 while (true) {
372 if (m_char == '\\') {
373 next();
374 if (m_char == 'u') {
375 std::string hexString;
376 next();
377 for (int i = 0; i < 4; ++i) {
378 hexString.push_back(m_char);
379 next();
380 }
381 char32_t codepoint = hexStringToUtf32(hexString);
382 if (isUtf16LeadSurrogate(codepoint)) {
383 check('\\');
384 check('u');
385 hexString.clear();
386 for (int i = 0; i < 4; ++i) {
387 hexString.push_back(m_char);
388 next();
389 }
390 codepoint = hexStringToUtf32(hexString, codepoint);
391 }
392 str += codepoint;
393 } else {
394 switch (m_char) {
395 case '"':
396 str += '"';
397 break;
398 case '\\':
399 str += '\\';
400 break;
401 case '/':
402 str += '/';
403 break;
404 case 'b':
405 str += '\b';
406 break;
407 case 'f':
408 str += '\f';
409 break;
410 case 'n':
411 str += '\n';
412 break;
413 case 'r':
414 str += '\r';
415 break;
416 case 't':
417 str += '\t';
418 break;
419 default:
420 error("bad string escape character");
421 break;

Callers

nothing calls this directly

Calls 6

errorFunction · 0.85
hexStringToUtf32Function · 0.85
isUtf16LeadSurrogateFunction · 0.85
checkFunction · 0.85
push_backMethod · 0.45
clearMethod · 0.45

Tested by

no test coverage detected