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