| 313 | } |
| 314 | |
| 315 | bool Reader::readValue() { |
| 316 | Token token; |
| 317 | skipCommentTokens(token); |
| 318 | bool successful = true; |
| 319 | |
| 320 | if (collectComments_ && !commentsBefore_.empty()) { |
| 321 | // Remove newline at the end of the comment |
| 322 | if (commentsBefore_[commentsBefore_.size() - 1] == '\n') |
| 323 | commentsBefore_.resize(commentsBefore_.size() - 1); |
| 324 | currentValue().setComment(commentsBefore_, commentBefore); |
| 325 | commentsBefore_ = ""; |
| 326 | } |
| 327 | |
| 328 | switch (token.type_) { |
| 329 | case tokenObjectBegin: |
| 330 | successful = readObject(token); |
| 331 | currentValue().setOffsetLimit(current_ - begin_); |
| 332 | break; |
| 333 | case tokenArrayBegin: |
| 334 | successful = readArray(token); |
| 335 | currentValue().setOffsetLimit(current_ - begin_); |
| 336 | break; |
| 337 | case tokenNumber: |
| 338 | successful = decodeNumber(token); |
| 339 | break; |
| 340 | case tokenString: |
| 341 | successful = decodeString(token); |
| 342 | break; |
| 343 | case tokenTrue: |
| 344 | { |
| 345 | Value v(true); |
| 346 | currentValue().swapPayload(v); |
| 347 | currentValue().setOffsetStart(token.start_ - begin_); |
| 348 | currentValue().setOffsetLimit(token.end_ - begin_); |
| 349 | } |
| 350 | break; |
| 351 | case tokenFalse: |
| 352 | { |
| 353 | Value v(false); |
| 354 | currentValue().swapPayload(v); |
| 355 | currentValue().setOffsetStart(token.start_ - begin_); |
| 356 | currentValue().setOffsetLimit(token.end_ - begin_); |
| 357 | } |
| 358 | break; |
| 359 | case tokenNull: |
| 360 | { |
| 361 | Value v; |
| 362 | currentValue().swapPayload(v); |
| 363 | currentValue().setOffsetStart(token.start_ - begin_); |
| 364 | currentValue().setOffsetLimit(token.end_ - begin_); |
| 365 | } |
| 366 | break; |
| 367 | case tokenArraySeparator: |
| 368 | if (features_.allowDroppedNullPlaceholders_) { |
| 369 | // "Un-read" the current token and mark the current value as a null |
| 370 | // token. |
| 371 | current_--; |
| 372 | Value v; |
nothing calls this directly
no test coverage detected