Skip to content

Commit 556a8a6

Browse files
committed
fix amalgamation and update NLOHMANN_JSON_TO_DEFAULT
Signed-off-by: chelseadzdr <[email protected]>
1 parent 5180b13 commit 556a8a6

File tree

2 files changed

+114
-112
lines changed

2 files changed

+114
-112
lines changed

include/nlohmann/detail/macro_scope.hpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -408,9 +408,10 @@
408408
#define NLOHMANN_JSON_TO(v1) nlohmann_json_j[#v1] = nlohmann_json_t.v1;
409409
#define NLOHMANN_JSON_FROM(v1) nlohmann_json_j.at(#v1).get_to(nlohmann_json_t.v1);
410410
#define NLOHMANN_JSON_FROM_WITH_DEFAULT(v1) nlohmann_json_t.v1 = !nlohmann_json_j.is_null() ? nlohmann_json_j.value(#v1, nlohmann_json_default_obj.v1) : nlohmann_json_default_obj.v1;
411-
#define NLOHMANN_JSON_TO_DEFAULT nlohmann_json_j = nlohmann::json::parse("{}"); (void) nlohmann_json_t;
411+
#define NLOHMANN_JSON_TO_DEFAULT nlohmann_json_j = BasicJsonType::object(); (void) nlohmann_json_t;
412412
#define NLOHMANN_JSON_FROM_DEFAULT (void) nlohmann_json_j; (void) nlohmann_json_t;
413413
#define NLOHMANN_JSON_FROM_WITH_DEFAULT_DEFAULT (void) nlohmann_json_j; (void) nlohmann_json_t; (void) nlohmann_json_default_obj;
414+
414415
/*!
415416
@brief macro
416417
@def NLOHMANN_DEFINE_TYPE_INTRUSIVE
@@ -423,7 +424,7 @@
423424
friend void to_json(BasicJsonType& nlohmann_json_j, const Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, NLOHMANN_JSON_EXPAND_ARGS(__VA_ARGS__))) } \
424425
template<typename BasicJsonType, nlohmann::detail::enable_if_t<nlohmann::detail::is_basic_json<BasicJsonType>::value, int> = 0> \
425426
friend void from_json(const BasicJsonType& nlohmann_json_j, Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_FROM, NLOHMANN_JSON_EXPAND_ARGS(__VA_ARGS__))) }
426-
427+
427428
#else
428429
#define NLOHMANN_DEFINE_TYPE_INTRUSIVE(Type, ...) \
429430
template<typename BasicJsonType, nlohmann::detail::enable_if_t<nlohmann::detail::is_basic_json<BasicJsonType>::value, int> = 0> \
@@ -444,7 +445,7 @@
444445
friend void to_json(BasicJsonType& nlohmann_json_j, const Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, NLOHMANN_JSON_EXPAND_ARGS(__VA_ARGS__))) } \
445446
template<typename BasicJsonType, nlohmann::detail::enable_if_t<nlohmann::detail::is_basic_json<BasicJsonType>::value, int> = 0> \
446447
friend void from_json(const BasicJsonType& nlohmann_json_j, Type& nlohmann_json_t) { const Type nlohmann_json_default_obj{}; NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_FROM_WITH_DEFAULT, NLOHMANN_JSON_EXPAND_ARGS(__VA_ARGS__))) }
447-
448+
448449
#else
449450
#define NLOHMANN_DEFINE_TYPE_INTRUSIVE_WITH_DEFAULT(Type, ...) \
450451
template<typename BasicJsonType, nlohmann::detail::enable_if_t<nlohmann::detail::is_basic_json<BasicJsonType>::value, int> = 0> \
@@ -665,7 +666,7 @@
665666
struct would_call_std_##std_name \
666667
{ \
667668
static constexpr auto const value = ::nlohmann::detail:: \
668-
is_detected_exact<std_name##_tag, result_of_##std_name, T...>::value; \
669+
is_detected_exact<std_name##_tag, result_of_##std_name, T...>::value; \
669670
}; \
670671
} /* namespace detail2 */ \
671672
\

single_include/nlohmann/json.hpp

