TerraForge3D  2.3.1
3D Terrain And Landscape Generator

◆ get_unchecked() [1/2]

template<typename BasicJsonType >
BasicJsonType & nlohmann::json_pointer< BasicJsonType >::get_unchecked ( BasicJsonType *  ptr) const
inlineprivate

return a reference to the pointed to value

Note
This version does not throw if a value is not present, but tries to create nested values instead. For instance, calling this function with pointer "/this/that" on a null value is equivalent to calling operator[]("this").operator[]("that") on that value, effectively changing the null value to an object.
Parameters
[in]ptra JSON value
Returns
reference to the JSON value pointed to by the JSON pointer

@complexity Linear in the length of the JSON pointer.

Exceptions
parse_error.106if an array index begins with '0'
parse_error.109if an array index was not a number
out_of_range.404if the JSON pointer can not be resolved

Definition at line 13024 of file json.hpp.

13025 {
13026 for (const auto &reference_token : reference_tokens)
13027 {
13028 // convert null values to arrays or objects before continuing
13029 if (ptr->is_null())
13030 {
13031 // check if reference token is a number
13032 const bool nums =
13033 std::all_of(reference_token.begin(), reference_token.end(),
13034 [](const unsigned char x)
13035 {
13036 return std::isdigit(x);
13037 });
13038 // change value to array for numbers or "-" or to object otherwise
13039 *ptr = (nums || reference_token == "-")
13042 }
13043
13044 switch (ptr->type())
13045 {
13047 {
13048 // use unchecked object access
13049 ptr = &ptr->operator[](reference_token);
13050 break;
13051 }
13052
13054 {
13055 if (reference_token == "-")
13056 {
13057 // explicitly treat "-" as index beyond the end
13058 ptr = &ptr->operator[](ptr->m_value.array->size());
13059 }
13060
13061 else
13062 {
13063 // convert array index to number; unchecked access
13064 ptr = &ptr->operator[](array_index(reference_token));
13065 }
13066
13067 break;
13068 }
13069
13078 default:
13079 JSON_THROW(detail::out_of_range::create(404, "unresolved reference token '" + reference_token + "'", *ptr));
13080 }
13081 }
13082
13083 return *ptr;
13084 }
static BasicJsonType::size_type array_index(const std::string &s)
Definition: json.hpp:12878
@ number_integer
number value (signed integer)
@ discarded
discarded by the parser callback function
@ binary
binary array (ordered collection of bytes)
@ object
object (unordered set of name/value pairs)
@ number_float
number value (floating-point)
@ number_unsigned
number value (unsigned integer)
@ array
array (ordered collection of values)