MCPcopy Create free account
hub / github.com/Samsung/ONE / readObject

Method readObject

runtime/3rdparty/jsoncpp/jsoncpp.cpp:739–798  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

737}
738
739bool Reader::readObject(Token &token)
740{
741 Token tokenName;
742 String name;
743 Value init(objectValue);
744 currentValue().swapPayload(init);
745 currentValue().setOffsetStart(token.start_ - begin_);
746 while (readToken(tokenName))
747 {
748 bool initialTokenOk = true;
749 while (tokenName.type_ == tokenComment && initialTokenOk)
750 initialTokenOk = readToken(tokenName);
751 if (!initialTokenOk)
752 break;
753 if (tokenName.type_ == tokenObjectEnd && name.empty()) // empty object
754 return true;
755 name.clear();
756 if (tokenName.type_ == tokenString)
757 {
758 if (!decodeString(tokenName, name))
759 return recoverFromError(tokenObjectEnd);
760 }
761 else if (tokenName.type_ == tokenNumber && features_.allowNumericKeys_)
762 {
763 Value numberName;
764 if (!decodeNumber(tokenName, numberName))
765 return recoverFromError(tokenObjectEnd);
766 name = numberName.asString();
767 }
768 else
769 {
770 break;
771 }
772
773 Token colon;
774 if (!readToken(colon) || colon.type_ != tokenMemberSeparator)
775 {
776 return addErrorAndRecover("Missing ':' after object member name", colon, tokenObjectEnd);
777 }
778 Value &value = currentValue()[name];
779 nodes_.push(&value);
780 bool ok = readValue();
781 nodes_.pop();
782 if (!ok) // error already set
783 return recoverFromError(tokenObjectEnd);
784
785 Token comma;
786 if (!readToken(comma) || (comma.type_ != tokenObjectEnd && comma.type_ != tokenArraySeparator &&
787 comma.type_ != tokenComment))
788 {
789 return addErrorAndRecover("Missing ',' or '}' in object declaration", comma, tokenObjectEnd);
790 }
791 bool finalizeTokenOk = true;
792 while (comma.type_ == tokenComment && finalizeTokenOk)
793 finalizeTokenOk = readToken(comma);
794 if (comma.type_ == tokenObjectEnd)
795 return true;
796 }

Callers

nothing calls this directly

Calls 10

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

Tested by

no test coverage detected