Add versioned, ABI-tagged inline namespace and namespace macros (#3590)

* Add versioned inline namespace

Add a versioned inline namespace to prevent ABI issues when linking code
using multiple library versions.

* Add namespace macros

* Encode ABI information in inline namespace

Add _diag suffix to inline namespace if JSON_DIAGNOSTICS is enabled, and
_ldvcmp suffix if JSON_USE_LEGACY_DISCARDED_VALUE_COMPARISON is enabled.

* Move ABI-affecting macros into abi_macros.hpp

* Move std_fs namespace definition into std_fs.hpp

* Remove std_fs namespace from unit test

* Format more files in tests directory

* Add unit tests

* Update documentation

* Fix GDB pretty printer

* fixup! Add namespace macros

* Derive ABI prefix from NLOHMANN_JSON_VERSION_*
This commit is contained in:
Florian Albrechtskirchinger
2022-07-30 21:59:13 +02:00
committed by GitHub
parent fca1ddda96
commit d909f80960
72 changed files with 23116 additions and 561 deletions
+4 -5
View File
@@ -8,16 +8,14 @@
#pragma once
#include <type_traits>
#include <utility>
#include <nlohmann/detail/abi_macros.hpp>
#include <nlohmann/detail/conversions/from_json.hpp>
#include <nlohmann/detail/conversions/to_json.hpp>
#include <nlohmann/detail/meta/identity_tag.hpp>
#include <nlohmann/detail/meta/type_traits.hpp>
namespace nlohmann
{
NLOHMANN_JSON_NAMESPACE_BEGIN
/// @sa https://json.nlohmann.me/api/adl_serializer/
template<typename ValueType, typename>
@@ -53,4 +51,5 @@ struct adl_serializer
::nlohmann::to_json(j, std::forward<TargetType>(val));
}
};
} // namespace nlohmann
NLOHMANN_JSON_NAMESPACE_END
@@ -12,8 +12,9 @@
#include <tuple> // tie
#include <utility> // move
namespace nlohmann
{
#include <nlohmann/detail/abi_macros.hpp>
NLOHMANN_JSON_NAMESPACE_BEGIN
/// @brief an internal type for a backed binary type
/// @sa https://json.nlohmann.me/api/byte_container_with_subtype/
@@ -99,4 +100,4 @@ class byte_container_with_subtype : public BinaryType
bool m_has_subtype = false;
};
} // namespace nlohmann
NLOHMANN_JSON_NAMESPACE_END
+71
View File
@@ -0,0 +1,71 @@
#pragma once
// This file contains all macro definitions affecting or depending on the ABI
#ifndef JSON_SKIP_LIBRARY_VERSION_CHECK
#if defined(NLOHMANN_JSON_VERSION_MAJOR) && defined(NLOHMANN_JSON_VERSION_MINOR) && defined(NLOHMANN_JSON_VERSION_PATCH)
#if NLOHMANN_JSON_VERSION_MAJOR != 3 || NLOHMANN_JSON_VERSION_MINOR != 10 || NLOHMANN_JSON_VERSION_PATCH != 5
#warning "Already included a different version of the library!"
#endif
#endif
#endif
#define NLOHMANN_JSON_VERSION_MAJOR 3 // NOLINT(modernize-macro-to-enum)
#define NLOHMANN_JSON_VERSION_MINOR 10 // NOLINT(modernize-macro-to-enum)
#define NLOHMANN_JSON_VERSION_PATCH 5 // NOLINT(modernize-macro-to-enum)
#ifndef JSON_DIAGNOSTICS
#define JSON_DIAGNOSTICS 0
#endif
#ifndef JSON_USE_LEGACY_DISCARDED_VALUE_COMPARISON
#define JSON_USE_LEGACY_DISCARDED_VALUE_COMPARISON 0
#endif
#if JSON_DIAGNOSTICS
#define NLOHMANN_JSON_ABI_TAG_DIAGNOSTICS _diag
#else
#define NLOHMANN_JSON_ABI_TAG_DIAGNOSTICS
#endif
#if JSON_USE_LEGACY_DISCARDED_VALUE_COMPARISON
#define NLOHMANN_JSON_ABI_TAG_LEGACY_DISCARDED_VALUE_COMPARISON _ldvcmp
#else
#define NLOHMANN_JSON_ABI_TAG_LEGACY_DISCARDED_VALUE_COMPARISON
#endif
#define NLOHMANN_JSON_ABI_PREFIX_EX(major, minor, patch) \
json_v ## major ## _ ## minor ## _ ## patch
#define NLOHMANN_JSON_ABI_PREFIX(major, minor, patch) \
NLOHMANN_JSON_ABI_PREFIX_EX(major, minor, patch)
#define NLOHMANN_JSON_ABI_CONCAT_EX(a, b, c) a ## b ## c
#define NLOHMANN_JSON_ABI_CONCAT(a, b, c) \
NLOHMANN_JSON_ABI_CONCAT_EX(a, b, c)
#define NLOHMANN_JSON_ABI_STRING \
NLOHMANN_JSON_ABI_CONCAT( \
NLOHMANN_JSON_ABI_PREFIX( \
NLOHMANN_JSON_VERSION_MAJOR, \
NLOHMANN_JSON_VERSION_MINOR, \
NLOHMANN_JSON_VERSION_PATCH), \
NLOHMANN_JSON_ABI_TAG_DIAGNOSTICS, \
NLOHMANN_JSON_ABI_TAG_LEGACY_DISCARDED_VALUE_COMPARISON)
#ifndef NLOHMANN_JSON_NAMESPACE
#define NLOHMANN_JSON_NAMESPACE nlohmann::NLOHMANN_JSON_ABI_STRING
#endif
#ifndef NLOHMANN_JSON_NAMESPACE_BEGIN
#define NLOHMANN_JSON_NAMESPACE_BEGIN \
namespace nlohmann \
{ \
inline namespace NLOHMANN_JSON_ABI_STRING \
{
#endif
#ifndef NLOHMANN_JSON_NAMESPACE_END
#define NLOHMANN_JSON_NAMESPACE_END \
} /* namespace (abi_string) */ \
} /* namespace nlohmann */
#endif
@@ -24,28 +24,15 @@
#include <nlohmann/detail/macro_scope.hpp>
#include <nlohmann/detail/meta/cpp_future.hpp>
#include <nlohmann/detail/meta/identity_tag.hpp>
#include <nlohmann/detail/meta/std_fs.hpp>
#include <nlohmann/detail/meta/type_traits.hpp>
#include <nlohmann/detail/string_concat.hpp>
#include <nlohmann/detail/value_t.hpp>
#if JSON_HAS_EXPERIMENTAL_FILESYSTEM
#include <experimental/filesystem>
namespace nlohmann::detail
{
namespace std_fs = std::experimental::filesystem;
} // namespace nlohmann::detail
#elif JSON_HAS_FILESYSTEM
#include <filesystem>
namespace nlohmann::detail
{
namespace std_fs = std::filesystem;
} // namespace nlohmann::detail
#endif
namespace nlohmann
{
NLOHMANN_JSON_NAMESPACE_BEGIN
namespace detail
{
template<typename BasicJsonType>
inline void from_json(const BasicJsonType& j, typename std::nullptr_t& n)
{
@@ -491,6 +478,7 @@ struct from_json_fn
return from_json(j, std::forward<T>(val));
}
};
} // namespace detail
#ifndef JSON_HAS_CPP_17
@@ -503,6 +491,7 @@ namespace // NOLINT(cert-dcl59-cpp,fuchsia-header-anon-namespaces,google-build-n
JSON_INLINE_VARIABLE constexpr const auto& from_json = // NOLINT(misc-definitions-in-headers)
detail::static_const<detail::from_json_fn>::value;
#ifndef JSON_HAS_CPP_17
} // namespace
} // namespace
#endif
} // namespace nlohmann
NLOHMANN_JSON_NAMESPACE_END
@@ -18,8 +18,7 @@
#include <nlohmann/detail/macro_scope.hpp>
namespace nlohmann
{
NLOHMANN_JSON_NAMESPACE_BEGIN
namespace detail
{
@@ -1048,7 +1047,7 @@ inline char* format_buffer(char* buf, int len, int decimal_exponent,
return append_exponent(buf, n - 1);
}
} // namespace dtoa_impl
} // namespace dtoa_impl
/*!
@brief generates a decimal representation of the floating-point number value in [first, last).
@@ -1115,5 +1114,5 @@ char* to_chars(char* first, const char* last, FloatType value)
return dtoa_impl::format_buffer(first, len, decimal_exponent, kMinExp, kMaxExp);
}
} // namespace detail
} // namespace nlohmann
} // namespace detail
NLOHMANN_JSON_NAMESPACE_END
@@ -17,30 +17,17 @@
#include <valarray> // valarray
#include <vector> // vector
#include <nlohmann/detail/macro_scope.hpp>
#include <nlohmann/detail/iterators/iteration_proxy.hpp>
#include <nlohmann/detail/macro_scope.hpp>
#include <nlohmann/detail/meta/cpp_future.hpp>
#include <nlohmann/detail/meta/std_fs.hpp>
#include <nlohmann/detail/meta/type_traits.hpp>
#include <nlohmann/detail/value_t.hpp>
#if JSON_HAS_EXPERIMENTAL_FILESYSTEM
#include <experimental/filesystem>
namespace nlohmann::detail
{
namespace std_fs = std::experimental::filesystem;
} // namespace nlohmann::detail
#elif JSON_HAS_FILESYSTEM
#include <filesystem>
namespace nlohmann::detail
{
namespace std_fs = std::filesystem;
} // namespace nlohmann::detail
#endif
namespace nlohmann
{
NLOHMANN_JSON_NAMESPACE_BEGIN
namespace detail
{
//////////////////
// constructors //
//////////////////
@@ -447,6 +434,7 @@ namespace // NOLINT(cert-dcl59-cpp,fuchsia-header-anon-namespaces,google-build-n
JSON_INLINE_VARIABLE constexpr const auto& to_json = // NOLINT(misc-definitions-in-headers)
detail::static_const<detail::to_json_fn>::value;
#ifndef JSON_HAS_CPP_17
} // namespace
} // namespace
#endif
} // namespace nlohmann
NLOHMANN_JSON_NAMESPACE_END
+3 -3
View File
@@ -23,10 +23,10 @@
#include <nlohmann/detail/string_concat.hpp>
namespace nlohmann
{
NLOHMANN_JSON_NAMESPACE_BEGIN
namespace detail
{
////////////////
// exceptions //
////////////////
@@ -252,4 +252,4 @@ class other_error : public exception
};
} // namespace detail
} // namespace nlohmann
NLOHMANN_JSON_NAMESPACE_END
+3 -4
View File
@@ -12,11 +12,10 @@
#include <cstddef> // size_t
#include <functional> // hash
#include <nlohmann/detail/macro_scope.hpp>
#include <nlohmann/detail/abi_macros.hpp>
#include <nlohmann/detail/value_t.hpp>
namespace nlohmann
{
NLOHMANN_JSON_NAMESPACE_BEGIN
namespace detail
{
@@ -127,4 +126,4 @@ std::size_t hash(const BasicJsonType& j)
}
} // namespace detail
} // namespace nlohmann
NLOHMANN_JSON_NAMESPACE_END
@@ -32,8 +32,7 @@
#include <nlohmann/detail/string_concat.hpp>
#include <nlohmann/detail/value_t.hpp>
namespace nlohmann
{
NLOHMANN_JSON_NAMESPACE_BEGIN
namespace detail
{
@@ -2969,5 +2968,6 @@ class binary_reader
/// the SAX parser
json_sax_t* sax = nullptr;
};
} // namespace detail
} // namespace nlohmann
NLOHMANN_JSON_NAMESPACE_END
@@ -26,10 +26,10 @@
#include <nlohmann/detail/iterators/iterator_traits.hpp>
#include <nlohmann/detail/macro_scope.hpp>
namespace nlohmann
{
NLOHMANN_JSON_NAMESPACE_BEGIN
namespace detail
{
/// the supported input formats
enum class input_format_t { json, cbor, msgpack, ubjson, bson, bjdata };
@@ -410,7 +410,7 @@ struct container_input_adapter_factory< ContainerType,
}
};
} // namespace container_input_adapter_factory_impl
} // namespace container_input_adapter_factory_impl
template<typename ContainerType>
typename container_input_adapter_factory_impl::container_input_adapter_factory<ContainerType>::adapter_type input_adapter(const ContainerType& container)
@@ -489,5 +489,6 @@ class span_input_adapter
private:
contiguous_bytes_input_adapter ia;
};
} // namespace detail
} // namespace nlohmann
NLOHMANN_JSON_NAMESPACE_END
+3 -4
View File
@@ -17,8 +17,7 @@
#include <nlohmann/detail/macro_scope.hpp>
#include <nlohmann/detail/string_concat.hpp>
namespace nlohmann
{
NLOHMANN_JSON_NAMESPACE_BEGIN
/*!
@brief SAX interface
@@ -724,6 +723,6 @@ class json_sax_acceptor
return false;
}
};
} // namespace detail
} // namespace nlohmann
} // namespace detail
NLOHMANN_JSON_NAMESPACE_END
+4 -3
View File
@@ -22,10 +22,10 @@
#include <nlohmann/detail/input/position_t.hpp>
#include <nlohmann/detail/macro_scope.hpp>
namespace nlohmann
{
NLOHMANN_JSON_NAMESPACE_BEGIN
namespace detail
{
///////////
// lexer //
///////////
@@ -1627,5 +1627,6 @@ scan_number_done:
/// the decimal point
const char_int_type decimal_point_char = '.';
};
} // namespace detail
} // namespace nlohmann
NLOHMANN_JSON_NAMESPACE_END
+2 -3
View File
@@ -24,8 +24,7 @@
#include <nlohmann/detail/string_concat.hpp>
#include <nlohmann/detail/value_t.hpp>
namespace nlohmann
{
NLOHMANN_JSON_NAMESPACE_BEGIN
namespace detail
{
////////////
@@ -505,4 +504,4 @@ class parser
};
} // namespace detail
} // namespace nlohmann
NLOHMANN_JSON_NAMESPACE_END
+6 -4
View File
@@ -10,10 +10,12 @@
#include <cstddef> // size_t
namespace nlohmann
{
#include <nlohmann/detail/abi_macros.hpp>
NLOHMANN_JSON_NAMESPACE_BEGIN
namespace detail
{
/// struct to capture the start position of the current token
struct position_t
{
@@ -31,5 +33,5 @@ struct position_t
}
};
} // namespace detail
} // namespace nlohmann
} // namespace detail
NLOHMANN_JSON_NAMESPACE_END
@@ -8,12 +8,13 @@
#pragma once
#include <nlohmann/detail/abi_macros.hpp>
#include <nlohmann/detail/iterators/primitive_iterator.hpp>
namespace nlohmann
{
NLOHMANN_JSON_NAMESPACE_BEGIN
namespace detail
{
/*!
@brief an iterator value
@@ -29,5 +30,6 @@ template<typename BasicJsonType> struct internal_iterator
/// generic iterator for all other types
primitive_iterator_t primitive_iterator {};
};
} // namespace detail
} // namespace nlohmann
NLOHMANN_JSON_NAMESPACE_END
@@ -19,10 +19,10 @@
#include <nlohmann/detail/meta/type_traits.hpp>
#include <nlohmann/detail/value_t.hpp>
namespace nlohmann
{
NLOHMANN_JSON_NAMESPACE_BEGIN
namespace detail
{
// forward declare, to be able to friend it later on
template<typename IteratorType> class iteration_proxy;
template<typename IteratorType> class iteration_proxy_value;
@@ -746,5 +746,6 @@ class iter_impl // NOLINT(cppcoreguidelines-special-member-functions,hicpp-speci
/// the actual iterator of the associated instance
internal_iterator<typename std::remove_const<BasicJsonType>::type> m_it {};
};
} // namespace detail
} // namespace nlohmann
} // namespace detail
NLOHMANN_JSON_NAMESPACE_END
@@ -18,13 +18,14 @@
#include <ranges> // enable_borrowed_range
#endif
#include <nlohmann/detail/abi_macros.hpp>
#include <nlohmann/detail/meta/type_traits.hpp>
#include <nlohmann/detail/value_t.hpp>
namespace nlohmann
{
NLOHMANN_JSON_NAMESPACE_BEGIN
namespace detail
{
template<typename string_type>
void int_to_string( string_type& target, std::size_t value )
{
@@ -201,8 +202,9 @@ auto get(const nlohmann::detail::iteration_proxy_value<IteratorType>& i) -> decl
{
return i.value();
}
} // namespace detail
} // 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
@@ -210,6 +212,7 @@ auto get(const nlohmann::detail::iteration_proxy_value<IteratorType>& 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
@@ -230,7 +233,8 @@ class tuple_element<N, ::nlohmann::detail::iteration_proxy_value<IteratorType >>
#if defined(__clang__)
#pragma clang diagnostic pop
#endif
} // namespace std
} // namespace std
#if JSON_HAS_RANGES
template <typename IteratorType>
@@ -10,13 +10,14 @@
#include <iterator> // random_access_iterator_tag
#include <nlohmann/detail/abi_macros.hpp>
#include <nlohmann/detail/meta/void_t.hpp>
#include <nlohmann/detail/meta/cpp_future.hpp>
namespace nlohmann
{
NLOHMANN_JSON_NAMESPACE_BEGIN
namespace detail
{
template<typename It, typename = void>
struct iterator_types {};
@@ -55,5 +56,6 @@ struct iterator_traits<T*, enable_if_t<std::is_object<T>::value>>
using pointer = T*;
using reference = T&;
};
} // namespace detail
} // namespace nlohmann
} // namespace detail
NLOHMANN_JSON_NAMESPACE_END
@@ -12,10 +12,12 @@
#include <iterator> // reverse_iterator
#include <utility> // declval
namespace nlohmann
{
#include <nlohmann/detail/abi_macros.hpp>
NLOHMANN_JSON_NAMESPACE_BEGIN
namespace detail
{
//////////////////////
// reverse_iterator //
//////////////////////
@@ -123,5 +125,6 @@ class json_reverse_iterator : public std::reverse_iterator<Base>
return it.operator * ();
}
};
} // namespace detail
} // namespace nlohmann
NLOHMANN_JSON_NAMESPACE_END
@@ -13,10 +13,10 @@
#include <nlohmann/detail/macro_scope.hpp>
namespace nlohmann
{
NLOHMANN_JSON_NAMESPACE_BEGIN
namespace detail
{
/*
@brief an iterator for primitive JSON types
@@ -127,5 +127,6 @@ class primitive_iterator_t
return *this;
}
};
} // namespace detail
} // namespace nlohmann
NLOHMANN_JSON_NAMESPACE_END
+3 -3
View File
@@ -27,8 +27,7 @@
#include <nlohmann/detail/string_escape.hpp>
#include <nlohmann/detail/value_t.hpp>
namespace nlohmann
{
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/
@@ -897,4 +896,5 @@ inline bool operator!=(json_pointer<RefStringTypeLhs> const& lhs,
{
return !(lhs == rhs);
}
} // namespace nlohmann
NLOHMANN_JSON_NAMESPACE_END
+5 -3
View File
@@ -11,12 +11,13 @@
#include <initializer_list>
#include <utility>
#include <nlohmann/detail/abi_macros.hpp>
#include <nlohmann/detail/meta/type_traits.hpp>
namespace nlohmann
{
NLOHMANN_JSON_NAMESPACE_BEGIN
namespace detail
{
template<typename BasicJsonType>
class json_ref
{
@@ -72,5 +73,6 @@ class json_ref
mutable value_type owned_value = nullptr;
value_type const* value_ref = nullptr;
};
} // namespace detail
} // namespace nlohmann
NLOHMANN_JSON_NAMESPACE_END
+4 -10
View File
@@ -9,12 +9,14 @@
#pragma once
#include <utility> // declval, pair
#include <nlohmann/thirdparty/hedley/hedley.hpp>
#include <nlohmann/detail/meta/detected.hpp>
#include <nlohmann/thirdparty/hedley/hedley.hpp>
// This file contains all internal macro definitions
// This file contains all internal macro definitions (except those affecting ABI)
// You MUST include macro_unscope.hpp at the end of json.hpp to undef all of them
#include <nlohmann/detail/abi_macros.hpp>
// exclude unsupported compilers
#if !defined(JSON_SKIP_UNSUPPORTED_COMPILER_CHECK)
#if defined(__clang__)
@@ -457,14 +459,6 @@
#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
@@ -10,7 +10,8 @@
#include <nlohmann/detail/macro_scope.hpp>
namespace nlohmann
{
NLOHMANN_JSON_NAMESPACE_BEGIN
NLOHMANN_CAN_CALL_STD_FUNC_IMPL(begin);
} // namespace nlohmann
NLOHMANN_JSON_NAMESPACE_END
@@ -10,7 +10,8 @@
#include <nlohmann/detail/macro_scope.hpp>
namespace nlohmann
{
NLOHMANN_JSON_NAMESPACE_BEGIN
NLOHMANN_CAN_CALL_STD_FUNC_IMPL(end);
} // namespace nlohmann
NLOHMANN_JSON_NAMESPACE_END
+2 -3
View File
@@ -15,8 +15,7 @@
#include <nlohmann/detail/macro_scope.hpp>
namespace nlohmann
{
NLOHMANN_JSON_NAMESPACE_BEGIN
namespace detail
{
@@ -164,4 +163,4 @@ struct static_const
#endif
} // namespace detail
} // namespace nlohmann
NLOHMANN_JSON_NAMESPACE_END
+5 -4
View File
@@ -12,11 +12,11 @@
#include <nlohmann/detail/meta/void_t.hpp>
// https://en.cppreference.com/w/cpp/experimental/is_detected
namespace nlohmann
{
NLOHMANN_JSON_NAMESPACE_BEGIN
namespace detail
{
// https://en.cppreference.com/w/cpp/experimental/is_detected
struct nonesuch
{
nonesuch() = delete;
@@ -65,5 +65,6 @@ using is_detected_exact = std::is_same<Expected, detected_t<Op, Args...>>;
template<class To, template<class...> class Op, class... Args>
using is_detected_convertible =
std::is_convertible<detected_t<Op, Args...>, To>;
} // namespace detail
} // namespace nlohmann
NLOHMANN_JSON_NAMESPACE_END
@@ -8,11 +8,14 @@
#pragma once
namespace nlohmann
{
#include <nlohmann/detail/abi_macros.hpp>
NLOHMANN_JSON_NAMESPACE_BEGIN
namespace detail
{
// dispatching helper struct
template <class T> struct identity_tag {};
} // namespace detail
} // namespace nlohmann
NLOHMANN_JSON_NAMESPACE_END
+5 -3
View File
@@ -12,13 +12,14 @@
#include <utility> // declval
#include <string> // string
#include <nlohmann/detail/abi_macros.hpp>
#include <nlohmann/detail/meta/detected.hpp>
#include <nlohmann/detail/meta/type_traits.hpp>
namespace nlohmann
{
NLOHMANN_JSON_NAMESPACE_BEGIN
namespace detail
{
template<typename T>
using null_function_t = decltype(std::declval<T&>().null());
@@ -153,5 +154,6 @@ struct is_sax_static_asserts
"Missing/invalid function: bool parse_error(std::size_t, const "
"std::string&, const exception&)");
};
} // namespace detail
} // namespace nlohmann
NLOHMANN_JSON_NAMESPACE_END
+21
View File
@@ -0,0 +1,21 @@
#pragma once
#include <nlohmann/detail/macro_scope.hpp>
#if JSON_HAS_EXPERIMENTAL_FILESYSTEM
#include <experimental/filesystem>
NLOHMANN_JSON_NAMESPACE_BEGIN
namespace detail
{
namespace std_fs = std::experimental::filesystem;
} // namespace detail
NLOHMANN_JSON_NAMESPACE_END
#elif JSON_HAS_FILESYSTEM
#include <filesystem>
NLOHMANN_JSON_NAMESPACE_BEGIN
namespace detail
{
namespace std_fs = std::filesystem;
} // namespace detail
NLOHMANN_JSON_NAMESPACE_END
#endif
+4 -5
View File
@@ -13,17 +13,15 @@
#include <utility> // declval
#include <tuple> // tuple
#include <nlohmann/detail/macro_scope.hpp>
#include <nlohmann/detail/iterators/iterator_traits.hpp>
#include <nlohmann/detail/macro_scope.hpp>
#include <nlohmann/detail/meta/call_std/begin.hpp>
#include <nlohmann/detail/meta/call_std/end.hpp>
#include <nlohmann/detail/meta/cpp_future.hpp>
#include <nlohmann/detail/meta/detected.hpp>
#include <nlohmann/json_fwd.hpp>
namespace nlohmann
{
NLOHMANN_JSON_NAMESPACE_BEGIN
/*!
@brief detail namespace with internal helper functions
@@ -34,6 +32,7 @@ implementations of some @ref basic_json methods, and meta-programming helpers.
*/
namespace detail
{
/////////////
// helpers //
/////////////
@@ -686,4 +685,4 @@ inline constexpr bool value_in_range_of(T val)
}
} // namespace detail
} // namespace nlohmann
NLOHMANN_JSON_NAMESPACE_END
+7 -4
View File
@@ -8,14 +8,17 @@
#pragma once
namespace nlohmann
{
#include <nlohmann/detail/abi_macros.hpp>
NLOHMANN_JSON_NAMESPACE_BEGIN
namespace detail
{
template<typename ...Ts> struct make_void
{
using type = void;
};
template<typename ...Ts> using void_t = typename make_void<Ts...>::type;
} // namespace detail
} // namespace nlohmann
} // namespace detail
NLOHMANN_JSON_NAMESPACE_END
@@ -24,10 +24,10 @@
#include <nlohmann/detail/output/output_adapters.hpp>
#include <nlohmann/detail/string_concat.hpp>
namespace nlohmann
{
NLOHMANN_JSON_NAMESPACE_BEGIN
namespace detail
{
///////////////////
// binary writer //
///////////////////
@@ -1833,5 +1833,6 @@ class binary_writer
/// the output
output_adapter_t<CharType> oa = nullptr;
};
} // namespace detail
} // namespace nlohmann
NLOHMANN_JSON_NAMESPACE_END
@@ -22,10 +22,10 @@
#include <nlohmann/detail/macro_scope.hpp>
namespace nlohmann
{
NLOHMANN_JSON_NAMESPACE_BEGIN
namespace detail
{
/// abstract output adapter interface
template<typename CharType> struct output_adapter_protocol
{
@@ -142,5 +142,6 @@ class output_adapter
private:
output_adapter_t<CharType> oa = nullptr;
};
} // namespace detail
} // namespace nlohmann
NLOHMANN_JSON_NAMESPACE_END
@@ -31,10 +31,10 @@
#include <nlohmann/detail/string_concat.hpp>
#include <nlohmann/detail/value_t.hpp>
namespace nlohmann
{
NLOHMANN_JSON_NAMESPACE_BEGIN
namespace detail
{
///////////////////
// serialization //
///////////////////
@@ -983,5 +983,6 @@ class serializer
/// error_handler how to react on decoding errors
const error_handler_t error_handler;
};
} // namespace detail
} // namespace nlohmann
NLOHMANN_JSON_NAMESPACE_END
+3 -4
View File
@@ -15,8 +15,7 @@
#include <nlohmann/detail/meta/cpp_future.hpp>
#include <nlohmann/detail/meta/detected.hpp>
namespace nlohmann
{
NLOHMANN_JSON_NAMESPACE_BEGIN
namespace detail
{
@@ -143,5 +142,5 @@ inline OutStringType concat(Args && ... args)
return str;
}
} // namespace detail
} // namespace nlohmann
} // namespace detail
NLOHMANN_JSON_NAMESPACE_END
+4 -5
View File
@@ -8,10 +8,9 @@
#pragma once
#include <nlohmann/detail/macro_scope.hpp>
#include <nlohmann/detail/abi_macros.hpp>
namespace nlohmann
{
NLOHMANN_JSON_NAMESPACE_BEGIN
namespace detail
{
@@ -69,5 +68,5 @@ static void unescape(StringType& s)
replace_substring(s, StringType{"~0"}, StringType{"~"});
}
} // namespace detail
} // namespace nlohmann
} // namespace detail
NLOHMANN_JSON_NAMESPACE_END
+4 -3
View File
@@ -18,10 +18,10 @@
#include <compare> // partial_ordering
#endif
namespace nlohmann
{
NLOHMANN_JSON_NAMESPACE_BEGIN
namespace detail
{
///////////////////////////
// JSON type enumeration //
///////////////////////////
@@ -113,5 +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 nlohmann
NLOHMANN_JSON_NAMESPACE_END
+3 -16
View File
@@ -18,18 +18,6 @@
#ifndef INCLUDE_NLOHMANN_JSON_HPP_
#define INCLUDE_NLOHMANN_JSON_HPP_
#ifndef JSON_SKIP_LIBRARY_VERSION_CHECK
#if defined(NLOHMANN_JSON_VERSION_MAJOR) && defined(NLOHMANN_JSON_VERSION_MINOR) && defined(NLOHMANN_JSON_VERSION_PATCH)
#if NLOHMANN_JSON_VERSION_MAJOR != 3 || NLOHMANN_JSON_VERSION_MINOR != 10 || NLOHMANN_JSON_VERSION_PATCH != 5
#warning "Already included a different version of the library!"
#endif
#endif
#endif
#define NLOHMANN_JSON_VERSION_MAJOR 3 // NOLINT(modernize-macro-to-enum)
#define NLOHMANN_JSON_VERSION_MINOR 10 // NOLINT(modernize-macro-to-enum)
#define NLOHMANN_JSON_VERSION_PATCH 5 // NOLINT(modernize-macro-to-enum)
#include <algorithm> // all_of, find, for_each
#include <cstddef> // nullptr_t, ptrdiff_t, size_t
#include <functional> // hash, less
@@ -83,8 +71,7 @@
@see https://github.com/nlohmann
@since version 1.0.0
*/
namespace nlohmann
{
NLOHMANN_JSON_NAMESPACE_BEGIN
/*!
@brief a class to store JSON values
@@ -5087,7 +5074,7 @@ std::string to_string(const NLOHMANN_BASIC_JSON_TPL& j)
return j.dump();
}
} // namespace nlohmann
NLOHMANN_JSON_NAMESPACE_END
///////////////////////
// nonmember support //
@@ -5141,7 +5128,7 @@ inline void swap(nlohmann::NLOHMANN_BASIC_JSON_TPL& j1, nlohmann::NLOHMANN_BASIC
#endif
} // namespace std
} // namespace std
/// @brief user-defined string literal for JSON values
/// @sa https://json.nlohmann.me/api/basic_json/operator_literal_json/
+5 -3
View File
@@ -15,13 +15,15 @@
#include <string> // string
#include <vector> // vector
#include <nlohmann/detail/abi_macros.hpp>
/*!
@brief namespace for Niels Lohmann
@see https://github.com/nlohmann
@since version 1.0.0
*/
namespace nlohmann
{
NLOHMANN_JSON_NAMESPACE_BEGIN
/*!
@brief default JSONSerializer template argument
@@ -67,6 +69,6 @@ struct ordered_map;
/// @sa https://json.nlohmann.me/api/ordered_json/
using ordered_json = basic_json<nlohmann::ordered_map>;
} // namespace nlohmann
NLOHMANN_JSON_NAMESPACE_END
#endif // INCLUDE_NLOHMANN_JSON_FWD_HPP_
+2 -3
View File
@@ -20,8 +20,7 @@
#include <nlohmann/detail/macro_scope.hpp>
#include <nlohmann/detail/meta/type_traits.hpp>
namespace nlohmann
{
NLOHMANN_JSON_NAMESPACE_BEGIN
/// ordered_map: a minimal map-like container that preserves insertion order
/// for use within nlohmann::basic_json<ordered_map>
@@ -357,4 +356,4 @@ private:
JSON_NO_UNIQUE_ADDRESS key_compare m_compare = key_compare();
};
} // namespace nlohmann
NLOHMANN_JSON_NAMESPACE_END