| 459 | |
| 460 | template <typename Json> |
| 461 | const Json* resolve(const Json* current, const typename Json::string_view_type& buffer, std::error_code& ec) |
| 462 | { |
| 463 | if (current->is_array()) |
| 464 | { |
| 465 | if (buffer.size() == 1 && buffer[0] == '-') |
| 466 | { |
| 467 | ec = jsonpointer_errc::index_exceeds_array_size; |
| 468 | return current; |
| 469 | } |
| 470 | std::size_t index{0}; |
| 471 | auto result = jsoncons::dec_to_integer(buffer.data(), buffer.length(), index); |
| 472 | if (!result) |
| 473 | { |
| 474 | ec = jsonpointer_errc::invalid_index; |
| 475 | return current; |
| 476 | } |
| 477 | if (index >= current->size()) |
| 478 | { |
| 479 | ec = jsonpointer_errc::index_exceeds_array_size; |
| 480 | return current; |
| 481 | } |
| 482 | current = std::addressof(current->at(index)); |
| 483 | } |
| 484 | else if (current->is_object()) |
| 485 | { |
| 486 | if (!current->contains(buffer)) |
| 487 | { |
| 488 | ec = jsonpointer_errc::key_not_found; |
| 489 | return current; |
| 490 | } |
| 491 | current = std::addressof(current->at(buffer)); |
| 492 | } |
| 493 | else |
| 494 | { |
| 495 | ec = jsonpointer_errc::expected_object_or_array; |
| 496 | return current; |
| 497 | } |
| 498 | return current; |
| 499 | } |
| 500 | |
| 501 | template <typename Json> |
| 502 | Json* resolve(Json* current, const typename Json::string_view_type& buffer, bool create_if_missing, std::error_code& ec) |
no test coverage detected