1
0
mirror of https://github.com/nlohmann/json.git synced 2025-07-29 23:01:16 +03:00

♻️ move wrapped binary type to separate file

This commit is contained in:
Niels Lohmann
2020-05-15 14:12:32 +02:00
parent bcf4f3ce9a
commit daf2d296dd
8 changed files with 192 additions and 154 deletions

View File

@ -228,9 +228,9 @@ template <typename BasicJsonType, typename ConstructibleArrayType,
is_constructible_array_type<BasicJsonType, ConstructibleArrayType>::value and
not is_constructible_object_type<BasicJsonType, ConstructibleArrayType>::value and
not is_constructible_string_type<BasicJsonType, ConstructibleArrayType>::value and
not std::is_same<ConstructibleArrayType, typename BasicJsonType::internal_binary_t>::value and
not is_basic_json<ConstructibleArrayType>::value,
int > = 0 >
auto from_json(const BasicJsonType& j, ConstructibleArrayType& arr)
-> decltype(from_json_array_impl(j, arr, priority_tag<3> {}),
j.template get<typename ConstructibleArrayType::value_type>(),
@ -245,6 +245,17 @@ void())
from_json_array_impl(j, arr, priority_tag<3> {});
}
template <typename BasicJsonType>
void from_json(const BasicJsonType& j, typename BasicJsonType::internal_binary_t& bin)
{
if (JSON_HEDLEY_UNLIKELY(not j.is_binary()))
{
JSON_THROW(type_error::create(302, "type must be binary, but is " + std::string(j.type_name())));
}
bin = *j.template get_ptr<const typename BasicJsonType::internal_binary_t*>();
}
template<typename BasicJsonType, typename ConstructibleObjectType,
enable_if_t<is_constructible_object_type<BasicJsonType, ConstructibleObjectType>::value, int> = 0>
void from_json(const BasicJsonType& j, ConstructibleObjectType& obj)