mirror of
https://github.com/nlohmann/json.git
synced 2026-10-06 06:30:31 +00:00
Keep the behavior-changing configuration readable after json.hpp
json.hpp undefines JSON_STRICT_NUL_HANDLING and JSON_USE_LEGACY_DISCARDED_VALUE_COMPARISON at its end. Code that builds on the library after it, such as the planned json_view.hpp, reads them from detail::abi_config instead. The constants live in the ABI namespace, which already encodes both settings, so they always match the basic_json in use. Signed-off-by: Niels Lohmann <mail@nlohmann.me>
This commit is contained in:
@@ -20,6 +20,7 @@ cc_library(
|
|||||||
hdrs = [
|
hdrs = [
|
||||||
"include/nlohmann/adl_serializer.hpp",
|
"include/nlohmann/adl_serializer.hpp",
|
||||||
"include/nlohmann/byte_container_with_subtype.hpp",
|
"include/nlohmann/byte_container_with_subtype.hpp",
|
||||||
|
"include/nlohmann/detail/abi_config.hpp",
|
||||||
"include/nlohmann/detail/abi_macros.hpp",
|
"include/nlohmann/detail/abi_macros.hpp",
|
||||||
"include/nlohmann/detail/bit_ops.hpp",
|
"include/nlohmann/detail/bit_ops.hpp",
|
||||||
"include/nlohmann/detail/conversions/from_json.hpp",
|
"include/nlohmann/detail/conversions/from_json.hpp",
|
||||||
|
|||||||
@@ -0,0 +1,34 @@
|
|||||||
|
// __ _____ _____ _____
|
||||||
|
// __| | __| | | | JSON for Modern C++
|
||||||
|
// | | |__ | | | | | | version 3.12.0
|
||||||
|
// |_____|_____|_____|_|___| https://github.com/nlohmann/json
|
||||||
|
//
|
||||||
|
// SPDX-FileCopyrightText: 2013-2026 Niels Lohmann <https://nlohmann.me>
|
||||||
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <nlohmann/detail/abi_macros.hpp>
|
||||||
|
|
||||||
|
NLOHMANN_JSON_NAMESPACE_BEGIN
|
||||||
|
namespace detail
|
||||||
|
{
|
||||||
|
|
||||||
|
/*!
|
||||||
|
@brief the configuration macros that change the library's behavior
|
||||||
|
|
||||||
|
json.hpp undefines these macros at its end (see macro_unscope.hpp), so code
|
||||||
|
that builds on the library after it (json_view.hpp) reads them here. Like the
|
||||||
|
macros, they are part of the ABI namespace, so they always match the
|
||||||
|
basic_json they are used with.
|
||||||
|
*/
|
||||||
|
struct abi_config
|
||||||
|
{
|
||||||
|
/// JSON_STRICT_NUL_HANDLING: a null byte is an error, not the end of input
|
||||||
|
static constexpr bool strict_nul_handling = JSON_STRICT_NUL_HANDLING != 0;
|
||||||
|
/// JSON_USE_LEGACY_DISCARDED_VALUE_COMPARISON
|
||||||
|
static constexpr bool legacy_discarded_value_comparison = JSON_USE_LEGACY_DISCARDED_VALUE_COMPARISON != 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace detail
|
||||||
|
NLOHMANN_JSON_NAMESPACE_END
|
||||||
@@ -45,6 +45,7 @@
|
|||||||
|
|
||||||
#include <nlohmann/adl_serializer.hpp>
|
#include <nlohmann/adl_serializer.hpp>
|
||||||
#include <nlohmann/byte_container_with_subtype.hpp>
|
#include <nlohmann/byte_container_with_subtype.hpp>
|
||||||
|
#include <nlohmann/detail/abi_config.hpp>
|
||||||
#include <nlohmann/detail/conversions/from_json.hpp>
|
#include <nlohmann/detail/conversions/from_json.hpp>
|
||||||
#include <nlohmann/detail/conversions/to_json.hpp>
|
#include <nlohmann/detail/conversions/to_json.hpp>
|
||||||
#include <nlohmann/detail/exceptions.hpp>
|
#include <nlohmann/detail/exceptions.hpp>
|
||||||
|
|||||||
@@ -7236,6 +7236,43 @@ class byte_container_with_subtype : public BinaryType
|
|||||||
|
|
||||||
NLOHMANN_JSON_NAMESPACE_END
|
NLOHMANN_JSON_NAMESPACE_END
|
||||||
|
|
||||||
|
// #include <nlohmann/detail/abi_config.hpp>
|
||||||
|
// __ _____ _____ _____
|
||||||
|
// __| | __| | | | JSON for Modern C++
|
||||||
|
// | | |__ | | | | | | version 3.12.0
|
||||||
|
// |_____|_____|_____|_|___| https://github.com/nlohmann/json
|
||||||
|
//
|
||||||
|
// SPDX-FileCopyrightText: 2013-2026 Niels Lohmann <https://nlohmann.me>
|
||||||
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// #include <nlohmann/detail/abi_macros.hpp>
|
||||||
|
|
||||||
|
|
||||||
|
NLOHMANN_JSON_NAMESPACE_BEGIN
|
||||||
|
namespace detail
|
||||||
|
{
|
||||||
|
|
||||||
|
/*!
|
||||||
|
@brief the configuration macros that change the library's behavior
|
||||||
|
|
||||||
|
json.hpp undefines these macros at its end (see macro_unscope.hpp), so code
|
||||||
|
that builds on the library after it (json_view.hpp) reads them here. Like the
|
||||||
|
macros, they are part of the ABI namespace, so they always match the
|
||||||
|
basic_json they are used with.
|
||||||
|
*/
|
||||||
|
struct abi_config
|
||||||
|
{
|
||||||
|
/// JSON_STRICT_NUL_HANDLING: a null byte is an error, not the end of input
|
||||||
|
static constexpr bool strict_nul_handling = JSON_STRICT_NUL_HANDLING != 0;
|
||||||
|
/// JSON_USE_LEGACY_DISCARDED_VALUE_COMPARISON
|
||||||
|
static constexpr bool legacy_discarded_value_comparison = JSON_USE_LEGACY_DISCARDED_VALUE_COMPARISON != 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace detail
|
||||||
|
NLOHMANN_JSON_NAMESPACE_END
|
||||||
|
|
||||||
// #include <nlohmann/detail/conversions/from_json.hpp>
|
// #include <nlohmann/detail/conversions/from_json.hpp>
|
||||||
|
|
||||||
// #include <nlohmann/detail/conversions/to_json.hpp>
|
// #include <nlohmann/detail/conversions/to_json.hpp>
|
||||||
|
|||||||
Reference in New Issue
Block a user