MCPcopy Create free account
hub / github.com/SICKAG/sick_scan_xd / readObject

Method readObject

test/docker/jsoncpp/src/lib_json/json_reader.cpp:443–497  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

441}
442
443bool Reader::readObject(Token& token) {
444 Token tokenName;
445 String name;
446 Value init(objectValue);
447 currentValue().swapPayload(init);
448 currentValue().setOffsetStart(token.start_ - begin_);
449 while (readToken(tokenName)) {
450 bool initialTokenOk = true;
451 while (tokenName.type_ == tokenComment && initialTokenOk)
452 initialTokenOk = readToken(tokenName);
453 if (!initialTokenOk)
454 break;
455 if (tokenName.type_ == tokenObjectEnd && name.empty()) // empty object
456 return true;
457 name.clear();
458 if (tokenName.type_ == tokenString) {
459 if (!decodeString(tokenName, name))
460 return recoverFromError(tokenObjectEnd);
461 } else if (tokenName.type_ == tokenNumber && features_.allowNumericKeys_) {
462 Value numberName;
463 if (!decodeNumber(tokenName, numberName))
464 return recoverFromError(tokenObjectEnd);
465 name = numberName.asString();
466 } else {
467 break;
468 }
469
470 Token colon;
471 if (!readToken(colon) || colon.type_ != tokenMemberSeparator) {
472 return addErrorAndRecover("Missing ':' after object member name", colon,
473 tokenObjectEnd);
474 }
475 Value& value = currentValue()[name];
476 nodes_.push(&value);
477 bool ok = readValue();
478 nodes_.pop();
479 if (!ok) // error already set
480 return recoverFromError(tokenObjectEnd);
481
482 Token comma;
483 if (!readToken(comma) ||
484 (comma.type_ != tokenObjectEnd && comma.type_ != tokenArraySeparator &&
485 comma.type_ != tokenComment)) {
486 return addErrorAndRecover("Missing ',' or '}' in object declaration",
487 comma, tokenObjectEnd);
488 }
489 bool finalizeTokenOk = true;
490 while (comma.type_ == tokenComment && finalizeTokenOk)
491 finalizeTokenOk = readToken(comma);
492 if (comma.type_ == tokenObjectEnd)
493 return true;
494 }
495 return addErrorAndRecover("Missing '}' or object member name", tokenName,
496 tokenObjectEnd);
497}
498
499bool Reader::readArray(Token& token) {
500 Value init(arrayValue);

Callers

nothing calls this directly

Calls 11

decodeStringFunction · 0.85
throwRuntimeErrorFunction · 0.85
swapPayloadMethod · 0.80
setOffsetStartMethod · 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