Skip to content

Commit 95a9a52

Browse files
committed
chore: regenerate single-header after enum deserialization fix
1 parent 27ab45c commit 95a9a52

File tree

1 file changed

+71
-64
lines changed

1 file changed

+71
-64
lines changed

single_include/nlohmann/json.hpp

Lines changed: 71 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -2614,7 +2614,14 @@ JSON_HEDLEY_DIAGNOSTIC_POP
26142614
{ \
26152615
return ej_pair.second == j; \
26162616
}); \
2617-
e = ((it != std::end(m)) ? it : std::begin(m))->first; \
2617+
if (it == std::end(m)) \
2618+
{ \
2619+
throw ::nlohmann::detail::type_error::create( \
2620+
302, \
2621+
std::string("invalid value for ") + #ENUM_TYPE + ": " + j.dump(), \
2622+
nullptr); \
2623+
} \
2624+
e = it->first; \
26182625
}
26192626

26202627
// Ugly macros to avoid uglier copy-paste when specializing basic_json. They
@@ -3499,71 +3506,71 @@ NLOHMANN_JSON_NAMESPACE_END
34993506
// SPDX-License-Identifier: MIT
35003507

35013508
#ifndef INCLUDE_NLOHMANN_JSON_FWD_HPP_
3502-
#define INCLUDE_NLOHMANN_JSON_FWD_HPP_
3509+
#define INCLUDE_NLOHMANN_JSON_FWD_HPP_
35033510

3504-
#include <cstdint> // int64_t, uint64_t
3505-
#include <map> // map
3506-
#include <memory> // allocator
3507-
#include <string> // string
3508-
#include <vector> // vector
3511+
#include <cstdint> // int64_t, uint64_t
3512+
#include <map> // map
3513+
#include <memory> // allocator
3514+
#include <string> // string
3515+
#include <vector> // vector
35093516

3510-
// #include <nlohmann/detail/abi_macros.hpp>
3517+
// #include <nlohmann/detail/abi_macros.hpp>
35113518

35123519

3513-
/*!
3514-
@brief namespace for Niels Lohmann
3515-
@see https://github.com/nlohmann
3516-
@since version 1.0.0
3517-
*/
3518-
NLOHMANN_JSON_NAMESPACE_BEGIN
3520+
/*!
3521+
@brief namespace for Niels Lohmann
3522+
@see https://github.com/nlohmann
3523+
@since version 1.0.0
3524+
*/
3525+
NLOHMANN_JSON_NAMESPACE_BEGIN
35193526

3520-
/*!
3521-
@brief default JSONSerializer template argument
3527+
/*!
3528+
@brief default JSONSerializer template argument
35223529

3523-
This serializer ignores the template arguments and uses ADL
3524-
([argument-dependent lookup](https://en.cppreference.com/w/cpp/language/adl))
3525-
for serialization.
3526-
*/
3527-
template<typename T = void, typename SFINAE = void>
3528-
struct adl_serializer;
3529-
3530-
/// a class to store JSON values
3531-
/// @sa https://json.nlohmann.me/api/basic_json/
3532-
template<template<typename U, typename V, typename... Args> class ObjectType =
3533-
std::map,
3534-
template<typename U, typename... Args> class ArrayType = std::vector,
3535-
class StringType = std::string, class BooleanType = bool,
3536-
class NumberIntegerType = std::int64_t,
3537-
class NumberUnsignedType = std::uint64_t,
3538-
class NumberFloatType = double,
3539-
template<typename U> class AllocatorType = std::allocator,
3540-
template<typename T, typename SFINAE = void> class JSONSerializer =
3541-
adl_serializer,
3542-
class BinaryType = std::vector<std::uint8_t>, // cppcheck-suppress syntaxError
3543-
class CustomBaseClass = void>
3544-
class basic_json;
3545-
3546-
/// @brief JSON Pointer defines a string syntax for identifying a specific value within a JSON document
3547-
/// @sa https://json.nlohmann.me/api/json_pointer/
3548-
template<typename RefStringType>
3549-
class json_pointer;
3530+
This serializer ignores the template arguments and uses ADL
3531+
([argument-dependent lookup](https://en.cppreference.com/w/cpp/language/adl))
3532+
for serialization.
3533+
*/
3534+
template<typename T = void, typename SFINAE = void>
3535+
struct adl_serializer;
3536+
3537+
/// a class to store JSON values
3538+
/// @sa https://json.nlohmann.me/api/basic_json/
3539+
template<template<typename U, typename V, typename... Args> class ObjectType =
3540+
std::map,
3541+
template<typename U, typename... Args> class ArrayType = std::vector,
3542+
class StringType = std::string, class BooleanType = bool,
3543+
class NumberIntegerType = std::int64_t,
3544+
class NumberUnsignedType = std::uint64_t,
3545+
class NumberFloatType = double,
3546+
template<typename U> class AllocatorType = std::allocator,
3547+
template<typename T, typename SFINAE = void> class JSONSerializer =
3548+
adl_serializer,
3549+
class BinaryType = std::vector<std::uint8_t>, // cppcheck-suppress syntaxError
3550+
class CustomBaseClass = void>
3551+
class basic_json;
35503552

3551-
/*!
3552-
@brief default specialization
3553-
@sa https://json.nlohmann.me/api/json/
3554-
*/
3555-
using json = basic_json<>;
3553+
/// @brief JSON Pointer defines a string syntax for identifying a specific value within a JSON document
3554+
/// @sa https://json.nlohmann.me/api/json_pointer/
3555+
template<typename RefStringType>
3556+
class json_pointer;
35563557

3557-
/// @brief a minimal map-like container that preserves insertion order
3558-
/// @sa https://json.nlohmann.me/api/ordered_map/
3559-
template<class Key, class T, class IgnoredLess, class Allocator>
3560-
struct ordered_map;
3558+
/*!
3559+
@brief default specialization
3560+
@sa https://json.nlohmann.me/api/json/
3561+
*/
3562+
using json = basic_json<>;
35613563

3562-
/// @brief specialization that maintains the insertion order of object keys
3563-
/// @sa https://json.nlohmann.me/api/ordered_json/
3564-
using ordered_json = basic_json<nlohmann::ordered_map>;
3564+
/// @brief a minimal map-like container that preserves insertion order
3565+
/// @sa https://json.nlohmann.me/api/ordered_map/
3566+
template<class Key, class T, class IgnoredLess, class Allocator>
3567+
struct ordered_map;
35653568

3566-
NLOHMANN_JSON_NAMESPACE_END
3569+
/// @brief specialization that maintains the insertion order of object keys
3570+
/// @sa https://json.nlohmann.me/api/ordered_json/
3571+
using ordered_json = basic_json<nlohmann::ordered_map>;
3572+
3573+
NLOHMANN_JSON_NAMESPACE_END
35673574

35683575
#endif // INCLUDE_NLOHMANN_JSON_FWD_HPP_
35693576

@@ -5427,7 +5434,7 @@ NLOHMANN_JSON_NAMESPACE_END
54275434

54285435

54295436
// #include <nlohmann/detail/macro_scope.hpp>
5430-
// JSON_HAS_CPP_17
5437+
// JSON_HAS_CPP_17
54315438
#ifdef JSON_HAS_CPP_17
54325439
#include <optional> // optional
54335440
#endif
@@ -20255,10 +20262,10 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
2025520262
const bool allow_exceptions = true,
2025620263
const bool ignore_comments = false,
2025720264
const bool ignore_trailing_commas = false
20258-
)
20265+
)
2025920266
{
2026020267
return ::nlohmann::detail::parser<basic_json, InputAdapterType>(std::move(adapter),
20261-
std::move(cb), allow_exceptions, ignore_comments, ignore_trailing_commas);
20268+
std::move(cb), allow_exceptions, ignore_comments, ignore_trailing_commas);
2026220269
}
2026320270

