MCPcopy Create free account
hub / github.com/cinder/Cinder / readObject

Method readObject

src/jsoncpp/jsoncpp.cpp:608–662  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

606}
607
608bool Reader::readObject(Token& tokenStart) {
609 Token tokenName;
610 std::string name;
611 Value init(objectValue);
612 currentValue().swapPayload(init);
613 currentValue().setOffsetStart(tokenStart.start_ - begin_);
614 while (readToken(tokenName)) {
615 bool initialTokenOk = true;
616 while (tokenName.type_ == tokenComment && initialTokenOk)
617 initialTokenOk = readToken(tokenName);
618 if (!initialTokenOk)
619 break;
620 if (tokenName.type_ == tokenObjectEnd && name.empty()) // empty object
621 return true;
622 name = "";
623 if (tokenName.type_ == tokenString) {
624 if (!decodeString(tokenName, name))
625 return recoverFromError(tokenObjectEnd);
626 } else if (tokenName.type_ == tokenNumber && features_.allowNumericKeys_) {
627 Value numberName;
628 if (!decodeNumber(tokenName, numberName))
629 return recoverFromError(tokenObjectEnd);
630 name = numberName.asString();
631 } else {
632 break;
633 }
634
635 Token colon;
636 if (!readToken(colon) || colon.type_ != tokenMemberSeparator) {
637 return addErrorAndRecover(
638 "Missing ':' after object member name", colon, tokenObjectEnd);
639 }
640 Value& value = currentValue()[name];
641 nodes_.push(&value);
642 bool ok = readValue();
643 nodes_.pop();
644 if (!ok) // error already set
645 return recoverFromError(tokenObjectEnd);
646
647 Token comma;
648 if (!readToken(comma) ||
649 (comma.type_ != tokenObjectEnd && comma.type_ != tokenArraySeparator &&
650 comma.type_ != tokenComment)) {
651 return addErrorAndRecover(
652 "Missing ',' or '}' in object declaration", comma, tokenObjectEnd);
653 }
654 bool finalizeTokenOk = true;
655 while (comma.type_ == tokenComment && finalizeTokenOk)
656 finalizeTokenOk = readToken(comma);
657 if (comma.type_ == tokenObjectEnd)
658 return true;
659 }
660 return addErrorAndRecover(
661 "Missing '}' or object member name", tokenName, tokenObjectEnd);
662}
663
664bool Reader::readArray(Token& tokenStart) {
665 Value init(arrayValue);

Callers

nothing calls this directly

Calls 7

readValueFunction · 0.85
swapPayloadMethod · 0.80
setOffsetStartMethod · 0.80
asStringMethod · 0.80
emptyMethod · 0.45
pushMethod · 0.45
popMethod · 0.45

Tested by

no test coverage detected