Lines changed: 109 additions & 108 deletions
Original file line numberDiff line numberDiff line change
@@ -2772,9 +2772,10 @@ JSON_HEDLEY_DIAGNOSTIC_POP
27722772
#define NLOHMANN_JSON_TO(v1) nlohmann_json_j[#v1] = nlohmann_json_t.v1;
27732773
#define NLOHMANN_JSON_FROM(v1) nlohmann_json_j.at(#v1).get_to(nlohmann_json_t.v1);
27742774
#define NLOHMANN_JSON_FROM_WITH_DEFAULT(v1) nlohmann_json_t.v1 = !nlohmann_json_j.is_null() ? nlohmann_json_j.value(#v1, nlohmann_json_default_obj.v1) : nlohmann_json_default_obj.v1;
2775-
#define NLOHMANN_JSON_TO_DEFAULT nlohmann_json_j = nlohmann::json::parse("{}"); (void) nlohmann_json_t;
2775+
#define NLOHMANN_JSON_TO_DEFAULT nlohmann_json_j = BasicJsonType::object(); (void) nlohmann_json_t;
27762776
#define NLOHMANN_JSON_FROM_DEFAULT (void) nlohmann_json_j; (void) nlohmann_json_t;
27772777
#define NLOHMANN_JSON_FROM_WITH_DEFAULT_DEFAULT (void) nlohmann_json_j; (void) nlohmann_json_t; (void) nlohmann_json_default_obj;
2778+
27782779
/*!
27792780
@brief macro
27802781
@def NLOHMANN_DEFINE_TYPE_INTRUSIVE
@@ -3591,71 +3592,71 @@ NLOHMANN_JSON_NAMESPACE_END
35913592
// SPDX-License-Identifier: MIT
35923593

35933594
#ifndef INCLUDE_NLOHMANN_JSON_FWD_HPP_
3594-
#define INCLUDE_NLOHMANN_JSON_FWD_HPP_
3595+
#define INCLUDE_NLOHMANN_JSON_FWD_HPP_
35953596

3596-
#include <cstdint> // int64_t, uint64_t
3597-
#include <map> // map
3598-
#include <memory> // allocator
3599-
#include <string> // string
3600-
#include <vector> // vector
3597+
#include <cstdint> // int64_t, uint64_t
3598+
#include <map> // map
3599+
#include <memory> // allocator
3600+
#include <string> // string
3601+
#include <vector> // vector
36013602

3602-
// #include <nlohmann/detail/abi_macros.hpp>
3603+
// #include <nlohmann/detail/abi_macros.hpp>
36033604

36043605

3605-
/*!
3606-
@brief namespace for Niels Lohmann
3607-
@see https://github.com/nlohmann
3608-
@since version 1.0.0
3609-
*/
3610-
NLOHMANN_JSON_NAMESPACE_BEGIN
3606+
/*!
3607+
@brief namespace for Niels Lohmann
3608+
@see https://github.com/nlohmann
3609+
@since version 1.0.0
3610+
*/
3611+
NLOHMANN_JSON_NAMESPACE_BEGIN
36113612

