diff --git a/include/nlohmann/adl_serializer.hpp b/include/nlohmann/adl_serializer.hpp index 770159ded..be4a7c16f 100644 --- a/include/nlohmann/adl_serializer.hpp +++ b/include/nlohmann/adl_serializer.hpp @@ -13,13 +13,11 @@ #include #include +#include #include #include -namespace nlohmann -{ -inline namespace json_v3_10_5 -{ +NLOHMANN_JSON_NAMESPACE_BEGIN /// @sa https://json.nlohmann.me/api/adl_serializer/ template @@ -55,5 +53,5 @@ struct adl_serializer ::nlohmann::to_json(j, std::forward(val)); } }; -} // namespace json_v3_10_5 -} // namespace nlohmann + +NLOHMANN_JSON_NAMESPACE_END diff --git a/include/nlohmann/byte_container_with_subtype.hpp b/include/nlohmann/byte_container_with_subtype.hpp index ab939c3cc..8d90a5313 100644 --- a/include/nlohmann/byte_container_with_subtype.hpp +++ b/include/nlohmann/byte_container_with_subtype.hpp @@ -12,10 +12,9 @@ #include // tie #include // move -namespace nlohmann -{ -inline namespace json_v3_10_5 -{ +#include + +NLOHMANN_JSON_NAMESPACE_BEGIN /// @brief an internal type for a backed binary type /// @sa https://json.nlohmann.me/api/byte_container_with_subtype/ @@ -101,5 +100,4 @@ class byte_container_with_subtype : public BinaryType bool m_has_subtype = false; }; -} // namespace json_v3_10_5 -} // namespace nlohmann +NLOHMANN_JSON_NAMESPACE_END diff --git a/include/nlohmann/detail/conversions/from_json.hpp b/include/nlohmann/detail/conversions/from_json.hpp index 22006290b..1fcc587a4 100644 --- a/include/nlohmann/detail/conversions/from_json.hpp +++ b/include/nlohmann/detail/conversions/from_json.hpp @@ -30,36 +30,26 @@ #if JSON_HAS_EXPERIMENTAL_FILESYSTEM #include -namespace nlohmann -{ -inline namespace json_v3_10_5 -{ +NLOHMANN_JSON_NAMESPACE_BEGIN namespace detail { namespace std_fs = std::experimental::filesystem; } // namespace detail -} // namespace json_v3_10_5 -} // namespace nlohmann +NLOHMANN_JSON_NAMESPACE_END #elif JSON_HAS_FILESYSTEM #include -namespace nlohmann -{ -inline namespace json_v3_10_5 -{ +NLOHMANN_JSON_NAMESPACE_BEGIN namespace detail { namespace std_fs = std::filesystem; } // namespace detail -} // namespace json_v3_10_5 -} // namespace nlohmann +NLOHMANN_JSON_NAMESPACE_END #endif -namespace nlohmann -{ -inline namespace json_v3_10_5 -{ +NLOHMANN_JSON_NAMESPACE_BEGIN namespace detail { + template inline void from_json(const BasicJsonType& j, typename std::nullptr_t& n) { @@ -505,6 +495,7 @@ struct from_json_fn return from_json(j, std::forward(val)); } }; + } // namespace detail #ifndef JSON_HAS_CPP_17 @@ -519,5 +510,5 @@ JSON_INLINE_VARIABLE constexpr const auto& from_json = // NOLINT(misc-definition #ifndef JSON_HAS_CPP_17 } // namespace #endif -} // namespace json_v3_10_5 -} // namespace nlohmann + +NLOHMANN_JSON_NAMESPACE_END diff --git a/include/nlohmann/detail/conversions/to_chars.hpp b/include/nlohmann/detail/conversions/to_chars.hpp index 5f9e8f743..87655c2ae 100644 --- a/include/nlohmann/detail/conversions/to_chars.hpp +++ b/include/nlohmann/detail/conversions/to_chars.hpp @@ -18,10 +18,7 @@ #include -namespace nlohmann -{ -inline namespace json_v3_10_5 -{ +NLOHMANN_JSON_NAMESPACE_BEGIN namespace detail { @@ -1118,5 +1115,4 @@ char* to_chars(char* first, const char* last, FloatType value) } } // namespace detail -} // namespace json_v3_10_5 -} // namespace nlohmann +NLOHMANN_JSON_NAMESPACE_END diff --git a/include/nlohmann/detail/conversions/to_json.hpp b/include/nlohmann/detail/conversions/to_json.hpp index 3d6c0455c..3cb6b6a70 100644 --- a/include/nlohmann/detail/conversions/to_json.hpp +++ b/include/nlohmann/detail/conversions/to_json.hpp @@ -17,44 +17,34 @@ #include // valarray #include // vector -#include #include +#include #include #include #include #if JSON_HAS_EXPERIMENTAL_FILESYSTEM #include -namespace nlohmann -{ -inline namespace json_v3_10_5 -{ +NLOHMANN_JSON_NAMESPACE_BEGIN namespace detail { namespace std_fs = std::experimental::filesystem; } // namespace detail -} // namespace json_v3_10_5 -} // namespace nlohmann +NLOHMANN_JSON_NAMESPACE_END #elif JSON_HAS_FILESYSTEM #include -namespace nlohmann -{ -inline namespace json_v3_10_5 -{ +NLOHMANN_JSON_NAMESPACE_BEGIN namespace detail { namespace std_fs = std::filesystem; } // namespace detail -} // namespace json_v3_10_5 -} // namespace nlohmann +NLOHMANN_JSON_NAMESPACE_END #endif -namespace nlohmann -{ -inline namespace json_v3_10_5 -{ +NLOHMANN_JSON_NAMESPACE_BEGIN namespace detail { + ////////////////// // constructors // ////////////////// @@ -463,5 +453,5 @@ JSON_INLINE_VARIABLE constexpr const auto& to_json = // NOLINT(misc-definitions- #ifndef JSON_HAS_CPP_17 } // namespace #endif -} // namespace json_v3_10_5 -} // namespace nlohmann + +NLOHMANN_JSON_NAMESPACE_END diff --git a/include/nlohmann/detail/exceptions.hpp b/include/nlohmann/detail/exceptions.hpp index a229f7c16..dc36dacb5 100644 --- a/include/nlohmann/detail/exceptions.hpp +++ b/include/nlohmann/detail/exceptions.hpp @@ -23,10 +23,7 @@ #include -namespace nlohmann -{ -inline namespace json_v3_10_5 -{ +NLOHMANN_JSON_NAMESPACE_BEGIN namespace detail { @@ -255,5 +252,4 @@ class other_error : public exception }; } // namespace detail -} // namespace json_v3_10_5 -} // namespace nlohmann +NLOHMANN_JSON_NAMESPACE_END diff --git a/include/nlohmann/detail/hash.hpp b/include/nlohmann/detail/hash.hpp index 6ee516f35..b01805211 100644 --- a/include/nlohmann/detail/hash.hpp +++ b/include/nlohmann/detail/hash.hpp @@ -15,10 +15,7 @@ #include #include -namespace nlohmann -{ -inline namespace json_v3_10_5 -{ +NLOHMANN_JSON_NAMESPACE_BEGIN namespace detail { @@ -129,5 +126,4 @@ std::size_t hash(const BasicJsonType& j) } } // namespace detail -} // namespace json_v3_10_5 -} // namespace nlohmann +NLOHMANN_JSON_NAMESPACE_END diff --git a/include/nlohmann/detail/input/binary_reader.hpp b/include/nlohmann/detail/input/binary_reader.hpp index d8c679437..cb16f4980 100644 --- a/include/nlohmann/detail/input/binary_reader.hpp +++ b/include/nlohmann/detail/input/binary_reader.hpp @@ -32,10 +32,7 @@ #include #include -namespace nlohmann -{ -inline namespace json_v3_10_5 -{ +NLOHMANN_JSON_NAMESPACE_BEGIN namespace detail { @@ -2971,6 +2968,6 @@ class binary_reader /// the SAX parser json_sax_t* sax = nullptr; }; + } // namespace detail -} // namespace json_v3_10_5 -} // namespace nlohmann +NLOHMANN_JSON_NAMESPACE_END diff --git a/include/nlohmann/detail/input/input_adapters.hpp b/include/nlohmann/detail/input/input_adapters.hpp index 35ac87e53..ce4d4a802 100644 --- a/include/nlohmann/detail/input/input_adapters.hpp +++ b/include/nlohmann/detail/input/input_adapters.hpp @@ -26,12 +26,10 @@ #include #include -namespace nlohmann -{ -inline namespace json_v3_10_5 -{ +NLOHMANN_JSON_NAMESPACE_BEGIN namespace detail { + /// the supported input formats enum class input_format_t { json, cbor, msgpack, ubjson, bson, bjdata }; @@ -491,6 +489,6 @@ class span_input_adapter private: contiguous_bytes_input_adapter ia; }; + } // namespace detail -} // namespace json_v3_10_5 -} // namespace nlohmann +NLOHMANN_JSON_NAMESPACE_END diff --git a/include/nlohmann/detail/input/json_sax.hpp b/include/nlohmann/detail/input/json_sax.hpp index 551dacfa5..c31191042 100644 --- a/include/nlohmann/detail/input/json_sax.hpp +++ b/include/nlohmann/detail/input/json_sax.hpp @@ -17,10 +17,7 @@ #include #include -namespace nlohmann -{ -inline namespace json_v3_10_5 -{ +NLOHMANN_JSON_NAMESPACE_BEGIN /*! @brief SAX interface @@ -726,7 +723,6 @@ class json_sax_acceptor return false; } }; -} // namespace detail -} // namespace json_v3_10_5 -} // namespace nlohmann +} // namespace detail +NLOHMANN_JSON_NAMESPACE_END diff --git a/include/nlohmann/detail/input/lexer.hpp b/include/nlohmann/detail/input/lexer.hpp index 91b18e9d9..d3b769e76 100644 --- a/include/nlohmann/detail/input/lexer.hpp +++ b/include/nlohmann/detail/input/lexer.hpp @@ -22,12 +22,10 @@ #include #include -namespace nlohmann -{ -inline namespace json_v3_10_5 -{ +NLOHMANN_JSON_NAMESPACE_BEGIN namespace detail { + /////////// // lexer // /////////// @@ -1629,6 +1627,6 @@ scan_number_done: /// the decimal point const char_int_type decimal_point_char = '.'; }; + } // namespace detail -} // namespace json_v3_10_5 -} // namespace nlohmann +NLOHMANN_JSON_NAMESPACE_END diff --git a/include/nlohmann/detail/input/parser.hpp b/include/nlohmann/detail/input/parser.hpp index 2538f4e45..1b913192e 100644 --- a/include/nlohmann/detail/input/parser.hpp +++ b/include/nlohmann/detail/input/parser.hpp @@ -24,10 +24,7 @@ #include #include -namespace nlohmann -{ -inline namespace json_v3_10_5 -{ +NLOHMANN_JSON_NAMESPACE_BEGIN namespace detail { //////////// @@ -507,5 +504,4 @@ class parser }; } // namespace detail -} // namespace json_v3_10_5 -} // namespace nlohmann +NLOHMANN_JSON_NAMESPACE_END diff --git a/include/nlohmann/detail/input/position_t.hpp b/include/nlohmann/detail/input/position_t.hpp index 2003ae5ba..874a0fe2d 100644 --- a/include/nlohmann/detail/input/position_t.hpp +++ b/include/nlohmann/detail/input/position_t.hpp @@ -10,12 +10,12 @@ #include // size_t -namespace nlohmann -{ -inline namespace json_v3_10_5 -{ +#include + +NLOHMANN_JSON_NAMESPACE_BEGIN namespace detail { + /// struct to capture the start position of the current token struct position_t { @@ -34,5 +34,4 @@ struct position_t }; } // namespace detail -} // namespace json_v3_10_5 -} // namespace nlohmann +NLOHMANN_JSON_NAMESPACE_END diff --git a/include/nlohmann/detail/iterators/internal_iterator.hpp b/include/nlohmann/detail/iterators/internal_iterator.hpp index 3339f4a50..5e0df2f80 100644 --- a/include/nlohmann/detail/iterators/internal_iterator.hpp +++ b/include/nlohmann/detail/iterators/internal_iterator.hpp @@ -9,13 +9,12 @@ #pragma once #include +#include -namespace nlohmann -{ -inline namespace json_v3_10_5 -{ +NLOHMANN_JSON_NAMESPACE_BEGIN namespace detail { + /*! @brief an iterator value @@ -31,6 +30,6 @@ template struct internal_iterator /// generic iterator for all other types primitive_iterator_t primitive_iterator {}; }; + } // namespace detail -} // namespace json_v3_10_5 -} // namespace nlohmann +NLOHMANN_JSON_NAMESPACE_END diff --git a/include/nlohmann/detail/iterators/iter_impl.hpp b/include/nlohmann/detail/iterators/iter_impl.hpp index 62ce6106f..84dfa3ecf 100644 --- a/include/nlohmann/detail/iterators/iter_impl.hpp +++ b/include/nlohmann/detail/iterators/iter_impl.hpp @@ -19,12 +19,10 @@ #include #include -namespace nlohmann -{ -inline namespace json_v3_10_5 -{ +NLOHMANN_JSON_NAMESPACE_BEGIN namespace detail { + // forward declare, to be able to friend it later on template class iteration_proxy; template class iteration_proxy_value; @@ -748,6 +746,6 @@ class iter_impl // NOLINT(cppcoreguidelines-special-member-functions,hicpp-speci /// the actual iterator of the associated instance internal_iterator::type> m_it {}; }; + } // namespace detail -} // namespace json_v3_10_5 -} // namespace nlohmann +NLOHMANN_JSON_NAMESPACE_END diff --git a/include/nlohmann/detail/iterators/iteration_proxy.hpp b/include/nlohmann/detail/iterators/iteration_proxy.hpp index fabd8d384..935ba7160 100644 --- a/include/nlohmann/detail/iterators/iteration_proxy.hpp +++ b/include/nlohmann/detail/iterators/iteration_proxy.hpp @@ -18,15 +18,14 @@ #include // enable_borrowed_range #endif +#include #include #include -namespace nlohmann -{ -inline namespace json_v3_10_5 -{ +NLOHMANN_JSON_NAMESPACE_BEGIN namespace detail { + template void int_to_string( string_type& target, std::size_t value ) { @@ -203,9 +202,9 @@ auto get(const nlohmann::detail::iteration_proxy_value& i) -> decl { return i.value(); } + } // namespace detail -} // namespace json_v3_10_5 -} // namespace nlohmann +NLOHMANN_JSON_NAMESPACE_END // The Addition to the STD Namespace is required to add // Structured Bindings Support to the iteration_proxy_value class @@ -213,6 +212,7 @@ auto get(const nlohmann::detail::iteration_proxy_value& i) -> decl // And see https://github.com/nlohmann/json/pull/1391 namespace std { + #if defined(__clang__) // Fix: https://github.com/nlohmann/json/issues/1401 #pragma clang diagnostic push @@ -233,6 +233,7 @@ class tuple_element> #if defined(__clang__) #pragma clang diagnostic pop #endif + } // namespace std #if JSON_HAS_RANGES diff --git a/include/nlohmann/detail/iterators/iterator_traits.hpp b/include/nlohmann/detail/iterators/iterator_traits.hpp index 7bbd55298..3d2efb003 100644 --- a/include/nlohmann/detail/iterators/iterator_traits.hpp +++ b/include/nlohmann/detail/iterators/iterator_traits.hpp @@ -10,15 +10,14 @@ #include // random_access_iterator_tag +#include #include #include -namespace nlohmann -{ -inline namespace json_v3_10_5 -{ +NLOHMANN_JSON_NAMESPACE_BEGIN namespace detail { + template struct iterator_types {}; @@ -57,6 +56,6 @@ struct iterator_traits::value>> using pointer = T*; using reference = T&; }; + } // namespace detail -} // namespace json_v3_10_5 -} // namespace nlohmann +NLOHMANN_JSON_NAMESPACE_END diff --git a/include/nlohmann/detail/iterators/json_reverse_iterator.hpp b/include/nlohmann/detail/iterators/json_reverse_iterator.hpp index fd4595258..e16b93b99 100644 --- a/include/nlohmann/detail/iterators/json_reverse_iterator.hpp +++ b/include/nlohmann/detail/iterators/json_reverse_iterator.hpp @@ -12,12 +12,12 @@ #include // reverse_iterator #include // declval -namespace nlohmann -{ -inline namespace json_v3_10_5 -{ +#include + +NLOHMANN_JSON_NAMESPACE_BEGIN namespace detail { + ////////////////////// // reverse_iterator // ////////////////////// @@ -125,6 +125,6 @@ class json_reverse_iterator : public std::reverse_iterator return it.operator * (); } }; + } // namespace detail -} // namespace json_v3_10_5 -} // namespace nlohmann +NLOHMANN_JSON_NAMESPACE_END diff --git a/include/nlohmann/detail/iterators/primitive_iterator.hpp b/include/nlohmann/detail/iterators/primitive_iterator.hpp index 85582ce2c..b47cf01f4 100644 --- a/include/nlohmann/detail/iterators/primitive_iterator.hpp +++ b/include/nlohmann/detail/iterators/primitive_iterator.hpp @@ -13,12 +13,10 @@ #include -namespace nlohmann -{ -inline namespace json_v3_10_5 -{ +NLOHMANN_JSON_NAMESPACE_BEGIN namespace detail { + /* @brief an iterator for primitive JSON types @@ -129,6 +127,6 @@ class primitive_iterator_t return *this; } }; + } // namespace detail -} // namespace json_v3_10_5 -} // namespace nlohmann +NLOHMANN_JSON_NAMESPACE_END diff --git a/include/nlohmann/detail/json_pointer.hpp b/include/nlohmann/detail/json_pointer.hpp index 4798edbf1..2aa68efad 100644 --- a/include/nlohmann/detail/json_pointer.hpp +++ b/include/nlohmann/detail/json_pointer.hpp @@ -27,10 +27,7 @@ #include #include -namespace nlohmann -{ -inline namespace json_v3_10_5 -{ +NLOHMANN_JSON_NAMESPACE_BEGIN /// @brief JSON Pointer defines a string syntax for identifying a specific value within a JSON document /// @sa https://json.nlohmann.me/api/json_pointer/ @@ -899,5 +896,5 @@ inline bool operator!=(json_pointer const& lhs, { return !(lhs == rhs); } -} // namespace json_v3_10_5 -} // namespace nlohmann + +NLOHMANN_JSON_NAMESPACE_END diff --git a/include/nlohmann/detail/json_ref.hpp b/include/nlohmann/detail/json_ref.hpp index 5dd9cb443..8569ea805 100644 --- a/include/nlohmann/detail/json_ref.hpp +++ b/include/nlohmann/detail/json_ref.hpp @@ -11,14 +11,13 @@ #include #include +#include #include -namespace nlohmann -{ -inline namespace json_v3_10_5 -{ +NLOHMANN_JSON_NAMESPACE_BEGIN namespace detail { + template class json_ref { @@ -74,6 +73,6 @@ class json_ref mutable value_type owned_value = nullptr; value_type const* value_ref = nullptr; }; + } // namespace detail -} // namespace json_v3_10_5 -} // namespace nlohmann +NLOHMANN_JSON_NAMESPACE_END diff --git a/include/nlohmann/detail/macro_scope.hpp b/include/nlohmann/detail/macro_scope.hpp index d3b30bace..4f7c88f07 100644 --- a/include/nlohmann/detail/macro_scope.hpp +++ b/include/nlohmann/detail/macro_scope.hpp @@ -9,8 +9,8 @@ #pragma once #include // declval, pair -#include #include +#include // This file contains all internal macro definitions // You MUST include macro_unscope.hpp at the end of json.hpp to undef all of them @@ -228,6 +228,54 @@ e = ((it != std::end(m)) ? it : std::begin(m))->first; \ } +#ifndef JSON_USE_IMPLICIT_CONVERSIONS + #define JSON_USE_IMPLICIT_CONVERSIONS 1 +#endif + +#if JSON_USE_IMPLICIT_CONVERSIONS + #define JSON_EXPLICIT +#else + #define JSON_EXPLICIT explicit +#endif + +#ifndef JSON_DIAGNOSTICS + #define JSON_DIAGNOSTICS 0 +#endif + +#ifndef JSON_USE_LEGACY_DISCARDED_VALUE_COMPARISON + #define JSON_USE_LEGACY_DISCARDED_VALUE_COMPARISON 0 +#endif + +#ifndef JSON_DISABLE_ENUM_SERIALIZATION + #define JSON_DISABLE_ENUM_SERIALIZATION 0 +#endif + +#if JSON_DIAGNOSTICS + #define NLOHMANN_JSON_ABI_TAG_DIAGNOSTICS _diag +#else + #define NLOHMANN_JSON_ABI_TAG_DIAGNOSTICS +#endif + +#define NLOHMANN_JSON_ABI_PREFIX json_v3_10_5 +#define NLOHMANN_JSON_ABI_CONCAT_EX(a, b) a ## b +#define NLOHMANN_JSON_ABI_CONCAT(a, b) NLOHMANN_JSON_ABI_CONCAT_EX(a, b) +#define NLOHMANN_JSON_ABI_STRING \ + NLOHMANN_JSON_ABI_CONCAT( \ + NLOHMANN_JSON_ABI_PREFIX, \ + NLOHMANN_JSON_ABI_TAG_DIAGNOSTICS \ + ) +#define NLOHMANN_JSON_NAMESPACE nlohmann::NLOHMANN_JSON_ABI_STRING + +#define NLOHMANN_JSON_NAMESPACE_BEGIN \ + namespace nlohmann \ + { \ + inline namespace NLOHMANN_JSON_ABI_STRING \ + { + +#define NLOHMANN_JSON_NAMESPACE_END \ + } /* namespace (abi_string) */ \ + } /* namespace nlohmann */ + // Ugly macros to avoid uglier copy-paste when specializing basic_json. They // may be removed in the future once the class is split. @@ -446,25 +494,3 @@ struct would_call_std_##std_name : detail2::would_call_std_##std_name \ { \ } - -#ifndef JSON_USE_IMPLICIT_CONVERSIONS - #define JSON_USE_IMPLICIT_CONVERSIONS 1 -#endif - -#if JSON_USE_IMPLICIT_CONVERSIONS - #define JSON_EXPLICIT -#else - #define JSON_EXPLICIT explicit -#endif - -#ifndef JSON_DIAGNOSTICS - #define JSON_DIAGNOSTICS 0 -#endif - -#ifndef JSON_USE_LEGACY_DISCARDED_VALUE_COMPARISON - #define JSON_USE_LEGACY_DISCARDED_VALUE_COMPARISON 0 -#endif - -#ifndef JSON_DISABLE_ENUM_SERIALIZATION - #define JSON_DISABLE_ENUM_SERIALIZATION 0 -#endif diff --git a/include/nlohmann/detail/meta/call_std/begin.hpp b/include/nlohmann/detail/meta/call_std/begin.hpp index c03c064f3..b8602e48a 100644 --- a/include/nlohmann/detail/meta/call_std/begin.hpp +++ b/include/nlohmann/detail/meta/call_std/begin.hpp @@ -10,10 +10,8 @@ #include -namespace nlohmann -{ -inline namespace json_v3_10_5 -{ +NLOHMANN_JSON_NAMESPACE_BEGIN + NLOHMANN_CAN_CALL_STD_FUNC_IMPL(begin); -} // namespace json_v3_10_5 -} // namespace nlohmann + +NLOHMANN_JSON_NAMESPACE_END diff --git a/include/nlohmann/detail/meta/call_std/end.hpp b/include/nlohmann/detail/meta/call_std/end.hpp index df06524fb..845c26182 100644 --- a/include/nlohmann/detail/meta/call_std/end.hpp +++ b/include/nlohmann/detail/meta/call_std/end.hpp @@ -10,10 +10,8 @@ #include -namespace nlohmann -{ -inline namespace json_v3_10_5 -{ +NLOHMANN_JSON_NAMESPACE_BEGIN + NLOHMANN_CAN_CALL_STD_FUNC_IMPL(end); -} // namespace json_v3_10_5 -} // namespace nlohmann + +NLOHMANN_JSON_NAMESPACE_END diff --git a/include/nlohmann/detail/meta/cpp_future.hpp b/include/nlohmann/detail/meta/cpp_future.hpp index 00292befb..de3b7d4a8 100644 --- a/include/nlohmann/detail/meta/cpp_future.hpp +++ b/include/nlohmann/detail/meta/cpp_future.hpp @@ -15,10 +15,7 @@ #include -namespace nlohmann -{ -inline namespace json_v3_10_5 -{ +NLOHMANN_JSON_NAMESPACE_BEGIN namespace detail { @@ -166,5 +163,4 @@ struct static_const #endif } // namespace detail -} // namespace json_v3_10_5 -} // namespace nlohmann +NLOHMANN_JSON_NAMESPACE_END diff --git a/include/nlohmann/detail/meta/detected.hpp b/include/nlohmann/detail/meta/detected.hpp index 3361dab5e..e38fb88a3 100644 --- a/include/nlohmann/detail/meta/detected.hpp +++ b/include/nlohmann/detail/meta/detected.hpp @@ -12,13 +12,12 @@ #include -// https://en.cppreference.com/w/cpp/experimental/is_detected -namespace nlohmann -{ -inline namespace json_v3_10_5 -{ +NLOHMANN_JSON_NAMESPACE_BEGIN namespace detail { + +// https://en.cppreference.com/w/cpp/experimental/is_detected + struct nonesuch { nonesuch() = delete; @@ -67,6 +66,6 @@ using is_detected_exact = std::is_same>; template class Op, class... Args> using is_detected_convertible = std::is_convertible, To>; + } // namespace detail -} // namespace json_v3_10_5 -} // namespace nlohmann +NLOHMANN_JSON_NAMESPACE_END diff --git a/include/nlohmann/detail/meta/identity_tag.hpp b/include/nlohmann/detail/meta/identity_tag.hpp index 688d9c184..4ef72b7ea 100644 --- a/include/nlohmann/detail/meta/identity_tag.hpp +++ b/include/nlohmann/detail/meta/identity_tag.hpp @@ -8,14 +8,14 @@ #pragma once -namespace nlohmann -{ -inline namespace json_v3_10_5 -{ +#include + +NLOHMANN_JSON_NAMESPACE_BEGIN namespace detail { + // dispatching helper struct template struct identity_tag {}; + } // namespace detail -} // namespace json_v3_10_5 -} // namespace nlohmann +NLOHMANN_JSON_NAMESPACE_END diff --git a/include/nlohmann/detail/meta/is_sax.hpp b/include/nlohmann/detail/meta/is_sax.hpp index 598045bc9..7572a1dc1 100644 --- a/include/nlohmann/detail/meta/is_sax.hpp +++ b/include/nlohmann/detail/meta/is_sax.hpp @@ -12,15 +12,14 @@ #include // declval #include // string +#include #include #include -namespace nlohmann -{ -inline namespace json_v3_10_5 -{ +NLOHMANN_JSON_NAMESPACE_BEGIN namespace detail { + template using null_function_t = decltype(std::declval().null()); @@ -155,6 +154,6 @@ struct is_sax_static_asserts "Missing/invalid function: bool parse_error(std::size_t, const " "std::string&, const exception&)"); }; + } // namespace detail -} // namespace json_v3_10_5 -} // namespace nlohmann +NLOHMANN_JSON_NAMESPACE_END diff --git a/include/nlohmann/detail/meta/type_traits.hpp b/include/nlohmann/detail/meta/type_traits.hpp index 336677b4a..978df9f29 100644 --- a/include/nlohmann/detail/meta/type_traits.hpp +++ b/include/nlohmann/detail/meta/type_traits.hpp @@ -13,19 +13,15 @@ #include // declval #include // tuple -#include - #include +#include #include #include #include #include #include -namespace nlohmann -{ -inline namespace json_v3_10_5 -{ +NLOHMANN_JSON_NAMESPACE_BEGIN /*! @brief detail namespace with internal helper functions @@ -36,6 +32,7 @@ implementations of some @ref basic_json methods, and meta-programming helpers. */ namespace detail { + ///////////// // helpers // ///////////// @@ -688,5 +685,4 @@ inline constexpr bool value_in_range_of(T val) } } // namespace detail -} // namespace json_v3_10_5 -} // namespace nlohmann +NLOHMANN_JSON_NAMESPACE_END diff --git a/include/nlohmann/detail/meta/void_t.hpp b/include/nlohmann/detail/meta/void_t.hpp index 163256140..73c651b1f 100644 --- a/include/nlohmann/detail/meta/void_t.hpp +++ b/include/nlohmann/detail/meta/void_t.hpp @@ -8,17 +8,17 @@ #pragma once -namespace nlohmann -{ -inline namespace json_v3_10_5 -{ +#include + +NLOHMANN_JSON_NAMESPACE_BEGIN namespace detail { + template struct make_void { using type = void; }; template using void_t = typename make_void::type; + } // namespace detail -} // namespace json_v3_10_5 -} // namespace nlohmann +NLOHMANN_JSON_NAMESPACE_END diff --git a/include/nlohmann/detail/output/binary_writer.hpp b/include/nlohmann/detail/output/binary_writer.hpp index 3007f4751..b2c35b88c 100644 --- a/include/nlohmann/detail/output/binary_writer.hpp +++ b/include/nlohmann/detail/output/binary_writer.hpp @@ -24,12 +24,10 @@ #include #include -namespace nlohmann -{ -inline namespace json_v3_10_5 -{ +NLOHMANN_JSON_NAMESPACE_BEGIN namespace detail { + /////////////////// // binary writer // /////////////////// @@ -1835,6 +1833,6 @@ class binary_writer /// the output output_adapter_t oa = nullptr; }; + } // namespace detail -} // namespace json_v3_10_5 -} // namespace nlohmann +NLOHMANN_JSON_NAMESPACE_END diff --git a/include/nlohmann/detail/output/output_adapters.hpp b/include/nlohmann/detail/output/output_adapters.hpp index f769d2516..5f0e87022 100644 --- a/include/nlohmann/detail/output/output_adapters.hpp +++ b/include/nlohmann/detail/output/output_adapters.hpp @@ -22,12 +22,10 @@ #include -namespace nlohmann -{ -inline namespace json_v3_10_5 -{ +NLOHMANN_JSON_NAMESPACE_BEGIN namespace detail { + /// abstract output adapter interface template struct output_adapter_protocol { @@ -144,6 +142,6 @@ class output_adapter private: output_adapter_t oa = nullptr; }; + } // namespace detail -} // namespace json_v3_10_5 -} // namespace nlohmann +NLOHMANN_JSON_NAMESPACE_END diff --git a/include/nlohmann/detail/output/serializer.hpp b/include/nlohmann/detail/output/serializer.hpp index 293e734f8..19d5cc434 100644 --- a/include/nlohmann/detail/output/serializer.hpp +++ b/include/nlohmann/detail/output/serializer.hpp @@ -31,12 +31,10 @@ #include #include -namespace nlohmann -{ -inline namespace json_v3_10_5 -{ +NLOHMANN_JSON_NAMESPACE_BEGIN namespace detail { + /////////////////// // serialization // /////////////////// @@ -985,6 +983,6 @@ class serializer /// error_handler how to react on decoding errors const error_handler_t error_handler; }; + } // namespace detail -} // namespace json_v3_10_5 -} // namespace nlohmann +NLOHMANN_JSON_NAMESPACE_END diff --git a/include/nlohmann/detail/string_concat.hpp b/include/nlohmann/detail/string_concat.hpp index caecb8f1e..af44a69b9 100644 --- a/include/nlohmann/detail/string_concat.hpp +++ b/include/nlohmann/detail/string_concat.hpp @@ -12,13 +12,11 @@ #include // string #include // forward +#include #include #include -namespace nlohmann -{ -inline namespace json_v3_10_5 -{ +NLOHMANN_JSON_NAMESPACE_BEGIN namespace detail { @@ -146,5 +144,4 @@ inline OutStringType concat(Args && ... args) } } // namespace detail -} // namespace json_v3_10_5 -} // namespace nlohmann +NLOHMANN_JSON_NAMESPACE_END diff --git a/include/nlohmann/detail/string_escape.hpp b/include/nlohmann/detail/string_escape.hpp index 3202eca01..e9b601a2a 100644 --- a/include/nlohmann/detail/string_escape.hpp +++ b/include/nlohmann/detail/string_escape.hpp @@ -10,10 +10,7 @@ #include -namespace nlohmann -{ -inline namespace json_v3_10_5 -{ +NLOHMANN_JSON_NAMESPACE_BEGIN namespace detail { @@ -72,5 +69,4 @@ static void unescape(StringType& s) } } // namespace detail -} // namespace json_v3_10_5 -} // namespace nlohmann +NLOHMANN_JSON_NAMESPACE_END diff --git a/include/nlohmann/detail/value_t.hpp b/include/nlohmann/detail/value_t.hpp index 0b435e8bf..e11187c6c 100644 --- a/include/nlohmann/detail/value_t.hpp +++ b/include/nlohmann/detail/value_t.hpp @@ -18,12 +18,10 @@ #include // partial_ordering #endif -namespace nlohmann -{ -inline namespace json_v3_10_5 -{ +NLOHMANN_JSON_NAMESPACE_BEGIN namespace detail { + /////////////////////////// // JSON type enumeration // /////////////////////////// @@ -115,6 +113,6 @@ inline bool operator<(const value_t lhs, const value_t rhs) noexcept return std::is_lt(lhs <=> rhs); // *NOPAD* } #endif + } // namespace detail -} // namespace json_v3_10_5 -} // namespace nlohmann +NLOHMANN_JSON_NAMESPACE_END diff --git a/include/nlohmann/json.hpp b/include/nlohmann/json.hpp index c1348b79d..9404bd733 100644 --- a/include/nlohmann/json.hpp +++ b/include/nlohmann/json.hpp @@ -83,10 +83,7 @@ @see https://github.com/nlohmann @since version 1.0.0 */ -namespace nlohmann -{ -inline namespace json_v3_10_5 -{ +NLOHMANN_JSON_NAMESPACE_BEGIN /*! @brief a class to store JSON values @@ -5088,8 +5085,7 @@ std::string to_string(const NLOHMANN_BASIC_JSON_TPL& j) return j.dump(); } -} // namespace json_v3_10_5 -} // namespace nlohmann +NLOHMANN_JSON_NAMESPACE_END /////////////////////// // nonmember support // diff --git a/include/nlohmann/json_fwd.hpp b/include/nlohmann/json_fwd.hpp index 6e05a2526..1a18dabb0 100644 --- a/include/nlohmann/json_fwd.hpp +++ b/include/nlohmann/json_fwd.hpp @@ -15,15 +15,15 @@ #include // string #include // vector +#include + /*! @brief namespace for Niels Lohmann @see https://github.com/nlohmann @since version 1.0.0 */ -namespace nlohmann -{ -inline namespace json_v3_10_5 -{ +NLOHMANN_JSON_NAMESPACE_BEGIN + /*! @brief default JSONSerializer template argument @@ -69,7 +69,6 @@ struct ordered_map; /// @sa https://json.nlohmann.me/api/ordered_json/ using ordered_json = basic_json; -} // namespace json_v3_10_5 -} // namespace nlohmann +NLOHMANN_JSON_NAMESPACE_END #endif // INCLUDE_NLOHMANN_JSON_FWD_HPP_ diff --git a/include/nlohmann/ordered_map.hpp b/include/nlohmann/ordered_map.hpp index 03d0efbd7..449fa7781 100644 --- a/include/nlohmann/ordered_map.hpp +++ b/include/nlohmann/ordered_map.hpp @@ -20,10 +20,7 @@ #include #include -namespace nlohmann -{ -inline namespace json_v3_10_5 -{ +NLOHMANN_JSON_NAMESPACE_BEGIN /// ordered_map: a minimal map-like container that preserves insertion order /// for use within nlohmann::basic_json @@ -359,5 +356,4 @@ private: JSON_NO_UNIQUE_ADDRESS key_compare m_compare = key_compare(); }; -} // namespace json_v3_10_5 -} // namespace nlohmann +NLOHMANN_JSON_NAMESPACE_END diff --git a/single_include/nlohmann/json.hpp b/single_include/nlohmann/json.hpp index 4412fc4bc..11f9d0978 100644 --- a/single_include/nlohmann/json.hpp +++ b/single_include/nlohmann/json.hpp @@ -126,6 +126,105 @@ #include // declval, pair +// #include +// __ _____ _____ _____ +// __| | __| | | | JSON for Modern C++ +// | | |__ | | | | | | version 3.10.5 +// |_____|_____|_____|_|___| https://github.com/nlohmann/json +// +// SPDX-FileCopyrightText: 2013-2022 Niels Lohmann +// SPDX-License-Identifier: MIT + + + +#include + +// #include +// __ _____ _____ _____ +// __| | __| | | | JSON for Modern C++ +// | | |__ | | | | | | version 3.10.5 +// |_____|_____|_____|_|___| https://github.com/nlohmann/json +// +// SPDX-FileCopyrightText: 2013-2022 Niels Lohmann +// SPDX-License-Identifier: MIT + + + +// #include + + +NLOHMANN_JSON_NAMESPACE_BEGIN +namespace detail +{ + +template struct make_void +{ + using type = void; +}; +template using void_t = typename make_void::type; + +} // namespace detail +NLOHMANN_JSON_NAMESPACE_END + + +NLOHMANN_JSON_NAMESPACE_BEGIN +namespace detail +{ + +// https://en.cppreference.com/w/cpp/experimental/is_detected + +struct nonesuch +{ + nonesuch() = delete; + ~nonesuch() = delete; + nonesuch(nonesuch const&) = delete; + nonesuch(nonesuch const&&) = delete; + void operator=(nonesuch const&) = delete; + void operator=(nonesuch&&) = delete; +}; + +template class Op, + class... Args> +struct detector +{ + using value_t = std::false_type; + using type = Default; +}; + +template class Op, class... Args> +struct detector>, Op, Args...> +{ + using value_t = std::true_type; + using type = Op; +}; + +template class Op, class... Args> +using is_detected = typename detector::value_t; + +template class Op, class... Args> +struct is_detected_lazy : is_detected { }; + +template class Op, class... Args> +using detected_t = typename detector::type; + +template class Op, class... Args> +using detected_or = detector; + +template class Op, class... Args> +using detected_or_t = typename detected_or::type; + +template class Op, class... Args> +using is_detected_exact = std::is_same>; + +template class Op, class... Args> +using is_detected_convertible = + std::is_convertible, To>; + +} // namespace detail +NLOHMANN_JSON_NAMESPACE_END + // #include @@ -2173,105 +2272,6 @@ JSON_HEDLEY_DIAGNOSTIC_POP #endif /* !defined(JSON_HEDLEY_VERSION) || (JSON_HEDLEY_VERSION < X) */ -// #include -// __ _____ _____ _____ -// __| | __| | | | JSON for Modern C++ -// | | |__ | | | | | | version 3.10.5 -// |_____|_____|_____|_|___| https://github.com/nlohmann/json -// -// SPDX-FileCopyrightText: 2013-2022 Niels Lohmann -// SPDX-License-Identifier: MIT - - - -#include - -// #include -// __ _____ _____ _____ -// __| | __| | | | JSON for Modern C++ -// | | |__ | | | | | | version 3.10.5 -// |_____|_____|_____|_|___| https://github.com/nlohmann/json -// -// SPDX-FileCopyrightText: 2013-2022 Niels Lohmann -// SPDX-License-Identifier: MIT - - - -namespace nlohmann -{ -inline namespace json_v3_10_5 -{ -namespace detail -{ -template struct make_void -{ - using type = void; -}; -template using void_t = typename make_void::type; -} // namespace detail -} // namespace json_v3_10_5 -} // namespace nlohmann - - -// https://en.cppreference.com/w/cpp/experimental/is_detected -namespace nlohmann -{ -inline namespace json_v3_10_5 -{ -namespace detail -{ -struct nonesuch -{ - nonesuch() = delete; - ~nonesuch() = delete; - nonesuch(nonesuch const&) = delete; - nonesuch(nonesuch const&&) = delete; - void operator=(nonesuch const&) = delete; - void operator=(nonesuch&&) = delete; -}; - -template class Op, - class... Args> -struct detector -{ - using value_t = std::false_type; - using type = Default; -}; - -template class Op, class... Args> -struct detector>, Op, Args...> -{ - using value_t = std::true_type; - using type = Op; -}; - -template class Op, class... Args> -using is_detected = typename detector::value_t; - -template class Op, class... Args> -struct is_detected_lazy : is_detected { }; - -template class Op, class... Args> -using detected_t = typename detector::type; - -template class Op, class... Args> -using detected_or = detector; - -template class Op, class... Args> -using detected_or_t = typename detected_or::type; - -template class Op, class... Args> -using is_detected_exact = std::is_same>; - -template class Op, class... Args> -using is_detected_convertible = - std::is_convertible, To>; -} // namespace detail -} // namespace json_v3_10_5 -} // namespace nlohmann - // This file contains all internal macro definitions // You MUST include macro_unscope.hpp at the end of json.hpp to undef all of them @@ -2489,6 +2489,54 @@ using is_detected_convertible = e = ((it != std::end(m)) ? it : std::begin(m))->first; \ } +#ifndef JSON_USE_IMPLICIT_CONVERSIONS + #define JSON_USE_IMPLICIT_CONVERSIONS 1 +#endif + +#if JSON_USE_IMPLICIT_CONVERSIONS + #define JSON_EXPLICIT +#else + #define JSON_EXPLICIT explicit +#endif + +#ifndef JSON_DIAGNOSTICS + #define JSON_DIAGNOSTICS 0 +#endif + +#ifndef JSON_USE_LEGACY_DISCARDED_VALUE_COMPARISON + #define JSON_USE_LEGACY_DISCARDED_VALUE_COMPARISON 0 +#endif + +#ifndef JSON_DISABLE_ENUM_SERIALIZATION + #define JSON_DISABLE_ENUM_SERIALIZATION 0 +#endif + +#if JSON_DIAGNOSTICS + #define NLOHMANN_JSON_ABI_TAG_DIAGNOSTICS _diag +#else + #define NLOHMANN_JSON_ABI_TAG_DIAGNOSTICS +#endif + +#define NLOHMANN_JSON_ABI_PREFIX json_v3_10_5 +#define NLOHMANN_JSON_ABI_CONCAT_EX(a, b) a ## b +#define NLOHMANN_JSON_ABI_CONCAT(a, b) NLOHMANN_JSON_ABI_CONCAT_EX(a, b) +#define NLOHMANN_JSON_ABI_STRING \ + NLOHMANN_JSON_ABI_CONCAT( \ + NLOHMANN_JSON_ABI_PREFIX, \ + NLOHMANN_JSON_ABI_TAG_DIAGNOSTICS \ + ) +#define NLOHMANN_JSON_NAMESPACE nlohmann::NLOHMANN_JSON_ABI_STRING + +#define NLOHMANN_JSON_NAMESPACE_BEGIN \ + namespace nlohmann \ + { \ + inline namespace NLOHMANN_JSON_ABI_STRING \ + { + +#define NLOHMANN_JSON_NAMESPACE_END \ + } /* namespace (abi_string) */ \ + } /* namespace nlohmann */ + // Ugly macros to avoid uglier copy-paste when specializing basic_json. They // may be removed in the future once the class is split. @@ -2708,38 +2756,14 @@ using is_detected_convertible = { \ } -#ifndef JSON_USE_IMPLICIT_CONVERSIONS - #define JSON_USE_IMPLICIT_CONVERSIONS 1 -#endif - -#if JSON_USE_IMPLICIT_CONVERSIONS - #define JSON_EXPLICIT -#else - #define JSON_EXPLICIT explicit -#endif - -#ifndef JSON_DIAGNOSTICS - #define JSON_DIAGNOSTICS 0 -#endif - -#ifndef JSON_USE_LEGACY_DISCARDED_VALUE_COMPARISON - #define JSON_USE_LEGACY_DISCARDED_VALUE_COMPARISON 0 -#endif - -#ifndef JSON_DISABLE_ENUM_SERIALIZATION - #define JSON_DISABLE_ENUM_SERIALIZATION 0 -#endif - #if JSON_HAS_THREE_WAY_COMPARISON #include // partial_ordering #endif -namespace nlohmann -{ -inline namespace json_v3_10_5 -{ +NLOHMANN_JSON_NAMESPACE_BEGIN namespace detail { + /////////////////////////// // JSON type enumeration // /////////////////////////// @@ -2831,9 +2855,9 @@ inline bool operator<(const value_t lhs, const value_t rhs) noexcept return std::is_lt(lhs <=> rhs); // *NOPAD* } #endif + } // namespace detail -} // namespace json_v3_10_5 -} // namespace nlohmann +NLOHMANN_JSON_NAMESPACE_END // #include // __ _____ _____ _____ @@ -2849,10 +2873,7 @@ inline bool operator<(const value_t lhs, const value_t rhs) noexcept // #include -namespace nlohmann -{ -inline namespace json_v3_10_5 -{ +NLOHMANN_JSON_NAMESPACE_BEGIN namespace detail { @@ -2911,8 +2932,7 @@ static void unescape(StringType& s) } } // namespace detail -} // namespace json_v3_10_5 -} // namespace nlohmann +NLOHMANN_JSON_NAMESPACE_END // #include // __ _____ _____ _____ @@ -2927,12 +2947,13 @@ static void unescape(StringType& s) #include // size_t -namespace nlohmann -{ -inline namespace json_v3_10_5 -{ +// #include + + +NLOHMANN_JSON_NAMESPACE_BEGIN namespace detail { + /// struct to capture the start position of the current token struct position_t { @@ -2951,8 +2972,7 @@ struct position_t }; } // namespace detail -} // namespace json_v3_10_5 -} // namespace nlohmann +NLOHMANN_JSON_NAMESPACE_END // #include @@ -2975,10 +2995,7 @@ struct position_t // #include -namespace nlohmann -{ -inline namespace json_v3_10_5 -{ +NLOHMANN_JSON_NAMESPACE_BEGIN namespace detail { @@ -3126,8 +3143,7 @@ struct static_const #endif } // namespace detail -} // namespace json_v3_10_5 -} // namespace nlohmann +NLOHMANN_JSON_NAMESPACE_END // #include // __ _____ _____ _____ @@ -3145,9 +3161,6 @@ struct static_const #include // declval #include // tuple -// #include - - // #include // __ _____ _____ _____ // __| | __| | | | JSON for Modern C++ @@ -3161,17 +3174,17 @@ struct static_const #include // random_access_iterator_tag +// #include + // #include // #include -namespace nlohmann -{ -inline namespace json_v3_10_5 -{ +NLOHMANN_JSON_NAMESPACE_BEGIN namespace detail { + template struct iterator_types {}; @@ -3210,9 +3223,11 @@ struct iterator_traits::value>> using pointer = T*; using reference = T&; }; + } // namespace detail -} // namespace json_v3_10_5 -} // namespace nlohmann +NLOHMANN_JSON_NAMESPACE_END + +// #include // #include // __ _____ _____ _____ @@ -3228,13 +3243,11 @@ struct iterator_traits::value>> // #include -namespace nlohmann -{ -inline namespace json_v3_10_5 -{ +NLOHMANN_JSON_NAMESPACE_BEGIN + NLOHMANN_CAN_CALL_STD_FUNC_IMPL(begin); -} // namespace json_v3_10_5 -} // namespace nlohmann + +NLOHMANN_JSON_NAMESPACE_END // #include // __ _____ _____ _____ @@ -3250,13 +3263,11 @@ NLOHMANN_CAN_CALL_STD_FUNC_IMPL(begin); // #include -namespace nlohmann -{ -inline namespace json_v3_10_5 -{ +NLOHMANN_JSON_NAMESPACE_BEGIN + NLOHMANN_CAN_CALL_STD_FUNC_IMPL(end); -} // namespace json_v3_10_5 -} // namespace nlohmann + +NLOHMANN_JSON_NAMESPACE_END // #include @@ -3272,78 +3283,75 @@ NLOHMANN_CAN_CALL_STD_FUNC_IMPL(end); // SPDX-License-Identifier: MIT #ifndef INCLUDE_NLOHMANN_JSON_FWD_HPP_ -#define INCLUDE_NLOHMANN_JSON_FWD_HPP_ + #define INCLUDE_NLOHMANN_JSON_FWD_HPP_ -#include // int64_t, uint64_t -#include // map -#include // allocator -#include // string -#include // vector + #include // int64_t, uint64_t + #include // map + #include // allocator + #include // string + #include // vector -/*! -@brief namespace for Niels Lohmann -@see https://github.com/nlohmann -@since version 1.0.0 -*/ -namespace nlohmann -{ -inline namespace json_v3_10_5 -{ -/*! -@brief default JSONSerializer template argument + // #include -This serializer ignores the template arguments and uses ADL -([argument-dependent lookup](https://en.cppreference.com/w/cpp/language/adl)) -for serialization. -*/ -template -struct adl_serializer; -/// a class to store JSON values -/// @sa https://json.nlohmann.me/api/basic_json/ -template class ObjectType = - std::map, - template 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 class AllocatorType = std::allocator, - template class JSONSerializer = - adl_serializer, - class BinaryType = std::vector> -class basic_json; + /*! + @brief namespace for Niels Lohmann + @see https://github.com/nlohmann + @since version 1.0.0 + */ + NLOHMANN_JSON_NAMESPACE_BEGIN -/// @brief JSON Pointer defines a string syntax for identifying a specific value within a JSON document -/// @sa https://json.nlohmann.me/api/json_pointer/ -template -class json_pointer; + /*! + @brief default JSONSerializer template argument -/*! -@brief default specialization -@sa https://json.nlohmann.me/api/json/ -*/ -using json = basic_json<>; + This serializer ignores the template arguments and uses ADL + ([argument-dependent lookup](https://en.cppreference.com/w/cpp/language/adl)) + for serialization. + */ + template + struct adl_serializer; -/// @brief a minimal map-like container that preserves insertion order -/// @sa https://json.nlohmann.me/api/ordered_map/ -template -struct ordered_map; + /// a class to store JSON values + /// @sa https://json.nlohmann.me/api/basic_json/ + template class ObjectType = + std::map, + template 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 class AllocatorType = std::allocator, + template class JSONSerializer = + adl_serializer, + class BinaryType = std::vector> + class basic_json; -/// @brief specialization that maintains the insertion order of object keys -/// @sa https://json.nlohmann.me/api/ordered_json/ -using ordered_json = basic_json; + /// @brief JSON Pointer defines a string syntax for identifying a specific value within a JSON document + /// @sa https://json.nlohmann.me/api/json_pointer/ + template + class json_pointer; -} // namespace json_v3_10_5 -} // namespace nlohmann + /*! + @brief default specialization + @sa https://json.nlohmann.me/api/json/ + */ + using json = basic_json<>; + + /// @brief a minimal map-like container that preserves insertion order + /// @sa https://json.nlohmann.me/api/ordered_map/ + template + struct ordered_map; + + /// @brief specialization that maintains the insertion order of object keys + /// @sa https://json.nlohmann.me/api/ordered_json/ + using ordered_json = basic_json; + + NLOHMANN_JSON_NAMESPACE_END #endif // INCLUDE_NLOHMANN_JSON_FWD_HPP_ -namespace nlohmann -{ -inline namespace json_v3_10_5 -{ +NLOHMANN_JSON_NAMESPACE_BEGIN /*! @brief detail namespace with internal helper functions @@ -3354,6 +3362,7 @@ implementations of some @ref basic_json methods, and meta-programming helpers. */ namespace detail { + ///////////// // helpers // ///////////// @@ -4006,8 +4015,7 @@ inline constexpr bool value_in_range_of(T val) } } // namespace detail -} // namespace json_v3_10_5 -} // namespace nlohmann +NLOHMANN_JSON_NAMESPACE_END // #include // __ _____ _____ _____ @@ -4024,15 +4032,14 @@ inline constexpr bool value_in_range_of(T val) #include // string #include // forward +// #include + // #include // #include -namespace nlohmann -{ -inline namespace json_v3_10_5 -{ +NLOHMANN_JSON_NAMESPACE_BEGIN namespace detail { @@ -4160,15 +4167,11 @@ inline OutStringType concat(Args && ... args) } } // namespace detail -} // namespace json_v3_10_5 -} // namespace nlohmann +NLOHMANN_JSON_NAMESPACE_END -namespace nlohmann -{ -inline namespace json_v3_10_5 -{ +NLOHMANN_JSON_NAMESPACE_BEGIN namespace detail { @@ -4397,8 +4400,7 @@ class other_error : public exception }; } // namespace detail -} // namespace json_v3_10_5 -} // namespace nlohmann +NLOHMANN_JSON_NAMESPACE_END // #include @@ -4415,17 +4417,18 @@ class other_error : public exception -namespace nlohmann -{ -inline namespace json_v3_10_5 -{ +// #include + + +NLOHMANN_JSON_NAMESPACE_BEGIN namespace detail { + // dispatching helper struct template struct identity_tag {}; + } // namespace detail -} // namespace json_v3_10_5 -} // namespace nlohmann +NLOHMANN_JSON_NAMESPACE_END // #include @@ -4436,36 +4439,26 @@ template struct identity_tag {}; #if JSON_HAS_EXPERIMENTAL_FILESYSTEM #include -namespace nlohmann -{ -inline namespace json_v3_10_5 -{ +NLOHMANN_JSON_NAMESPACE_BEGIN namespace detail { namespace std_fs = std::experimental::filesystem; } // namespace detail -} // namespace json_v3_10_5 -} // namespace nlohmann +NLOHMANN_JSON_NAMESPACE_END #elif JSON_HAS_FILESYSTEM #include -namespace nlohmann -{ -inline namespace json_v3_10_5 -{ +NLOHMANN_JSON_NAMESPACE_BEGIN namespace detail { namespace std_fs = std::filesystem; } // namespace detail -} // namespace json_v3_10_5 -} // namespace nlohmann +NLOHMANN_JSON_NAMESPACE_END #endif -namespace nlohmann -{ -inline namespace json_v3_10_5 -{ +NLOHMANN_JSON_NAMESPACE_BEGIN namespace detail { + template inline void from_json(const BasicJsonType& j, typename std::nullptr_t& n) { @@ -4911,6 +4904,7 @@ struct from_json_fn return from_json(j, std::forward(val)); } }; + } // namespace detail #ifndef JSON_HAS_CPP_17 @@ -4925,8 +4919,8 @@ JSON_INLINE_VARIABLE constexpr const auto& from_json = // NOLINT(misc-definition #ifndef JSON_HAS_CPP_17 } // namespace #endif -} // namespace json_v3_10_5 -} // namespace nlohmann + +NLOHMANN_JSON_NAMESPACE_END // #include // __ _____ _____ _____ @@ -4948,8 +4942,6 @@ JSON_INLINE_VARIABLE constexpr const auto& from_json = // NOLINT(misc-definition #include // valarray #include // vector -// #include - // #include // __ _____ _____ _____ // __| | __| | | | JSON for Modern C++ @@ -4971,17 +4963,17 @@ JSON_INLINE_VARIABLE constexpr const auto& from_json = // NOLINT(misc-definition #include // enable_borrowed_range #endif +// #include + // #include // #include -namespace nlohmann -{ -inline namespace json_v3_10_5 -{ +NLOHMANN_JSON_NAMESPACE_BEGIN namespace detail { + template void int_to_string( string_type& target, std::size_t value ) { @@ -5158,9 +5150,9 @@ auto get(const nlohmann::detail::iteration_proxy_value& i) -> decl { return i.value(); } + } // namespace detail -} // namespace json_v3_10_5 -} // namespace nlohmann +NLOHMANN_JSON_NAMESPACE_END // The Addition to the STD Namespace is required to add // Structured Bindings Support to the iteration_proxy_value class @@ -5168,6 +5160,7 @@ auto get(const nlohmann::detail::iteration_proxy_value& i) -> decl // And see https://github.com/nlohmann/json/pull/1391 namespace std { + #if defined(__clang__) // Fix: https://github.com/nlohmann/json/issues/1401 #pragma clang diagnostic push @@ -5188,6 +5181,7 @@ class tuple_element> #if defined(__clang__) #pragma clang diagnostic pop #endif + } // namespace std #if JSON_HAS_RANGES @@ -5195,6 +5189,8 @@ class tuple_element> inline constexpr bool ::std::ranges::enable_borrowed_range<::nlohmann::detail::iteration_proxy> = true; #endif +// #include + // #include // #include @@ -5204,36 +5200,26 @@ class tuple_element> #if JSON_HAS_EXPERIMENTAL_FILESYSTEM #include -namespace nlohmann -{ -inline namespace json_v3_10_5 -{ +NLOHMANN_JSON_NAMESPACE_BEGIN namespace detail { namespace std_fs = std::experimental::filesystem; } // namespace detail -} // namespace json_v3_10_5 -} // namespace nlohmann +NLOHMANN_JSON_NAMESPACE_END #elif JSON_HAS_FILESYSTEM #include -namespace nlohmann -{ -inline namespace json_v3_10_5 -{ +NLOHMANN_JSON_NAMESPACE_BEGIN namespace detail { namespace std_fs = std::filesystem; } // namespace detail -} // namespace json_v3_10_5 -} // namespace nlohmann +NLOHMANN_JSON_NAMESPACE_END #endif -namespace nlohmann -{ -inline namespace json_v3_10_5 -{ +NLOHMANN_JSON_NAMESPACE_BEGIN namespace detail { + ////////////////// // constructors // ////////////////// @@ -5642,18 +5628,17 @@ JSON_INLINE_VARIABLE constexpr const auto& to_json = // NOLINT(misc-definitions- #ifndef JSON_HAS_CPP_17 } // namespace #endif -} // namespace json_v3_10_5 -} // namespace nlohmann + +NLOHMANN_JSON_NAMESPACE_END + +// #include // #include // #include -namespace nlohmann -{ -inline namespace json_v3_10_5 -{ +NLOHMANN_JSON_NAMESPACE_BEGIN /// @sa https://json.nlohmann.me/api/adl_serializer/ template @@ -5689,8 +5674,8 @@ struct adl_serializer ::nlohmann::to_json(j, std::forward(val)); } }; -} // namespace json_v3_10_5 -} // namespace nlohmann + +NLOHMANN_JSON_NAMESPACE_END // #include // __ _____ _____ _____ @@ -5707,10 +5692,10 @@ struct adl_serializer #include // tie #include // move -namespace nlohmann -{ -inline namespace json_v3_10_5 -{ +// #include + + +NLOHMANN_JSON_NAMESPACE_BEGIN /// @brief an internal type for a backed binary type /// @sa https://json.nlohmann.me/api/byte_container_with_subtype/ @@ -5796,8 +5781,7 @@ class byte_container_with_subtype : public BinaryType bool m_has_subtype = false; }; -} // namespace json_v3_10_5 -} // namespace nlohmann +NLOHMANN_JSON_NAMESPACE_END // #include @@ -5825,10 +5809,7 @@ class byte_container_with_subtype : public BinaryType // #include -namespace nlohmann -{ -inline namespace json_v3_10_5 -{ +NLOHMANN_JSON_NAMESPACE_BEGIN namespace detail { @@ -5939,8 +5920,7 @@ std::size_t hash(const BasicJsonType& j) } } // namespace detail -} // namespace json_v3_10_5 -} // namespace nlohmann +NLOHMANN_JSON_NAMESPACE_END // #include // __ _____ _____ _____ @@ -6000,12 +5980,10 @@ std::size_t hash(const BasicJsonType& j) // #include -namespace nlohmann -{ -inline namespace json_v3_10_5 -{ +NLOHMANN_JSON_NAMESPACE_BEGIN namespace detail { + /// the supported input formats enum class input_format_t { json, cbor, msgpack, ubjson, bson, bjdata }; @@ -6465,9 +6443,9 @@ class span_input_adapter private: contiguous_bytes_input_adapter ia; }; + } // namespace detail -} // namespace json_v3_10_5 -} // namespace nlohmann +NLOHMANN_JSON_NAMESPACE_END // #include // __ _____ _____ _____ @@ -6492,10 +6470,7 @@ class span_input_adapter // #include -namespace nlohmann -{ -inline namespace json_v3_10_5 -{ +NLOHMANN_JSON_NAMESPACE_BEGIN /*! @brief SAX interface @@ -7201,10 +7176,9 @@ class json_sax_acceptor return false; } }; -} // namespace detail -} // namespace json_v3_10_5 -} // namespace nlohmann +} // namespace detail +NLOHMANN_JSON_NAMESPACE_END // #include // __ _____ _____ _____ @@ -7234,12 +7208,10 @@ class json_sax_acceptor // #include -namespace nlohmann -{ -inline namespace json_v3_10_5 -{ +NLOHMANN_JSON_NAMESPACE_BEGIN namespace detail { + /////////// // lexer // /////////// @@ -8841,9 +8813,9 @@ scan_number_done: /// the decimal point const char_int_type decimal_point_char = '.'; }; + } // namespace detail -} // namespace json_v3_10_5 -} // namespace nlohmann +NLOHMANN_JSON_NAMESPACE_END // #include @@ -8862,17 +8834,17 @@ scan_number_done: #include // declval #include // string +// #include + // #include // #include -namespace nlohmann -{ -inline namespace json_v3_10_5 -{ +NLOHMANN_JSON_NAMESPACE_BEGIN namespace detail { + template using null_function_t = decltype(std::declval().null()); @@ -9007,9 +8979,9 @@ struct is_sax_static_asserts "Missing/invalid function: bool parse_error(std::size_t, const " "std::string&, const exception&)"); }; + } // namespace detail -} // namespace json_v3_10_5 -} // namespace nlohmann +NLOHMANN_JSON_NAMESPACE_END // #include @@ -9018,10 +8990,7 @@ struct is_sax_static_asserts // #include -namespace nlohmann -{ -inline namespace json_v3_10_5 -{ +NLOHMANN_JSON_NAMESPACE_BEGIN namespace detail { @@ -11957,9 +11926,9 @@ class binary_reader /// the SAX parser json_sax_t* sax = nullptr; }; + } // namespace detail -} // namespace json_v3_10_5 -} // namespace nlohmann +NLOHMANN_JSON_NAMESPACE_END // #include @@ -12000,10 +11969,7 @@ class binary_reader // #include -namespace nlohmann -{ -inline namespace json_v3_10_5 -{ +NLOHMANN_JSON_NAMESPACE_BEGIN namespace detail { //////////// @@ -12483,8 +12449,7 @@ class parser }; } // namespace detail -} // namespace json_v3_10_5 -} // namespace nlohmann +NLOHMANN_JSON_NAMESPACE_END // #include // __ _____ _____ _____ @@ -12514,12 +12479,10 @@ class parser // #include -namespace nlohmann -{ -inline namespace json_v3_10_5 -{ +NLOHMANN_JSON_NAMESPACE_BEGIN namespace detail { + /* @brief an iterator for primitive JSON types @@ -12630,17 +12593,17 @@ class primitive_iterator_t return *this; } }; + } // namespace detail -} // namespace json_v3_10_5 -} // namespace nlohmann +NLOHMANN_JSON_NAMESPACE_END + +// #include -namespace nlohmann -{ -inline namespace json_v3_10_5 -{ +NLOHMANN_JSON_NAMESPACE_BEGIN namespace detail { + /*! @brief an iterator value @@ -12656,9 +12619,9 @@ template struct internal_iterator /// generic iterator for all other types primitive_iterator_t primitive_iterator {}; }; + } // namespace detail -} // namespace json_v3_10_5 -} // namespace nlohmann +NLOHMANN_JSON_NAMESPACE_END // #include // __ _____ _____ _____ @@ -12689,12 +12652,10 @@ template struct internal_iterator // #include -namespace nlohmann -{ -inline namespace json_v3_10_5 -{ +NLOHMANN_JSON_NAMESPACE_BEGIN namespace detail { + // forward declare, to be able to friend it later on template class iteration_proxy; template class iteration_proxy_value; @@ -13418,9 +13379,9 @@ class iter_impl // NOLINT(cppcoreguidelines-special-member-functions,hicpp-speci /// the actual iterator of the associated instance internal_iterator::type> m_it {}; }; + } // namespace detail -} // namespace json_v3_10_5 -} // namespace nlohmann +NLOHMANN_JSON_NAMESPACE_END // #include @@ -13439,12 +13400,13 @@ class iter_impl // NOLINT(cppcoreguidelines-special-member-functions,hicpp-speci #include // reverse_iterator #include // declval -namespace nlohmann -{ -inline namespace json_v3_10_5 -{ +// #include + + +NLOHMANN_JSON_NAMESPACE_BEGIN namespace detail { + ////////////////////// // reverse_iterator // ////////////////////// @@ -13552,9 +13514,9 @@ class json_reverse_iterator : public std::reverse_iterator return it.operator * (); } }; + } // namespace detail -} // namespace json_v3_10_5 -} // namespace nlohmann +NLOHMANN_JSON_NAMESPACE_END // #include @@ -13593,10 +13555,7 @@ class json_reverse_iterator : public std::reverse_iterator // #include -namespace nlohmann -{ -inline namespace json_v3_10_5 -{ +NLOHMANN_JSON_NAMESPACE_BEGIN /// @brief JSON Pointer defines a string syntax for identifying a specific value within a JSON document /// @sa https://json.nlohmann.me/api/json_pointer/ @@ -14465,8 +14424,8 @@ inline bool operator!=(json_pointer const& lhs, { return !(lhs == rhs); } -} // namespace json_v3_10_5 -} // namespace nlohmann + +NLOHMANN_JSON_NAMESPACE_END // #include // __ _____ _____ _____ @@ -14482,15 +14441,15 @@ inline bool operator!=(json_pointer const& lhs, #include #include +// #include + // #include -namespace nlohmann -{ -inline namespace json_v3_10_5 -{ +NLOHMANN_JSON_NAMESPACE_BEGIN namespace detail { + template class json_ref { @@ -14546,9 +14505,9 @@ class json_ref mutable value_type owned_value = nullptr; value_type const* value_ref = nullptr; }; + } // namespace detail -} // namespace json_v3_10_5 -} // namespace nlohmann +NLOHMANN_JSON_NAMESPACE_END // #include @@ -14612,12 +14571,10 @@ class json_ref // #include -namespace nlohmann -{ -inline namespace json_v3_10_5 -{ +NLOHMANN_JSON_NAMESPACE_BEGIN namespace detail { + /// abstract output adapter interface template struct output_adapter_protocol { @@ -14734,19 +14691,17 @@ class output_adapter private: output_adapter_t oa = nullptr; }; + } // namespace detail -} // namespace json_v3_10_5 -} // namespace nlohmann +NLOHMANN_JSON_NAMESPACE_END // #include -namespace nlohmann -{ -inline namespace json_v3_10_5 -{ +NLOHMANN_JSON_NAMESPACE_BEGIN namespace detail { + /////////////////// // binary writer // /////////////////// @@ -16552,9 +16507,9 @@ class binary_writer /// the output output_adapter_t oa = nullptr; }; + } // namespace detail -} // namespace json_v3_10_5 -} // namespace nlohmann +NLOHMANN_JSON_NAMESPACE_END // #include @@ -16605,10 +16560,7 @@ class binary_writer // #include -namespace nlohmann -{ -inline namespace json_v3_10_5 -{ +NLOHMANN_JSON_NAMESPACE_BEGIN namespace detail { @@ -17705,8 +17657,7 @@ char* to_chars(char* first, const char* last, FloatType value) } } // namespace detail -} // namespace json_v3_10_5 -} // namespace nlohmann +NLOHMANN_JSON_NAMESPACE_END // #include @@ -17723,12 +17674,10 @@ char* to_chars(char* first, const char* last, FloatType value) // #include -namespace nlohmann -{ -inline namespace json_v3_10_5 -{ +NLOHMANN_JSON_NAMESPACE_BEGIN namespace detail { + /////////////////// // serialization // /////////////////// @@ -18677,9 +18626,9 @@ class serializer /// error_handler how to react on decoding errors const error_handler_t error_handler; }; + } // namespace detail -} // namespace json_v3_10_5 -} // namespace nlohmann +NLOHMANN_JSON_NAMESPACE_END // #include @@ -18710,10 +18659,7 @@ class serializer // #include -namespace nlohmann -{ -inline namespace json_v3_10_5 -{ +NLOHMANN_JSON_NAMESPACE_BEGIN /// ordered_map: a minimal map-like container that preserves insertion order /// for use within nlohmann::basic_json @@ -19049,8 +18995,7 @@ private: JSON_NO_UNIQUE_ADDRESS key_compare m_compare = key_compare(); }; -} // namespace json_v3_10_5 -} // namespace nlohmann +NLOHMANN_JSON_NAMESPACE_END #if defined(JSON_HAS_CPP_17) @@ -19063,10 +19008,7 @@ private: @see https://github.com/nlohmann @since version 1.0.0 */ -namespace nlohmann -{ -inline namespace json_v3_10_5 -{ +NLOHMANN_JSON_NAMESPACE_BEGIN /*! @brief a class to store JSON values @@ -24068,8 +24010,7 @@ std::string to_string(const NLOHMANN_BASIC_JSON_TPL& j) return j.dump(); } -} // namespace json_v3_10_5 -} // namespace nlohmann +NLOHMANN_JSON_NAMESPACE_END /////////////////////// // nonmember support //