MCPcopy Create free account
hub / github.com/SOUI2/soui / readObject

Method readObject

third-part/jsoncpp/src/lib_json/json_reader.cpp:462–516  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

460}
461
462bool Reader::readObject(Token& tokenStart) {
463 Token tokenName;
464 JSONCPP_STRING name;
465 Value init(objectValue);
466 currentValue().swapPayload(init);
467 currentValue().setOffsetStart(tokenStart.start_ - begin_);
468 while (readToken(tokenName)) {
469 bool initialTokenOk = true;
470 while (tokenName.type_ == tokenComment && initialTokenOk)
471 initialTokenOk = readToken(tokenName);
472 if (!initialTokenOk)
473 break;
474 if (tokenName.type_ == tokenObjectEnd && name.empty()) // empty object
475 return true;
476 name.clear();
477 if (tokenName.type_ == tokenString) {
478 if (!decodeString(tokenName, name))
479 return recoverFromError(tokenObjectEnd);
480 } else if (tokenName.type_ == tokenNumber && features_.allowNumericKeys_) {
481 Value numberName;
482 if (!decodeNumber(tokenName, numberName))
483 return recoverFromError(tokenObjectEnd);
484 name = JSONCPP_STRING(numberName.asCString());
485 } else {
486 break;
487 }
488
489 Token colon;
490 if (!readToken(colon) || colon.type_ != tokenMemberSeparator) {
491 return addErrorAndRecover(
492 "Missing ':' after object member name", colon, tokenObjectEnd);
493 }
494 Value& value = currentValue()[name];
495 nodes_.push(&value);
496 bool ok = readValue();
497 nodes_.pop();
498 if (!ok) // error already set
499 return recoverFromError(tokenObjectEnd);
500
501 Token comma;
502 if (!readToken(comma) ||
503 (comma.type_ != tokenObjectEnd && comma.type_ != tokenArraySeparator &&
504 comma.type_ != tokenComment)) {
505 return addErrorAndRecover(
506 "Missing ',' or '}' in object declaration", comma, tokenObjectEnd);
507 }
508 bool finalizeTokenOk = true;
509 while (comma.type_ == tokenComment && finalizeTokenOk)
510 finalizeTokenOk = readToken(comma);
511 if (comma.type_ == tokenObjectEnd)
512 return true;
513 }
514 return addErrorAndRecover(
515 "Missing '}' or object member name", tokenName, tokenObjectEnd);
516}
517
518bool Reader::readArray(Token& tokenStart) {
519 Value init(arrayValue);

Callers

nothing calls this directly

Calls 11

throwRuntimeErrorFunction · 0.85
swapPayloadMethod · 0.80
setOffsetStartMethod · 0.80
asCStringMethod · 0.80
asStringMethod · 0.80
isMemberMethod · 0.80
emptyMethod · 0.45
clearMethod · 0.45
pushMethod · 0.45
popMethod · 0.45
lengthMethod · 0.45

Tested by

no test coverage detected