MCPcopy Create free account
hub / github.com/WolfireGames/overgrowth / readObject

Method readObject

Source/JSON/jsoncpp.cpp:598–646  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

596}
597
598bool Reader::readObject(Token& /*tokenStart*/) {
599 Token tokenName;
600 std::string name;
601 Value init(objectValue);
602 currentValue().swapPayload(init);
603 while (readToken(tokenName)) {
604 bool initialTokenOk = true;
605 while (tokenName.type_ == tokenComment && initialTokenOk)
606 initialTokenOk = readToken(tokenName);
607 if (!initialTokenOk)
608 break;
609 if (tokenName.type_ == tokenObjectEnd && name.empty()) // empty object
610 return true;
611 name = "";
612 if (tokenName.type_ == tokenString) {
613 if (!decodeString(tokenName, name))
614 return recoverFromError(tokenObjectEnd);
615 } else {
616 break;
617 }
618
619 Token colon;
620 if (!readToken(colon) || colon.type_ != tokenMemberSeparator) {
621 return addErrorAndRecover(
622 "Missing ':' after object member name", colon, tokenObjectEnd);
623 }
624 Value& value = currentValue()[name];
625 nodes_.push(&value);
626 bool ok = readValue();
627 nodes_.pop();
628 if (!ok) // error already set
629 return recoverFromError(tokenObjectEnd);
630
631 Token comma;
632 if (!readToken(comma) ||
633 (comma.type_ != tokenObjectEnd && comma.type_ != tokenArraySeparator &&
634 comma.type_ != tokenComment)) {
635 return addErrorAndRecover(
636 "Missing ',' or '}' in object declaration", comma, tokenObjectEnd);
637 }
638 bool finalizeTokenOk = true;
639 while (comma.type_ == tokenComment && finalizeTokenOk)
640 finalizeTokenOk = readToken(comma);
641 if (comma.type_ == tokenObjectEnd)
642 return true;
643 }
644 return addErrorAndRecover(
645 "Missing '}' or object member name", tokenName, tokenObjectEnd);
646}
647
648bool Reader::readArray(Token& /*tokenStart*/) {
649 Value init(arrayValue);

Callers

nothing calls this directly

Calls 8

throwRuntimeErrorFunction · 0.70
swapPayloadMethod · 0.45
emptyMethod · 0.45
pushMethod · 0.45
popMethod · 0.45
asStringMethod · 0.45
lengthMethod · 0.45
isMemberMethod · 0.45

Tested by

no test coverage detected