3612-
/*!
3613-
@brief default JSONSerializer template argument
3613+
/*!
3614+
@brief default JSONSerializer template argument
36143615

3615-
This serializer ignores the template arguments and uses ADL
3616-
([argument-dependent lookup](https://en.cppreference.com/w/cpp/language/adl))
3617-
for serialization.
3618-
*/
3619-
template<typename T = void, typename SFINAE = void>
3620-
struct adl_serializer;
3621-
3622-
/// a class to store JSON values
3623-
/// @sa https://json.nlohmann.me/api/basic_json/
3624-
template<template<typename U, typename V, typename... Args> class ObjectType =
3625-
std::map,
3626-
template<typename U, typename... Args> class ArrayType = std::vector,
3627-
class StringType = std::string, class BooleanType = bool,
3628-
class NumberIntegerType = std::int64_t,
3629-
class NumberUnsignedType = std::uint64_t,
3630-
class NumberFloatType = double,
3631-
template<typename U> class AllocatorType = std::allocator,
3632-
template<typename T, typename SFINAE = void> class JSONSerializer =
3633-
adl_serializer,
3634-
class BinaryType = std::vector<std::uint8_t>, // cppcheck-suppress syntaxError
3635-
class CustomBaseClass = void>
3636-
class basic_json;
3637-
3638-
/// @brief JSON Pointer defines a string syntax for identifying a specific value within a JSON document
3639-
/// @sa https://json.nlohmann.me/api/json_pointer/
3640-
template<typename RefStringType>
3641-
class json_pointer;
3616+
This serializer ignores the template arguments and uses ADL
3617+
([argument-dependent lookup](https://en.cppreference.com/w/cpp/language/adl))
3618+
for serialization.
3619+
*/
3620+
template<typename T = void, typename SFINAE = void>
3621+
struct adl_serializer;
3622+
3623+
/// a class to store JSON values
3624+
/// @sa https://json.nlohmann.me/api/basic_json/
3625+
template<template<typename U, typename V, typename... Args> class ObjectType =
3626+
std::map,
3627+
template<typename U, typename... Args> class ArrayType = std::vector,
3628+
class StringType = std::string, class BooleanType = bool,
3629+
class NumberIntegerType = std::int64_t,
3630+
class NumberUnsignedType = std::uint64_t,
3631+
class NumberFloatType = double,
3632+
template<typename U> class AllocatorType = std::allocator,
3633+
template<typename T, typename SFINAE = void> class JSONSerializer =
3634+
adl_serializer,
3635+
class BinaryType = std::vector<std::uint8_t>, // cppcheck-suppress syntaxError
3636+
class CustomBaseClass = void>
3637+
class basic_json;
36423638

3643-
/*!
3644-
@brief default specialization
3645-
@sa https://json.nlohmann.me/api/json/
3646-
*/
3647-
using json = basic_json<>;
3639+
/// @brief JSON Pointer defines a string syntax for identifying a specific value within a JSON document
3640+
/// @sa https://json.nlohmann.me/api/json_pointer/
3641+
template<typename RefStringType>
3642+
class json_pointer;
36483643

3649-
/// @brief a minimal map-like container that preserves insertion order
3650-
/// @sa https://json.nlohmann.me/api/ordered_map/
3651-
template<class Key, class T, class IgnoredLess, class Allocator>
3652-
struct ordered_map;
3644+
/*!
3645+
@brief default specialization
3646+
@sa https://json.nlohmann.me/api/json/
3647+
*/
3648+
using json = basic_json<>;
36533649

3654-
/// @brief specialization that maintains the insertion order of object keys
3655-
/// @sa https://json.nlohmann.me/api/ordered_json/
3656-
using ordered_json = basic_json<nlohmann::ordered_map>;
3650+
/// @brief a minimal map-like container that preserves insertion order
3651+
/// @sa https://json.nlohmann.me/api/ordered_map/
3652+
template<class Key, class T, class IgnoredLess, class Allocator>
3653+
struct ordered_map;
36573654

3658-
NLOHMANN_JSON_NAMESPACE_END
3655+
/// @brief specialization that maintains the insertion order of object keys
3656+
/// @sa https://json.nlohmann.me/api/ordered_json/
3657+
using ordered_json = basic_json<nlohmann::ordered_map>;
3658+
3659+
NLOHMANN_JSON_NAMESPACE_END
36593660

36603661
#endif // INCLUDE_NLOHMANN_JSON_FWD_HPP_
36613662

@@ -5519,7 +5520,7 @@ NLOHMANN_JSON_NAMESPACE_END
55195520

55205521

55215522
// #include <nlohmann/detail/macro_scope.hpp>
5522-
// JSON_HAS_CPP_17
5523+
// JSON_HAS_CPP_17
55235524
#ifdef JSON_HAS_CPP_17
55245525
#include <optional> // optional
55255526
#endif
@@ -18203,43 +18204,43 @@ inline cached_power get_cached_power_for_binary_exponent(int e)
1820318204
{ 0xAB70FE17C79AC6CA, -1060, -300 },
1820418205
{ 0xFF77B1FCBEBCDC4F, -1034, -292 },
1820518206
{ 0xBE5691EF416BD60C, -1007, -284 },
18206-
{ 0x8DD01FAD907FFC3C, -980, -276 },
18207-
{ 0xD3515C2831559A83, -954, -268 },
18208-
{ 0x9D71AC8FADA6C9B5, -927, -260 },
18209-
{ 0xEA9C227723EE8BCB, -901, -252 },
18210-
{ 0xAECC49914078536D, -874, -244 },
18211-
{ 0x823C12795DB6CE57, -847, -236 },
18212-
{ 0xC21094364DFB5637, -821, -228 },
18213-
{ 0x9096EA6F3848984F, -794, -220 },
18214-
{ 0xD77485CB25823AC7, -768, -212 },
18215-
{ 0xA086CFCD97BF97F4, -741, -204 },
18216-
{ 0xEF340A98172AACE5, -715, -196 },
18217-
{ 0xB23867FB2A35B28E, -688, -188 },
18218-
{ 0x84C8D4DFD2C63F3B, -661, -180 },
18219-
{ 0xC5DD44271AD3CDBA, -635, -172 },
18220-
{ 0x936B9FCEBB25C996, -608, -164 },
18221-
{ 0xDBAC6C247D62A584, -582, -156 },
18222-
{ 0xA3AB66580D5FDAF6, -555, -148 },
18223-
{ 0xF3E2F893DEC3F126, -529, -140 },
18224-
{ 0xB5B5ADA8AAFF80B8, -502, -132 },
18225-
{ 0x87625F056C7C4A8B, -475, -124 },
18226-
{ 0xC9BCFF6034C13053, -449, -116 },
18227-
{ 0x964E858C91BA2655, -422, -108 },
18228-
{ 0xDFF9772470297EBD, -396, -100 },
18229-
{ 0xA6DFBD9FB8E5B88F, -369, -92 },
18230-
{ 0xF8A95FCF88747D94, -343, -84 },
18231-
{ 0xB94470938FA89BCF, -316, -76 },
18232-
{ 0x8A08F0F8BF0F156B, -289, -68 },
18233-
{ 0xCDB02555653131B6, -263, -60 },
18234-
{ 0x993FE2C6D07B7FAC, -236, -52 },
18235-
{ 0xE45C10C42A2B3B06, -210, -44 },
18236-
{ 0xAA242499697392D3, -183, -36 },
18237-
{ 0xFD87B5F28300CA0E, -157, -28 },
18238-
{ 0xBCE5086492111AEB, -130, -20 },
18239-
{ 0x8CBCCC096F5088CC, -103, -12 },
18240-
{ 0xD1B71758E219652C, -77, -4 },
18241-
{ 0x9C40000000000000, -50, 4 },
18242-
{ 0xE8D4A51000000000, -24, 12 },
18207+
{ 0x8DD01FAD907FFC3C, -980, -276 },
18208+
{ 0xD3515C2831559A83, -954, -268 },
18209+
{ 0x9D71AC8FADA6C9B5, -927, -260 },
18210+
{ 0xEA9C227723EE8BCB, -901, -252 },
18211+
{ 0xAECC49914078536D, -874, -244 },
18212+
{ 0x823C12795DB6CE57, -847, -236 },
18213+
{ 0xC21094364DFB5637, -821, -228 },
18214+
{ 0x9096EA6F3848984F, -794, -220 },
18215+
{ 0xD77485CB25823AC7, -768, -212 },
18216+
{ 0xA086CFCD97BF97F4, -741, -204 },
18217+
{ 0xEF340A98172AACE5, -715, -196 },
18218+
{ 0xB23867FB2A35B28E, -688, -188 },
18219+
{ 0x84C8D4DFD2C63F3B, -661, -180 },
18220+
{ 0xC5DD44271AD3CDBA, -635, -172 },
18221+
{ 0x936B9FCEBB25C996, -608, -164 },
18222+
{ 0xDBAC6C247D62A584, -582, -156 },
18223+
{ 0xA3AB66580D5FDAF6, -555, -148 },
18224+
{ 0xF3E2F893DEC3F126, -529, -140 },
18225+
{ 0xB5B5ADA8AAFF80B8, -502, -132 },
18226+
{ 0x87625F056C7C4A8B, -475, -124 },
18227+
{ 0xC9BCFF6034C13053, -449, -116 },
18228+
{ 0x964E858C91BA2655, -422, -108 },
18229+
{ 0xDFF9772470297EBD, -396, -100 },
18230+
{ 0xA6DFBD9FB8E5B88F, -369, -92 },
18231+
{ 0xF8A95FCF88747D94, -343, -84 },
18232+
{ 0xB94470938FA89BCF, -316, -76 },
18233+
{ 0x8A08F0F8BF0F156B, -289, -68 },
18234+
{ 0xCDB02555653131B6, -263, -60 },
18235+
{ 0x993FE2C6D07B7FAC, -236, -52 },
18236+
{ 0xE45C10C42A2B3B06, -210, -44 },
18237+
{ 0xAA242499697392D3, -183, -36 },
18238+
{ 0xFD87B5F28300CA0E, -157, -28 },
18239+
{ 0xBCE5086492111AEB, -130, -20 },
18240+
{ 0x8CBCCC096F5088CC, -103, -12 },
18241+
{ 0xD1B71758E219652C, -77, -4 },
18242+
{ 0x9C40000000000000, -50, 4 },
18243+
{ 0xE8D4A51000000000, -24, 12 },
1824318244
{ 0xAD78EBC5AC620000, 3, 20 },
1824418245
{ 0x813F3978F8940984, 30, 28 },
1824518246
{ 0xC097CE7BC90715B3, 56, 36 },
@@ -19940,7 +19941,7 @@ NLOHMANN_JSON_NAMESPACE_BEGIN
1994019941
/// for use within nlohmann::basic_json<ordered_map>
1994119942
template <class Key, class T, class IgnoredLess = std::less<Key>,
1994219943
class Allocator = std::allocator<std::pair<const Key, T>>>
19943-
struct ordered_map : std::vector<std::pair<const Key, T>, Allocator>
19944+
struct ordered_map : std::vector<std::pair<const Key, T>, Allocator>
1994419945
{
1994519946
using key_type = Key;
1994619947
using mapped_type = T;
@@ -20255,7 +20256,7 @@ struct ordered_map : std::vector<std::pair<const Key, T>, Allocator>
2025520256

2025620257
template<typename InputIt>
2025720258
using require_input_iter = typename std::enable_if<std::is_convertible<typename std::iterator_traits<InputIt>::iterator_category,
20258-
std::input_iterator_tag>::value>::type;
20259+
std::input_iterator_tag>::value>::type;
2025920260

2026020261
template<typename InputIt, typename = require_input_iter<InputIt>>
2026120262
void insert(InputIt first, InputIt last)
@@ -20266,7 +20267,7 @@ struct ordered_map : std::vector<std::pair<const Key, T>, Allocator>
2026620267
}
2026720268
}
2026820269

20269-
private:
20270+
private:
2027020271
JSON_NO_UNIQUE_ADDRESS key_compare m_compare = key_compare();
2027120272
};
2027220273

