MCPcopy Create free account
hub / github.com/danielaparker/jsoncons / resolve

Function resolve

include/jsoncons_ext/jsonpointer/jsonpointer.hpp:461–499  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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)

Callers 6

resolveMethod · 0.85
jsonpointer.hppFile · 0.85
addFunction · 0.85
add_if_absentFunction · 0.85
removeFunction · 0.85
replaceFunction · 0.85

Calls 10

dec_to_integerFunction · 0.85
atMethod · 0.80
is_arrayMethod · 0.45
sizeMethod · 0.45
dataMethod · 0.45
lengthMethod · 0.45
is_objectMethod · 0.45
containsMethod · 0.45
try_emplaceMethod · 0.45
valueMethod · 0.45

Tested by

no test coverage detected