From 867621ee5a30766a0d55144f5c839131be480544 Mon Sep 17 00:00:00 2001 From: Florian Albrechtskirchinger Date: Mon, 9 May 2022 19:47:25 +0200 Subject: [PATCH] Export library configuration in JSON meta --- include/nlohmann/json.hpp | 78 ++++++++++++++++++++++++++++++++ single_include/nlohmann/json.hpp | 78 ++++++++++++++++++++++++++++++++ 2 files changed, 156 insertions(+) diff --git a/include/nlohmann/json.hpp b/include/nlohmann/json.hpp index 357815f7d..85b3974ec 100644 --- a/include/nlohmann/json.hpp +++ b/include/nlohmann/json.hpp @@ -304,6 +304,84 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec #else result["compiler"]["c++"] = "unknown"; #endif + + // NOLINTBEGIN(modernize-use-bool-literals) + + result["config"]["JSON_DIAGNOSTICS"] = + static_cast(JSON_DIAGNOSTICS); // NOLINT(modernize-use-bool-literals) + + result["config"]["JSON_DISABLE_ENUM_SERIALIZATION"] = + static_cast(JSON_DISABLE_ENUM_SERIALIZATION); + + result["config"]["JSON_HAS_CPP_11"] = +#ifdef JSON_HAS_CPP_11 + true; +#else + false; +#endif + + result["config"]["JSON_HAS_CPP_14"] = +#ifdef JSON_HAS_CPP_14 + true; +#else + false; +#endif + + result["config"]["JSON_HAS_CPP_17"] = +#ifdef JSON_HAS_CPP_17 + true; +#else + false; +#endif + + result["config"]["JSON_HAS_CPP_20"] = +#ifdef JSON_HAS_CPP_20 + true; +#else + false; +#endif + + result["config"]["JSON_HAS_CPP_23"] = +#ifdef JSON_HAS_CPP_23 + true; +#else + false; +#endif + + result["config"]["JSON_HAS_EXPERIMENTAL_FILESYSTEM"] = + static_cast(JSON_HAS_EXPERIMENTAL_FILESYSTEM); + + result["config"]["JSON_HAS_FILESYSTEM"] = + static_cast(JSON_HAS_FILESYSTEM); + + result["config"]["JSON_HAS_THREE_WAY_COMPARISON"] = + static_cast(JSON_HAS_THREE_WAY_COMPARISON); + + result["config"]["JSON_NOEXCEPTION"] = +#ifdef JSON_NOEXCEPTION + true; +#else + false; +#endif + + result["config"]["JSON_NO_IO"] = +#ifdef JSON_NO_IO + true; +#else + false; +#endif + + result["config"]["JSON_USE_IMPLICIT_CONVERSIONS"] = + static_cast(JSON_USE_IMPLICIT_CONVERSIONS); + + result["config"]["JSON_USE_LEGACY_DISCARDED_VALUE_COMPARISON"] = + static_cast(JSON_USE_LEGACY_DISCARDED_VALUE_COMPARISON); + + result["config"]["NLOHMANN_JSON_ABI_STRING"] = + JSON_HEDLEY_STRINGIFY(NLOHMANN_JSON_ABI_STRING); + + // NOLINTEND(modernize-use-bool-literals) + return result; } diff --git a/single_include/nlohmann/json.hpp b/single_include/nlohmann/json.hpp index 42694e559..0335565b9 100644 --- a/single_include/nlohmann/json.hpp +++ b/single_include/nlohmann/json.hpp @@ -19315,6 +19315,84 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec #else result["compiler"]["c++"] = "unknown"; #endif + + // NOLINTBEGIN(modernize-use-bool-literals) + + result["config"]["JSON_DIAGNOSTICS"] = + static_cast(JSON_DIAGNOSTICS); // NOLINT(modernize-use-bool-literals) + + result["config"]["JSON_DISABLE_ENUM_SERIALIZATION"] = + static_cast(JSON_DISABLE_ENUM_SERIALIZATION); + + result["config"]["JSON_HAS_CPP_11"] = +#ifdef JSON_HAS_CPP_11 + true; +#else + false; +#endif + + result["config"]["JSON_HAS_CPP_14"] = +#ifdef JSON_HAS_CPP_14 + true; +#else + false; +#endif + + result["config"]["JSON_HAS_CPP_17"] = +#ifdef JSON_HAS_CPP_17 + true; +#else + false; +#endif + + result["config"]["JSON_HAS_CPP_20"] = +#ifdef JSON_HAS_CPP_20 + true; +#else + false; +#endif + + result["config"]["JSON_HAS_CPP_23"] = +#ifdef JSON_HAS_CPP_23 + true; +#else + false; +#endif + + result["config"]["JSON_HAS_EXPERIMENTAL_FILESYSTEM"] = + static_cast(JSON_HAS_EXPERIMENTAL_FILESYSTEM); + + result["config"]["JSON_HAS_FILESYSTEM"] = + static_cast(JSON_HAS_FILESYSTEM); + + result["config"]["JSON_HAS_THREE_WAY_COMPARISON"] = + static_cast(JSON_HAS_THREE_WAY_COMPARISON); + + result["config"]["JSON_NOEXCEPTION"] = +#ifdef JSON_NOEXCEPTION + true; +#else + false; +#endif + + result["config"]["JSON_NO_IO"] = +#ifdef JSON_NO_IO + true; +#else + false; +#endif + + result["config"]["JSON_USE_IMPLICIT_CONVERSIONS"] = + static_cast(JSON_USE_IMPLICIT_CONVERSIONS); + + result["config"]["JSON_USE_LEGACY_DISCARDED_VALUE_COMPARISON"] = + static_cast(JSON_USE_LEGACY_DISCARDED_VALUE_COMPARISON); + + result["config"]["NLOHMANN_JSON_ABI_STRING"] = + JSON_HEDLEY_STRINGIFY(NLOHMANN_JSON_ABI_STRING); + + // NOLINTEND(modernize-use-bool-literals) + return result; }