@@ -22121,18 +22122,18 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
2212122122
detail::negation<std::is_pointer<ValueType>>,
2212222123
detail::negation<std::is_same<ValueType, std::nullptr_t>>,
2212322124
detail::negation<std::is_same<ValueType, detail::json_ref<basic_json>>>,
22124-
detail::negation<std::is_same<ValueType, typename string_t::value_type>>,
22125-
detail::negation<detail::is_basic_json<ValueType>>,
22126-
detail::negation<std::is_same<ValueType, std::initializer_list<typename string_t::value_type>>>,
22125+
detail::negation<std::is_same<ValueType, typename string_t::value_type>>,
22126+
detail::negation<detail::is_basic_json<ValueType>>,
22127+
detail::negation<std::is_same<ValueType, std::initializer_list<typename string_t::value_type>>>,
2212722128
#if defined(JSON_HAS_CPP_17) && (defined(__GNUC__) || (defined(_MSC_VER) && _MSC_VER >= 1910 && _MSC_VER <= 1914))
22128-
detail::negation<std::is_same<ValueType, std::string_view>>,
22129+
detail::negation<std::is_same<ValueType, std::string_view>>,
2212922130
#endif
2213022131
#if defined(JSON_HAS_CPP_17) && JSON_HAS_STATIC_RTTI
22131-
detail::negation<std::is_same<ValueType, std::any>>,
22132+
detail::negation<std::is_same<ValueType, std::any>>,
2213222133
#endif
22133-
detail::is_detected_lazy<detail::get_template_function, const basic_json_t&, ValueType>
22134-
>::value, int >::type = 0 >
22135-
JSON_EXPLICIT operator ValueType() const
22134+
detail::is_detected_lazy<detail::get_template_function, const basic_json_t&, ValueType>
22135+
>::value, int >::type = 0 >
22136+
JSON_EXPLICIT operator ValueType() const
2213622137
{
2213722138
// delegate the call to get<>() const
2213822139
return get<ValueType>();
@@ -22448,12 +22449,12 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
2244822449
private:
2244922450
template<typename KeyType>
2245022451
using is_comparable_with_object_key = detail::is_comparable <
22451-
object_comparator_t, const typename object_t::key_type&, KeyType >;
22452+
object_comparator_t, const typename object_t::key_type&, KeyType >;
2245222453

2245322454
template<typename ValueType>
2245422455
using value_return_type = std::conditional <
22455-
detail::is_c_string_uncvref<ValueType>::value,
22456-
string_t, typename std::decay<ValueType>::type >;
22456+
detail::is_c_string_uncvref<ValueType>::value,
22457+
string_t, typename std::decay<ValueType>::type >;
2245722458

2245822459
public:
2245922460
/// @brief access specified object element with default value

0 commit comments

Comments
 (0)