| 403 | } |
| 404 | |
| 405 | bool Reader::readValue() { |
| 406 | // readValue() may call itself only if it calls readObject() or ReadArray(). |
| 407 | // These methods execute nodes_.push() just before and nodes_.pop)() just |
| 408 | // after calling readValue(). parse() executes one nodes_.push(), so > instead |
| 409 | // of >=. |
| 410 | if (nodes_.size() > stackLimit_g) |
| 411 | throwRuntimeError("Exceeded stackLimit in readValue()."); |
| 412 | |
| 413 | Token token; |
| 414 | skipCommentTokens(token); |
| 415 | bool successful = true; |
| 416 | |
| 417 | if (collectComments_ && !commentsBefore_.empty()) { |
| 418 | currentValue().setComment(commentsBefore_, commentBefore); |
| 419 | commentsBefore_.clear(); |
| 420 | } |
| 421 | |
| 422 | switch (token.type_) { |
| 423 | case tokenObjectBegin: |
| 424 | successful = readObject(token); |
| 425 | currentValue().setOffsetLimit(current_ - begin_); |
| 426 | break; |
| 427 | case tokenArrayBegin: |
| 428 | successful = readArray(token); |
| 429 | currentValue().setOffsetLimit(current_ - begin_); |
| 430 | break; |
| 431 | case tokenNumber: |
| 432 | successful = decodeNumber(token); |
| 433 | break; |
| 434 | case tokenString: |
| 435 | successful = decodeString(token); |
| 436 | break; |
| 437 | case tokenTrue: { |
| 438 | Value v(true); |
| 439 | currentValue().swapPayload(v); |
| 440 | currentValue().setOffsetStart(token.start_ - begin_); |
| 441 | currentValue().setOffsetLimit(token.end_ - begin_); |
| 442 | } break; |
| 443 | case tokenFalse: { |
| 444 | Value v(false); |
| 445 | currentValue().swapPayload(v); |
| 446 | currentValue().setOffsetStart(token.start_ - begin_); |
| 447 | currentValue().setOffsetLimit(token.end_ - begin_); |
| 448 | } break; |
| 449 | case tokenNull: { |
| 450 | Value v; |
| 451 | currentValue().swapPayload(v); |
| 452 | currentValue().setOffsetStart(token.start_ - begin_); |
| 453 | currentValue().setOffsetLimit(token.end_ - begin_); |
| 454 | } break; |
| 455 | case tokenArraySeparator: |
| 456 | case tokenObjectEnd: |
| 457 | case tokenArrayEnd: |
| 458 | if (features_.allowDroppedNullPlaceholders_) { |
| 459 | // "Un-read" the current token and mark the current value as a null |
| 460 | // token. |
| 461 | current_--; |
| 462 | Value v; |
nothing calls this directly
no test coverage detected