2026420271
private:
@@ -20956,8 +20963,8 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
2095620963
detail::enable_if_t <
2095720964
!detail::is_basic_json<U>::value && detail::is_compatible_type<basic_json_t, U>::value, int > = 0 >
2095820965
basic_json(CompatibleType && val) noexcept(noexcept( // NOLINT(bugprone-forwarding-reference-overload,bugprone-exception-escape)
20959-
JSONSerializer<U>::to_json(std::declval<basic_json_t&>(),
20960-
std::forward<CompatibleType>(val))))
20966+
JSONSerializer<U>::to_json(std::declval<basic_json_t&>(),
20967+
std::forward<CompatibleType>(val))))
2096120968
{
2096220969
JSONSerializer<U>::to_json(*this, std::forward<CompatibleType>(val));
2096320970
set_parents();
@@ -21751,7 +21758,7 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
2175121758
detail::has_from_json<basic_json_t, ValueType>::value,
2175221759
int > = 0 >
2175321760
ValueType get_impl(detail::priority_tag<0> /*unused*/) const noexcept(noexcept(
21754-
JSONSerializer<ValueType>::from_json(std::declval<const basic_json_t&>(), std::declval<ValueType&>())))
21761+
JSONSerializer<ValueType>::from_json(std::declval<const basic_json_t&>(), std::declval<ValueType&>())))
2175521762
{
2175621763
auto ret = ValueType();
2175721764
JSONSerializer<ValueType>::from_json(*this, ret);
@@ -21793,7 +21800,7 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
2179321800
detail::has_non_default_from_json<basic_json_t, ValueType>::value,
2179421801
int > = 0 >
2179521802
ValueType get_impl(detail::priority_tag<1> /*unused*/) const noexcept(noexcept(
21796-
JSONSerializer<ValueType>::from_json(std::declval<const basic_json_t&>())))
21803+
JSONSerializer<ValueType>::from_json(std::declval<const basic_json_t&>())))
2179721804
{
2179821805
return JSONSerializer<ValueType>::from_json(*this);
2179921806
}
@@ -21943,7 +21950,7 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
2194321950
detail::has_from_json<basic_json_t, ValueType>::value,
2194421951
int > = 0 >
2194521952
ValueType & get_to(ValueType& v) const noexcept(noexcept(
21946-
JSONSerializer<ValueType>::from_json(std::declval<const basic_json_t&>(), v)))
21953+
JSONSerializer<ValueType>::from_json(std::declval<const basic_json_t&>(), v)))
2194721954
{
2194821955
JSONSerializer<ValueType>::from_json(*this, v);
2194921956
return v;

0 commit comments

Comments
 (0)