TerraForge3D  2.3.1
3D Terrain And Landscape Generator

◆ basic_json() [4/10]

template<template< typename U, typename V, typename... Args > class ObjectType = std::map, template< typename U, typename... Args > class ArrayType = std::vector, class StringType = std::string, class BooleanType = bool, class NumberIntegerType = std::int64_t, class NumberUnsignedType = std::uint64_t, class NumberFloatType = double, template< typename U > class AllocatorType = std::allocator, template< typename T, typename SFINAE=void > class JSONSerializer = adl_serializer, class BinaryType = std::vector<std::uint8_t>>
template<typename BasicJsonType , detail::enable_if_t< detail::is_basic_json< BasicJsonType >::value &&!std::is_same< basic_json, BasicJsonType >::value, int > = 0>
nlohmann::basic_json< ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer, BinaryType >::basic_json ( const BasicJsonType &  val)
inline

create a JSON value from an existing one

This is a constructor for existing basic_json types. It does not hijack copy/move constructors, since the parameter has different template arguments than the current ones.

The constructor tries to convert the internal m_value of the parameter.

Template Parameters
BasicJsonTypea type such that:
Parameters
[in]valthe basic_json value to be converted.

@complexity Usually linear in the size of the passed val, also depending on the implementation of the called to_json() method.

@exceptionsafety Depends on the called constructor. For types directly supported by the library (i.e., all types for which no to_json() function was provided), strong guarantee holds: if an exception is thrown, there are no changes to any JSON value.

Since
version 3.2.0

Definition at line 19298 of file json.hpp.

19299 {
19300 using other_boolean_t = typename BasicJsonType::boolean_t;
19301 using other_number_float_t = typename BasicJsonType::number_float_t;
19302 using other_number_integer_t = typename BasicJsonType::number_integer_t;
19303 using other_number_unsigned_t = typename BasicJsonType::number_unsigned_t;
19304 using other_string_t = typename BasicJsonType::string_t;
19305 using other_object_t = typename BasicJsonType::object_t;
19306 using other_array_t = typename BasicJsonType::array_t;
19307 using other_binary_t = typename BasicJsonType::binary_t;
19308
19309 switch (val.type())
19310 {
19311 case value_t::boolean:
19312 JSONSerializer<other_boolean_t>::to_json(*this, val.template get<other_boolean_t>());
19313 break;
19314
19316 JSONSerializer<other_number_float_t>::to_json(*this, val.template get<other_number_float_t>());
19317 break;
19318
19320 JSONSerializer<other_number_integer_t>::to_json(*this, val.template get<other_number_integer_t>());
19321 break;
19322
19324 JSONSerializer<other_number_unsigned_t>::to_json(*this, val.template get<other_number_unsigned_t>());
19325 break;
19326
19327 case value_t::string:
19328 JSONSerializer<other_string_t>::to_json(*this, val.template get_ref<const other_string_t &>());
19329 break;
19330
19331 case value_t::object:
19332 JSONSerializer<other_object_t>::to_json(*this, val.template get_ref<const other_object_t &>());
19333 break;
19334
19335 case value_t::array:
19336 JSONSerializer<other_array_t>::to_json(*this, val.template get_ref<const other_array_t &>());
19337 break;
19338
19339 case value_t::binary:
19340 JSONSerializer<other_binary_t>::to_json(*this, val.template get_ref<const other_binary_t &>());
19341 break;
19342
19343 case value_t::null:
19344 *this = nullptr;
19345 break;
19346
19347 case value_t::discarded:
19348 m_type = value_t::discarded;
19349 break;
19350
19351 default: // LCOV_EXCL_LINE
19352 JSON_ASSERT(false); // NOLINT(cert-dcl03-c,hicpp-static-assert,misc-static-assert) LCOV_EXCL_LINE
19353 }
19354
19355 set_parents();
19357 }
void assert_invariant(bool check_parents=true) const noexcept
checks the class invariants
Definition: json.hpp:18935
@ 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)