From 2f44ac1def9899c6ac4b09e67fb313c36d172b96 Mon Sep 17 00:00:00 2001 From: onqtam Date: Sun, 13 Jan 2019 18:41:21 +0200 Subject: [PATCH 001/106] moved from Catch to doctest for unit tests --- .github/CONTRIBUTING.md | 2 +- Makefile | 2 - README.md | 2 +- test/CMakeLists.txt | 26 +- test/Makefile | 8 +- test/src/unit-algorithms.cpp | 2 +- test/src/unit-allocator.cpp | 25 +- test/src/unit-alt-string.cpp | 3 +- test/src/unit-bson.cpp | 18 +- test/src/unit-capacity.cpp | 2 +- test/src/unit-cbor.cpp | 29 +- test/src/unit-class_const_iterator.cpp | 3 +- test/src/unit-class_iterator.cpp | 3 +- test/src/unit-class_lexer.cpp | 3 +- test/src/unit-class_parser.cpp | 23 +- test/src/unit-comparison.cpp | 2 +- test/src/unit-concepts.cpp | 2 +- test/src/unit-constructor1.cpp | 4 +- test/src/unit-constructor2.cpp | 2 +- test/src/unit-convenience.cpp | 5 +- test/src/unit-conversions.cpp | 4 +- test/src/unit-deserialization.cpp | 3 +- test/src/unit-element_access1.cpp | 2 +- test/src/unit-element_access2.cpp | 6 +- test/src/unit-inspection.cpp | 6 +- test/src/unit-items.cpp | 2 +- test/src/unit-iterators1.cpp | 3 +- test/src/unit-iterators2.cpp | 2 +- test/src/unit-json_patch.cpp | 10 +- test/src/unit-json_pointer.cpp | 3 +- test/src/unit-merge_patch.cpp | 2 +- test/src/unit-meta.cpp | 2 +- test/src/unit-modifiers.cpp | 2 +- test/src/unit-msgpack.cpp | 17 +- test/src/unit-noexcept.cpp | 3 +- test/src/unit-pointer_access.cpp | 2 +- test/src/unit-readme.cpp | 7 +- test/src/unit-reference_access.cpp | 2 +- test/src/unit-regression.cpp | 22 +- test/src/unit-serialization.cpp | 5 +- test/src/unit-testsuites.cpp | 6 +- test/src/unit-to_chars.cpp | 2 +- test/src/unit-ubjson.cpp | 21 +- test/src/unit-udt.cpp | 17 +- test/src/unit-unicode.cpp | 10 +- test/src/unit-wstring.cpp | 3 +- test/src/unit.cpp | 4 +- test/thirdparty/catch/LICENSE_1_0.txt | 23 - test/thirdparty/catch/catch.hpp | 11689 ---------------- test/thirdparty/doctest/LICENSE.txt | 21 + test/thirdparty/doctest/doctest.h | 5269 +++++++ .../doctest/doctest_compatibility.h | 35 + 52 files changed, 5517 insertions(+), 11854 deletions(-) delete mode 100755 test/thirdparty/catch/LICENSE_1_0.txt delete mode 100644 test/thirdparty/catch/catch.hpp create mode 100644 test/thirdparty/doctest/LICENSE.txt create mode 100644 test/thirdparty/doctest/doctest.h create mode 100644 test/thirdparty/doctest/doctest_compatibility.h diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index 4ae0cb2d..f274b10d 100644 --- a/.github/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -32,7 +32,7 @@ To make changes, you need to edit the following files: 1. [`include/nlohmann/*`](https://github.com/nlohmann/json/tree/develop/include/nlohmann) - These files are the sources of the library. Before testing or creating a pull request, execute `make amalgamate` to regenerate `single_include/nlohmann/json.hpp`. -2. [`test/src/unit-*.cpp`](https://github.com/nlohmann/json/tree/develop/test/src) - These files contain the [Catch](https://github.com/philsquared/Catch) unit tests which currently cover [100 %](https://coveralls.io/github/nlohmann/json) of the library's code. +2. [`test/src/unit-*.cpp`](https://github.com/nlohmann/json/tree/develop/test/src) - These files contain the [doctest](https://github.com/onqtam/doctest) unit tests which currently cover [100 %](https://coveralls.io/github/nlohmann/json) of the library's code. If you add or change a feature, please also add a unit test to this file. The unit tests can be compiled and executed with diff --git a/Makefile b/Makefile index 297443a5..cb03ff80 100644 --- a/Makefile +++ b/Makefile @@ -113,7 +113,6 @@ doctest: # calling Clang with all warnings, except: # -Wno-documentation-unknown-command: code uses user-defined commands like @complexity -# -Wno-exit-time-destructors: warning in Catch code # -Wno-keyword-macro: unit-tests use "#define private public" # -Wno-deprecated-declarations: the library deprecated some functions # -Wno-weak-vtables: exception class is defined inline, but has virtual method @@ -128,7 +127,6 @@ pedantic_clang: -Werror \ -Weverything \ -Wno-documentation-unknown-command \ - -Wno-exit-time-destructors \ -Wno-keyword-macro \ -Wno-deprecated-declarations \ -Wno-weak-vtables \ diff --git a/README.md b/README.md index 7f041680..0c2bfca0 100644 --- a/README.md +++ b/README.md @@ -1240,13 +1240,13 @@ The library itself consists of a single header file licensed under the MIT licen - [**American fuzzy lop**](http://lcamtuf.coredump.cx/afl/) for fuzz testing - [**AppVeyor**](https://www.appveyor.com) for [continuous integration](https://ci.appveyor.com/project/nlohmann/json) on Windows - [**Artistic Style**](http://astyle.sourceforge.net) for automatic source code identation -- [**Catch**](https://github.com/philsquared/Catch) for the unit tests - [**Clang**](http://clang.llvm.org) for compilation with code sanitizers - [**CMake**](https://cmake.org) for build automation - [**Codacity**](https://www.codacy.com) for further [code analysis](https://www.codacy.com/app/nlohmann/json) - [**Coveralls**](https://coveralls.io) to measure [code coverage](https://coveralls.io/github/nlohmann/json) - [**Coverity Scan**](https://scan.coverity.com) for [static analysis](https://scan.coverity.com/projects/nlohmann-json) - [**cppcheck**](http://cppcheck.sourceforge.net) for static analysis +- [**doctest**](https://github.com/onqtam/doctest) for the unit tests - [**Doxygen**](http://www.stack.nl/~dimitri/doxygen/) to generate [documentation](https://nlohmann.github.io/json/) - [**git-update-ghpages**](https://github.com/rstacruz/git-update-ghpages) to upload the documentation to gh-pages - [**GitHub Changelog Generator**](https://github.com/skywinder/github-changelog-generator) to generate the [ChangeLog](https://github.com/nlohmann/json/blob/develop/ChangeLog.md) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 04acdaab..f314ea66 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -22,7 +22,7 @@ if(JSON_NoExceptions) if(NOT MSVC) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DJSON_NOEXCEPTION") endif() - set(CATCH_TEST_FILTER -e) + set(DOCTEST_TEST_FILTER --no-throw) endif() if(JSON_Coverage) @@ -54,18 +54,18 @@ if(JSON_Coverage) endif() ############################################################################# -# Catch library with the main function to speed up build +# doctest library with the main function to speed up build ############################################################################# -add_library(catch_main OBJECT +add_library(doctest_main OBJECT "src/unit.cpp" ) -set_target_properties(catch_main PROPERTIES +set_target_properties(doctest_main PROPERTIES COMPILE_DEFINITIONS "$<$:_SCL_SECURE_NO_WARNINGS>" COMPILE_OPTIONS "$<$:/EHsc;$<$:/Od>>" ) -target_compile_features(catch_main PUBLIC cxx_std_11) -target_include_directories(catch_main PRIVATE "thirdparty/catch") +target_compile_features(doctest_main PUBLIC cxx_std_11) +target_include_directories(doctest_main PRIVATE "thirdparty/doctest") # https://stackoverflow.com/questions/2368811/how-to-set-warning-level-in-cmake if(MSVC) @@ -95,10 +95,10 @@ foreach(file ${files}) get_filename_component(file_basename ${file} NAME_WE) string(REGEX REPLACE "unit-([^$]+)" "test-\\1" testcase ${file_basename}) - add_executable(${testcase} $ ${file}) + add_executable(${testcase} $ ${file}) target_compile_definitions(${testcase} PRIVATE - CATCH_CONFIG_FAST_COMPILE - $<$:_SCL_SECURE_NO_WARNINGS> + DOCTEST_CONFIG_SUPER_FAST_ASSERTS + DOCTEST_THREAD_LOCAL ) target_compile_options(${testcase} PRIVATE $<$:/EHsc;$<$:/Od>> @@ -106,26 +106,26 @@ foreach(file ${files}) $<$:-Wno-deprecated-declarations> ) target_include_directories(${testcase} PRIVATE - thirdparty/catch + thirdparty/doctest thirdparty/fifo_map ) target_link_libraries(${testcase} ${NLOHMANN_JSON_TARGET_NAME}) add_test(NAME "${testcase}_default" - COMMAND ${testcase} ${CATCH_TEST_FILTER} + COMMAND ${testcase} ${DOCTEST_TEST_FILTER} WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} ) set_tests_properties("${testcase}_default" PROPERTIES LABELS "default") add_test(NAME "${testcase}_all" - COMMAND ${testcase} ${CATCH_TEST_FILTER} "*" + COMMAND ${testcase} ${DOCTEST_TEST_FILTER} --no-skip WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} ) set_tests_properties("${testcase}_all" PROPERTIES LABELS "all") if(JSON_Valgrind) add_test(NAME "${testcase}_valgrind" - COMMAND ${memcheck_command} ${CMAKE_CURRENT_BINARY_DIR}/${testcase} ${CATCH_TEST_FILTER} + COMMAND ${memcheck_command} ${CMAKE_CURRENT_BINARY_DIR}/${testcase} ${DOCTEST_TEST_FILTER} WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} ) set_tests_properties("${testcase}_valgrind" PROPERTIES LABELS "valgrind") diff --git a/test/Makefile b/test/Makefile index 4f00cbc7..499ff3c2 100644 --- a/test/Makefile +++ b/test/Makefile @@ -4,7 +4,7 @@ # additional flags CXXFLAGS += -std=c++11 -Wall -Wextra -pedantic -Wcast-align -Wcast-qual -Wno-ctor-dtor-privacy -Wdisabled-optimization -Wformat=2 -Winit-self -Wmissing-declarations -Wmissing-include-dirs -Wold-style-cast -Woverloaded-virtual -Wredundant-decls -Wshadow -Wsign-conversion -Wsign-promo -Wstrict-overflow=5 -Wswitch -Wundef -Wno-unused -Wnon-virtual-dtor -Wreorder -Wdeprecated -Wno-float-equal -CPPFLAGS += -I ../single_include -I . -I thirdparty/catch -I thirdparty/fifo_map -DCATCH_CONFIG_FAST_COMPILE +CPPFLAGS += -I ../single_include -I . -I thirdparty/doctest -I thirdparty/fifo_map -DDOCTEST_CONFIG_SUPER_FAST_ASSERTS SOURCES = src/unit.cpp \ src/unit-algorithms.cpp \ @@ -63,11 +63,11 @@ clean: # single test file ############################################################################## -json_unit: $(OBJECTS) ../single_include/nlohmann/json.hpp thirdparty/catch/catch.hpp +json_unit: $(OBJECTS) ../single_include/nlohmann/json.hpp thirdparty/doctest/doctest.h @echo "[CXXLD] $@" @$(CXX) $(CXXFLAGS) $(LDFLAGS) $(OBJECTS) -o $@ -%.o: %.cpp ../single_include/nlohmann/json.hpp thirdparty/catch/catch.hpp +%.o: %.cpp ../single_include/nlohmann/json.hpp thirdparty/doctest/doctest.h @echo "[CXX] $@" @$(CXX) $(CXXFLAGS) $(CPPFLAGS) -c $< -o $@ @@ -76,7 +76,7 @@ json_unit: $(OBJECTS) ../single_include/nlohmann/json.hpp thirdparty/catch/catch # individual test cases ############################################################################## -test-%: src/unit-%.o src/unit.o ../single_include/nlohmann/json.hpp thirdparty/catch/catch.hpp +test-%: src/unit-%.o src/unit.o ../single_include/nlohmann/json.hpp thirdparty/doctest/doctest.h @echo "[CXXLD] $@" @$(CXX) $(CXXFLAGS) $(CPPFLAGS) $(LDFLAGS) $< src/unit.o -o $@ diff --git a/test/src/unit-algorithms.cpp b/test/src/unit-algorithms.cpp index 547d2294..adcf141f 100644 --- a/test/src/unit-algorithms.cpp +++ b/test/src/unit-algorithms.cpp @@ -27,7 +27,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#include "catch.hpp" +#include "doctest_compatibility.h" #include using nlohmann::json; diff --git a/test/src/unit-allocator.cpp b/test/src/unit-allocator.cpp index 06d56d5e..1d9de260 100644 --- a/test/src/unit-allocator.cpp +++ b/test/src/unit-allocator.cpp @@ -27,11 +27,12 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#include "catch.hpp" +#include "doctest_compatibility.h" #define private public #include using nlohmann::json; +#undef private // special test case to check if memory is leaked if constructor throws @@ -60,7 +61,7 @@ TEST_CASE("bad_alloc") bad_allocator>; // creating an object should throw - CHECK_THROWS_AS(bad_json(bad_json::value_t::object), std::bad_alloc&); + CHECK_THROWS_AS(auto tmp = bad_json(bad_json::value_t::object), std::bad_alloc&); } } @@ -144,7 +145,7 @@ TEST_CASE("controlled bad_alloc") auto t = my_json::value_t::object; CHECK_NOTHROW(my_allocator_clean_up(my_json::json_value(t).object)); next_construct_fails = true; - CHECK_THROWS_AS(my_json::json_value(t), std::bad_alloc&); + CHECK_THROWS_AS(auto tmp = my_json::json_value(t), std::bad_alloc&); next_construct_fails = false; } SECTION("array") @@ -153,7 +154,7 @@ TEST_CASE("controlled bad_alloc") auto t = my_json::value_t::array; CHECK_NOTHROW(my_allocator_clean_up(my_json::json_value(t).array)); next_construct_fails = true; - CHECK_THROWS_AS(my_json::json_value(t), std::bad_alloc&); + CHECK_THROWS_AS(auto tmp = my_json::json_value(t), std::bad_alloc&); next_construct_fails = false; } SECTION("string") @@ -162,7 +163,7 @@ TEST_CASE("controlled bad_alloc") auto t = my_json::value_t::string; CHECK_NOTHROW(my_allocator_clean_up(my_json::json_value(t).string)); next_construct_fails = true; - CHECK_THROWS_AS(my_json::json_value(t), std::bad_alloc&); + CHECK_THROWS_AS(auto tmp = my_json::json_value(t), std::bad_alloc&); next_construct_fails = false; } } @@ -173,7 +174,7 @@ TEST_CASE("controlled bad_alloc") my_json::string_t v("foo"); CHECK_NOTHROW(my_allocator_clean_up(my_json::json_value(v).string)); next_construct_fails = true; - CHECK_THROWS_AS(my_json::json_value(v), std::bad_alloc&); + CHECK_THROWS_AS(auto tmp = my_json::json_value(v), std::bad_alloc&); next_construct_fails = false; } } @@ -184,9 +185,9 @@ TEST_CASE("controlled bad_alloc") { next_construct_fails = false; std::map v {{"foo", "bar"}}; - CHECK_NOTHROW(my_json(v)); + CHECK_NOTHROW(auto tmp = my_json(v)); next_construct_fails = true; - CHECK_THROWS_AS(my_json(v), std::bad_alloc&); + CHECK_THROWS_AS(auto tmp = my_json(v), std::bad_alloc&); next_construct_fails = false; } @@ -194,9 +195,9 @@ TEST_CASE("controlled bad_alloc") { next_construct_fails = false; std::vector v {"foo", "bar", "baz"}; - CHECK_NOTHROW(my_json(v)); + CHECK_NOTHROW(auto tmp = my_json(v)); next_construct_fails = true; - CHECK_THROWS_AS(my_json(v), std::bad_alloc&); + CHECK_THROWS_AS(auto tmp = my_json(v), std::bad_alloc&); next_construct_fails = false; } @@ -213,9 +214,9 @@ TEST_CASE("controlled bad_alloc") { next_construct_fails = false; std::string s("foo"); - CHECK_NOTHROW(my_json(s)); + CHECK_NOTHROW(auto tmp = my_json(s)); next_construct_fails = true; - CHECK_THROWS_AS(my_json(s), std::bad_alloc&); + CHECK_THROWS_AS(auto tmp = my_json(s), std::bad_alloc&); next_construct_fails = false; } } diff --git a/test/src/unit-alt-string.cpp b/test/src/unit-alt-string.cpp index 9db580b4..23b40d89 100644 --- a/test/src/unit-alt-string.cpp +++ b/test/src/unit-alt-string.cpp @@ -27,9 +27,10 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#include "catch.hpp" +#include "doctest_compatibility.h" #include + #include #include diff --git a/test/src/unit-bson.cpp b/test/src/unit-bson.cpp index 7ae7db36..475f2755 100644 --- a/test/src/unit-bson.cpp +++ b/test/src/unit-bson.cpp @@ -27,11 +27,13 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#include "catch.hpp" +#include "doctest_compatibility.h" #include using nlohmann::json; + #include +#include TEST_CASE("BSON") { @@ -1138,7 +1140,7 @@ TEST_CASE("BSON numerical data") }; CHECK_THROWS_AS(json::to_bson(j), json::out_of_range&); - CHECK_THROWS_WITH(json::to_bson(j), "[json.exception.out_of_range.407] integer number " + std::to_string(i) + " cannot be represented by BSON as it does not fit int64"); + CHECK_THROWS_WITH_STD_STR(json::to_bson(j), "[json.exception.out_of_range.407] integer number " + std::to_string(i) + " cannot be represented by BSON as it does not fit int64"); } } @@ -1146,7 +1148,7 @@ TEST_CASE("BSON numerical data") } } -TEST_CASE("BSON roundtrips", "[hide]") +TEST_CASE("BSON roundtrips" * doctest::skip()) { SECTION("reference files") { @@ -1161,8 +1163,8 @@ TEST_CASE("BSON roundtrips", "[hide]") { CAPTURE(filename) - SECTION(filename + ": std::vector") { + INFO_WITH_TEMP(filename + ": std::vector"); // parse JSON file std::ifstream f_json(filename); json j1 = json::parse(f_json); @@ -1179,8 +1181,8 @@ TEST_CASE("BSON roundtrips", "[hide]") CHECK(j1 == j2); } - SECTION(filename + ": std::ifstream") { + INFO_WITH_TEMP(filename + ": std::ifstream"); // parse JSON file std::ifstream f_json(filename); json j1 = json::parse(f_json); @@ -1194,8 +1196,8 @@ TEST_CASE("BSON roundtrips", "[hide]") CHECK(j1 == j2); } - SECTION(filename + ": uint8_t* and size") { + INFO_WITH_TEMP(filename + ": uint8_t* and size"); // parse JSON file std::ifstream f_json(filename); json j1 = json::parse(f_json); @@ -1212,8 +1214,8 @@ TEST_CASE("BSON roundtrips", "[hide]") CHECK(j1 == j2); } - SECTION(filename + ": output to output adapters") { + INFO_WITH_TEMP(filename + ": output to output adapters"); // parse JSON file std::ifstream f_json(filename); json j1 = json::parse(f_json); @@ -1224,8 +1226,8 @@ TEST_CASE("BSON roundtrips", "[hide]") (std::istreambuf_iterator(f_bson)), std::istreambuf_iterator()); - SECTION(filename + ": output adapters: std::vector") { + INFO_WITH_TEMP(filename + ": output adapters: std::vector"); std::vector vec; json::to_bson(j1, vec); diff --git a/test/src/unit-capacity.cpp b/test/src/unit-capacity.cpp index a2332613..0ab187f9 100644 --- a/test/src/unit-capacity.cpp +++ b/test/src/unit-capacity.cpp @@ -27,7 +27,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#include "catch.hpp" +#include "doctest_compatibility.h" #include using nlohmann::json; diff --git a/test/src/unit-cbor.cpp b/test/src/unit-cbor.cpp index e96f4cd0..7cfdc383 100644 --- a/test/src/unit-cbor.cpp +++ b/test/src/unit-cbor.cpp @@ -27,12 +27,15 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#include "catch.hpp" +#include "doctest_compatibility.h" #include using nlohmann::json; #include +#include +#include +#include class SaxCountdown { @@ -1586,7 +1589,8 @@ TEST_CASE("single CBOR roundtrip") } } -TEST_CASE("CBOR regressions", "[!throws]") +#if not defined(JSON_NOEXCEPTION) +TEST_CASE("CBOR regressions") { SECTION("fuzz test results") { @@ -1655,12 +1659,13 @@ TEST_CASE("CBOR regressions", "[!throws]") } } } +#endif -TEST_CASE("CBOR roundtrips", "[hide]") +TEST_CASE("CBOR roundtrips" * doctest::skip()) { SECTION("input from flynn") { - // most of these are exluded due to differences in key order (not a real problem) + // most of these are excluded due to differences in key order (not a real problem) auto exclude_packed = std::set { "test/data/json.org/1.json", @@ -1827,8 +1832,8 @@ TEST_CASE("CBOR roundtrips", "[hide]") { CAPTURE(filename) - SECTION(filename + ": std::vector") { + INFO_WITH_TEMP(filename + ": std::vector"); // parse JSON file std::ifstream f_json(filename); json j1 = json::parse(f_json); @@ -1845,8 +1850,8 @@ TEST_CASE("CBOR roundtrips", "[hide]") CHECK(j1 == j2); } - SECTION(filename + ": std::ifstream") { + INFO_WITH_TEMP(filename + ": std::ifstream"); // parse JSON file std::ifstream f_json(filename); json j1 = json::parse(f_json); @@ -1860,8 +1865,8 @@ TEST_CASE("CBOR roundtrips", "[hide]") CHECK(j1 == j2); } - SECTION(filename + ": uint8_t* and size") { + INFO_WITH_TEMP(filename + ": uint8_t* and size"); // parse JSON file std::ifstream f_json(filename); json j1 = json::parse(f_json); @@ -1878,8 +1883,8 @@ TEST_CASE("CBOR roundtrips", "[hide]") CHECK(j1 == j2); } - SECTION(filename + ": output to output adapters") { + INFO_WITH_TEMP(filename + ": output to output adapters"); // parse JSON file std::ifstream f_json(filename); json j1 = json::parse(f_json); @@ -1892,8 +1897,8 @@ TEST_CASE("CBOR roundtrips", "[hide]") if (!exclude_packed.count(filename)) { - SECTION(filename + ": output adapters: std::vector") { + INFO_WITH_TEMP(filename + ": output adapters: std::vector"); std::vector vec; json::to_cbor(j1, vec); CHECK(vec == packed); @@ -1904,7 +1909,8 @@ TEST_CASE("CBOR roundtrips", "[hide]") } } -TEST_CASE("all CBOR first bytes", "[!throws]") +#if not defined(JSON_NOEXCEPTION) +TEST_CASE("all CBOR first bytes") { // these bytes will fail immediately with exception parse_error.112 std::set unsupported = @@ -1968,7 +1974,7 @@ TEST_CASE("all CBOR first bytes", "[!throws]") { // check that parse_error.112 is only thrown if the // first byte is in the unsupported set - CAPTURE(e.what()) + INFO_WITH_TEMP(e.what()); if (std::find(unsupported.begin(), unsupported.end(), byte) != unsupported.end()) { CHECK(e.id == 112); @@ -1980,6 +1986,7 @@ TEST_CASE("all CBOR first bytes", "[!throws]") } } } +#endif TEST_CASE("examples from RFC 7049 Appendix A") { diff --git a/test/src/unit-class_const_iterator.cpp b/test/src/unit-class_const_iterator.cpp index 40ce1dd5..caa2a001 100644 --- a/test/src/unit-class_const_iterator.cpp +++ b/test/src/unit-class_const_iterator.cpp @@ -27,11 +27,12 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#include "catch.hpp" +#include "doctest_compatibility.h" #define private public #include using nlohmann::json; +#undef private TEST_CASE("const_iterator class") { diff --git a/test/src/unit-class_iterator.cpp b/test/src/unit-class_iterator.cpp index b7d132e0..841aed3e 100644 --- a/test/src/unit-class_iterator.cpp +++ b/test/src/unit-class_iterator.cpp @@ -27,11 +27,12 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#include "catch.hpp" +#include "doctest_compatibility.h" #define private public #include using nlohmann::json; +#undef private TEST_CASE("iterator class") { diff --git a/test/src/unit-class_lexer.cpp b/test/src/unit-class_lexer.cpp index a2dff573..0200c86f 100644 --- a/test/src/unit-class_lexer.cpp +++ b/test/src/unit-class_lexer.cpp @@ -27,11 +27,12 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#include "catch.hpp" +#include "doctest_compatibility.h" #define private public #include using nlohmann::json; +#undef private // shortcut to scan a string literal json::lexer::token_type scan_string(const char* s); diff --git a/test/src/unit-class_parser.cpp b/test/src/unit-class_parser.cpp index 2d2929ee..b3fcef22 100644 --- a/test/src/unit-class_parser.cpp +++ b/test/src/unit-class_parser.cpp @@ -27,11 +27,12 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#include "catch.hpp" +#include "doctest_compatibility.h" #define private public #include using nlohmann::json; +#undef private #include @@ -1105,8 +1106,8 @@ TEST_CASE("parser class") // only check error message if c is not a control character if (c > 0x1f) { - CHECK_THROWS_WITH(parser_helper(s.c_str()), - "[json.exception.parse_error.101] parse error at line 1, column 3: syntax error while parsing value - invalid string: forbidden character after backslash; last read: '\"\\" + std::string(1, static_cast(c)) + "'"); + CHECK_THROWS_WITH_STD_STR(parser_helper(s.c_str()), + "[json.exception.parse_error.101] parse error at line 1, column 3: syntax error while parsing value - invalid string: forbidden character after backslash; last read: '\"\\" + std::string(1, static_cast(c)) + "'"); } break; } @@ -1181,8 +1182,8 @@ TEST_CASE("parser class") // only check error message if c is not a control character if (c > 0x1f) { - CHECK_THROWS_WITH(parser_helper(s1.c_str()), - "[json.exception.parse_error.101] parse error at line 1, column 7: syntax error while parsing value - invalid string: '\\u' must be followed by 4 hex digits; last read: '" + s1.substr(0, 7) + "'"); + CHECK_THROWS_WITH_STD_STR(parser_helper(s1.c_str()), + "[json.exception.parse_error.101] parse error at line 1, column 7: syntax error while parsing value - invalid string: '\\u' must be followed by 4 hex digits; last read: '" + s1.substr(0, 7) + "'"); } CAPTURE(s2) @@ -1190,8 +1191,8 @@ TEST_CASE("parser class") // only check error message if c is not a control character if (c > 0x1f) { - CHECK_THROWS_WITH(parser_helper(s2.c_str()), - "[json.exception.parse_error.101] parse error at line 1, column 6: syntax error while parsing value - invalid string: '\\u' must be followed by 4 hex digits; last read: '" + s2.substr(0, 6) + "'"); + CHECK_THROWS_WITH_STD_STR(parser_helper(s2.c_str()), + "[json.exception.parse_error.101] parse error at line 1, column 6: syntax error while parsing value - invalid string: '\\u' must be followed by 4 hex digits; last read: '" + s2.substr(0, 6) + "'"); } CAPTURE(s3) @@ -1199,8 +1200,8 @@ TEST_CASE("parser class") // only check error message if c is not a control character if (c > 0x1f) { - CHECK_THROWS_WITH(parser_helper(s3.c_str()), - "[json.exception.parse_error.101] parse error at line 1, column 5: syntax error while parsing value - invalid string: '\\u' must be followed by 4 hex digits; last read: '" + s3.substr(0, 5) + "'"); + CHECK_THROWS_WITH_STD_STR(parser_helper(s3.c_str()), + "[json.exception.parse_error.101] parse error at line 1, column 5: syntax error while parsing value - invalid string: '\\u' must be followed by 4 hex digits; last read: '" + s3.substr(0, 5) + "'"); } CAPTURE(s4) @@ -1208,8 +1209,8 @@ TEST_CASE("parser class") // only check error message if c is not a control character if (c > 0x1f) { - CHECK_THROWS_WITH(parser_helper(s4.c_str()), - "[json.exception.parse_error.101] parse error at line 1, column 4: syntax error while parsing value - invalid string: '\\u' must be followed by 4 hex digits; last read: '" + s4.substr(0, 4) + "'"); + CHECK_THROWS_WITH_STD_STR(parser_helper(s4.c_str()), + "[json.exception.parse_error.101] parse error at line 1, column 4: syntax error while parsing value - invalid string: '\\u' must be followed by 4 hex digits; last read: '" + s4.substr(0, 4) + "'"); } } } diff --git a/test/src/unit-comparison.cpp b/test/src/unit-comparison.cpp index e729d1f2..d030cea8 100644 --- a/test/src/unit-comparison.cpp +++ b/test/src/unit-comparison.cpp @@ -27,7 +27,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#include "catch.hpp" +#include "doctest_compatibility.h" #include using nlohmann::json; diff --git a/test/src/unit-concepts.cpp b/test/src/unit-concepts.cpp index 870ef52f..c73af279 100644 --- a/test/src/unit-concepts.cpp +++ b/test/src/unit-concepts.cpp @@ -27,7 +27,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#include "catch.hpp" +#include "doctest_compatibility.h" #include using nlohmann::json; diff --git a/test/src/unit-constructor1.cpp b/test/src/unit-constructor1.cpp index 205daeb3..65e50c5a 100644 --- a/test/src/unit-constructor1.cpp +++ b/test/src/unit-constructor1.cpp @@ -27,16 +27,18 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#include "catch.hpp" +#include "doctest_compatibility.h" #define private public #include using nlohmann::json; +#undef private #include #include #include #include +#include #include #include #include diff --git a/test/src/unit-constructor2.cpp b/test/src/unit-constructor2.cpp index 809b4551..39316ed0 100644 --- a/test/src/unit-constructor2.cpp +++ b/test/src/unit-constructor2.cpp @@ -27,7 +27,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#include "catch.hpp" +#include "doctest_compatibility.h" #include using nlohmann::json; diff --git a/test/src/unit-convenience.cpp b/test/src/unit-convenience.cpp index dda515f2..ea55338f 100644 --- a/test/src/unit-convenience.cpp +++ b/test/src/unit-convenience.cpp @@ -27,11 +27,14 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#include "catch.hpp" +#include "doctest_compatibility.h" #define private public #include using nlohmann::json; +#undef private + +#include void check_escaped(const char* original, const char* escaped = "", const bool ensure_ascii = false); void check_escaped(const char* original, const char* escaped, const bool ensure_ascii) diff --git a/test/src/unit-conversions.cpp b/test/src/unit-conversions.cpp index 368cb4f5..8dba9465 100644 --- a/test/src/unit-conversions.cpp +++ b/test/src/unit-conversions.cpp @@ -27,15 +27,17 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#include "catch.hpp" +#include "doctest_compatibility.h" #define private public #include using nlohmann::json; +#undef private #include #include #include +#include #include #include #include diff --git a/test/src/unit-deserialization.cpp b/test/src/unit-deserialization.cpp index f92241ff..b8163f73 100644 --- a/test/src/unit-deserialization.cpp +++ b/test/src/unit-deserialization.cpp @@ -27,12 +27,13 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#include "catch.hpp" +#include "doctest_compatibility.h" #include using nlohmann::json; #include +#include #include struct SaxEventLogger : public nlohmann::json_sax diff --git a/test/src/unit-element_access1.cpp b/test/src/unit-element_access1.cpp index 171feef4..59df62ea 100644 --- a/test/src/unit-element_access1.cpp +++ b/test/src/unit-element_access1.cpp @@ -27,7 +27,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#include "catch.hpp" +#include "doctest_compatibility.h" #include using nlohmann::json; diff --git a/test/src/unit-element_access2.cpp b/test/src/unit-element_access2.cpp index 52a30073..78958dfa 100644 --- a/test/src/unit-element_access2.cpp +++ b/test/src/unit-element_access2.cpp @@ -27,7 +27,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#include "catch.hpp" +#include "doctest_compatibility.h" #include using nlohmann::json; @@ -985,7 +985,8 @@ TEST_CASE("element access 2") } } -TEST_CASE("element access 2 (throwing tests)", "[!throws]") +#if not defined(JSON_NOEXCEPTION) +TEST_CASE("element access 2 (throwing tests)") { SECTION("object") { @@ -1018,3 +1019,4 @@ TEST_CASE("element access 2 (throwing tests)", "[!throws]") } } } +#endif diff --git a/test/src/unit-inspection.cpp b/test/src/unit-inspection.cpp index a529f098..1a31cff2 100644 --- a/test/src/unit-inspection.cpp +++ b/test/src/unit-inspection.cpp @@ -27,12 +27,14 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#include "catch.hpp" +#include "doctest_compatibility.h" -#include #include using nlohmann::json; +#include +#include + TEST_CASE("object inspection") { SECTION("convenience type checker") diff --git a/test/src/unit-items.cpp b/test/src/unit-items.cpp index c2f43cd4..9d77e5c9 100644 --- a/test/src/unit-items.cpp +++ b/test/src/unit-items.cpp @@ -27,7 +27,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#include "catch.hpp" +#include "doctest_compatibility.h" #include using nlohmann::json; diff --git a/test/src/unit-iterators1.cpp b/test/src/unit-iterators1.cpp index 1923cf60..d825e728 100644 --- a/test/src/unit-iterators1.cpp +++ b/test/src/unit-iterators1.cpp @@ -27,11 +27,12 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#include "catch.hpp" +#include "doctest_compatibility.h" #define private public #include using nlohmann::json; +#undef private TEST_CASE("iterators 1") { diff --git a/test/src/unit-iterators2.cpp b/test/src/unit-iterators2.cpp index e6536389..1f3cb9f9 100644 --- a/test/src/unit-iterators2.cpp +++ b/test/src/unit-iterators2.cpp @@ -27,7 +27,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#include "catch.hpp" +#include "doctest_compatibility.h" #include using nlohmann::json; diff --git a/test/src/unit-json_patch.cpp b/test/src/unit-json_patch.cpp index b72f1148..a24f1db5 100644 --- a/test/src/unit-json_patch.cpp +++ b/test/src/unit-json_patch.cpp @@ -27,7 +27,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#include "catch.hpp" +#include "doctest_compatibility.h" #include using nlohmann::json; @@ -342,7 +342,7 @@ TEST_CASE("JSON patch") // check that evaluation throws CHECK_THROWS_AS(doc.patch(patch), json::other_error&); - CHECK_THROWS_WITH(doc.patch(patch), "[json.exception.other_error.501] unsuccessful: " + patch[0].dump()); + CHECK_THROWS_WITH_STD_STR(doc.patch(patch), "[json.exception.other_error.501] unsuccessful: " + patch[0].dump()); } SECTION("A.10. Adding a Nested Member Object") @@ -483,7 +483,7 @@ TEST_CASE("JSON patch") // check that evaluation throws CHECK_THROWS_AS(doc.patch(patch), json::other_error&); - CHECK_THROWS_WITH(doc.patch(patch), "[json.exception.other_error.501] unsuccessful: " + patch[0].dump()); + CHECK_THROWS_WITH_STD_STR(doc.patch(patch), "[json.exception.other_error.501] unsuccessful: " + patch[0].dump()); } SECTION("A.16. Adding an Array Value") @@ -1182,7 +1182,7 @@ TEST_CASE("JSON patch") // the test will fail CHECK_THROWS_AS(doc.patch(patch), json::other_error&); - CHECK_THROWS_WITH(doc.patch(patch), "[json.exception.other_error.501] unsuccessful: " + patch[0].dump()); + CHECK_THROWS_WITH_STD_STR(doc.patch(patch), "[json.exception.other_error.501] unsuccessful: " + patch[0].dump()); } } } @@ -1268,7 +1268,7 @@ TEST_CASE("JSON patch") for (const auto& test : suite) { - CAPTURE(test.value("comment", "")) + INFO_WITH_TEMP(test.value("comment", "")); // skip tests marked as disabled if (test.value("disabled", false)) diff --git a/test/src/unit-json_pointer.cpp b/test/src/unit-json_pointer.cpp index ac9cd71e..2f5ac4fd 100644 --- a/test/src/unit-json_pointer.cpp +++ b/test/src/unit-json_pointer.cpp @@ -27,11 +27,12 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#include "catch.hpp" +#include "doctest_compatibility.h" #define private public #include using nlohmann::json; +#undef private TEST_CASE("JSON pointers") { diff --git a/test/src/unit-merge_patch.cpp b/test/src/unit-merge_patch.cpp index 901d3568..3a557c6d 100644 --- a/test/src/unit-merge_patch.cpp +++ b/test/src/unit-merge_patch.cpp @@ -27,7 +27,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#include "catch.hpp" +#include "doctest_compatibility.h" #include using nlohmann::json; diff --git a/test/src/unit-meta.cpp b/test/src/unit-meta.cpp index 46f2a9aa..28eee10b 100644 --- a/test/src/unit-meta.cpp +++ b/test/src/unit-meta.cpp @@ -27,7 +27,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#include "catch.hpp" +#include "doctest_compatibility.h" #include using nlohmann::json; diff --git a/test/src/unit-modifiers.cpp b/test/src/unit-modifiers.cpp index 9e53deab..57867237 100644 --- a/test/src/unit-modifiers.cpp +++ b/test/src/unit-modifiers.cpp @@ -27,7 +27,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#include "catch.hpp" +#include "doctest_compatibility.h" #include using nlohmann::json; diff --git a/test/src/unit-msgpack.cpp b/test/src/unit-msgpack.cpp index 544ed224..2d6a6974 100644 --- a/test/src/unit-msgpack.cpp +++ b/test/src/unit-msgpack.cpp @@ -27,12 +27,15 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#include "catch.hpp" +#include "doctest_compatibility.h" #include using nlohmann::json; #include +#include +#include +#include class SaxCountdown { @@ -1345,7 +1348,7 @@ TEST_CASE("single MessagePack roundtrip") } -TEST_CASE("MessagePack roundtrips", "[hide]") +TEST_CASE("MessagePack roundtrips" * doctest::skip()) { SECTION("input from msgpack-python") { @@ -1519,8 +1522,8 @@ TEST_CASE("MessagePack roundtrips", "[hide]") { CAPTURE(filename) - SECTION(filename + ": std::vector") { + INFO_WITH_TEMP(filename + ": std::vector"); // parse JSON file std::ifstream f_json(filename); json j1 = json::parse(f_json); @@ -1537,8 +1540,8 @@ TEST_CASE("MessagePack roundtrips", "[hide]") CHECK(j1 == j2); } - SECTION(filename + ": std::ifstream") { + INFO_WITH_TEMP(filename + ": std::ifstream"); // parse JSON file std::ifstream f_json(filename); json j1 = json::parse(f_json); @@ -1552,8 +1555,8 @@ TEST_CASE("MessagePack roundtrips", "[hide]") CHECK(j1 == j2); } - SECTION(filename + ": uint8_t* and size") { + INFO_WITH_TEMP(filename + ": uint8_t* and size"); // parse JSON file std::ifstream f_json(filename); json j1 = json::parse(f_json); @@ -1570,8 +1573,8 @@ TEST_CASE("MessagePack roundtrips", "[hide]") CHECK(j1 == j2); } - SECTION(filename + ": output to output adapters") { + INFO_WITH_TEMP(filename + ": output to output adapters"); // parse JSON file std::ifstream f_json(filename); json j1 = json::parse(f_json); @@ -1584,8 +1587,8 @@ TEST_CASE("MessagePack roundtrips", "[hide]") if (!exclude_packed.count(filename)) { - SECTION(filename + ": output adapters: std::vector") { + INFO_WITH_TEMP(filename + ": output adapters: std::vector"); std::vector vec; json::to_msgpack(j1, vec); CHECK(vec == packed); diff --git a/test/src/unit-noexcept.cpp b/test/src/unit-noexcept.cpp index 3e1e544d..0aeda12a 100644 --- a/test/src/unit-noexcept.cpp +++ b/test/src/unit-noexcept.cpp @@ -27,7 +27,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#include "catch.hpp" +#include "doctest_compatibility.h" + #include using nlohmann::json; diff --git a/test/src/unit-pointer_access.cpp b/test/src/unit-pointer_access.cpp index ab409282..81025aec 100644 --- a/test/src/unit-pointer_access.cpp +++ b/test/src/unit-pointer_access.cpp @@ -27,7 +27,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#include "catch.hpp" +#include "doctest_compatibility.h" #include using nlohmann::json; diff --git a/test/src/unit-readme.cpp b/test/src/unit-readme.cpp index 280a834e..ffddaf36 100644 --- a/test/src/unit-readme.cpp +++ b/test/src/unit-readme.cpp @@ -27,7 +27,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#include "catch.hpp" +#include "doctest_compatibility.h" #include using nlohmann::json; @@ -35,16 +35,19 @@ using nlohmann::json; #include #include #include +#include #include #include #include +#include +#include #if defined(_MSC_VER) #pragma warning (push) #pragma warning (disable : 4189) // local variable is initialized but not referenced #endif -TEST_CASE("README", "[hide]") +TEST_CASE("README" * doctest::skip()) { { // redirect std::cout for the README file diff --git a/test/src/unit-reference_access.cpp b/test/src/unit-reference_access.cpp index bc54ef52..907ed033 100644 --- a/test/src/unit-reference_access.cpp +++ b/test/src/unit-reference_access.cpp @@ -27,7 +27,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#include "catch.hpp" +#include "doctest_compatibility.h" #include using nlohmann::json; diff --git a/test/src/unit-regression.cpp b/test/src/unit-regression.cpp index e739e3c3..b157537e 100644 --- a/test/src/unit-regression.cpp +++ b/test/src/unit-regression.cpp @@ -27,11 +27,20 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#include "catch.hpp" +#include "doctest_compatibility.h" + +// for some reason including this after the json header leads to linker errors with VS 2017... +#include #define private public #include using nlohmann::json; +#undef private + +#include +#include +#include +#include #if (defined(__cplusplus) && __cplusplus >= 201703L) || (defined(_HAS_CXX17) && _HAS_CXX17 == 1) // fix for issue #464 #define JSON_HAS_CPP_17 @@ -43,10 +52,6 @@ using nlohmann::json; #include "fifo_map.hpp" -#include -#include -#include - ///////////////////////////////////////////////////////////////////// // for #972 ///////////////////////////////////////////////////////////////////// @@ -295,8 +300,7 @@ TEST_CASE("regression tests") nlohmann::basic_json; custom_json j; j["int_1"] = 1; - // we need to cast to int to compile with Catch - the value is int32_t - CHECK(static_cast(j["int_1"]) == 1); + CHECK(j["int_1"] == 1); // tests for correct handling of non-standard integers that overflow the type selected by the user @@ -1710,7 +1714,8 @@ TEST_CASE("regression tests") } } -TEST_CASE("regression tests, exceptions dependent", "[!throws]") +#if not defined(JSON_NOEXCEPTION) +TEST_CASE("regression tests, exceptions dependent") { SECTION("issue #1340 - eof not set on exhausted input stream") { @@ -1722,3 +1727,4 @@ TEST_CASE("regression tests, exceptions dependent", "[!throws]") CHECK(s.eof()); } } +#endif diff --git a/test/src/unit-serialization.cpp b/test/src/unit-serialization.cpp index 51ee9b57..ce7fd8de 100644 --- a/test/src/unit-serialization.cpp +++ b/test/src/unit-serialization.cpp @@ -27,11 +27,14 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#include "catch.hpp" +#include "doctest_compatibility.h" #include using nlohmann::json; +#include +#include + TEST_CASE("serialization") { SECTION("operator<<") diff --git a/test/src/unit-testsuites.cpp b/test/src/unit-testsuites.cpp index f930c974..aecc21e0 100644 --- a/test/src/unit-testsuites.cpp +++ b/test/src/unit-testsuites.cpp @@ -27,7 +27,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#include "catch.hpp" +#include "doctest_compatibility.h" #include using nlohmann::json; @@ -457,7 +457,7 @@ TEST_CASE("RFC 7159 examples") } )"; - CHECK_NOTHROW(json(json_contents)); + CHECK_NOTHROW(auto tmp = json(json_contents)); } { @@ -484,7 +484,7 @@ TEST_CASE("RFC 7159 examples") "Country": "US" } ])"; - CHECK_NOTHROW(json(json_contents)); + CHECK_NOTHROW(auto tmp = json(json_contents)); } CHECK(json::parse("\"Hello world!\"") == json("Hello world!")); diff --git a/test/src/unit-to_chars.cpp b/test/src/unit-to_chars.cpp index a8c7492c..17f1ead0 100644 --- a/test/src/unit-to_chars.cpp +++ b/test/src/unit-to_chars.cpp @@ -31,7 +31,7 @@ SOFTWARE. // Only compile these tests if 'float' and 'double' are IEEE-754 single- and // double-precision numbers, resp. -#include "catch.hpp" +#include "doctest_compatibility.h" #include using nlohmann::detail::dtoa_impl::reinterpret_bits; diff --git a/test/src/unit-ubjson.cpp b/test/src/unit-ubjson.cpp index 6279a5d3..1e42a7af 100644 --- a/test/src/unit-ubjson.cpp +++ b/test/src/unit-ubjson.cpp @@ -27,12 +27,13 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#include "catch.hpp" +#include "doctest_compatibility.h" #include using nlohmann::json; #include +#include class SaxCountdown { @@ -2113,7 +2114,8 @@ TEST_CASE("Universal Binary JSON Specification Examples 1") } } -TEST_CASE("all UBJSON first bytes", "[!throws]") +#if not defined(JSON_NOEXCEPTION) +TEST_CASE("all UBJSON first bytes") { // these bytes will fail immediately with exception parse_error.112 std::set supported = @@ -2134,7 +2136,7 @@ TEST_CASE("all UBJSON first bytes", "[!throws]") { // check that parse_error.112 is only thrown if the // first byte is not in the supported set - CAPTURE(e.what()) + INFO_WITH_TEMP(e.what()); if (std::find(supported.begin(), supported.end(), byte) == supported.end()) { CHECK(e.id == 112); @@ -2146,8 +2148,9 @@ TEST_CASE("all UBJSON first bytes", "[!throws]") } } } +#endif -TEST_CASE("UBJSON roundtrips", "[hide]") +TEST_CASE("UBJSON roundtrips" * doctest::skip()) { SECTION("input from self-generated UBJSON files") { @@ -2199,8 +2202,8 @@ TEST_CASE("UBJSON roundtrips", "[hide]") { CAPTURE(filename) - SECTION(filename + ": std::vector") { + INFO_WITH_TEMP(filename + ": std::vector"); // parse JSON file std::ifstream f_json(filename); json j1 = json::parse(f_json); @@ -2217,8 +2220,8 @@ TEST_CASE("UBJSON roundtrips", "[hide]") CHECK(j1 == j2); } - SECTION(filename + ": std::ifstream") { + INFO_WITH_TEMP(filename + ": std::ifstream"); // parse JSON file std::ifstream f_json(filename); json j1 = json::parse(f_json); @@ -2232,8 +2235,8 @@ TEST_CASE("UBJSON roundtrips", "[hide]") CHECK(j1 == j2); } - SECTION(filename + ": uint8_t* and size") { + INFO_WITH_TEMP(filename + ": uint8_t* and size"); // parse JSON file std::ifstream f_json(filename); json j1 = json::parse(f_json); @@ -2250,8 +2253,8 @@ TEST_CASE("UBJSON roundtrips", "[hide]") CHECK(j1 == j2); } - SECTION(filename + ": output to output adapters") { + INFO_WITH_TEMP(filename + ": output to output adapters"); // parse JSON file std::ifstream f_json(filename); json j1 = json::parse(f_json); @@ -2262,8 +2265,8 @@ TEST_CASE("UBJSON roundtrips", "[hide]") (std::istreambuf_iterator(f_ubjson)), std::istreambuf_iterator()); - SECTION(filename + ": output adapters: std::vector") { + INFO_WITH_TEMP(filename + ": output adapters: std::vector"); std::vector vec; json::to_ubjson(j1, vec); CHECK(vec == packed); diff --git a/test/src/unit-udt.cpp b/test/src/unit-udt.cpp index 833a4c71..bb4b3ab3 100644 --- a/test/src/unit-udt.cpp +++ b/test/src/unit-udt.cpp @@ -27,10 +27,9 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#include "catch.hpp" +#include "doctest_compatibility.h" #include - using nlohmann::json; #include @@ -236,7 +235,7 @@ void from_json(const nlohmann::json& j, contact_book& cb) } } -TEST_CASE("basic usage", "[udt]") +TEST_CASE("basic usage" * doctest::test_suite("udt")) { // a bit narcissic maybe :) ? @@ -392,7 +391,7 @@ struct adl_serializer }; } -TEST_CASE("adl_serializer specialization", "[udt]") +TEST_CASE("adl_serializer specialization" * doctest::test_suite("udt")) { SECTION("partial specialization") { @@ -468,7 +467,7 @@ struct adl_serializer> }; } -TEST_CASE("even supported types can be specialized", "[udt]") +TEST_CASE("even supported types can be specialized" * doctest::test_suite("udt")) { json j = std::vector {1.0, 2.0, 3.0}; CHECK(j.dump() == R"("hijacked!")"); @@ -509,7 +508,7 @@ struct adl_serializer> }; } -TEST_CASE("Non-copyable types", "[udt]") +TEST_CASE("Non-copyable types" * doctest::test_suite("udt")) { SECTION("to_json") { @@ -651,7 +650,7 @@ std::ostream& operator<<(std::ostream& os, small_pod l) } } -TEST_CASE("custom serializer for pods", "[udt]") +TEST_CASE("custom serializer for pods" * doctest::test_suite("udt")) { using custom_json = nlohmann::basic_json struct is_constructible_patched())))> : std::true_type {}; } -TEST_CASE("an incomplete type does not trigger a compiler error in non-evaluated context", "[udt]") +TEST_CASE("an incomplete type does not trigger a compiler error in non-evaluated context" * doctest::test_suite("udt")) { static_assert(not is_constructible_patched::value, ""); } diff --git a/test/src/unit-unicode.cpp b/test/src/unit-unicode.cpp index 57c3c505..aaa3b585 100644 --- a/test/src/unit-unicode.cpp +++ b/test/src/unit-unicode.cpp @@ -27,14 +27,20 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#include "catch.hpp" +#include "doctest_compatibility.h" + +// for some reason including this after the json header leads to linker errors with VS 2017... +#include #define private public #include using nlohmann::json; +#undef private #include +#include #include +#include extern size_t calls; size_t calls = 0; @@ -160,7 +166,7 @@ void check_utf8string(bool success_expected, int byte1, int byte2 = -1, int byte } } -TEST_CASE("Unicode", "[hide]") +TEST_CASE("Unicode" * doctest::skip()) { SECTION("RFC 3629") { diff --git a/test/src/unit-wstring.cpp b/test/src/unit-wstring.cpp index 8434b199..32bc4a98 100644 --- a/test/src/unit-wstring.cpp +++ b/test/src/unit-wstring.cpp @@ -27,10 +27,9 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#include "catch.hpp" +#include "doctest_compatibility.h" #include - using nlohmann::json; bool wstring_is_utf16(); diff --git a/test/src/unit.cpp b/test/src/unit.cpp index 8ea7e2e8..7bad90d7 100644 --- a/test/src/unit.cpp +++ b/test/src/unit.cpp @@ -27,5 +27,5 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#define CATCH_CONFIG_MAIN -#include "catch.hpp" +#define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN +#include "doctest_compatibility.h" diff --git a/test/thirdparty/catch/LICENSE_1_0.txt b/test/thirdparty/catch/LICENSE_1_0.txt deleted file mode 100755 index 36b7cd93..00000000 --- a/test/thirdparty/catch/LICENSE_1_0.txt +++ /dev/null @@ -1,23 +0,0 @@ -Boost Software License - Version 1.0 - August 17th, 2003 - -Permission is hereby granted, free of charge, to any person or organization -obtaining a copy of the software and accompanying documentation covered by -this license (the "Software") to use, reproduce, display, distribute, -execute, and transmit the Software, and to prepare derivative works of the -Software, and to permit third-parties to whom the Software is furnished to -do so, all subject to the following: - -The copyright notices in the Software and this entire statement, including -the above license grant, this restriction and the following disclaimer, -must be included in all copies of the Software, in whole or in part, and -all derivative works of the Software, unless such copies or derivative -works are solely in the form of machine-executable object code generated by -a source language processor. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT -SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE -FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, -ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -DEALINGS IN THE SOFTWARE. diff --git a/test/thirdparty/catch/catch.hpp b/test/thirdparty/catch/catch.hpp deleted file mode 100644 index fdb046fe..00000000 --- a/test/thirdparty/catch/catch.hpp +++ /dev/null @@ -1,11689 +0,0 @@ -/* - * Catch v1.12.2 - * Generated: 2018-05-14 15:10:01.112442 - * ---------------------------------------------------------- - * This file has been merged from multiple headers. Please don't edit it directly - * Copyright (c) 2012 Two Blue Cubes Ltd. All rights reserved. - * - * Distributed under the Boost Software License, Version 1.0. (See accompanying - * file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - */ -#ifndef TWOBLUECUBES_SINGLE_INCLUDE_CATCH_HPP_INCLUDED -#define TWOBLUECUBES_SINGLE_INCLUDE_CATCH_HPP_INCLUDED - -#define TWOBLUECUBES_CATCH_HPP_INCLUDED - -#ifdef __clang__ -# pragma clang system_header -#elif defined __GNUC__ -# pragma GCC system_header -#endif - -// #included from: internal/catch_suppress_warnings.h - -#ifdef __clang__ -# ifdef __ICC // icpc defines the __clang__ macro -# pragma warning(push) -# pragma warning(disable: 161 1682) -# else // __ICC -# pragma clang diagnostic ignored "-Wglobal-constructors" -# pragma clang diagnostic ignored "-Wvariadic-macros" -# pragma clang diagnostic ignored "-Wc99-extensions" -# pragma clang diagnostic ignored "-Wunused-variable" -# pragma clang diagnostic push -# pragma clang diagnostic ignored "-Wpadded" -# pragma clang diagnostic ignored "-Wc++98-compat" -# pragma clang diagnostic ignored "-Wc++98-compat-pedantic" -# pragma clang diagnostic ignored "-Wswitch-enum" -# pragma clang diagnostic ignored "-Wcovered-switch-default" -# endif -#elif defined __GNUC__ -# pragma GCC diagnostic ignored "-Wvariadic-macros" -# pragma GCC diagnostic ignored "-Wunused-variable" -# pragma GCC diagnostic ignored "-Wparentheses" - -# pragma GCC diagnostic push -# pragma GCC diagnostic ignored "-Wpadded" -#endif -#if defined(CATCH_CONFIG_MAIN) || defined(CATCH_CONFIG_RUNNER) -# define CATCH_IMPL -#endif - -#ifdef CATCH_IMPL -# ifndef CLARA_CONFIG_MAIN -# define CLARA_CONFIG_MAIN_NOT_DEFINED -# define CLARA_CONFIG_MAIN -# endif -#endif - -// #included from: internal/catch_notimplemented_exception.h -#define TWOBLUECUBES_CATCH_NOTIMPLEMENTED_EXCEPTION_H_INCLUDED - -// #included from: catch_common.h -#define TWOBLUECUBES_CATCH_COMMON_H_INCLUDED - -// #included from: catch_compiler_capabilities.h -#define TWOBLUECUBES_CATCH_COMPILER_CAPABILITIES_HPP_INCLUDED - -// Detect a number of compiler features - mostly C++11/14 conformance - by compiler -// The following features are defined: -// -// CATCH_CONFIG_CPP11_NULLPTR : is nullptr supported? -// CATCH_CONFIG_CPP11_NOEXCEPT : is noexcept supported? -// CATCH_CONFIG_CPP11_GENERATED_METHODS : The delete and default keywords for compiler generated methods -// CATCH_CONFIG_CPP11_IS_ENUM : std::is_enum is supported? -// CATCH_CONFIG_CPP11_TUPLE : std::tuple is supported -// CATCH_CONFIG_CPP11_LONG_LONG : is long long supported? -// CATCH_CONFIG_CPP11_OVERRIDE : is override supported? -// CATCH_CONFIG_CPP11_UNIQUE_PTR : is unique_ptr supported (otherwise use auto_ptr) -// CATCH_CONFIG_CPP11_SHUFFLE : is std::shuffle supported? -// CATCH_CONFIG_CPP11_TYPE_TRAITS : are type_traits and enable_if supported? - -// CATCH_CONFIG_CPP11_OR_GREATER : Is C++11 supported? - -// CATCH_CONFIG_VARIADIC_MACROS : are variadic macros supported? -// CATCH_CONFIG_COUNTER : is the __COUNTER__ macro supported? -// CATCH_CONFIG_WINDOWS_SEH : is Windows SEH supported? -// CATCH_CONFIG_POSIX_SIGNALS : are POSIX signals supported? -// **************** -// Note to maintainers: if new toggles are added please document them -// in configuration.md, too -// **************** - -// In general each macro has a _NO_ form -// (e.g. CATCH_CONFIG_CPP11_NO_NULLPTR) which disables the feature. -// Many features, at point of detection, define an _INTERNAL_ macro, so they -// can be combined, en-mass, with the _NO_ forms later. - -// All the C++11 features can be disabled with CATCH_CONFIG_NO_CPP11 - -#ifdef __cplusplus - -# if __cplusplus >= 201103L -# define CATCH_CPP11_OR_GREATER -# endif - -# if __cplusplus >= 201402L -# define CATCH_CPP14_OR_GREATER -# endif - -#endif - -#ifdef __clang__ - -# if __has_feature(cxx_nullptr) -# define CATCH_INTERNAL_CONFIG_CPP11_NULLPTR -# endif - -# if __has_feature(cxx_noexcept) -# define CATCH_INTERNAL_CONFIG_CPP11_NOEXCEPT -# endif - -# if defined(CATCH_CPP11_OR_GREATER) -# define CATCH_INTERNAL_SUPPRESS_ETD_WARNINGS \ - _Pragma( "clang diagnostic push" ) \ - _Pragma( "clang diagnostic ignored \"-Wexit-time-destructors\"" ) -# define CATCH_INTERNAL_UNSUPPRESS_ETD_WARNINGS \ - _Pragma( "clang diagnostic pop" ) - -# define CATCH_INTERNAL_SUPPRESS_PARENTHESES_WARNINGS \ - _Pragma( "clang diagnostic push" ) \ - _Pragma( "clang diagnostic ignored \"-Wparentheses\"" ) -# define CATCH_INTERNAL_UNSUPPRESS_PARENTHESES_WARNINGS \ - _Pragma( "clang diagnostic pop" ) -# endif - -#endif // __clang__ - -//////////////////////////////////////////////////////////////////////////////// -// We know some environments not to support full POSIX signals -#if defined(__CYGWIN__) || defined(__QNX__) - -# if !defined(CATCH_CONFIG_POSIX_SIGNALS) -# define CATCH_INTERNAL_CONFIG_NO_POSIX_SIGNALS -# endif - -#endif - -#ifdef __OS400__ -# define CATCH_INTERNAL_CONFIG_NO_POSIX_SIGNALS -# define CATCH_CONFIG_COLOUR_NONE -#endif - -//////////////////////////////////////////////////////////////////////////////// -// Cygwin -#ifdef __CYGWIN__ - -// Required for some versions of Cygwin to declare gettimeofday -// see: http://stackoverflow.com/questions/36901803/gettimeofday-not-declared-in-this-scope-cygwin -# define _BSD_SOURCE - -#endif // __CYGWIN__ - -//////////////////////////////////////////////////////////////////////////////// -// Borland -#ifdef __BORLANDC__ - -#endif // __BORLANDC__ - -//////////////////////////////////////////////////////////////////////////////// -// EDG -#ifdef __EDG_VERSION__ - -#endif // __EDG_VERSION__ - -//////////////////////////////////////////////////////////////////////////////// -// Digital Mars -#ifdef __DMC__ - -#endif // __DMC__ - -//////////////////////////////////////////////////////////////////////////////// -// GCC -#ifdef __GNUC__ - -# if __GNUC__ == 4 && __GNUC_MINOR__ >= 6 && defined(__GXX_EXPERIMENTAL_CXX0X__) -# define CATCH_INTERNAL_CONFIG_CPP11_NULLPTR -# endif - -// - otherwise more recent versions define __cplusplus >= 201103L -// and will get picked up below - -#endif // __GNUC__ - -//////////////////////////////////////////////////////////////////////////////// -// Visual C++ -#ifdef _MSC_VER - -#define CATCH_INTERNAL_CONFIG_WINDOWS_SEH - -#if (_MSC_VER >= 1600) -# define CATCH_INTERNAL_CONFIG_CPP11_NULLPTR -# define CATCH_INTERNAL_CONFIG_CPP11_UNIQUE_PTR -#endif - -#if (_MSC_VER >= 1900 ) // (VC++ 13 (VS2015)) -#define CATCH_INTERNAL_CONFIG_CPP11_NOEXCEPT -#define CATCH_INTERNAL_CONFIG_CPP11_GENERATED_METHODS -#define CATCH_INTERNAL_CONFIG_CPP11_SHUFFLE -#define CATCH_INTERNAL_CONFIG_CPP11_TYPE_TRAITS -#endif - -#endif // _MSC_VER - -//////////////////////////////////////////////////////////////////////////////// - -// Use variadic macros if the compiler supports them -#if ( defined _MSC_VER && _MSC_VER > 1400 && !defined __EDGE__) || \ - ( defined __WAVE__ && __WAVE_HAS_VARIADICS ) || \ - ( defined __GNUC__ && __GNUC__ >= 3 ) || \ - ( !defined __cplusplus && __STDC_VERSION__ >= 199901L || __cplusplus >= 201103L ) - -#define CATCH_INTERNAL_CONFIG_VARIADIC_MACROS - -#endif - -// Use __COUNTER__ if the compiler supports it -#if ( defined _MSC_VER && _MSC_VER >= 1300 ) || \ - ( defined __GNUC__ && ( __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3 )) ) || \ - ( defined __clang__ && __clang_major__ >= 3 ) - -// Use of __COUNTER__ is suppressed during code analysis in CLion/AppCode 2017.2.x and former, -// because __COUNTER__ is not properly handled by it. -// This does not affect compilation -#if ( !defined __JETBRAINS_IDE__ || __JETBRAINS_IDE__ >= 20170300L ) - #define CATCH_INTERNAL_CONFIG_COUNTER -#endif - -#endif - -//////////////////////////////////////////////////////////////////////////////// -// C++ language feature support - -// catch all support for C++11 -#if defined(CATCH_CPP11_OR_GREATER) - -# if !defined(CATCH_INTERNAL_CONFIG_CPP11_NULLPTR) -# define CATCH_INTERNAL_CONFIG_CPP11_NULLPTR -# endif - -# ifndef CATCH_INTERNAL_CONFIG_CPP11_NOEXCEPT -# define CATCH_INTERNAL_CONFIG_CPP11_NOEXCEPT -# endif - -# ifndef CATCH_INTERNAL_CONFIG_CPP11_GENERATED_METHODS -# define CATCH_INTERNAL_CONFIG_CPP11_GENERATED_METHODS -# endif - -# ifndef CATCH_INTERNAL_CONFIG_CPP11_IS_ENUM -# define CATCH_INTERNAL_CONFIG_CPP11_IS_ENUM -# endif - -# ifndef CATCH_INTERNAL_CONFIG_CPP11_TUPLE -# define CATCH_INTERNAL_CONFIG_CPP11_TUPLE -# endif - -# ifndef CATCH_INTERNAL_CONFIG_VARIADIC_MACROS -# define CATCH_INTERNAL_CONFIG_VARIADIC_MACROS -# endif - -# if !defined(CATCH_INTERNAL_CONFIG_CPP11_LONG_LONG) -# define CATCH_INTERNAL_CONFIG_CPP11_LONG_LONG -# endif - -# if !defined(CATCH_INTERNAL_CONFIG_CPP11_OVERRIDE) -# define CATCH_INTERNAL_CONFIG_CPP11_OVERRIDE -# endif -# if !defined(CATCH_INTERNAL_CONFIG_CPP11_UNIQUE_PTR) -# define CATCH_INTERNAL_CONFIG_CPP11_UNIQUE_PTR -# endif -# if !defined(CATCH_INTERNAL_CONFIG_CPP11_SHUFFLE) -# define CATCH_INTERNAL_CONFIG_CPP11_SHUFFLE -# endif -# if !defined(CATCH_INTERNAL_CONFIG_CPP11_TYPE_TRAITS) -# define CATCH_INTERNAL_CONFIG_CPP11_TYPE_TRAITS -# endif - -#endif // __cplusplus >= 201103L - -// Now set the actual defines based on the above + anything the user has configured -#if defined(CATCH_INTERNAL_CONFIG_CPP11_NULLPTR) && !defined(CATCH_CONFIG_CPP11_NO_NULLPTR) && !defined(CATCH_CONFIG_CPP11_NULLPTR) && !defined(CATCH_CONFIG_NO_CPP11) -# define CATCH_CONFIG_CPP11_NULLPTR -#endif -#if defined(CATCH_INTERNAL_CONFIG_CPP11_NOEXCEPT) && !defined(CATCH_CONFIG_CPP11_NO_NOEXCEPT) && !defined(CATCH_CONFIG_CPP11_NOEXCEPT) && !defined(CATCH_CONFIG_NO_CPP11) -# define CATCH_CONFIG_CPP11_NOEXCEPT -#endif -#if defined(CATCH_INTERNAL_CONFIG_CPP11_GENERATED_METHODS) && !defined(CATCH_CONFIG_CPP11_NO_GENERATED_METHODS) && !defined(CATCH_CONFIG_CPP11_GENERATED_METHODS) && !defined(CATCH_CONFIG_NO_CPP11) -# define CATCH_CONFIG_CPP11_GENERATED_METHODS -#endif -#if defined(CATCH_INTERNAL_CONFIG_CPP11_IS_ENUM) && !defined(CATCH_CONFIG_CPP11_NO_IS_ENUM) && !defined(CATCH_CONFIG_CPP11_IS_ENUM) && !defined(CATCH_CONFIG_NO_CPP11) -# define CATCH_CONFIG_CPP11_IS_ENUM -#endif -#if defined(CATCH_INTERNAL_CONFIG_CPP11_TUPLE) && !defined(CATCH_CONFIG_CPP11_NO_TUPLE) && !defined(CATCH_CONFIG_CPP11_TUPLE) && !defined(CATCH_CONFIG_NO_CPP11) -# define CATCH_CONFIG_CPP11_TUPLE -#endif -#if defined(CATCH_INTERNAL_CONFIG_VARIADIC_MACROS) && !defined(CATCH_CONFIG_NO_VARIADIC_MACROS) && !defined(CATCH_CONFIG_VARIADIC_MACROS) -# define CATCH_CONFIG_VARIADIC_MACROS -#endif -#if defined(CATCH_INTERNAL_CONFIG_CPP11_LONG_LONG) && !defined(CATCH_CONFIG_CPP11_NO_LONG_LONG) && !defined(CATCH_CONFIG_CPP11_LONG_LONG) && !defined(CATCH_CONFIG_NO_CPP11) -# define CATCH_CONFIG_CPP11_LONG_LONG -#endif -#if defined(CATCH_INTERNAL_CONFIG_CPP11_OVERRIDE) && !defined(CATCH_CONFIG_CPP11_NO_OVERRIDE) && !defined(CATCH_CONFIG_CPP11_OVERRIDE) && !defined(CATCH_CONFIG_NO_CPP11) -# define CATCH_CONFIG_CPP11_OVERRIDE -#endif -#if defined(CATCH_INTERNAL_CONFIG_CPP11_UNIQUE_PTR) && !defined(CATCH_CONFIG_CPP11_NO_UNIQUE_PTR) && !defined(CATCH_CONFIG_CPP11_UNIQUE_PTR) && !defined(CATCH_CONFIG_NO_CPP11) -# define CATCH_CONFIG_CPP11_UNIQUE_PTR -#endif -#if defined(CATCH_INTERNAL_CONFIG_COUNTER) && !defined(CATCH_CONFIG_NO_COUNTER) && !defined(CATCH_CONFIG_COUNTER) -# define CATCH_CONFIG_COUNTER -#endif -#if defined(CATCH_INTERNAL_CONFIG_CPP11_SHUFFLE) && !defined(CATCH_CONFIG_CPP11_NO_SHUFFLE) && !defined(CATCH_CONFIG_CPP11_SHUFFLE) && !defined(CATCH_CONFIG_NO_CPP11) -# define CATCH_CONFIG_CPP11_SHUFFLE -#endif -# if defined(CATCH_INTERNAL_CONFIG_CPP11_TYPE_TRAITS) && !defined(CATCH_CONFIG_CPP11_NO_TYPE_TRAITS) && !defined(CATCH_CONFIG_CPP11_TYPE_TRAITS) && !defined(CATCH_CONFIG_NO_CPP11) -# define CATCH_CONFIG_CPP11_TYPE_TRAITS -# endif -#if defined(CATCH_INTERNAL_CONFIG_WINDOWS_SEH) && !defined(CATCH_CONFIG_NO_WINDOWS_SEH) && !defined(CATCH_CONFIG_WINDOWS_SEH) -# define CATCH_CONFIG_WINDOWS_SEH -#endif -// This is set by default, because we assume that unix compilers are posix-signal-compatible by default. -#if !defined(CATCH_INTERNAL_CONFIG_NO_POSIX_SIGNALS) && !defined(CATCH_CONFIG_NO_POSIX_SIGNALS) && !defined(CATCH_CONFIG_POSIX_SIGNALS) -# define CATCH_CONFIG_POSIX_SIGNALS -#endif - -#if !defined(CATCH_INTERNAL_SUPPRESS_PARENTHESES_WARNINGS) -# define CATCH_INTERNAL_SUPPRESS_PARENTHESES_WARNINGS -# define CATCH_INTERNAL_UNSUPPRESS_PARENTHESES_WARNINGS -#endif -#if !defined(CATCH_INTERNAL_SUPPRESS_ETD_WARNINGS) -# define CATCH_INTERNAL_SUPPRESS_ETD_WARNINGS -# define CATCH_INTERNAL_UNSUPPRESS_ETD_WARNINGS -#endif - -// noexcept support: -#if defined(CATCH_CONFIG_CPP11_NOEXCEPT) && !defined(CATCH_NOEXCEPT) -# define CATCH_NOEXCEPT noexcept -# define CATCH_NOEXCEPT_IS(x) noexcept(x) -#else -# define CATCH_NOEXCEPT throw() -# define CATCH_NOEXCEPT_IS(x) -#endif - -// nullptr support -#ifdef CATCH_CONFIG_CPP11_NULLPTR -# define CATCH_NULL nullptr -#else -# define CATCH_NULL NULL -#endif - -// override support -#ifdef CATCH_CONFIG_CPP11_OVERRIDE -# define CATCH_OVERRIDE override -#else -# define CATCH_OVERRIDE -#endif - -// unique_ptr support -#ifdef CATCH_CONFIG_CPP11_UNIQUE_PTR -# define CATCH_AUTO_PTR( T ) std::unique_ptr -#else -# define CATCH_AUTO_PTR( T ) std::auto_ptr -#endif - -#define INTERNAL_CATCH_UNIQUE_NAME_LINE2( name, line ) name##line -#define INTERNAL_CATCH_UNIQUE_NAME_LINE( name, line ) INTERNAL_CATCH_UNIQUE_NAME_LINE2( name, line ) -#ifdef CATCH_CONFIG_COUNTER -# define INTERNAL_CATCH_UNIQUE_NAME( name ) INTERNAL_CATCH_UNIQUE_NAME_LINE( name, __COUNTER__ ) -#else -# define INTERNAL_CATCH_UNIQUE_NAME( name ) INTERNAL_CATCH_UNIQUE_NAME_LINE( name, __LINE__ ) -#endif - -#define INTERNAL_CATCH_STRINGIFY2( expr ) #expr -#define INTERNAL_CATCH_STRINGIFY( expr ) INTERNAL_CATCH_STRINGIFY2( expr ) - -#include -#include - -namespace Catch { - - struct IConfig; - - struct CaseSensitive { enum Choice { - Yes, - No - }; }; - - class NonCopyable { -#ifdef CATCH_CONFIG_CPP11_GENERATED_METHODS - NonCopyable( NonCopyable const& ) = delete; - NonCopyable( NonCopyable && ) = delete; - NonCopyable& operator = ( NonCopyable const& ) = delete; - NonCopyable& operator = ( NonCopyable && ) = delete; -#else - NonCopyable( NonCopyable const& info ); - NonCopyable& operator = ( NonCopyable const& ); -#endif - - protected: - NonCopyable() {} - virtual ~NonCopyable(); - }; - - class SafeBool { - public: - typedef void (SafeBool::*type)() const; - - static type makeSafe( bool value ) { - return value ? &SafeBool::trueValue : 0; - } - private: - void trueValue() const {} - }; - - template - void deleteAll( ContainerT& container ) { - typename ContainerT::const_iterator it = container.begin(); - typename ContainerT::const_iterator itEnd = container.end(); - for(; it != itEnd; ++it ) - delete *it; - } - template - void deleteAllValues( AssociativeContainerT& container ) { - typename AssociativeContainerT::const_iterator it = container.begin(); - typename AssociativeContainerT::const_iterator itEnd = container.end(); - for(; it != itEnd; ++it ) - delete it->second; - } - - bool startsWith( std::string const& s, std::string const& prefix ); - bool startsWith( std::string const& s, char prefix ); - bool endsWith( std::string const& s, std::string const& suffix ); - bool endsWith( std::string const& s, char suffix ); - bool contains( std::string const& s, std::string const& infix ); - void toLowerInPlace( std::string& s ); - std::string toLower( std::string const& s ); - std::string trim( std::string const& str ); - bool replaceInPlace( std::string& str, std::string const& replaceThis, std::string const& withThis ); - - struct pluralise { - pluralise( std::size_t count, std::string const& label ); - - friend std::ostream& operator << ( std::ostream& os, pluralise const& pluraliser ); - - std::size_t m_count; - std::string m_label; - }; - - struct SourceLineInfo { - - SourceLineInfo(); - SourceLineInfo( char const* _file, std::size_t _line ); -# ifdef CATCH_CONFIG_CPP11_GENERATED_METHODS - SourceLineInfo(SourceLineInfo const& other) = default; - SourceLineInfo( SourceLineInfo && ) = default; - SourceLineInfo& operator = ( SourceLineInfo const& ) = default; - SourceLineInfo& operator = ( SourceLineInfo && ) = default; -# endif - bool empty() const; - bool operator == ( SourceLineInfo const& other ) const; - bool operator < ( SourceLineInfo const& other ) const; - - char const* file; - std::size_t line; - }; - - std::ostream& operator << ( std::ostream& os, SourceLineInfo const& info ); - - // This is just here to avoid compiler warnings with macro constants and boolean literals - inline bool isTrue( bool value ){ return value; } - inline bool alwaysTrue() { return true; } - inline bool alwaysFalse() { return false; } - - void throwLogicError( std::string const& message, SourceLineInfo const& locationInfo ); - - void seedRng( IConfig const& config ); - unsigned int rngSeed(); - - // Use this in variadic streaming macros to allow - // >> +StreamEndStop - // as well as - // >> stuff +StreamEndStop - struct StreamEndStop { - std::string operator+() { - return std::string(); - } - }; - template - T const& operator + ( T const& value, StreamEndStop ) { - return value; - } -} - -#define CATCH_INTERNAL_LINEINFO ::Catch::SourceLineInfo( __FILE__, static_cast( __LINE__ ) ) -#define CATCH_INTERNAL_ERROR( msg ) ::Catch::throwLogicError( msg, CATCH_INTERNAL_LINEINFO ); - -namespace Catch { - - class NotImplementedException : public std::exception - { - public: - NotImplementedException( SourceLineInfo const& lineInfo ); - - virtual ~NotImplementedException() CATCH_NOEXCEPT {} - - virtual const char* what() const CATCH_NOEXCEPT; - - private: - std::string m_what; - SourceLineInfo m_lineInfo; - }; - -} // end namespace Catch - -/////////////////////////////////////////////////////////////////////////////// -#define CATCH_NOT_IMPLEMENTED throw Catch::NotImplementedException( CATCH_INTERNAL_LINEINFO ) - -// #included from: internal/catch_context.h -#define TWOBLUECUBES_CATCH_CONTEXT_H_INCLUDED - -// #included from: catch_interfaces_generators.h -#define TWOBLUECUBES_CATCH_INTERFACES_GENERATORS_H_INCLUDED - -#include - -namespace Catch { - - struct IGeneratorInfo { - virtual ~IGeneratorInfo(); - virtual bool moveNext() = 0; - virtual std::size_t getCurrentIndex() const = 0; - }; - - struct IGeneratorsForTest { - virtual ~IGeneratorsForTest(); - - virtual IGeneratorInfo& getGeneratorInfo( std::string const& fileInfo, std::size_t size ) = 0; - virtual bool moveNext() = 0; - }; - - IGeneratorsForTest* createGeneratorsForTest(); - -} // end namespace Catch - -// #included from: catch_ptr.hpp -#define TWOBLUECUBES_CATCH_PTR_HPP_INCLUDED - -#ifdef __clang__ -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wpadded" -#endif - -namespace Catch { - - // An intrusive reference counting smart pointer. - // T must implement addRef() and release() methods - // typically implementing the IShared interface - template - class Ptr { - public: - Ptr() : m_p( CATCH_NULL ){} - Ptr( T* p ) : m_p( p ){ - if( m_p ) - m_p->addRef(); - } - Ptr( Ptr const& other ) : m_p( other.m_p ){ - if( m_p ) - m_p->addRef(); - } - ~Ptr(){ - if( m_p ) - m_p->release(); - } - void reset() { - if( m_p ) - m_p->release(); - m_p = CATCH_NULL; - } - Ptr& operator = ( T* p ){ - Ptr temp( p ); - swap( temp ); - return *this; - } - Ptr& operator = ( Ptr const& other ){ - Ptr temp( other ); - swap( temp ); - return *this; - } - void swap( Ptr& other ) { std::swap( m_p, other.m_p ); } - T* get() const{ return m_p; } - T& operator*() const { return *m_p; } - T* operator->() const { return m_p; } - bool operator !() const { return m_p == CATCH_NULL; } - operator SafeBool::type() const { return SafeBool::makeSafe( m_p != CATCH_NULL ); } - - private: - T* m_p; - }; - - struct IShared : NonCopyable { - virtual ~IShared(); - virtual void addRef() const = 0; - virtual void release() const = 0; - }; - - template - struct SharedImpl : T { - - SharedImpl() : m_rc( 0 ){} - - virtual void addRef() const { - ++m_rc; - } - virtual void release() const { - if( --m_rc == 0 ) - delete this; - } - - mutable unsigned int m_rc; - }; - -} // end namespace Catch - -#ifdef __clang__ -#pragma clang diagnostic pop -#endif - -namespace Catch { - - class TestCase; - class Stream; - struct IResultCapture; - struct IRunner; - struct IGeneratorsForTest; - struct IConfig; - - struct IContext - { - virtual ~IContext(); - - virtual IResultCapture* getResultCapture() = 0; - virtual IRunner* getRunner() = 0; - virtual size_t getGeneratorIndex( std::string const& fileInfo, size_t totalSize ) = 0; - virtual bool advanceGeneratorsForCurrentTest() = 0; - virtual Ptr getConfig() const = 0; - }; - - struct IMutableContext : IContext - { - virtual ~IMutableContext(); - virtual void setResultCapture( IResultCapture* resultCapture ) = 0; - virtual void setRunner( IRunner* runner ) = 0; - virtual void setConfig( Ptr const& config ) = 0; - }; - - IContext& getCurrentContext(); - IMutableContext& getCurrentMutableContext(); - void cleanUpContext(); - Stream createStream( std::string const& streamName ); - -} - -// #included from: internal/catch_test_registry.hpp -#define TWOBLUECUBES_CATCH_TEST_REGISTRY_HPP_INCLUDED - -// #included from: catch_interfaces_testcase.h -#define TWOBLUECUBES_CATCH_INTERFACES_TESTCASE_H_INCLUDED - -#include - -namespace Catch { - - class TestSpec; - - struct ITestCase : IShared { - virtual void invoke () const = 0; - protected: - virtual ~ITestCase(); - }; - - class TestCase; - struct IConfig; - - struct ITestCaseRegistry { - virtual ~ITestCaseRegistry(); - virtual std::vector const& getAllTests() const = 0; - virtual std::vector const& getAllTestsSorted( IConfig const& config ) const = 0; - }; - - bool matchTest( TestCase const& testCase, TestSpec const& testSpec, IConfig const& config ); - std::vector filterTests( std::vector const& testCases, TestSpec const& testSpec, IConfig const& config ); - std::vector const& getAllTestCasesSorted( IConfig const& config ); - -} - -namespace Catch { - -template -class MethodTestCase : public SharedImpl { - -public: - MethodTestCase( void (C::*method)() ) : m_method( method ) {} - - virtual void invoke() const { - C obj; - (obj.*m_method)(); - } - -private: - virtual ~MethodTestCase() {} - - void (C::*m_method)(); -}; - -typedef void(*TestFunction)(); - -struct NameAndDesc { - NameAndDesc( const char* _name = "", const char* _description= "" ) - : name( _name ), description( _description ) - {} - - const char* name; - const char* description; -}; - -void registerTestCase - ( ITestCase* testCase, - char const* className, - NameAndDesc const& nameAndDesc, - SourceLineInfo const& lineInfo ); - -struct AutoReg { - - AutoReg - ( TestFunction function, - SourceLineInfo const& lineInfo, - NameAndDesc const& nameAndDesc ); - - template - AutoReg - ( void (C::*method)(), - char const* className, - NameAndDesc const& nameAndDesc, - SourceLineInfo const& lineInfo ) { - - registerTestCase - ( new MethodTestCase( method ), - className, - nameAndDesc, - lineInfo ); - } - - ~AutoReg(); - -private: - AutoReg( AutoReg const& ); - void operator= ( AutoReg const& ); -}; - -void registerTestCaseFunction - ( TestFunction function, - SourceLineInfo const& lineInfo, - NameAndDesc const& nameAndDesc ); - -} // end namespace Catch - -#ifdef CATCH_CONFIG_VARIADIC_MACROS - /////////////////////////////////////////////////////////////////////////////// - #define INTERNAL_CATCH_TESTCASE2( TestName, ... ) \ - static void TestName(); \ - CATCH_INTERNAL_SUPPRESS_ETD_WARNINGS \ - namespace{ Catch::AutoReg INTERNAL_CATCH_UNIQUE_NAME( autoRegistrar )( &TestName, CATCH_INTERNAL_LINEINFO, Catch::NameAndDesc( __VA_ARGS__ ) ); } /* NOLINT */ \ - CATCH_INTERNAL_UNSUPPRESS_ETD_WARNINGS \ - static void TestName() - #define INTERNAL_CATCH_TESTCASE( ... ) \ - INTERNAL_CATCH_TESTCASE2( INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_S_T____ ), __VA_ARGS__ ) - - /////////////////////////////////////////////////////////////////////////////// - #define INTERNAL_CATCH_METHOD_AS_TEST_CASE( QualifiedMethod, ... ) \ - CATCH_INTERNAL_SUPPRESS_ETD_WARNINGS \ - namespace{ Catch::AutoReg INTERNAL_CATCH_UNIQUE_NAME( autoRegistrar )( &QualifiedMethod, "&" #QualifiedMethod, Catch::NameAndDesc( __VA_ARGS__ ), CATCH_INTERNAL_LINEINFO ); } /* NOLINT */ \ - CATCH_INTERNAL_UNSUPPRESS_ETD_WARNINGS - - /////////////////////////////////////////////////////////////////////////////// - #define INTERNAL_CATCH_TEST_CASE_METHOD2( TestName, ClassName, ... )\ - CATCH_INTERNAL_SUPPRESS_ETD_WARNINGS \ - namespace{ \ - struct TestName : ClassName{ \ - void test(); \ - }; \ - Catch::AutoReg INTERNAL_CATCH_UNIQUE_NAME( autoRegistrar ) ( &TestName::test, #ClassName, Catch::NameAndDesc( __VA_ARGS__ ), CATCH_INTERNAL_LINEINFO ); /* NOLINT */ \ - } \ - CATCH_INTERNAL_UNSUPPRESS_ETD_WARNINGS \ - void TestName::test() - #define INTERNAL_CATCH_TEST_CASE_METHOD( ClassName, ... ) \ - INTERNAL_CATCH_TEST_CASE_METHOD2( INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_S_T____ ), ClassName, __VA_ARGS__ ) - - /////////////////////////////////////////////////////////////////////////////// - #define INTERNAL_CATCH_REGISTER_TESTCASE( Function, ... ) \ - CATCH_INTERNAL_SUPPRESS_ETD_WARNINGS \ - Catch::AutoReg( Function, CATCH_INTERNAL_LINEINFO, Catch::NameAndDesc( __VA_ARGS__ ) ); /* NOLINT */ \ - CATCH_INTERNAL_UNSUPPRESS_ETD_WARNINGS - -#else - /////////////////////////////////////////////////////////////////////////////// - #define INTERNAL_CATCH_TESTCASE2( TestName, Name, Desc ) \ - static void TestName(); \ - CATCH_INTERNAL_SUPPRESS_ETD_WARNINGS \ - namespace{ Catch::AutoReg INTERNAL_CATCH_UNIQUE_NAME( autoRegistrar )( &TestName, CATCH_INTERNAL_LINEINFO, Catch::NameAndDesc( Name, Desc ) ); } /* NOLINT */ \ - CATCH_INTERNAL_UNSUPPRESS_ETD_WARNINGS \ - static void TestName() - #define INTERNAL_CATCH_TESTCASE( Name, Desc ) \ - INTERNAL_CATCH_TESTCASE2( INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_S_T____ ), Name, Desc ) - - /////////////////////////////////////////////////////////////////////////////// - #define INTERNAL_CATCH_METHOD_AS_TEST_CASE( QualifiedMethod, Name, Desc ) \ - CATCH_INTERNAL_SUPPRESS_ETD_WARNINGS \ - namespace{ Catch::AutoReg INTERNAL_CATCH_UNIQUE_NAME( autoRegistrar )( &QualifiedMethod, "&" #QualifiedMethod, Catch::NameAndDesc( Name, Desc ), CATCH_INTERNAL_LINEINFO ); } /* NOLINT */ \ - CATCH_INTERNAL_UNSUPPRESS_ETD_WARNINGS - - /////////////////////////////////////////////////////////////////////////////// - #define INTERNAL_CATCH_TEST_CASE_METHOD2( TestCaseName, ClassName, TestName, Desc )\ - CATCH_INTERNAL_SUPPRESS_ETD_WARNINGS \ - namespace{ \ - struct TestCaseName : ClassName{ \ - void test(); \ - }; \ - Catch::AutoReg INTERNAL_CATCH_UNIQUE_NAME( autoRegistrar ) ( &TestCaseName::test, #ClassName, Catch::NameAndDesc( TestName, Desc ), CATCH_INTERNAL_LINEINFO ); /* NOLINT */ \ - } \ - CATCH_INTERNAL_UNSUPPRESS_ETD_WARNINGS \ - void TestCaseName::test() - #define INTERNAL_CATCH_TEST_CASE_METHOD( ClassName, TestName, Desc )\ - INTERNAL_CATCH_TEST_CASE_METHOD2( INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_S_T____ ), ClassName, TestName, Desc ) - - /////////////////////////////////////////////////////////////////////////////// - #define INTERNAL_CATCH_REGISTER_TESTCASE( Function, Name, Desc ) \ - CATCH_INTERNAL_SUPPRESS_ETD_WARNINGS \ - Catch::AutoReg( Function, CATCH_INTERNAL_LINEINFO, Catch::NameAndDesc( Name, Desc ) ); /* NOLINT */ \ - CATCH_INTERNAL_UNSUPPRESS_ETD_WARNINGS - -#endif - -// #included from: internal/catch_capture.hpp -#define TWOBLUECUBES_CATCH_CAPTURE_HPP_INCLUDED - -// #included from: catch_result_builder.h -#define TWOBLUECUBES_CATCH_RESULT_BUILDER_H_INCLUDED - -// #included from: catch_result_type.h -#define TWOBLUECUBES_CATCH_RESULT_TYPE_H_INCLUDED - -namespace Catch { - - // ResultWas::OfType enum - struct ResultWas { enum OfType { - Unknown = -1, - Ok = 0, - Info = 1, - Warning = 2, - - FailureBit = 0x10, - - ExpressionFailed = FailureBit | 1, - ExplicitFailure = FailureBit | 2, - - Exception = 0x100 | FailureBit, - - ThrewException = Exception | 1, - DidntThrowException = Exception | 2, - - FatalErrorCondition = 0x200 | FailureBit - - }; }; - - inline bool isOk( ResultWas::OfType resultType ) { - return ( resultType & ResultWas::FailureBit ) == 0; - } - inline bool isJustInfo( int flags ) { - return flags == ResultWas::Info; - } - - // ResultDisposition::Flags enum - struct ResultDisposition { enum Flags { - Normal = 0x01, - - ContinueOnFailure = 0x02, // Failures fail test, but execution continues - FalseTest = 0x04, // Prefix expression with ! - SuppressFail = 0x08 // Failures are reported but do not fail the test - }; }; - - inline ResultDisposition::Flags operator | ( ResultDisposition::Flags lhs, ResultDisposition::Flags rhs ) { - return static_cast( static_cast( lhs ) | static_cast( rhs ) ); - } - - inline bool shouldContinueOnFailure( int flags ) { return ( flags & ResultDisposition::ContinueOnFailure ) != 0; } - inline bool isFalseTest( int flags ) { return ( flags & ResultDisposition::FalseTest ) != 0; } - inline bool shouldSuppressFailure( int flags ) { return ( flags & ResultDisposition::SuppressFail ) != 0; } - -} // end namespace Catch - -// #included from: catch_assertionresult.h -#define TWOBLUECUBES_CATCH_ASSERTIONRESULT_H_INCLUDED - -#include - -namespace Catch { - - struct STATIC_ASSERT_Expression_Too_Complex_Please_Rewrite_As_Binary_Comparison; - - struct DecomposedExpression - { - virtual ~DecomposedExpression() {} - virtual bool isBinaryExpression() const { - return false; - } - virtual void reconstructExpression( std::string& dest ) const = 0; - - // Only simple binary comparisons can be decomposed. - // If more complex check is required then wrap sub-expressions in parentheses. - template STATIC_ASSERT_Expression_Too_Complex_Please_Rewrite_As_Binary_Comparison& operator + ( T const& ); - template STATIC_ASSERT_Expression_Too_Complex_Please_Rewrite_As_Binary_Comparison& operator - ( T const& ); - template STATIC_ASSERT_Expression_Too_Complex_Please_Rewrite_As_Binary_Comparison& operator * ( T const& ); - template STATIC_ASSERT_Expression_Too_Complex_Please_Rewrite_As_Binary_Comparison& operator / ( T const& ); - template STATIC_ASSERT_Expression_Too_Complex_Please_Rewrite_As_Binary_Comparison& operator % ( T const& ); - template STATIC_ASSERT_Expression_Too_Complex_Please_Rewrite_As_Binary_Comparison& operator && ( T const& ); - template STATIC_ASSERT_Expression_Too_Complex_Please_Rewrite_As_Binary_Comparison& operator || ( T const& ); - - private: - DecomposedExpression& operator = (DecomposedExpression const&); - }; - - struct AssertionInfo - { - AssertionInfo(); - AssertionInfo( char const * _macroName, - SourceLineInfo const& _lineInfo, - char const * _capturedExpression, - ResultDisposition::Flags _resultDisposition, - char const * _secondArg = ""); - - char const * macroName; - SourceLineInfo lineInfo; - char const * capturedExpression; - ResultDisposition::Flags resultDisposition; - char const * secondArg; - }; - - struct AssertionResultData - { - AssertionResultData() : decomposedExpression( CATCH_NULL ) - , resultType( ResultWas::Unknown ) - , negated( false ) - , parenthesized( false ) {} - - void negate( bool parenthesize ) { - negated = !negated; - parenthesized = parenthesize; - if( resultType == ResultWas::Ok ) - resultType = ResultWas::ExpressionFailed; - else if( resultType == ResultWas::ExpressionFailed ) - resultType = ResultWas::Ok; - } - - std::string const& reconstructExpression() const { - if( decomposedExpression != CATCH_NULL ) { - decomposedExpression->reconstructExpression( reconstructedExpression ); - if( parenthesized ) { - reconstructedExpression.insert( 0, 1, '(' ); - reconstructedExpression.append( 1, ')' ); - } - if( negated ) { - reconstructedExpression.insert( 0, 1, '!' ); - } - decomposedExpression = CATCH_NULL; - } - return reconstructedExpression; - } - - mutable DecomposedExpression const* decomposedExpression; - mutable std::string reconstructedExpression; - std::string message; - ResultWas::OfType resultType; - bool negated; - bool parenthesized; - }; - - class AssertionResult { - public: - AssertionResult(); - AssertionResult( AssertionInfo const& info, AssertionResultData const& data ); - ~AssertionResult(); -# ifdef CATCH_CONFIG_CPP11_GENERATED_METHODS - AssertionResult( AssertionResult const& ) = default; - AssertionResult( AssertionResult && ) = default; - AssertionResult& operator = ( AssertionResult const& ) = default; - AssertionResult& operator = ( AssertionResult && ) = default; -# endif - - bool isOk() const; - bool succeeded() const; - ResultWas::OfType getResultType() const; - bool hasExpression() const; - bool hasMessage() const; - std::string getExpression() const; - std::string getExpressionInMacro() const; - bool hasExpandedExpression() const; - std::string getExpandedExpression() const; - std::string getMessage() const; - SourceLineInfo getSourceInfo() const; - std::string getTestMacroName() const; - void discardDecomposedExpression() const; - void expandDecomposedExpression() const; - - protected: - AssertionInfo m_info; - AssertionResultData m_resultData; - }; - -} // end namespace Catch - -// #included from: catch_matchers.hpp -#define TWOBLUECUBES_CATCH_MATCHERS_HPP_INCLUDED - -namespace Catch { -namespace Matchers { - namespace Impl { - - template struct MatchAllOf; - template struct MatchAnyOf; - template struct MatchNotOf; - - class MatcherUntypedBase { - public: - std::string toString() const { - if( m_cachedToString.empty() ) - m_cachedToString = describe(); - return m_cachedToString; - } - - protected: - virtual ~MatcherUntypedBase(); - virtual std::string describe() const = 0; - mutable std::string m_cachedToString; - private: - MatcherUntypedBase& operator = ( MatcherUntypedBase const& ); - }; - - template - struct MatcherMethod { - virtual bool match( ObjectT const& arg ) const = 0; - }; - template - struct MatcherMethod { - virtual bool match( PtrT* arg ) const = 0; - }; - - template - struct MatcherBase : MatcherUntypedBase, MatcherMethod { - - MatchAllOf operator && ( MatcherBase const& other ) const; - MatchAnyOf operator || ( MatcherBase const& other ) const; - MatchNotOf operator ! () const; - }; - - template - struct MatchAllOf : MatcherBase { - virtual bool match( ArgT const& arg ) const CATCH_OVERRIDE { - for( std::size_t i = 0; i < m_matchers.size(); ++i ) { - if (!m_matchers[i]->match(arg)) - return false; - } - return true; - } - virtual std::string describe() const CATCH_OVERRIDE { - std::string description; - description.reserve( 4 + m_matchers.size()*32 ); - description += "( "; - for( std::size_t i = 0; i < m_matchers.size(); ++i ) { - if( i != 0 ) - description += " and "; - description += m_matchers[i]->toString(); - } - description += " )"; - return description; - } - - MatchAllOf& operator && ( MatcherBase const& other ) { - m_matchers.push_back( &other ); - return *this; - } - - std::vector const*> m_matchers; - }; - template - struct MatchAnyOf : MatcherBase { - - virtual bool match( ArgT const& arg ) const CATCH_OVERRIDE { - for( std::size_t i = 0; i < m_matchers.size(); ++i ) { - if (m_matchers[i]->match(arg)) - return true; - } - return false; - } - virtual std::string describe() const CATCH_OVERRIDE { - std::string description; - description.reserve( 4 + m_matchers.size()*32 ); - description += "( "; - for( std::size_t i = 0; i < m_matchers.size(); ++i ) { - if( i != 0 ) - description += " or "; - description += m_matchers[i]->toString(); - } - description += " )"; - return description; - } - - MatchAnyOf& operator || ( MatcherBase const& other ) { - m_matchers.push_back( &other ); - return *this; - } - - std::vector const*> m_matchers; - }; - - template - struct MatchNotOf : MatcherBase { - - MatchNotOf( MatcherBase const& underlyingMatcher ) : m_underlyingMatcher( underlyingMatcher ) {} - - virtual bool match( ArgT const& arg ) const CATCH_OVERRIDE { - return !m_underlyingMatcher.match( arg ); - } - - virtual std::string describe() const CATCH_OVERRIDE { - return "not " + m_underlyingMatcher.toString(); - } - MatcherBase const& m_underlyingMatcher; - }; - - template - MatchAllOf MatcherBase::operator && ( MatcherBase const& other ) const { - return MatchAllOf() && *this && other; - } - template - MatchAnyOf MatcherBase::operator || ( MatcherBase const& other ) const { - return MatchAnyOf() || *this || other; - } - template - MatchNotOf MatcherBase::operator ! () const { - return MatchNotOf( *this ); - } - - } // namespace Impl - - // The following functions create the actual matcher objects. - // This allows the types to be inferred - // - deprecated: prefer ||, && and ! - template - Impl::MatchNotOf Not( Impl::MatcherBase const& underlyingMatcher ) { - return Impl::MatchNotOf( underlyingMatcher ); - } - template - Impl::MatchAllOf AllOf( Impl::MatcherBase const& m1, Impl::MatcherBase const& m2 ) { - return Impl::MatchAllOf() && m1 && m2; - } - template - Impl::MatchAllOf AllOf( Impl::MatcherBase const& m1, Impl::MatcherBase const& m2, Impl::MatcherBase const& m3 ) { - return Impl::MatchAllOf() && m1 && m2 && m3; - } - template - Impl::MatchAnyOf AnyOf( Impl::MatcherBase const& m1, Impl::MatcherBase const& m2 ) { - return Impl::MatchAnyOf() || m1 || m2; - } - template - Impl::MatchAnyOf AnyOf( Impl::MatcherBase const& m1, Impl::MatcherBase const& m2, Impl::MatcherBase const& m3 ) { - return Impl::MatchAnyOf() || m1 || m2 || m3; - } - -} // namespace Matchers - -using namespace Matchers; -using Matchers::Impl::MatcherBase; - -} // namespace Catch - -namespace Catch { - - struct TestFailureException{}; - - template class ExpressionLhs; - - struct CopyableStream { - CopyableStream() {} - CopyableStream( CopyableStream const& other ) { - oss << other.oss.str(); - } - CopyableStream& operator=( CopyableStream const& other ) { - oss.str(std::string()); - oss << other.oss.str(); - return *this; - } - std::ostringstream oss; - }; - - class ResultBuilder : public DecomposedExpression { - public: - ResultBuilder( char const* macroName, - SourceLineInfo const& lineInfo, - char const* capturedExpression, - ResultDisposition::Flags resultDisposition, - char const* secondArg = "" ); - ~ResultBuilder(); - - template - ExpressionLhs operator <= ( T const& operand ); - ExpressionLhs operator <= ( bool value ); - - template - ResultBuilder& operator << ( T const& value ) { - stream().oss << value; - return *this; - } - - ResultBuilder& setResultType( ResultWas::OfType result ); - ResultBuilder& setResultType( bool result ); - - void endExpression( DecomposedExpression const& expr ); - - virtual void reconstructExpression( std::string& dest ) const CATCH_OVERRIDE; - - AssertionResult build() const; - AssertionResult build( DecomposedExpression const& expr ) const; - - void useActiveException( ResultDisposition::Flags resultDisposition = ResultDisposition::Normal ); - void captureResult( ResultWas::OfType resultType ); - void captureExpression(); - void captureExpectedException( std::string const& expectedMessage ); - void captureExpectedException( Matchers::Impl::MatcherBase const& matcher ); - void handleResult( AssertionResult const& result ); - void react(); - bool shouldDebugBreak() const; - bool allowThrows() const; - - template - void captureMatch( ArgT const& arg, MatcherT const& matcher, char const* matcherString ); - - void setExceptionGuard(); - void unsetExceptionGuard(); - - private: - AssertionInfo m_assertionInfo; - AssertionResultData m_data; - - CopyableStream &stream() - { - if(!m_usedStream) - { - m_usedStream = true; - m_stream().oss.str(""); - } - return m_stream(); - } - - static CopyableStream &m_stream() - { - static CopyableStream s; - return s; - } - - bool m_shouldDebugBreak; - bool m_shouldThrow; - bool m_guardException; - bool m_usedStream; - }; - -} // namespace Catch - -// Include after due to circular dependency: -// #included from: catch_expression_lhs.hpp -#define TWOBLUECUBES_CATCH_EXPRESSION_LHS_HPP_INCLUDED - -// #included from: catch_evaluate.hpp -#define TWOBLUECUBES_CATCH_EVALUATE_HPP_INCLUDED - -#ifdef _MSC_VER -#pragma warning(push) -#pragma warning(disable:4389) // '==' : signed/unsigned mismatch -#pragma warning(disable:4018) // more "signed/unsigned mismatch" -#pragma warning(disable:4312) // Converting int to T* using reinterpret_cast (issue on x64 platform) -#endif - -#include - -namespace Catch { -namespace Internal { - - enum Operator { - IsEqualTo, - IsNotEqualTo, - IsLessThan, - IsGreaterThan, - IsLessThanOrEqualTo, - IsGreaterThanOrEqualTo - }; - - template struct OperatorTraits { static const char* getName(){ return "*error*"; } }; - template<> struct OperatorTraits { static const char* getName(){ return "=="; } }; - template<> struct OperatorTraits { static const char* getName(){ return "!="; } }; - template<> struct OperatorTraits { static const char* getName(){ return "<"; } }; - template<> struct OperatorTraits { static const char* getName(){ return ">"; } }; - template<> struct OperatorTraits { static const char* getName(){ return "<="; } }; - template<> struct OperatorTraits{ static const char* getName(){ return ">="; } }; - - template - T& opCast(T const& t) { return const_cast(t); } - -// nullptr_t support based on pull request #154 from Konstantin Baumann -#ifdef CATCH_CONFIG_CPP11_NULLPTR - inline std::nullptr_t opCast(std::nullptr_t) { return nullptr; } -#endif // CATCH_CONFIG_CPP11_NULLPTR - - // So the compare overloads can be operator agnostic we convey the operator as a template - // enum, which is used to specialise an Evaluator for doing the comparison. - template - struct Evaluator{}; - - template - struct Evaluator { - static bool evaluate( T1 const& lhs, T2 const& rhs) { - return bool( opCast( lhs ) == opCast( rhs ) ); - } - }; - template - struct Evaluator { - static bool evaluate( T1 const& lhs, T2 const& rhs ) { - return bool( opCast( lhs ) != opCast( rhs ) ); - } - }; - template - struct Evaluator { - static bool evaluate( T1 const& lhs, T2 const& rhs ) { - return bool( opCast( lhs ) < opCast( rhs ) ); - } - }; - template - struct Evaluator { - static bool evaluate( T1 const& lhs, T2 const& rhs ) { - return bool( opCast( lhs ) > opCast( rhs ) ); - } - }; - template - struct Evaluator { - static bool evaluate( T1 const& lhs, T2 const& rhs ) { - return bool( opCast( lhs ) >= opCast( rhs ) ); - } - }; - template - struct Evaluator { - static bool evaluate( T1 const& lhs, T2 const& rhs ) { - return bool( opCast( lhs ) <= opCast( rhs ) ); - } - }; - - template - bool applyEvaluator( T1 const& lhs, T2 const& rhs ) { - return Evaluator::evaluate( lhs, rhs ); - } - - // This level of indirection allows us to specialise for integer types - // to avoid signed/ unsigned warnings - - // "base" overload - template - bool compare( T1 const& lhs, T2 const& rhs ) { - return Evaluator::evaluate( lhs, rhs ); - } - - // unsigned X to int - template bool compare( unsigned int lhs, int rhs ) { - return applyEvaluator( lhs, static_cast( rhs ) ); - } - template bool compare( unsigned long lhs, int rhs ) { - return applyEvaluator( lhs, static_cast( rhs ) ); - } - template bool compare( unsigned char lhs, int rhs ) { - return applyEvaluator( lhs, static_cast( rhs ) ); - } - - // unsigned X to long - template bool compare( unsigned int lhs, long rhs ) { - return applyEvaluator( lhs, static_cast( rhs ) ); - } - template bool compare( unsigned long lhs, long rhs ) { - return applyEvaluator( lhs, static_cast( rhs ) ); - } - template bool compare( unsigned char lhs, long rhs ) { - return applyEvaluator( lhs, static_cast( rhs ) ); - } - - // int to unsigned X - template bool compare( int lhs, unsigned int rhs ) { - return applyEvaluator( static_cast( lhs ), rhs ); - } - template bool compare( int lhs, unsigned long rhs ) { - return applyEvaluator( static_cast( lhs ), rhs ); - } - template bool compare( int lhs, unsigned char rhs ) { - return applyEvaluator( static_cast( lhs ), rhs ); - } - - // long to unsigned X - template bool compare( long lhs, unsigned int rhs ) { - return applyEvaluator( static_cast( lhs ), rhs ); - } - template bool compare( long lhs, unsigned long rhs ) { - return applyEvaluator( static_cast( lhs ), rhs ); - } - template bool compare( long lhs, unsigned char rhs ) { - return applyEvaluator( static_cast( lhs ), rhs ); - } - - // pointer to long (when comparing against NULL) - template bool compare( long lhs, T* rhs ) { - return Evaluator::evaluate( reinterpret_cast( lhs ), rhs ); - } - template bool compare( T* lhs, long rhs ) { - return Evaluator::evaluate( lhs, reinterpret_cast( rhs ) ); - } - - // pointer to int (when comparing against NULL) - template bool compare( int lhs, T* rhs ) { - return Evaluator::evaluate( reinterpret_cast( lhs ), rhs ); - } - template bool compare( T* lhs, int rhs ) { - return Evaluator::evaluate( lhs, reinterpret_cast( rhs ) ); - } - -#ifdef CATCH_CONFIG_CPP11_LONG_LONG - // long long to unsigned X - template bool compare( long long lhs, unsigned int rhs ) { - return applyEvaluator( static_cast( lhs ), rhs ); - } - template bool compare( long long lhs, unsigned long rhs ) { - return applyEvaluator( static_cast( lhs ), rhs ); - } - template bool compare( long long lhs, unsigned long long rhs ) { - return applyEvaluator( static_cast( lhs ), rhs ); - } - template bool compare( long long lhs, unsigned char rhs ) { - return applyEvaluator( static_cast( lhs ), rhs ); - } - - // unsigned long long to X - template bool compare( unsigned long long lhs, int rhs ) { - return applyEvaluator( static_cast( lhs ), rhs ); - } - template bool compare( unsigned long long lhs, long rhs ) { - return applyEvaluator( static_cast( lhs ), rhs ); - } - template bool compare( unsigned long long lhs, long long rhs ) { - return applyEvaluator( static_cast( lhs ), rhs ); - } - template bool compare( unsigned long long lhs, char rhs ) { - return applyEvaluator( static_cast( lhs ), rhs ); - } - - // pointer to long long (when comparing against NULL) - template bool compare( long long lhs, T* rhs ) { - return Evaluator::evaluate( reinterpret_cast( lhs ), rhs ); - } - template bool compare( T* lhs, long long rhs ) { - return Evaluator::evaluate( lhs, reinterpret_cast( rhs ) ); - } -#endif // CATCH_CONFIG_CPP11_LONG_LONG - -#ifdef CATCH_CONFIG_CPP11_NULLPTR - // pointer to nullptr_t (when comparing against nullptr) - template bool compare( std::nullptr_t, T* rhs ) { - return Evaluator::evaluate( nullptr, rhs ); - } - template bool compare( T* lhs, std::nullptr_t ) { - return Evaluator::evaluate( lhs, nullptr ); - } -#endif // CATCH_CONFIG_CPP11_NULLPTR - -} // end of namespace Internal -} // end of namespace Catch - -#ifdef _MSC_VER -#pragma warning(pop) -#endif - -// #included from: catch_tostring.h -#define TWOBLUECUBES_CATCH_TOSTRING_H_INCLUDED - -#include -#include -#include -#include -#include - -#ifdef __OBJC__ -// #included from: catch_objc_arc.hpp -#define TWOBLUECUBES_CATCH_OBJC_ARC_HPP_INCLUDED - -#import - -#ifdef __has_feature -#define CATCH_ARC_ENABLED __has_feature(objc_arc) -#else -#define CATCH_ARC_ENABLED 0 -#endif - -void arcSafeRelease( NSObject* obj ); -id performOptionalSelector( id obj, SEL sel ); - -#if !CATCH_ARC_ENABLED -inline void arcSafeRelease( NSObject* obj ) { - [obj release]; -} -inline id performOptionalSelector( id obj, SEL sel ) { - if( [obj respondsToSelector: sel] ) - return [obj performSelector: sel]; - return nil; -} -#define CATCH_UNSAFE_UNRETAINED -#define CATCH_ARC_STRONG -#else -inline void arcSafeRelease( NSObject* ){} -inline id performOptionalSelector( id obj, SEL sel ) { -#ifdef __clang__ -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Warc-performSelector-leaks" -#endif - if( [obj respondsToSelector: sel] ) - return [obj performSelector: sel]; -#ifdef __clang__ -#pragma clang diagnostic pop -#endif - return nil; -} -#define CATCH_UNSAFE_UNRETAINED __unsafe_unretained -#define CATCH_ARC_STRONG __strong -#endif - -#endif - -#ifdef CATCH_CONFIG_CPP11_TUPLE -#include -#endif - -#ifdef CATCH_CONFIG_CPP11_IS_ENUM -#include -#endif - -namespace Catch { - -// Why we're here. -template -std::string toString( T const& value ); - -// Built in overloads - -std::string toString( std::string const& value ); -std::string toString( std::wstring const& value ); -std::string toString( const char* const value ); -std::string toString( char* const value ); -std::string toString( const wchar_t* const value ); -std::string toString( wchar_t* const value ); -std::string toString( int value ); -std::string toString( unsigned long value ); -std::string toString( unsigned int value ); -std::string toString( const double value ); -std::string toString( const float value ); -std::string toString( bool value ); -std::string toString( char value ); -std::string toString( signed char value ); -std::string toString( unsigned char value ); - -#ifdef CATCH_CONFIG_CPP11_LONG_LONG -std::string toString( long long value ); -std::string toString( unsigned long long value ); -#endif - -#ifdef CATCH_CONFIG_CPP11_NULLPTR -std::string toString( std::nullptr_t ); -#endif - -#ifdef __OBJC__ - std::string toString( NSString const * const& nsstring ); - std::string toString( NSString * CATCH_ARC_STRONG & nsstring ); - std::string toString( NSObject* const& nsObject ); -#endif - -namespace Detail { - - extern const std::string unprintableString; - - #if !defined(CATCH_CONFIG_CPP11_STREAM_INSERTABLE_CHECK) - struct BorgType { - template BorgType( T const& ); - }; - - struct TrueType { char sizer[1]; }; - struct FalseType { char sizer[2]; }; - - TrueType& testStreamable( std::ostream& ); - FalseType testStreamable( FalseType ); - - FalseType operator<<( std::ostream const&, BorgType const& ); - - template - struct IsStreamInsertable { - static std::ostream &s; - static T const&t; - enum { value = sizeof( testStreamable(s << t) ) == sizeof( TrueType ) }; - }; -#else - template - class IsStreamInsertable { - template - static auto test(int) - -> decltype( std::declval() << std::declval(), std::true_type() ); - - template - static auto test(...) -> std::false_type; - - public: - static const bool value = decltype(test(0))::value; - }; -#endif - -#if defined(CATCH_CONFIG_CPP11_IS_ENUM) - template::value - > - struct EnumStringMaker - { - static std::string convert( T const& ) { return unprintableString; } - }; - - template - struct EnumStringMaker - { - static std::string convert( T const& v ) - { - return ::Catch::toString( - static_cast::type>(v) - ); - } - }; -#endif - template - struct StringMakerBase { -#if defined(CATCH_CONFIG_CPP11_IS_ENUM) - template - static std::string convert( T const& v ) - { - return EnumStringMaker::convert( v ); - } -#else - template - static std::string convert( T const& ) { return unprintableString; } -#endif - }; - - template<> - struct StringMakerBase { - template - static std::string convert( T const& _value ) { - std::ostringstream oss; - oss << _value; - return oss.str(); - } - }; - - std::string rawMemoryToString( const void *object, std::size_t size ); - - template - std::string rawMemoryToString( const T& object ) { - return rawMemoryToString( &object, sizeof(object) ); - } - -} // end namespace Detail - -template -struct StringMaker : - Detail::StringMakerBase::value> {}; - -template -struct StringMaker { - template - static std::string convert( U* p ) { - if( !p ) - return "NULL"; - else - return Detail::rawMemoryToString( p ); - } -}; - -template -struct StringMaker { - static std::string convert( R C::* p ) { - if( !p ) - return "NULL"; - else - return Detail::rawMemoryToString( p ); - } -}; - -namespace Detail { - template - std::string rangeToString( InputIterator first, InputIterator last ); -} - -//template -//struct StringMaker > { -// static std::string convert( std::vector const& v ) { -// return Detail::rangeToString( v.begin(), v.end() ); -// } -//}; - -template -std::string toString( std::vector const& v ) { - return Detail::rangeToString( v.begin(), v.end() ); -} - -#ifdef CATCH_CONFIG_CPP11_TUPLE - -// toString for tuples -namespace TupleDetail { - template< - typename Tuple, - std::size_t N = 0, - bool = (N < std::tuple_size::value) - > - struct ElementPrinter { - static void print( const Tuple& tuple, std::ostream& os ) - { - os << ( N ? ", " : " " ) - << Catch::toString(std::get(tuple)); - ElementPrinter::print(tuple,os); - } - }; - - template< - typename Tuple, - std::size_t N - > - struct ElementPrinter { - static void print( const Tuple&, std::ostream& ) {} - }; - -} - -template -struct StringMaker> { - - static std::string convert( const std::tuple& tuple ) - { - std::ostringstream os; - os << '{'; - TupleDetail::ElementPrinter>::print( tuple, os ); - os << " }"; - return os.str(); - } -}; -#endif // CATCH_CONFIG_CPP11_TUPLE - -namespace Detail { - template - std::string makeString( T const& value ) { - return StringMaker::convert( value ); - } -} // end namespace Detail - -/// \brief converts any type to a string -/// -/// The default template forwards on to ostringstream - except when an -/// ostringstream overload does not exist - in which case it attempts to detect -/// that and writes {?}. -/// Overload (not specialise) this template for custom typs that you don't want -/// to provide an ostream overload for. -template -std::string toString( T const& value ) { - return StringMaker::convert( value ); -} - - namespace Detail { - template - std::string rangeToString( InputIterator first, InputIterator last ) { - std::ostringstream oss; - oss << "{ "; - if( first != last ) { - oss << Catch::toString( *first ); - for( ++first ; first != last ; ++first ) - oss << ", " << Catch::toString( *first ); - } - oss << " }"; - return oss.str(); - } -} - -} // end namespace Catch - -namespace Catch { - -template -class BinaryExpression; - -template -class MatchExpression; - -// Wraps the LHS of an expression and overloads comparison operators -// for also capturing those and RHS (if any) -template -class ExpressionLhs : public DecomposedExpression { -public: - ExpressionLhs( ResultBuilder& rb, T lhs ) : m_rb( rb ), m_lhs( lhs ), m_truthy(false) {} - - ExpressionLhs& operator = ( const ExpressionLhs& ); - - template - BinaryExpression - operator == ( RhsT const& rhs ) { - return captureExpression( rhs ); - } - - template - BinaryExpression - operator != ( RhsT const& rhs ) { - return captureExpression( rhs ); - } - - template - BinaryExpression - operator < ( RhsT const& rhs ) { - return captureExpression( rhs ); - } - - template - BinaryExpression - operator > ( RhsT const& rhs ) { - return captureExpression( rhs ); - } - - template - BinaryExpression - operator <= ( RhsT const& rhs ) { - return captureExpression( rhs ); - } - - template - BinaryExpression - operator >= ( RhsT const& rhs ) { - return captureExpression( rhs ); - } - - BinaryExpression operator == ( bool rhs ) { - return captureExpression( rhs ); - } - - BinaryExpression operator != ( bool rhs ) { - return captureExpression( rhs ); - } - - void endExpression() { - m_truthy = m_lhs ? true : false; - m_rb - .setResultType( m_truthy ) - .endExpression( *this ); - } - - virtual void reconstructExpression( std::string& dest ) const CATCH_OVERRIDE { - dest = Catch::toString( m_lhs ); - } - -private: - template - BinaryExpression captureExpression( RhsT& rhs ) const { - return BinaryExpression( m_rb, m_lhs, rhs ); - } - - template - BinaryExpression captureExpression( bool rhs ) const { - return BinaryExpression( m_rb, m_lhs, rhs ); - } - -private: - ResultBuilder& m_rb; - T m_lhs; - bool m_truthy; -}; - -template -class BinaryExpression : public DecomposedExpression { -public: - BinaryExpression( ResultBuilder& rb, LhsT lhs, RhsT rhs ) - : m_rb( rb ), m_lhs( lhs ), m_rhs( rhs ) {} - - BinaryExpression& operator = ( BinaryExpression& ); - - void endExpression() const { - m_rb - .setResultType( Internal::compare( m_lhs, m_rhs ) ) - .endExpression( *this ); - } - - virtual bool isBinaryExpression() const CATCH_OVERRIDE { - return true; - } - - virtual void reconstructExpression( std::string& dest ) const CATCH_OVERRIDE { - std::string lhs = Catch::toString( m_lhs ); - std::string rhs = Catch::toString( m_rhs ); - char delim = lhs.size() + rhs.size() < 40 && - lhs.find('\n') == std::string::npos && - rhs.find('\n') == std::string::npos ? ' ' : '\n'; - dest.reserve( 7 + lhs.size() + rhs.size() ); - // 2 for spaces around operator - // 2 for operator - // 2 for parentheses (conditionally added later) - // 1 for negation (conditionally added later) - dest = lhs; - dest += delim; - dest += Internal::OperatorTraits::getName(); - dest += delim; - dest += rhs; - } - -private: - ResultBuilder& m_rb; - LhsT m_lhs; - RhsT m_rhs; -}; - -template -class MatchExpression : public DecomposedExpression { -public: - MatchExpression( ArgT arg, MatcherT matcher, char const* matcherString ) - : m_arg( arg ), m_matcher( matcher ), m_matcherString( matcherString ) {} - - virtual bool isBinaryExpression() const CATCH_OVERRIDE { - return true; - } - - virtual void reconstructExpression( std::string& dest ) const CATCH_OVERRIDE { - std::string matcherAsString = m_matcher.toString(); - dest = Catch::toString( m_arg ); - dest += ' '; - if( matcherAsString == Detail::unprintableString ) - dest += m_matcherString; - else - dest += matcherAsString; - } - -private: - ArgT m_arg; - MatcherT m_matcher; - char const* m_matcherString; -}; - -} // end namespace Catch - - -namespace Catch { - - template - ExpressionLhs ResultBuilder::operator <= ( T const& operand ) { - return ExpressionLhs( *this, operand ); - } - - inline ExpressionLhs ResultBuilder::operator <= ( bool value ) { - return ExpressionLhs( *this, value ); - } - - template - void ResultBuilder::captureMatch( ArgT const& arg, MatcherT const& matcher, - char const* matcherString ) { - MatchExpression expr( arg, matcher, matcherString ); - setResultType( matcher.match( arg ) ); - endExpression( expr ); - } - -} // namespace Catch - -// #included from: catch_message.h -#define TWOBLUECUBES_CATCH_MESSAGE_H_INCLUDED - -#include - -namespace Catch { - - struct MessageInfo { - MessageInfo( std::string const& _macroName, - SourceLineInfo const& _lineInfo, - ResultWas::OfType _type ); - - std::string macroName; - SourceLineInfo lineInfo; - ResultWas::OfType type; - std::string message; - unsigned int sequence; - - bool operator == ( MessageInfo const& other ) const { - return sequence == other.sequence; - } - bool operator < ( MessageInfo const& other ) const { - return sequence < other.sequence; - } - private: - static unsigned int globalCount; - }; - - struct MessageBuilder { - MessageBuilder( std::string const& macroName, - SourceLineInfo const& lineInfo, - ResultWas::OfType type ) - : m_info( macroName, lineInfo, type ) - {} - - template - MessageBuilder& operator << ( T const& value ) { - m_stream << value; - return *this; - } - - MessageInfo m_info; - std::ostringstream m_stream; - }; - - class ScopedMessage { - public: - ScopedMessage( MessageBuilder const& builder ); - ScopedMessage( ScopedMessage const& other ); - ~ScopedMessage(); - - MessageInfo m_info; - }; - -} // end namespace Catch - -// #included from: catch_interfaces_capture.h -#define TWOBLUECUBES_CATCH_INTERFACES_CAPTURE_H_INCLUDED - -#include - -namespace Catch { - - class TestCase; - class AssertionResult; - struct AssertionInfo; - struct SectionInfo; - struct SectionEndInfo; - struct MessageInfo; - class ScopedMessageBuilder; - struct Counts; - - struct IResultCapture { - - virtual ~IResultCapture(); - - virtual void assertionEnded( AssertionResult const& result ) = 0; - virtual bool sectionStarted( SectionInfo const& sectionInfo, - Counts& assertions ) = 0; - virtual void sectionEnded( SectionEndInfo const& endInfo ) = 0; - virtual void sectionEndedEarly( SectionEndInfo const& endInfo ) = 0; - virtual void pushScopedMessage( MessageInfo const& message ) = 0; - virtual void popScopedMessage( MessageInfo const& message ) = 0; - - virtual std::string getCurrentTestName() const = 0; - virtual const AssertionResult* getLastResult() const = 0; - - virtual void exceptionEarlyReported() = 0; - - virtual void handleFatalErrorCondition( std::string const& message ) = 0; - - virtual bool lastAssertionPassed() = 0; - virtual void assertionPassed() = 0; - virtual void assertionRun() = 0; - }; - - IResultCapture& getResultCapture(); -} - -// #included from: catch_debugger.h -#define TWOBLUECUBES_CATCH_DEBUGGER_H_INCLUDED - -// #included from: catch_platform.h -#define TWOBLUECUBES_CATCH_PLATFORM_H_INCLUDED - -#if defined(__MAC_OS_X_VERSION_MIN_REQUIRED) -# define CATCH_PLATFORM_MAC -#elif defined(__IPHONE_OS_VERSION_MIN_REQUIRED) -# define CATCH_PLATFORM_IPHONE -#elif defined(linux) || defined(__linux) || defined(__linux__) -# define CATCH_PLATFORM_LINUX -#elif defined(WIN32) || defined(__WIN32__) || defined(_WIN32) || defined(_MSC_VER) -# define CATCH_PLATFORM_WINDOWS -# if !defined(NOMINMAX) && !defined(CATCH_CONFIG_NO_NOMINMAX) -# define CATCH_DEFINES_NOMINMAX -# endif -# if !defined(WIN32_LEAN_AND_MEAN) && !defined(CATCH_CONFIG_NO_WIN32_LEAN_AND_MEAN) -# define CATCH_DEFINES_WIN32_LEAN_AND_MEAN -# endif -#endif - -#include - -namespace Catch{ - - bool isDebuggerActive(); - void writeToDebugConsole( std::string const& text ); -} - -#ifdef CATCH_PLATFORM_MAC - - // The following code snippet based on: - // http://cocoawithlove.com/2008/03/break-into-debugger.html - #if defined(__ppc64__) || defined(__ppc__) - #define CATCH_TRAP() \ - __asm__("li r0, 20\nsc\nnop\nli r0, 37\nli r4, 2\nsc\nnop\n" \ - : : : "memory","r0","r3","r4" ) /* NOLINT */ - #else - #define CATCH_TRAP() __asm__("int $3\n" : : /* NOLINT */ ) - #endif - -#elif defined(CATCH_PLATFORM_LINUX) - // If we can use inline assembler, do it because this allows us to break - // directly at the location of the failing check instead of breaking inside - // raise() called from it, i.e. one stack frame below. - #if defined(__GNUC__) && (defined(__i386) || defined(__x86_64)) - #define CATCH_TRAP() asm volatile ("int $3") /* NOLINT */ - #else // Fall back to the generic way. - #include - - #define CATCH_TRAP() raise(SIGTRAP) - #endif -#elif defined(_MSC_VER) - #define CATCH_TRAP() __debugbreak() -#elif defined(__MINGW32__) - extern "C" __declspec(dllimport) void __stdcall DebugBreak(); - #define CATCH_TRAP() DebugBreak() -#endif - -#ifdef CATCH_TRAP - #define CATCH_BREAK_INTO_DEBUGGER() if( Catch::isDebuggerActive() ) { CATCH_TRAP(); } -#else - #define CATCH_BREAK_INTO_DEBUGGER() Catch::alwaysTrue(); -#endif - -// #included from: catch_interfaces_runner.h -#define TWOBLUECUBES_CATCH_INTERFACES_RUNNER_H_INCLUDED - -namespace Catch { - class TestCase; - - struct IRunner { - virtual ~IRunner(); - virtual bool aborting() const = 0; - }; -} - -#if !defined(CATCH_CONFIG_DISABLE_STRINGIFICATION) -# define CATCH_INTERNAL_STRINGIFY(expr) #expr -#else -# define CATCH_INTERNAL_STRINGIFY(expr) "Disabled by CATCH_CONFIG_DISABLE_STRINGIFICATION" -#endif - -#if defined(CATCH_CONFIG_FAST_COMPILE) -/////////////////////////////////////////////////////////////////////////////// -// We can speedup compilation significantly by breaking into debugger lower in -// the callstack, because then we don't have to expand CATCH_BREAK_INTO_DEBUGGER -// macro in each assertion -#define INTERNAL_CATCH_REACT( resultBuilder ) \ - resultBuilder.react(); - -/////////////////////////////////////////////////////////////////////////////// -// Another way to speed-up compilation is to omit local try-catch for REQUIRE* -// macros. -// This can potentially cause false negative, if the test code catches -// the exception before it propagates back up to the runner. -#define INTERNAL_CATCH_TEST_NO_TRY( macroName, resultDisposition, expr ) \ - do { \ - Catch::ResultBuilder __catchResult( macroName, CATCH_INTERNAL_LINEINFO, CATCH_INTERNAL_STRINGIFY(expr), resultDisposition ); \ - __catchResult.setExceptionGuard(); \ - CATCH_INTERNAL_SUPPRESS_PARENTHESES_WARNINGS \ - ( __catchResult <= expr ).endExpression(); \ - CATCH_INTERNAL_UNSUPPRESS_PARENTHESES_WARNINGS \ - __catchResult.unsetExceptionGuard(); \ - INTERNAL_CATCH_REACT( __catchResult ) \ - } while( Catch::isTrue( false && static_cast( !!(expr) ) ) ) // expr here is never evaluated at runtime but it forces the compiler to give it a look -// The double negation silences MSVC's C4800 warning, the static_cast forces short-circuit evaluation if the type has overloaded &&. - -#define INTERNAL_CHECK_THAT_NO_TRY( macroName, matcher, resultDisposition, arg ) \ - do { \ - Catch::ResultBuilder __catchResult( macroName, CATCH_INTERNAL_LINEINFO, CATCH_INTERNAL_STRINGIFY(arg) ", " CATCH_INTERNAL_STRINGIFY(matcher), resultDisposition ); \ - __catchResult.setExceptionGuard(); \ - __catchResult.captureMatch( arg, matcher, CATCH_INTERNAL_STRINGIFY(matcher) ); \ - __catchResult.unsetExceptionGuard(); \ - INTERNAL_CATCH_REACT( __catchResult ) \ - } while( Catch::alwaysFalse() ) - -#else -/////////////////////////////////////////////////////////////////////////////// -// In the event of a failure works out if the debugger needs to be invoked -// and/or an exception thrown and takes appropriate action. -// This needs to be done as a macro so the debugger will stop in the user -// source code rather than in Catch library code -#define INTERNAL_CATCH_REACT( resultBuilder ) \ - if( resultBuilder.shouldDebugBreak() ) CATCH_BREAK_INTO_DEBUGGER(); \ - resultBuilder.react(); -#endif - -/////////////////////////////////////////////////////////////////////////////// -#define INTERNAL_CATCH_TEST( macroName, resultDisposition, expr ) \ - do { \ - Catch::ResultBuilder __catchResult( macroName, CATCH_INTERNAL_LINEINFO, CATCH_INTERNAL_STRINGIFY(expr), resultDisposition ); \ - try { \ - CATCH_INTERNAL_SUPPRESS_PARENTHESES_WARNINGS \ - ( __catchResult <= expr ).endExpression(); \ - CATCH_INTERNAL_UNSUPPRESS_PARENTHESES_WARNINGS \ - } \ - catch( ... ) { \ - __catchResult.useActiveException( resultDisposition ); \ - } \ - INTERNAL_CATCH_REACT( __catchResult ) \ - } while( Catch::isTrue( false && static_cast( !!(expr) ) ) ) // expr here is never evaluated at runtime but it forces the compiler to give it a look - // The double negation silences MSVC's C4800 warning, the static_cast forces short-circuit evaluation if the type has overloaded &&. - -/////////////////////////////////////////////////////////////////////////////// -#define INTERNAL_CATCH_IF( macroName, resultDisposition, expr ) \ - INTERNAL_CATCH_TEST( macroName, resultDisposition, expr ); \ - if( Catch::getResultCapture().lastAssertionPassed() ) - -/////////////////////////////////////////////////////////////////////////////// -#define INTERNAL_CATCH_ELSE( macroName, resultDisposition, expr ) \ - INTERNAL_CATCH_TEST( macroName, resultDisposition, expr ); \ - if( !Catch::getResultCapture().lastAssertionPassed() ) - -/////////////////////////////////////////////////////////////////////////////// -#define INTERNAL_CATCH_NO_THROW( macroName, resultDisposition, expr ) \ - do { \ - Catch::ResultBuilder __catchResult( macroName, CATCH_INTERNAL_LINEINFO, CATCH_INTERNAL_STRINGIFY(expr), resultDisposition ); \ - try { \ - static_cast(expr); \ - __catchResult.captureResult( Catch::ResultWas::Ok ); \ - } \ - catch( ... ) { \ - __catchResult.useActiveException( resultDisposition ); \ - } \ - INTERNAL_CATCH_REACT( __catchResult ) \ - } while( Catch::alwaysFalse() ) - -/////////////////////////////////////////////////////////////////////////////// -#define INTERNAL_CATCH_THROWS( macroName, resultDisposition, matcher, expr ) \ - do { \ - Catch::ResultBuilder __catchResult( macroName, CATCH_INTERNAL_LINEINFO, CATCH_INTERNAL_STRINGIFY(expr), resultDisposition, CATCH_INTERNAL_STRINGIFY(matcher) ); \ - if( __catchResult.allowThrows() ) \ - try { \ - static_cast(expr); \ - __catchResult.captureResult( Catch::ResultWas::DidntThrowException ); \ - } \ - catch( ... ) { \ - __catchResult.captureExpectedException( matcher ); \ - } \ - else \ - __catchResult.captureResult( Catch::ResultWas::Ok ); \ - INTERNAL_CATCH_REACT( __catchResult ) \ - } while( Catch::alwaysFalse() ) - -/////////////////////////////////////////////////////////////////////////////// -#define INTERNAL_CATCH_THROWS_AS( macroName, exceptionType, resultDisposition, expr ) \ - do { \ - Catch::ResultBuilder __catchResult( macroName, CATCH_INTERNAL_LINEINFO, CATCH_INTERNAL_STRINGIFY(expr) ", " CATCH_INTERNAL_STRINGIFY(exceptionType), resultDisposition ); \ - if( __catchResult.allowThrows() ) \ - try { \ - static_cast(expr); \ - __catchResult.captureResult( Catch::ResultWas::DidntThrowException ); \ - } \ - catch( exceptionType ) { \ - __catchResult.captureResult( Catch::ResultWas::Ok ); \ - } \ - catch( ... ) { \ - __catchResult.useActiveException( resultDisposition ); \ - } \ - else \ - __catchResult.captureResult( Catch::ResultWas::Ok ); \ - INTERNAL_CATCH_REACT( __catchResult ) \ - } while( Catch::alwaysFalse() ) - -/////////////////////////////////////////////////////////////////////////////// -#ifdef CATCH_CONFIG_VARIADIC_MACROS - #define INTERNAL_CATCH_MSG( macroName, messageType, resultDisposition, ... ) \ - do { \ - Catch::ResultBuilder __catchResult( macroName, CATCH_INTERNAL_LINEINFO, "", resultDisposition ); \ - __catchResult << __VA_ARGS__ + ::Catch::StreamEndStop(); \ - __catchResult.captureResult( messageType ); \ - INTERNAL_CATCH_REACT( __catchResult ) \ - } while( Catch::alwaysFalse() ) -#else - #define INTERNAL_CATCH_MSG( macroName, messageType, resultDisposition, log ) \ - do { \ - Catch::ResultBuilder __catchResult( macroName, CATCH_INTERNAL_LINEINFO, "", resultDisposition ); \ - __catchResult << log + ::Catch::StreamEndStop(); \ - __catchResult.captureResult( messageType ); \ - INTERNAL_CATCH_REACT( __catchResult ) \ - } while( Catch::alwaysFalse() ) -#endif - -/////////////////////////////////////////////////////////////////////////////// -#define INTERNAL_CATCH_INFO( macroName, log ) \ - Catch::ScopedMessage INTERNAL_CATCH_UNIQUE_NAME( scopedMessage ) = Catch::MessageBuilder( macroName, CATCH_INTERNAL_LINEINFO, Catch::ResultWas::Info ) << log; - -/////////////////////////////////////////////////////////////////////////////// -#define INTERNAL_CHECK_THAT( macroName, matcher, resultDisposition, arg ) \ - do { \ - Catch::ResultBuilder __catchResult( macroName, CATCH_INTERNAL_LINEINFO, CATCH_INTERNAL_STRINGIFY(arg) ", " CATCH_INTERNAL_STRINGIFY(matcher), resultDisposition ); \ - try { \ - __catchResult.captureMatch( arg, matcher, CATCH_INTERNAL_STRINGIFY(matcher) ); \ - } catch( ... ) { \ - __catchResult.useActiveException( resultDisposition | Catch::ResultDisposition::ContinueOnFailure ); \ - } \ - INTERNAL_CATCH_REACT( __catchResult ) \ - } while( Catch::alwaysFalse() ) - -// #included from: internal/catch_section.h -#define TWOBLUECUBES_CATCH_SECTION_H_INCLUDED - -// #included from: catch_section_info.h -#define TWOBLUECUBES_CATCH_SECTION_INFO_H_INCLUDED - -// #included from: catch_totals.hpp -#define TWOBLUECUBES_CATCH_TOTALS_HPP_INCLUDED - -#include - -namespace Catch { - - struct Counts { - Counts() : passed( 0 ), failed( 0 ), failedButOk( 0 ) {} - - Counts operator - ( Counts const& other ) const { - Counts diff; - diff.passed = passed - other.passed; - diff.failed = failed - other.failed; - diff.failedButOk = failedButOk - other.failedButOk; - return diff; - } - Counts& operator += ( Counts const& other ) { - passed += other.passed; - failed += other.failed; - failedButOk += other.failedButOk; - return *this; - } - - std::size_t total() const { - return passed + failed + failedButOk; - } - bool allPassed() const { - return failed == 0 && failedButOk == 0; - } - bool allOk() const { - return failed == 0; - } - - std::size_t passed; - std::size_t failed; - std::size_t failedButOk; - }; - - struct Totals { - - Totals operator - ( Totals const& other ) const { - Totals diff; - diff.assertions = assertions - other.assertions; - diff.testCases = testCases - other.testCases; - return diff; - } - - Totals delta( Totals const& prevTotals ) const { - Totals diff = *this - prevTotals; - if( diff.assertions.failed > 0 ) - ++diff.testCases.failed; - else if( diff.assertions.failedButOk > 0 ) - ++diff.testCases.failedButOk; - else - ++diff.testCases.passed; - return diff; - } - - Totals& operator += ( Totals const& other ) { - assertions += other.assertions; - testCases += other.testCases; - return *this; - } - - Counts assertions; - Counts testCases; - }; -} - -#include - -namespace Catch { - - struct SectionInfo { - SectionInfo - ( SourceLineInfo const& _lineInfo, - std::string const& _name, - std::string const& _description = std::string() ); - - std::string name; - std::string description; - SourceLineInfo lineInfo; - }; - - struct SectionEndInfo { - SectionEndInfo( SectionInfo const& _sectionInfo, Counts const& _prevAssertions, double _durationInSeconds ) - : sectionInfo( _sectionInfo ), prevAssertions( _prevAssertions ), durationInSeconds( _durationInSeconds ) - {} - - SectionInfo sectionInfo; - Counts prevAssertions; - double durationInSeconds; - }; - -} // end namespace Catch - -// #included from: catch_timer.h -#define TWOBLUECUBES_CATCH_TIMER_H_INCLUDED - -#ifdef _MSC_VER - -namespace Catch { - typedef unsigned long long UInt64; -} -#else -#include -namespace Catch { - typedef uint64_t UInt64; -} -#endif - -namespace Catch { - class Timer { - public: - Timer() : m_ticks( 0 ) {} - void start(); - unsigned int getElapsedMicroseconds() const; - unsigned int getElapsedMilliseconds() const; - double getElapsedSeconds() const; - - private: - UInt64 m_ticks; - }; - -} // namespace Catch - -#include - -namespace Catch { - - class Section : NonCopyable { - public: - Section( SectionInfo const& info ); - ~Section(); - - // This indicates whether the section should be executed or not - operator bool() const; - - private: - SectionInfo m_info; - - std::string m_name; - Counts m_assertions; - bool m_sectionIncluded; - Timer m_timer; - }; - -} // end namespace Catch - -#ifdef CATCH_CONFIG_VARIADIC_MACROS - #define INTERNAL_CATCH_SECTION( ... ) \ - if( Catch::Section const& INTERNAL_CATCH_UNIQUE_NAME( catch_internal_Section ) = Catch::SectionInfo( CATCH_INTERNAL_LINEINFO, __VA_ARGS__ ) ) -#else - #define INTERNAL_CATCH_SECTION( name, desc ) \ - if( Catch::Section const& INTERNAL_CATCH_UNIQUE_NAME( catch_internal_Section ) = Catch::SectionInfo( CATCH_INTERNAL_LINEINFO, name, desc ) ) -#endif - -// #included from: internal/catch_generators.hpp -#define TWOBLUECUBES_CATCH_GENERATORS_HPP_INCLUDED - -#include -#include -#include - -namespace Catch { - -template -struct IGenerator { - virtual ~IGenerator() {} - virtual T getValue( std::size_t index ) const = 0; - virtual std::size_t size () const = 0; -}; - -template -class BetweenGenerator : public IGenerator { -public: - BetweenGenerator( T from, T to ) : m_from( from ), m_to( to ){} - - virtual T getValue( std::size_t index ) const { - return m_from+static_cast( index ); - } - - virtual std::size_t size() const { - return static_cast( 1+m_to-m_from ); - } - -private: - - T m_from; - T m_to; -}; - -template -class ValuesGenerator : public IGenerator { -public: - ValuesGenerator(){} - - void add( T value ) { - m_values.push_back( value ); - } - - virtual T getValue( std::size_t index ) const { - return m_values[index]; - } - - virtual std::size_t size() const { - return m_values.size(); - } - -private: - std::vector m_values; -}; - -template -class CompositeGenerator { -public: - CompositeGenerator() : m_totalSize( 0 ) {} - - // *** Move semantics, similar to auto_ptr *** - CompositeGenerator( CompositeGenerator& other ) - : m_fileInfo( other.m_fileInfo ), - m_totalSize( 0 ) - { - move( other ); - } - - CompositeGenerator& setFileInfo( const char* fileInfo ) { - m_fileInfo = fileInfo; - return *this; - } - - ~CompositeGenerator() { - deleteAll( m_composed ); - } - - operator T () const { - size_t overallIndex = getCurrentContext().getGeneratorIndex( m_fileInfo, m_totalSize ); - - typename std::vector*>::const_iterator it = m_composed.begin(); - typename std::vector*>::const_iterator itEnd = m_composed.end(); - for( size_t index = 0; it != itEnd; ++it ) - { - const IGenerator* generator = *it; - if( overallIndex >= index && overallIndex < index + generator->size() ) - { - return generator->getValue( overallIndex-index ); - } - index += generator->size(); - } - CATCH_INTERNAL_ERROR( "Indexed past end of generated range" ); - return T(); // Suppress spurious "not all control paths return a value" warning in Visual Studio - if you know how to fix this please do so - } - - void add( const IGenerator* generator ) { - m_totalSize += generator->size(); - m_composed.push_back( generator ); - } - - CompositeGenerator& then( CompositeGenerator& other ) { - move( other ); - return *this; - } - - CompositeGenerator& then( T value ) { - ValuesGenerator* valuesGen = new ValuesGenerator(); - valuesGen->add( value ); - add( valuesGen ); - return *this; - } - -private: - - void move( CompositeGenerator& other ) { - m_composed.insert( m_composed.end(), other.m_composed.begin(), other.m_composed.end() ); - m_totalSize += other.m_totalSize; - other.m_composed.clear(); - } - - std::vector*> m_composed; - std::string m_fileInfo; - size_t m_totalSize; -}; - -namespace Generators -{ - template - CompositeGenerator between( T from, T to ) { - CompositeGenerator generators; - generators.add( new BetweenGenerator( from, to ) ); - return generators; - } - - template - CompositeGenerator values( T val1, T val2 ) { - CompositeGenerator generators; - ValuesGenerator* valuesGen = new ValuesGenerator(); - valuesGen->add( val1 ); - valuesGen->add( val2 ); - generators.add( valuesGen ); - return generators; - } - - template - CompositeGenerator values( T val1, T val2, T val3 ){ - CompositeGenerator generators; - ValuesGenerator* valuesGen = new ValuesGenerator(); - valuesGen->add( val1 ); - valuesGen->add( val2 ); - valuesGen->add( val3 ); - generators.add( valuesGen ); - return generators; - } - - template - CompositeGenerator values( T val1, T val2, T val3, T val4 ) { - CompositeGenerator generators; - ValuesGenerator* valuesGen = new ValuesGenerator(); - valuesGen->add( val1 ); - valuesGen->add( val2 ); - valuesGen->add( val3 ); - valuesGen->add( val4 ); - generators.add( valuesGen ); - return generators; - } - -} // end namespace Generators - -using namespace Generators; - -} // end namespace Catch - -#define INTERNAL_CATCH_LINESTR2( line ) #line -#define INTERNAL_CATCH_LINESTR( line ) INTERNAL_CATCH_LINESTR2( line ) - -#define INTERNAL_CATCH_GENERATE( expr ) expr.setFileInfo( __FILE__ "(" INTERNAL_CATCH_LINESTR( __LINE__ ) ")" ) - -// #included from: internal/catch_interfaces_exception.h -#define TWOBLUECUBES_CATCH_INTERFACES_EXCEPTION_H_INCLUDED - -#include -#include - -// #included from: catch_interfaces_registry_hub.h -#define TWOBLUECUBES_CATCH_INTERFACES_REGISTRY_HUB_H_INCLUDED - -#include - -namespace Catch { - - class TestCase; - struct ITestCaseRegistry; - struct IExceptionTranslatorRegistry; - struct IExceptionTranslator; - struct IReporterRegistry; - struct IReporterFactory; - struct ITagAliasRegistry; - - struct IRegistryHub { - virtual ~IRegistryHub(); - - virtual IReporterRegistry const& getReporterRegistry() const = 0; - virtual ITestCaseRegistry const& getTestCaseRegistry() const = 0; - virtual ITagAliasRegistry const& getTagAliasRegistry() const = 0; - - virtual IExceptionTranslatorRegistry& getExceptionTranslatorRegistry() = 0; - }; - - struct IMutableRegistryHub { - virtual ~IMutableRegistryHub(); - virtual void registerReporter( std::string const& name, Ptr const& factory ) = 0; - virtual void registerListener( Ptr const& factory ) = 0; - virtual void registerTest( TestCase const& testInfo ) = 0; - virtual void registerTranslator( const IExceptionTranslator* translator ) = 0; - virtual void registerTagAlias( std::string const& alias, std::string const& tag, SourceLineInfo const& lineInfo ) = 0; - }; - - IRegistryHub& getRegistryHub(); - IMutableRegistryHub& getMutableRegistryHub(); - void cleanUp(); - std::string translateActiveException(); - -} - -namespace Catch { - - typedef std::string(*exceptionTranslateFunction)(); - - struct IExceptionTranslator; - typedef std::vector ExceptionTranslators; - - struct IExceptionTranslator { - virtual ~IExceptionTranslator(); - virtual std::string translate( ExceptionTranslators::const_iterator it, ExceptionTranslators::const_iterator itEnd ) const = 0; - }; - - struct IExceptionTranslatorRegistry { - virtual ~IExceptionTranslatorRegistry(); - - virtual std::string translateActiveException() const = 0; - }; - - class ExceptionTranslatorRegistrar { - template - class ExceptionTranslator : public IExceptionTranslator { - public: - - ExceptionTranslator( std::string(*translateFunction)( T& ) ) - : m_translateFunction( translateFunction ) - {} - - virtual std::string translate( ExceptionTranslators::const_iterator it, ExceptionTranslators::const_iterator itEnd ) const CATCH_OVERRIDE { - try { - if( it == itEnd ) - throw; - else - return (*it)->translate( it+1, itEnd ); - } - catch( T& ex ) { - return m_translateFunction( ex ); - } - } - - protected: - std::string(*m_translateFunction)( T& ); - }; - - public: - template - ExceptionTranslatorRegistrar( std::string(*translateFunction)( T& ) ) { - getMutableRegistryHub().registerTranslator - ( new ExceptionTranslator( translateFunction ) ); - } - }; -} - -/////////////////////////////////////////////////////////////////////////////// -#define INTERNAL_CATCH_TRANSLATE_EXCEPTION2( translatorName, signature ) \ - static std::string translatorName( signature ); \ - namespace{ Catch::ExceptionTranslatorRegistrar INTERNAL_CATCH_UNIQUE_NAME( catch_internal_ExceptionRegistrar )( &translatorName ); }\ - static std::string translatorName( signature ) - -#define INTERNAL_CATCH_TRANSLATE_EXCEPTION( signature ) INTERNAL_CATCH_TRANSLATE_EXCEPTION2( INTERNAL_CATCH_UNIQUE_NAME( catch_internal_ExceptionTranslator ), signature ) - -// #included from: internal/catch_approx.hpp -#define TWOBLUECUBES_CATCH_APPROX_HPP_INCLUDED - -#include -#include - -#if defined(CATCH_CONFIG_CPP11_TYPE_TRAITS) -#include -#endif - -namespace Catch { -namespace Detail { - - class Approx { - public: - explicit Approx ( double value ) - : m_epsilon( std::numeric_limits::epsilon()*100 ), - m_margin( 0.0 ), - m_scale( 1.0 ), - m_value( value ) - {} - - static Approx custom() { - return Approx( 0 ); - } - -#if defined(CATCH_CONFIG_CPP11_TYPE_TRAITS) - - template ::value>::type> - Approx operator()( T value ) { - Approx approx( static_cast(value) ); - approx.epsilon( m_epsilon ); - approx.margin( m_margin ); - approx.scale( m_scale ); - return approx; - } - - template ::value>::type> - explicit Approx( T value ): Approx(static_cast(value)) - {} - - template ::value>::type> - friend bool operator == ( const T& lhs, Approx const& rhs ) { - // Thanks to Richard Harris for his help refining this formula - auto lhs_v = double(lhs); - bool relativeOK = std::fabs(lhs_v - rhs.m_value) < rhs.m_epsilon * (rhs.m_scale + (std::max)(std::fabs(lhs_v), std::fabs(rhs.m_value))); - if (relativeOK) { - return true; - } - - return std::fabs(lhs_v - rhs.m_value) <= rhs.m_margin; - } - - template ::value>::type> - friend bool operator == ( Approx const& lhs, const T& rhs ) { - return operator==( rhs, lhs ); - } - - template ::value>::type> - friend bool operator != ( T lhs, Approx const& rhs ) { - return !operator==( lhs, rhs ); - } - - template ::value>::type> - friend bool operator != ( Approx const& lhs, T rhs ) { - return !operator==( rhs, lhs ); - } - - template ::value>::type> - friend bool operator <= ( T lhs, Approx const& rhs ) { - return double(lhs) < rhs.m_value || lhs == rhs; - } - - template ::value>::type> - friend bool operator <= ( Approx const& lhs, T rhs ) { - return lhs.m_value < double(rhs) || lhs == rhs; - } - - template ::value>::type> - friend bool operator >= ( T lhs, Approx const& rhs ) { - return double(lhs) > rhs.m_value || lhs == rhs; - } - - template ::value>::type> - friend bool operator >= ( Approx const& lhs, T rhs ) { - return lhs.m_value > double(rhs) || lhs == rhs; - } - - template ::value>::type> - Approx& epsilon( T newEpsilon ) { - m_epsilon = double(newEpsilon); - return *this; - } - - template ::value>::type> - Approx& margin( T newMargin ) { - m_margin = double(newMargin); - return *this; - } - - template ::value>::type> - Approx& scale( T newScale ) { - m_scale = double(newScale); - return *this; - } - -#else - - Approx operator()( double value ) { - Approx approx( value ); - approx.epsilon( m_epsilon ); - approx.margin( m_margin ); - approx.scale( m_scale ); - return approx; - } - - friend bool operator == ( double lhs, Approx const& rhs ) { - // Thanks to Richard Harris for his help refining this formula - bool relativeOK = std::fabs( lhs - rhs.m_value ) < rhs.m_epsilon * (rhs.m_scale + (std::max)( std::fabs(lhs), std::fabs(rhs.m_value) ) ); - if (relativeOK) { - return true; - } - return std::fabs(lhs - rhs.m_value) <= rhs.m_margin; - } - - friend bool operator == ( Approx const& lhs, double rhs ) { - return operator==( rhs, lhs ); - } - - friend bool operator != ( double lhs, Approx const& rhs ) { - return !operator==( lhs, rhs ); - } - - friend bool operator != ( Approx const& lhs, double rhs ) { - return !operator==( rhs, lhs ); - } - - friend bool operator <= ( double lhs, Approx const& rhs ) { - return lhs < rhs.m_value || lhs == rhs; - } - - friend bool operator <= ( Approx const& lhs, double rhs ) { - return lhs.m_value < rhs || lhs == rhs; - } - - friend bool operator >= ( double lhs, Approx const& rhs ) { - return lhs > rhs.m_value || lhs == rhs; - } - - friend bool operator >= ( Approx const& lhs, double rhs ) { - return lhs.m_value > rhs || lhs == rhs; - } - - Approx& epsilon( double newEpsilon ) { - m_epsilon = newEpsilon; - return *this; - } - - Approx& margin( double newMargin ) { - m_margin = newMargin; - return *this; - } - - Approx& scale( double newScale ) { - m_scale = newScale; - return *this; - } -#endif - - std::string toString() const { - std::ostringstream oss; - oss << "Approx( " << Catch::toString( m_value ) << " )"; - return oss.str(); - } - - private: - double m_epsilon; - double m_margin; - double m_scale; - double m_value; - }; -} - -template<> -inline std::string toString( Detail::Approx const& value ) { - return value.toString(); -} - -} // end namespace Catch - -// #included from: internal/catch_matchers_string.h -#define TWOBLUECUBES_CATCH_MATCHERS_STRING_H_INCLUDED - -namespace Catch { -namespace Matchers { - - namespace StdString { - - struct CasedString - { - CasedString( std::string const& str, CaseSensitive::Choice caseSensitivity ); - std::string adjustString( std::string const& str ) const; - std::string caseSensitivitySuffix() const; - - CaseSensitive::Choice m_caseSensitivity; - std::string m_str; - }; - - struct StringMatcherBase : MatcherBase { - StringMatcherBase( std::string const& operation, CasedString const& comparator ); - virtual std::string describe() const CATCH_OVERRIDE; - - CasedString m_comparator; - std::string m_operation; - }; - - struct EqualsMatcher : StringMatcherBase { - EqualsMatcher( CasedString const& comparator ); - virtual bool match( std::string const& source ) const CATCH_OVERRIDE; - }; - struct ContainsMatcher : StringMatcherBase { - ContainsMatcher( CasedString const& comparator ); - virtual bool match( std::string const& source ) const CATCH_OVERRIDE; - }; - struct StartsWithMatcher : StringMatcherBase { - StartsWithMatcher( CasedString const& comparator ); - virtual bool match( std::string const& source ) const CATCH_OVERRIDE; - }; - struct EndsWithMatcher : StringMatcherBase { - EndsWithMatcher( CasedString const& comparator ); - virtual bool match( std::string const& source ) const CATCH_OVERRIDE; - }; - - } // namespace StdString - - // The following functions create the actual matcher objects. - // This allows the types to be inferred - - StdString::EqualsMatcher Equals( std::string const& str, CaseSensitive::Choice caseSensitivity = CaseSensitive::Yes ); - StdString::ContainsMatcher Contains( std::string const& str, CaseSensitive::Choice caseSensitivity = CaseSensitive::Yes ); - StdString::EndsWithMatcher EndsWith( std::string const& str, CaseSensitive::Choice caseSensitivity = CaseSensitive::Yes ); - StdString::StartsWithMatcher StartsWith( std::string const& str, CaseSensitive::Choice caseSensitivity = CaseSensitive::Yes ); - -} // namespace Matchers -} // namespace Catch - -// #included from: internal/catch_matchers_vector.h -#define TWOBLUECUBES_CATCH_MATCHERS_VECTOR_H_INCLUDED - -namespace Catch { -namespace Matchers { - - namespace Vector { - - template - struct ContainsElementMatcher : MatcherBase, T> { - - ContainsElementMatcher(T const &comparator) : m_comparator( comparator) {} - - bool match(std::vector const &v) const CATCH_OVERRIDE { - return std::find(v.begin(), v.end(), m_comparator) != v.end(); - } - - virtual std::string describe() const CATCH_OVERRIDE { - return "Contains: " + Catch::toString( m_comparator ); - } - - T const& m_comparator; - }; - - template - struct ContainsMatcher : MatcherBase, std::vector > { - - ContainsMatcher(std::vector const &comparator) : m_comparator( comparator ) {} - - bool match(std::vector const &v) const CATCH_OVERRIDE { - // !TBD: see note in EqualsMatcher - if (m_comparator.size() > v.size()) - return false; - for (size_t i = 0; i < m_comparator.size(); ++i) - if (std::find(v.begin(), v.end(), m_comparator[i]) == v.end()) - return false; - return true; - } - virtual std::string describe() const CATCH_OVERRIDE { - return "Contains: " + Catch::toString( m_comparator ); - } - - std::vector const& m_comparator; - }; - - template - struct EqualsMatcher : MatcherBase, std::vector > { - - EqualsMatcher(std::vector const &comparator) : m_comparator( comparator ) {} - - bool match(std::vector const &v) const CATCH_OVERRIDE { - // !TBD: This currently works if all elements can be compared using != - // - a more general approach would be via a compare template that defaults - // to using !=. but could be specialised for, e.g. std::vector etc - // - then just call that directly - if (m_comparator.size() != v.size()) - return false; - for (size_t i = 0; i < v.size(); ++i) - if (m_comparator[i] != v[i]) - return false; - return true; - } - virtual std::string describe() const CATCH_OVERRIDE { - return "Equals: " + Catch::toString( m_comparator ); - } - std::vector const& m_comparator; - }; - - } // namespace Vector - - // The following functions create the actual matcher objects. - // This allows the types to be inferred - - template - Vector::ContainsMatcher Contains( std::vector const& comparator ) { - return Vector::ContainsMatcher( comparator ); - } - - template - Vector::ContainsElementMatcher VectorContains( T const& comparator ) { - return Vector::ContainsElementMatcher( comparator ); - } - - template - Vector::EqualsMatcher Equals( std::vector const& comparator ) { - return Vector::EqualsMatcher( comparator ); - } - -} // namespace Matchers -} // namespace Catch - -// #included from: internal/catch_interfaces_tag_alias_registry.h -#define TWOBLUECUBES_CATCH_INTERFACES_TAG_ALIAS_REGISTRY_H_INCLUDED - -// #included from: catch_tag_alias.h -#define TWOBLUECUBES_CATCH_TAG_ALIAS_H_INCLUDED - -#include - -namespace Catch { - - struct TagAlias { - TagAlias( std::string const& _tag, SourceLineInfo _lineInfo ) : tag( _tag ), lineInfo( _lineInfo ) {} - - std::string tag; - SourceLineInfo lineInfo; - }; - - struct RegistrarForTagAliases { - RegistrarForTagAliases( char const* alias, char const* tag, SourceLineInfo const& lineInfo ); - }; - -} // end namespace Catch - -#define CATCH_REGISTER_TAG_ALIAS( alias, spec ) namespace{ Catch::RegistrarForTagAliases INTERNAL_CATCH_UNIQUE_NAME( AutoRegisterTagAlias )( alias, spec, CATCH_INTERNAL_LINEINFO ); } -// #included from: catch_option.hpp -#define TWOBLUECUBES_CATCH_OPTION_HPP_INCLUDED - -namespace Catch { - - // An optional type - template - class Option { - public: - Option() : nullableValue( CATCH_NULL ) {} - Option( T const& _value ) - : nullableValue( new( storage ) T( _value ) ) - {} - Option( Option const& _other ) - : nullableValue( _other ? new( storage ) T( *_other ) : CATCH_NULL ) - {} - - ~Option() { - reset(); - } - - Option& operator= ( Option const& _other ) { - if( &_other != this ) { - reset(); - if( _other ) - nullableValue = new( storage ) T( *_other ); - } - return *this; - } - Option& operator = ( T const& _value ) { - reset(); - nullableValue = new( storage ) T( _value ); - return *this; - } - - void reset() { - if( nullableValue ) - nullableValue->~T(); - nullableValue = CATCH_NULL; - } - - T& operator*() { return *nullableValue; } - T const& operator*() const { return *nullableValue; } - T* operator->() { return nullableValue; } - const T* operator->() const { return nullableValue; } - - T valueOr( T const& defaultValue ) const { - return nullableValue ? *nullableValue : defaultValue; - } - - bool some() const { return nullableValue != CATCH_NULL; } - bool none() const { return nullableValue == CATCH_NULL; } - - bool operator !() const { return nullableValue == CATCH_NULL; } - operator SafeBool::type() const { - return SafeBool::makeSafe( some() ); - } - - private: - T *nullableValue; - union { - char storage[sizeof(T)]; - - // These are here to force alignment for the storage - long double dummy1; - void (*dummy2)(); - long double dummy3; -#ifdef CATCH_CONFIG_CPP11_LONG_LONG - long long dummy4; -#endif - }; - }; - -} // end namespace Catch - -namespace Catch { - - struct ITagAliasRegistry { - virtual ~ITagAliasRegistry(); - virtual Option find( std::string const& alias ) const = 0; - virtual std::string expandAliases( std::string const& unexpandedTestSpec ) const = 0; - - static ITagAliasRegistry const& get(); - }; - -} // end namespace Catch - -// These files are included here so the single_include script doesn't put them -// in the conditionally compiled sections -// #included from: internal/catch_test_case_info.h -#define TWOBLUECUBES_CATCH_TEST_CASE_INFO_H_INCLUDED - -#include -#include - -#ifdef __clang__ -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wpadded" -#endif - -namespace Catch { - - struct ITestCase; - - struct TestCaseInfo { - enum SpecialProperties{ - None = 0, - IsHidden = 1 << 1, - ShouldFail = 1 << 2, - MayFail = 1 << 3, - Throws = 1 << 4, - NonPortable = 1 << 5 - }; - - TestCaseInfo( std::string const& _name, - std::string const& _className, - std::string const& _description, - std::set const& _tags, - SourceLineInfo const& _lineInfo ); - - TestCaseInfo( TestCaseInfo const& other ); - - friend void setTags( TestCaseInfo& testCaseInfo, std::set const& tags ); - - bool isHidden() const; - bool throws() const; - bool okToFail() const; - bool expectedToFail() const; - - std::string name; - std::string className; - std::string description; - std::set tags; - std::set lcaseTags; - std::string tagsAsString; - SourceLineInfo lineInfo; - SpecialProperties properties; - }; - - class TestCase : public TestCaseInfo { - public: - - TestCase( ITestCase* testCase, TestCaseInfo const& info ); - TestCase( TestCase const& other ); - - TestCase withName( std::string const& _newName ) const; - - void invoke() const; - - TestCaseInfo const& getTestCaseInfo() const; - - void swap( TestCase& other ); - bool operator == ( TestCase const& other ) const; - bool operator < ( TestCase const& other ) const; - TestCase& operator = ( TestCase const& other ); - - private: - Ptr test; - }; - - TestCase makeTestCase( ITestCase* testCase, - std::string const& className, - std::string const& name, - std::string const& description, - SourceLineInfo const& lineInfo ); -} - -#ifdef __clang__ -#pragma clang diagnostic pop -#endif - - -#ifdef __OBJC__ -// #included from: internal/catch_objc.hpp -#define TWOBLUECUBES_CATCH_OBJC_HPP_INCLUDED - -#import - -#include - -// NB. Any general catch headers included here must be included -// in catch.hpp first to make sure they are included by the single -// header for non obj-usage - -/////////////////////////////////////////////////////////////////////////////// -// This protocol is really only here for (self) documenting purposes, since -// all its methods are optional. -@protocol OcFixture - -@optional - --(void) setUp; --(void) tearDown; - -@end - -namespace Catch { - - class OcMethod : public SharedImpl { - - public: - OcMethod( Class cls, SEL sel ) : m_cls( cls ), m_sel( sel ) {} - - virtual void invoke() const { - id obj = [[m_cls alloc] init]; - - performOptionalSelector( obj, @selector(setUp) ); - performOptionalSelector( obj, m_sel ); - performOptionalSelector( obj, @selector(tearDown) ); - - arcSafeRelease( obj ); - } - private: - virtual ~OcMethod() {} - - Class m_cls; - SEL m_sel; - }; - - namespace Detail{ - - inline std::string getAnnotation( Class cls, - std::string const& annotationName, - std::string const& testCaseName ) { - NSString* selStr = [[NSString alloc] initWithFormat:@"Catch_%s_%s", annotationName.c_str(), testCaseName.c_str()]; - SEL sel = NSSelectorFromString( selStr ); - arcSafeRelease( selStr ); - id value = performOptionalSelector( cls, sel ); - if( value ) - return [(NSString*)value UTF8String]; - return ""; - } - } - - inline size_t registerTestMethods() { - size_t noTestMethods = 0; - int noClasses = objc_getClassList( CATCH_NULL, 0 ); - - Class* classes = (CATCH_UNSAFE_UNRETAINED Class *)malloc( sizeof(Class) * noClasses); - objc_getClassList( classes, noClasses ); - - for( int c = 0; c < noClasses; c++ ) { - Class cls = classes[c]; - { - u_int count; - Method* methods = class_copyMethodList( cls, &count ); - for( u_int m = 0; m < count ; m++ ) { - SEL selector = method_getName(methods[m]); - std::string methodName = sel_getName(selector); - if( startsWith( methodName, "Catch_TestCase_" ) ) { - std::string testCaseName = methodName.substr( 15 ); - std::string name = Detail::getAnnotation( cls, "Name", testCaseName ); - std::string desc = Detail::getAnnotation( cls, "Description", testCaseName ); - const char* className = class_getName( cls ); - - getMutableRegistryHub().registerTest( makeTestCase( new OcMethod( cls, selector ), className, name.c_str(), desc.c_str(), SourceLineInfo() ) ); - noTestMethods++; - } - } - free(methods); - } - } - return noTestMethods; - } - - namespace Matchers { - namespace Impl { - namespace NSStringMatchers { - - struct StringHolder : MatcherBase{ - StringHolder( NSString* substr ) : m_substr( [substr copy] ){} - StringHolder( StringHolder const& other ) : m_substr( [other.m_substr copy] ){} - StringHolder() { - arcSafeRelease( m_substr ); - } - - virtual bool match( NSString* arg ) const CATCH_OVERRIDE { - return false; - } - - NSString* m_substr; - }; - - struct Equals : StringHolder { - Equals( NSString* substr ) : StringHolder( substr ){} - - virtual bool match( NSString* str ) const CATCH_OVERRIDE { - return (str != nil || m_substr == nil ) && - [str isEqualToString:m_substr]; - } - - virtual std::string describe() const CATCH_OVERRIDE { - return "equals string: " + Catch::toString( m_substr ); - } - }; - - struct Contains : StringHolder { - Contains( NSString* substr ) : StringHolder( substr ){} - - virtual bool match( NSString* str ) const { - return (str != nil || m_substr == nil ) && - [str rangeOfString:m_substr].location != NSNotFound; - } - - virtual std::string describe() const CATCH_OVERRIDE { - return "contains string: " + Catch::toString( m_substr ); - } - }; - - struct StartsWith : StringHolder { - StartsWith( NSString* substr ) : StringHolder( substr ){} - - virtual bool match( NSString* str ) const { - return (str != nil || m_substr == nil ) && - [str rangeOfString:m_substr].location == 0; - } - - virtual std::string describe() const CATCH_OVERRIDE { - return "starts with: " + Catch::toString( m_substr ); - } - }; - struct EndsWith : StringHolder { - EndsWith( NSString* substr ) : StringHolder( substr ){} - - virtual bool match( NSString* str ) const { - return (str != nil || m_substr == nil ) && - [str rangeOfString:m_substr].location == [str length] - [m_substr length]; - } - - virtual std::string describe() const CATCH_OVERRIDE { - return "ends with: " + Catch::toString( m_substr ); - } - }; - - } // namespace NSStringMatchers - } // namespace Impl - - inline Impl::NSStringMatchers::Equals - Equals( NSString* substr ){ return Impl::NSStringMatchers::Equals( substr ); } - - inline Impl::NSStringMatchers::Contains - Contains( NSString* substr ){ return Impl::NSStringMatchers::Contains( substr ); } - - inline Impl::NSStringMatchers::StartsWith - StartsWith( NSString* substr ){ return Impl::NSStringMatchers::StartsWith( substr ); } - - inline Impl::NSStringMatchers::EndsWith - EndsWith( NSString* substr ){ return Impl::NSStringMatchers::EndsWith( substr ); } - - } // namespace Matchers - - using namespace Matchers; - -} // namespace Catch - -/////////////////////////////////////////////////////////////////////////////// -#define OC_TEST_CASE( name, desc )\ -+(NSString*) INTERNAL_CATCH_UNIQUE_NAME( Catch_Name_test ) \ -{\ -return @ name; \ -}\ -+(NSString*) INTERNAL_CATCH_UNIQUE_NAME( Catch_Description_test ) \ -{ \ -return @ desc; \ -} \ --(void) INTERNAL_CATCH_UNIQUE_NAME( Catch_TestCase_test ) - -#endif - -#ifdef CATCH_IMPL - -// !TBD: Move the leak detector code into a separate header -#ifdef CATCH_CONFIG_WINDOWS_CRTDBG -#include -class LeakDetector { -public: - LeakDetector() { - int flag = _CrtSetDbgFlag(_CRTDBG_REPORT_FLAG); - flag |= _CRTDBG_LEAK_CHECK_DF; - flag |= _CRTDBG_ALLOC_MEM_DF; - _CrtSetDbgFlag(flag); - _CrtSetReportMode(_CRT_WARN, _CRTDBG_MODE_FILE | _CRTDBG_MODE_DEBUG); - _CrtSetReportFile(_CRT_WARN, _CRTDBG_FILE_STDERR); - // Change this to leaking allocation's number to break there - _CrtSetBreakAlloc(-1); - } -}; -#else -class LeakDetector {}; -#endif - -LeakDetector leakDetector; - -// #included from: internal/catch_impl.hpp -#define TWOBLUECUBES_CATCH_IMPL_HPP_INCLUDED - -// Collect all the implementation files together here -// These are the equivalent of what would usually be cpp files - -#ifdef __clang__ -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wweak-vtables" -#endif - -// #included from: ../catch_session.hpp -#define TWOBLUECUBES_CATCH_RUNNER_HPP_INCLUDED - -// #included from: internal/catch_commandline.hpp -#define TWOBLUECUBES_CATCH_COMMANDLINE_HPP_INCLUDED - -// #included from: catch_config.hpp -#define TWOBLUECUBES_CATCH_CONFIG_HPP_INCLUDED - -// #included from: catch_test_spec_parser.hpp -#define TWOBLUECUBES_CATCH_TEST_SPEC_PARSER_HPP_INCLUDED - -#ifdef __clang__ -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wpadded" -#endif - -// #included from: catch_test_spec.hpp -#define TWOBLUECUBES_CATCH_TEST_SPEC_HPP_INCLUDED - -#ifdef __clang__ -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wpadded" -#endif - -// #included from: catch_wildcard_pattern.hpp -#define TWOBLUECUBES_CATCH_WILDCARD_PATTERN_HPP_INCLUDED - -#include - -namespace Catch -{ - class WildcardPattern { - enum WildcardPosition { - NoWildcard = 0, - WildcardAtStart = 1, - WildcardAtEnd = 2, - WildcardAtBothEnds = WildcardAtStart | WildcardAtEnd - }; - - public: - - WildcardPattern( std::string const& pattern, CaseSensitive::Choice caseSensitivity ) - : m_caseSensitivity( caseSensitivity ), - m_wildcard( NoWildcard ), - m_pattern( adjustCase( pattern ) ) - { - if( startsWith( m_pattern, '*' ) ) { - m_pattern = m_pattern.substr( 1 ); - m_wildcard = WildcardAtStart; - } - if( endsWith( m_pattern, '*' ) ) { - m_pattern = m_pattern.substr( 0, m_pattern.size()-1 ); - m_wildcard = static_cast( m_wildcard | WildcardAtEnd ); - } - } - virtual ~WildcardPattern(); - virtual bool matches( std::string const& str ) const { - switch( m_wildcard ) { - case NoWildcard: - return m_pattern == adjustCase( str ); - case WildcardAtStart: - return endsWith( adjustCase( str ), m_pattern ); - case WildcardAtEnd: - return startsWith( adjustCase( str ), m_pattern ); - case WildcardAtBothEnds: - return contains( adjustCase( str ), m_pattern ); - } - -#ifdef __clang__ -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wunreachable-code" -#endif - throw std::logic_error( "Unknown enum" ); -#ifdef __clang__ -#pragma clang diagnostic pop -#endif - } - private: - std::string adjustCase( std::string const& str ) const { - return m_caseSensitivity == CaseSensitive::No ? toLower( str ) : str; - } - CaseSensitive::Choice m_caseSensitivity; - WildcardPosition m_wildcard; - std::string m_pattern; - }; -} - -#include -#include - -namespace Catch { - - class TestSpec { - struct Pattern : SharedImpl<> { - virtual ~Pattern(); - virtual bool matches( TestCaseInfo const& testCase ) const = 0; - }; - class NamePattern : public Pattern { - public: - NamePattern( std::string const& name ) - : m_wildcardPattern( toLower( name ), CaseSensitive::No ) - {} - virtual ~NamePattern(); - virtual bool matches( TestCaseInfo const& testCase ) const { - return m_wildcardPattern.matches( toLower( testCase.name ) ); - } - private: - WildcardPattern m_wildcardPattern; - }; - - class TagPattern : public Pattern { - public: - TagPattern( std::string const& tag ) : m_tag( toLower( tag ) ) {} - virtual ~TagPattern(); - virtual bool matches( TestCaseInfo const& testCase ) const { - return testCase.lcaseTags.find( m_tag ) != testCase.lcaseTags.end(); - } - private: - std::string m_tag; - }; - - class ExcludedPattern : public Pattern { - public: - ExcludedPattern( Ptr const& underlyingPattern ) : m_underlyingPattern( underlyingPattern ) {} - virtual ~ExcludedPattern(); - virtual bool matches( TestCaseInfo const& testCase ) const { return !m_underlyingPattern->matches( testCase ); } - private: - Ptr m_underlyingPattern; - }; - - struct Filter { - std::vector > m_patterns; - - bool matches( TestCaseInfo const& testCase ) const { - // All patterns in a filter must match for the filter to be a match - for( std::vector >::const_iterator it = m_patterns.begin(), itEnd = m_patterns.end(); it != itEnd; ++it ) { - if( !(*it)->matches( testCase ) ) - return false; - } - return true; - } - }; - - public: - bool hasFilters() const { - return !m_filters.empty(); - } - bool matches( TestCaseInfo const& testCase ) const { - // A TestSpec matches if any filter matches - for( std::vector::const_iterator it = m_filters.begin(), itEnd = m_filters.end(); it != itEnd; ++it ) - if( it->matches( testCase ) ) - return true; - return false; - } - - private: - std::vector m_filters; - - friend class TestSpecParser; - }; -} - -#ifdef __clang__ -#pragma clang diagnostic pop -#endif - -namespace Catch { - - class TestSpecParser { - enum Mode{ None, Name, QuotedName, Tag, EscapedName }; - Mode m_mode; - bool m_exclusion; - std::size_t m_start, m_pos; - std::string m_arg; - std::vector m_escapeChars; - TestSpec::Filter m_currentFilter; - TestSpec m_testSpec; - ITagAliasRegistry const* m_tagAliases; - - public: - TestSpecParser( ITagAliasRegistry const& tagAliases ) :m_mode(None), m_exclusion(false), m_start(0), m_pos(0), m_tagAliases( &tagAliases ) {} - - TestSpecParser& parse( std::string const& arg ) { - m_mode = None; - m_exclusion = false; - m_start = std::string::npos; - m_arg = m_tagAliases->expandAliases( arg ); - m_escapeChars.clear(); - for( m_pos = 0; m_pos < m_arg.size(); ++m_pos ) - visitChar( m_arg[m_pos] ); - if( m_mode == Name ) - addPattern(); - return *this; - } - TestSpec testSpec() { - addFilter(); - return m_testSpec; - } - private: - void visitChar( char c ) { - if( m_mode == None ) { - switch( c ) { - case ' ': return; - case '~': m_exclusion = true; return; - case '[': return startNewMode( Tag, ++m_pos ); - case '"': return startNewMode( QuotedName, ++m_pos ); - case '\\': return escape(); - default: startNewMode( Name, m_pos ); break; - } - } - if( m_mode == Name ) { - if( c == ',' ) { - addPattern(); - addFilter(); - } - else if( c == '[' ) { - if( subString() == "exclude:" ) - m_exclusion = true; - else - addPattern(); - startNewMode( Tag, ++m_pos ); - } - else if( c == '\\' ) - escape(); - } - else if( m_mode == EscapedName ) - m_mode = Name; - else if( m_mode == QuotedName && c == '"' ) - addPattern(); - else if( m_mode == Tag && c == ']' ) - addPattern(); - } - void startNewMode( Mode mode, std::size_t start ) { - m_mode = mode; - m_start = start; - } - void escape() { - if( m_mode == None ) - m_start = m_pos; - m_mode = EscapedName; - m_escapeChars.push_back( m_pos ); - } - std::string subString() const { return m_arg.substr( m_start, m_pos - m_start ); } - template - void addPattern() { - std::string token = subString(); - for( size_t i = 0; i < m_escapeChars.size(); ++i ) - token = token.substr( 0, m_escapeChars[i]-m_start-i ) + token.substr( m_escapeChars[i]-m_start-i+1 ); - m_escapeChars.clear(); - if( startsWith( token, "exclude:" ) ) { - m_exclusion = true; - token = token.substr( 8 ); - } - if( !token.empty() ) { - Ptr pattern = new T( token ); - if( m_exclusion ) - pattern = new TestSpec::ExcludedPattern( pattern ); - m_currentFilter.m_patterns.push_back( pattern ); - } - m_exclusion = false; - m_mode = None; - } - void addFilter() { - if( !m_currentFilter.m_patterns.empty() ) { - m_testSpec.m_filters.push_back( m_currentFilter ); - m_currentFilter = TestSpec::Filter(); - } - } - }; - inline TestSpec parseTestSpec( std::string const& arg ) { - return TestSpecParser( ITagAliasRegistry::get() ).parse( arg ).testSpec(); - } - -} // namespace Catch - -#ifdef __clang__ -#pragma clang diagnostic pop -#endif - -// #included from: catch_interfaces_config.h -#define TWOBLUECUBES_CATCH_INTERFACES_CONFIG_H_INCLUDED - -#include -#include -#include - -namespace Catch { - - struct Verbosity { enum Level { - NoOutput = 0, - Quiet, - Normal - }; }; - - struct WarnAbout { enum What { - Nothing = 0x00, - NoAssertions = 0x01 - }; }; - - struct ShowDurations { enum OrNot { - DefaultForReporter, - Always, - Never - }; }; - struct RunTests { enum InWhatOrder { - InDeclarationOrder, - InLexicographicalOrder, - InRandomOrder - }; }; - struct UseColour { enum YesOrNo { - Auto, - Yes, - No - }; }; - struct WaitForKeypress { enum When { - Never, - BeforeStart = 1, - BeforeExit = 2, - BeforeStartAndExit = BeforeStart | BeforeExit - }; }; - - class TestSpec; - - struct IConfig : IShared { - - virtual ~IConfig(); - - virtual bool allowThrows() const = 0; - virtual std::ostream& stream() const = 0; - virtual std::string name() const = 0; - virtual bool includeSuccessfulResults() const = 0; - virtual bool shouldDebugBreak() const = 0; - virtual bool warnAboutMissingAssertions() const = 0; - virtual int abortAfter() const = 0; - virtual bool showInvisibles() const = 0; - virtual ShowDurations::OrNot showDurations() const = 0; - virtual TestSpec const& testSpec() const = 0; - virtual RunTests::InWhatOrder runOrder() const = 0; - virtual unsigned int rngSeed() const = 0; - virtual UseColour::YesOrNo useColour() const = 0; - virtual std::vector const& getSectionsToRun() const = 0; - - }; -} - -// #included from: catch_stream.h -#define TWOBLUECUBES_CATCH_STREAM_H_INCLUDED - -// #included from: catch_streambuf.h -#define TWOBLUECUBES_CATCH_STREAMBUF_H_INCLUDED - -#include - -namespace Catch { - - class StreamBufBase : public std::streambuf { - public: - virtual ~StreamBufBase() CATCH_NOEXCEPT; - }; -} - -#include -#include -#include -#include - -namespace Catch { - - std::ostream& cout(); - std::ostream& cerr(); - std::ostream& clog(); - - struct IStream { - virtual ~IStream() CATCH_NOEXCEPT; - virtual std::ostream& stream() const = 0; - }; - - class FileStream : public IStream { - mutable std::ofstream m_ofs; - public: - FileStream( std::string const& filename ); - virtual ~FileStream() CATCH_NOEXCEPT; - public: // IStream - virtual std::ostream& stream() const CATCH_OVERRIDE; - }; - - class CoutStream : public IStream { - mutable std::ostream m_os; - public: - CoutStream(); - virtual ~CoutStream() CATCH_NOEXCEPT; - - public: // IStream - virtual std::ostream& stream() const CATCH_OVERRIDE; - }; - - class DebugOutStream : public IStream { - CATCH_AUTO_PTR( StreamBufBase ) m_streamBuf; - mutable std::ostream m_os; - public: - DebugOutStream(); - virtual ~DebugOutStream() CATCH_NOEXCEPT; - - public: // IStream - virtual std::ostream& stream() const CATCH_OVERRIDE; - }; -} - -#include -#include -#include -#include - -#ifndef CATCH_CONFIG_CONSOLE_WIDTH -#define CATCH_CONFIG_CONSOLE_WIDTH 80 -#endif - -namespace Catch { - - struct ConfigData { - - ConfigData() - : listTests( false ), - listTags( false ), - listReporters( false ), - listTestNamesOnly( false ), - listExtraInfo( false ), - showSuccessfulTests( false ), - shouldDebugBreak( false ), - noThrow( false ), - showHelp( false ), - showInvisibles( false ), - filenamesAsTags( false ), - libIdentify( false ), - abortAfter( -1 ), - rngSeed( 0 ), - verbosity( Verbosity::Normal ), - warnings( WarnAbout::Nothing ), - showDurations( ShowDurations::DefaultForReporter ), - runOrder( RunTests::InDeclarationOrder ), - useColour( UseColour::Auto ), - waitForKeypress( WaitForKeypress::Never ) - {} - - bool listTests; - bool listTags; - bool listReporters; - bool listTestNamesOnly; - bool listExtraInfo; - - bool showSuccessfulTests; - bool shouldDebugBreak; - bool noThrow; - bool showHelp; - bool showInvisibles; - bool filenamesAsTags; - bool libIdentify; - - int abortAfter; - unsigned int rngSeed; - - Verbosity::Level verbosity; - WarnAbout::What warnings; - ShowDurations::OrNot showDurations; - RunTests::InWhatOrder runOrder; - UseColour::YesOrNo useColour; - WaitForKeypress::When waitForKeypress; - - std::string outputFilename; - std::string name; - std::string processName; - - std::vector reporterNames; - std::vector testsOrTags; - std::vector sectionsToRun; - }; - - class Config : public SharedImpl { - private: - Config( Config const& other ); - Config& operator = ( Config const& other ); - virtual void dummy(); - public: - - Config() - {} - - Config( ConfigData const& data ) - : m_data( data ), - m_stream( openStream() ) - { - if( !data.testsOrTags.empty() ) { - TestSpecParser parser( ITagAliasRegistry::get() ); - for( std::size_t i = 0; i < data.testsOrTags.size(); ++i ) - parser.parse( data.testsOrTags[i] ); - m_testSpec = parser.testSpec(); - } - } - - virtual ~Config() {} - - std::string const& getFilename() const { - return m_data.outputFilename ; - } - - bool listTests() const { return m_data.listTests; } - bool listTestNamesOnly() const { return m_data.listTestNamesOnly; } - bool listTags() const { return m_data.listTags; } - bool listReporters() const { return m_data.listReporters; } - bool listExtraInfo() const { return m_data.listExtraInfo; } - - std::string getProcessName() const { return m_data.processName; } - - std::vector const& getReporterNames() const { return m_data.reporterNames; } - std::vector const& getSectionsToRun() const CATCH_OVERRIDE { return m_data.sectionsToRun; } - - virtual TestSpec const& testSpec() const CATCH_OVERRIDE { return m_testSpec; } - - bool showHelp() const { return m_data.showHelp; } - - // IConfig interface - virtual bool allowThrows() const CATCH_OVERRIDE { return !m_data.noThrow; } - virtual std::ostream& stream() const CATCH_OVERRIDE { return m_stream->stream(); } - virtual std::string name() const CATCH_OVERRIDE { return m_data.name.empty() ? m_data.processName : m_data.name; } - virtual bool includeSuccessfulResults() const CATCH_OVERRIDE { return m_data.showSuccessfulTests; } - virtual bool warnAboutMissingAssertions() const CATCH_OVERRIDE { return m_data.warnings & WarnAbout::NoAssertions; } - virtual ShowDurations::OrNot showDurations() const CATCH_OVERRIDE { return m_data.showDurations; } - virtual RunTests::InWhatOrder runOrder() const CATCH_OVERRIDE { return m_data.runOrder; } - virtual unsigned int rngSeed() const CATCH_OVERRIDE { return m_data.rngSeed; } - virtual UseColour::YesOrNo useColour() const CATCH_OVERRIDE { return m_data.useColour; } - virtual bool shouldDebugBreak() const CATCH_OVERRIDE { return m_data.shouldDebugBreak; } - virtual int abortAfter() const CATCH_OVERRIDE { return m_data.abortAfter; } - virtual bool showInvisibles() const CATCH_OVERRIDE { return m_data.showInvisibles; } - - private: - - IStream const* openStream() { - if( m_data.outputFilename.empty() ) - return new CoutStream(); - else if( m_data.outputFilename[0] == '%' ) { - if( m_data.outputFilename == "%debug" ) - return new DebugOutStream(); - else - throw std::domain_error( "Unrecognised stream: " + m_data.outputFilename ); - } - else - return new FileStream( m_data.outputFilename ); - } - ConfigData m_data; - - CATCH_AUTO_PTR( IStream const ) m_stream; - TestSpec m_testSpec; - }; - -} // end namespace Catch - -// #included from: catch_clara.h -#define TWOBLUECUBES_CATCH_CLARA_H_INCLUDED - -// Use Catch's value for console width (store Clara's off to the side, if present) -#ifdef CLARA_CONFIG_CONSOLE_WIDTH -#define CATCH_TEMP_CLARA_CONFIG_CONSOLE_WIDTH CLARA_CONFIG_CONSOLE_WIDTH -#undef CLARA_CONFIG_CONSOLE_WIDTH -#endif -#define CLARA_CONFIG_CONSOLE_WIDTH CATCH_CONFIG_CONSOLE_WIDTH - -// Declare Clara inside the Catch namespace -#define STITCH_CLARA_OPEN_NAMESPACE namespace Catch { -// #included from: ../external/clara.h - -// Version 0.0.2.4 - -// Only use header guard if we are not using an outer namespace -#if !defined(TWOBLUECUBES_CLARA_H_INCLUDED) || defined(STITCH_CLARA_OPEN_NAMESPACE) - -#ifndef STITCH_CLARA_OPEN_NAMESPACE -#define TWOBLUECUBES_CLARA_H_INCLUDED -#define STITCH_CLARA_OPEN_NAMESPACE -#define STITCH_CLARA_CLOSE_NAMESPACE -#else -#define STITCH_CLARA_CLOSE_NAMESPACE } -#endif - -#define STITCH_TBC_TEXT_FORMAT_OPEN_NAMESPACE STITCH_CLARA_OPEN_NAMESPACE - -// ----------- #included from tbc_text_format.h ----------- - -// Only use header guard if we are not using an outer namespace -#if !defined(TBC_TEXT_FORMAT_H_INCLUDED) || defined(STITCH_TBC_TEXT_FORMAT_OUTER_NAMESPACE) -#ifndef STITCH_TBC_TEXT_FORMAT_OUTER_NAMESPACE -#define TBC_TEXT_FORMAT_H_INCLUDED -#endif - -#include -#include -#include -#include -#include - -// Use optional outer namespace -#ifdef STITCH_TBC_TEXT_FORMAT_OUTER_NAMESPACE -namespace STITCH_TBC_TEXT_FORMAT_OUTER_NAMESPACE { -#endif - -namespace Tbc { - -#ifdef TBC_TEXT_FORMAT_CONSOLE_WIDTH - const unsigned int consoleWidth = TBC_TEXT_FORMAT_CONSOLE_WIDTH; -#else - const unsigned int consoleWidth = 80; -#endif - - struct TextAttributes { - TextAttributes() - : initialIndent( std::string::npos ), - indent( 0 ), - width( consoleWidth-1 ), - tabChar( '\t' ) - {} - - TextAttributes& setInitialIndent( std::size_t _value ) { initialIndent = _value; return *this; } - TextAttributes& setIndent( std::size_t _value ) { indent = _value; return *this; } - TextAttributes& setWidth( std::size_t _value ) { width = _value; return *this; } - TextAttributes& setTabChar( char _value ) { tabChar = _value; return *this; } - - std::size_t initialIndent; // indent of first line, or npos - std::size_t indent; // indent of subsequent lines, or all if initialIndent is npos - std::size_t width; // maximum width of text, including indent. Longer text will wrap - char tabChar; // If this char is seen the indent is changed to current pos - }; - - class Text { - public: - Text( std::string const& _str, TextAttributes const& _attr = TextAttributes() ) - : attr( _attr ) - { - std::string wrappableChars = " [({.,/|\\-"; - std::size_t indent = _attr.initialIndent != std::string::npos - ? _attr.initialIndent - : _attr.indent; - std::string remainder = _str; - - while( !remainder.empty() ) { - if( lines.size() >= 1000 ) { - lines.push_back( "... message truncated due to excessive size" ); - return; - } - std::size_t tabPos = std::string::npos; - std::size_t width = (std::min)( remainder.size(), _attr.width - indent ); - std::size_t pos = remainder.find_first_of( '\n' ); - if( pos <= width ) { - width = pos; - } - pos = remainder.find_last_of( _attr.tabChar, width ); - if( pos != std::string::npos ) { - tabPos = pos; - if( remainder[width] == '\n' ) - width--; - remainder = remainder.substr( 0, tabPos ) + remainder.substr( tabPos+1 ); - } - - if( width == remainder.size() ) { - spliceLine( indent, remainder, width ); - } - else if( remainder[width] == '\n' ) { - spliceLine( indent, remainder, width ); - if( width <= 1 || remainder.size() != 1 ) - remainder = remainder.substr( 1 ); - indent = _attr.indent; - } - else { - pos = remainder.find_last_of( wrappableChars, width ); - if( pos != std::string::npos && pos > 0 ) { - spliceLine( indent, remainder, pos ); - if( remainder[0] == ' ' ) - remainder = remainder.substr( 1 ); - } - else { - spliceLine( indent, remainder, width-1 ); - lines.back() += "-"; - } - if( lines.size() == 1 ) - indent = _attr.indent; - if( tabPos != std::string::npos ) - indent += tabPos; - } - } - } - - void spliceLine( std::size_t _indent, std::string& _remainder, std::size_t _pos ) { - lines.push_back( std::string( _indent, ' ' ) + _remainder.substr( 0, _pos ) ); - _remainder = _remainder.substr( _pos ); - } - - typedef std::vector::const_iterator const_iterator; - - const_iterator begin() const { return lines.begin(); } - const_iterator end() const { return lines.end(); } - std::string const& last() const { return lines.back(); } - std::size_t size() const { return lines.size(); } - std::string const& operator[]( std::size_t _index ) const { return lines[_index]; } - std::string toString() const { - std::ostringstream oss; - oss << *this; - return oss.str(); - } - - friend std::ostream& operator << ( std::ostream& _stream, Text const& _text ) { - for( Text::const_iterator it = _text.begin(), itEnd = _text.end(); - it != itEnd; ++it ) { - if( it != _text.begin() ) - _stream << "\n"; - _stream << *it; - } - return _stream; - } - - private: - std::string str; - TextAttributes attr; - std::vector lines; - }; - -} // end namespace Tbc - -#ifdef STITCH_TBC_TEXT_FORMAT_OUTER_NAMESPACE -} // end outer namespace -#endif - -#endif // TBC_TEXT_FORMAT_H_INCLUDED - -// ----------- end of #include from tbc_text_format.h ----------- -// ........... back in clara.h - -#undef STITCH_TBC_TEXT_FORMAT_OPEN_NAMESPACE - -// ----------- #included from clara_compilers.h ----------- - -#ifndef TWOBLUECUBES_CLARA_COMPILERS_H_INCLUDED -#define TWOBLUECUBES_CLARA_COMPILERS_H_INCLUDED - -// Detect a number of compiler features - mostly C++11/14 conformance - by compiler -// The following features are defined: -// -// CLARA_CONFIG_CPP11_NULLPTR : is nullptr supported? -// CLARA_CONFIG_CPP11_NOEXCEPT : is noexcept supported? -// CLARA_CONFIG_CPP11_GENERATED_METHODS : The delete and default keywords for compiler generated methods -// CLARA_CONFIG_CPP11_OVERRIDE : is override supported? -// CLARA_CONFIG_CPP11_UNIQUE_PTR : is unique_ptr supported (otherwise use auto_ptr) - -// CLARA_CONFIG_CPP11_OR_GREATER : Is C++11 supported? - -// CLARA_CONFIG_VARIADIC_MACROS : are variadic macros supported? - -// In general each macro has a _NO_ form -// (e.g. CLARA_CONFIG_CPP11_NO_NULLPTR) which disables the feature. -// Many features, at point of detection, define an _INTERNAL_ macro, so they -// can be combined, en-mass, with the _NO_ forms later. - -// All the C++11 features can be disabled with CLARA_CONFIG_NO_CPP11 - -#ifdef __clang__ - -#if __has_feature(cxx_nullptr) -#define CLARA_INTERNAL_CONFIG_CPP11_NULLPTR -#endif - -#if __has_feature(cxx_noexcept) -#define CLARA_INTERNAL_CONFIG_CPP11_NOEXCEPT -#endif - -#endif // __clang__ - -//////////////////////////////////////////////////////////////////////////////// -// GCC -#ifdef __GNUC__ - -#if __GNUC__ == 4 && __GNUC_MINOR__ >= 6 && defined(__GXX_EXPERIMENTAL_CXX0X__) -#define CLARA_INTERNAL_CONFIG_CPP11_NULLPTR -#endif - -// - otherwise more recent versions define __cplusplus >= 201103L -// and will get picked up below - -#endif // __GNUC__ - -//////////////////////////////////////////////////////////////////////////////// -// Visual C++ -#ifdef _MSC_VER - -#if (_MSC_VER >= 1600) -#define CLARA_INTERNAL_CONFIG_CPP11_NULLPTR -#define CLARA_INTERNAL_CONFIG_CPP11_UNIQUE_PTR -#endif - -#if (_MSC_VER >= 1900 ) // (VC++ 13 (VS2015)) -#define CLARA_INTERNAL_CONFIG_CPP11_NOEXCEPT -#define CLARA_INTERNAL_CONFIG_CPP11_GENERATED_METHODS -#endif - -#endif // _MSC_VER - -//////////////////////////////////////////////////////////////////////////////// -// C++ language feature support - -// catch all support for C++11 -#if defined(__cplusplus) && __cplusplus >= 201103L - -#define CLARA_CPP11_OR_GREATER - -#if !defined(CLARA_INTERNAL_CONFIG_CPP11_NULLPTR) -#define CLARA_INTERNAL_CONFIG_CPP11_NULLPTR -#endif - -#ifndef CLARA_INTERNAL_CONFIG_CPP11_NOEXCEPT -#define CLARA_INTERNAL_CONFIG_CPP11_NOEXCEPT -#endif - -#ifndef CLARA_INTERNAL_CONFIG_CPP11_GENERATED_METHODS -#define CLARA_INTERNAL_CONFIG_CPP11_GENERATED_METHODS -#endif - -#if !defined(CLARA_INTERNAL_CONFIG_CPP11_OVERRIDE) -#define CLARA_INTERNAL_CONFIG_CPP11_OVERRIDE -#endif -#if !defined(CLARA_INTERNAL_CONFIG_CPP11_UNIQUE_PTR) -#define CLARA_INTERNAL_CONFIG_CPP11_UNIQUE_PTR -#endif - -#endif // __cplusplus >= 201103L - -// Now set the actual defines based on the above + anything the user has configured -#if defined(CLARA_INTERNAL_CONFIG_CPP11_NULLPTR) && !defined(CLARA_CONFIG_CPP11_NO_NULLPTR) && !defined(CLARA_CONFIG_CPP11_NULLPTR) && !defined(CLARA_CONFIG_NO_CPP11) -#define CLARA_CONFIG_CPP11_NULLPTR -#endif -#if defined(CLARA_INTERNAL_CONFIG_CPP11_NOEXCEPT) && !defined(CLARA_CONFIG_CPP11_NO_NOEXCEPT) && !defined(CLARA_CONFIG_CPP11_NOEXCEPT) && !defined(CLARA_CONFIG_NO_CPP11) -#define CLARA_CONFIG_CPP11_NOEXCEPT -#endif -#if defined(CLARA_INTERNAL_CONFIG_CPP11_GENERATED_METHODS) && !defined(CLARA_CONFIG_CPP11_NO_GENERATED_METHODS) && !defined(CLARA_CONFIG_CPP11_GENERATED_METHODS) && !defined(CLARA_CONFIG_NO_CPP11) -#define CLARA_CONFIG_CPP11_GENERATED_METHODS -#endif -#if defined(CLARA_INTERNAL_CONFIG_CPP11_OVERRIDE) && !defined(CLARA_CONFIG_NO_OVERRIDE) && !defined(CLARA_CONFIG_CPP11_OVERRIDE) && !defined(CLARA_CONFIG_NO_CPP11) -#define CLARA_CONFIG_CPP11_OVERRIDE -#endif -#if defined(CLARA_INTERNAL_CONFIG_CPP11_UNIQUE_PTR) && !defined(CLARA_CONFIG_NO_UNIQUE_PTR) && !defined(CLARA_CONFIG_CPP11_UNIQUE_PTR) && !defined(CLARA_CONFIG_NO_CPP11) -#define CLARA_CONFIG_CPP11_UNIQUE_PTR -#endif - -// noexcept support: -#if defined(CLARA_CONFIG_CPP11_NOEXCEPT) && !defined(CLARA_NOEXCEPT) -#define CLARA_NOEXCEPT noexcept -# define CLARA_NOEXCEPT_IS(x) noexcept(x) -#else -#define CLARA_NOEXCEPT throw() -# define CLARA_NOEXCEPT_IS(x) -#endif - -// nullptr support -#ifdef CLARA_CONFIG_CPP11_NULLPTR -#define CLARA_NULL nullptr -#else -#define CLARA_NULL NULL -#endif - -// override support -#ifdef CLARA_CONFIG_CPP11_OVERRIDE -#define CLARA_OVERRIDE override -#else -#define CLARA_OVERRIDE -#endif - -// unique_ptr support -#ifdef CLARA_CONFIG_CPP11_UNIQUE_PTR -# define CLARA_AUTO_PTR( T ) std::unique_ptr -#else -# define CLARA_AUTO_PTR( T ) std::auto_ptr -#endif - -#endif // TWOBLUECUBES_CLARA_COMPILERS_H_INCLUDED - -// ----------- end of #include from clara_compilers.h ----------- -// ........... back in clara.h - -#include -#include -#include - -#if defined(WIN32) || defined(__WIN32__) || defined(_WIN32) || defined(_MSC_VER) -#define CLARA_PLATFORM_WINDOWS -#endif - -// Use optional outer namespace -#ifdef STITCH_CLARA_OPEN_NAMESPACE -STITCH_CLARA_OPEN_NAMESPACE -#endif - -namespace Clara { - - struct UnpositionalTag {}; - - extern UnpositionalTag _; - -#ifdef CLARA_CONFIG_MAIN - UnpositionalTag _; -#endif - - namespace Detail { - -#ifdef CLARA_CONSOLE_WIDTH - const unsigned int consoleWidth = CLARA_CONFIG_CONSOLE_WIDTH; -#else - const unsigned int consoleWidth = 80; -#endif - - using namespace Tbc; - - inline bool startsWith( std::string const& str, std::string const& prefix ) { - return str.size() >= prefix.size() && str.substr( 0, prefix.size() ) == prefix; - } - - template struct RemoveConstRef{ typedef T type; }; - template struct RemoveConstRef{ typedef T type; }; - template struct RemoveConstRef{ typedef T type; }; - template struct RemoveConstRef{ typedef T type; }; - - template struct IsBool { static const bool value = false; }; - template<> struct IsBool { static const bool value = true; }; - - template - void convertInto( std::string const& _source, T& _dest ) { - std::stringstream ss; - ss << _source; - ss >> _dest; - if( ss.fail() ) - throw std::runtime_error( "Unable to convert " + _source + " to destination type" ); - } - inline void convertInto( std::string const& _source, std::string& _dest ) { - _dest = _source; - } - char toLowerCh(char c) { - return static_cast( std::tolower( c ) ); - } - inline void convertInto( std::string const& _source, bool& _dest ) { - std::string sourceLC = _source; - std::transform( sourceLC.begin(), sourceLC.end(), sourceLC.begin(), toLowerCh ); - if( sourceLC == "y" || sourceLC == "1" || sourceLC == "true" || sourceLC == "yes" || sourceLC == "on" ) - _dest = true; - else if( sourceLC == "n" || sourceLC == "0" || sourceLC == "false" || sourceLC == "no" || sourceLC == "off" ) - _dest = false; - else - throw std::runtime_error( "Expected a boolean value but did not recognise:\n '" + _source + "'" ); - } - - template - struct IArgFunction { - virtual ~IArgFunction() {} -#ifdef CLARA_CONFIG_CPP11_GENERATED_METHODS - IArgFunction() = default; - IArgFunction( IArgFunction const& ) = default; -#endif - virtual void set( ConfigT& config, std::string const& value ) const = 0; - virtual bool takesArg() const = 0; - virtual IArgFunction* clone() const = 0; - }; - - template - class BoundArgFunction { - public: - BoundArgFunction() : functionObj( CLARA_NULL ) {} - BoundArgFunction( IArgFunction* _functionObj ) : functionObj( _functionObj ) {} - BoundArgFunction( BoundArgFunction const& other ) : functionObj( other.functionObj ? other.functionObj->clone() : CLARA_NULL ) {} - BoundArgFunction& operator = ( BoundArgFunction const& other ) { - IArgFunction* newFunctionObj = other.functionObj ? other.functionObj->clone() : CLARA_NULL; - delete functionObj; - functionObj = newFunctionObj; - return *this; - } - ~BoundArgFunction() { delete functionObj; } - - void set( ConfigT& config, std::string const& value ) const { - functionObj->set( config, value ); - } - bool takesArg() const { return functionObj->takesArg(); } - - bool isSet() const { - return functionObj != CLARA_NULL; - } - private: - IArgFunction* functionObj; - }; - - template - struct NullBinder : IArgFunction{ - virtual void set( C&, std::string const& ) const {} - virtual bool takesArg() const { return true; } - virtual IArgFunction* clone() const { return new NullBinder( *this ); } - }; - - template - struct BoundDataMember : IArgFunction{ - BoundDataMember( M C::* _member ) : member( _member ) {} - virtual void set( C& p, std::string const& stringValue ) const { - convertInto( stringValue, p.*member ); - } - virtual bool takesArg() const { return !IsBool::value; } - virtual IArgFunction* clone() const { return new BoundDataMember( *this ); } - M C::* member; - }; - template - struct BoundUnaryMethod : IArgFunction{ - BoundUnaryMethod( void (C::*_member)( M ) ) : member( _member ) {} - virtual void set( C& p, std::string const& stringValue ) const { - typename RemoveConstRef::type value; - convertInto( stringValue, value ); - (p.*member)( value ); - } - virtual bool takesArg() const { return !IsBool::value; } - virtual IArgFunction* clone() const { return new BoundUnaryMethod( *this ); } - void (C::*member)( M ); - }; - template - struct BoundNullaryMethod : IArgFunction{ - BoundNullaryMethod( void (C::*_member)() ) : member( _member ) {} - virtual void set( C& p, std::string const& stringValue ) const { - bool value; - convertInto( stringValue, value ); - if( value ) - (p.*member)(); - } - virtual bool takesArg() const { return false; } - virtual IArgFunction* clone() const { return new BoundNullaryMethod( *this ); } - void (C::*member)(); - }; - - template - struct BoundUnaryFunction : IArgFunction{ - BoundUnaryFunction( void (*_function)( C& ) ) : function( _function ) {} - virtual void set( C& obj, std::string const& stringValue ) const { - bool value; - convertInto( stringValue, value ); - if( value ) - function( obj ); - } - virtual bool takesArg() const { return false; } - virtual IArgFunction* clone() const { return new BoundUnaryFunction( *this ); } - void (*function)( C& ); - }; - - template - struct BoundBinaryFunction : IArgFunction{ - BoundBinaryFunction( void (*_function)( C&, T ) ) : function( _function ) {} - virtual void set( C& obj, std::string const& stringValue ) const { - typename RemoveConstRef::type value; - convertInto( stringValue, value ); - function( obj, value ); - } - virtual bool takesArg() const { return !IsBool::value; } - virtual IArgFunction* clone() const { return new BoundBinaryFunction( *this ); } - void (*function)( C&, T ); - }; - - } // namespace Detail - - inline std::vector argsToVector( int argc, char const* const* const argv ) { - std::vector args( static_cast( argc ) ); - for( std::size_t i = 0; i < static_cast( argc ); ++i ) - args[i] = argv[i]; - - return args; - } - - class Parser { - enum Mode { None, MaybeShortOpt, SlashOpt, ShortOpt, LongOpt, Positional }; - Mode mode; - std::size_t from; - bool inQuotes; - public: - - struct Token { - enum Type { Positional, ShortOpt, LongOpt }; - Token( Type _type, std::string const& _data ) : type( _type ), data( _data ) {} - Type type; - std::string data; - }; - - Parser() : mode( None ), from( 0 ), inQuotes( false ){} - - void parseIntoTokens( std::vector const& args, std::vector& tokens ) { - const std::string doubleDash = "--"; - for( std::size_t i = 1; i < args.size() && args[i] != doubleDash; ++i ) - parseIntoTokens( args[i], tokens); - } - - void parseIntoTokens( std::string const& arg, std::vector& tokens ) { - for( std::size_t i = 0; i < arg.size(); ++i ) { - char c = arg[i]; - if( c == '"' ) - inQuotes = !inQuotes; - mode = handleMode( i, c, arg, tokens ); - } - mode = handleMode( arg.size(), '\0', arg, tokens ); - } - Mode handleMode( std::size_t i, char c, std::string const& arg, std::vector& tokens ) { - switch( mode ) { - case None: return handleNone( i, c ); - case MaybeShortOpt: return handleMaybeShortOpt( i, c ); - case ShortOpt: - case LongOpt: - case SlashOpt: return handleOpt( i, c, arg, tokens ); - case Positional: return handlePositional( i, c, arg, tokens ); - default: throw std::logic_error( "Unknown mode" ); - } - } - - Mode handleNone( std::size_t i, char c ) { - if( inQuotes ) { - from = i; - return Positional; - } - switch( c ) { - case '-': return MaybeShortOpt; -#ifdef CLARA_PLATFORM_WINDOWS - case '/': from = i+1; return SlashOpt; -#endif - default: from = i; return Positional; - } - } - Mode handleMaybeShortOpt( std::size_t i, char c ) { - switch( c ) { - case '-': from = i+1; return LongOpt; - default: from = i; return ShortOpt; - } - } - - Mode handleOpt( std::size_t i, char c, std::string const& arg, std::vector& tokens ) { - if( std::string( ":=\0", 3 ).find( c ) == std::string::npos ) - return mode; - - std::string optName = arg.substr( from, i-from ); - if( mode == ShortOpt ) - for( std::size_t j = 0; j < optName.size(); ++j ) - tokens.push_back( Token( Token::ShortOpt, optName.substr( j, 1 ) ) ); - else if( mode == SlashOpt && optName.size() == 1 ) - tokens.push_back( Token( Token::ShortOpt, optName ) ); - else - tokens.push_back( Token( Token::LongOpt, optName ) ); - return None; - } - Mode handlePositional( std::size_t i, char c, std::string const& arg, std::vector& tokens ) { - if( inQuotes || std::string( "\0", 1 ).find( c ) == std::string::npos ) - return mode; - - std::string data = arg.substr( from, i-from ); - tokens.push_back( Token( Token::Positional, data ) ); - return None; - } - }; - - template - struct CommonArgProperties { - CommonArgProperties() {} - CommonArgProperties( Detail::BoundArgFunction const& _boundField ) : boundField( _boundField ) {} - - Detail::BoundArgFunction boundField; - std::string description; - std::string detail; - std::string placeholder; // Only value if boundField takes an arg - - bool takesArg() const { - return !placeholder.empty(); - } - void validate() const { - if( !boundField.isSet() ) - throw std::logic_error( "option not bound" ); - } - }; - struct OptionArgProperties { - std::vector shortNames; - std::string longName; - - bool hasShortName( std::string const& shortName ) const { - return std::find( shortNames.begin(), shortNames.end(), shortName ) != shortNames.end(); - } - bool hasLongName( std::string const& _longName ) const { - return _longName == longName; - } - }; - struct PositionalArgProperties { - PositionalArgProperties() : position( -1 ) {} - int position; // -1 means non-positional (floating) - - bool isFixedPositional() const { - return position != -1; - } - }; - - template - class CommandLine { - - struct Arg : CommonArgProperties, OptionArgProperties, PositionalArgProperties { - Arg() {} - Arg( Detail::BoundArgFunction const& _boundField ) : CommonArgProperties( _boundField ) {} - - using CommonArgProperties::placeholder; // !TBD - - std::string dbgName() const { - if( !longName.empty() ) - return "--" + longName; - if( !shortNames.empty() ) - return "-" + shortNames[0]; - return "positional args"; - } - std::string commands() const { - std::ostringstream oss; - bool first = true; - std::vector::const_iterator it = shortNames.begin(), itEnd = shortNames.end(); - for(; it != itEnd; ++it ) { - if( first ) - first = false; - else - oss << ", "; - oss << "-" << *it; - } - if( !longName.empty() ) { - if( !first ) - oss << ", "; - oss << "--" << longName; - } - if( !placeholder.empty() ) - oss << " <" << placeholder << ">"; - return oss.str(); - } - }; - - typedef CLARA_AUTO_PTR( Arg ) ArgAutoPtr; - - friend void addOptName( Arg& arg, std::string const& optName ) - { - if( optName.empty() ) - return; - if( Detail::startsWith( optName, "--" ) ) { - if( !arg.longName.empty() ) - throw std::logic_error( "Only one long opt may be specified. '" - + arg.longName - + "' already specified, now attempting to add '" - + optName + "'" ); - arg.longName = optName.substr( 2 ); - } - else if( Detail::startsWith( optName, "-" ) ) - arg.shortNames.push_back( optName.substr( 1 ) ); - else - throw std::logic_error( "option must begin with - or --. Option was: '" + optName + "'" ); - } - friend void setPositionalArg( Arg& arg, int position ) - { - arg.position = position; - } - - class ArgBuilder { - public: - ArgBuilder( Arg* arg ) : m_arg( arg ) {} - - // Bind a non-boolean data member (requires placeholder string) - template - void bind( M C::* field, std::string const& placeholder ) { - m_arg->boundField = new Detail::BoundDataMember( field ); - m_arg->placeholder = placeholder; - } - // Bind a boolean data member (no placeholder required) - template - void bind( bool C::* field ) { - m_arg->boundField = new Detail::BoundDataMember( field ); - } - - // Bind a method taking a single, non-boolean argument (requires a placeholder string) - template - void bind( void (C::* unaryMethod)( M ), std::string const& placeholder ) { - m_arg->boundField = new Detail::BoundUnaryMethod( unaryMethod ); - m_arg->placeholder = placeholder; - } - - // Bind a method taking a single, boolean argument (no placeholder string required) - template - void bind( void (C::* unaryMethod)( bool ) ) { - m_arg->boundField = new Detail::BoundUnaryMethod( unaryMethod ); - } - - // Bind a method that takes no arguments (will be called if opt is present) - template - void bind( void (C::* nullaryMethod)() ) { - m_arg->boundField = new Detail::BoundNullaryMethod( nullaryMethod ); - } - - // Bind a free function taking a single argument - the object to operate on (no placeholder string required) - template - void bind( void (* unaryFunction)( C& ) ) { - m_arg->boundField = new Detail::BoundUnaryFunction( unaryFunction ); - } - - // Bind a free function taking a single argument - the object to operate on (requires a placeholder string) - template - void bind( void (* binaryFunction)( C&, T ), std::string const& placeholder ) { - m_arg->boundField = new Detail::BoundBinaryFunction( binaryFunction ); - m_arg->placeholder = placeholder; - } - - ArgBuilder& describe( std::string const& description ) { - m_arg->description = description; - return *this; - } - ArgBuilder& detail( std::string const& detail ) { - m_arg->detail = detail; - return *this; - } - - protected: - Arg* m_arg; - }; - - class OptBuilder : public ArgBuilder { - public: - OptBuilder( Arg* arg ) : ArgBuilder( arg ) {} - OptBuilder( OptBuilder& other ) : ArgBuilder( other ) {} - - OptBuilder& operator[]( std::string const& optName ) { - addOptName( *ArgBuilder::m_arg, optName ); - return *this; - } - }; - - public: - - CommandLine() - : m_boundProcessName( new Detail::NullBinder() ), - m_highestSpecifiedArgPosition( 0 ), - m_throwOnUnrecognisedTokens( false ) - {} - CommandLine( CommandLine const& other ) - : m_boundProcessName( other.m_boundProcessName ), - m_options ( other.m_options ), - m_positionalArgs( other.m_positionalArgs ), - m_highestSpecifiedArgPosition( other.m_highestSpecifiedArgPosition ), - m_throwOnUnrecognisedTokens( other.m_throwOnUnrecognisedTokens ) - { - if( other.m_floatingArg.get() ) - m_floatingArg.reset( new Arg( *other.m_floatingArg ) ); - } - - CommandLine& setThrowOnUnrecognisedTokens( bool shouldThrow = true ) { - m_throwOnUnrecognisedTokens = shouldThrow; - return *this; - } - - OptBuilder operator[]( std::string const& optName ) { - m_options.push_back( Arg() ); - addOptName( m_options.back(), optName ); - OptBuilder builder( &m_options.back() ); - return builder; - } - - ArgBuilder operator[]( int position ) { - m_positionalArgs.insert( std::make_pair( position, Arg() ) ); - if( position > m_highestSpecifiedArgPosition ) - m_highestSpecifiedArgPosition = position; - setPositionalArg( m_positionalArgs[position], position ); - ArgBuilder builder( &m_positionalArgs[position] ); - return builder; - } - - // Invoke this with the _ instance - ArgBuilder operator[]( UnpositionalTag ) { - if( m_floatingArg.get() ) - throw std::logic_error( "Only one unpositional argument can be added" ); - m_floatingArg.reset( new Arg() ); - ArgBuilder builder( m_floatingArg.get() ); - return builder; - } - - template - void bindProcessName( M C::* field ) { - m_boundProcessName = new Detail::BoundDataMember( field ); - } - template - void bindProcessName( void (C::*_unaryMethod)( M ) ) { - m_boundProcessName = new Detail::BoundUnaryMethod( _unaryMethod ); - } - - void optUsage( std::ostream& os, std::size_t indent = 0, std::size_t width = Detail::consoleWidth ) const { - typename std::vector::const_iterator itBegin = m_options.begin(), itEnd = m_options.end(), it; - std::size_t maxWidth = 0; - for( it = itBegin; it != itEnd; ++it ) - maxWidth = (std::max)( maxWidth, it->commands().size() ); - - for( it = itBegin; it != itEnd; ++it ) { - Detail::Text usage( it->commands(), Detail::TextAttributes() - .setWidth( maxWidth+indent ) - .setIndent( indent ) ); - Detail::Text desc( it->description, Detail::TextAttributes() - .setWidth( width - maxWidth - 3 ) ); - - for( std::size_t i = 0; i < (std::max)( usage.size(), desc.size() ); ++i ) { - std::string usageCol = i < usage.size() ? usage[i] : ""; - os << usageCol; - - if( i < desc.size() && !desc[i].empty() ) - os << std::string( indent + 2 + maxWidth - usageCol.size(), ' ' ) - << desc[i]; - os << "\n"; - } - } - } - std::string optUsage() const { - std::ostringstream oss; - optUsage( oss ); - return oss.str(); - } - - void argSynopsis( std::ostream& os ) const { - for( int i = 1; i <= m_highestSpecifiedArgPosition; ++i ) { - if( i > 1 ) - os << " "; - typename std::map::const_iterator it = m_positionalArgs.find( i ); - if( it != m_positionalArgs.end() ) - os << "<" << it->second.placeholder << ">"; - else if( m_floatingArg.get() ) - os << "<" << m_floatingArg->placeholder << ">"; - else - throw std::logic_error( "non consecutive positional arguments with no floating args" ); - } - // !TBD No indication of mandatory args - if( m_floatingArg.get() ) { - if( m_highestSpecifiedArgPosition > 1 ) - os << " "; - os << "[<" << m_floatingArg->placeholder << "> ...]"; - } - } - std::string argSynopsis() const { - std::ostringstream oss; - argSynopsis( oss ); - return oss.str(); - } - - void usage( std::ostream& os, std::string const& procName ) const { - validate(); - os << "usage:\n " << procName << " "; - argSynopsis( os ); - if( !m_options.empty() ) { - os << " [options]\n\nwhere options are: \n"; - optUsage( os, 2 ); - } - os << "\n"; - } - std::string usage( std::string const& procName ) const { - std::ostringstream oss; - usage( oss, procName ); - return oss.str(); - } - - ConfigT parse( std::vector const& args ) const { - ConfigT config; - parseInto( args, config ); - return config; - } - - std::vector parseInto( std::vector const& args, ConfigT& config ) const { - std::string processName = args.empty() ? std::string() : args[0]; - std::size_t lastSlash = processName.find_last_of( "/\\" ); - if( lastSlash != std::string::npos ) - processName = processName.substr( lastSlash+1 ); - m_boundProcessName.set( config, processName ); - std::vector tokens; - Parser parser; - parser.parseIntoTokens( args, tokens ); - return populate( tokens, config ); - } - - std::vector populate( std::vector const& tokens, ConfigT& config ) const { - validate(); - std::vector unusedTokens = populateOptions( tokens, config ); - unusedTokens = populateFixedArgs( unusedTokens, config ); - unusedTokens = populateFloatingArgs( unusedTokens, config ); - return unusedTokens; - } - - std::vector populateOptions( std::vector const& tokens, ConfigT& config ) const { - std::vector unusedTokens; - std::vector errors; - for( std::size_t i = 0; i < tokens.size(); ++i ) { - Parser::Token const& token = tokens[i]; - typename std::vector::const_iterator it = m_options.begin(), itEnd = m_options.end(); - for(; it != itEnd; ++it ) { - Arg const& arg = *it; - - try { - if( ( token.type == Parser::Token::ShortOpt && arg.hasShortName( token.data ) ) || - ( token.type == Parser::Token::LongOpt && arg.hasLongName( token.data ) ) ) { - if( arg.takesArg() ) { - if( i == tokens.size()-1 || tokens[i+1].type != Parser::Token::Positional ) - errors.push_back( "Expected argument to option: " + token.data ); - else - arg.boundField.set( config, tokens[++i].data ); - } - else { - arg.boundField.set( config, "true" ); - } - break; - } - } - catch( std::exception& ex ) { - errors.push_back( std::string( ex.what() ) + "\n- while parsing: (" + arg.commands() + ")" ); - } - } - if( it == itEnd ) { - if( token.type == Parser::Token::Positional || !m_throwOnUnrecognisedTokens ) - unusedTokens.push_back( token ); - else if( errors.empty() && m_throwOnUnrecognisedTokens ) - errors.push_back( "unrecognised option: " + token.data ); - } - } - if( !errors.empty() ) { - std::ostringstream oss; - for( std::vector::const_iterator it = errors.begin(), itEnd = errors.end(); - it != itEnd; - ++it ) { - if( it != errors.begin() ) - oss << "\n"; - oss << *it; - } - throw std::runtime_error( oss.str() ); - } - return unusedTokens; - } - std::vector populateFixedArgs( std::vector const& tokens, ConfigT& config ) const { - std::vector unusedTokens; - int position = 1; - for( std::size_t i = 0; i < tokens.size(); ++i ) { - Parser::Token const& token = tokens[i]; - typename std::map::const_iterator it = m_positionalArgs.find( position ); - if( it != m_positionalArgs.end() ) - it->second.boundField.set( config, token.data ); - else - unusedTokens.push_back( token ); - if( token.type == Parser::Token::Positional ) - position++; - } - return unusedTokens; - } - std::vector populateFloatingArgs( std::vector const& tokens, ConfigT& config ) const { - if( !m_floatingArg.get() ) - return tokens; - std::vector unusedTokens; - for( std::size_t i = 0; i < tokens.size(); ++i ) { - Parser::Token const& token = tokens[i]; - if( token.type == Parser::Token::Positional ) - m_floatingArg->boundField.set( config, token.data ); - else - unusedTokens.push_back( token ); - } - return unusedTokens; - } - - void validate() const - { - if( m_options.empty() && m_positionalArgs.empty() && !m_floatingArg.get() ) - throw std::logic_error( "No options or arguments specified" ); - - for( typename std::vector::const_iterator it = m_options.begin(), - itEnd = m_options.end(); - it != itEnd; ++it ) - it->validate(); - } - - private: - Detail::BoundArgFunction m_boundProcessName; - std::vector m_options; - std::map m_positionalArgs; - ArgAutoPtr m_floatingArg; - int m_highestSpecifiedArgPosition; - bool m_throwOnUnrecognisedTokens; - }; - -} // end namespace Clara - -STITCH_CLARA_CLOSE_NAMESPACE -#undef STITCH_CLARA_OPEN_NAMESPACE -#undef STITCH_CLARA_CLOSE_NAMESPACE - -#endif // TWOBLUECUBES_CLARA_H_INCLUDED -#undef STITCH_CLARA_OPEN_NAMESPACE - -// Restore Clara's value for console width, if present -#ifdef CATCH_TEMP_CLARA_CONFIG_CONSOLE_WIDTH -#define CLARA_CONFIG_CONSOLE_WIDTH CATCH_TEMP_CLARA_CONFIG_CONSOLE_WIDTH -#undef CATCH_TEMP_CLARA_CONFIG_CONSOLE_WIDTH -#endif - -#include -#include - -namespace Catch { - - inline void abortAfterFirst( ConfigData& config ) { config.abortAfter = 1; } - inline void abortAfterX( ConfigData& config, int x ) { - if( x < 1 ) - throw std::runtime_error( "Value after -x or --abortAfter must be greater than zero" ); - config.abortAfter = x; - } - inline void addTestOrTags( ConfigData& config, std::string const& _testSpec ) { config.testsOrTags.push_back( _testSpec ); } - inline void addSectionToRun( ConfigData& config, std::string const& sectionName ) { config.sectionsToRun.push_back( sectionName ); } - inline void addReporterName( ConfigData& config, std::string const& _reporterName ) { config.reporterNames.push_back( _reporterName ); } - - inline void addWarning( ConfigData& config, std::string const& _warning ) { - if( _warning == "NoAssertions" ) - config.warnings = static_cast( config.warnings | WarnAbout::NoAssertions ); - else - throw std::runtime_error( "Unrecognised warning: '" + _warning + '\'' ); - } - inline void setOrder( ConfigData& config, std::string const& order ) { - if( startsWith( "declared", order ) ) - config.runOrder = RunTests::InDeclarationOrder; - else if( startsWith( "lexical", order ) ) - config.runOrder = RunTests::InLexicographicalOrder; - else if( startsWith( "random", order ) ) - config.runOrder = RunTests::InRandomOrder; - else - throw std::runtime_error( "Unrecognised ordering: '" + order + '\'' ); - } - inline void setRngSeed( ConfigData& config, std::string const& seed ) { - if( seed == "time" ) { - config.rngSeed = static_cast( std::time(0) ); - } - else { - std::stringstream ss; - ss << seed; - ss >> config.rngSeed; - if( ss.fail() ) - throw std::runtime_error( "Argument to --rng-seed should be the word 'time' or a number" ); - } - } - inline void setVerbosity( ConfigData& config, int level ) { - // !TBD: accept strings? - config.verbosity = static_cast( level ); - } - inline void setShowDurations( ConfigData& config, bool _showDurations ) { - config.showDurations = _showDurations - ? ShowDurations::Always - : ShowDurations::Never; - } - inline void setUseColour( ConfigData& config, std::string const& value ) { - std::string mode = toLower( value ); - - if( mode == "yes" ) - config.useColour = UseColour::Yes; - else if( mode == "no" ) - config.useColour = UseColour::No; - else if( mode == "auto" ) - config.useColour = UseColour::Auto; - else - throw std::runtime_error( "colour mode must be one of: auto, yes or no" ); - } - inline void setWaitForKeypress( ConfigData& config, std::string const& keypress ) { - std::string keypressLc = toLower( keypress ); - if( keypressLc == "start" ) - config.waitForKeypress = WaitForKeypress::BeforeStart; - else if( keypressLc == "exit" ) - config.waitForKeypress = WaitForKeypress::BeforeExit; - else if( keypressLc == "both" ) - config.waitForKeypress = WaitForKeypress::BeforeStartAndExit; - else - throw std::runtime_error( "keypress argument must be one of: start, exit or both. '" + keypress + "' not recognised" ); - }; - - inline void forceColour( ConfigData& config ) { - config.useColour = UseColour::Yes; - } - inline void loadTestNamesFromFile( ConfigData& config, std::string const& _filename ) { - std::ifstream f( _filename.c_str() ); - if( !f.is_open() ) - throw std::domain_error( "Unable to load input file: " + _filename ); - - std::string line; - while( std::getline( f, line ) ) { - line = trim(line); - if( !line.empty() && !startsWith( line, '#' ) ) { - if( !startsWith( line, '"' ) ) - line = '"' + line + '"'; - addTestOrTags( config, line + ',' ); - } - } - } - - inline Clara::CommandLine makeCommandLineParser() { - - using namespace Clara; - CommandLine cli; - - cli.bindProcessName( &ConfigData::processName ); - - cli["-?"]["-h"]["--help"] - .describe( "display usage information" ) - .bind( &ConfigData::showHelp ); - - cli["-l"]["--list-tests"] - .describe( "list all/matching test cases" ) - .bind( &ConfigData::listTests ); - - cli["-t"]["--list-tags"] - .describe( "list all/matching tags" ) - .bind( &ConfigData::listTags ); - - cli["-s"]["--success"] - .describe( "include successful tests in output" ) - .bind( &ConfigData::showSuccessfulTests ); - - cli["-b"]["--break"] - .describe( "break into debugger on failure" ) - .bind( &ConfigData::shouldDebugBreak ); - - cli["-e"]["--nothrow"] - .describe( "skip exception tests" ) - .bind( &ConfigData::noThrow ); - - cli["-i"]["--invisibles"] - .describe( "show invisibles (tabs, newlines)" ) - .bind( &ConfigData::showInvisibles ); - - cli["-o"]["--out"] - .describe( "output filename" ) - .bind( &ConfigData::outputFilename, "filename" ); - - cli["-r"]["--reporter"] -// .placeholder( "name[:filename]" ) - .describe( "reporter to use (defaults to console)" ) - .bind( &addReporterName, "name" ); - - cli["-n"]["--name"] - .describe( "suite name" ) - .bind( &ConfigData::name, "name" ); - - cli["-a"]["--abort"] - .describe( "abort at first failure" ) - .bind( &abortAfterFirst ); - - cli["-x"]["--abortx"] - .describe( "abort after x failures" ) - .bind( &abortAfterX, "no. failures" ); - - cli["-w"]["--warn"] - .describe( "enable warnings" ) - .bind( &addWarning, "warning name" ); - -// - needs updating if reinstated -// cli.into( &setVerbosity ) -// .describe( "level of verbosity (0=no output)" ) -// .shortOpt( "v") -// .longOpt( "verbosity" ) -// .placeholder( "level" ); - - cli[_] - .describe( "which test or tests to use" ) - .bind( &addTestOrTags, "test name, pattern or tags" ); - - cli["-d"]["--durations"] - .describe( "show test durations" ) - .bind( &setShowDurations, "yes|no" ); - - cli["-f"]["--input-file"] - .describe( "load test names to run from a file" ) - .bind( &loadTestNamesFromFile, "filename" ); - - cli["-#"]["--filenames-as-tags"] - .describe( "adds a tag for the filename" ) - .bind( &ConfigData::filenamesAsTags ); - - cli["-c"]["--section"] - .describe( "specify section to run" ) - .bind( &addSectionToRun, "section name" ); - - // Less common commands which don't have a short form - cli["--list-test-names-only"] - .describe( "list all/matching test cases names only" ) - .bind( &ConfigData::listTestNamesOnly ); - - cli["--list-extra-info"] - .describe( "list all/matching test cases with more info" ) - .bind( &ConfigData::listExtraInfo ); - - cli["--list-reporters"] - .describe( "list all reporters" ) - .bind( &ConfigData::listReporters ); - - cli["--order"] - .describe( "test case order (defaults to decl)" ) - .bind( &setOrder, "decl|lex|rand" ); - - cli["--rng-seed"] - .describe( "set a specific seed for random numbers" ) - .bind( &setRngSeed, "'time'|number" ); - - cli["--force-colour"] - .describe( "force colourised output (deprecated)" ) - .bind( &forceColour ); - - cli["--use-colour"] - .describe( "should output be colourised" ) - .bind( &setUseColour, "yes|no" ); - - cli["--libidentify"] - .describe( "report name and version according to libidentify standard" ) - .bind( &ConfigData::libIdentify ); - - cli["--wait-for-keypress"] - .describe( "waits for a keypress before exiting" ) - .bind( &setWaitForKeypress, "start|exit|both" ); - - return cli; - } - -} // end namespace Catch - -// #included from: internal/catch_list.hpp -#define TWOBLUECUBES_CATCH_LIST_HPP_INCLUDED - -// #included from: catch_text.h -#define TWOBLUECUBES_CATCH_TEXT_H_INCLUDED - -#define TBC_TEXT_FORMAT_CONSOLE_WIDTH CATCH_CONFIG_CONSOLE_WIDTH - -#define CLICHE_TBC_TEXT_FORMAT_OUTER_NAMESPACE Catch -// #included from: ../external/tbc_text_format.h -// Only use header guard if we are not using an outer namespace -#ifndef CLICHE_TBC_TEXT_FORMAT_OUTER_NAMESPACE -# ifdef TWOBLUECUBES_TEXT_FORMAT_H_INCLUDED -# ifndef TWOBLUECUBES_TEXT_FORMAT_H_ALREADY_INCLUDED -# define TWOBLUECUBES_TEXT_FORMAT_H_ALREADY_INCLUDED -# endif -# else -# define TWOBLUECUBES_TEXT_FORMAT_H_INCLUDED -# endif -#endif -#ifndef TWOBLUECUBES_TEXT_FORMAT_H_ALREADY_INCLUDED -#include -#include -#include - -// Use optional outer namespace -#ifdef CLICHE_TBC_TEXT_FORMAT_OUTER_NAMESPACE -namespace CLICHE_TBC_TEXT_FORMAT_OUTER_NAMESPACE { -#endif - -namespace Tbc { - -#ifdef TBC_TEXT_FORMAT_CONSOLE_WIDTH - const unsigned int consoleWidth = TBC_TEXT_FORMAT_CONSOLE_WIDTH; -#else - const unsigned int consoleWidth = 80; -#endif - - struct TextAttributes { - TextAttributes() - : initialIndent( std::string::npos ), - indent( 0 ), - width( consoleWidth-1 ) - {} - - TextAttributes& setInitialIndent( std::size_t _value ) { initialIndent = _value; return *this; } - TextAttributes& setIndent( std::size_t _value ) { indent = _value; return *this; } - TextAttributes& setWidth( std::size_t _value ) { width = _value; return *this; } - - std::size_t initialIndent; // indent of first line, or npos - std::size_t indent; // indent of subsequent lines, or all if initialIndent is npos - std::size_t width; // maximum width of text, including indent. Longer text will wrap - }; - - class Text { - public: - Text( std::string const& _str, TextAttributes const& _attr = TextAttributes() ) - : attr( _attr ) - { - const std::string wrappableBeforeChars = "[({<\t"; - const std::string wrappableAfterChars = "])}>-,./|\\"; - const std::string wrappableInsteadOfChars = " \n\r"; - std::string indent = _attr.initialIndent != std::string::npos - ? std::string( _attr.initialIndent, ' ' ) - : std::string( _attr.indent, ' ' ); - - typedef std::string::const_iterator iterator; - iterator it = _str.begin(); - const iterator strEnd = _str.end(); - - while( it != strEnd ) { - - if( lines.size() >= 1000 ) { - lines.push_back( "... message truncated due to excessive size" ); - return; - } - - std::string suffix; - std::size_t width = (std::min)( static_cast( strEnd-it ), _attr.width-static_cast( indent.size() ) ); - iterator itEnd = it+width; - iterator itNext = _str.end(); - - iterator itNewLine = std::find( it, itEnd, '\n' ); - if( itNewLine != itEnd ) - itEnd = itNewLine; - - if( itEnd != strEnd ) { - bool foundWrapPoint = false; - iterator findIt = itEnd; - do { - if( wrappableAfterChars.find( *findIt ) != std::string::npos && findIt != itEnd ) { - itEnd = findIt+1; - itNext = findIt+1; - foundWrapPoint = true; - } - else if( findIt > it && wrappableBeforeChars.find( *findIt ) != std::string::npos ) { - itEnd = findIt; - itNext = findIt; - foundWrapPoint = true; - } - else if( wrappableInsteadOfChars.find( *findIt ) != std::string::npos ) { - itNext = findIt+1; - itEnd = findIt; - foundWrapPoint = true; - } - if( findIt == it ) - break; - else - --findIt; - } - while( !foundWrapPoint ); - - if( !foundWrapPoint ) { - // No good wrap char, so we'll break mid word and add a hyphen - --itEnd; - itNext = itEnd; - suffix = "-"; - } - else { - while( itEnd > it && wrappableInsteadOfChars.find( *(itEnd-1) ) != std::string::npos ) - --itEnd; - } - } - lines.push_back( indent + std::string( it, itEnd ) + suffix ); - - if( indent.size() != _attr.indent ) - indent = std::string( _attr.indent, ' ' ); - it = itNext; - } - } - - typedef std::vector::const_iterator const_iterator; - - const_iterator begin() const { return lines.begin(); } - const_iterator end() const { return lines.end(); } - std::string const& last() const { return lines.back(); } - std::size_t size() const { return lines.size(); } - std::string const& operator[]( std::size_t _index ) const { return lines[_index]; } - std::string toString() const { - std::ostringstream oss; - oss << *this; - return oss.str(); - } - - inline friend std::ostream& operator << ( std::ostream& _stream, Text const& _text ) { - for( Text::const_iterator it = _text.begin(), itEnd = _text.end(); - it != itEnd; ++it ) { - if( it != _text.begin() ) - _stream << "\n"; - _stream << *it; - } - return _stream; - } - - private: - std::string str; - TextAttributes attr; - std::vector lines; - }; - -} // end namespace Tbc - -#ifdef CLICHE_TBC_TEXT_FORMAT_OUTER_NAMESPACE -} // end outer namespace -#endif - -#endif // TWOBLUECUBES_TEXT_FORMAT_H_ALREADY_INCLUDED -#undef CLICHE_TBC_TEXT_FORMAT_OUTER_NAMESPACE - -namespace Catch { - using Tbc::Text; - using Tbc::TextAttributes; -} - -// #included from: catch_console_colour.hpp -#define TWOBLUECUBES_CATCH_CONSOLE_COLOUR_HPP_INCLUDED - -namespace Catch { - - struct Colour { - enum Code { - None = 0, - - White, - Red, - Green, - Blue, - Cyan, - Yellow, - Grey, - - Bright = 0x10, - - BrightRed = Bright | Red, - BrightGreen = Bright | Green, - LightGrey = Bright | Grey, - BrightWhite = Bright | White, - - // By intention - FileName = LightGrey, - Warning = Yellow, - ResultError = BrightRed, - ResultSuccess = BrightGreen, - ResultExpectedFailure = Warning, - - Error = BrightRed, - Success = Green, - - OriginalExpression = Cyan, - ReconstructedExpression = Yellow, - - SecondaryText = LightGrey, - Headers = White - }; - - // Use constructed object for RAII guard - Colour( Code _colourCode ); - Colour( Colour const& other ); - ~Colour(); - - // Use static method for one-shot changes - static void use( Code _colourCode ); - - private: - bool m_moved; - }; - - inline std::ostream& operator << ( std::ostream& os, Colour const& ) { return os; } - -} // end namespace Catch - -// #included from: catch_interfaces_reporter.h -#define TWOBLUECUBES_CATCH_INTERFACES_REPORTER_H_INCLUDED - -#include -#include -#include - -namespace Catch -{ - struct ReporterConfig { - explicit ReporterConfig( Ptr const& _fullConfig ) - : m_stream( &_fullConfig->stream() ), m_fullConfig( _fullConfig ) {} - - ReporterConfig( Ptr const& _fullConfig, std::ostream& _stream ) - : m_stream( &_stream ), m_fullConfig( _fullConfig ) {} - - std::ostream& stream() const { return *m_stream; } - Ptr fullConfig() const { return m_fullConfig; } - - private: - std::ostream* m_stream; - Ptr m_fullConfig; - }; - - struct ReporterPreferences { - ReporterPreferences() - : shouldRedirectStdOut( false ) - {} - - bool shouldRedirectStdOut; - }; - - template - struct LazyStat : Option { - LazyStat() : used( false ) {} - LazyStat& operator=( T const& _value ) { - Option::operator=( _value ); - used = false; - return *this; - } - void reset() { - Option::reset(); - used = false; - } - bool used; - }; - - struct TestRunInfo { - TestRunInfo( std::string const& _name ) : name( _name ) {} - std::string name; - }; - struct GroupInfo { - GroupInfo( std::string const& _name, - std::size_t _groupIndex, - std::size_t _groupsCount ) - : name( _name ), - groupIndex( _groupIndex ), - groupsCounts( _groupsCount ) - {} - - std::string name; - std::size_t groupIndex; - std::size_t groupsCounts; - }; - - struct AssertionStats { - AssertionStats( AssertionResult const& _assertionResult, - std::vector const& _infoMessages, - Totals const& _totals ) - : assertionResult( _assertionResult ), - infoMessages( _infoMessages ), - totals( _totals ) - { - if( assertionResult.hasMessage() ) { - // Copy message into messages list. - // !TBD This should have been done earlier, somewhere - MessageBuilder builder( assertionResult.getTestMacroName(), assertionResult.getSourceInfo(), assertionResult.getResultType() ); - builder << assertionResult.getMessage(); - builder.m_info.message = builder.m_stream.str(); - - infoMessages.push_back( builder.m_info ); - } - } - virtual ~AssertionStats(); - -# ifdef CATCH_CONFIG_CPP11_GENERATED_METHODS - AssertionStats( AssertionStats const& ) = default; - AssertionStats( AssertionStats && ) = default; - AssertionStats& operator = ( AssertionStats const& ) = default; - AssertionStats& operator = ( AssertionStats && ) = default; -# endif - - AssertionResult assertionResult; - std::vector infoMessages; - Totals totals; - }; - - struct SectionStats { - SectionStats( SectionInfo const& _sectionInfo, - Counts const& _assertions, - double _durationInSeconds, - bool _missingAssertions ) - : sectionInfo( _sectionInfo ), - assertions( _assertions ), - durationInSeconds( _durationInSeconds ), - missingAssertions( _missingAssertions ) - {} - virtual ~SectionStats(); -# ifdef CATCH_CONFIG_CPP11_GENERATED_METHODS - SectionStats( SectionStats const& ) = default; - SectionStats( SectionStats && ) = default; - SectionStats& operator = ( SectionStats const& ) = default; - SectionStats& operator = ( SectionStats && ) = default; -# endif - - SectionInfo sectionInfo; - Counts assertions; - double durationInSeconds; - bool missingAssertions; - }; - - struct TestCaseStats { - TestCaseStats( TestCaseInfo const& _testInfo, - Totals const& _totals, - std::string const& _stdOut, - std::string const& _stdErr, - bool _aborting ) - : testInfo( _testInfo ), - totals( _totals ), - stdOut( _stdOut ), - stdErr( _stdErr ), - aborting( _aborting ) - {} - virtual ~TestCaseStats(); - -# ifdef CATCH_CONFIG_CPP11_GENERATED_METHODS - TestCaseStats( TestCaseStats const& ) = default; - TestCaseStats( TestCaseStats && ) = default; - TestCaseStats& operator = ( TestCaseStats const& ) = default; - TestCaseStats& operator = ( TestCaseStats && ) = default; -# endif - - TestCaseInfo testInfo; - Totals totals; - std::string stdOut; - std::string stdErr; - bool aborting; - }; - - struct TestGroupStats { - TestGroupStats( GroupInfo const& _groupInfo, - Totals const& _totals, - bool _aborting ) - : groupInfo( _groupInfo ), - totals( _totals ), - aborting( _aborting ) - {} - TestGroupStats( GroupInfo const& _groupInfo ) - : groupInfo( _groupInfo ), - aborting( false ) - {} - virtual ~TestGroupStats(); - -# ifdef CATCH_CONFIG_CPP11_GENERATED_METHODS - TestGroupStats( TestGroupStats const& ) = default; - TestGroupStats( TestGroupStats && ) = default; - TestGroupStats& operator = ( TestGroupStats const& ) = default; - TestGroupStats& operator = ( TestGroupStats && ) = default; -# endif - - GroupInfo groupInfo; - Totals totals; - bool aborting; - }; - - struct TestRunStats { - TestRunStats( TestRunInfo const& _runInfo, - Totals const& _totals, - bool _aborting ) - : runInfo( _runInfo ), - totals( _totals ), - aborting( _aborting ) - {} - virtual ~TestRunStats(); - -# ifndef CATCH_CONFIG_CPP11_GENERATED_METHODS - TestRunStats( TestRunStats const& _other ) - : runInfo( _other.runInfo ), - totals( _other.totals ), - aborting( _other.aborting ) - {} -# else - TestRunStats( TestRunStats const& ) = default; - TestRunStats( TestRunStats && ) = default; - TestRunStats& operator = ( TestRunStats const& ) = default; - TestRunStats& operator = ( TestRunStats && ) = default; -# endif - - TestRunInfo runInfo; - Totals totals; - bool aborting; - }; - - class MultipleReporters; - - struct IStreamingReporter : IShared { - virtual ~IStreamingReporter(); - - // Implementing class must also provide the following static method: - // static std::string getDescription(); - - virtual ReporterPreferences getPreferences() const = 0; - - virtual void noMatchingTestCases( std::string const& spec ) = 0; - - virtual void testRunStarting( TestRunInfo const& testRunInfo ) = 0; - virtual void testGroupStarting( GroupInfo const& groupInfo ) = 0; - - virtual void testCaseStarting( TestCaseInfo const& testInfo ) = 0; - virtual void sectionStarting( SectionInfo const& sectionInfo ) = 0; - - virtual void assertionStarting( AssertionInfo const& assertionInfo ) = 0; - - // The return value indicates if the messages buffer should be cleared: - virtual bool assertionEnded( AssertionStats const& assertionStats ) = 0; - - virtual void sectionEnded( SectionStats const& sectionStats ) = 0; - virtual void testCaseEnded( TestCaseStats const& testCaseStats ) = 0; - virtual void testGroupEnded( TestGroupStats const& testGroupStats ) = 0; - virtual void testRunEnded( TestRunStats const& testRunStats ) = 0; - - virtual void skipTest( TestCaseInfo const& testInfo ) = 0; - - virtual MultipleReporters* tryAsMulti() { return CATCH_NULL; } - }; - - struct IReporterFactory : IShared { - virtual ~IReporterFactory(); - virtual IStreamingReporter* create( ReporterConfig const& config ) const = 0; - virtual std::string getDescription() const = 0; - }; - - struct IReporterRegistry { - typedef std::map > FactoryMap; - typedef std::vector > Listeners; - - virtual ~IReporterRegistry(); - virtual IStreamingReporter* create( std::string const& name, Ptr const& config ) const = 0; - virtual FactoryMap const& getFactories() const = 0; - virtual Listeners const& getListeners() const = 0; - }; - - Ptr addReporter( Ptr const& existingReporter, Ptr const& additionalReporter ); - -} - -#include -#include - -namespace Catch { - - inline std::size_t listTests( Config const& config ) { - - TestSpec testSpec = config.testSpec(); - if( config.testSpec().hasFilters() ) - Catch::cout() << "Matching test cases:\n"; - else { - Catch::cout() << "All available test cases:\n"; - testSpec = TestSpecParser( ITagAliasRegistry::get() ).parse( "*" ).testSpec(); - } - - std::size_t matchedTests = 0; - TextAttributes nameAttr, descAttr, tagsAttr; - nameAttr.setInitialIndent( 2 ).setIndent( 4 ); - descAttr.setIndent( 4 ); - tagsAttr.setIndent( 6 ); - - std::vector matchedTestCases = filterTests( getAllTestCasesSorted( config ), testSpec, config ); - for( std::vector::const_iterator it = matchedTestCases.begin(), itEnd = matchedTestCases.end(); - it != itEnd; - ++it ) { - matchedTests++; - TestCaseInfo const& testCaseInfo = it->getTestCaseInfo(); - Colour::Code colour = testCaseInfo.isHidden() - ? Colour::SecondaryText - : Colour::None; - Colour colourGuard( colour ); - - Catch::cout() << Text( testCaseInfo.name, nameAttr ) << std::endl; - if( config.listExtraInfo() ) { - Catch::cout() << " " << testCaseInfo.lineInfo << std::endl; - std::string description = testCaseInfo.description; - if( description.empty() ) - description = "(NO DESCRIPTION)"; - Catch::cout() << Text( description, descAttr ) << std::endl; - } - if( !testCaseInfo.tags.empty() ) - Catch::cout() << Text( testCaseInfo.tagsAsString, tagsAttr ) << std::endl; - } - - if( !config.testSpec().hasFilters() ) - Catch::cout() << pluralise( matchedTests, "test case" ) << '\n' << std::endl; - else - Catch::cout() << pluralise( matchedTests, "matching test case" ) << '\n' << std::endl; - return matchedTests; - } - - inline std::size_t listTestsNamesOnly( Config const& config ) { - TestSpec testSpec = config.testSpec(); - if( !config.testSpec().hasFilters() ) - testSpec = TestSpecParser( ITagAliasRegistry::get() ).parse( "*" ).testSpec(); - std::size_t matchedTests = 0; - std::vector matchedTestCases = filterTests( getAllTestCasesSorted( config ), testSpec, config ); - for( std::vector::const_iterator it = matchedTestCases.begin(), itEnd = matchedTestCases.end(); - it != itEnd; - ++it ) { - matchedTests++; - TestCaseInfo const& testCaseInfo = it->getTestCaseInfo(); - if( startsWith( testCaseInfo.name, '#' ) ) - Catch::cout() << '"' << testCaseInfo.name << '"'; - else - Catch::cout() << testCaseInfo.name; - if ( config.listExtraInfo() ) - Catch::cout() << "\t@" << testCaseInfo.lineInfo; - Catch::cout() << std::endl; - } - return matchedTests; - } - - struct TagInfo { - TagInfo() : count ( 0 ) {} - void add( std::string const& spelling ) { - ++count; - spellings.insert( spelling ); - } - std::string all() const { - std::string out; - for( std::set::const_iterator it = spellings.begin(), itEnd = spellings.end(); - it != itEnd; - ++it ) - out += "[" + *it + "]"; - return out; - } - std::set spellings; - std::size_t count; - }; - - inline std::size_t listTags( Config const& config ) { - TestSpec testSpec = config.testSpec(); - if( config.testSpec().hasFilters() ) - Catch::cout() << "Tags for matching test cases:\n"; - else { - Catch::cout() << "All available tags:\n"; - testSpec = TestSpecParser( ITagAliasRegistry::get() ).parse( "*" ).testSpec(); - } - - std::map tagCounts; - - std::vector matchedTestCases = filterTests( getAllTestCasesSorted( config ), testSpec, config ); - for( std::vector::const_iterator it = matchedTestCases.begin(), itEnd = matchedTestCases.end(); - it != itEnd; - ++it ) { - for( std::set::const_iterator tagIt = it->getTestCaseInfo().tags.begin(), - tagItEnd = it->getTestCaseInfo().tags.end(); - tagIt != tagItEnd; - ++tagIt ) { - std::string tagName = *tagIt; - std::string lcaseTagName = toLower( tagName ); - std::map::iterator countIt = tagCounts.find( lcaseTagName ); - if( countIt == tagCounts.end() ) - countIt = tagCounts.insert( std::make_pair( lcaseTagName, TagInfo() ) ).first; - countIt->second.add( tagName ); - } - } - - for( std::map::const_iterator countIt = tagCounts.begin(), - countItEnd = tagCounts.end(); - countIt != countItEnd; - ++countIt ) { - std::ostringstream oss; - oss << " " << std::setw(2) << countIt->second.count << " "; - Text wrapper( countIt->second.all(), TextAttributes() - .setInitialIndent( 0 ) - .setIndent( oss.str().size() ) - .setWidth( CATCH_CONFIG_CONSOLE_WIDTH-10 ) ); - Catch::cout() << oss.str() << wrapper << '\n'; - } - Catch::cout() << pluralise( tagCounts.size(), "tag" ) << '\n' << std::endl; - return tagCounts.size(); - } - - inline std::size_t listReporters( Config const& /*config*/ ) { - Catch::cout() << "Available reporters:\n"; - IReporterRegistry::FactoryMap const& factories = getRegistryHub().getReporterRegistry().getFactories(); - IReporterRegistry::FactoryMap::const_iterator itBegin = factories.begin(), itEnd = factories.end(), it; - std::size_t maxNameLen = 0; - for(it = itBegin; it != itEnd; ++it ) - maxNameLen = (std::max)( maxNameLen, it->first.size() ); - - for(it = itBegin; it != itEnd; ++it ) { - Text wrapper( it->second->getDescription(), TextAttributes() - .setInitialIndent( 0 ) - .setIndent( 7+maxNameLen ) - .setWidth( CATCH_CONFIG_CONSOLE_WIDTH - maxNameLen-8 ) ); - Catch::cout() << " " - << it->first - << ':' - << std::string( maxNameLen - it->first.size() + 2, ' ' ) - << wrapper << '\n'; - } - Catch::cout() << std::endl; - return factories.size(); - } - - inline Option list( Config const& config ) { - Option listedCount; - if( config.listTests() || ( config.listExtraInfo() && !config.listTestNamesOnly() ) ) - listedCount = listedCount.valueOr(0) + listTests( config ); - if( config.listTestNamesOnly() ) - listedCount = listedCount.valueOr(0) + listTestsNamesOnly( config ); - if( config.listTags() ) - listedCount = listedCount.valueOr(0) + listTags( config ); - if( config.listReporters() ) - listedCount = listedCount.valueOr(0) + listReporters( config ); - return listedCount; - } - -} // end namespace Catch - -// #included from: internal/catch_run_context.hpp -#define TWOBLUECUBES_CATCH_RUNNER_IMPL_HPP_INCLUDED - -// #included from: catch_test_case_tracker.hpp -#define TWOBLUECUBES_CATCH_TEST_CASE_TRACKER_HPP_INCLUDED - -#include -#include -#include -#include -#include - -CATCH_INTERNAL_SUPPRESS_ETD_WARNINGS - -namespace Catch { -namespace TestCaseTracking { - - struct NameAndLocation { - std::string name; - SourceLineInfo location; - - NameAndLocation( std::string const& _name, SourceLineInfo const& _location ) - : name( _name ), - location( _location ) - {} - }; - - struct ITracker : SharedImpl<> { - virtual ~ITracker(); - - // static queries - virtual NameAndLocation const& nameAndLocation() const = 0; - - // dynamic queries - virtual bool isComplete() const = 0; // Successfully completed or failed - virtual bool isSuccessfullyCompleted() const = 0; - virtual bool isOpen() const = 0; // Started but not complete - virtual bool hasChildren() const = 0; - - virtual ITracker& parent() = 0; - - // actions - virtual void close() = 0; // Successfully complete - virtual void fail() = 0; - virtual void markAsNeedingAnotherRun() = 0; - - virtual void addChild( Ptr const& child ) = 0; - virtual ITracker* findChild( NameAndLocation const& nameAndLocation ) = 0; - virtual void openChild() = 0; - - // Debug/ checking - virtual bool isSectionTracker() const = 0; - virtual bool isIndexTracker() const = 0; - }; - - class TrackerContext { - - enum RunState { - NotStarted, - Executing, - CompletedCycle - }; - - Ptr m_rootTracker; - ITracker* m_currentTracker; - RunState m_runState; - - public: - - static TrackerContext& instance() { - static TrackerContext s_instance; - return s_instance; - } - - TrackerContext() - : m_currentTracker( CATCH_NULL ), - m_runState( NotStarted ) - {} - - ITracker& startRun(); - - void endRun() { - m_rootTracker.reset(); - m_currentTracker = CATCH_NULL; - m_runState = NotStarted; - } - - void startCycle() { - m_currentTracker = m_rootTracker.get(); - m_runState = Executing; - } - void completeCycle() { - m_runState = CompletedCycle; - } - - bool completedCycle() const { - return m_runState == CompletedCycle; - } - ITracker& currentTracker() { - return *m_currentTracker; - } - void setCurrentTracker( ITracker* tracker ) { - m_currentTracker = tracker; - } - }; - - class TrackerBase : public ITracker { - protected: - enum CycleState { - NotStarted, - Executing, - ExecutingChildren, - NeedsAnotherRun, - CompletedSuccessfully, - Failed - }; - class TrackerHasName { - NameAndLocation m_nameAndLocation; - public: - TrackerHasName( NameAndLocation const& nameAndLocation ) : m_nameAndLocation( nameAndLocation ) {} - bool operator ()( Ptr const& tracker ) { - return - tracker->nameAndLocation().name == m_nameAndLocation.name && - tracker->nameAndLocation().location == m_nameAndLocation.location; - } - }; - typedef std::vector > Children; - NameAndLocation m_nameAndLocation; - TrackerContext& m_ctx; - ITracker* m_parent; - Children m_children; - CycleState m_runState; - public: - TrackerBase( NameAndLocation const& nameAndLocation, TrackerContext& ctx, ITracker* parent ) - : m_nameAndLocation( nameAndLocation ), - m_ctx( ctx ), - m_parent( parent ), - m_runState( NotStarted ) - {} - virtual ~TrackerBase(); - - virtual NameAndLocation const& nameAndLocation() const CATCH_OVERRIDE { - return m_nameAndLocation; - } - virtual bool isComplete() const CATCH_OVERRIDE { - return m_runState == CompletedSuccessfully || m_runState == Failed; - } - virtual bool isSuccessfullyCompleted() const CATCH_OVERRIDE { - return m_runState == CompletedSuccessfully; - } - virtual bool isOpen() const CATCH_OVERRIDE { - return m_runState != NotStarted && !isComplete(); - } - virtual bool hasChildren() const CATCH_OVERRIDE { - return !m_children.empty(); - } - - virtual void addChild( Ptr const& child ) CATCH_OVERRIDE { - m_children.push_back( child ); - } - - virtual ITracker* findChild( NameAndLocation const& nameAndLocation ) CATCH_OVERRIDE { - Children::const_iterator it = std::find_if( m_children.begin(), m_children.end(), TrackerHasName( nameAndLocation ) ); - return( it != m_children.end() ) - ? it->get() - : CATCH_NULL; - } - virtual ITracker& parent() CATCH_OVERRIDE { - assert( m_parent ); // Should always be non-null except for root - return *m_parent; - } - - virtual void openChild() CATCH_OVERRIDE { - if( m_runState != ExecutingChildren ) { - m_runState = ExecutingChildren; - if( m_parent ) - m_parent->openChild(); - } - } - - virtual bool isSectionTracker() const CATCH_OVERRIDE { return false; } - virtual bool isIndexTracker() const CATCH_OVERRIDE { return false; } - - void open() { - m_runState = Executing; - moveToThis(); - if( m_parent ) - m_parent->openChild(); - } - - virtual void close() CATCH_OVERRIDE { - - // Close any still open children (e.g. generators) - while( &m_ctx.currentTracker() != this ) - m_ctx.currentTracker().close(); - - switch( m_runState ) { - case NotStarted: - case CompletedSuccessfully: - case Failed: - throw std::logic_error( "Illogical state" ); - - case NeedsAnotherRun: - break;; - - case Executing: - m_runState = CompletedSuccessfully; - break; - case ExecutingChildren: - if( m_children.empty() || m_children.back()->isComplete() ) - m_runState = CompletedSuccessfully; - break; - - default: - throw std::logic_error( "Unexpected state" ); - } - moveToParent(); - m_ctx.completeCycle(); - } - virtual void fail() CATCH_OVERRIDE { - m_runState = Failed; - if( m_parent ) - m_parent->markAsNeedingAnotherRun(); - moveToParent(); - m_ctx.completeCycle(); - } - virtual void markAsNeedingAnotherRun() CATCH_OVERRIDE { - m_runState = NeedsAnotherRun; - } - private: - void moveToParent() { - assert( m_parent ); - m_ctx.setCurrentTracker( m_parent ); - } - void moveToThis() { - m_ctx.setCurrentTracker( this ); - } - }; - - class SectionTracker : public TrackerBase { - std::vector m_filters; - public: - SectionTracker( NameAndLocation const& nameAndLocation, TrackerContext& ctx, ITracker* parent ) - : TrackerBase( nameAndLocation, ctx, parent ) - { - if( parent ) { - while( !parent->isSectionTracker() ) - parent = &parent->parent(); - - SectionTracker& parentSection = static_cast( *parent ); - addNextFilters( parentSection.m_filters ); - } - } - virtual ~SectionTracker(); - - virtual bool isSectionTracker() const CATCH_OVERRIDE { return true; } - - static SectionTracker& acquire( TrackerContext& ctx, NameAndLocation const& nameAndLocation ) { - SectionTracker* section = CATCH_NULL; - - ITracker& currentTracker = ctx.currentTracker(); - if( ITracker* childTracker = currentTracker.findChild( nameAndLocation ) ) { - assert( childTracker ); - assert( childTracker->isSectionTracker() ); - section = static_cast( childTracker ); - } - else { - section = new SectionTracker( nameAndLocation, ctx, ¤tTracker ); - currentTracker.addChild( section ); - } - if( !ctx.completedCycle() ) - section->tryOpen(); - return *section; - } - - void tryOpen() { - if( !isComplete() && (m_filters.empty() || m_filters[0].empty() || m_filters[0] == m_nameAndLocation.name ) ) - open(); - } - - void addInitialFilters( std::vector const& filters ) { - if( !filters.empty() ) { - m_filters.push_back(""); // Root - should never be consulted - m_filters.push_back(""); // Test Case - not a section filter - m_filters.insert( m_filters.end(), filters.begin(), filters.end() ); - } - } - void addNextFilters( std::vector const& filters ) { - if( filters.size() > 1 ) - m_filters.insert( m_filters.end(), ++filters.begin(), filters.end() ); - } - }; - - class IndexTracker : public TrackerBase { - int m_size; - int m_index; - public: - IndexTracker( NameAndLocation const& nameAndLocation, TrackerContext& ctx, ITracker* parent, int size ) - : TrackerBase( nameAndLocation, ctx, parent ), - m_size( size ), - m_index( -1 ) - {} - virtual ~IndexTracker(); - - virtual bool isIndexTracker() const CATCH_OVERRIDE { return true; } - - static IndexTracker& acquire( TrackerContext& ctx, NameAndLocation const& nameAndLocation, int size ) { - IndexTracker* tracker = CATCH_NULL; - - ITracker& currentTracker = ctx.currentTracker(); - if( ITracker* childTracker = currentTracker.findChild( nameAndLocation ) ) { - assert( childTracker ); - assert( childTracker->isIndexTracker() ); - tracker = static_cast( childTracker ); - } - else { - tracker = new IndexTracker( nameAndLocation, ctx, ¤tTracker, size ); - currentTracker.addChild( tracker ); - } - - if( !ctx.completedCycle() && !tracker->isComplete() ) { - if( tracker->m_runState != ExecutingChildren && tracker->m_runState != NeedsAnotherRun ) - tracker->moveNext(); - tracker->open(); - } - - return *tracker; - } - - int index() const { return m_index; } - - void moveNext() { - m_index++; - m_children.clear(); - } - - virtual void close() CATCH_OVERRIDE { - TrackerBase::close(); - if( m_runState == CompletedSuccessfully && m_index < m_size-1 ) - m_runState = Executing; - } - }; - - inline ITracker& TrackerContext::startRun() { - m_rootTracker = new SectionTracker( NameAndLocation( "{root}", CATCH_INTERNAL_LINEINFO ), *this, CATCH_NULL ); - m_currentTracker = CATCH_NULL; - m_runState = Executing; - return *m_rootTracker; - } - -} // namespace TestCaseTracking - -using TestCaseTracking::ITracker; -using TestCaseTracking::TrackerContext; -using TestCaseTracking::SectionTracker; -using TestCaseTracking::IndexTracker; - -} // namespace Catch - -CATCH_INTERNAL_UNSUPPRESS_ETD_WARNINGS - -// #included from: catch_fatal_condition.hpp -#define TWOBLUECUBES_CATCH_FATAL_CONDITION_H_INCLUDED - -namespace Catch { - - // Report the error condition - inline void reportFatal( std::string const& message ) { - IContext& context = Catch::getCurrentContext(); - IResultCapture* resultCapture = context.getResultCapture(); - resultCapture->handleFatalErrorCondition( message ); - } - -} // namespace Catch - -#if defined ( CATCH_PLATFORM_WINDOWS ) ///////////////////////////////////////// -// #included from: catch_windows_h_proxy.h - -#define TWOBLUECUBES_CATCH_WINDOWS_H_PROXY_H_INCLUDED - -#ifdef CATCH_DEFINES_NOMINMAX -# define NOMINMAX -#endif -#ifdef CATCH_DEFINES_WIN32_LEAN_AND_MEAN -# define WIN32_LEAN_AND_MEAN -#endif - -#ifdef __AFXDLL -#include -#else -#include -#endif - -#ifdef CATCH_DEFINES_NOMINMAX -# undef NOMINMAX -#endif -#ifdef CATCH_DEFINES_WIN32_LEAN_AND_MEAN -# undef WIN32_LEAN_AND_MEAN -#endif - - -# if !defined ( CATCH_CONFIG_WINDOWS_SEH ) - -namespace Catch { - struct FatalConditionHandler { - void reset() {} - }; -} - -# else // CATCH_CONFIG_WINDOWS_SEH is defined - -namespace Catch { - - struct SignalDefs { DWORD id; const char* name; }; - extern SignalDefs signalDefs[]; - // There is no 1-1 mapping between signals and windows exceptions. - // Windows can easily distinguish between SO and SigSegV, - // but SigInt, SigTerm, etc are handled differently. - SignalDefs signalDefs[] = { - { EXCEPTION_ILLEGAL_INSTRUCTION, "SIGILL - Illegal instruction signal" }, - { EXCEPTION_STACK_OVERFLOW, "SIGSEGV - Stack overflow" }, - { EXCEPTION_ACCESS_VIOLATION, "SIGSEGV - Segmentation violation signal" }, - { EXCEPTION_INT_DIVIDE_BY_ZERO, "Divide by zero error" }, - }; - - struct FatalConditionHandler { - - static LONG CALLBACK handleVectoredException(PEXCEPTION_POINTERS ExceptionInfo) { - for (int i = 0; i < sizeof(signalDefs) / sizeof(SignalDefs); ++i) { - if (ExceptionInfo->ExceptionRecord->ExceptionCode == signalDefs[i].id) { - reportFatal(signalDefs[i].name); - } - } - // If its not an exception we care about, pass it along. - // This stops us from eating debugger breaks etc. - return EXCEPTION_CONTINUE_SEARCH; - } - - FatalConditionHandler() { - isSet = true; - // 32k seems enough for Catch to handle stack overflow, - // but the value was found experimentally, so there is no strong guarantee - guaranteeSize = 32 * 1024; - exceptionHandlerHandle = CATCH_NULL; - // Register as first handler in current chain - exceptionHandlerHandle = AddVectoredExceptionHandler(1, handleVectoredException); - // Pass in guarantee size to be filled - SetThreadStackGuarantee(&guaranteeSize); - } - - static void reset() { - if (isSet) { - // Unregister handler and restore the old guarantee - RemoveVectoredExceptionHandler(exceptionHandlerHandle); - SetThreadStackGuarantee(&guaranteeSize); - exceptionHandlerHandle = CATCH_NULL; - isSet = false; - } - } - - ~FatalConditionHandler() { - reset(); - } - private: - static bool isSet; - static ULONG guaranteeSize; - static PVOID exceptionHandlerHandle; - }; - - bool FatalConditionHandler::isSet = false; - ULONG FatalConditionHandler::guaranteeSize = 0; - PVOID FatalConditionHandler::exceptionHandlerHandle = CATCH_NULL; - -} // namespace Catch - -# endif // CATCH_CONFIG_WINDOWS_SEH - -#else // Not Windows - assumed to be POSIX compatible ////////////////////////// - -# if !defined(CATCH_CONFIG_POSIX_SIGNALS) - -namespace Catch { - struct FatalConditionHandler { - void reset() {} - }; -} - -# else // CATCH_CONFIG_POSIX_SIGNALS is defined - -#include - -namespace Catch { - - struct SignalDefs { - int id; - const char* name; - }; - extern SignalDefs signalDefs[]; - SignalDefs signalDefs[] = { - { SIGINT, "SIGINT - Terminal interrupt signal" }, - { SIGILL, "SIGILL - Illegal instruction signal" }, - { SIGFPE, "SIGFPE - Floating point error signal" }, - { SIGSEGV, "SIGSEGV - Segmentation violation signal" }, - { SIGTERM, "SIGTERM - Termination request signal" }, - { SIGABRT, "SIGABRT - Abort (abnormal termination) signal" } - }; - - struct FatalConditionHandler { - - static bool isSet; - static struct sigaction oldSigActions [sizeof(signalDefs)/sizeof(SignalDefs)]; - static stack_t oldSigStack; - static char altStackMem[SIGSTKSZ]; - - static void handleSignal( int sig ) { - std::string name = ""; - for (std::size_t i = 0; i < sizeof(signalDefs) / sizeof(SignalDefs); ++i) { - SignalDefs &def = signalDefs[i]; - if (sig == def.id) { - name = def.name; - break; - } - } - reset(); - reportFatal(name); - raise( sig ); - } - - FatalConditionHandler() { - isSet = true; - stack_t sigStack; - sigStack.ss_sp = altStackMem; - sigStack.ss_size = SIGSTKSZ; - sigStack.ss_flags = 0; - sigaltstack(&sigStack, &oldSigStack); - struct sigaction sa = { 0 }; - - sa.sa_handler = handleSignal; - sa.sa_flags = SA_ONSTACK; - for (std::size_t i = 0; i < sizeof(signalDefs)/sizeof(SignalDefs); ++i) { - sigaction(signalDefs[i].id, &sa, &oldSigActions[i]); - } - } - - ~FatalConditionHandler() { - reset(); - } - static void reset() { - if( isSet ) { - // Set signals back to previous values -- hopefully nobody overwrote them in the meantime - for( std::size_t i = 0; i < sizeof(signalDefs)/sizeof(SignalDefs); ++i ) { - sigaction(signalDefs[i].id, &oldSigActions[i], CATCH_NULL); - } - // Return the old stack - sigaltstack(&oldSigStack, CATCH_NULL); - isSet = false; - } - } - }; - - bool FatalConditionHandler::isSet = false; - struct sigaction FatalConditionHandler::oldSigActions[sizeof(signalDefs)/sizeof(SignalDefs)] = {}; - stack_t FatalConditionHandler::oldSigStack = {}; - char FatalConditionHandler::altStackMem[SIGSTKSZ] = {}; - -} // namespace Catch - -# endif // CATCH_CONFIG_POSIX_SIGNALS - -#endif // not Windows - -#include -#include -#include - -namespace Catch { - - class StreamRedirect { - - public: - StreamRedirect( std::ostream& stream, std::string& targetString ) - : m_stream( stream ), - m_prevBuf( stream.rdbuf() ), - m_targetString( targetString ) - { - stream.rdbuf( m_oss.rdbuf() ); - } - - ~StreamRedirect() { - m_targetString += m_oss.str(); - m_stream.rdbuf( m_prevBuf ); - } - - private: - std::ostream& m_stream; - std::streambuf* m_prevBuf; - std::ostringstream m_oss; - std::string& m_targetString; - }; - - // StdErr has two constituent streams in C++, std::cerr and std::clog - // This means that we need to redirect 2 streams into 1 to keep proper - // order of writes and cannot use StreamRedirect on its own - class StdErrRedirect { - public: - StdErrRedirect(std::string& targetString) - :m_cerrBuf( cerr().rdbuf() ), m_clogBuf(clog().rdbuf()), - m_targetString(targetString){ - cerr().rdbuf(m_oss.rdbuf()); - clog().rdbuf(m_oss.rdbuf()); - } - ~StdErrRedirect() { - m_targetString += m_oss.str(); - cerr().rdbuf(m_cerrBuf); - clog().rdbuf(m_clogBuf); - } - private: - std::streambuf* m_cerrBuf; - std::streambuf* m_clogBuf; - std::ostringstream m_oss; - std::string& m_targetString; - }; - - /////////////////////////////////////////////////////////////////////////// - - class RunContext : public IResultCapture, public IRunner { - - RunContext( RunContext const& ); - void operator =( RunContext const& ); - - public: - - explicit RunContext( Ptr const& _config, Ptr const& reporter ) - : m_runInfo( _config->name() ), - m_context( getCurrentMutableContext() ), - m_activeTestCase( CATCH_NULL ), - m_config( _config ), - m_reporter( reporter ), - m_shouldReportUnexpected ( true ) - { - m_context.setRunner( this ); - m_context.setConfig( m_config ); - m_context.setResultCapture( this ); - m_reporter->testRunStarting( m_runInfo ); - } - - virtual ~RunContext() { - m_reporter->testRunEnded( TestRunStats( m_runInfo, m_totals, aborting() ) ); - } - - void testGroupStarting( std::string const& testSpec, std::size_t groupIndex, std::size_t groupsCount ) { - m_reporter->testGroupStarting( GroupInfo( testSpec, groupIndex, groupsCount ) ); - } - void testGroupEnded( std::string const& testSpec, Totals const& totals, std::size_t groupIndex, std::size_t groupsCount ) { - m_reporter->testGroupEnded( TestGroupStats( GroupInfo( testSpec, groupIndex, groupsCount ), totals, aborting() ) ); - } - - Totals runTest( TestCase const& testCase ) { - Totals prevTotals = m_totals; - - std::string redirectedCout; - std::string redirectedCerr; - - TestCaseInfo testInfo = testCase.getTestCaseInfo(); - - m_reporter->testCaseStarting( testInfo ); - - m_activeTestCase = &testCase; - - do { - ITracker& rootTracker = m_trackerContext.startRun(); - assert( rootTracker.isSectionTracker() ); - static_cast( rootTracker ).addInitialFilters( m_config->getSectionsToRun() ); - do { - m_trackerContext.startCycle(); - m_testCaseTracker = &SectionTracker::acquire( m_trackerContext, TestCaseTracking::NameAndLocation( testInfo.name, testInfo.lineInfo ) ); - runCurrentTest( redirectedCout, redirectedCerr ); - } - while( !m_testCaseTracker->isSuccessfullyCompleted() && !aborting() ); - } - // !TBD: deprecated - this will be replaced by indexed trackers - while( getCurrentContext().advanceGeneratorsForCurrentTest() && !aborting() ); - - Totals deltaTotals = m_totals.delta( prevTotals ); - if( testInfo.expectedToFail() && deltaTotals.testCases.passed > 0 ) { - deltaTotals.assertions.failed++; - deltaTotals.testCases.passed--; - deltaTotals.testCases.failed++; - } - m_totals.testCases += deltaTotals.testCases; - m_reporter->testCaseEnded( TestCaseStats( testInfo, - deltaTotals, - redirectedCout, - redirectedCerr, - aborting() ) ); - - m_activeTestCase = CATCH_NULL; - m_testCaseTracker = CATCH_NULL; - - return deltaTotals; - } - - Ptr config() const { - return m_config; - } - - private: // IResultCapture - - virtual void assertionEnded( AssertionResult const& result ) { - if( result.getResultType() == ResultWas::Ok ) { - m_totals.assertions.passed++; - } - else if( !result.isOk() ) { - if( m_activeTestCase->getTestCaseInfo().okToFail() ) - m_totals.assertions.failedButOk++; - else - m_totals.assertions.failed++; - } - - // We have no use for the return value (whether messages should be cleared), because messages were made scoped - // and should be let to clear themselves out. - static_cast(m_reporter->assertionEnded(AssertionStats(result, m_messages, m_totals))); - - // Reset working state - m_lastAssertionInfo = AssertionInfo( "", m_lastAssertionInfo.lineInfo, "{Unknown expression after the reported line}" , m_lastAssertionInfo.resultDisposition ); - m_lastResult = result; - } - - virtual bool lastAssertionPassed() - { - return m_totals.assertions.passed == (m_prevPassed + 1); - } - - virtual void assertionPassed() - { - m_totals.assertions.passed++; - m_lastAssertionInfo.capturedExpression = "{Unknown expression after the reported line}"; - m_lastAssertionInfo.macroName = ""; - } - - virtual void assertionRun() - { - m_prevPassed = m_totals.assertions.passed; - } - - virtual bool sectionStarted ( - SectionInfo const& sectionInfo, - Counts& assertions - ) - { - ITracker& sectionTracker = SectionTracker::acquire( m_trackerContext, TestCaseTracking::NameAndLocation( sectionInfo.name, sectionInfo.lineInfo ) ); - if( !sectionTracker.isOpen() ) - return false; - m_activeSections.push_back( §ionTracker ); - - m_lastAssertionInfo.lineInfo = sectionInfo.lineInfo; - - m_reporter->sectionStarting( sectionInfo ); - - assertions = m_totals.assertions; - - return true; - } - bool testForMissingAssertions( Counts& assertions ) { - if( assertions.total() != 0 ) - return false; - if( !m_config->warnAboutMissingAssertions() ) - return false; - if( m_trackerContext.currentTracker().hasChildren() ) - return false; - m_totals.assertions.failed++; - assertions.failed++; - return true; - } - - virtual void sectionEnded( SectionEndInfo const& endInfo ) { - Counts assertions = m_totals.assertions - endInfo.prevAssertions; - bool missingAssertions = testForMissingAssertions( assertions ); - - if( !m_activeSections.empty() ) { - m_activeSections.back()->close(); - m_activeSections.pop_back(); - } - - m_reporter->sectionEnded( SectionStats( endInfo.sectionInfo, assertions, endInfo.durationInSeconds, missingAssertions ) ); - m_messages.clear(); - } - - virtual void sectionEndedEarly( SectionEndInfo const& endInfo ) { - if( m_unfinishedSections.empty() ) - m_activeSections.back()->fail(); - else - m_activeSections.back()->close(); - m_activeSections.pop_back(); - - m_unfinishedSections.push_back( endInfo ); - } - - virtual void pushScopedMessage( MessageInfo const& message ) { - m_messages.push_back( message ); - } - - virtual void popScopedMessage( MessageInfo const& message ) { - m_messages.erase( std::remove( m_messages.begin(), m_messages.end(), message ), m_messages.end() ); - } - - virtual std::string getCurrentTestName() const { - return m_activeTestCase - ? m_activeTestCase->getTestCaseInfo().name - : std::string(); - } - - virtual const AssertionResult* getLastResult() const { - return &m_lastResult; - } - - virtual void exceptionEarlyReported() { - m_shouldReportUnexpected = false; - } - - virtual void handleFatalErrorCondition( std::string const& message ) { - // Don't rebuild the result -- the stringification itself can cause more fatal errors - // Instead, fake a result data. - AssertionResultData tempResult; - tempResult.resultType = ResultWas::FatalErrorCondition; - tempResult.message = message; - AssertionResult result(m_lastAssertionInfo, tempResult); - - getResultCapture().assertionEnded(result); - - handleUnfinishedSections(); - - // Recreate section for test case (as we will lose the one that was in scope) - TestCaseInfo const& testCaseInfo = m_activeTestCase->getTestCaseInfo(); - SectionInfo testCaseSection( testCaseInfo.lineInfo, testCaseInfo.name, testCaseInfo.description ); - - Counts assertions; - assertions.failed = 1; - SectionStats testCaseSectionStats( testCaseSection, assertions, 0, false ); - m_reporter->sectionEnded( testCaseSectionStats ); - - TestCaseInfo testInfo = m_activeTestCase->getTestCaseInfo(); - - Totals deltaTotals; - deltaTotals.testCases.failed = 1; - deltaTotals.assertions.failed = 1; - m_reporter->testCaseEnded( TestCaseStats( testInfo, - deltaTotals, - std::string(), - std::string(), - false ) ); - m_totals.testCases.failed++; - testGroupEnded( std::string(), m_totals, 1, 1 ); - m_reporter->testRunEnded( TestRunStats( m_runInfo, m_totals, false ) ); - } - - public: - // !TBD We need to do this another way! - bool aborting() const { - return m_totals.assertions.failed == static_cast( m_config->abortAfter() ); - } - - private: - - void runCurrentTest( std::string& redirectedCout, std::string& redirectedCerr ) { - TestCaseInfo const& testCaseInfo = m_activeTestCase->getTestCaseInfo(); - SectionInfo testCaseSection( testCaseInfo.lineInfo, testCaseInfo.name, testCaseInfo.description ); - m_reporter->sectionStarting( testCaseSection ); - Counts prevAssertions = m_totals.assertions; - double duration = 0; - m_shouldReportUnexpected = true; - try { - m_lastAssertionInfo = AssertionInfo( "TEST_CASE", testCaseInfo.lineInfo, "", ResultDisposition::Normal ); - - seedRng( *m_config ); - - Timer timer; - timer.start(); - if( m_reporter->getPreferences().shouldRedirectStdOut ) { - StreamRedirect coutRedir( Catch::cout(), redirectedCout ); - StdErrRedirect errRedir( redirectedCerr ); - invokeActiveTestCase(); - } - else { - invokeActiveTestCase(); - } - duration = timer.getElapsedSeconds(); - } - catch( TestFailureException& ) { - // This just means the test was aborted due to failure - } - catch(...) { - // Under CATCH_CONFIG_FAST_COMPILE, unexpected exceptions under REQUIRE assertions - // are reported without translation at the point of origin. - if (m_shouldReportUnexpected) { - makeUnexpectedResultBuilder().useActiveException(); - } - } - m_testCaseTracker->close(); - handleUnfinishedSections(); - m_messages.clear(); - - Counts assertions = m_totals.assertions - prevAssertions; - bool missingAssertions = testForMissingAssertions( assertions ); - - SectionStats testCaseSectionStats( testCaseSection, assertions, duration, missingAssertions ); - m_reporter->sectionEnded( testCaseSectionStats ); - } - - void invokeActiveTestCase() { - FatalConditionHandler fatalConditionHandler; // Handle signals - m_activeTestCase->invoke(); - fatalConditionHandler.reset(); - } - - private: - - ResultBuilder makeUnexpectedResultBuilder() const { - return ResultBuilder( m_lastAssertionInfo.macroName, - m_lastAssertionInfo.lineInfo, - m_lastAssertionInfo.capturedExpression, - m_lastAssertionInfo.resultDisposition ); - } - - void handleUnfinishedSections() { - // If sections ended prematurely due to an exception we stored their - // infos here so we can tear them down outside the unwind process. - for( std::vector::const_reverse_iterator it = m_unfinishedSections.rbegin(), - itEnd = m_unfinishedSections.rend(); - it != itEnd; - ++it ) - sectionEnded( *it ); - m_unfinishedSections.clear(); - } - - TestRunInfo m_runInfo; - IMutableContext& m_context; - TestCase const* m_activeTestCase; - ITracker* m_testCaseTracker; - ITracker* m_currentSectionTracker; - AssertionResult m_lastResult; - - Ptr m_config; - Totals m_totals; - Ptr m_reporter; - std::vector m_messages; - AssertionInfo m_lastAssertionInfo; - std::vector m_unfinishedSections; - std::vector m_activeSections; - TrackerContext m_trackerContext; - size_t m_prevPassed; - bool m_shouldReportUnexpected; - }; - - IResultCapture& getResultCapture() { - if( IResultCapture* capture = getCurrentContext().getResultCapture() ) - return *capture; - else - throw std::logic_error( "No result capture instance" ); - } - -} // end namespace Catch - -// #included from: internal/catch_version.h -#define TWOBLUECUBES_CATCH_VERSION_H_INCLUDED - -namespace Catch { - - // Versioning information - struct Version { - Version( unsigned int _majorVersion, - unsigned int _minorVersion, - unsigned int _patchNumber, - char const * const _branchName, - unsigned int _buildNumber ); - - unsigned int const majorVersion; - unsigned int const minorVersion; - unsigned int const patchNumber; - - // buildNumber is only used if branchName is not null - char const * const branchName; - unsigned int const buildNumber; - - friend std::ostream& operator << ( std::ostream& os, Version const& version ); - - private: - void operator=( Version const& ); - }; - - inline Version libraryVersion(); -} - -#include -#include -#include - -namespace Catch { - - Ptr createReporter( std::string const& reporterName, Ptr const& config ) { - Ptr reporter = getRegistryHub().getReporterRegistry().create( reporterName, config.get() ); - if( !reporter ) { - std::ostringstream oss; - oss << "No reporter registered with name: '" << reporterName << "'"; - throw std::domain_error( oss.str() ); - } - return reporter; - } - -#if !defined(CATCH_CONFIG_DEFAULT_REPORTER) -#define CATCH_CONFIG_DEFAULT_REPORTER "console" -#endif - - Ptr makeReporter( Ptr const& config ) { - std::vector reporters = config->getReporterNames(); - if( reporters.empty() ) - reporters.push_back( CATCH_CONFIG_DEFAULT_REPORTER ); - - Ptr reporter; - for( std::vector::const_iterator it = reporters.begin(), itEnd = reporters.end(); - it != itEnd; - ++it ) - reporter = addReporter( reporter, createReporter( *it, config ) ); - return reporter; - } - Ptr addListeners( Ptr const& config, Ptr reporters ) { - IReporterRegistry::Listeners listeners = getRegistryHub().getReporterRegistry().getListeners(); - for( IReporterRegistry::Listeners::const_iterator it = listeners.begin(), itEnd = listeners.end(); - it != itEnd; - ++it ) - reporters = addReporter(reporters, (*it)->create( ReporterConfig( config ) ) ); - return reporters; - } - - Totals runTests( Ptr const& config ) { - - Ptr iconfig = config.get(); - - Ptr reporter = makeReporter( config ); - reporter = addListeners( iconfig, reporter ); - - RunContext context( iconfig, reporter ); - - Totals totals; - - context.testGroupStarting( config->name(), 1, 1 ); - - TestSpec testSpec = config->testSpec(); - if( !testSpec.hasFilters() ) - testSpec = TestSpecParser( ITagAliasRegistry::get() ).parse( "~[.]" ).testSpec(); // All not hidden tests - - std::vector const& allTestCases = getAllTestCasesSorted( *iconfig ); - for( std::vector::const_iterator it = allTestCases.begin(), itEnd = allTestCases.end(); - it != itEnd; - ++it ) { - if( !context.aborting() && matchTest( *it, testSpec, *iconfig ) ) - totals += context.runTest( *it ); - else - reporter->skipTest( *it ); - } - - context.testGroupEnded( iconfig->name(), totals, 1, 1 ); - return totals; - } - - void applyFilenamesAsTags( IConfig const& config ) { - std::vector const& tests = getAllTestCasesSorted( config ); - for(std::size_t i = 0; i < tests.size(); ++i ) { - TestCase& test = const_cast( tests[i] ); - std::set tags = test.tags; - - std::string filename = test.lineInfo.file; - std::string::size_type lastSlash = filename.find_last_of( "\\/" ); - if( lastSlash != std::string::npos ) - filename = filename.substr( lastSlash+1 ); - - std::string::size_type lastDot = filename.find_last_of( '.' ); - if( lastDot != std::string::npos ) - filename = filename.substr( 0, lastDot ); - - tags.insert( '#' + filename ); - setTags( test, tags ); - } - } - - class Session : NonCopyable { - static bool alreadyInstantiated; - - public: - - struct OnUnusedOptions { enum DoWhat { Ignore, Fail }; }; - - Session() - : m_cli( makeCommandLineParser() ) { - if( alreadyInstantiated ) { - std::string msg = "Only one instance of Catch::Session can ever be used"; - Catch::cerr() << msg << std::endl; - throw std::logic_error( msg ); - } - alreadyInstantiated = true; - } - ~Session() { - Catch::cleanUp(); - } - - void showHelp( std::string const& processName ) { - Catch::cout() << "\nCatch v" << libraryVersion() << "\n"; - - m_cli.usage( Catch::cout(), processName ); - Catch::cout() << "For more detail usage please see the project docs\n" << std::endl; - } - void libIdentify() { - Catch::cout() - << std::left << std::setw(16) << "description: " << "A Catch test executable\n" - << std::left << std::setw(16) << "category: " << "testframework\n" - << std::left << std::setw(16) << "framework: " << "Catch Test\n" - << std::left << std::setw(16) << "version: " << libraryVersion() << std::endl; - } - - int applyCommandLine( int argc, char const* const* const argv, OnUnusedOptions::DoWhat unusedOptionBehaviour = OnUnusedOptions::Fail ) { - try { - m_cli.setThrowOnUnrecognisedTokens( unusedOptionBehaviour == OnUnusedOptions::Fail ); - m_unusedTokens = m_cli.parseInto( Clara::argsToVector( argc, argv ), m_configData ); - if( m_configData.showHelp ) - showHelp( m_configData.processName ); - if( m_configData.libIdentify ) - libIdentify(); - m_config.reset(); - } - catch( std::exception& ex ) { - { - Colour colourGuard( Colour::Red ); - Catch::cerr() - << "\nError(s) in input:\n" - << Text( ex.what(), TextAttributes().setIndent(2) ) - << "\n\n"; - } - m_cli.usage( Catch::cout(), m_configData.processName ); - return (std::numeric_limits::max)(); - } - return 0; - } - - void useConfigData( ConfigData const& _configData ) { - m_configData = _configData; - m_config.reset(); - } - - int run( int argc, char const* const* const argv ) { - - int returnCode = applyCommandLine( argc, argv ); - if( returnCode == 0 ) - returnCode = run(); - return returnCode; - } - - #if defined(WIN32) && defined(UNICODE) - int run( int argc, wchar_t const* const* const argv ) { - - char **utf8Argv = new char *[ argc ]; - - for ( int i = 0; i < argc; ++i ) { - int bufSize = WideCharToMultiByte( CP_UTF8, 0, argv[i], -1, NULL, 0, NULL, NULL ); - - utf8Argv[ i ] = new char[ bufSize ]; - - WideCharToMultiByte( CP_UTF8, 0, argv[i], -1, utf8Argv[i], bufSize, NULL, NULL ); - } - - int returnCode = applyCommandLine( argc, utf8Argv ); - if( returnCode == 0 ) - returnCode = run(); - - for ( int i = 0; i < argc; ++i ) - delete [] utf8Argv[ i ]; - - delete [] utf8Argv; - - return returnCode; - } - #endif - - int run() { - if( ( m_configData.waitForKeypress & WaitForKeypress::BeforeStart ) != 0 ) { - Catch::cout() << "...waiting for enter/ return before starting" << std::endl; - static_cast(std::getchar()); - } - int exitCode = runInternal(); - if( ( m_configData.waitForKeypress & WaitForKeypress::BeforeExit ) != 0 ) { - Catch::cout() << "...waiting for enter/ return before exiting, with code: " << exitCode << std::endl; - static_cast(std::getchar()); - } - return exitCode; - } - - Clara::CommandLine const& cli() const { - return m_cli; - } - std::vector const& unusedTokens() const { - return m_unusedTokens; - } - ConfigData& configData() { - return m_configData; - } - Config& config() { - if( !m_config ) - m_config = new Config( m_configData ); - return *m_config; - } - private: - - int runInternal() { - if( m_configData.showHelp || m_configData.libIdentify ) - return 0; - - try - { - config(); // Force config to be constructed - - seedRng( *m_config ); - - if( m_configData.filenamesAsTags ) - applyFilenamesAsTags( *m_config ); - - // Handle list request - if( Option listed = list( config() ) ) - return static_cast( *listed ); - - return static_cast( runTests( m_config ).assertions.failed ); - } - catch( std::exception& ex ) { - Catch::cerr() << ex.what() << std::endl; - return (std::numeric_limits::max)(); - } - } - - Clara::CommandLine m_cli; - std::vector m_unusedTokens; - ConfigData m_configData; - Ptr m_config; - }; - - bool Session::alreadyInstantiated = false; - -} // end namespace Catch - -// #included from: catch_registry_hub.hpp -#define TWOBLUECUBES_CATCH_REGISTRY_HUB_HPP_INCLUDED - -// #included from: catch_test_case_registry_impl.hpp -#define TWOBLUECUBES_CATCH_TEST_CASE_REGISTRY_IMPL_HPP_INCLUDED - -#include -#include -#include -#include - -namespace Catch { - - struct RandomNumberGenerator { - typedef unsigned int result_type; - - result_type operator()( result_type n ) const { return std::rand() % n; } - -#ifdef CATCH_CONFIG_CPP11_SHUFFLE - static constexpr result_type (min)() { return 0; } - static constexpr result_type (max)() { return 1000000; } - result_type operator()() const { return std::rand() % (max)(); } -#endif - template - static void shuffle( V& vector ) { - RandomNumberGenerator rng; -#ifdef CATCH_CONFIG_CPP11_SHUFFLE - std::shuffle( vector.begin(), vector.end(), rng ); -#else - std::random_shuffle( vector.begin(), vector.end(), rng ); -#endif - } - }; - - inline std::vector sortTests( IConfig const& config, std::vector const& unsortedTestCases ) { - - std::vector sorted = unsortedTestCases; - - switch( config.runOrder() ) { - case RunTests::InLexicographicalOrder: - std::sort( sorted.begin(), sorted.end() ); - break; - case RunTests::InRandomOrder: - { - seedRng( config ); - RandomNumberGenerator::shuffle( sorted ); - } - break; - case RunTests::InDeclarationOrder: - // already in declaration order - break; - } - return sorted; - } - bool matchTest( TestCase const& testCase, TestSpec const& testSpec, IConfig const& config ) { - return testSpec.matches( testCase ) && ( config.allowThrows() || !testCase.throws() ); - } - - void enforceNoDuplicateTestCases( std::vector const& functions ) { - std::set seenFunctions; - for( std::vector::const_iterator it = functions.begin(), itEnd = functions.end(); - it != itEnd; - ++it ) { - std::pair::const_iterator, bool> prev = seenFunctions.insert( *it ); - if( !prev.second ) { - std::ostringstream ss; - - ss << Colour( Colour::Red ) - << "error: TEST_CASE( \"" << it->name << "\" ) already defined.\n" - << "\tFirst seen at " << prev.first->getTestCaseInfo().lineInfo << '\n' - << "\tRedefined at " << it->getTestCaseInfo().lineInfo << std::endl; - - throw std::runtime_error(ss.str()); - } - } - } - - std::vector filterTests( std::vector const& testCases, TestSpec const& testSpec, IConfig const& config ) { - std::vector filtered; - filtered.reserve( testCases.size() ); - for( std::vector::const_iterator it = testCases.begin(), itEnd = testCases.end(); - it != itEnd; - ++it ) - if( matchTest( *it, testSpec, config ) ) - filtered.push_back( *it ); - return filtered; - } - std::vector const& getAllTestCasesSorted( IConfig const& config ) { - return getRegistryHub().getTestCaseRegistry().getAllTestsSorted( config ); - } - - class TestRegistry : public ITestCaseRegistry { - public: - TestRegistry() - : m_currentSortOrder( RunTests::InDeclarationOrder ), - m_unnamedCount( 0 ) - {} - virtual ~TestRegistry(); - - virtual void registerTest( TestCase const& testCase ) { - std::string name = testCase.getTestCaseInfo().name; - if( name.empty() ) { - std::ostringstream oss; - oss << "Anonymous test case " << ++m_unnamedCount; - return registerTest( testCase.withName( oss.str() ) ); - } - m_functions.push_back( testCase ); - } - - virtual std::vector const& getAllTests() const { - return m_functions; - } - virtual std::vector const& getAllTestsSorted( IConfig const& config ) const { - if( m_sortedFunctions.empty() ) - enforceNoDuplicateTestCases( m_functions ); - - if( m_currentSortOrder != config.runOrder() || m_sortedFunctions.empty() ) { - m_sortedFunctions = sortTests( config, m_functions ); - m_currentSortOrder = config.runOrder(); - } - return m_sortedFunctions; - } - - private: - std::vector m_functions; - mutable RunTests::InWhatOrder m_currentSortOrder; - mutable std::vector m_sortedFunctions; - size_t m_unnamedCount; - std::ios_base::Init m_ostreamInit; // Forces cout/ cerr to be initialised - }; - - /////////////////////////////////////////////////////////////////////////// - - class FreeFunctionTestCase : public SharedImpl { - public: - - FreeFunctionTestCase( TestFunction fun ) : m_fun( fun ) {} - - virtual void invoke() const { - m_fun(); - } - - private: - virtual ~FreeFunctionTestCase(); - - TestFunction m_fun; - }; - - inline std::string extractClassName( std::string const& classOrQualifiedMethodName ) { - std::string className = classOrQualifiedMethodName; - if( startsWith( className, '&' ) ) - { - std::size_t lastColons = className.rfind( "::" ); - std::size_t penultimateColons = className.rfind( "::", lastColons-1 ); - if( penultimateColons == std::string::npos ) - penultimateColons = 1; - className = className.substr( penultimateColons, lastColons-penultimateColons ); - } - return className; - } - - void registerTestCase - ( ITestCase* testCase, - char const* classOrQualifiedMethodName, - NameAndDesc const& nameAndDesc, - SourceLineInfo const& lineInfo ) { - - getMutableRegistryHub().registerTest - ( makeTestCase - ( testCase, - extractClassName( classOrQualifiedMethodName ), - nameAndDesc.name, - nameAndDesc.description, - lineInfo ) ); - } - void registerTestCaseFunction - ( TestFunction function, - SourceLineInfo const& lineInfo, - NameAndDesc const& nameAndDesc ) { - registerTestCase( new FreeFunctionTestCase( function ), "", nameAndDesc, lineInfo ); - } - - /////////////////////////////////////////////////////////////////////////// - - AutoReg::AutoReg - ( TestFunction function, - SourceLineInfo const& lineInfo, - NameAndDesc const& nameAndDesc ) { - registerTestCaseFunction( function, lineInfo, nameAndDesc ); - } - - AutoReg::~AutoReg() {} - -} // end namespace Catch - -// #included from: catch_reporter_registry.hpp -#define TWOBLUECUBES_CATCH_REPORTER_REGISTRY_HPP_INCLUDED - -#include - -namespace Catch { - - class ReporterRegistry : public IReporterRegistry { - - public: - - virtual ~ReporterRegistry() CATCH_OVERRIDE {} - - virtual IStreamingReporter* create( std::string const& name, Ptr const& config ) const CATCH_OVERRIDE { - FactoryMap::const_iterator it = m_factories.find( name ); - if( it == m_factories.end() ) - return CATCH_NULL; - return it->second->create( ReporterConfig( config ) ); - } - - void registerReporter( std::string const& name, Ptr const& factory ) { - m_factories.insert( std::make_pair( name, factory ) ); - } - void registerListener( Ptr const& factory ) { - m_listeners.push_back( factory ); - } - - virtual FactoryMap const& getFactories() const CATCH_OVERRIDE { - return m_factories; - } - virtual Listeners const& getListeners() const CATCH_OVERRIDE { - return m_listeners; - } - - private: - FactoryMap m_factories; - Listeners m_listeners; - }; -} - -// #included from: catch_exception_translator_registry.hpp -#define TWOBLUECUBES_CATCH_EXCEPTION_TRANSLATOR_REGISTRY_HPP_INCLUDED - -#ifdef __OBJC__ -#import "Foundation/Foundation.h" -#endif - -namespace Catch { - - class ExceptionTranslatorRegistry : public IExceptionTranslatorRegistry { - public: - ~ExceptionTranslatorRegistry() { - deleteAll( m_translators ); - } - - virtual void registerTranslator( const IExceptionTranslator* translator ) { - m_translators.push_back( translator ); - } - - virtual std::string translateActiveException() const { - try { -#ifdef __OBJC__ - // In Objective-C try objective-c exceptions first - @try { - return tryTranslators(); - } - @catch (NSException *exception) { - return Catch::toString( [exception description] ); - } -#else - return tryTranslators(); -#endif - } - catch( TestFailureException& ) { - throw; - } - catch( std::exception& ex ) { - return ex.what(); - } - catch( std::string& msg ) { - return msg; - } - catch( const char* msg ) { - return msg; - } - catch(...) { - return "Unknown exception"; - } - } - - std::string tryTranslators() const { - if( m_translators.empty() ) - throw; - else - return m_translators[0]->translate( m_translators.begin()+1, m_translators.end() ); - } - - private: - std::vector m_translators; - }; -} - -// #included from: catch_tag_alias_registry.h -#define TWOBLUECUBES_CATCH_TAG_ALIAS_REGISTRY_H_INCLUDED - -#include - -namespace Catch { - - class TagAliasRegistry : public ITagAliasRegistry { - public: - virtual ~TagAliasRegistry(); - virtual Option find( std::string const& alias ) const; - virtual std::string expandAliases( std::string const& unexpandedTestSpec ) const; - void add( std::string const& alias, std::string const& tag, SourceLineInfo const& lineInfo ); - - private: - std::map m_registry; - }; - -} // end namespace Catch - -namespace Catch { - - namespace { - - class RegistryHub : public IRegistryHub, public IMutableRegistryHub { - - RegistryHub( RegistryHub const& ); - void operator=( RegistryHub const& ); - - public: // IRegistryHub - RegistryHub() { - } - virtual IReporterRegistry const& getReporterRegistry() const CATCH_OVERRIDE { - return m_reporterRegistry; - } - virtual ITestCaseRegistry const& getTestCaseRegistry() const CATCH_OVERRIDE { - return m_testCaseRegistry; - } - virtual IExceptionTranslatorRegistry& getExceptionTranslatorRegistry() CATCH_OVERRIDE { - return m_exceptionTranslatorRegistry; - } - virtual ITagAliasRegistry const& getTagAliasRegistry() const CATCH_OVERRIDE { - return m_tagAliasRegistry; - } - - public: // IMutableRegistryHub - virtual void registerReporter( std::string const& name, Ptr const& factory ) CATCH_OVERRIDE { - m_reporterRegistry.registerReporter( name, factory ); - } - virtual void registerListener( Ptr const& factory ) CATCH_OVERRIDE { - m_reporterRegistry.registerListener( factory ); - } - virtual void registerTest( TestCase const& testInfo ) CATCH_OVERRIDE { - m_testCaseRegistry.registerTest( testInfo ); - } - virtual void registerTranslator( const IExceptionTranslator* translator ) CATCH_OVERRIDE { - m_exceptionTranslatorRegistry.registerTranslator( translator ); - } - virtual void registerTagAlias( std::string const& alias, std::string const& tag, SourceLineInfo const& lineInfo ) CATCH_OVERRIDE { - m_tagAliasRegistry.add( alias, tag, lineInfo ); - } - - private: - TestRegistry m_testCaseRegistry; - ReporterRegistry m_reporterRegistry; - ExceptionTranslatorRegistry m_exceptionTranslatorRegistry; - TagAliasRegistry m_tagAliasRegistry; - }; - - // Single, global, instance - inline RegistryHub*& getTheRegistryHub() { - static RegistryHub* theRegistryHub = CATCH_NULL; - if( !theRegistryHub ) - theRegistryHub = new RegistryHub(); - return theRegistryHub; - } - } - - IRegistryHub& getRegistryHub() { - return *getTheRegistryHub(); - } - IMutableRegistryHub& getMutableRegistryHub() { - return *getTheRegistryHub(); - } - void cleanUp() { - delete getTheRegistryHub(); - getTheRegistryHub() = CATCH_NULL; - cleanUpContext(); - } - std::string translateActiveException() { - return getRegistryHub().getExceptionTranslatorRegistry().translateActiveException(); - } - -} // end namespace Catch - -// #included from: catch_notimplemented_exception.hpp -#define TWOBLUECUBES_CATCH_NOTIMPLEMENTED_EXCEPTION_HPP_INCLUDED - -#include - -namespace Catch { - - NotImplementedException::NotImplementedException( SourceLineInfo const& lineInfo ) - : m_lineInfo( lineInfo ) { - std::ostringstream oss; - oss << lineInfo << ": function "; - oss << "not implemented"; - m_what = oss.str(); - } - - const char* NotImplementedException::what() const CATCH_NOEXCEPT { - return m_what.c_str(); - } - -} // end namespace Catch - -// #included from: catch_context_impl.hpp -#define TWOBLUECUBES_CATCH_CONTEXT_IMPL_HPP_INCLUDED - -// #included from: catch_stream.hpp -#define TWOBLUECUBES_CATCH_STREAM_HPP_INCLUDED - -#include -#include -#include - -namespace Catch { - - template - class StreamBufImpl : public StreamBufBase { - char data[bufferSize]; - WriterF m_writer; - - public: - StreamBufImpl() { - setp( data, data + sizeof(data) ); - } - - ~StreamBufImpl() CATCH_NOEXCEPT { - sync(); - } - - private: - int overflow( int c ) { - sync(); - - if( c != EOF ) { - if( pbase() == epptr() ) - m_writer( std::string( 1, static_cast( c ) ) ); - else - sputc( static_cast( c ) ); - } - return 0; - } - - int sync() { - if( pbase() != pptr() ) { - m_writer( std::string( pbase(), static_cast( pptr() - pbase() ) ) ); - setp( pbase(), epptr() ); - } - return 0; - } - }; - - /////////////////////////////////////////////////////////////////////////// - - FileStream::FileStream( std::string const& filename ) { - m_ofs.open( filename.c_str() ); - if( m_ofs.fail() ) { - std::ostringstream oss; - oss << "Unable to open file: '" << filename << '\''; - throw std::domain_error( oss.str() ); - } - } - - std::ostream& FileStream::stream() const { - return m_ofs; - } - - struct OutputDebugWriter { - - void operator()( std::string const&str ) { - writeToDebugConsole( str ); - } - }; - - DebugOutStream::DebugOutStream() - : m_streamBuf( new StreamBufImpl() ), - m_os( m_streamBuf.get() ) - {} - - std::ostream& DebugOutStream::stream() const { - return m_os; - } - - // Store the streambuf from cout up-front because - // cout may get redirected when running tests - CoutStream::CoutStream() - : m_os( Catch::cout().rdbuf() ) - {} - - std::ostream& CoutStream::stream() const { - return m_os; - } - -#ifndef CATCH_CONFIG_NOSTDOUT // If you #define this you must implement these functions - std::ostream& cout() { - return std::cout; - } - std::ostream& cerr() { - return std::cerr; - } - std::ostream& clog() { - return std::clog; - } -#endif -} - -namespace Catch { - - class Context : public IMutableContext { - - Context() : m_config( CATCH_NULL ), m_runner( CATCH_NULL ), m_resultCapture( CATCH_NULL ) {} - Context( Context const& ); - void operator=( Context const& ); - - public: - virtual ~Context() { - deleteAllValues( m_generatorsByTestName ); - } - - public: // IContext - virtual IResultCapture* getResultCapture() { - return m_resultCapture; - } - virtual IRunner* getRunner() { - return m_runner; - } - virtual size_t getGeneratorIndex( std::string const& fileInfo, size_t totalSize ) { - return getGeneratorsForCurrentTest() - .getGeneratorInfo( fileInfo, totalSize ) - .getCurrentIndex(); - } - virtual bool advanceGeneratorsForCurrentTest() { - IGeneratorsForTest* generators = findGeneratorsForCurrentTest(); - return generators && generators->moveNext(); - } - - virtual Ptr getConfig() const { - return m_config; - } - - public: // IMutableContext - virtual void setResultCapture( IResultCapture* resultCapture ) { - m_resultCapture = resultCapture; - } - virtual void setRunner( IRunner* runner ) { - m_runner = runner; - } - virtual void setConfig( Ptr const& config ) { - m_config = config; - } - - friend IMutableContext& getCurrentMutableContext(); - - private: - IGeneratorsForTest* findGeneratorsForCurrentTest() { - std::string testName = getResultCapture()->getCurrentTestName(); - - std::map::const_iterator it = - m_generatorsByTestName.find( testName ); - return it != m_generatorsByTestName.end() - ? it->second - : CATCH_NULL; - } - - IGeneratorsForTest& getGeneratorsForCurrentTest() { - IGeneratorsForTest* generators = findGeneratorsForCurrentTest(); - if( !generators ) { - std::string testName = getResultCapture()->getCurrentTestName(); - generators = createGeneratorsForTest(); - m_generatorsByTestName.insert( std::make_pair( testName, generators ) ); - } - return *generators; - } - - private: - Ptr m_config; - IRunner* m_runner; - IResultCapture* m_resultCapture; - std::map m_generatorsByTestName; - }; - - namespace { - Context* currentContext = CATCH_NULL; - } - IMutableContext& getCurrentMutableContext() { - if( !currentContext ) - currentContext = new Context(); - return *currentContext; - } - IContext& getCurrentContext() { - return getCurrentMutableContext(); - } - - void cleanUpContext() { - delete currentContext; - currentContext = CATCH_NULL; - } -} - -// #included from: catch_console_colour_impl.hpp -#define TWOBLUECUBES_CATCH_CONSOLE_COLOUR_IMPL_HPP_INCLUDED - -// #included from: catch_errno_guard.hpp -#define TWOBLUECUBES_CATCH_ERRNO_GUARD_HPP_INCLUDED - -#include - -namespace Catch { - - class ErrnoGuard { - public: - ErrnoGuard():m_oldErrno(errno){} - ~ErrnoGuard() { errno = m_oldErrno; } - private: - int m_oldErrno; - }; - -} - -namespace Catch { - namespace { - - struct IColourImpl { - virtual ~IColourImpl() {} - virtual void use( Colour::Code _colourCode ) = 0; - }; - - struct NoColourImpl : IColourImpl { - void use( Colour::Code ) {} - - static IColourImpl* instance() { - static NoColourImpl s_instance; - return &s_instance; - } - }; - - } // anon namespace -} // namespace Catch - -#if !defined( CATCH_CONFIG_COLOUR_NONE ) && !defined( CATCH_CONFIG_COLOUR_WINDOWS ) && !defined( CATCH_CONFIG_COLOUR_ANSI ) -# ifdef CATCH_PLATFORM_WINDOWS -# define CATCH_CONFIG_COLOUR_WINDOWS -# else -# define CATCH_CONFIG_COLOUR_ANSI -# endif -#endif - -#if defined ( CATCH_CONFIG_COLOUR_WINDOWS ) ///////////////////////////////////////// - -namespace Catch { -namespace { - - class Win32ColourImpl : public IColourImpl { - public: - Win32ColourImpl() : stdoutHandle( GetStdHandle(STD_OUTPUT_HANDLE) ) - { - CONSOLE_SCREEN_BUFFER_INFO csbiInfo; - GetConsoleScreenBufferInfo( stdoutHandle, &csbiInfo ); - originalForegroundAttributes = csbiInfo.wAttributes & ~( BACKGROUND_GREEN | BACKGROUND_RED | BACKGROUND_BLUE | BACKGROUND_INTENSITY ); - originalBackgroundAttributes = csbiInfo.wAttributes & ~( FOREGROUND_GREEN | FOREGROUND_RED | FOREGROUND_BLUE | FOREGROUND_INTENSITY ); - } - - virtual void use( Colour::Code _colourCode ) { - switch( _colourCode ) { - case Colour::None: return setTextAttribute( originalForegroundAttributes ); - case Colour::White: return setTextAttribute( FOREGROUND_GREEN | FOREGROUND_RED | FOREGROUND_BLUE ); - case Colour::Red: return setTextAttribute( FOREGROUND_RED ); - case Colour::Green: return setTextAttribute( FOREGROUND_GREEN ); - case Colour::Blue: return setTextAttribute( FOREGROUND_BLUE ); - case Colour::Cyan: return setTextAttribute( FOREGROUND_BLUE | FOREGROUND_GREEN ); - case Colour::Yellow: return setTextAttribute( FOREGROUND_RED | FOREGROUND_GREEN ); - case Colour::Grey: return setTextAttribute( 0 ); - - case Colour::LightGrey: return setTextAttribute( FOREGROUND_INTENSITY ); - case Colour::BrightRed: return setTextAttribute( FOREGROUND_INTENSITY | FOREGROUND_RED ); - case Colour::BrightGreen: return setTextAttribute( FOREGROUND_INTENSITY | FOREGROUND_GREEN ); - case Colour::BrightWhite: return setTextAttribute( FOREGROUND_INTENSITY | FOREGROUND_GREEN | FOREGROUND_RED | FOREGROUND_BLUE ); - - case Colour::Bright: throw std::logic_error( "not a colour" ); - } - } - - private: - void setTextAttribute( WORD _textAttribute ) { - SetConsoleTextAttribute( stdoutHandle, _textAttribute | originalBackgroundAttributes ); - } - HANDLE stdoutHandle; - WORD originalForegroundAttributes; - WORD originalBackgroundAttributes; - }; - - IColourImpl* platformColourInstance() { - static Win32ColourImpl s_instance; - - Ptr config = getCurrentContext().getConfig(); - UseColour::YesOrNo colourMode = config - ? config->useColour() - : UseColour::Auto; - if( colourMode == UseColour::Auto ) - colourMode = !isDebuggerActive() - ? UseColour::Yes - : UseColour::No; - return colourMode == UseColour::Yes - ? &s_instance - : NoColourImpl::instance(); - } - -} // end anon namespace -} // end namespace Catch - -#elif defined( CATCH_CONFIG_COLOUR_ANSI ) ////////////////////////////////////// - -#include - -namespace Catch { -namespace { - - // use POSIX/ ANSI console terminal codes - // Thanks to Adam Strzelecki for original contribution - // (http://github.com/nanoant) - // https://github.com/philsquared/Catch/pull/131 - class PosixColourImpl : public IColourImpl { - public: - virtual void use( Colour::Code _colourCode ) { - switch( _colourCode ) { - case Colour::None: - case Colour::White: return setColour( "[0m" ); - case Colour::Red: return setColour( "[0;31m" ); - case Colour::Green: return setColour( "[0;32m" ); - case Colour::Blue: return setColour( "[0;34m" ); - case Colour::Cyan: return setColour( "[0;36m" ); - case Colour::Yellow: return setColour( "[0;33m" ); - case Colour::Grey: return setColour( "[1;30m" ); - - case Colour::LightGrey: return setColour( "[0;37m" ); - case Colour::BrightRed: return setColour( "[1;31m" ); - case Colour::BrightGreen: return setColour( "[1;32m" ); - case Colour::BrightWhite: return setColour( "[1;37m" ); - - case Colour::Bright: throw std::logic_error( "not a colour" ); - } - } - static IColourImpl* instance() { - static PosixColourImpl s_instance; - return &s_instance; - } - - private: - void setColour( const char* _escapeCode ) { - Catch::cout() << '\033' << _escapeCode; - } - }; - - IColourImpl* platformColourInstance() { - ErrnoGuard guard; - Ptr config = getCurrentContext().getConfig(); - UseColour::YesOrNo colourMode = config - ? config->useColour() - : UseColour::Auto; - if( colourMode == UseColour::Auto ) - colourMode = (!isDebuggerActive() && isatty(STDOUT_FILENO) ) - ? UseColour::Yes - : UseColour::No; - return colourMode == UseColour::Yes - ? PosixColourImpl::instance() - : NoColourImpl::instance(); - } - -} // end anon namespace -} // end namespace Catch - -#else // not Windows or ANSI /////////////////////////////////////////////// - -namespace Catch { - - static IColourImpl* platformColourInstance() { return NoColourImpl::instance(); } - -} // end namespace Catch - -#endif // Windows/ ANSI/ None - -namespace Catch { - - Colour::Colour( Code _colourCode ) : m_moved( false ) { use( _colourCode ); } - Colour::Colour( Colour const& _other ) : m_moved( false ) { const_cast( _other ).m_moved = true; } - Colour::~Colour(){ if( !m_moved ) use( None ); } - - void Colour::use( Code _colourCode ) { - static IColourImpl* impl = platformColourInstance(); - impl->use( _colourCode ); - } - -} // end namespace Catch - -// #included from: catch_generators_impl.hpp -#define TWOBLUECUBES_CATCH_GENERATORS_IMPL_HPP_INCLUDED - -#include -#include -#include - -namespace Catch { - - struct GeneratorInfo : IGeneratorInfo { - - GeneratorInfo( std::size_t size ) - : m_size( size ), - m_currentIndex( 0 ) - {} - - bool moveNext() { - if( ++m_currentIndex == m_size ) { - m_currentIndex = 0; - return false; - } - return true; - } - - std::size_t getCurrentIndex() const { - return m_currentIndex; - } - - std::size_t m_size; - std::size_t m_currentIndex; - }; - - /////////////////////////////////////////////////////////////////////////// - - class GeneratorsForTest : public IGeneratorsForTest { - - public: - ~GeneratorsForTest() { - deleteAll( m_generatorsInOrder ); - } - - IGeneratorInfo& getGeneratorInfo( std::string const& fileInfo, std::size_t size ) { - std::map::const_iterator it = m_generatorsByName.find( fileInfo ); - if( it == m_generatorsByName.end() ) { - IGeneratorInfo* info = new GeneratorInfo( size ); - m_generatorsByName.insert( std::make_pair( fileInfo, info ) ); - m_generatorsInOrder.push_back( info ); - return *info; - } - return *it->second; - } - - bool moveNext() { - std::vector::const_iterator it = m_generatorsInOrder.begin(); - std::vector::const_iterator itEnd = m_generatorsInOrder.end(); - for(; it != itEnd; ++it ) { - if( (*it)->moveNext() ) - return true; - } - return false; - } - - private: - std::map m_generatorsByName; - std::vector m_generatorsInOrder; - }; - - IGeneratorsForTest* createGeneratorsForTest() - { - return new GeneratorsForTest(); - } - -} // end namespace Catch - -// #included from: catch_assertionresult.hpp -#define TWOBLUECUBES_CATCH_ASSERTIONRESULT_HPP_INCLUDED - -namespace Catch { - - AssertionInfo::AssertionInfo():macroName(""), capturedExpression(""), resultDisposition(ResultDisposition::Normal), secondArg(""){} - - AssertionInfo::AssertionInfo( char const * _macroName, - SourceLineInfo const& _lineInfo, - char const * _capturedExpression, - ResultDisposition::Flags _resultDisposition, - char const * _secondArg) - : macroName( _macroName ), - lineInfo( _lineInfo ), - capturedExpression( _capturedExpression ), - resultDisposition( _resultDisposition ), - secondArg( _secondArg ) - {} - - AssertionResult::AssertionResult() {} - - AssertionResult::AssertionResult( AssertionInfo const& info, AssertionResultData const& data ) - : m_info( info ), - m_resultData( data ) - {} - - AssertionResult::~AssertionResult() {} - - // Result was a success - bool AssertionResult::succeeded() const { - return Catch::isOk( m_resultData.resultType ); - } - - // Result was a success, or failure is suppressed - bool AssertionResult::isOk() const { - return Catch::isOk( m_resultData.resultType ) || shouldSuppressFailure( m_info.resultDisposition ); - } - - ResultWas::OfType AssertionResult::getResultType() const { - return m_resultData.resultType; - } - - bool AssertionResult::hasExpression() const { - return m_info.capturedExpression[0] != 0; - } - - bool AssertionResult::hasMessage() const { - return !m_resultData.message.empty(); - } - - std::string capturedExpressionWithSecondArgument( char const * capturedExpression, char const * secondArg ) { - return (secondArg[0] == 0 || secondArg[0] == '"' && secondArg[1] == '"') - ? capturedExpression - : std::string(capturedExpression) + ", " + secondArg; - } - - std::string AssertionResult::getExpression() const { - if( isFalseTest( m_info.resultDisposition ) ) - return "!(" + capturedExpressionWithSecondArgument(m_info.capturedExpression, m_info.secondArg) + ")"; - else - return capturedExpressionWithSecondArgument(m_info.capturedExpression, m_info.secondArg); - } - std::string AssertionResult::getExpressionInMacro() const { - if( m_info.macroName[0] == 0 ) - return capturedExpressionWithSecondArgument(m_info.capturedExpression, m_info.secondArg); - else - return std::string(m_info.macroName) + "( " + capturedExpressionWithSecondArgument(m_info.capturedExpression, m_info.secondArg) + " )"; - } - - bool AssertionResult::hasExpandedExpression() const { - return hasExpression() && getExpandedExpression() != getExpression(); - } - - std::string AssertionResult::getExpandedExpression() const { - return m_resultData.reconstructExpression(); - } - - std::string AssertionResult::getMessage() const { - return m_resultData.message; - } - SourceLineInfo AssertionResult::getSourceInfo() const { - return m_info.lineInfo; - } - - std::string AssertionResult::getTestMacroName() const { - return m_info.macroName; - } - - void AssertionResult::discardDecomposedExpression() const { - m_resultData.decomposedExpression = CATCH_NULL; - } - - void AssertionResult::expandDecomposedExpression() const { - m_resultData.reconstructExpression(); - } - -} // end namespace Catch - -// #included from: catch_test_case_info.hpp -#define TWOBLUECUBES_CATCH_TEST_CASE_INFO_HPP_INCLUDED - -#include - -namespace Catch { - - inline TestCaseInfo::SpecialProperties parseSpecialTag( std::string const& tag ) { - if( startsWith( tag, '.' ) || - tag == "hide" || - tag == "!hide" ) - return TestCaseInfo::IsHidden; - else if( tag == "!throws" ) - return TestCaseInfo::Throws; - else if( tag == "!shouldfail" ) - return TestCaseInfo::ShouldFail; - else if( tag == "!mayfail" ) - return TestCaseInfo::MayFail; - else if( tag == "!nonportable" ) - return TestCaseInfo::NonPortable; - else - return TestCaseInfo::None; - } - inline bool isReservedTag( std::string const& tag ) { - return parseSpecialTag( tag ) == TestCaseInfo::None && tag.size() > 0 && !std::isalnum( tag[0] ); - } - inline void enforceNotReservedTag( std::string const& tag, SourceLineInfo const& _lineInfo ) { - if( isReservedTag( tag ) ) { - std::ostringstream ss; - ss << Colour(Colour::Red) - << "Tag name [" << tag << "] not allowed.\n" - << "Tag names starting with non alpha-numeric characters are reserved\n" - << Colour(Colour::FileName) - << _lineInfo << '\n'; - throw std::runtime_error(ss.str()); - } - } - - TestCase makeTestCase( ITestCase* _testCase, - std::string const& _className, - std::string const& _name, - std::string const& _descOrTags, - SourceLineInfo const& _lineInfo ) - { - bool isHidden( startsWith( _name, "./" ) ); // Legacy support - - // Parse out tags - std::set tags; - std::string desc, tag; - bool inTag = false; - for( std::size_t i = 0; i < _descOrTags.size(); ++i ) { - char c = _descOrTags[i]; - if( !inTag ) { - if( c == '[' ) - inTag = true; - else - desc += c; - } - else { - if( c == ']' ) { - TestCaseInfo::SpecialProperties prop = parseSpecialTag( tag ); - if( prop == TestCaseInfo::IsHidden ) - isHidden = true; - else if( prop == TestCaseInfo::None ) - enforceNotReservedTag( tag, _lineInfo ); - - tags.insert( tag ); - tag.clear(); - inTag = false; - } - else - tag += c; - } - } - if( isHidden ) { - tags.insert( "hide" ); - tags.insert( "." ); - } - - TestCaseInfo info( _name, _className, desc, tags, _lineInfo ); - return TestCase( _testCase, info ); - } - - void setTags( TestCaseInfo& testCaseInfo, std::set const& tags ) - { - testCaseInfo.tags = tags; - testCaseInfo.lcaseTags.clear(); - - std::ostringstream oss; - for( std::set::const_iterator it = tags.begin(), itEnd = tags.end(); it != itEnd; ++it ) { - oss << '[' << *it << ']'; - std::string lcaseTag = toLower( *it ); - testCaseInfo.properties = static_cast( testCaseInfo.properties | parseSpecialTag( lcaseTag ) ); - testCaseInfo.lcaseTags.insert( lcaseTag ); - } - testCaseInfo.tagsAsString = oss.str(); - } - - TestCaseInfo::TestCaseInfo( std::string const& _name, - std::string const& _className, - std::string const& _description, - std::set const& _tags, - SourceLineInfo const& _lineInfo ) - : name( _name ), - className( _className ), - description( _description ), - lineInfo( _lineInfo ), - properties( None ) - { - setTags( *this, _tags ); - } - - TestCaseInfo::TestCaseInfo( TestCaseInfo const& other ) - : name( other.name ), - className( other.className ), - description( other.description ), - tags( other.tags ), - lcaseTags( other.lcaseTags ), - tagsAsString( other.tagsAsString ), - lineInfo( other.lineInfo ), - properties( other.properties ) - {} - - bool TestCaseInfo::isHidden() const { - return ( properties & IsHidden ) != 0; - } - bool TestCaseInfo::throws() const { - return ( properties & Throws ) != 0; - } - bool TestCaseInfo::okToFail() const { - return ( properties & (ShouldFail | MayFail ) ) != 0; - } - bool TestCaseInfo::expectedToFail() const { - return ( properties & (ShouldFail ) ) != 0; - } - - TestCase::TestCase( ITestCase* testCase, TestCaseInfo const& info ) : TestCaseInfo( info ), test( testCase ) {} - - TestCase::TestCase( TestCase const& other ) - : TestCaseInfo( other ), - test( other.test ) - {} - - TestCase TestCase::withName( std::string const& _newName ) const { - TestCase other( *this ); - other.name = _newName; - return other; - } - - void TestCase::swap( TestCase& other ) { - test.swap( other.test ); - name.swap( other.name ); - className.swap( other.className ); - description.swap( other.description ); - tags.swap( other.tags ); - lcaseTags.swap( other.lcaseTags ); - tagsAsString.swap( other.tagsAsString ); - std::swap( TestCaseInfo::properties, static_cast( other ).properties ); - std::swap( lineInfo, other.lineInfo ); - } - - void TestCase::invoke() const { - test->invoke(); - } - - bool TestCase::operator == ( TestCase const& other ) const { - return test.get() == other.test.get() && - name == other.name && - className == other.className; - } - - bool TestCase::operator < ( TestCase const& other ) const { - return name < other.name; - } - TestCase& TestCase::operator = ( TestCase const& other ) { - TestCase temp( other ); - swap( temp ); - return *this; - } - - TestCaseInfo const& TestCase::getTestCaseInfo() const - { - return *this; - } - -} // end namespace Catch - -// #included from: catch_version.hpp -#define TWOBLUECUBES_CATCH_VERSION_HPP_INCLUDED - -namespace Catch { - - Version::Version - ( unsigned int _majorVersion, - unsigned int _minorVersion, - unsigned int _patchNumber, - char const * const _branchName, - unsigned int _buildNumber ) - : majorVersion( _majorVersion ), - minorVersion( _minorVersion ), - patchNumber( _patchNumber ), - branchName( _branchName ), - buildNumber( _buildNumber ) - {} - - std::ostream& operator << ( std::ostream& os, Version const& version ) { - os << version.majorVersion << '.' - << version.minorVersion << '.' - << version.patchNumber; - // branchName is never null -> 0th char is \0 if it is empty - if (version.branchName[0]) { - os << '-' << version.branchName - << '.' << version.buildNumber; - } - return os; - } - - inline Version libraryVersion() { - static Version version( 1, 12, 2, "", 0 ); - return version; - } - -} - -// #included from: catch_message.hpp -#define TWOBLUECUBES_CATCH_MESSAGE_HPP_INCLUDED - -namespace Catch { - - MessageInfo::MessageInfo( std::string const& _macroName, - SourceLineInfo const& _lineInfo, - ResultWas::OfType _type ) - : macroName( _macroName ), - lineInfo( _lineInfo ), - type( _type ), - sequence( ++globalCount ) - {} - - // This may need protecting if threading support is added - unsigned int MessageInfo::globalCount = 0; - - //////////////////////////////////////////////////////////////////////////// - - ScopedMessage::ScopedMessage( MessageBuilder const& builder ) - : m_info( builder.m_info ) - { - m_info.message = builder.m_stream.str(); - getResultCapture().pushScopedMessage( m_info ); - } - ScopedMessage::ScopedMessage( ScopedMessage const& other ) - : m_info( other.m_info ) - {} - -#if defined(_MSC_VER) -#pragma warning(push) -#pragma warning(disable:4996) // std::uncaught_exception is deprecated in C++17 -#endif - ScopedMessage::~ScopedMessage() { - if ( !std::uncaught_exception() ){ - getResultCapture().popScopedMessage(m_info); - } - } -#if defined(_MSC_VER) -#pragma warning(pop) -#endif - -} // end namespace Catch - -// #included from: catch_legacy_reporter_adapter.hpp -#define TWOBLUECUBES_CATCH_LEGACY_REPORTER_ADAPTER_HPP_INCLUDED - -// #included from: catch_legacy_reporter_adapter.h -#define TWOBLUECUBES_CATCH_LEGACY_REPORTER_ADAPTER_H_INCLUDED - -namespace Catch -{ - // Deprecated - struct IReporter : IShared { - virtual ~IReporter(); - - virtual bool shouldRedirectStdout() const = 0; - - virtual void StartTesting() = 0; - virtual void EndTesting( Totals const& totals ) = 0; - virtual void StartGroup( std::string const& groupName ) = 0; - virtual void EndGroup( std::string const& groupName, Totals const& totals ) = 0; - virtual void StartTestCase( TestCaseInfo const& testInfo ) = 0; - virtual void EndTestCase( TestCaseInfo const& testInfo, Totals const& totals, std::string const& stdOut, std::string const& stdErr ) = 0; - virtual void StartSection( std::string const& sectionName, std::string const& description ) = 0; - virtual void EndSection( std::string const& sectionName, Counts const& assertions ) = 0; - virtual void NoAssertionsInSection( std::string const& sectionName ) = 0; - virtual void NoAssertionsInTestCase( std::string const& testName ) = 0; - virtual void Aborted() = 0; - virtual void Result( AssertionResult const& result ) = 0; - }; - - class LegacyReporterAdapter : public SharedImpl - { - public: - LegacyReporterAdapter( Ptr const& legacyReporter ); - virtual ~LegacyReporterAdapter(); - - virtual ReporterPreferences getPreferences() const; - virtual void noMatchingTestCases( std::string const& ); - virtual void testRunStarting( TestRunInfo const& ); - virtual void testGroupStarting( GroupInfo const& groupInfo ); - virtual void testCaseStarting( TestCaseInfo const& testInfo ); - virtual void sectionStarting( SectionInfo const& sectionInfo ); - virtual void assertionStarting( AssertionInfo const& ); - virtual bool assertionEnded( AssertionStats const& assertionStats ); - virtual void sectionEnded( SectionStats const& sectionStats ); - virtual void testCaseEnded( TestCaseStats const& testCaseStats ); - virtual void testGroupEnded( TestGroupStats const& testGroupStats ); - virtual void testRunEnded( TestRunStats const& testRunStats ); - virtual void skipTest( TestCaseInfo const& ); - - private: - Ptr m_legacyReporter; - }; -} - -namespace Catch -{ - LegacyReporterAdapter::LegacyReporterAdapter( Ptr const& legacyReporter ) - : m_legacyReporter( legacyReporter ) - {} - LegacyReporterAdapter::~LegacyReporterAdapter() {} - - ReporterPreferences LegacyReporterAdapter::getPreferences() const { - ReporterPreferences prefs; - prefs.shouldRedirectStdOut = m_legacyReporter->shouldRedirectStdout(); - return prefs; - } - - void LegacyReporterAdapter::noMatchingTestCases( std::string const& ) {} - void LegacyReporterAdapter::testRunStarting( TestRunInfo const& ) { - m_legacyReporter->StartTesting(); - } - void LegacyReporterAdapter::testGroupStarting( GroupInfo const& groupInfo ) { - m_legacyReporter->StartGroup( groupInfo.name ); - } - void LegacyReporterAdapter::testCaseStarting( TestCaseInfo const& testInfo ) { - m_legacyReporter->StartTestCase( testInfo ); - } - void LegacyReporterAdapter::sectionStarting( SectionInfo const& sectionInfo ) { - m_legacyReporter->StartSection( sectionInfo.name, sectionInfo.description ); - } - void LegacyReporterAdapter::assertionStarting( AssertionInfo const& ) { - // Not on legacy interface - } - - bool LegacyReporterAdapter::assertionEnded( AssertionStats const& assertionStats ) { - if( assertionStats.assertionResult.getResultType() != ResultWas::Ok ) { - for( std::vector::const_iterator it = assertionStats.infoMessages.begin(), itEnd = assertionStats.infoMessages.end(); - it != itEnd; - ++it ) { - if( it->type == ResultWas::Info ) { - ResultBuilder rb( it->macroName.c_str(), it->lineInfo, "", ResultDisposition::Normal ); - rb << it->message; - rb.setResultType( ResultWas::Info ); - AssertionResult result = rb.build(); - m_legacyReporter->Result( result ); - } - } - } - m_legacyReporter->Result( assertionStats.assertionResult ); - return true; - } - void LegacyReporterAdapter::sectionEnded( SectionStats const& sectionStats ) { - if( sectionStats.missingAssertions ) - m_legacyReporter->NoAssertionsInSection( sectionStats.sectionInfo.name ); - m_legacyReporter->EndSection( sectionStats.sectionInfo.name, sectionStats.assertions ); - } - void LegacyReporterAdapter::testCaseEnded( TestCaseStats const& testCaseStats ) { - m_legacyReporter->EndTestCase - ( testCaseStats.testInfo, - testCaseStats.totals, - testCaseStats.stdOut, - testCaseStats.stdErr ); - } - void LegacyReporterAdapter::testGroupEnded( TestGroupStats const& testGroupStats ) { - if( testGroupStats.aborting ) - m_legacyReporter->Aborted(); - m_legacyReporter->EndGroup( testGroupStats.groupInfo.name, testGroupStats.totals ); - } - void LegacyReporterAdapter::testRunEnded( TestRunStats const& testRunStats ) { - m_legacyReporter->EndTesting( testRunStats.totals ); - } - void LegacyReporterAdapter::skipTest( TestCaseInfo const& ) { - } -} - -// #included from: catch_timer.hpp - -#ifdef __clang__ -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wc++11-long-long" -#endif - -#ifdef CATCH_PLATFORM_WINDOWS - -#else - -#include - -#endif - -namespace Catch { - - namespace { -#ifdef CATCH_PLATFORM_WINDOWS - UInt64 getCurrentTicks() { - static UInt64 hz=0, hzo=0; - if (!hz) { - QueryPerformanceFrequency( reinterpret_cast( &hz ) ); - QueryPerformanceCounter( reinterpret_cast( &hzo ) ); - } - UInt64 t; - QueryPerformanceCounter( reinterpret_cast( &t ) ); - return ((t-hzo)*1000000)/hz; - } -#else - UInt64 getCurrentTicks() { - timeval t; - gettimeofday(&t,CATCH_NULL); - return static_cast( t.tv_sec ) * 1000000ull + static_cast( t.tv_usec ); - } -#endif - } - - void Timer::start() { - m_ticks = getCurrentTicks(); - } - unsigned int Timer::getElapsedMicroseconds() const { - return static_cast(getCurrentTicks() - m_ticks); - } - unsigned int Timer::getElapsedMilliseconds() const { - return static_cast(getElapsedMicroseconds()/1000); - } - double Timer::getElapsedSeconds() const { - return getElapsedMicroseconds()/1000000.0; - } - -} // namespace Catch - -#ifdef __clang__ -#pragma clang diagnostic pop -#endif -// #included from: catch_common.hpp -#define TWOBLUECUBES_CATCH_COMMON_HPP_INCLUDED - -#include -#include - -namespace Catch { - - bool startsWith( std::string const& s, std::string const& prefix ) { - return s.size() >= prefix.size() && std::equal(prefix.begin(), prefix.end(), s.begin()); - } - bool startsWith( std::string const& s, char prefix ) { - return !s.empty() && s[0] == prefix; - } - bool endsWith( std::string const& s, std::string const& suffix ) { - return s.size() >= suffix.size() && std::equal(suffix.rbegin(), suffix.rend(), s.rbegin()); - } - bool endsWith( std::string const& s, char suffix ) { - return !s.empty() && s[s.size()-1] == suffix; - } - bool contains( std::string const& s, std::string const& infix ) { - return s.find( infix ) != std::string::npos; - } - char toLowerCh(char c) { - return static_cast( std::tolower( c ) ); - } - void toLowerInPlace( std::string& s ) { - std::transform( s.begin(), s.end(), s.begin(), toLowerCh ); - } - std::string toLower( std::string const& s ) { - std::string lc = s; - toLowerInPlace( lc ); - return lc; - } - std::string trim( std::string const& str ) { - static char const* whitespaceChars = "\n\r\t "; - std::string::size_type start = str.find_first_not_of( whitespaceChars ); - std::string::size_type end = str.find_last_not_of( whitespaceChars ); - - return start != std::string::npos ? str.substr( start, 1+end-start ) : std::string(); - } - - bool replaceInPlace( std::string& str, std::string const& replaceThis, std::string const& withThis ) { - bool replaced = false; - std::size_t i = str.find( replaceThis ); - while( i != std::string::npos ) { - replaced = true; - str = str.substr( 0, i ) + withThis + str.substr( i+replaceThis.size() ); - if( i < str.size()-withThis.size() ) - i = str.find( replaceThis, i+withThis.size() ); - else - i = std::string::npos; - } - return replaced; - } - - pluralise::pluralise( std::size_t count, std::string const& label ) - : m_count( count ), - m_label( label ) - {} - - std::ostream& operator << ( std::ostream& os, pluralise const& pluraliser ) { - os << pluraliser.m_count << ' ' << pluraliser.m_label; - if( pluraliser.m_count != 1 ) - os << 's'; - return os; - } - - SourceLineInfo::SourceLineInfo() : file(""), line( 0 ){} - SourceLineInfo::SourceLineInfo( char const* _file, std::size_t _line ) - : file( _file ), - line( _line ) - {} - bool SourceLineInfo::empty() const { - return file[0] == '\0'; - } - bool SourceLineInfo::operator == ( SourceLineInfo const& other ) const { - return line == other.line && (file == other.file || std::strcmp(file, other.file) == 0); - } - bool SourceLineInfo::operator < ( SourceLineInfo const& other ) const { - return line < other.line || ( line == other.line && (std::strcmp(file, other.file) < 0)); - } - - void seedRng( IConfig const& config ) { - if( config.rngSeed() != 0 ) - std::srand( config.rngSeed() ); - } - unsigned int rngSeed() { - return getCurrentContext().getConfig()->rngSeed(); - } - - std::ostream& operator << ( std::ostream& os, SourceLineInfo const& info ) { -#ifndef __GNUG__ - os << info.file << '(' << info.line << ')'; -#else - os << info.file << ':' << info.line; -#endif - return os; - } - - void throwLogicError( std::string const& message, SourceLineInfo const& locationInfo ) { - std::ostringstream oss; - oss << locationInfo << ": Internal Catch error: '" << message << '\''; - if( alwaysTrue() ) - throw std::logic_error( oss.str() ); - } -} - -// #included from: catch_section.hpp -#define TWOBLUECUBES_CATCH_SECTION_HPP_INCLUDED - -namespace Catch { - - SectionInfo::SectionInfo - ( SourceLineInfo const& _lineInfo, - std::string const& _name, - std::string const& _description ) - : name( _name ), - description( _description ), - lineInfo( _lineInfo ) - {} - - Section::Section( SectionInfo const& info ) - : m_info( info ), - m_sectionIncluded( getResultCapture().sectionStarted( m_info, m_assertions ) ) - { - m_timer.start(); - } - -#if defined(_MSC_VER) -#pragma warning(push) -#pragma warning(disable:4996) // std::uncaught_exception is deprecated in C++17 -#endif - Section::~Section() { - if( m_sectionIncluded ) { - SectionEndInfo endInfo( m_info, m_assertions, m_timer.getElapsedSeconds() ); - if( std::uncaught_exception() ) - getResultCapture().sectionEndedEarly( endInfo ); - else - getResultCapture().sectionEnded( endInfo ); - } - } -#if defined(_MSC_VER) -#pragma warning(pop) -#endif - - // This indicates whether the section should be executed or not - Section::operator bool() const { - return m_sectionIncluded; - } - -} // end namespace Catch - -// #included from: catch_debugger.hpp -#define TWOBLUECUBES_CATCH_DEBUGGER_HPP_INCLUDED - -#ifdef CATCH_PLATFORM_MAC - - #include - #include - #include - #include - #include - - namespace Catch{ - - // The following function is taken directly from the following technical note: - // http://developer.apple.com/library/mac/#qa/qa2004/qa1361.html - - // Returns true if the current process is being debugged (either - // running under the debugger or has a debugger attached post facto). - bool isDebuggerActive(){ - - int mib[4]; - struct kinfo_proc info; - size_t size; - - // Initialize the flags so that, if sysctl fails for some bizarre - // reason, we get a predictable result. - - info.kp_proc.p_flag = 0; - - // Initialize mib, which tells sysctl the info we want, in this case - // we're looking for information about a specific process ID. - - mib[0] = CTL_KERN; - mib[1] = KERN_PROC; - mib[2] = KERN_PROC_PID; - mib[3] = getpid(); - - // Call sysctl. - - size = sizeof(info); - if( sysctl(mib, sizeof(mib) / sizeof(*mib), &info, &size, CATCH_NULL, 0) != 0 ) { - Catch::cerr() << "\n** Call to sysctl failed - unable to determine if debugger is active **\n" << std::endl; - return false; - } - - // We're being debugged if the P_TRACED flag is set. - - return ( (info.kp_proc.p_flag & P_TRACED) != 0 ); - } - } // namespace Catch - -#elif defined(CATCH_PLATFORM_LINUX) - #include - #include - - namespace Catch{ - // The standard POSIX way of detecting a debugger is to attempt to - // ptrace() the process, but this needs to be done from a child and not - // this process itself to still allow attaching to this process later - // if wanted, so is rather heavy. Under Linux we have the PID of the - // "debugger" (which doesn't need to be gdb, of course, it could also - // be strace, for example) in /proc/$PID/status, so just get it from - // there instead. - bool isDebuggerActive(){ - // Libstdc++ has a bug, where std::ifstream sets errno to 0 - // This way our users can properly assert over errno values - ErrnoGuard guard; - std::ifstream in("/proc/self/status"); - for( std::string line; std::getline(in, line); ) { - static const int PREFIX_LEN = 11; - if( line.compare(0, PREFIX_LEN, "TracerPid:\t") == 0 ) { - // We're traced if the PID is not 0 and no other PID starts - // with 0 digit, so it's enough to check for just a single - // character. - return line.length() > PREFIX_LEN && line[PREFIX_LEN] != '0'; - } - } - - return false; - } - } // namespace Catch -#elif defined(_MSC_VER) - extern "C" __declspec(dllimport) int __stdcall IsDebuggerPresent(); - namespace Catch { - bool isDebuggerActive() { - return IsDebuggerPresent() != 0; - } - } -#elif defined(__MINGW32__) - extern "C" __declspec(dllimport) int __stdcall IsDebuggerPresent(); - namespace Catch { - bool isDebuggerActive() { - return IsDebuggerPresent() != 0; - } - } -#else - namespace Catch { - inline bool isDebuggerActive() { return false; } - } -#endif // Platform - -#ifdef CATCH_PLATFORM_WINDOWS - - namespace Catch { - void writeToDebugConsole( std::string const& text ) { - ::OutputDebugStringA( text.c_str() ); - } - } -#else - namespace Catch { - void writeToDebugConsole( std::string const& text ) { - // !TBD: Need a version for Mac/ XCode and other IDEs - Catch::cout() << text; - } - } -#endif // Platform - -// #included from: catch_tostring.hpp -#define TWOBLUECUBES_CATCH_TOSTRING_HPP_INCLUDED - -namespace Catch { - -namespace Detail { - - const std::string unprintableString = "{?}"; - - namespace { - const int hexThreshold = 255; - - struct Endianness { - enum Arch { Big, Little }; - - static Arch which() { - union _{ - int asInt; - char asChar[sizeof (int)]; - } u; - - u.asInt = 1; - return ( u.asChar[sizeof(int)-1] == 1 ) ? Big : Little; - } - }; - } - - std::string rawMemoryToString( const void *object, std::size_t size ) - { - // Reverse order for little endian architectures - int i = 0, end = static_cast( size ), inc = 1; - if( Endianness::which() == Endianness::Little ) { - i = end-1; - end = inc = -1; - } - - unsigned char const *bytes = static_cast(object); - std::ostringstream os; - os << "0x" << std::setfill('0') << std::hex; - for( ; i != end; i += inc ) - os << std::setw(2) << static_cast(bytes[i]); - return os.str(); - } -} - -std::string toString( std::string const& value ) { - std::string s = value; - if( getCurrentContext().getConfig()->showInvisibles() ) { - for(size_t i = 0; i < s.size(); ++i ) { - std::string subs; - switch( s[i] ) { - case '\n': subs = "\\n"; break; - case '\t': subs = "\\t"; break; - default: break; - } - if( !subs.empty() ) { - s = s.substr( 0, i ) + subs + s.substr( i+1 ); - ++i; - } - } - } - return '"' + s + '"'; -} -std::string toString( std::wstring const& value ) { - - std::string s; - s.reserve( value.size() ); - for(size_t i = 0; i < value.size(); ++i ) - s += value[i] <= 0xff ? static_cast( value[i] ) : '?'; - return Catch::toString( s ); -} - -std::string toString( const char* const value ) { - return value ? Catch::toString( std::string( value ) ) : std::string( "{null string}" ); -} - -std::string toString( char* const value ) { - return Catch::toString( static_cast( value ) ); -} - -std::string toString( const wchar_t* const value ) -{ - return value ? Catch::toString( std::wstring(value) ) : std::string( "{null string}" ); -} - -std::string toString( wchar_t* const value ) -{ - return Catch::toString( static_cast( value ) ); -} - -std::string toString( int value ) { - std::ostringstream oss; - oss << value; - if( value > Detail::hexThreshold ) - oss << " (0x" << std::hex << value << ')'; - return oss.str(); -} - -std::string toString( unsigned long value ) { - std::ostringstream oss; - oss << value; - if( value > Detail::hexThreshold ) - oss << " (0x" << std::hex << value << ')'; - return oss.str(); -} - -std::string toString( unsigned int value ) { - return Catch::toString( static_cast( value ) ); -} - -template -std::string fpToString( T value, int precision ) { - std::ostringstream oss; - oss << std::setprecision( precision ) - << std::fixed - << value; - std::string d = oss.str(); - std::size_t i = d.find_last_not_of( '0' ); - if( i != std::string::npos && i != d.size()-1 ) { - if( d[i] == '.' ) - i++; - d = d.substr( 0, i+1 ); - } - return d; -} - -std::string toString( const double value ) { - return fpToString( value, 10 ); -} -std::string toString( const float value ) { - return fpToString( value, 5 ) + 'f'; -} - -std::string toString( bool value ) { - return value ? "true" : "false"; -} - -std::string toString( char value ) { - if ( value == '\r' ) - return "'\\r'"; - if ( value == '\f' ) - return "'\\f'"; - if ( value == '\n' ) - return "'\\n'"; - if ( value == '\t' ) - return "'\\t'"; - if ( '\0' <= value && value < ' ' ) - return toString( static_cast( value ) ); - char chstr[] = "' '"; - chstr[1] = value; - return chstr; -} - -std::string toString( signed char value ) { - return toString( static_cast( value ) ); -} - -std::string toString( unsigned char value ) { - return toString( static_cast( value ) ); -} - -#ifdef CATCH_CONFIG_CPP11_LONG_LONG -std::string toString( long long value ) { - std::ostringstream oss; - oss << value; - if( value > Detail::hexThreshold ) - oss << " (0x" << std::hex << value << ')'; - return oss.str(); -} -std::string toString( unsigned long long value ) { - std::ostringstream oss; - oss << value; - if( value > Detail::hexThreshold ) - oss << " (0x" << std::hex << value << ')'; - return oss.str(); -} -#endif - -#ifdef CATCH_CONFIG_CPP11_NULLPTR -std::string toString( std::nullptr_t ) { - return "nullptr"; -} -#endif - -#ifdef __OBJC__ - std::string toString( NSString const * const& nsstring ) { - if( !nsstring ) - return "nil"; - return "@" + toString([nsstring UTF8String]); - } - std::string toString( NSString * CATCH_ARC_STRONG & nsstring ) { - if( !nsstring ) - return "nil"; - return "@" + toString([nsstring UTF8String]); - } - std::string toString( NSObject* const& nsObject ) { - return toString( [nsObject description] ); - } -#endif - -} // end namespace Catch - -// #included from: catch_result_builder.hpp -#define TWOBLUECUBES_CATCH_RESULT_BUILDER_HPP_INCLUDED - -#include - -namespace Catch { - - ResultBuilder::ResultBuilder( char const* macroName, - SourceLineInfo const& lineInfo, - char const* capturedExpression, - ResultDisposition::Flags resultDisposition, - char const* secondArg ) - : m_assertionInfo( macroName, lineInfo, capturedExpression, resultDisposition, secondArg ), - m_shouldDebugBreak( false ), - m_shouldThrow( false ), - m_guardException( false ), - m_usedStream( false ) - {} - - ResultBuilder::~ResultBuilder() { -#if defined(CATCH_CONFIG_FAST_COMPILE) - if ( m_guardException ) { - stream().oss << "Exception translation was disabled by CATCH_CONFIG_FAST_COMPILE"; - captureResult( ResultWas::ThrewException ); - getCurrentContext().getResultCapture()->exceptionEarlyReported(); - } -#endif - } - - ResultBuilder& ResultBuilder::setResultType( ResultWas::OfType result ) { - m_data.resultType = result; - return *this; - } - ResultBuilder& ResultBuilder::setResultType( bool result ) { - m_data.resultType = result ? ResultWas::Ok : ResultWas::ExpressionFailed; - return *this; - } - - void ResultBuilder::endExpression( DecomposedExpression const& expr ) { - // Flip bool results if FalseTest flag is set - if( isFalseTest( m_assertionInfo.resultDisposition ) ) { - m_data.negate( expr.isBinaryExpression() ); - } - - getResultCapture().assertionRun(); - - if(getCurrentContext().getConfig()->includeSuccessfulResults() || m_data.resultType != ResultWas::Ok) - { - AssertionResult result = build( expr ); - handleResult( result ); - } - else - getResultCapture().assertionPassed(); - } - - void ResultBuilder::useActiveException( ResultDisposition::Flags resultDisposition ) { - m_assertionInfo.resultDisposition = resultDisposition; - stream().oss << Catch::translateActiveException(); - captureResult( ResultWas::ThrewException ); - } - - void ResultBuilder::captureResult( ResultWas::OfType resultType ) { - setResultType( resultType ); - captureExpression(); - } - - void ResultBuilder::captureExpectedException( std::string const& expectedMessage ) { - if( expectedMessage.empty() ) - captureExpectedException( Matchers::Impl::MatchAllOf() ); - else - captureExpectedException( Matchers::Equals( expectedMessage ) ); - } - - void ResultBuilder::captureExpectedException( Matchers::Impl::MatcherBase const& matcher ) { - - assert( !isFalseTest( m_assertionInfo.resultDisposition ) ); - AssertionResultData data = m_data; - data.resultType = ResultWas::Ok; - data.reconstructedExpression = capturedExpressionWithSecondArgument(m_assertionInfo.capturedExpression, m_assertionInfo.secondArg); - - std::string actualMessage = Catch::translateActiveException(); - if( !matcher.match( actualMessage ) ) { - data.resultType = ResultWas::ExpressionFailed; - data.reconstructedExpression = actualMessage; - } - AssertionResult result( m_assertionInfo, data ); - handleResult( result ); - } - - void ResultBuilder::captureExpression() { - AssertionResult result = build(); - handleResult( result ); - } - - void ResultBuilder::handleResult( AssertionResult const& result ) - { - getResultCapture().assertionEnded( result ); - - if( !result.isOk() ) { - if( getCurrentContext().getConfig()->shouldDebugBreak() ) - m_shouldDebugBreak = true; - if( getCurrentContext().getRunner()->aborting() || (m_assertionInfo.resultDisposition & ResultDisposition::Normal) ) - m_shouldThrow = true; - } - } - - void ResultBuilder::react() { -#if defined(CATCH_CONFIG_FAST_COMPILE) - if (m_shouldDebugBreak) { - /////////////////////////////////////////////////////////////////// - // To inspect the state during test, you need to go one level up the callstack - // To go back to the test and change execution, jump over the throw statement - /////////////////////////////////////////////////////////////////// - CATCH_BREAK_INTO_DEBUGGER(); - } -#endif - if( m_shouldThrow ) - throw Catch::TestFailureException(); - } - - bool ResultBuilder::shouldDebugBreak() const { return m_shouldDebugBreak; } - bool ResultBuilder::allowThrows() const { return getCurrentContext().getConfig()->allowThrows(); } - - AssertionResult ResultBuilder::build() const - { - return build( *this ); - } - - // CAVEAT: The returned AssertionResult stores a pointer to the argument expr, - // a temporary DecomposedExpression, which in turn holds references to - // operands, possibly temporary as well. - // It should immediately be passed to handleResult; if the expression - // needs to be reported, its string expansion must be composed before - // the temporaries are destroyed. - AssertionResult ResultBuilder::build( DecomposedExpression const& expr ) const - { - assert( m_data.resultType != ResultWas::Unknown ); - AssertionResultData data = m_data; - - if(m_usedStream) - data.message = m_stream().oss.str(); - data.decomposedExpression = &expr; // for lazy reconstruction - return AssertionResult( m_assertionInfo, data ); - } - - void ResultBuilder::reconstructExpression( std::string& dest ) const { - dest = capturedExpressionWithSecondArgument(m_assertionInfo.capturedExpression, m_assertionInfo.secondArg); - } - - void ResultBuilder::setExceptionGuard() { - m_guardException = true; - } - void ResultBuilder::unsetExceptionGuard() { - m_guardException = false; - } - -} // end namespace Catch - -// #included from: catch_tag_alias_registry.hpp -#define TWOBLUECUBES_CATCH_TAG_ALIAS_REGISTRY_HPP_INCLUDED - -namespace Catch { - - TagAliasRegistry::~TagAliasRegistry() {} - - Option TagAliasRegistry::find( std::string const& alias ) const { - std::map::const_iterator it = m_registry.find( alias ); - if( it != m_registry.end() ) - return it->second; - else - return Option(); - } - - std::string TagAliasRegistry::expandAliases( std::string const& unexpandedTestSpec ) const { - std::string expandedTestSpec = unexpandedTestSpec; - for( std::map::const_iterator it = m_registry.begin(), itEnd = m_registry.end(); - it != itEnd; - ++it ) { - std::size_t pos = expandedTestSpec.find( it->first ); - if( pos != std::string::npos ) { - expandedTestSpec = expandedTestSpec.substr( 0, pos ) + - it->second.tag + - expandedTestSpec.substr( pos + it->first.size() ); - } - } - return expandedTestSpec; - } - - void TagAliasRegistry::add( std::string const& alias, std::string const& tag, SourceLineInfo const& lineInfo ) { - - if( !startsWith( alias, "[@" ) || !endsWith( alias, ']' ) ) { - std::ostringstream oss; - oss << Colour( Colour::Red ) - << "error: tag alias, \"" << alias << "\" is not of the form [@alias name].\n" - << Colour( Colour::FileName ) - << lineInfo << '\n'; - throw std::domain_error( oss.str().c_str() ); - } - if( !m_registry.insert( std::make_pair( alias, TagAlias( tag, lineInfo ) ) ).second ) { - std::ostringstream oss; - oss << Colour( Colour::Red ) - << "error: tag alias, \"" << alias << "\" already registered.\n" - << "\tFirst seen at " - << Colour( Colour::Red ) << find(alias)->lineInfo << '\n' - << Colour( Colour::Red ) << "\tRedefined at " - << Colour( Colour::FileName) << lineInfo << '\n'; - throw std::domain_error( oss.str().c_str() ); - } - } - - ITagAliasRegistry::~ITagAliasRegistry() {} - - ITagAliasRegistry const& ITagAliasRegistry::get() { - return getRegistryHub().getTagAliasRegistry(); - } - - RegistrarForTagAliases::RegistrarForTagAliases( char const* alias, char const* tag, SourceLineInfo const& lineInfo ) { - getMutableRegistryHub().registerTagAlias( alias, tag, lineInfo ); - } - -} // end namespace Catch - -// #included from: catch_matchers_string.hpp - -namespace Catch { -namespace Matchers { - - namespace StdString { - - CasedString::CasedString( std::string const& str, CaseSensitive::Choice caseSensitivity ) - : m_caseSensitivity( caseSensitivity ), - m_str( adjustString( str ) ) - {} - std::string CasedString::adjustString( std::string const& str ) const { - return m_caseSensitivity == CaseSensitive::No - ? toLower( str ) - : str; - } - std::string CasedString::caseSensitivitySuffix() const { - return m_caseSensitivity == CaseSensitive::No - ? " (case insensitive)" - : std::string(); - } - - StringMatcherBase::StringMatcherBase( std::string const& operation, CasedString const& comparator ) - : m_comparator( comparator ), - m_operation( operation ) { - } - - std::string StringMatcherBase::describe() const { - std::string description; - description.reserve(5 + m_operation.size() + m_comparator.m_str.size() + - m_comparator.caseSensitivitySuffix().size()); - description += m_operation; - description += ": \""; - description += m_comparator.m_str; - description += "\""; - description += m_comparator.caseSensitivitySuffix(); - return description; - } - - EqualsMatcher::EqualsMatcher( CasedString const& comparator ) : StringMatcherBase( "equals", comparator ) {} - - bool EqualsMatcher::match( std::string const& source ) const { - return m_comparator.adjustString( source ) == m_comparator.m_str; - } - - ContainsMatcher::ContainsMatcher( CasedString const& comparator ) : StringMatcherBase( "contains", comparator ) {} - - bool ContainsMatcher::match( std::string const& source ) const { - return contains( m_comparator.adjustString( source ), m_comparator.m_str ); - } - - StartsWithMatcher::StartsWithMatcher( CasedString const& comparator ) : StringMatcherBase( "starts with", comparator ) {} - - bool StartsWithMatcher::match( std::string const& source ) const { - return startsWith( m_comparator.adjustString( source ), m_comparator.m_str ); - } - - EndsWithMatcher::EndsWithMatcher( CasedString const& comparator ) : StringMatcherBase( "ends with", comparator ) {} - - bool EndsWithMatcher::match( std::string const& source ) const { - return endsWith( m_comparator.adjustString( source ), m_comparator.m_str ); - } - - } // namespace StdString - - StdString::EqualsMatcher Equals( std::string const& str, CaseSensitive::Choice caseSensitivity ) { - return StdString::EqualsMatcher( StdString::CasedString( str, caseSensitivity) ); - } - StdString::ContainsMatcher Contains( std::string const& str, CaseSensitive::Choice caseSensitivity ) { - return StdString::ContainsMatcher( StdString::CasedString( str, caseSensitivity) ); - } - StdString::EndsWithMatcher EndsWith( std::string const& str, CaseSensitive::Choice caseSensitivity ) { - return StdString::EndsWithMatcher( StdString::CasedString( str, caseSensitivity) ); - } - StdString::StartsWithMatcher StartsWith( std::string const& str, CaseSensitive::Choice caseSensitivity ) { - return StdString::StartsWithMatcher( StdString::CasedString( str, caseSensitivity) ); - } - -} // namespace Matchers -} // namespace Catch -// #included from: ../reporters/catch_reporter_multi.hpp -#define TWOBLUECUBES_CATCH_REPORTER_MULTI_HPP_INCLUDED - -namespace Catch { - -class MultipleReporters : public SharedImpl { - typedef std::vector > Reporters; - Reporters m_reporters; - -public: - void add( Ptr const& reporter ) { - m_reporters.push_back( reporter ); - } - -public: // IStreamingReporter - - virtual ReporterPreferences getPreferences() const CATCH_OVERRIDE { - return m_reporters[0]->getPreferences(); - } - - virtual void noMatchingTestCases( std::string const& spec ) CATCH_OVERRIDE { - for( Reporters::const_iterator it = m_reporters.begin(), itEnd = m_reporters.end(); - it != itEnd; - ++it ) - (*it)->noMatchingTestCases( spec ); - } - - virtual void testRunStarting( TestRunInfo const& testRunInfo ) CATCH_OVERRIDE { - for( Reporters::const_iterator it = m_reporters.begin(), itEnd = m_reporters.end(); - it != itEnd; - ++it ) - (*it)->testRunStarting( testRunInfo ); - } - - virtual void testGroupStarting( GroupInfo const& groupInfo ) CATCH_OVERRIDE { - for( Reporters::const_iterator it = m_reporters.begin(), itEnd = m_reporters.end(); - it != itEnd; - ++it ) - (*it)->testGroupStarting( groupInfo ); - } - - virtual void testCaseStarting( TestCaseInfo const& testInfo ) CATCH_OVERRIDE { - for( Reporters::const_iterator it = m_reporters.begin(), itEnd = m_reporters.end(); - it != itEnd; - ++it ) - (*it)->testCaseStarting( testInfo ); - } - - virtual void sectionStarting( SectionInfo const& sectionInfo ) CATCH_OVERRIDE { - for( Reporters::const_iterator it = m_reporters.begin(), itEnd = m_reporters.end(); - it != itEnd; - ++it ) - (*it)->sectionStarting( sectionInfo ); - } - - virtual void assertionStarting( AssertionInfo const& assertionInfo ) CATCH_OVERRIDE { - for( Reporters::const_iterator it = m_reporters.begin(), itEnd = m_reporters.end(); - it != itEnd; - ++it ) - (*it)->assertionStarting( assertionInfo ); - } - - // The return value indicates if the messages buffer should be cleared: - virtual bool assertionEnded( AssertionStats const& assertionStats ) CATCH_OVERRIDE { - bool clearBuffer = false; - for( Reporters::const_iterator it = m_reporters.begin(), itEnd = m_reporters.end(); - it != itEnd; - ++it ) - clearBuffer |= (*it)->assertionEnded( assertionStats ); - return clearBuffer; - } - - virtual void sectionEnded( SectionStats const& sectionStats ) CATCH_OVERRIDE { - for( Reporters::const_iterator it = m_reporters.begin(), itEnd = m_reporters.end(); - it != itEnd; - ++it ) - (*it)->sectionEnded( sectionStats ); - } - - virtual void testCaseEnded( TestCaseStats const& testCaseStats ) CATCH_OVERRIDE { - for( Reporters::const_iterator it = m_reporters.begin(), itEnd = m_reporters.end(); - it != itEnd; - ++it ) - (*it)->testCaseEnded( testCaseStats ); - } - - virtual void testGroupEnded( TestGroupStats const& testGroupStats ) CATCH_OVERRIDE { - for( Reporters::const_iterator it = m_reporters.begin(), itEnd = m_reporters.end(); - it != itEnd; - ++it ) - (*it)->testGroupEnded( testGroupStats ); - } - - virtual void testRunEnded( TestRunStats const& testRunStats ) CATCH_OVERRIDE { - for( Reporters::const_iterator it = m_reporters.begin(), itEnd = m_reporters.end(); - it != itEnd; - ++it ) - (*it)->testRunEnded( testRunStats ); - } - - virtual void skipTest( TestCaseInfo const& testInfo ) CATCH_OVERRIDE { - for( Reporters::const_iterator it = m_reporters.begin(), itEnd = m_reporters.end(); - it != itEnd; - ++it ) - (*it)->skipTest( testInfo ); - } - - virtual MultipleReporters* tryAsMulti() CATCH_OVERRIDE { - return this; - } - -}; - -Ptr addReporter( Ptr const& existingReporter, Ptr const& additionalReporter ) { - Ptr resultingReporter; - - if( existingReporter ) { - MultipleReporters* multi = existingReporter->tryAsMulti(); - if( !multi ) { - multi = new MultipleReporters; - resultingReporter = Ptr( multi ); - if( existingReporter ) - multi->add( existingReporter ); - } - else - resultingReporter = existingReporter; - multi->add( additionalReporter ); - } - else - resultingReporter = additionalReporter; - - return resultingReporter; -} - -} // end namespace Catch - -// #included from: ../reporters/catch_reporter_xml.hpp -#define TWOBLUECUBES_CATCH_REPORTER_XML_HPP_INCLUDED - -// #included from: catch_reporter_bases.hpp -#define TWOBLUECUBES_CATCH_REPORTER_BASES_HPP_INCLUDED - -#include -#include -#include -#include - -namespace Catch { - - namespace { - // Because formatting using c++ streams is stateful, drop down to C is required - // Alternatively we could use stringstream, but its performance is... not good. - std::string getFormattedDuration( double duration ) { - // Max exponent + 1 is required to represent the whole part - // + 1 for decimal point - // + 3 for the 3 decimal places - // + 1 for null terminator - const size_t maxDoubleSize = DBL_MAX_10_EXP + 1 + 1 + 3 + 1; - char buffer[maxDoubleSize]; - - // Save previous errno, to prevent sprintf from overwriting it - ErrnoGuard guard; -#ifdef _MSC_VER - sprintf_s(buffer, "%.3f", duration); -#else - sprintf(buffer, "%.3f", duration); -#endif - return std::string(buffer); - } - } - - struct StreamingReporterBase : SharedImpl { - - StreamingReporterBase( ReporterConfig const& _config ) - : m_config( _config.fullConfig() ), - stream( _config.stream() ) - { - m_reporterPrefs.shouldRedirectStdOut = false; - } - - virtual ReporterPreferences getPreferences() const CATCH_OVERRIDE { - return m_reporterPrefs; - } - - virtual ~StreamingReporterBase() CATCH_OVERRIDE; - - virtual void noMatchingTestCases( std::string const& ) CATCH_OVERRIDE {} - - virtual void testRunStarting( TestRunInfo const& _testRunInfo ) CATCH_OVERRIDE { - currentTestRunInfo = _testRunInfo; - } - virtual void testGroupStarting( GroupInfo const& _groupInfo ) CATCH_OVERRIDE { - currentGroupInfo = _groupInfo; - } - - virtual void testCaseStarting( TestCaseInfo const& _testInfo ) CATCH_OVERRIDE { - currentTestCaseInfo = _testInfo; - } - virtual void sectionStarting( SectionInfo const& _sectionInfo ) CATCH_OVERRIDE { - m_sectionStack.push_back( _sectionInfo ); - } - - virtual void sectionEnded( SectionStats const& /* _sectionStats */ ) CATCH_OVERRIDE { - m_sectionStack.pop_back(); - } - virtual void testCaseEnded( TestCaseStats const& /* _testCaseStats */ ) CATCH_OVERRIDE { - currentTestCaseInfo.reset(); - } - virtual void testGroupEnded( TestGroupStats const& /* _testGroupStats */ ) CATCH_OVERRIDE { - currentGroupInfo.reset(); - } - virtual void testRunEnded( TestRunStats const& /* _testRunStats */ ) CATCH_OVERRIDE { - currentTestCaseInfo.reset(); - currentGroupInfo.reset(); - currentTestRunInfo.reset(); - } - - virtual void skipTest( TestCaseInfo const& ) CATCH_OVERRIDE { - // Don't do anything with this by default. - // It can optionally be overridden in the derived class. - } - - Ptr m_config; - std::ostream& stream; - - LazyStat currentTestRunInfo; - LazyStat currentGroupInfo; - LazyStat currentTestCaseInfo; - - std::vector m_sectionStack; - ReporterPreferences m_reporterPrefs; - }; - - struct CumulativeReporterBase : SharedImpl { - template - struct Node : SharedImpl<> { - explicit Node( T const& _value ) : value( _value ) {} - virtual ~Node() {} - - typedef std::vector > ChildNodes; - T value; - ChildNodes children; - }; - struct SectionNode : SharedImpl<> { - explicit SectionNode( SectionStats const& _stats ) : stats( _stats ) {} - virtual ~SectionNode(); - - bool operator == ( SectionNode const& other ) const { - return stats.sectionInfo.lineInfo == other.stats.sectionInfo.lineInfo; - } - bool operator == ( Ptr const& other ) const { - return operator==( *other ); - } - - SectionStats stats; - typedef std::vector > ChildSections; - typedef std::vector Assertions; - ChildSections childSections; - Assertions assertions; - std::string stdOut; - std::string stdErr; - }; - - struct BySectionInfo { - BySectionInfo( SectionInfo const& other ) : m_other( other ) {} - BySectionInfo( BySectionInfo const& other ) : m_other( other.m_other ) {} - bool operator() ( Ptr const& node ) const { - return ((node->stats.sectionInfo.name == m_other.name) && - (node->stats.sectionInfo.lineInfo == m_other.lineInfo)); - } - private: - void operator=( BySectionInfo const& ); - SectionInfo const& m_other; - }; - - typedef Node TestCaseNode; - typedef Node TestGroupNode; - typedef Node TestRunNode; - - CumulativeReporterBase( ReporterConfig const& _config ) - : m_config( _config.fullConfig() ), - stream( _config.stream() ) - { - m_reporterPrefs.shouldRedirectStdOut = false; - } - ~CumulativeReporterBase(); - - virtual ReporterPreferences getPreferences() const CATCH_OVERRIDE { - return m_reporterPrefs; - } - - virtual void testRunStarting( TestRunInfo const& ) CATCH_OVERRIDE {} - virtual void testGroupStarting( GroupInfo const& ) CATCH_OVERRIDE {} - - virtual void testCaseStarting( TestCaseInfo const& ) CATCH_OVERRIDE {} - - virtual void sectionStarting( SectionInfo const& sectionInfo ) CATCH_OVERRIDE { - SectionStats incompleteStats( sectionInfo, Counts(), 0, false ); - Ptr node; - if( m_sectionStack.empty() ) { - if( !m_rootSection ) - m_rootSection = new SectionNode( incompleteStats ); - node = m_rootSection; - } - else { - SectionNode& parentNode = *m_sectionStack.back(); - SectionNode::ChildSections::const_iterator it = - std::find_if( parentNode.childSections.begin(), - parentNode.childSections.end(), - BySectionInfo( sectionInfo ) ); - if( it == parentNode.childSections.end() ) { - node = new SectionNode( incompleteStats ); - parentNode.childSections.push_back( node ); - } - else - node = *it; - } - m_sectionStack.push_back( node ); - m_deepestSection = node; - } - - virtual void assertionStarting( AssertionInfo const& ) CATCH_OVERRIDE {} - - virtual bool assertionEnded( AssertionStats const& assertionStats ) CATCH_OVERRIDE { - assert( !m_sectionStack.empty() ); - SectionNode& sectionNode = *m_sectionStack.back(); - sectionNode.assertions.push_back( assertionStats ); - // AssertionResult holds a pointer to a temporary DecomposedExpression, - // which getExpandedExpression() calls to build the expression string. - // Our section stack copy of the assertionResult will likely outlive the - // temporary, so it must be expanded or discarded now to avoid calling - // a destroyed object later. - prepareExpandedExpression( sectionNode.assertions.back().assertionResult ); - return true; - } - virtual void sectionEnded( SectionStats const& sectionStats ) CATCH_OVERRIDE { - assert( !m_sectionStack.empty() ); - SectionNode& node = *m_sectionStack.back(); - node.stats = sectionStats; - m_sectionStack.pop_back(); - } - virtual void testCaseEnded( TestCaseStats const& testCaseStats ) CATCH_OVERRIDE { - Ptr node = new TestCaseNode( testCaseStats ); - assert( m_sectionStack.size() == 0 ); - node->children.push_back( m_rootSection ); - m_testCases.push_back( node ); - m_rootSection.reset(); - - assert( m_deepestSection ); - m_deepestSection->stdOut = testCaseStats.stdOut; - m_deepestSection->stdErr = testCaseStats.stdErr; - } - virtual void testGroupEnded( TestGroupStats const& testGroupStats ) CATCH_OVERRIDE { - Ptr node = new TestGroupNode( testGroupStats ); - node->children.swap( m_testCases ); - m_testGroups.push_back( node ); - } - virtual void testRunEnded( TestRunStats const& testRunStats ) CATCH_OVERRIDE { - Ptr node = new TestRunNode( testRunStats ); - node->children.swap( m_testGroups ); - m_testRuns.push_back( node ); - testRunEndedCumulative(); - } - virtual void testRunEndedCumulative() = 0; - - virtual void skipTest( TestCaseInfo const& ) CATCH_OVERRIDE {} - - virtual void prepareExpandedExpression( AssertionResult& result ) const { - if( result.isOk() ) - result.discardDecomposedExpression(); - else - result.expandDecomposedExpression(); - } - - Ptr m_config; - std::ostream& stream; - std::vector m_assertions; - std::vector > > m_sections; - std::vector > m_testCases; - std::vector > m_testGroups; - - std::vector > m_testRuns; - - Ptr m_rootSection; - Ptr m_deepestSection; - std::vector > m_sectionStack; - ReporterPreferences m_reporterPrefs; - - }; - - template - char const* getLineOfChars() { - static char line[CATCH_CONFIG_CONSOLE_WIDTH] = {0}; - if( !*line ) { - std::memset( line, C, CATCH_CONFIG_CONSOLE_WIDTH-1 ); - line[CATCH_CONFIG_CONSOLE_WIDTH-1] = 0; - } - return line; - } - - struct TestEventListenerBase : StreamingReporterBase { - TestEventListenerBase( ReporterConfig const& _config ) - : StreamingReporterBase( _config ) - {} - - virtual void assertionStarting( AssertionInfo const& ) CATCH_OVERRIDE {} - virtual bool assertionEnded( AssertionStats const& ) CATCH_OVERRIDE { - return false; - } - }; - -} // end namespace Catch - -// #included from: ../internal/catch_reporter_registrars.hpp -#define TWOBLUECUBES_CATCH_REPORTER_REGISTRARS_HPP_INCLUDED - -namespace Catch { - - template - class LegacyReporterRegistrar { - - class ReporterFactory : public IReporterFactory { - virtual IStreamingReporter* create( ReporterConfig const& config ) const { - return new LegacyReporterAdapter( new T( config ) ); - } - - virtual std::string getDescription() const { - return T::getDescription(); - } - }; - - public: - - LegacyReporterRegistrar( std::string const& name ) { - getMutableRegistryHub().registerReporter( name, new ReporterFactory() ); - } - }; - - template - class ReporterRegistrar { - - class ReporterFactory : public SharedImpl { - - // *** Please Note ***: - // - If you end up here looking at a compiler error because it's trying to register - // your custom reporter class be aware that the native reporter interface has changed - // to IStreamingReporter. The "legacy" interface, IReporter, is still supported via - // an adapter. Just use REGISTER_LEGACY_REPORTER to take advantage of the adapter. - // However please consider updating to the new interface as the old one is now - // deprecated and will probably be removed quite soon! - // Please contact me via github if you have any questions at all about this. - // In fact, ideally, please contact me anyway to let me know you've hit this - as I have - // no idea who is actually using custom reporters at all (possibly no-one!). - // The new interface is designed to minimise exposure to interface changes in the future. - virtual IStreamingReporter* create( ReporterConfig const& config ) const { - return new T( config ); - } - - virtual std::string getDescription() const { - return T::getDescription(); - } - }; - - public: - - ReporterRegistrar( std::string const& name ) { - getMutableRegistryHub().registerReporter( name, new ReporterFactory() ); - } - }; - - template - class ListenerRegistrar { - - class ListenerFactory : public SharedImpl { - - virtual IStreamingReporter* create( ReporterConfig const& config ) const { - return new T( config ); - } - virtual std::string getDescription() const { - return std::string(); - } - }; - - public: - - ListenerRegistrar() { - getMutableRegistryHub().registerListener( new ListenerFactory() ); - } - }; -} - -#define INTERNAL_CATCH_REGISTER_LEGACY_REPORTER( name, reporterType ) \ - namespace{ Catch::LegacyReporterRegistrar catch_internal_RegistrarFor##reporterType( name ); } - -#define INTERNAL_CATCH_REGISTER_REPORTER( name, reporterType ) \ - namespace{ Catch::ReporterRegistrar catch_internal_RegistrarFor##reporterType( name ); } - -// Deprecated - use the form without INTERNAL_ -#define INTERNAL_CATCH_REGISTER_LISTENER( listenerType ) \ - namespace{ Catch::ListenerRegistrar catch_internal_RegistrarFor##listenerType; } - -#define CATCH_REGISTER_LISTENER( listenerType ) \ - namespace{ Catch::ListenerRegistrar catch_internal_RegistrarFor##listenerType; } - -// #included from: ../internal/catch_xmlwriter.hpp -#define TWOBLUECUBES_CATCH_XMLWRITER_HPP_INCLUDED - -#include -#include -#include -#include - -namespace Catch { - - class XmlEncode { - public: - enum ForWhat { ForTextNodes, ForAttributes }; - - XmlEncode( std::string const& str, ForWhat forWhat = ForTextNodes ) - : m_str( str ), - m_forWhat( forWhat ) - {} - - void encodeTo( std::ostream& os ) const { - - // Apostrophe escaping not necessary if we always use " to write attributes - // (see: http://www.w3.org/TR/xml/#syntax) - - for( std::size_t i = 0; i < m_str.size(); ++ i ) { - char c = m_str[i]; - switch( c ) { - case '<': os << "<"; break; - case '&': os << "&"; break; - - case '>': - // See: http://www.w3.org/TR/xml/#syntax - if( i > 2 && m_str[i-1] == ']' && m_str[i-2] == ']' ) - os << ">"; - else - os << c; - break; - - case '\"': - if( m_forWhat == ForAttributes ) - os << """; - else - os << c; - break; - - default: - // Escape control chars - based on contribution by @espenalb in PR #465 and - // by @mrpi PR #588 - if ( ( c >= 0 && c < '\x09' ) || ( c > '\x0D' && c < '\x20') || c=='\x7F' ) { - // see http://stackoverflow.com/questions/404107/why-are-control-characters-illegal-in-xml-1-0 - os << "\\x" << std::uppercase << std::hex << std::setfill('0') << std::setw(2) - << static_cast( c ); - } - else - os << c; - } - } - } - - friend std::ostream& operator << ( std::ostream& os, XmlEncode const& xmlEncode ) { - xmlEncode.encodeTo( os ); - return os; - } - - private: - std::string m_str; - ForWhat m_forWhat; - }; - - class XmlWriter { - public: - - class ScopedElement { - public: - ScopedElement( XmlWriter* writer ) - : m_writer( writer ) - {} - - ScopedElement( ScopedElement const& other ) - : m_writer( other.m_writer ){ - other.m_writer = CATCH_NULL; - } - - ~ScopedElement() { - if( m_writer ) - m_writer->endElement(); - } - - ScopedElement& writeText( std::string const& text, bool indent = true ) { - m_writer->writeText( text, indent ); - return *this; - } - - template - ScopedElement& writeAttribute( std::string const& name, T const& attribute ) { - m_writer->writeAttribute( name, attribute ); - return *this; - } - - private: - mutable XmlWriter* m_writer; - }; - - XmlWriter() - : m_tagIsOpen( false ), - m_needsNewline( false ), - m_os( Catch::cout() ) - { - writeDeclaration(); - } - - XmlWriter( std::ostream& os ) - : m_tagIsOpen( false ), - m_needsNewline( false ), - m_os( os ) - { - writeDeclaration(); - } - - ~XmlWriter() { - while( !m_tags.empty() ) - endElement(); - } - - XmlWriter& startElement( std::string const& name ) { - ensureTagClosed(); - newlineIfNecessary(); - m_os << m_indent << '<' << name; - m_tags.push_back( name ); - m_indent += " "; - m_tagIsOpen = true; - return *this; - } - - ScopedElement scopedElement( std::string const& name ) { - ScopedElement scoped( this ); - startElement( name ); - return scoped; - } - - XmlWriter& endElement() { - newlineIfNecessary(); - m_indent = m_indent.substr( 0, m_indent.size()-2 ); - if( m_tagIsOpen ) { - m_os << "/>"; - m_tagIsOpen = false; - } - else { - m_os << m_indent << ""; - } - m_os << std::endl; - m_tags.pop_back(); - return *this; - } - - XmlWriter& writeAttribute( std::string const& name, std::string const& attribute ) { - if( !name.empty() && !attribute.empty() ) - m_os << ' ' << name << "=\"" << XmlEncode( attribute, XmlEncode::ForAttributes ) << '"'; - return *this; - } - - XmlWriter& writeAttribute( std::string const& name, bool attribute ) { - m_os << ' ' << name << "=\"" << ( attribute ? "true" : "false" ) << '"'; - return *this; - } - - template - XmlWriter& writeAttribute( std::string const& name, T const& attribute ) { - std::ostringstream oss; - oss << attribute; - return writeAttribute( name, oss.str() ); - } - - XmlWriter& writeText( std::string const& text, bool indent = true ) { - if( !text.empty() ){ - bool tagWasOpen = m_tagIsOpen; - ensureTagClosed(); - if( tagWasOpen && indent ) - m_os << m_indent; - m_os << XmlEncode( text ); - m_needsNewline = true; - } - return *this; - } - - XmlWriter& writeComment( std::string const& text ) { - ensureTagClosed(); - m_os << m_indent << ""; - m_needsNewline = true; - return *this; - } - - void writeStylesheetRef( std::string const& url ) { - m_os << "\n"; - } - - XmlWriter& writeBlankLine() { - ensureTagClosed(); - m_os << '\n'; - return *this; - } - - void ensureTagClosed() { - if( m_tagIsOpen ) { - m_os << ">" << std::endl; - m_tagIsOpen = false; - } - } - - private: - XmlWriter( XmlWriter const& ); - void operator=( XmlWriter const& ); - - void writeDeclaration() { - m_os << "\n"; - } - - void newlineIfNecessary() { - if( m_needsNewline ) { - m_os << std::endl; - m_needsNewline = false; - } - } - - bool m_tagIsOpen; - bool m_needsNewline; - std::vector m_tags; - std::string m_indent; - std::ostream& m_os; - }; - -} - -namespace Catch { - class XmlReporter : public StreamingReporterBase { - public: - XmlReporter( ReporterConfig const& _config ) - : StreamingReporterBase( _config ), - m_xml(_config.stream()), - m_sectionDepth( 0 ) - { - m_reporterPrefs.shouldRedirectStdOut = true; - } - - virtual ~XmlReporter() CATCH_OVERRIDE; - - static std::string getDescription() { - return "Reports test results as an XML document"; - } - - virtual std::string getStylesheetRef() const { - return std::string(); - } - - void writeSourceInfo( SourceLineInfo const& sourceInfo ) { - m_xml - .writeAttribute( "filename", sourceInfo.file ) - .writeAttribute( "line", sourceInfo.line ); - } - - public: // StreamingReporterBase - - virtual void noMatchingTestCases( std::string const& s ) CATCH_OVERRIDE { - StreamingReporterBase::noMatchingTestCases( s ); - } - - virtual void testRunStarting( TestRunInfo const& testInfo ) CATCH_OVERRIDE { - StreamingReporterBase::testRunStarting( testInfo ); - std::string stylesheetRef = getStylesheetRef(); - if( !stylesheetRef.empty() ) - m_xml.writeStylesheetRef( stylesheetRef ); - m_xml.startElement( "Catch" ); - if( !m_config->name().empty() ) - m_xml.writeAttribute( "name", m_config->name() ); - } - - virtual void testGroupStarting( GroupInfo const& groupInfo ) CATCH_OVERRIDE { - StreamingReporterBase::testGroupStarting( groupInfo ); - m_xml.startElement( "Group" ) - .writeAttribute( "name", groupInfo.name ); - } - - virtual void testCaseStarting( TestCaseInfo const& testInfo ) CATCH_OVERRIDE { - StreamingReporterBase::testCaseStarting(testInfo); - m_xml.startElement( "TestCase" ) - .writeAttribute( "name", trim( testInfo.name ) ) - .writeAttribute( "description", testInfo.description ) - .writeAttribute( "tags", testInfo.tagsAsString ); - - writeSourceInfo( testInfo.lineInfo ); - - if ( m_config->showDurations() == ShowDurations::Always ) - m_testCaseTimer.start(); - m_xml.ensureTagClosed(); - } - - virtual void sectionStarting( SectionInfo const& sectionInfo ) CATCH_OVERRIDE { - StreamingReporterBase::sectionStarting( sectionInfo ); - if( m_sectionDepth++ > 0 ) { - m_xml.startElement( "Section" ) - .writeAttribute( "name", trim( sectionInfo.name ) ) - .writeAttribute( "description", sectionInfo.description ); - writeSourceInfo( sectionInfo.lineInfo ); - m_xml.ensureTagClosed(); - } - } - - virtual void assertionStarting( AssertionInfo const& ) CATCH_OVERRIDE { } - - virtual bool assertionEnded( AssertionStats const& assertionStats ) CATCH_OVERRIDE { - - AssertionResult const& result = assertionStats.assertionResult; - - bool includeResults = m_config->includeSuccessfulResults() || !result.isOk(); - - if( includeResults || result.getResultType() == ResultWas::Warning ) { - // Print any info messages in tags. - for( std::vector::const_iterator it = assertionStats.infoMessages.begin(), itEnd = assertionStats.infoMessages.end(); - it != itEnd; - ++it ) { - if( it->type == ResultWas::Info && includeResults ) { - m_xml.scopedElement( "Info" ) - .writeText( it->message ); - } else if ( it->type == ResultWas::Warning ) { - m_xml.scopedElement( "Warning" ) - .writeText( it->message ); - } - } - } - - // Drop out if result was successful but we're not printing them. - if( !includeResults && result.getResultType() != ResultWas::Warning ) - return true; - - // Print the expression if there is one. - if( result.hasExpression() ) { - m_xml.startElement( "Expression" ) - .writeAttribute( "success", result.succeeded() ) - .writeAttribute( "type", result.getTestMacroName() ); - - writeSourceInfo( result.getSourceInfo() ); - - m_xml.scopedElement( "Original" ) - .writeText( result.getExpression() ); - m_xml.scopedElement( "Expanded" ) - .writeText( result.getExpandedExpression() ); - } - - // And... Print a result applicable to each result type. - switch( result.getResultType() ) { - case ResultWas::ThrewException: - m_xml.startElement( "Exception" ); - writeSourceInfo( result.getSourceInfo() ); - m_xml.writeText( result.getMessage() ); - m_xml.endElement(); - break; - case ResultWas::FatalErrorCondition: - m_xml.startElement( "FatalErrorCondition" ); - writeSourceInfo( result.getSourceInfo() ); - m_xml.writeText( result.getMessage() ); - m_xml.endElement(); - break; - case ResultWas::Info: - m_xml.scopedElement( "Info" ) - .writeText( result.getMessage() ); - break; - case ResultWas::Warning: - // Warning will already have been written - break; - case ResultWas::ExplicitFailure: - m_xml.startElement( "Failure" ); - writeSourceInfo( result.getSourceInfo() ); - m_xml.writeText( result.getMessage() ); - m_xml.endElement(); - break; - default: - break; - } - - if( result.hasExpression() ) - m_xml.endElement(); - - return true; - } - - virtual void sectionEnded( SectionStats const& sectionStats ) CATCH_OVERRIDE { - StreamingReporterBase::sectionEnded( sectionStats ); - if( --m_sectionDepth > 0 ) { - XmlWriter::ScopedElement e = m_xml.scopedElement( "OverallResults" ); - e.writeAttribute( "successes", sectionStats.assertions.passed ); - e.writeAttribute( "failures", sectionStats.assertions.failed ); - e.writeAttribute( "expectedFailures", sectionStats.assertions.failedButOk ); - - if ( m_config->showDurations() == ShowDurations::Always ) - e.writeAttribute( "durationInSeconds", sectionStats.durationInSeconds ); - - m_xml.endElement(); - } - } - - virtual void testCaseEnded( TestCaseStats const& testCaseStats ) CATCH_OVERRIDE { - StreamingReporterBase::testCaseEnded( testCaseStats ); - XmlWriter::ScopedElement e = m_xml.scopedElement( "OverallResult" ); - e.writeAttribute( "success", testCaseStats.totals.assertions.allOk() ); - - if ( m_config->showDurations() == ShowDurations::Always ) - e.writeAttribute( "durationInSeconds", m_testCaseTimer.getElapsedSeconds() ); - - if( !testCaseStats.stdOut.empty() ) - m_xml.scopedElement( "StdOut" ).writeText( trim( testCaseStats.stdOut ), false ); - if( !testCaseStats.stdErr.empty() ) - m_xml.scopedElement( "StdErr" ).writeText( trim( testCaseStats.stdErr ), false ); - - m_xml.endElement(); - } - - virtual void testGroupEnded( TestGroupStats const& testGroupStats ) CATCH_OVERRIDE { - StreamingReporterBase::testGroupEnded( testGroupStats ); - // TODO: Check testGroupStats.aborting and act accordingly. - m_xml.scopedElement( "OverallResults" ) - .writeAttribute( "successes", testGroupStats.totals.assertions.passed ) - .writeAttribute( "failures", testGroupStats.totals.assertions.failed ) - .writeAttribute( "expectedFailures", testGroupStats.totals.assertions.failedButOk ); - m_xml.endElement(); - } - - virtual void testRunEnded( TestRunStats const& testRunStats ) CATCH_OVERRIDE { - StreamingReporterBase::testRunEnded( testRunStats ); - m_xml.scopedElement( "OverallResults" ) - .writeAttribute( "successes", testRunStats.totals.assertions.passed ) - .writeAttribute( "failures", testRunStats.totals.assertions.failed ) - .writeAttribute( "expectedFailures", testRunStats.totals.assertions.failedButOk ); - m_xml.endElement(); - } - - private: - Timer m_testCaseTimer; - XmlWriter m_xml; - int m_sectionDepth; - }; - - INTERNAL_CATCH_REGISTER_REPORTER( "xml", XmlReporter ) - -} // end namespace Catch - -// #included from: ../reporters/catch_reporter_junit.hpp -#define TWOBLUECUBES_CATCH_REPORTER_JUNIT_HPP_INCLUDED - -#include - -namespace Catch { - - namespace { - std::string getCurrentTimestamp() { - // Beware, this is not reentrant because of backward compatibility issues - // Also, UTC only, again because of backward compatibility (%z is C++11) - time_t rawtime; - std::time(&rawtime); - const size_t timeStampSize = sizeof("2017-01-16T17:06:45Z"); - -#ifdef _MSC_VER - std::tm timeInfo = {}; - gmtime_s(&timeInfo, &rawtime); -#else - std::tm* timeInfo; - timeInfo = std::gmtime(&rawtime); -#endif - - char timeStamp[timeStampSize]; - const char * const fmt = "%Y-%m-%dT%H:%M:%SZ"; - -#ifdef _MSC_VER - std::strftime(timeStamp, timeStampSize, fmt, &timeInfo); -#else - std::strftime(timeStamp, timeStampSize, fmt, timeInfo); -#endif - return std::string(timeStamp); - } - - } - - class JunitReporter : public CumulativeReporterBase { - public: - JunitReporter( ReporterConfig const& _config ) - : CumulativeReporterBase( _config ), - xml( _config.stream() ), - unexpectedExceptions( 0 ), - m_okToFail( false ) - { - m_reporterPrefs.shouldRedirectStdOut = true; - } - - virtual ~JunitReporter() CATCH_OVERRIDE; - - static std::string getDescription() { - return "Reports test results in an XML format that looks like Ant's junitreport target"; - } - - virtual void noMatchingTestCases( std::string const& /*spec*/ ) CATCH_OVERRIDE {} - - virtual void testRunStarting( TestRunInfo const& runInfo ) CATCH_OVERRIDE { - CumulativeReporterBase::testRunStarting( runInfo ); - xml.startElement( "testsuites" ); - } - - virtual void testGroupStarting( GroupInfo const& groupInfo ) CATCH_OVERRIDE { - suiteTimer.start(); - stdOutForSuite.str(""); - stdErrForSuite.str(""); - unexpectedExceptions = 0; - CumulativeReporterBase::testGroupStarting( groupInfo ); - } - - virtual void testCaseStarting( TestCaseInfo const& testCaseInfo ) CATCH_OVERRIDE { - m_okToFail = testCaseInfo.okToFail(); - } - virtual bool assertionEnded( AssertionStats const& assertionStats ) CATCH_OVERRIDE { - if( assertionStats.assertionResult.getResultType() == ResultWas::ThrewException && !m_okToFail ) - unexpectedExceptions++; - return CumulativeReporterBase::assertionEnded( assertionStats ); - } - - virtual void testCaseEnded( TestCaseStats const& testCaseStats ) CATCH_OVERRIDE { - stdOutForSuite << testCaseStats.stdOut; - stdErrForSuite << testCaseStats.stdErr; - CumulativeReporterBase::testCaseEnded( testCaseStats ); - } - - virtual void testGroupEnded( TestGroupStats const& testGroupStats ) CATCH_OVERRIDE { - double suiteTime = suiteTimer.getElapsedSeconds(); - CumulativeReporterBase::testGroupEnded( testGroupStats ); - writeGroup( *m_testGroups.back(), suiteTime ); - } - - virtual void testRunEndedCumulative() CATCH_OVERRIDE { - xml.endElement(); - } - - void writeGroup( TestGroupNode const& groupNode, double suiteTime ) { - XmlWriter::ScopedElement e = xml.scopedElement( "testsuite" ); - TestGroupStats const& stats = groupNode.value; - xml.writeAttribute( "name", stats.groupInfo.name ); - xml.writeAttribute( "errors", unexpectedExceptions ); - xml.writeAttribute( "failures", stats.totals.assertions.failed-unexpectedExceptions ); - xml.writeAttribute( "tests", stats.totals.assertions.total() ); - xml.writeAttribute( "hostname", "tbd" ); // !TBD - if( m_config->showDurations() == ShowDurations::Never ) - xml.writeAttribute( "time", "" ); - else - xml.writeAttribute( "time", suiteTime ); - xml.writeAttribute( "timestamp", getCurrentTimestamp() ); - - // Write test cases - for( TestGroupNode::ChildNodes::const_iterator - it = groupNode.children.begin(), itEnd = groupNode.children.end(); - it != itEnd; - ++it ) - writeTestCase( **it ); - - xml.scopedElement( "system-out" ).writeText( trim( stdOutForSuite.str() ), false ); - xml.scopedElement( "system-err" ).writeText( trim( stdErrForSuite.str() ), false ); - } - - void writeTestCase( TestCaseNode const& testCaseNode ) { - TestCaseStats const& stats = testCaseNode.value; - - // All test cases have exactly one section - which represents the - // test case itself. That section may have 0-n nested sections - assert( testCaseNode.children.size() == 1 ); - SectionNode const& rootSection = *testCaseNode.children.front(); - - std::string className = stats.testInfo.className; - - if( className.empty() ) { - if( rootSection.childSections.empty() ) - className = "global"; - } - writeSection( className, "", rootSection ); - } - - void writeSection( std::string const& className, - std::string const& rootName, - SectionNode const& sectionNode ) { - std::string name = trim( sectionNode.stats.sectionInfo.name ); - if( !rootName.empty() ) - name = rootName + '/' + name; - - if( !sectionNode.assertions.empty() || - !sectionNode.stdOut.empty() || - !sectionNode.stdErr.empty() ) { - XmlWriter::ScopedElement e = xml.scopedElement( "testcase" ); - if( className.empty() ) { - xml.writeAttribute( "classname", name ); - xml.writeAttribute( "name", "root" ); - } - else { - xml.writeAttribute( "classname", className ); - xml.writeAttribute( "name", name ); - } - xml.writeAttribute( "time", Catch::toString( sectionNode.stats.durationInSeconds ) ); - - writeAssertions( sectionNode ); - - if( !sectionNode.stdOut.empty() ) - xml.scopedElement( "system-out" ).writeText( trim( sectionNode.stdOut ), false ); - if( !sectionNode.stdErr.empty() ) - xml.scopedElement( "system-err" ).writeText( trim( sectionNode.stdErr ), false ); - } - for( SectionNode::ChildSections::const_iterator - it = sectionNode.childSections.begin(), - itEnd = sectionNode.childSections.end(); - it != itEnd; - ++it ) - if( className.empty() ) - writeSection( name, "", **it ); - else - writeSection( className, name, **it ); - } - - void writeAssertions( SectionNode const& sectionNode ) { - for( SectionNode::Assertions::const_iterator - it = sectionNode.assertions.begin(), itEnd = sectionNode.assertions.end(); - it != itEnd; - ++it ) - writeAssertion( *it ); - } - void writeAssertion( AssertionStats const& stats ) { - AssertionResult const& result = stats.assertionResult; - if( !result.isOk() ) { - std::string elementName; - switch( result.getResultType() ) { - case ResultWas::ThrewException: - case ResultWas::FatalErrorCondition: - elementName = "error"; - break; - case ResultWas::ExplicitFailure: - elementName = "failure"; - break; - case ResultWas::ExpressionFailed: - elementName = "failure"; - break; - case ResultWas::DidntThrowException: - elementName = "failure"; - break; - - // We should never see these here: - case ResultWas::Info: - case ResultWas::Warning: - case ResultWas::Ok: - case ResultWas::Unknown: - case ResultWas::FailureBit: - case ResultWas::Exception: - elementName = "internalError"; - break; - } - - XmlWriter::ScopedElement e = xml.scopedElement( elementName ); - - xml.writeAttribute( "message", result.getExpandedExpression() ); - xml.writeAttribute( "type", result.getTestMacroName() ); - - std::ostringstream oss; - if( !result.getMessage().empty() ) - oss << result.getMessage() << '\n'; - for( std::vector::const_iterator - it = stats.infoMessages.begin(), - itEnd = stats.infoMessages.end(); - it != itEnd; - ++it ) - if( it->type == ResultWas::Info ) - oss << it->message << '\n'; - - oss << "at " << result.getSourceInfo(); - xml.writeText( oss.str(), false ); - } - } - - XmlWriter xml; - Timer suiteTimer; - std::ostringstream stdOutForSuite; - std::ostringstream stdErrForSuite; - unsigned int unexpectedExceptions; - bool m_okToFail; - }; - - INTERNAL_CATCH_REGISTER_REPORTER( "junit", JunitReporter ) - -} // end namespace Catch - -// #included from: ../reporters/catch_reporter_console.hpp -#define TWOBLUECUBES_CATCH_REPORTER_CONSOLE_HPP_INCLUDED - -#include -#include -#include - -namespace Catch { - - struct ConsoleReporter : StreamingReporterBase { - ConsoleReporter( ReporterConfig const& _config ) - : StreamingReporterBase( _config ), - m_headerPrinted( false ) - {} - - virtual ~ConsoleReporter() CATCH_OVERRIDE; - static std::string getDescription() { - return "Reports test results as plain lines of text"; - } - - virtual void noMatchingTestCases( std::string const& spec ) CATCH_OVERRIDE { - stream << "No test cases matched '" << spec << '\'' << std::endl; - } - - virtual void assertionStarting( AssertionInfo const& ) CATCH_OVERRIDE { - } - - virtual bool assertionEnded( AssertionStats const& _assertionStats ) CATCH_OVERRIDE { - AssertionResult const& result = _assertionStats.assertionResult; - - bool includeResults = m_config->includeSuccessfulResults() || !result.isOk(); - - // Drop out if result was successful but we're not printing them. - if( !includeResults && result.getResultType() != ResultWas::Warning ) - return false; - - lazyPrint(); - - AssertionPrinter printer( stream, _assertionStats, includeResults ); - printer.print(); - stream << std::endl; - return true; - } - - virtual void sectionStarting( SectionInfo const& _sectionInfo ) CATCH_OVERRIDE { - m_headerPrinted = false; - StreamingReporterBase::sectionStarting( _sectionInfo ); - } - virtual void sectionEnded( SectionStats const& _sectionStats ) CATCH_OVERRIDE { - if( _sectionStats.missingAssertions ) { - lazyPrint(); - Colour colour( Colour::ResultError ); - if( m_sectionStack.size() > 1 ) - stream << "\nNo assertions in section"; - else - stream << "\nNo assertions in test case"; - stream << " '" << _sectionStats.sectionInfo.name << "'\n" << std::endl; - } - if( m_config->showDurations() == ShowDurations::Always ) { - stream << getFormattedDuration(_sectionStats.durationInSeconds) << " s: " << _sectionStats.sectionInfo.name << std::endl; - } - if( m_headerPrinted ) { - m_headerPrinted = false; - } - StreamingReporterBase::sectionEnded( _sectionStats ); - } - - virtual void testCaseEnded( TestCaseStats const& _testCaseStats ) CATCH_OVERRIDE { - StreamingReporterBase::testCaseEnded( _testCaseStats ); - m_headerPrinted = false; - } - virtual void testGroupEnded( TestGroupStats const& _testGroupStats ) CATCH_OVERRIDE { - if( currentGroupInfo.used ) { - printSummaryDivider(); - stream << "Summary for group '" << _testGroupStats.groupInfo.name << "':\n"; - printTotals( _testGroupStats.totals ); - stream << '\n' << std::endl; - } - StreamingReporterBase::testGroupEnded( _testGroupStats ); - } - virtual void testRunEnded( TestRunStats const& _testRunStats ) CATCH_OVERRIDE { - printTotalsDivider( _testRunStats.totals ); - printTotals( _testRunStats.totals ); - stream << std::endl; - StreamingReporterBase::testRunEnded( _testRunStats ); - } - - private: - - class AssertionPrinter { - void operator= ( AssertionPrinter const& ); - public: - AssertionPrinter( std::ostream& _stream, AssertionStats const& _stats, bool _printInfoMessages ) - : stream( _stream ), - stats( _stats ), - result( _stats.assertionResult ), - colour( Colour::None ), - message( result.getMessage() ), - messages( _stats.infoMessages ), - printInfoMessages( _printInfoMessages ) - { - switch( result.getResultType() ) { - case ResultWas::Ok: - colour = Colour::Success; - passOrFail = "PASSED"; - //if( result.hasMessage() ) - if( _stats.infoMessages.size() == 1 ) - messageLabel = "with message"; - if( _stats.infoMessages.size() > 1 ) - messageLabel = "with messages"; - break; - case ResultWas::ExpressionFailed: - if( result.isOk() ) { - colour = Colour::Success; - passOrFail = "FAILED - but was ok"; - } - else { - colour = Colour::Error; - passOrFail = "FAILED"; - } - if( _stats.infoMessages.size() == 1 ) - messageLabel = "with message"; - if( _stats.infoMessages.size() > 1 ) - messageLabel = "with messages"; - break; - case ResultWas::ThrewException: - colour = Colour::Error; - passOrFail = "FAILED"; - messageLabel = "due to unexpected exception with "; - if (_stats.infoMessages.size() == 1) - messageLabel += "message"; - if (_stats.infoMessages.size() > 1) - messageLabel += "messages"; - break; - case ResultWas::FatalErrorCondition: - colour = Colour::Error; - passOrFail = "FAILED"; - messageLabel = "due to a fatal error condition"; - break; - case ResultWas::DidntThrowException: - colour = Colour::Error; - passOrFail = "FAILED"; - messageLabel = "because no exception was thrown where one was expected"; - break; - case ResultWas::Info: - messageLabel = "info"; - break; - case ResultWas::Warning: - messageLabel = "warning"; - break; - case ResultWas::ExplicitFailure: - passOrFail = "FAILED"; - colour = Colour::Error; - if( _stats.infoMessages.size() == 1 ) - messageLabel = "explicitly with message"; - if( _stats.infoMessages.size() > 1 ) - messageLabel = "explicitly with messages"; - break; - // These cases are here to prevent compiler warnings - case ResultWas::Unknown: - case ResultWas::FailureBit: - case ResultWas::Exception: - passOrFail = "** internal error **"; - colour = Colour::Error; - break; - } - } - - void print() const { - printSourceInfo(); - if( stats.totals.assertions.total() > 0 ) { - if( result.isOk() ) - stream << '\n'; - printResultType(); - printOriginalExpression(); - printReconstructedExpression(); - } - else { - stream << '\n'; - } - printMessage(); - } - - private: - void printResultType() const { - if( !passOrFail.empty() ) { - Colour colourGuard( colour ); - stream << passOrFail << ":\n"; - } - } - void printOriginalExpression() const { - if( result.hasExpression() ) { - Colour colourGuard( Colour::OriginalExpression ); - stream << " "; - stream << result.getExpressionInMacro(); - stream << '\n'; - } - } - void printReconstructedExpression() const { - if( result.hasExpandedExpression() ) { - stream << "with expansion:\n"; - Colour colourGuard( Colour::ReconstructedExpression ); - stream << Text( result.getExpandedExpression(), TextAttributes().setIndent(2) ) << '\n'; - } - } - void printMessage() const { - if( !messageLabel.empty() ) - stream << messageLabel << ':' << '\n'; - for( std::vector::const_iterator it = messages.begin(), itEnd = messages.end(); - it != itEnd; - ++it ) { - // If this assertion is a warning ignore any INFO messages - if( printInfoMessages || it->type != ResultWas::Info ) - stream << Text( it->message, TextAttributes().setIndent(2) ) << '\n'; - } - } - void printSourceInfo() const { - Colour colourGuard( Colour::FileName ); - stream << result.getSourceInfo() << ": "; - } - - std::ostream& stream; - AssertionStats const& stats; - AssertionResult const& result; - Colour::Code colour; - std::string passOrFail; - std::string messageLabel; - std::string message; - std::vector messages; - bool printInfoMessages; - }; - - void lazyPrint() { - - if( !currentTestRunInfo.used ) - lazyPrintRunInfo(); - if( !currentGroupInfo.used ) - lazyPrintGroupInfo(); - - if( !m_headerPrinted ) { - printTestCaseAndSectionHeader(); - m_headerPrinted = true; - } - } - void lazyPrintRunInfo() { - stream << '\n' << getLineOfChars<'~'>() << '\n'; - Colour colour( Colour::SecondaryText ); - stream << currentTestRunInfo->name - << " is a Catch v" << libraryVersion() << " host application.\n" - << "Run with -? for options\n\n"; - - if( m_config->rngSeed() != 0 ) - stream << "Randomness seeded to: " << m_config->rngSeed() << "\n\n"; - - currentTestRunInfo.used = true; - } - void lazyPrintGroupInfo() { - if( !currentGroupInfo->name.empty() && currentGroupInfo->groupsCounts > 1 ) { - printClosedHeader( "Group: " + currentGroupInfo->name ); - currentGroupInfo.used = true; - } - } - void printTestCaseAndSectionHeader() { - assert( !m_sectionStack.empty() ); - printOpenHeader( currentTestCaseInfo->name ); - - if( m_sectionStack.size() > 1 ) { - Colour colourGuard( Colour::Headers ); - - std::vector::const_iterator - it = m_sectionStack.begin()+1, // Skip first section (test case) - itEnd = m_sectionStack.end(); - for( ; it != itEnd; ++it ) - printHeaderString( it->name, 2 ); - } - - SourceLineInfo lineInfo = m_sectionStack.back().lineInfo; - - if( !lineInfo.empty() ){ - stream << getLineOfChars<'-'>() << '\n'; - Colour colourGuard( Colour::FileName ); - stream << lineInfo << '\n'; - } - stream << getLineOfChars<'.'>() << '\n' << std::endl; - } - - void printClosedHeader( std::string const& _name ) { - printOpenHeader( _name ); - stream << getLineOfChars<'.'>() << '\n'; - } - void printOpenHeader( std::string const& _name ) { - stream << getLineOfChars<'-'>() << '\n'; - { - Colour colourGuard( Colour::Headers ); - printHeaderString( _name ); - } - } - - // if string has a : in first line will set indent to follow it on - // subsequent lines - void printHeaderString( std::string const& _string, std::size_t indent = 0 ) { - std::size_t i = _string.find( ": " ); - if( i != std::string::npos ) - i+=2; - else - i = 0; - stream << Text( _string, TextAttributes() - .setIndent( indent+i) - .setInitialIndent( indent ) ) << '\n'; - } - - struct SummaryColumn { - - SummaryColumn( std::string const& _label, Colour::Code _colour ) - : label( _label ), - colour( _colour ) - {} - SummaryColumn addRow( std::size_t count ) { - std::ostringstream oss; - oss << count; - std::string row = oss.str(); - for( std::vector::iterator it = rows.begin(); it != rows.end(); ++it ) { - while( it->size() < row.size() ) - *it = ' ' + *it; - while( it->size() > row.size() ) - row = ' ' + row; - } - rows.push_back( row ); - return *this; - } - - std::string label; - Colour::Code colour; - std::vector rows; - - }; - - void printTotals( Totals const& totals ) { - if( totals.testCases.total() == 0 ) { - stream << Colour( Colour::Warning ) << "No tests ran\n"; - } - else if( totals.assertions.total() > 0 && totals.testCases.allPassed() ) { - stream << Colour( Colour::ResultSuccess ) << "All tests passed"; - stream << " (" - << pluralise( totals.assertions.passed, "assertion" ) << " in " - << pluralise( totals.testCases.passed, "test case" ) << ')' - << '\n'; - } - else { - - std::vector columns; - columns.push_back( SummaryColumn( "", Colour::None ) - .addRow( totals.testCases.total() ) - .addRow( totals.assertions.total() ) ); - columns.push_back( SummaryColumn( "passed", Colour::Success ) - .addRow( totals.testCases.passed ) - .addRow( totals.assertions.passed ) ); - columns.push_back( SummaryColumn( "failed", Colour::ResultError ) - .addRow( totals.testCases.failed ) - .addRow( totals.assertions.failed ) ); - columns.push_back( SummaryColumn( "failed as expected", Colour::ResultExpectedFailure ) - .addRow( totals.testCases.failedButOk ) - .addRow( totals.assertions.failedButOk ) ); - - printSummaryRow( "test cases", columns, 0 ); - printSummaryRow( "assertions", columns, 1 ); - } - } - void printSummaryRow( std::string const& label, std::vector const& cols, std::size_t row ) { - for( std::vector::const_iterator it = cols.begin(); it != cols.end(); ++it ) { - std::string value = it->rows[row]; - if( it->label.empty() ) { - stream << label << ": "; - if( value != "0" ) - stream << value; - else - stream << Colour( Colour::Warning ) << "- none -"; - } - else if( value != "0" ) { - stream << Colour( Colour::LightGrey ) << " | "; - stream << Colour( it->colour ) - << value << ' ' << it->label; - } - } - stream << '\n'; - } - - static std::size_t makeRatio( std::size_t number, std::size_t total ) { - std::size_t ratio = total > 0 ? CATCH_CONFIG_CONSOLE_WIDTH * number/ total : 0; - return ( ratio == 0 && number > 0 ) ? 1 : ratio; - } - static std::size_t& findMax( std::size_t& i, std::size_t& j, std::size_t& k ) { - if( i > j && i > k ) - return i; - else if( j > k ) - return j; - else - return k; - } - - void printTotalsDivider( Totals const& totals ) { - if( totals.testCases.total() > 0 ) { - std::size_t failedRatio = makeRatio( totals.testCases.failed, totals.testCases.total() ); - std::size_t failedButOkRatio = makeRatio( totals.testCases.failedButOk, totals.testCases.total() ); - std::size_t passedRatio = makeRatio( totals.testCases.passed, totals.testCases.total() ); - while( failedRatio + failedButOkRatio + passedRatio < CATCH_CONFIG_CONSOLE_WIDTH-1 ) - findMax( failedRatio, failedButOkRatio, passedRatio )++; - while( failedRatio + failedButOkRatio + passedRatio > CATCH_CONFIG_CONSOLE_WIDTH-1 ) - findMax( failedRatio, failedButOkRatio, passedRatio )--; - - stream << Colour( Colour::Error ) << std::string( failedRatio, '=' ); - stream << Colour( Colour::ResultExpectedFailure ) << std::string( failedButOkRatio, '=' ); - if( totals.testCases.allPassed() ) - stream << Colour( Colour::ResultSuccess ) << std::string( passedRatio, '=' ); - else - stream << Colour( Colour::Success ) << std::string( passedRatio, '=' ); - } - else { - stream << Colour( Colour::Warning ) << std::string( CATCH_CONFIG_CONSOLE_WIDTH-1, '=' ); - } - stream << '\n'; - } - void printSummaryDivider() { - stream << getLineOfChars<'-'>() << '\n'; - } - - private: - bool m_headerPrinted; - }; - - INTERNAL_CATCH_REGISTER_REPORTER( "console", ConsoleReporter ) - -} // end namespace Catch - -// #included from: ../reporters/catch_reporter_compact.hpp -#define TWOBLUECUBES_CATCH_REPORTER_COMPACT_HPP_INCLUDED - -namespace Catch { - - struct CompactReporter : StreamingReporterBase { - - CompactReporter( ReporterConfig const& _config ) - : StreamingReporterBase( _config ) - {} - - virtual ~CompactReporter(); - - static std::string getDescription() { - return "Reports test results on a single line, suitable for IDEs"; - } - - virtual ReporterPreferences getPreferences() const { - ReporterPreferences prefs; - prefs.shouldRedirectStdOut = false; - return prefs; - } - - virtual void noMatchingTestCases( std::string const& spec ) { - stream << "No test cases matched '" << spec << '\'' << std::endl; - } - - virtual void assertionStarting( AssertionInfo const& ) {} - - virtual bool assertionEnded( AssertionStats const& _assertionStats ) { - AssertionResult const& result = _assertionStats.assertionResult; - - bool printInfoMessages = true; - - // Drop out if result was successful and we're not printing those - if( !m_config->includeSuccessfulResults() && result.isOk() ) { - if( result.getResultType() != ResultWas::Warning ) - return false; - printInfoMessages = false; - } - - AssertionPrinter printer( stream, _assertionStats, printInfoMessages ); - printer.print(); - - stream << std::endl; - return true; - } - - virtual void sectionEnded(SectionStats const& _sectionStats) CATCH_OVERRIDE { - if (m_config->showDurations() == ShowDurations::Always) { - stream << getFormattedDuration(_sectionStats.durationInSeconds) << " s: " << _sectionStats.sectionInfo.name << std::endl; - } - } - - virtual void testRunEnded( TestRunStats const& _testRunStats ) { - printTotals( _testRunStats.totals ); - stream << '\n' << std::endl; - StreamingReporterBase::testRunEnded( _testRunStats ); - } - - private: - class AssertionPrinter { - void operator= ( AssertionPrinter const& ); - public: - AssertionPrinter( std::ostream& _stream, AssertionStats const& _stats, bool _printInfoMessages ) - : stream( _stream ) - , stats( _stats ) - , result( _stats.assertionResult ) - , messages( _stats.infoMessages ) - , itMessage( _stats.infoMessages.begin() ) - , printInfoMessages( _printInfoMessages ) - {} - - void print() { - printSourceInfo(); - - itMessage = messages.begin(); - - switch( result.getResultType() ) { - case ResultWas::Ok: - printResultType( Colour::ResultSuccess, passedString() ); - printOriginalExpression(); - printReconstructedExpression(); - if ( ! result.hasExpression() ) - printRemainingMessages( Colour::None ); - else - printRemainingMessages(); - break; - case ResultWas::ExpressionFailed: - if( result.isOk() ) - printResultType( Colour::ResultSuccess, failedString() + std::string( " - but was ok" ) ); - else - printResultType( Colour::Error, failedString() ); - printOriginalExpression(); - printReconstructedExpression(); - printRemainingMessages(); - break; - case ResultWas::ThrewException: - printResultType( Colour::Error, failedString() ); - printIssue( "unexpected exception with message:" ); - printMessage(); - printExpressionWas(); - printRemainingMessages(); - break; - case ResultWas::FatalErrorCondition: - printResultType( Colour::Error, failedString() ); - printIssue( "fatal error condition with message:" ); - printMessage(); - printExpressionWas(); - printRemainingMessages(); - break; - case ResultWas::DidntThrowException: - printResultType( Colour::Error, failedString() ); - printIssue( "expected exception, got none" ); - printExpressionWas(); - printRemainingMessages(); - break; - case ResultWas::Info: - printResultType( Colour::None, "info" ); - printMessage(); - printRemainingMessages(); - break; - case ResultWas::Warning: - printResultType( Colour::None, "warning" ); - printMessage(); - printRemainingMessages(); - break; - case ResultWas::ExplicitFailure: - printResultType( Colour::Error, failedString() ); - printIssue( "explicitly" ); - printRemainingMessages( Colour::None ); - break; - // These cases are here to prevent compiler warnings - case ResultWas::Unknown: - case ResultWas::FailureBit: - case ResultWas::Exception: - printResultType( Colour::Error, "** internal error **" ); - break; - } - } - - private: - // Colour::LightGrey - - static Colour::Code dimColour() { return Colour::FileName; } - -#ifdef CATCH_PLATFORM_MAC - static const char* failedString() { return "FAILED"; } - static const char* passedString() { return "PASSED"; } -#else - static const char* failedString() { return "failed"; } - static const char* passedString() { return "passed"; } -#endif - - void printSourceInfo() const { - Colour colourGuard( Colour::FileName ); - stream << result.getSourceInfo() << ':'; - } - - void printResultType( Colour::Code colour, std::string const& passOrFail ) const { - if( !passOrFail.empty() ) { - { - Colour colourGuard( colour ); - stream << ' ' << passOrFail; - } - stream << ':'; - } - } - - void printIssue( std::string const& issue ) const { - stream << ' ' << issue; - } - - void printExpressionWas() { - if( result.hasExpression() ) { - stream << ';'; - { - Colour colour( dimColour() ); - stream << " expression was:"; - } - printOriginalExpression(); - } - } - - void printOriginalExpression() const { - if( result.hasExpression() ) { - stream << ' ' << result.getExpression(); - } - } - - void printReconstructedExpression() const { - if( result.hasExpandedExpression() ) { - { - Colour colour( dimColour() ); - stream << " for: "; - } - stream << result.getExpandedExpression(); - } - } - - void printMessage() { - if ( itMessage != messages.end() ) { - stream << " '" << itMessage->message << '\''; - ++itMessage; - } - } - - void printRemainingMessages( Colour::Code colour = dimColour() ) { - if ( itMessage == messages.end() ) - return; - - // using messages.end() directly yields compilation error: - std::vector::const_iterator itEnd = messages.end(); - const std::size_t N = static_cast( std::distance( itMessage, itEnd ) ); - - { - Colour colourGuard( colour ); - stream << " with " << pluralise( N, "message" ) << ':'; - } - - for(; itMessage != itEnd; ) { - // If this assertion is a warning ignore any INFO messages - if( printInfoMessages || itMessage->type != ResultWas::Info ) { - stream << " '" << itMessage->message << '\''; - if ( ++itMessage != itEnd ) { - Colour colourGuard( dimColour() ); - stream << " and"; - } - } - } - } - - private: - std::ostream& stream; - AssertionStats const& stats; - AssertionResult const& result; - std::vector messages; - std::vector::const_iterator itMessage; - bool printInfoMessages; - }; - - // Colour, message variants: - // - white: No tests ran. - // - red: Failed [both/all] N test cases, failed [both/all] M assertions. - // - white: Passed [both/all] N test cases (no assertions). - // - red: Failed N tests cases, failed M assertions. - // - green: Passed [both/all] N tests cases with M assertions. - - std::string bothOrAll( std::size_t count ) const { - return count == 1 ? std::string() : count == 2 ? "both " : "all " ; - } - - void printTotals( const Totals& totals ) const { - if( totals.testCases.total() == 0 ) { - stream << "No tests ran."; - } - else if( totals.testCases.failed == totals.testCases.total() ) { - Colour colour( Colour::ResultError ); - const std::string qualify_assertions_failed = - totals.assertions.failed == totals.assertions.total() ? - bothOrAll( totals.assertions.failed ) : std::string(); - stream << - "Failed " << bothOrAll( totals.testCases.failed ) - << pluralise( totals.testCases.failed, "test case" ) << ", " - "failed " << qualify_assertions_failed << - pluralise( totals.assertions.failed, "assertion" ) << '.'; - } - else if( totals.assertions.total() == 0 ) { - stream << - "Passed " << bothOrAll( totals.testCases.total() ) - << pluralise( totals.testCases.total(), "test case" ) - << " (no assertions)."; - } - else if( totals.assertions.failed ) { - Colour colour( Colour::ResultError ); - stream << - "Failed " << pluralise( totals.testCases.failed, "test case" ) << ", " - "failed " << pluralise( totals.assertions.failed, "assertion" ) << '.'; - } - else { - Colour colour( Colour::ResultSuccess ); - stream << - "Passed " << bothOrAll( totals.testCases.passed ) - << pluralise( totals.testCases.passed, "test case" ) << - " with " << pluralise( totals.assertions.passed, "assertion" ) << '.'; - } - } - }; - - INTERNAL_CATCH_REGISTER_REPORTER( "compact", CompactReporter ) - -} // end namespace Catch - -namespace Catch { - // These are all here to avoid warnings about not having any out of line - // virtual methods - NonCopyable::~NonCopyable() {} - IShared::~IShared() {} - IStream::~IStream() CATCH_NOEXCEPT {} - FileStream::~FileStream() CATCH_NOEXCEPT {} - CoutStream::~CoutStream() CATCH_NOEXCEPT {} - DebugOutStream::~DebugOutStream() CATCH_NOEXCEPT {} - StreamBufBase::~StreamBufBase() CATCH_NOEXCEPT {} - IContext::~IContext() {} - IResultCapture::~IResultCapture() {} - ITestCase::~ITestCase() {} - ITestCaseRegistry::~ITestCaseRegistry() {} - IRegistryHub::~IRegistryHub() {} - IMutableRegistryHub::~IMutableRegistryHub() {} - IExceptionTranslator::~IExceptionTranslator() {} - IExceptionTranslatorRegistry::~IExceptionTranslatorRegistry() {} - IReporter::~IReporter() {} - IReporterFactory::~IReporterFactory() {} - IReporterRegistry::~IReporterRegistry() {} - IStreamingReporter::~IStreamingReporter() {} - AssertionStats::~AssertionStats() {} - SectionStats::~SectionStats() {} - TestCaseStats::~TestCaseStats() {} - TestGroupStats::~TestGroupStats() {} - TestRunStats::~TestRunStats() {} - CumulativeReporterBase::SectionNode::~SectionNode() {} - CumulativeReporterBase::~CumulativeReporterBase() {} - - StreamingReporterBase::~StreamingReporterBase() {} - ConsoleReporter::~ConsoleReporter() {} - CompactReporter::~CompactReporter() {} - IRunner::~IRunner() {} - IMutableContext::~IMutableContext() {} - IConfig::~IConfig() {} - XmlReporter::~XmlReporter() {} - JunitReporter::~JunitReporter() {} - TestRegistry::~TestRegistry() {} - FreeFunctionTestCase::~FreeFunctionTestCase() {} - IGeneratorInfo::~IGeneratorInfo() {} - IGeneratorsForTest::~IGeneratorsForTest() {} - WildcardPattern::~WildcardPattern() {} - TestSpec::Pattern::~Pattern() {} - TestSpec::NamePattern::~NamePattern() {} - TestSpec::TagPattern::~TagPattern() {} - TestSpec::ExcludedPattern::~ExcludedPattern() {} - Matchers::Impl::MatcherUntypedBase::~MatcherUntypedBase() {} - - void Config::dummy() {} - - namespace TestCaseTracking { - ITracker::~ITracker() {} - TrackerBase::~TrackerBase() {} - SectionTracker::~SectionTracker() {} - IndexTracker::~IndexTracker() {} - } -} - -#ifdef __clang__ -#pragma clang diagnostic pop -#endif - -#endif - -#ifdef CATCH_CONFIG_MAIN -// #included from: internal/catch_default_main.hpp -#define TWOBLUECUBES_CATCH_DEFAULT_MAIN_HPP_INCLUDED - -#ifndef __OBJC__ - -#if defined(WIN32) && defined(_UNICODE) && !defined(DO_NOT_USE_WMAIN) -// Standard C/C++ Win32 Unicode wmain entry point -extern "C" int wmain (int argc, wchar_t * argv[], wchar_t * []) { -#else -// Standard C/C++ main entry point -int main (int argc, char * argv[]) { -#endif - - int result = Catch::Session().run( argc, argv ); - return ( result < 0xff ? result : 0xff ); -} - -#else // __OBJC__ - -// Objective-C entry point -int main (int argc, char * const argv[]) { -#if !CATCH_ARC_ENABLED - NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init]; -#endif - - Catch::registerTestMethods(); - int result = Catch::Session().run( argc, (char* const*)argv ); - -#if !CATCH_ARC_ENABLED - [pool drain]; -#endif - - return ( result < 0xff ? result : 0xff ); -} - -#endif // __OBJC__ - -#endif - -#ifdef CLARA_CONFIG_MAIN_NOT_DEFINED -# undef CLARA_CONFIG_MAIN -#endif - -////// - -// If this config identifier is defined then all CATCH macros are prefixed with CATCH_ -#ifdef CATCH_CONFIG_PREFIX_ALL - -#if defined(CATCH_CONFIG_FAST_COMPILE) -#define CATCH_REQUIRE( expr ) INTERNAL_CATCH_TEST_NO_TRY( "CATCH_REQUIRE", Catch::ResultDisposition::Normal, expr ) -#define CATCH_REQUIRE_FALSE( expr ) INTERNAL_CATCH_TEST_NO_TRY( "CATCH_REQUIRE_FALSE", Catch::ResultDisposition::Normal | Catch::ResultDisposition::FalseTest, expr ) -#else -#define CATCH_REQUIRE( expr ) INTERNAL_CATCH_TEST( "CATCH_REQUIRE", Catch::ResultDisposition::Normal, expr ) -#define CATCH_REQUIRE_FALSE( expr ) INTERNAL_CATCH_TEST( "CATCH_REQUIRE_FALSE", Catch::ResultDisposition::Normal | Catch::ResultDisposition::FalseTest, expr ) -#endif - -#define CATCH_REQUIRE_THROWS( expr ) INTERNAL_CATCH_THROWS( "CATCH_REQUIRE_THROWS", Catch::ResultDisposition::Normal, "", expr ) -#define CATCH_REQUIRE_THROWS_AS( expr, exceptionType ) INTERNAL_CATCH_THROWS_AS( "CATCH_REQUIRE_THROWS_AS", exceptionType, Catch::ResultDisposition::Normal, expr ) -#define CATCH_REQUIRE_THROWS_WITH( expr, matcher ) INTERNAL_CATCH_THROWS( "CATCH_REQUIRE_THROWS_WITH", Catch::ResultDisposition::Normal, matcher, expr ) -#define CATCH_REQUIRE_NOTHROW( expr ) INTERNAL_CATCH_NO_THROW( "CATCH_REQUIRE_NOTHROW", Catch::ResultDisposition::Normal, expr ) - -#define CATCH_CHECK( expr ) INTERNAL_CATCH_TEST( "CATCH_CHECK", Catch::ResultDisposition::ContinueOnFailure, expr ) -#define CATCH_CHECK_FALSE( expr ) INTERNAL_CATCH_TEST( "CATCH_CHECK_FALSE", Catch::ResultDisposition::ContinueOnFailure | Catch::ResultDisposition::FalseTest, expr ) -#define CATCH_CHECKED_IF( expr ) INTERNAL_CATCH_IF( "CATCH_CHECKED_IF", Catch::ResultDisposition::ContinueOnFailure, expr ) -#define CATCH_CHECKED_ELSE( expr ) INTERNAL_CATCH_ELSE( "CATCH_CHECKED_ELSE", Catch::ResultDisposition::ContinueOnFailure, expr ) -#define CATCH_CHECK_NOFAIL( expr ) INTERNAL_CATCH_TEST( "CATCH_CHECK_NOFAIL", Catch::ResultDisposition::ContinueOnFailure | Catch::ResultDisposition::SuppressFail, expr ) - -#define CATCH_CHECK_THROWS( expr ) INTERNAL_CATCH_THROWS( "CATCH_CHECK_THROWS", Catch::ResultDisposition::ContinueOnFailure, "", expr ) -#define CATCH_CHECK_THROWS_AS( expr, exceptionType ) INTERNAL_CATCH_THROWS_AS( "CATCH_CHECK_THROWS_AS", exceptionType, Catch::ResultDisposition::ContinueOnFailure, expr ) -#define CATCH_CHECK_THROWS_WITH( expr, matcher ) INTERNAL_CATCH_THROWS( "CATCH_CHECK_THROWS_WITH", Catch::ResultDisposition::ContinueOnFailure, matcher, expr ) -#define CATCH_CHECK_NOTHROW( expr ) INTERNAL_CATCH_NO_THROW( "CATCH_CHECK_NOTHROW", Catch::ResultDisposition::ContinueOnFailure, expr ) - -#define CATCH_CHECK_THAT( arg, matcher ) INTERNAL_CHECK_THAT( "CATCH_CHECK_THAT", matcher, Catch::ResultDisposition::ContinueOnFailure, arg ) - -#if defined(CATCH_CONFIG_FAST_COMPILE) -#define CATCH_REQUIRE_THAT( arg, matcher ) INTERNAL_CHECK_THAT_NO_TRY( "CATCH_REQUIRE_THAT", matcher, Catch::ResultDisposition::Normal, arg ) -#else -#define CATCH_REQUIRE_THAT( arg, matcher ) INTERNAL_CHECK_THAT( "CATCH_REQUIRE_THAT", matcher, Catch::ResultDisposition::Normal, arg ) -#endif - -#define CATCH_INFO( msg ) INTERNAL_CATCH_INFO( "CATCH_INFO", msg ) -#define CATCH_WARN( msg ) INTERNAL_CATCH_MSG( "CATCH_WARN", Catch::ResultWas::Warning, Catch::ResultDisposition::ContinueOnFailure, msg ) -#define CATCH_SCOPED_INFO( msg ) INTERNAL_CATCH_INFO( "CATCH_INFO", msg ) -#define CATCH_CAPTURE( msg ) INTERNAL_CATCH_INFO( "CATCH_CAPTURE", #msg " := " << Catch::toString(msg) ) -#define CATCH_SCOPED_CAPTURE( msg ) INTERNAL_CATCH_INFO( "CATCH_CAPTURE", #msg " := " << Catch::toString(msg) ) - -#ifdef CATCH_CONFIG_VARIADIC_MACROS - #define CATCH_TEST_CASE( ... ) INTERNAL_CATCH_TESTCASE( __VA_ARGS__ ) - #define CATCH_TEST_CASE_METHOD( className, ... ) INTERNAL_CATCH_TEST_CASE_METHOD( className, __VA_ARGS__ ) - #define CATCH_METHOD_AS_TEST_CASE( method, ... ) INTERNAL_CATCH_METHOD_AS_TEST_CASE( method, __VA_ARGS__ ) - #define CATCH_REGISTER_TEST_CASE( Function, ... ) INTERNAL_CATCH_REGISTER_TESTCASE( Function, __VA_ARGS__ ) - #define CATCH_SECTION( ... ) INTERNAL_CATCH_SECTION( __VA_ARGS__ ) - #define CATCH_FAIL( ... ) INTERNAL_CATCH_MSG( "CATCH_FAIL", Catch::ResultWas::ExplicitFailure, Catch::ResultDisposition::Normal, __VA_ARGS__ ) - #define CATCH_FAIL_CHECK( ... ) INTERNAL_CATCH_MSG( "CATCH_FAIL_CHECK", Catch::ResultWas::ExplicitFailure, Catch::ResultDisposition::ContinueOnFailure, __VA_ARGS__ ) - #define CATCH_SUCCEED( ... ) INTERNAL_CATCH_MSG( "CATCH_SUCCEED", Catch::ResultWas::Ok, Catch::ResultDisposition::ContinueOnFailure, __VA_ARGS__ ) -#else - #define CATCH_TEST_CASE( name, description ) INTERNAL_CATCH_TESTCASE( name, description ) - #define CATCH_TEST_CASE_METHOD( className, name, description ) INTERNAL_CATCH_TEST_CASE_METHOD( className, name, description ) - #define CATCH_METHOD_AS_TEST_CASE( method, name, description ) INTERNAL_CATCH_METHOD_AS_TEST_CASE( method, name, description ) - #define CATCH_REGISTER_TEST_CASE( function, name, description ) INTERNAL_CATCH_REGISTER_TESTCASE( function, name, description ) - #define CATCH_SECTION( name, description ) INTERNAL_CATCH_SECTION( name, description ) - #define CATCH_FAIL( msg ) INTERNAL_CATCH_MSG( "CATCH_FAIL", Catch::ResultWas::ExplicitFailure, Catch::ResultDisposition::Normal, msg ) - #define CATCH_FAIL_CHECK( msg ) INTERNAL_CATCH_MSG( "CATCH_FAIL_CHECK", Catch::ResultWas::ExplicitFailure, Catch::ResultDisposition::ContinueOnFailure, msg ) - #define CATCH_SUCCEED( msg ) INTERNAL_CATCH_MSG( "CATCH_SUCCEED", Catch::ResultWas::Ok, Catch::ResultDisposition::ContinueOnFailure, msg ) -#endif -#define CATCH_ANON_TEST_CASE() INTERNAL_CATCH_TESTCASE( "", "" ) - -#define CATCH_REGISTER_REPORTER( name, reporterType ) INTERNAL_CATCH_REGISTER_REPORTER( name, reporterType ) -#define CATCH_REGISTER_LEGACY_REPORTER( name, reporterType ) INTERNAL_CATCH_REGISTER_LEGACY_REPORTER( name, reporterType ) - -#define CATCH_GENERATE( expr) INTERNAL_CATCH_GENERATE( expr ) - -// "BDD-style" convenience wrappers -#ifdef CATCH_CONFIG_VARIADIC_MACROS -#define CATCH_SCENARIO( ... ) CATCH_TEST_CASE( "Scenario: " __VA_ARGS__ ) -#define CATCH_SCENARIO_METHOD( className, ... ) INTERNAL_CATCH_TEST_CASE_METHOD( className, "Scenario: " __VA_ARGS__ ) -#else -#define CATCH_SCENARIO( name, tags ) CATCH_TEST_CASE( "Scenario: " name, tags ) -#define CATCH_SCENARIO_METHOD( className, name, tags ) INTERNAL_CATCH_TEST_CASE_METHOD( className, "Scenario: " name, tags ) -#endif -#define CATCH_GIVEN( desc ) CATCH_SECTION( std::string( "Given: ") + desc, "" ) -#define CATCH_WHEN( desc ) CATCH_SECTION( std::string( " When: ") + desc, "" ) -#define CATCH_AND_WHEN( desc ) CATCH_SECTION( std::string( " And: ") + desc, "" ) -#define CATCH_THEN( desc ) CATCH_SECTION( std::string( " Then: ") + desc, "" ) -#define CATCH_AND_THEN( desc ) CATCH_SECTION( std::string( " And: ") + desc, "" ) - -// If CATCH_CONFIG_PREFIX_ALL is not defined then the CATCH_ prefix is not required -#else - -#if defined(CATCH_CONFIG_FAST_COMPILE) -#define REQUIRE( expr ) INTERNAL_CATCH_TEST_NO_TRY( "REQUIRE", Catch::ResultDisposition::Normal, expr ) -#define REQUIRE_FALSE( expr ) INTERNAL_CATCH_TEST_NO_TRY( "REQUIRE_FALSE", Catch::ResultDisposition::Normal | Catch::ResultDisposition::FalseTest, expr ) - -#else -#define REQUIRE( expr ) INTERNAL_CATCH_TEST( "REQUIRE", Catch::ResultDisposition::Normal, expr ) -#define REQUIRE_FALSE( expr ) INTERNAL_CATCH_TEST( "REQUIRE_FALSE", Catch::ResultDisposition::Normal | Catch::ResultDisposition::FalseTest, expr ) -#endif - -#define REQUIRE_THROWS( expr ) INTERNAL_CATCH_THROWS( "REQUIRE_THROWS", Catch::ResultDisposition::Normal, "", expr ) -#define REQUIRE_THROWS_AS( expr, exceptionType ) INTERNAL_CATCH_THROWS_AS( "REQUIRE_THROWS_AS", exceptionType, Catch::ResultDisposition::Normal, expr ) -#define REQUIRE_THROWS_WITH( expr, matcher ) INTERNAL_CATCH_THROWS( "REQUIRE_THROWS_WITH", Catch::ResultDisposition::Normal, matcher, expr ) -#define REQUIRE_NOTHROW( expr ) INTERNAL_CATCH_NO_THROW( "REQUIRE_NOTHROW", Catch::ResultDisposition::Normal, expr ) - -#define CHECK( expr ) INTERNAL_CATCH_TEST( "CHECK", Catch::ResultDisposition::ContinueOnFailure, expr ) -#define CHECK_FALSE( expr ) INTERNAL_CATCH_TEST( "CHECK_FALSE", Catch::ResultDisposition::ContinueOnFailure | Catch::ResultDisposition::FalseTest, expr ) -#define CHECKED_IF( expr ) INTERNAL_CATCH_IF( "CHECKED_IF", Catch::ResultDisposition::ContinueOnFailure, expr ) -#define CHECKED_ELSE( expr ) INTERNAL_CATCH_ELSE( "CHECKED_ELSE", Catch::ResultDisposition::ContinueOnFailure, expr ) -#define CHECK_NOFAIL( expr ) INTERNAL_CATCH_TEST( "CHECK_NOFAIL", Catch::ResultDisposition::ContinueOnFailure | Catch::ResultDisposition::SuppressFail, expr ) - -#define CHECK_THROWS( expr ) INTERNAL_CATCH_THROWS( "CHECK_THROWS", Catch::ResultDisposition::ContinueOnFailure, "", expr ) -#define CHECK_THROWS_AS( expr, exceptionType ) INTERNAL_CATCH_THROWS_AS( "CHECK_THROWS_AS", exceptionType, Catch::ResultDisposition::ContinueOnFailure, expr ) -#define CHECK_THROWS_WITH( expr, matcher ) INTERNAL_CATCH_THROWS( "CHECK_THROWS_WITH", Catch::ResultDisposition::ContinueOnFailure, matcher, expr ) -#define CHECK_NOTHROW( expr ) INTERNAL_CATCH_NO_THROW( "CHECK_NOTHROW", Catch::ResultDisposition::ContinueOnFailure, expr ) - -#define CHECK_THAT( arg, matcher ) INTERNAL_CHECK_THAT( "CHECK_THAT", matcher, Catch::ResultDisposition::ContinueOnFailure, arg ) - -#if defined(CATCH_CONFIG_FAST_COMPILE) -#define REQUIRE_THAT( arg, matcher ) INTERNAL_CHECK_THAT_NO_TRY( "REQUIRE_THAT", matcher, Catch::ResultDisposition::Normal, arg ) -#else -#define REQUIRE_THAT( arg, matcher ) INTERNAL_CHECK_THAT( "REQUIRE_THAT", matcher, Catch::ResultDisposition::Normal, arg ) -#endif - -#define INFO( msg ) INTERNAL_CATCH_INFO( "INFO", msg ) -#define WARN( msg ) INTERNAL_CATCH_MSG( "WARN", Catch::ResultWas::Warning, Catch::ResultDisposition::ContinueOnFailure, msg ) -#define SCOPED_INFO( msg ) INTERNAL_CATCH_INFO( "INFO", msg ) -#define CAPTURE( msg ) INTERNAL_CATCH_INFO( "CAPTURE", #msg " := " << Catch::toString(msg) ) -#define SCOPED_CAPTURE( msg ) INTERNAL_CATCH_INFO( "CAPTURE", #msg " := " << Catch::toString(msg) ) - -#ifdef CATCH_CONFIG_VARIADIC_MACROS -#define TEST_CASE( ... ) INTERNAL_CATCH_TESTCASE( __VA_ARGS__ ) -#define TEST_CASE_METHOD( className, ... ) INTERNAL_CATCH_TEST_CASE_METHOD( className, __VA_ARGS__ ) -#define METHOD_AS_TEST_CASE( method, ... ) INTERNAL_CATCH_METHOD_AS_TEST_CASE( method, __VA_ARGS__ ) -#define REGISTER_TEST_CASE( Function, ... ) INTERNAL_CATCH_REGISTER_TESTCASE( Function, __VA_ARGS__ ) -#define SECTION( ... ) INTERNAL_CATCH_SECTION( __VA_ARGS__ ) -#define FAIL( ... ) INTERNAL_CATCH_MSG( "FAIL", Catch::ResultWas::ExplicitFailure, Catch::ResultDisposition::Normal, __VA_ARGS__ ) -#define FAIL_CHECK( ... ) INTERNAL_CATCH_MSG( "FAIL_CHECK", Catch::ResultWas::ExplicitFailure, Catch::ResultDisposition::ContinueOnFailure, __VA_ARGS__ ) -#define SUCCEED( ... ) INTERNAL_CATCH_MSG( "SUCCEED", Catch::ResultWas::Ok, Catch::ResultDisposition::ContinueOnFailure, __VA_ARGS__ ) -#else -#define TEST_CASE( name, description ) INTERNAL_CATCH_TESTCASE( name, description ) - #define TEST_CASE_METHOD( className, name, description ) INTERNAL_CATCH_TEST_CASE_METHOD( className, name, description ) - #define METHOD_AS_TEST_CASE( method, name, description ) INTERNAL_CATCH_METHOD_AS_TEST_CASE( method, name, description ) - #define REGISTER_TEST_CASE( method, name, description ) INTERNAL_CATCH_REGISTER_TESTCASE( method, name, description ) - #define SECTION( name, description ) INTERNAL_CATCH_SECTION( name, description ) - #define FAIL( msg ) INTERNAL_CATCH_MSG( "FAIL", Catch::ResultWas::ExplicitFailure, Catch::ResultDisposition::Normal, msg ) - #define FAIL_CHECK( msg ) INTERNAL_CATCH_MSG( "FAIL_CHECK", Catch::ResultWas::ExplicitFailure, Catch::ResultDisposition::ContinueOnFailure, msg ) - #define SUCCEED( msg ) INTERNAL_CATCH_MSG( "SUCCEED", Catch::ResultWas::Ok, Catch::ResultDisposition::ContinueOnFailure, msg ) -#endif -#define ANON_TEST_CASE() INTERNAL_CATCH_TESTCASE( "", "" ) - -#define REGISTER_REPORTER( name, reporterType ) INTERNAL_CATCH_REGISTER_REPORTER( name, reporterType ) -#define REGISTER_LEGACY_REPORTER( name, reporterType ) INTERNAL_CATCH_REGISTER_LEGACY_REPORTER( name, reporterType ) - -#define GENERATE( expr) INTERNAL_CATCH_GENERATE( expr ) - -#endif - -#define CATCH_TRANSLATE_EXCEPTION( signature ) INTERNAL_CATCH_TRANSLATE_EXCEPTION( signature ) - -// "BDD-style" convenience wrappers -#ifdef CATCH_CONFIG_VARIADIC_MACROS -#define SCENARIO( ... ) TEST_CASE( "Scenario: " __VA_ARGS__ ) -#define SCENARIO_METHOD( className, ... ) INTERNAL_CATCH_TEST_CASE_METHOD( className, "Scenario: " __VA_ARGS__ ) -#else -#define SCENARIO( name, tags ) TEST_CASE( "Scenario: " name, tags ) -#define SCENARIO_METHOD( className, name, tags ) INTERNAL_CATCH_TEST_CASE_METHOD( className, "Scenario: " name, tags ) -#endif -#define GIVEN( desc ) SECTION( std::string(" Given: ") + desc, "" ) -#define WHEN( desc ) SECTION( std::string(" When: ") + desc, "" ) -#define AND_WHEN( desc ) SECTION( std::string("And when: ") + desc, "" ) -#define THEN( desc ) SECTION( std::string(" Then: ") + desc, "" ) -#define AND_THEN( desc ) SECTION( std::string(" And: ") + desc, "" ) - -using Catch::Detail::Approx; - -// #included from: internal/catch_reenable_warnings.h - -#define TWOBLUECUBES_CATCH_REENABLE_WARNINGS_H_INCLUDED - -#ifdef __clang__ -# ifdef __ICC // icpc defines the __clang__ macro -# pragma warning(pop) -# else -# pragma clang diagnostic pop -# endif -#elif defined __GNUC__ -# pragma GCC diagnostic pop -#endif - -#endif // TWOBLUECUBES_SINGLE_INCLUDE_CATCH_HPP_INCLUDED - diff --git a/test/thirdparty/doctest/LICENSE.txt b/test/thirdparty/doctest/LICENSE.txt new file mode 100644 index 00000000..62cdd948 --- /dev/null +++ b/test/thirdparty/doctest/LICENSE.txt @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2016-2018 Viktor Kirilov + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/test/thirdparty/doctest/doctest.h b/test/thirdparty/doctest/doctest.h new file mode 100644 index 00000000..eda93fc7 --- /dev/null +++ b/test/thirdparty/doctest/doctest.h @@ -0,0 +1,5269 @@ +// ====================================================================== +// == DO NOT MODIFY THIS FILE BY HAND - IT IS AUTO GENERATED BY CMAKE! == +// ====================================================================== +// +// doctest.h - the lightest feature-rich C++ single-header testing framework for unit tests and TDD +// +// Copyright (c) 2016-2018 Viktor Kirilov +// +// Distributed under the MIT Software License +// See accompanying file LICENSE.txt or copy at +// https://opensource.org/licenses/MIT +// +// The documentation can be found at the library's page: +// https://github.com/onqtam/doctest/blob/master/doc/markdown/readme.md +// +// ================================================================================================= +// ================================================================================================= +// ================================================================================================= +// +// The library is heavily influenced by Catch - https://github.com/philsquared/Catch +// which uses the Boost Software License - Version 1.0 +// see here - https://github.com/philsquared/Catch/blob/master/LICENSE.txt +// +// The concept of subcases (sections in Catch) and expression decomposition are from there. +// Some parts of the code are taken directly: +// - stringification - the detection of "ostream& operator<<(ostream&, const T&)" and StringMaker<> +// - the Approx() helper class for floating point comparison +// - colors in the console +// - breaking into a debugger +// - signal / SEH handling +// - timer +// +// The expression decomposing templates are taken from lest - https://github.com/martinmoene/lest +// which uses the Boost Software License - Version 1.0 +// see here - https://github.com/martinmoene/lest/blob/master/LICENSE.txt +// +// ================================================================================================= +// ================================================================================================= +// ================================================================================================= + +#ifndef DOCTEST_LIBRARY_INCLUDED +#define DOCTEST_LIBRARY_INCLUDED + +// ================================================================================================= +// == VERSION ====================================================================================== +// ================================================================================================= + +#define DOCTEST_VERSION_MAJOR 2 +#define DOCTEST_VERSION_MINOR 2 +#define DOCTEST_VERSION_PATCH 1 +#define DOCTEST_VERSION_STR "2.2.1" + +#define DOCTEST_VERSION \ + (DOCTEST_VERSION_MAJOR * 10000 + DOCTEST_VERSION_MINOR * 100 + DOCTEST_VERSION_PATCH) + +// ================================================================================================= +// == COMPILER VERSION ============================================================================= +// ================================================================================================= + +// ideas for the version stuff are taken from here: https://github.com/cxxstuff/cxx_detect + +#define DOCTEST_COMPILER(MAJOR, MINOR, PATCH) ((MAJOR)*10000000 + (MINOR)*100000 + (PATCH)) + +// GCC/Clang and GCC/MSVC are mutually exclusive, but Clang/MSVC are not because of clang-cl... +#if defined(_MSC_VER) && defined(_MSC_FULL_VER) +#if _MSC_VER == _MSC_FULL_VER / 10000 +#define DOCTEST_MSVC DOCTEST_COMPILER(_MSC_VER / 100, _MSC_VER % 100, _MSC_FULL_VER % 10000) +#else // MSVC +#define DOCTEST_MSVC \ + DOCTEST_COMPILER(_MSC_VER / 100, (_MSC_FULL_VER / 100000) % 100, _MSC_FULL_VER % 100000) +#endif // MSVC +#endif // MSVC +#if defined(__clang__) && defined(__clang_minor__) +#define DOCTEST_CLANG DOCTEST_COMPILER(__clang_major__, __clang_minor__, __clang_patchlevel__) +#elif defined(__GNUC__) && defined(__GNUC_MINOR__) && defined(__GNUC_PATCHLEVEL__) && \ + !defined(__INTEL_COMPILER) +#define DOCTEST_GCC DOCTEST_COMPILER(__GNUC__, __GNUC_MINOR__, __GNUC_PATCHLEVEL__) +#endif // GCC + +#ifndef DOCTEST_MSVC +#define DOCTEST_MSVC 0 +#endif // DOCTEST_MSVC +#ifndef DOCTEST_CLANG +#define DOCTEST_CLANG 0 +#endif // DOCTEST_CLANG +#ifndef DOCTEST_GCC +#define DOCTEST_GCC 0 +#endif // DOCTEST_GCC + +// ================================================================================================= +// == COMPILER WARNINGS HELPERS ==================================================================== +// ================================================================================================= + +#if DOCTEST_CLANG +#define DOCTEST_PRAGMA_TO_STR(x) _Pragma(#x) +#define DOCTEST_CLANG_SUPPRESS_WARNING_PUSH _Pragma("clang diagnostic push") +#define DOCTEST_CLANG_SUPPRESS_WARNING(w) DOCTEST_PRAGMA_TO_STR(clang diagnostic ignored w) +#define DOCTEST_CLANG_SUPPRESS_WARNING_POP _Pragma("clang diagnostic pop") +#define DOCTEST_CLANG_SUPPRESS_WARNING_WITH_PUSH(w) \ + DOCTEST_CLANG_SUPPRESS_WARNING_PUSH DOCTEST_CLANG_SUPPRESS_WARNING(w) +#else // DOCTEST_CLANG +#define DOCTEST_CLANG_SUPPRESS_WARNING_PUSH +#define DOCTEST_CLANG_SUPPRESS_WARNING(w) +#define DOCTEST_CLANG_SUPPRESS_WARNING_POP +#define DOCTEST_CLANG_SUPPRESS_WARNING_WITH_PUSH(w) +#endif // DOCTEST_CLANG + +#if DOCTEST_GCC +#define DOCTEST_PRAGMA_TO_STR(x) _Pragma(#x) +#define DOCTEST_GCC_SUPPRESS_WARNING_PUSH _Pragma("GCC diagnostic push") +#define DOCTEST_GCC_SUPPRESS_WARNING(w) DOCTEST_PRAGMA_TO_STR(GCC diagnostic ignored w) +#define DOCTEST_GCC_SUPPRESS_WARNING_POP _Pragma("GCC diagnostic pop") +#define DOCTEST_GCC_SUPPRESS_WARNING_WITH_PUSH(w) \ + DOCTEST_GCC_SUPPRESS_WARNING_PUSH DOCTEST_GCC_SUPPRESS_WARNING(w) +#else // DOCTEST_GCC +#define DOCTEST_GCC_SUPPRESS_WARNING_PUSH +#define DOCTEST_GCC_SUPPRESS_WARNING(w) +#define DOCTEST_GCC_SUPPRESS_WARNING_POP +#define DOCTEST_GCC_SUPPRESS_WARNING_WITH_PUSH(w) +#endif // DOCTEST_GCC + +#if DOCTEST_MSVC +#define DOCTEST_MSVC_SUPPRESS_WARNING_PUSH __pragma(warning(push)) +#define DOCTEST_MSVC_SUPPRESS_WARNING(w) __pragma(warning(disable : w)) +#define DOCTEST_MSVC_SUPPRESS_WARNING_POP __pragma(warning(pop)) +#define DOCTEST_MSVC_SUPPRESS_WARNING_WITH_PUSH(w) \ + DOCTEST_MSVC_SUPPRESS_WARNING_PUSH DOCTEST_MSVC_SUPPRESS_WARNING(w) +#else // DOCTEST_MSVC +#define DOCTEST_MSVC_SUPPRESS_WARNING_PUSH +#define DOCTEST_MSVC_SUPPRESS_WARNING(w) +#define DOCTEST_MSVC_SUPPRESS_WARNING_POP +#define DOCTEST_MSVC_SUPPRESS_WARNING_WITH_PUSH(w) +#endif // DOCTEST_MSVC + +// ================================================================================================= +// == COMPILER WARNINGS ============================================================================ +// ================================================================================================= + +DOCTEST_CLANG_SUPPRESS_WARNING_PUSH +DOCTEST_CLANG_SUPPRESS_WARNING("-Wunknown-pragmas") +DOCTEST_CLANG_SUPPRESS_WARNING("-Wnon-virtual-dtor") +DOCTEST_CLANG_SUPPRESS_WARNING("-Wweak-vtables") +DOCTEST_CLANG_SUPPRESS_WARNING("-Wpadded") +DOCTEST_CLANG_SUPPRESS_WARNING("-Wdeprecated") +DOCTEST_CLANG_SUPPRESS_WARNING("-Wmissing-prototypes") +DOCTEST_CLANG_SUPPRESS_WARNING("-Wunused-local-typedef") +DOCTEST_CLANG_SUPPRESS_WARNING("-Wc++98-compat") +DOCTEST_CLANG_SUPPRESS_WARNING("-Wc++98-compat-pedantic") + +DOCTEST_GCC_SUPPRESS_WARNING_PUSH +DOCTEST_GCC_SUPPRESS_WARNING("-Wunknown-pragmas") +DOCTEST_GCC_SUPPRESS_WARNING("-Wpragmas") +DOCTEST_GCC_SUPPRESS_WARNING("-Weffc++") +DOCTEST_GCC_SUPPRESS_WARNING("-Wstrict-overflow") +DOCTEST_GCC_SUPPRESS_WARNING("-Wstrict-aliasing") +DOCTEST_GCC_SUPPRESS_WARNING("-Wctor-dtor-privacy") +DOCTEST_GCC_SUPPRESS_WARNING("-Wmissing-declarations") +DOCTEST_GCC_SUPPRESS_WARNING("-Wnon-virtual-dtor") +DOCTEST_GCC_SUPPRESS_WARNING("-Winline") +DOCTEST_GCC_SUPPRESS_WARNING("-Wunused-local-typedefs") +DOCTEST_GCC_SUPPRESS_WARNING("-Wuseless-cast") + +DOCTEST_MSVC_SUPPRESS_WARNING_PUSH +DOCTEST_MSVC_SUPPRESS_WARNING(4616) // invalid compiler warning +DOCTEST_MSVC_SUPPRESS_WARNING(4619) // invalid compiler warning +DOCTEST_MSVC_SUPPRESS_WARNING(4996) // The compiler encountered a deprecated declaration +DOCTEST_MSVC_SUPPRESS_WARNING(4706) // assignment within conditional expression +DOCTEST_MSVC_SUPPRESS_WARNING(4512) // 'class' : assignment operator could not be generated +DOCTEST_MSVC_SUPPRESS_WARNING(4127) // conditional expression is constant +DOCTEST_MSVC_SUPPRESS_WARNING(4820) // padding +DOCTEST_MSVC_SUPPRESS_WARNING(4625) // copy constructor was implicitly defined as deleted +DOCTEST_MSVC_SUPPRESS_WARNING(4626) // assignment operator was implicitly defined as deleted +DOCTEST_MSVC_SUPPRESS_WARNING(5027) // move assignment operator was implicitly defined as deleted +DOCTEST_MSVC_SUPPRESS_WARNING(5026) // move constructor was implicitly defined as deleted +DOCTEST_MSVC_SUPPRESS_WARNING(4623) // default constructor was implicitly defined as deleted +DOCTEST_MSVC_SUPPRESS_WARNING(4640) // construction of local static object is not thread-safe +// static analysis +DOCTEST_MSVC_SUPPRESS_WARNING(26439) // This kind of function may not throw. Declare it 'noexcept' +DOCTEST_MSVC_SUPPRESS_WARNING(26495) // Always initialize a member variable +DOCTEST_MSVC_SUPPRESS_WARNING(26451) // Arithmetic overflow ... +DOCTEST_MSVC_SUPPRESS_WARNING(26444) // Avoid unnamed objects with custom construction and dtr... + +// 4548 - expression before comma has no effect; expected expression with side - effect +// 4265 - class has virtual functions, but destructor is not virtual +// 4986 - exception specification does not match previous declaration +// 4350 - behavior change: 'member1' called instead of 'member2' +// 4668 - 'x' is not defined as a preprocessor macro, replacing with '0' for '#if/#elif' +// 4365 - conversion from 'int' to 'unsigned long', signed/unsigned mismatch +// 4774 - format string expected in argument 'x' is not a string literal +// 4820 - padding in structs + +// only 4 should be disabled globally: +// - 4514 # unreferenced inline function has been removed +// - 4571 # SEH related +// - 4710 # function not inlined +// - 4711 # function 'x' selected for automatic inline expansion + +#define DOCTEST_MAKE_STD_HEADERS_CLEAN_FROM_WARNINGS_ON_WALL_BEGIN \ + DOCTEST_MSVC_SUPPRESS_WARNING_PUSH \ + DOCTEST_MSVC_SUPPRESS_WARNING(4548) \ + DOCTEST_MSVC_SUPPRESS_WARNING(4265) \ + DOCTEST_MSVC_SUPPRESS_WARNING(4986) \ + DOCTEST_MSVC_SUPPRESS_WARNING(4350) \ + DOCTEST_MSVC_SUPPRESS_WARNING(4668) \ + DOCTEST_MSVC_SUPPRESS_WARNING(4365) \ + DOCTEST_MSVC_SUPPRESS_WARNING(4774) \ + DOCTEST_MSVC_SUPPRESS_WARNING(4820) \ + DOCTEST_MSVC_SUPPRESS_WARNING(4625) \ + DOCTEST_MSVC_SUPPRESS_WARNING(4626) \ + DOCTEST_MSVC_SUPPRESS_WARNING(5027) \ + DOCTEST_MSVC_SUPPRESS_WARNING(5026) \ + DOCTEST_MSVC_SUPPRESS_WARNING(4623) \ + DOCTEST_MSVC_SUPPRESS_WARNING(5039) + +#define DOCTEST_MAKE_STD_HEADERS_CLEAN_FROM_WARNINGS_ON_WALL_END DOCTEST_MSVC_SUPPRESS_WARNING_POP + +// ================================================================================================= +// == FEATURE DETECTION ============================================================================ +// ================================================================================================= + +// general compiler feature support table: https://en.cppreference.com/w/cpp/compiler_support +// MSVC C++11 feature support table: https://msdn.microsoft.com/en-us/library/hh567368.aspx +// GCC C++11 feature support table: https://gcc.gnu.org/projects/cxx-status.html +// MSVC version table: +// MSVC++ 15.0 _MSC_VER == 1910 (Visual Studio 2017) +// MSVC++ 14.0 _MSC_VER == 1900 (Visual Studio 2015) +// MSVC++ 12.0 _MSC_VER == 1800 (Visual Studio 2013) +// MSVC++ 11.0 _MSC_VER == 1700 (Visual Studio 2012) +// MSVC++ 10.0 _MSC_VER == 1600 (Visual Studio 2010) +// MSVC++ 9.0 _MSC_VER == 1500 (Visual Studio 2008) +// MSVC++ 8.0 _MSC_VER == 1400 (Visual Studio 2005) + +#if DOCTEST_MSVC && !defined(DOCTEST_CONFIG_WINDOWS_SEH) +#define DOCTEST_CONFIG_WINDOWS_SEH +#endif // MSVC +#if defined(DOCTEST_CONFIG_NO_WINDOWS_SEH) && defined(DOCTEST_CONFIG_WINDOWS_SEH) +#undef DOCTEST_CONFIG_WINDOWS_SEH +#endif // DOCTEST_CONFIG_NO_WINDOWS_SEH + +#if !defined(_WIN32) && !defined(__QNX__) && !defined(DOCTEST_CONFIG_POSIX_SIGNALS) +#define DOCTEST_CONFIG_POSIX_SIGNALS +#endif // _WIN32 +#if defined(DOCTEST_CONFIG_NO_POSIX_SIGNALS) && defined(DOCTEST_CONFIG_POSIX_SIGNALS) +#undef DOCTEST_CONFIG_POSIX_SIGNALS +#endif // DOCTEST_CONFIG_NO_POSIX_SIGNALS + +#ifndef DOCTEST_CONFIG_NO_EXCEPTIONS +#if(DOCTEST_GCC || (DOCTEST_CLANG && !DOCTEST_MSVC)) && !defined(__EXCEPTIONS) +#define DOCTEST_CONFIG_NO_EXCEPTIONS +#endif // clang and gcc +#if DOCTEST_MSVC && (defined(_HAS_EXCEPTIONS) && _HAS_EXCEPTIONS == 0) +#define DOCTEST_CONFIG_NO_EXCEPTIONS +#endif // MSVC +#endif // DOCTEST_CONFIG_NO_EXCEPTIONS + +#ifdef DOCTEST_CONFIG_NO_EXCEPTIONS_BUT_WITH_ALL_ASSERTS +#ifndef DOCTEST_CONFIG_NO_EXCEPTIONS +#define DOCTEST_CONFIG_NO_EXCEPTIONS +#endif // DOCTEST_CONFIG_NO_EXCEPTIONS +#endif // DOCTEST_CONFIG_NO_EXCEPTIONS_BUT_WITH_ALL_ASSERTS + +#if defined(DOCTEST_CONFIG_NO_EXCEPTIONS) && !defined(DOCTEST_CONFIG_NO_TRY_CATCH_IN_ASSERTS) +#define DOCTEST_CONFIG_NO_TRY_CATCH_IN_ASSERTS +#endif // DOCTEST_CONFIG_NO_EXCEPTIONS && !DOCTEST_CONFIG_NO_TRY_CATCH_IN_ASSERTS + +#if defined(DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN) && !defined(DOCTEST_CONFIG_IMPLEMENT) +#define DOCTEST_CONFIG_IMPLEMENT +#endif // DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN + +#if defined(_WIN32) || defined(__CYGWIN__) +#if DOCTEST_MSVC +#define DOCTEST_SYMBOL_EXPORT __declspec(dllexport) +#define DOCTEST_SYMBOL_IMPORT __declspec(dllimport) +#else // MSVC +#define DOCTEST_SYMBOL_EXPORT __attribute__((dllexport)) +#define DOCTEST_SYMBOL_IMPORT __attribute__((dllimport)) +#endif // MSVC +#else // _WIN32 +#define DOCTEST_SYMBOL_EXPORT __attribute__((visibility("default"))) +#define DOCTEST_SYMBOL_IMPORT +#endif // _WIN32 + +#ifdef DOCTEST_CONFIG_IMPLEMENTATION_IN_DLL +#ifdef DOCTEST_CONFIG_IMPLEMENT +#define DOCTEST_INTERFACE DOCTEST_SYMBOL_EXPORT +#else // DOCTEST_CONFIG_IMPLEMENT +#define DOCTEST_INTERFACE DOCTEST_SYMBOL_IMPORT +#endif // DOCTEST_CONFIG_IMPLEMENT +#else // DOCTEST_CONFIG_IMPLEMENTATION_IN_DLL +#define DOCTEST_INTERFACE +#endif // DOCTEST_CONFIG_IMPLEMENTATION_IN_DLL + +#if DOCTEST_MSVC +#define DOCTEST_NOINLINE __declspec(noinline) +#define DOCTEST_UNUSED +#define DOCTEST_ALIGNMENT(x) +#else // MSVC +#define DOCTEST_NOINLINE __attribute__((noinline)) +#define DOCTEST_UNUSED __attribute__((unused)) +#define DOCTEST_ALIGNMENT(x) __attribute__((aligned(x))) +#endif // MSVC + +#ifndef DOCTEST_CONFIG_NUM_CAPTURES_ON_STACK +#define DOCTEST_CONFIG_NUM_CAPTURES_ON_STACK 5 +#endif // DOCTEST_CONFIG_NUM_CAPTURES_ON_STACK + +// ================================================================================================= +// == FEATURE DETECTION END ======================================================================== +// ================================================================================================= + +// internal macros for string concatenation and anonymous variable name generation +#define DOCTEST_CAT_IMPL(s1, s2) s1##s2 +#define DOCTEST_CAT(s1, s2) DOCTEST_CAT_IMPL(s1, s2) +#ifdef __COUNTER__ // not standard and may be missing for some compilers +#define DOCTEST_ANONYMOUS(x) DOCTEST_CAT(x, __COUNTER__) +#else // __COUNTER__ +#define DOCTEST_ANONYMOUS(x) DOCTEST_CAT(x, __LINE__) +#endif // __COUNTER__ + +#ifndef DOCTEST_CONFIG_ASSERTION_PARAMETERS_BY_VALUE +#define DOCTEST_REF_WRAP(x) x& +#else // DOCTEST_CONFIG_ASSERTION_PARAMETERS_BY_VALUE +#define DOCTEST_REF_WRAP(x) x +#endif // DOCTEST_CONFIG_ASSERTION_PARAMETERS_BY_VALUE + +// not using __APPLE__ because... this is how Catch does it +#if defined(__MAC_OS_X_VERSION_MIN_REQUIRED) +#define DOCTEST_PLATFORM_MAC +#elif defined(__IPHONE_OS_VERSION_MIN_REQUIRED) +#define DOCTEST_PLATFORM_IPHONE +#elif defined(_WIN32) +#define DOCTEST_PLATFORM_WINDOWS +#else // DOCTEST_PLATFORM +#define DOCTEST_PLATFORM_LINUX +#endif // DOCTEST_PLATFORM + +// clang-format off +#define DOCTEST_DELETE_COPIES(type) type(const type&) = delete; type& operator=(const type&) = delete +#define DOCTEST_DECLARE_COPIES(type) type(const type&); type& operator=(const type&) +#define DOCTEST_DEFINE_COPIES(type) type::type(const type&) = default; type& type::operator=(const type&) = default +#define DOCTEST_DECLARE_DEFAULTS(type) type(); ~type() +#define DOCTEST_DEFINE_DEFAULTS(type) type::type() = default; type::~type() = default +// clang-format on + +#define DOCTEST_GLOBAL_NO_WARNINGS(var) \ + DOCTEST_CLANG_SUPPRESS_WARNING_WITH_PUSH("-Wglobal-constructors") \ + static int var DOCTEST_UNUSED // NOLINT(fuchsia-statically-constructed-objects,cert-err58-cpp) +#define DOCTEST_GLOBAL_NO_WARNINGS_END() DOCTEST_CLANG_SUPPRESS_WARNING_POP + +// should probably take a look at https://github.com/scottt/debugbreak +#ifdef DOCTEST_PLATFORM_MAC +#define DOCTEST_BREAK_INTO_DEBUGGER() __asm__("int $3\n" : :) +#elif DOCTEST_MSVC +#define DOCTEST_BREAK_INTO_DEBUGGER() __debugbreak() +#elif defined(__MINGW32__) +extern "C" __declspec(dllimport) void __stdcall DebugBreak(); +#define DOCTEST_BREAK_INTO_DEBUGGER() ::DebugBreak() +#else // linux +#define DOCTEST_BREAK_INTO_DEBUGGER() ((void)0) +#endif // linux + +#if DOCTEST_CLANG +// to detect if libc++ is being used with clang (the _LIBCPP_VERSION identifier) +#include +#endif // clang + +// Forward declaring 'X' in namespace std is not permitted by the C++ Standard. +DOCTEST_MSVC_SUPPRESS_WARNING_WITH_PUSH(4643) + +#if defined(_LIBCPP_VERSION) || defined(DOCTEST_CONFIG_USE_IOSFWD) +// not forward declaring ostream for libc++ because I had some problems (inline namespaces vs c++98) +// so the header is used - also it is very light and doesn't drag a ton of stuff +#include +#else // _LIBCPP_VERSION +namespace std { +template +struct char_traits; +template <> +struct char_traits; +template +class basic_ostream; +typedef basic_ostream > ostream; +} // namespace std +#endif // _LIBCPP_VERSION || DOCTEST_CONFIG_USE_IOSFWD + +#ifdef _LIBCPP_VERSION +#include +#else // _LIBCPP_VERSION +namespace std { +typedef decltype(nullptr) nullptr_t; +} +#endif // _LIBCPP_VERSION + +DOCTEST_MSVC_SUPPRESS_WARNING_POP + +#ifdef DOCTEST_CONFIG_INCLUDE_TYPE_TRAITS +#include +#endif // DOCTEST_CONFIG_INCLUDE_TYPE_TRAITS + +namespace doctest { + +DOCTEST_INTERFACE extern bool is_running_in_test; + +// A 24 byte string class (can be as small as 17 for x64 and 13 for x86) that can hold strings with length +// of up to 23 chars on the stack before going on the heap - the last byte of the buffer is used for: +// - "is small" bit - the highest bit - if "0" then it is small - otherwise its "1" (128) +// - if small - capacity left before going on the heap - using the lowest 5 bits +// - if small - 2 bits are left unused - the second and third highest ones +// - if small - acts as a null terminator if strlen() is 23 (24 including the null terminator) +// and the "is small" bit remains "0" ("as well as the capacity left") so its OK +// Idea taken from this lecture about the string implementation of facebook/folly - fbstring +// https://www.youtube.com/watch?v=kPR8h4-qZdk +// TODO: +// - optimizations - like not deleting memory unnecessarily in operator= and etc. +// - resize/reserve/clear +// - substr +// - replace +// - back/front +// - iterator stuff +// - find & friends +// - push_back/pop_back +// - assign/insert/erase +// - relational operators as free functions - taking const char* as one of the params +class DOCTEST_INTERFACE String +{ + static const unsigned len = 24; //!OCLINT avoid private static members + static const unsigned last = len - 1; //!OCLINT avoid private static members + + struct view // len should be more than sizeof(view) - because of the final byte for flags + { + char* ptr; + unsigned size; + unsigned capacity; + }; + + union + { + char buf[len]; + view data; + }; + + bool isOnStack() const { return (buf[last] & 128) == 0; } + void setOnHeap(); + void setLast(unsigned in = last); + + void copy(const String& other); + +public: + String(); + ~String(); + + String(const char* in); + String(const char* in, unsigned in_size); + + String(const String& other); + String& operator=(const String& other); + + String& operator+=(const String& other); + String operator+(const String& other) const; + + String(String&& other); + String& operator=(String&& other); + + char operator[](unsigned i) const; + char& operator[](unsigned i); + + // the only functions I'm willing to leave in the interface - available for inlining + const char* c_str() const { return const_cast(this)->c_str(); } // NOLINT + char* c_str() { + if(isOnStack()) + return reinterpret_cast(buf); + return data.ptr; + } + + unsigned size() const; + unsigned capacity() const; + + int compare(const char* other, bool no_case = false) const; + int compare(const String& other, bool no_case = false) const; +}; + +DOCTEST_INTERFACE bool operator==(const String& lhs, const String& rhs); +DOCTEST_INTERFACE bool operator!=(const String& lhs, const String& rhs); +DOCTEST_INTERFACE bool operator<(const String& lhs, const String& rhs); +DOCTEST_INTERFACE bool operator>(const String& lhs, const String& rhs); +DOCTEST_INTERFACE bool operator<=(const String& lhs, const String& rhs); +DOCTEST_INTERFACE bool operator>=(const String& lhs, const String& rhs); + +DOCTEST_INTERFACE std::ostream& operator<<(std::ostream& s, const String& in); + +namespace Color { + enum Enum + { + None = 0, + White, + Red, + Green, + Blue, + Cyan, + Yellow, + Grey, + + Bright = 0x10, + + BrightRed = Bright | Red, + BrightGreen = Bright | Green, + LightGrey = Bright | Grey, + BrightWhite = Bright | White + }; + + DOCTEST_INTERFACE std::ostream& operator<<(std::ostream& s, Color::Enum code); +} // namespace Color + +namespace assertType { + enum Enum + { + // macro traits + + is_warn = 1, + is_check = 2 * is_warn, + is_require = 2 * is_check, + + is_normal = 2 * is_require, + is_throws = 2 * is_normal, + is_throws_as = 2 * is_throws, + is_throws_with = 2 * is_throws_as, + is_nothrow = 2 * is_throws_with, + + is_false = 2 * is_nothrow, + is_unary = 2 * is_false, // not checked anywhere - used just to distinguish the types + + is_eq = 2 * is_unary, + is_ne = 2 * is_eq, + + is_lt = 2 * is_ne, + is_gt = 2 * is_lt, + + is_ge = 2 * is_gt, + is_le = 2 * is_ge, + + // macro types + + DT_WARN = is_normal | is_warn, + DT_CHECK = is_normal | is_check, + DT_REQUIRE = is_normal | is_require, + + DT_WARN_FALSE = is_normal | is_false | is_warn, + DT_CHECK_FALSE = is_normal | is_false | is_check, + DT_REQUIRE_FALSE = is_normal | is_false | is_require, + + DT_WARN_THROWS = is_throws | is_warn, + DT_CHECK_THROWS = is_throws | is_check, + DT_REQUIRE_THROWS = is_throws | is_require, + + DT_WARN_THROWS_AS = is_throws_as | is_warn, + DT_CHECK_THROWS_AS = is_throws_as | is_check, + DT_REQUIRE_THROWS_AS = is_throws_as | is_require, + + DT_WARN_THROWS_WITH = is_throws_with | is_warn, + DT_CHECK_THROWS_WITH = is_throws_with | is_check, + DT_REQUIRE_THROWS_WITH = is_throws_with | is_require, + + DT_WARN_NOTHROW = is_nothrow | is_warn, + DT_CHECK_NOTHROW = is_nothrow | is_check, + DT_REQUIRE_NOTHROW = is_nothrow | is_require, + + DT_WARN_EQ = is_normal | is_eq | is_warn, + DT_CHECK_EQ = is_normal | is_eq | is_check, + DT_REQUIRE_EQ = is_normal | is_eq | is_require, + + DT_WARN_NE = is_normal | is_ne | is_warn, + DT_CHECK_NE = is_normal | is_ne | is_check, + DT_REQUIRE_NE = is_normal | is_ne | is_require, + + DT_WARN_GT = is_normal | is_gt | is_warn, + DT_CHECK_GT = is_normal | is_gt | is_check, + DT_REQUIRE_GT = is_normal | is_gt | is_require, + + DT_WARN_LT = is_normal | is_lt | is_warn, + DT_CHECK_LT = is_normal | is_lt | is_check, + DT_REQUIRE_LT = is_normal | is_lt | is_require, + + DT_WARN_GE = is_normal | is_ge | is_warn, + DT_CHECK_GE = is_normal | is_ge | is_check, + DT_REQUIRE_GE = is_normal | is_ge | is_require, + + DT_WARN_LE = is_normal | is_le | is_warn, + DT_CHECK_LE = is_normal | is_le | is_check, + DT_REQUIRE_LE = is_normal | is_le | is_require, + + DT_WARN_UNARY = is_normal | is_unary | is_warn, + DT_CHECK_UNARY = is_normal | is_unary | is_check, + DT_REQUIRE_UNARY = is_normal | is_unary | is_require, + + DT_WARN_UNARY_FALSE = is_normal | is_false | is_unary | is_warn, + DT_CHECK_UNARY_FALSE = is_normal | is_false | is_unary | is_check, + DT_REQUIRE_UNARY_FALSE = is_normal | is_false | is_unary | is_require, + }; +} // namespace assertType + +DOCTEST_INTERFACE const char* assertString(assertType::Enum at); +DOCTEST_INTERFACE const char* failureString(assertType::Enum at); +DOCTEST_INTERFACE const char* removePathFromFilename(const char* file); + +struct DOCTEST_INTERFACE TestCaseData +{ + const char* m_file; // the file in which the test was registered + unsigned m_line; // the line where the test was registered + const char* m_name; // name of the test case + const char* m_test_suite; // the test suite in which the test was added + const char* m_description; + bool m_skip; + bool m_may_fail; + bool m_should_fail; + int m_expected_failures; + double m_timeout; + + DOCTEST_DECLARE_DEFAULTS(TestCaseData); + DOCTEST_DECLARE_COPIES(TestCaseData); +}; + +struct DOCTEST_INTERFACE AssertData +{ + // common - for all asserts + const TestCaseData* m_test_case; + assertType::Enum m_at; + const char* m_file; + int m_line; + const char* m_expr; + bool m_failed; + + // exception-related - for all asserts + bool m_threw; + String m_exception; + + // for normal asserts + String m_decomp; + + // for specific exception-related asserts + bool m_threw_as; + const char* m_exception_type; + + DOCTEST_DECLARE_DEFAULTS(AssertData); + DOCTEST_DELETE_COPIES(AssertData); +}; + +struct DOCTEST_INTERFACE MessageData +{ + String m_string; + const char* m_file; + int m_line; + assertType::Enum m_severity; + + DOCTEST_DECLARE_DEFAULTS(MessageData); + DOCTEST_DELETE_COPIES(MessageData); +}; + +struct DOCTEST_INTERFACE SubcaseSignature +{ + const char* m_name; + const char* m_file; + int m_line; + + SubcaseSignature(const char* name, const char* file, int line); + + bool operator<(const SubcaseSignature& other) const; + + DOCTEST_DECLARE_DEFAULTS(SubcaseSignature); + DOCTEST_DECLARE_COPIES(SubcaseSignature); +}; + +struct DOCTEST_INTERFACE IContextScope +{ + DOCTEST_DELETE_COPIES(IContextScope); + + IContextScope(); + virtual ~IContextScope(); + virtual void stringify(std::ostream*) const = 0; +}; + +struct ContextOptions //!OCLINT too many fields +{ + // == parameters from the command line + String order_by; // how tests should be ordered + unsigned rand_seed; // the seed for rand ordering + + unsigned first; // the first (matching) test to be executed + unsigned last; // the last (matching) test to be executed + + int abort_after; // stop tests after this many failed assertions + int subcase_filter_levels; // apply the subcase filters for the first N levels + + bool success; // include successful assertions in output + bool case_sensitive; // if filtering should be case sensitive + bool exit; // if the program should be exited after the tests are ran/whatever + bool duration; // print the time duration of each test case + bool no_throw; // to skip exceptions-related assertion macros + bool no_exitcode; // if the framework should return 0 as the exitcode + bool no_run; // to not run the tests at all (can be done with an "*" exclude) + bool no_version; // to not print the version of the framework + bool no_colors; // if output to the console should be colorized + bool force_colors; // forces the use of colors even when a tty cannot be detected + bool no_breaks; // to not break into the debugger + bool no_skip; // don't skip test cases which are marked to be skipped + bool gnu_file_line; // if line numbers should be surrounded with :x: and not (x): + bool no_path_in_filenames; // if the path to files should be removed from the output + bool no_line_numbers; // if source code line numbers should be omitted from the output + bool no_skipped_summary; // don't print "skipped" in the summary !!! UNDOCUMENTED !!! + + bool help; // to print the help + bool version; // to print the version + bool count; // if only the count of matching tests is to be retreived + bool list_test_cases; // to list all tests matching the filters + bool list_test_suites; // to list all suites matching the filters + bool list_reporters; // lists all registered reporters + + DOCTEST_DECLARE_DEFAULTS(ContextOptions); + DOCTEST_DELETE_COPIES(ContextOptions); +}; + +namespace detail { +#if defined(DOCTEST_CONFIG_TREAT_CHAR_STAR_AS_STRING) || defined(DOCTEST_CONFIG_INCLUDE_TYPE_TRAITS) + template + struct enable_if + {}; + + template + struct enable_if + { typedef TYPE type; }; +#endif // DOCTEST_CONFIG_TREAT_CHAR_STAR_AS_STRING) || DOCTEST_CONFIG_INCLUDE_TYPE_TRAITS + + // clang-format off + template struct remove_reference { typedef T type; }; + template struct remove_reference { typedef T type; }; + template struct remove_reference { typedef T type; }; + + template struct remove_const { typedef T type; }; + template struct remove_const { typedef T type; }; + // clang-format on + + template + struct deferred_false + // cppcheck-suppress unusedStructMember + { static const bool value = false; }; + + namespace has_insertion_operator_impl { + typedef char no; + typedef char yes[2]; + + struct any_t + { + template + // cppcheck-suppress noExplicitConstructor + any_t(const DOCTEST_REF_WRAP(T)); + }; + + yes& testStreamable(std::ostream&); + no testStreamable(no); + + no operator<<(const std::ostream&, const any_t&); + + template + struct has_insertion_operator + { + static std::ostream& s; + static const DOCTEST_REF_WRAP(T) t; + static const bool value = sizeof(testStreamable(s << t)) == sizeof(yes); + }; + } // namespace has_insertion_operator_impl + + template + struct has_insertion_operator : has_insertion_operator_impl::has_insertion_operator + {}; + + DOCTEST_INTERFACE void my_memcpy(void* dest, const void* src, unsigned num); + + DOCTEST_INTERFACE std::ostream* getTlsOss(); // returns a thread-local ostringstream + DOCTEST_INTERFACE String getTlsOssResult(); + + template + struct StringMakerBase + { + template + static String convert(const DOCTEST_REF_WRAP(T)) { + return "{?}"; + } + }; + + template <> + struct StringMakerBase + { + template + static String convert(const DOCTEST_REF_WRAP(T) in) { + *getTlsOss() << in; + return getTlsOssResult(); + } + }; + + DOCTEST_INTERFACE String rawMemoryToString(const void* object, unsigned size); + + template + String rawMemoryToString(const DOCTEST_REF_WRAP(T) object) { + return rawMemoryToString(&object, sizeof(object)); + } + + template + const char* type_to_string() { + return "<>"; + } +} // namespace detail + +template +struct StringMaker : public detail::StringMakerBase::value> +{}; + +template +struct StringMaker +{ + template + static String convert(U* p) { + if(p) + return detail::rawMemoryToString(p); + return "NULL"; + } +}; + +template +struct StringMaker +{ + static String convert(R C::*p) { + if(p) + return detail::rawMemoryToString(p); + return "NULL"; + } +}; + +template +String toString(const DOCTEST_REF_WRAP(T) value) { + return StringMaker::convert(value); +} + +#ifdef DOCTEST_CONFIG_TREAT_CHAR_STAR_AS_STRING +DOCTEST_INTERFACE String toString(char* in); +DOCTEST_INTERFACE String toString(const char* in); +#endif // DOCTEST_CONFIG_TREAT_CHAR_STAR_AS_STRING +DOCTEST_INTERFACE String toString(bool in); +DOCTEST_INTERFACE String toString(float in); +DOCTEST_INTERFACE String toString(double in); +DOCTEST_INTERFACE String toString(double long in); + +DOCTEST_INTERFACE String toString(char in); +DOCTEST_INTERFACE String toString(char signed in); +DOCTEST_INTERFACE String toString(char unsigned in); +DOCTEST_INTERFACE String toString(int short in); +DOCTEST_INTERFACE String toString(int short unsigned in); +DOCTEST_INTERFACE String toString(int in); +DOCTEST_INTERFACE String toString(int unsigned in); +DOCTEST_INTERFACE String toString(int long in); +DOCTEST_INTERFACE String toString(int long unsigned in); +DOCTEST_INTERFACE String toString(int long long in); +DOCTEST_INTERFACE String toString(int long long unsigned in); +DOCTEST_INTERFACE String toString(std::nullptr_t in); + +class DOCTEST_INTERFACE Approx +{ +public: + explicit Approx(double value); + + DOCTEST_DECLARE_COPIES(Approx); + + Approx operator()(double value) const; + +#ifdef DOCTEST_CONFIG_INCLUDE_TYPE_TRAITS + template + explicit Approx(const T& value, + typename detail::enable_if::value>::type* = + static_cast(nullptr)) { + *this = Approx(static_cast(value)); + } +#endif // DOCTEST_CONFIG_INCLUDE_TYPE_TRAITS + + Approx& epsilon(double newEpsilon); + +#ifdef DOCTEST_CONFIG_INCLUDE_TYPE_TRAITS + template + typename detail::enable_if::value, Approx&>::type epsilon( + const T& newEpsilon) { + m_epsilon = static_cast(newEpsilon); + return *this; + } +#endif // DOCTEST_CONFIG_INCLUDE_TYPE_TRAITS + + Approx& scale(double newScale); + +#ifdef DOCTEST_CONFIG_INCLUDE_TYPE_TRAITS + template + typename detail::enable_if::value, Approx&>::type scale( + const T& newScale) { + m_scale = static_cast(newScale); + return *this; + } +#endif // DOCTEST_CONFIG_INCLUDE_TYPE_TRAITS + + // clang-format off + DOCTEST_INTERFACE friend bool operator==(double lhs, const Approx & rhs); + DOCTEST_INTERFACE friend bool operator==(const Approx & lhs, double rhs); + DOCTEST_INTERFACE friend bool operator!=(double lhs, const Approx & rhs); + DOCTEST_INTERFACE friend bool operator!=(const Approx & lhs, double rhs); + DOCTEST_INTERFACE friend bool operator<=(double lhs, const Approx & rhs); + DOCTEST_INTERFACE friend bool operator<=(const Approx & lhs, double rhs); + DOCTEST_INTERFACE friend bool operator>=(double lhs, const Approx & rhs); + DOCTEST_INTERFACE friend bool operator>=(const Approx & lhs, double rhs); + DOCTEST_INTERFACE friend bool operator< (double lhs, const Approx & rhs); + DOCTEST_INTERFACE friend bool operator< (const Approx & lhs, double rhs); + DOCTEST_INTERFACE friend bool operator> (double lhs, const Approx & rhs); + DOCTEST_INTERFACE friend bool operator> (const Approx & lhs, double rhs); + + DOCTEST_INTERFACE friend String toString(const Approx& in); + +#ifdef DOCTEST_CONFIG_INCLUDE_TYPE_TRAITS +#define DOCTEST_APPROX_PREFIX \ + template friend typename detail::enable_if::value, bool>::type + + DOCTEST_APPROX_PREFIX operator==(const T& lhs, const Approx& rhs) { return operator==(double(lhs), rhs); } + DOCTEST_APPROX_PREFIX operator==(const Approx& lhs, const T& rhs) { return operator==(rhs, lhs); } + DOCTEST_APPROX_PREFIX operator!=(const T& lhs, const Approx& rhs) { return !operator==(lhs, rhs); } + DOCTEST_APPROX_PREFIX operator!=(const Approx& lhs, const T& rhs) { return !operator==(rhs, lhs); } + DOCTEST_APPROX_PREFIX operator<=(const T& lhs, const Approx& rhs) { return double(lhs) < rhs.m_value || lhs == rhs; } + DOCTEST_APPROX_PREFIX operator<=(const Approx& lhs, const T& rhs) { return lhs.m_value < double(rhs) || lhs == rhs; } + DOCTEST_APPROX_PREFIX operator>=(const T& lhs, const Approx& rhs) { return double(lhs) > rhs.m_value || lhs == rhs; } + DOCTEST_APPROX_PREFIX operator>=(const Approx& lhs, const T& rhs) { return lhs.m_value > double(rhs) || lhs == rhs; } + DOCTEST_APPROX_PREFIX operator< (const T& lhs, const Approx& rhs) { return double(lhs) < rhs.m_value && lhs != rhs; } + DOCTEST_APPROX_PREFIX operator< (const Approx& lhs, const T& rhs) { return lhs.m_value < double(rhs) && lhs != rhs; } + DOCTEST_APPROX_PREFIX operator> (const T& lhs, const Approx& rhs) { return double(lhs) > rhs.m_value && lhs != rhs; } + DOCTEST_APPROX_PREFIX operator> (const Approx& lhs, const T& rhs) { return lhs.m_value > double(rhs) && lhs != rhs; } +#undef DOCTEST_APPROX_PREFIX +#endif // DOCTEST_CONFIG_INCLUDE_TYPE_TRAITS + + // clang-format on + +private: + double m_epsilon; + double m_scale; + double m_value; +}; + +DOCTEST_INTERFACE String toString(const Approx& in); + +DOCTEST_INTERFACE const ContextOptions* getContextOptions(); + +#if !defined(DOCTEST_CONFIG_DISABLE) + +namespace detail { + // clang-format off +#ifdef DOCTEST_CONFIG_TREAT_CHAR_STAR_AS_STRING + template struct decay_array { typedef T type; }; + template struct decay_array { typedef T* type; }; + template struct decay_array { typedef T* type; }; + + template struct not_char_pointer { enum { value = 1 }; }; + template<> struct not_char_pointer { enum { value = 0 }; }; + template<> struct not_char_pointer { enum { value = 0 }; }; + + template struct can_use_op : public not_char_pointer::type> {}; +#endif // DOCTEST_CONFIG_TREAT_CHAR_STAR_AS_STRING + // clang-format on + + struct DOCTEST_INTERFACE TestFailureException + { + DOCTEST_DECLARE_DEFAULTS(TestFailureException); + DOCTEST_DECLARE_COPIES(TestFailureException); + }; + + DOCTEST_INTERFACE bool checkIfShouldThrow(assertType::Enum at); + DOCTEST_INTERFACE void throwException(); + + struct DOCTEST_INTERFACE Subcase + { + SubcaseSignature m_signature; + bool m_entered = false; + + Subcase(const char* name, const char* file, int line); + ~Subcase(); + + DOCTEST_DELETE_COPIES(Subcase); + + operator bool() const; + }; + + template + String stringifyBinaryExpr(const DOCTEST_REF_WRAP(L) lhs, const char* op, + const DOCTEST_REF_WRAP(R) rhs) { + return toString(lhs) + op + toString(rhs); + } + +#define DOCTEST_DO_BINARY_EXPRESSION_COMPARISON(op, op_str, op_macro) \ + template \ + DOCTEST_NOINLINE Result operator op(const DOCTEST_REF_WRAP(R) rhs) { \ + bool res = op_macro(lhs, rhs); \ + if(m_at & assertType::is_false) \ + res = !res; \ + if(!res || doctest::getContextOptions()->success) \ + return Result(res, stringifyBinaryExpr(lhs, op_str, rhs)); \ + return Result(res); \ + } + +#define DOCTEST_FORBIT_EXPRESSION(rt, op) \ + template \ + rt& operator op(const R&) { \ + static_assert(deferred_false::value, \ + "Expression Too Complex Please Rewrite As Binary Comparison!"); \ + return *this; \ + } + + struct DOCTEST_INTERFACE Result + { + bool m_passed; + String m_decomp; + + Result(bool passed, const String& decomposition = String()); + + DOCTEST_DECLARE_DEFAULTS(Result); + DOCTEST_DECLARE_COPIES(Result); + + // forbidding some expressions based on this table: http://en.cppreference.com/w/cpp/language/operator_precedence + DOCTEST_FORBIT_EXPRESSION(Result, &) + DOCTEST_FORBIT_EXPRESSION(Result, ^) + DOCTEST_FORBIT_EXPRESSION(Result, |) + DOCTEST_FORBIT_EXPRESSION(Result, &&) + DOCTEST_FORBIT_EXPRESSION(Result, ||) + DOCTEST_FORBIT_EXPRESSION(Result, ==) + DOCTEST_FORBIT_EXPRESSION(Result, !=) + DOCTEST_FORBIT_EXPRESSION(Result, <) + DOCTEST_FORBIT_EXPRESSION(Result, >) + DOCTEST_FORBIT_EXPRESSION(Result, <=) + DOCTEST_FORBIT_EXPRESSION(Result, >=) + DOCTEST_FORBIT_EXPRESSION(Result, =) + DOCTEST_FORBIT_EXPRESSION(Result, +=) + DOCTEST_FORBIT_EXPRESSION(Result, -=) + DOCTEST_FORBIT_EXPRESSION(Result, *=) + DOCTEST_FORBIT_EXPRESSION(Result, /=) + DOCTEST_FORBIT_EXPRESSION(Result, %=) + DOCTEST_FORBIT_EXPRESSION(Result, <<=) + DOCTEST_FORBIT_EXPRESSION(Result, >>=) + DOCTEST_FORBIT_EXPRESSION(Result, &=) + DOCTEST_FORBIT_EXPRESSION(Result, ^=) + DOCTEST_FORBIT_EXPRESSION(Result, |=) + }; + +#ifndef DOCTEST_CONFIG_NO_COMPARISON_WARNING_SUPPRESSION + + DOCTEST_CLANG_SUPPRESS_WARNING_PUSH + DOCTEST_CLANG_SUPPRESS_WARNING("-Wsign-conversion") + DOCTEST_CLANG_SUPPRESS_WARNING("-Wsign-compare") + //DOCTEST_CLANG_SUPPRESS_WARNING("-Wdouble-promotion") + //DOCTEST_CLANG_SUPPRESS_WARNING("-Wconversion") + //DOCTEST_CLANG_SUPPRESS_WARNING("-Wfloat-equal") + + DOCTEST_GCC_SUPPRESS_WARNING_PUSH + DOCTEST_GCC_SUPPRESS_WARNING("-Wsign-conversion") + DOCTEST_GCC_SUPPRESS_WARNING("-Wsign-compare") + //DOCTEST_GCC_SUPPRESS_WARNING("-Wdouble-promotion") + //DOCTEST_GCC_SUPPRESS_WARNING("-Wconversion") + //DOCTEST_GCC_SUPPRESS_WARNING("-Wfloat-equal") + + DOCTEST_MSVC_SUPPRESS_WARNING_PUSH + // http://stackoverflow.com/questions/39479163 what's the difference between 4018 and 4389 + DOCTEST_MSVC_SUPPRESS_WARNING(4388) // signed/unsigned mismatch + DOCTEST_MSVC_SUPPRESS_WARNING(4389) // 'operator' : signed/unsigned mismatch + DOCTEST_MSVC_SUPPRESS_WARNING(4018) // 'expression' : signed/unsigned mismatch + //DOCTEST_MSVC_SUPPRESS_WARNING(4805) // 'operation' : unsafe mix of type 'type' and type 'type' in operation + +#endif // DOCTEST_CONFIG_NO_COMPARISON_WARNING_SUPPRESSION + + // clang-format off +#ifndef DOCTEST_CONFIG_TREAT_CHAR_STAR_AS_STRING +#define DOCTEST_COMPARISON_RETURN_TYPE bool +#else // DOCTEST_CONFIG_TREAT_CHAR_STAR_AS_STRING +#define DOCTEST_COMPARISON_RETURN_TYPE typename enable_if::value || can_use_op::value, bool>::type + inline bool eq(const char* lhs, const char* rhs) { return String(lhs) == String(rhs); } + inline bool ne(const char* lhs, const char* rhs) { return String(lhs) != String(rhs); } + inline bool lt(const char* lhs, const char* rhs) { return String(lhs) < String(rhs); } + inline bool gt(const char* lhs, const char* rhs) { return String(lhs) > String(rhs); } + inline bool le(const char* lhs, const char* rhs) { return String(lhs) <= String(rhs); } + inline bool ge(const char* lhs, const char* rhs) { return String(lhs) >= String(rhs); } +#endif // DOCTEST_CONFIG_TREAT_CHAR_STAR_AS_STRING + // clang-format on + +#define DOCTEST_RELATIONAL_OP(name, op) \ + template \ + DOCTEST_COMPARISON_RETURN_TYPE name(const DOCTEST_REF_WRAP(L) lhs, \ + const DOCTEST_REF_WRAP(R) rhs) { \ + return lhs op rhs; \ + } + + DOCTEST_RELATIONAL_OP(eq, ==) + DOCTEST_RELATIONAL_OP(ne, !=) + DOCTEST_RELATIONAL_OP(lt, <) + DOCTEST_RELATIONAL_OP(gt, >) + DOCTEST_RELATIONAL_OP(le, <=) + DOCTEST_RELATIONAL_OP(ge, >=) + +#ifndef DOCTEST_CONFIG_TREAT_CHAR_STAR_AS_STRING +#define DOCTEST_CMP_EQ(l, r) l == r +#define DOCTEST_CMP_NE(l, r) l != r +#define DOCTEST_CMP_GT(l, r) l > r +#define DOCTEST_CMP_LT(l, r) l < r +#define DOCTEST_CMP_GE(l, r) l >= r +#define DOCTEST_CMP_LE(l, r) l <= r +#else // DOCTEST_CONFIG_TREAT_CHAR_STAR_AS_STRING +#define DOCTEST_CMP_EQ(l, r) eq(l, r) +#define DOCTEST_CMP_NE(l, r) ne(l, r) +#define DOCTEST_CMP_GT(l, r) gt(l, r) +#define DOCTEST_CMP_LT(l, r) lt(l, r) +#define DOCTEST_CMP_GE(l, r) ge(l, r) +#define DOCTEST_CMP_LE(l, r) le(l, r) +#endif // DOCTEST_CONFIG_TREAT_CHAR_STAR_AS_STRING + + template + // cppcheck-suppress copyCtorAndEqOperator + struct Expression_lhs + { + L lhs; + assertType::Enum m_at; + + explicit Expression_lhs(L in, assertType::Enum at) + : lhs(in) + , m_at(at) {} + + DOCTEST_NOINLINE operator Result() { + bool res = !!lhs; + if(m_at & assertType::is_false) //!OCLINT bitwise operator in conditional + res = !res; + + if(!res || getContextOptions()->success) + return Result(res, toString(lhs)); + return Result(res); + } + + // clang-format off + DOCTEST_DO_BINARY_EXPRESSION_COMPARISON(==, " == ", DOCTEST_CMP_EQ) //!OCLINT bitwise operator in conditional + DOCTEST_DO_BINARY_EXPRESSION_COMPARISON(!=, " != ", DOCTEST_CMP_NE) //!OCLINT bitwise operator in conditional + DOCTEST_DO_BINARY_EXPRESSION_COMPARISON(>, " > ", DOCTEST_CMP_GT) //!OCLINT bitwise operator in conditional + DOCTEST_DO_BINARY_EXPRESSION_COMPARISON(<, " < ", DOCTEST_CMP_LT) //!OCLINT bitwise operator in conditional + DOCTEST_DO_BINARY_EXPRESSION_COMPARISON(>=, " >= ", DOCTEST_CMP_GE) //!OCLINT bitwise operator in conditional + DOCTEST_DO_BINARY_EXPRESSION_COMPARISON(<=, " <= ", DOCTEST_CMP_LE) //!OCLINT bitwise operator in conditional + // clang-format on + + // forbidding some expressions based on this table: http://en.cppreference.com/w/cpp/language/operator_precedence + DOCTEST_FORBIT_EXPRESSION(Expression_lhs, &) + DOCTEST_FORBIT_EXPRESSION(Expression_lhs, ^) + DOCTEST_FORBIT_EXPRESSION(Expression_lhs, |) + DOCTEST_FORBIT_EXPRESSION(Expression_lhs, &&) + DOCTEST_FORBIT_EXPRESSION(Expression_lhs, ||) + DOCTEST_FORBIT_EXPRESSION(Expression_lhs, =) + DOCTEST_FORBIT_EXPRESSION(Expression_lhs, +=) + DOCTEST_FORBIT_EXPRESSION(Expression_lhs, -=) + DOCTEST_FORBIT_EXPRESSION(Expression_lhs, *=) + DOCTEST_FORBIT_EXPRESSION(Expression_lhs, /=) + DOCTEST_FORBIT_EXPRESSION(Expression_lhs, %=) + DOCTEST_FORBIT_EXPRESSION(Expression_lhs, <<=) + DOCTEST_FORBIT_EXPRESSION(Expression_lhs, >>=) + DOCTEST_FORBIT_EXPRESSION(Expression_lhs, &=) + DOCTEST_FORBIT_EXPRESSION(Expression_lhs, ^=) + DOCTEST_FORBIT_EXPRESSION(Expression_lhs, |=) + // these 2 are unfortunate because they should be allowed - they have higher precedence over the comparisons, but the + // ExpressionDecomposer class uses the left shift operator to capture the left operand of the binary expression... + DOCTEST_FORBIT_EXPRESSION(Expression_lhs, <<) + DOCTEST_FORBIT_EXPRESSION(Expression_lhs, >>) + }; + +#ifndef DOCTEST_CONFIG_NO_COMPARISON_WARNING_SUPPRESSION + + DOCTEST_CLANG_SUPPRESS_WARNING_POP + DOCTEST_MSVC_SUPPRESS_WARNING_POP + DOCTEST_GCC_SUPPRESS_WARNING_POP + +#endif // DOCTEST_CONFIG_NO_COMPARISON_WARNING_SUPPRESSION + + struct DOCTEST_INTERFACE ExpressionDecomposer + { + assertType::Enum m_at; + + ExpressionDecomposer(assertType::Enum at); + + DOCTEST_DECLARE_DEFAULTS(ExpressionDecomposer); + DOCTEST_DELETE_COPIES(ExpressionDecomposer); + + // The right operator for capturing expressions is "<=" instead of "<<" (based on the operator precedence table) + // but then there will be warnings from GCC about "-Wparentheses" and since "_Pragma()" is problematic this will stay for now... + // https://github.com/philsquared/Catch/issues/870 + // https://github.com/philsquared/Catch/issues/565 + template + Expression_lhs operator<<(const DOCTEST_REF_WRAP(L) operand) { + return Expression_lhs(operand, m_at); + } + }; + + struct DOCTEST_INTERFACE TestSuite + { + const char* m_test_suite; + const char* m_description; + bool m_skip; + bool m_may_fail; + bool m_should_fail; + int m_expected_failures; + double m_timeout; + + DOCTEST_DECLARE_DEFAULTS(TestSuite); + DOCTEST_DECLARE_COPIES(TestSuite); + + TestSuite& operator*(const char* in); + + template + TestSuite& operator*(const T& in) { + in.fill(*this); + return *this; + } + }; + + typedef void (*funcType)(); + + struct DOCTEST_INTERFACE TestCase : public TestCaseData + { + funcType m_test; // a function pointer to the test case + + const char* m_type; // for templated test cases - gets appended to the real name + int m_template_id; // an ID used to distinguish between the different versions of a templated test case + String m_full_name; // contains the name (only for templated test cases!) + the template type + + TestCase(funcType test, const char* file, unsigned line, const TestSuite& test_suite, + const char* type = "", int template_id = -1); + + DOCTEST_DECLARE_DEFAULTS(TestCase); + + TestCase(const TestCase& other); + + DOCTEST_MSVC_SUPPRESS_WARNING_WITH_PUSH(26434) // hides a non-virtual function + TestCase& operator=(const TestCase& other); + DOCTEST_MSVC_SUPPRESS_WARNING_POP + + TestCase& operator*(const char* in); + + template + TestCase& operator*(const T& in) { + in.fill(*this); + return *this; + } + + bool operator<(const TestCase& other) const; + }; + + // forward declarations of functions used by the macros + DOCTEST_INTERFACE int regTest(const TestCase& tc); + DOCTEST_INTERFACE int setTestSuite(const TestSuite& ts); + DOCTEST_INTERFACE bool isDebuggerActive(); + + namespace binaryAssertComparison { + enum Enum + { + eq = 0, + ne, + gt, + lt, + ge, + le + }; + } // namespace binaryAssertComparison + + // clang-format off + template struct RelationalComparator { bool operator()(const DOCTEST_REF_WRAP(L), const DOCTEST_REF_WRAP(R) ) const { return false; } }; + +#define DOCTEST_BINARY_RELATIONAL_OP(n, op) \ + template struct RelationalComparator { bool operator()(const DOCTEST_REF_WRAP(L) lhs, const DOCTEST_REF_WRAP(R) rhs) const { return op(lhs, rhs); } }; + // clang-format on + + DOCTEST_BINARY_RELATIONAL_OP(0, eq) + DOCTEST_BINARY_RELATIONAL_OP(1, ne) + DOCTEST_BINARY_RELATIONAL_OP(2, gt) + DOCTEST_BINARY_RELATIONAL_OP(3, lt) + DOCTEST_BINARY_RELATIONAL_OP(4, ge) + DOCTEST_BINARY_RELATIONAL_OP(5, le) + + struct DOCTEST_INTERFACE ResultBuilder : public AssertData + { + ResultBuilder(assertType::Enum at, const char* file, int line, const char* expr, + const char* exception_type = ""); + + DOCTEST_DECLARE_DEFAULTS(ResultBuilder); + DOCTEST_DELETE_COPIES(ResultBuilder); + + void setResult(const Result& res); + + template + DOCTEST_NOINLINE void binary_assert(const DOCTEST_REF_WRAP(L) lhs, + const DOCTEST_REF_WRAP(R) rhs) { + m_failed = !RelationalComparator()(lhs, rhs); + if(m_failed || getContextOptions()->success) + m_decomp = stringifyBinaryExpr(lhs, ", ", rhs); + } + + template + DOCTEST_NOINLINE void unary_assert(const DOCTEST_REF_WRAP(L) val) { + m_failed = !val; + + if(m_at & assertType::is_false) //!OCLINT bitwise operator in conditional + m_failed = !m_failed; + + if(m_failed || getContextOptions()->success) + m_decomp = toString(val); + } + + void translateException(); + + bool log(); + void react() const; + }; + + namespace assertAction { + enum Enum + { + nothing = 0, + dbgbreak = 1, + shouldthrow = 2 + }; + } // namespace assertAction + + DOCTEST_INTERFACE void failed_out_of_a_testing_context(const AssertData& ad); + + DOCTEST_INTERFACE void decomp_assert(assertType::Enum at, const char* file, int line, + const char* expr, Result result); + +#define DOCTEST_ASSERT_OUT_OF_TESTS(decomp) \ + do { \ + if(!is_running_in_test) { \ + if(failed) { \ + ResultBuilder rb(at, file, line, expr); \ + rb.m_failed = failed; \ + rb.m_decomp = decomp; \ + failed_out_of_a_testing_context(rb); \ + if(isDebuggerActive() && !getContextOptions()->no_breaks) \ + DOCTEST_BREAK_INTO_DEBUGGER(); \ + if(checkIfShouldThrow(at)) \ + throwException(); \ + } \ + return; \ + } \ + } while(false) + +#define DOCTEST_ASSERT_IN_TESTS(decomp) \ + ResultBuilder rb(at, file, line, expr); \ + rb.m_failed = failed; \ + if(rb.m_failed || getContextOptions()->success) \ + rb.m_decomp = decomp; \ + if(rb.log()) \ + DOCTEST_BREAK_INTO_DEBUGGER(); \ + if(rb.m_failed && checkIfShouldThrow(at)) \ + throwException() + + template + DOCTEST_NOINLINE void binary_assert(assertType::Enum at, const char* file, int line, + const char* expr, const DOCTEST_REF_WRAP(L) lhs, + const DOCTEST_REF_WRAP(R) rhs) { + bool failed = !RelationalComparator()(lhs, rhs); + + // ################################################################################### + // IF THE DEBUGGER BREAKS HERE - GO 1 LEVEL UP IN THE CALLSTACK FOR THE FAILING ASSERT + // THIS IS THE EFFECT OF HAVING 'DOCTEST_CONFIG_SUPER_FAST_ASSERTS' DEFINED + // ################################################################################### + DOCTEST_ASSERT_OUT_OF_TESTS(stringifyBinaryExpr(lhs, ", ", rhs)); + DOCTEST_ASSERT_IN_TESTS(stringifyBinaryExpr(lhs, ", ", rhs)); + } + + template + DOCTEST_NOINLINE void unary_assert(assertType::Enum at, const char* file, int line, + const char* expr, const DOCTEST_REF_WRAP(L) val) { + bool failed = !val; + + if(at & assertType::is_false) //!OCLINT bitwise operator in conditional + failed = !failed; + + // ################################################################################### + // IF THE DEBUGGER BREAKS HERE - GO 1 LEVEL UP IN THE CALLSTACK FOR THE FAILING ASSERT + // THIS IS THE EFFECT OF HAVING 'DOCTEST_CONFIG_SUPER_FAST_ASSERTS' DEFINED + // ################################################################################### + DOCTEST_ASSERT_OUT_OF_TESTS(toString(val)); + DOCTEST_ASSERT_IN_TESTS(toString(val)); + } + + struct DOCTEST_INTERFACE IExceptionTranslator + { + DOCTEST_DELETE_COPIES(IExceptionTranslator); + + IExceptionTranslator(); + virtual ~IExceptionTranslator(); + virtual bool translate(String&) const = 0; + }; + + template + class ExceptionTranslator : public IExceptionTranslator //!OCLINT destructor of virtual class + { + public: + explicit ExceptionTranslator(String (*translateFunction)(T)) + : m_translateFunction(translateFunction) {} + + bool translate(String& res) const { +#ifndef DOCTEST_CONFIG_NO_EXCEPTIONS + try { + throw; + // cppcheck-suppress catchExceptionByValue + } catch(T ex) { // NOLINT + res = m_translateFunction(ex); //!OCLINT parameter reassignment + return true; + } catch(...) {} //!OCLINT - empty catch statement +#endif // DOCTEST_CONFIG_NO_EXCEPTIONS + ((void)res); // to silence -Wunused-parameter + return false; + } + + private: + String (*m_translateFunction)(T); + }; + + DOCTEST_INTERFACE void registerExceptionTranslatorImpl(const IExceptionTranslator* et); + + // FIX FOR VISUAL STUDIO VERSIONS PRIOR TO 2015 - they failed to compile the call to operator<< with + // std::ostream passed as a reference noting that there is a use of an undefined type (which there isn't) + DOCTEST_INTERFACE void writeStringToStream(std::ostream* s, const String& str); + + template + struct StringStreamBase + { + template + static void convert(std::ostream* s, const T& in) { + writeStringToStream(s, toString(in)); + } + + // always treat char* as a string in this context - no matter + // if DOCTEST_CONFIG_TREAT_CHAR_STAR_AS_STRING is defined + static void convert(std::ostream* s, const char* in) { writeStringToStream(s, String(in)); } + }; + + template <> + struct StringStreamBase + { + template + static void convert(std::ostream* s, const T& in) { + *s << in; + } + }; + + template + struct StringStream : public StringStreamBase::value> + {}; + + template + void toStream(std::ostream* s, const T& value) { + StringStream::convert(s, value); + } + +#ifdef DOCTEST_CONFIG_TREAT_CHAR_STAR_AS_STRING + DOCTEST_INTERFACE void toStream(std::ostream* s, char* in); + DOCTEST_INTERFACE void toStream(std::ostream* s, const char* in); +#endif // DOCTEST_CONFIG_TREAT_CHAR_STAR_AS_STRING + DOCTEST_INTERFACE void toStream(std::ostream* s, bool in); + DOCTEST_INTERFACE void toStream(std::ostream* s, float in); + DOCTEST_INTERFACE void toStream(std::ostream* s, double in); + DOCTEST_INTERFACE void toStream(std::ostream* s, double long in); + + DOCTEST_INTERFACE void toStream(std::ostream* s, char in); + DOCTEST_INTERFACE void toStream(std::ostream* s, char signed in); + DOCTEST_INTERFACE void toStream(std::ostream* s, char unsigned in); + DOCTEST_INTERFACE void toStream(std::ostream* s, int short in); + DOCTEST_INTERFACE void toStream(std::ostream* s, int short unsigned in); + DOCTEST_INTERFACE void toStream(std::ostream* s, int in); + DOCTEST_INTERFACE void toStream(std::ostream* s, int unsigned in); + DOCTEST_INTERFACE void toStream(std::ostream* s, int long in); + DOCTEST_INTERFACE void toStream(std::ostream* s, int long unsigned in); + DOCTEST_INTERFACE void toStream(std::ostream* s, int long long in); + DOCTEST_INTERFACE void toStream(std::ostream* s, int long long unsigned in); + + class DOCTEST_INTERFACE ContextBuilder + { + friend class ContextScope; + + struct DOCTEST_INTERFACE ICapture + { + DOCTEST_DELETE_COPIES(ICapture); + ICapture(); + virtual ~ICapture(); + virtual void toStream(std::ostream*) const = 0; + }; + + template + struct Capture : public ICapture //!OCLINT destructor of virtual class + { + const T* capture; + + explicit Capture(const T* in) + : capture(in) {} + void toStream(std::ostream* s) const override { detail::toStream(s, *capture); } + }; + + struct DOCTEST_INTERFACE Chunk + { + char buf[sizeof(Capture)] DOCTEST_ALIGNMENT( + 2 * sizeof(void*)); // place to construct a Capture + + DOCTEST_DECLARE_DEFAULTS(Chunk); + DOCTEST_DELETE_COPIES(Chunk); + }; + + struct DOCTEST_INTERFACE Node + { + Chunk chunk; + Node* next; + + DOCTEST_DECLARE_DEFAULTS(Node); + DOCTEST_DELETE_COPIES(Node); + }; + + Chunk stackChunks[DOCTEST_CONFIG_NUM_CAPTURES_ON_STACK]; + int numCaptures = 0; + Node* head = nullptr; + Node* tail = nullptr; + + ContextBuilder(ContextBuilder& other); + + ContextBuilder& operator=(const ContextBuilder&) = delete; + + void stringify(std::ostream* s) const; + + public: + ContextBuilder(); + ~ContextBuilder(); + + template + DOCTEST_NOINLINE ContextBuilder& operator<<(T& in) { + Capture temp(&in); + + // construct either on stack or on heap + // copy the bytes for the whole object - including the vtable because we cant construct + // the object directly in the buffer using placement new - need the header... + if(numCaptures < DOCTEST_CONFIG_NUM_CAPTURES_ON_STACK) { + my_memcpy(stackChunks[numCaptures].buf, &temp, sizeof(Chunk)); + } else { + auto curr = new Node; + curr->next = nullptr; + if(tail) { + tail->next = curr; + tail = curr; + } else { + head = tail = curr; + } + + my_memcpy(tail->chunk.buf, &temp, sizeof(Chunk)); + } + ++numCaptures; + return *this; + } + + template + ContextBuilder& operator<<(const T&&) { + static_assert(deferred_false::value, + "Cannot pass temporaries or rvalues to the streaming operator because it " + "caches pointers to the passed objects for lazy evaluation!"); + return *this; + } + }; + + class DOCTEST_INTERFACE ContextScope : public IContextScope + { + ContextBuilder contextBuilder; + + public: + explicit ContextScope(ContextBuilder& temp); + + DOCTEST_DELETE_COPIES(ContextScope); + + ~ContextScope(); + + void stringify(std::ostream* s) const; + }; + + struct DOCTEST_INTERFACE MessageBuilder : public MessageData + { + std::ostream* m_stream; + + MessageBuilder(const char* file, int line, assertType::Enum severity); + MessageBuilder() = delete; + ~MessageBuilder(); + + DOCTEST_DELETE_COPIES(MessageBuilder); + + template + MessageBuilder& operator<<(const T& in) { + toStream(m_stream, in); + return *this; + } + + bool log(); + void react(); + }; +} // namespace detail + +#define DOCTEST_DEFINE_DECORATOR(name, type, def) \ + struct name \ + { \ + type data; \ + name(type in = def) \ + : data(in) {} \ + void fill(detail::TestCase& state) const { state.DOCTEST_CAT(m_, name) = data; } \ + void fill(detail::TestSuite& state) const { state.DOCTEST_CAT(m_, name) = data; } \ + } + +DOCTEST_DEFINE_DECORATOR(test_suite, const char*, ""); +DOCTEST_DEFINE_DECORATOR(description, const char*, ""); +DOCTEST_DEFINE_DECORATOR(skip, bool, true); +DOCTEST_DEFINE_DECORATOR(timeout, double, 0); +DOCTEST_DEFINE_DECORATOR(may_fail, bool, true); +DOCTEST_DEFINE_DECORATOR(should_fail, bool, true); +DOCTEST_DEFINE_DECORATOR(expected_failures, int, 0); + +template +int registerExceptionTranslator(String (*translateFunction)(T)) { + DOCTEST_CLANG_SUPPRESS_WARNING_WITH_PUSH("-Wexit-time-destructors") + static detail::ExceptionTranslator exceptionTranslator(translateFunction); + DOCTEST_CLANG_SUPPRESS_WARNING_POP + detail::registerExceptionTranslatorImpl(&exceptionTranslator); + return 0; +} + +} // namespace doctest + +// in a separate namespace outside of doctest because the DOCTEST_TEST_SUITE macro +// introduces an anonymous namespace in which getCurrentTestSuite gets overridden +namespace doctest_detail_test_suite_ns { +DOCTEST_INTERFACE doctest::detail::TestSuite& getCurrentTestSuite(); +} // namespace doctest_detail_test_suite_ns + +namespace doctest { +#else // DOCTEST_CONFIG_DISABLE +template +int registerExceptionTranslator(String (*)(T)) { + return 0; +} +#endif // DOCTEST_CONFIG_DISABLE + +namespace detail { + typedef void (*assert_handler)(const AssertData&); + struct ContextState; +} // namespace detail + +class DOCTEST_INTERFACE Context +{ + detail::ContextState* p; + + void parseArgs(int argc, const char* const* argv, bool withDefaults = false); + +public: + explicit Context(int argc = 0, const char* const* argv = nullptr); + + DOCTEST_DELETE_COPIES(Context); + + ~Context(); + + void applyCommandLine(int argc, const char* const* argv); + + void addFilter(const char* filter, const char* value); + void clearFilters(); + void setOption(const char* option, int value); + void setOption(const char* option, const char* value); + + bool shouldExit(); + + void setAsDefaultForAssertsOutOfTestCases(); + + void setAssertHandler(detail::assert_handler ah); + + int run(); +}; + +namespace TestCaseFailureReason { + enum Enum + { + None = 0, + AssertFailure = 1, // an assertion has failed in the test case + Exception = 2, // test case threw an exception + Crash = 4, // a crash... + TooManyFailedAsserts = 8, // the abort-after option + Timeout = 16, // see the timeout decorator + ShouldHaveFailedButDidnt = 32, // see the should_fail decorator + ShouldHaveFailedAndDid = 64, // see the should_fail decorator + DidntFailExactlyNumTimes = 128, // see the expected_failures decorator + FailedExactlyNumTimes = 256, // see the expected_failures decorator + CouldHaveFailedAndDid = 512 // see the may_fail decorator + }; +} // namespace TestCaseFailureReason + +struct DOCTEST_INTERFACE CurrentTestCaseStats +{ + int numAssertsForCurrentTestCase; + int numAssertsFailedForCurrentTestCase; + double seconds_so_far; + int failure_flags; // use TestCaseFailureReason::Enum + String error_string; + bool should_reenter; // means we are not done with the test case because of subcases + + DOCTEST_DECLARE_DEFAULTS(CurrentTestCaseStats); + DOCTEST_DELETE_COPIES(CurrentTestCaseStats); +}; + +struct DOCTEST_INTERFACE TestRunStats +{ + unsigned numTestCases; + unsigned numTestCasesPassingFilters; + unsigned numTestSuitesPassingFilters; + unsigned numTestCasesFailed; + int numAsserts; + int numAssertsFailed; + + DOCTEST_DECLARE_DEFAULTS(TestRunStats); + DOCTEST_DELETE_COPIES(TestRunStats); +}; + +struct DOCTEST_INTERFACE IReporter +{ + // called when the whole test run starts (safe to cache a pointer to the input) + virtual void test_run_start(const ContextOptions&) = 0; + // called when the whole test run ends (caching a pointer to the input doesn't make sense here) + virtual void test_run_end(const TestRunStats&) = 0; + + // called when a test case is started (safe to cache a pointer to the input) + virtual void test_case_start(const TestCaseData&) = 0; + // called when a test case has ended - could be re-entered if more subcases have to be + // traversed - check CurrentTestCaseStats::should_reenter (caching a pointer to the input doesn't make sense here) + virtual void test_case_end(const CurrentTestCaseStats&) = 0; + + // called whenever a subcase is entered (don't cache pointers to the input) + virtual void subcase_start(const SubcaseSignature&) = 0; + // called whenever a subcase is exited (don't cache pointers to the input) + virtual void subcase_end(const SubcaseSignature&) = 0; + + // called for each assert (don't cache pointers to the input) + virtual void log_assert(const AssertData&) = 0; + // called for each message (don't cache pointers to the input) + virtual void log_message(const MessageData&) = 0; + + // called when a test case is skipped either because it doesn't pass the filters, has a skip decorator + // or isn't in the execution range (between first and last) (safe to cache a pointer to the input) + virtual void test_case_skipped(const TestCaseData&) = 0; + + // doctest will not be managing the lifetimes of reporters given to it but this would still be nice to have + virtual ~IReporter(); + + // can obtain all currently active contexts and stringify them if one wishes to do so + static int get_num_active_contexts(); + static const IContextScope* const* get_active_contexts(); + + // can iterate through contexts which have been stringified automatically in their destructors when an exception has been thrown + static int get_num_stringified_contexts(); + static const String* get_stringified_contexts(); +}; + +int registerReporter(const char* name, int priority, IReporter& r); + +} // namespace doctest + +// if registering is not disabled +#if !defined(DOCTEST_CONFIG_DISABLE) + +// common code in asserts - for convenience +#define DOCTEST_ASSERT_LOG_AND_REACT(b) \ + if(b.log()) \ + DOCTEST_BREAK_INTO_DEBUGGER(); \ + b.react() + +#ifdef DOCTEST_CONFIG_NO_TRY_CATCH_IN_ASSERTS +#define DOCTEST_WRAP_IN_TRY(x) x; +#else // DOCTEST_CONFIG_NO_TRY_CATCH_IN_ASSERTS +#define DOCTEST_WRAP_IN_TRY(x) \ + try { \ + x; \ + } catch(...) { _DOCTEST_RB.translateException(); } +#endif // DOCTEST_CONFIG_NO_TRY_CATCH_IN_ASSERTS + +// registers the test by initializing a dummy var with a function +#define DOCTEST_REGISTER_FUNCTION(f, decorators) \ + DOCTEST_GLOBAL_NO_WARNINGS(DOCTEST_ANONYMOUS(_DOCTEST_ANON_VAR_)) = doctest::detail::regTest( \ + doctest::detail::TestCase(f, __FILE__, __LINE__, \ + doctest_detail_test_suite_ns::getCurrentTestSuite()) * \ + decorators); \ + DOCTEST_GLOBAL_NO_WARNINGS_END() + +#define DOCTEST_IMPLEMENT_FIXTURE(der, base, func, decorators) \ + namespace { \ + struct der : public base \ + { \ + void f(); \ + }; \ + static void func() { \ + der v; \ + v.f(); \ + } \ + DOCTEST_REGISTER_FUNCTION(func, decorators) \ + } \ + inline DOCTEST_NOINLINE void der::f() + +#define DOCTEST_CREATE_AND_REGISTER_FUNCTION(f, decorators) \ + static void f(); \ + DOCTEST_REGISTER_FUNCTION(f, decorators) \ + static void f() + +// for registering tests +#define DOCTEST_TEST_CASE(decorators) \ + DOCTEST_CREATE_AND_REGISTER_FUNCTION(DOCTEST_ANONYMOUS(_DOCTEST_ANON_FUNC_), decorators) + +// for registering tests with a fixture +#define DOCTEST_TEST_CASE_FIXTURE(c, decorators) \ + DOCTEST_IMPLEMENT_FIXTURE(DOCTEST_ANONYMOUS(_DOCTEST_ANON_CLASS_), c, \ + DOCTEST_ANONYMOUS(_DOCTEST_ANON_FUNC_), decorators) + +// for converting types to strings without the header and demangling +#define DOCTEST_TYPE_TO_STRING_IMPL(...) \ + template <> \ + inline const char* type_to_string<__VA_ARGS__>() { \ + return "<" #__VA_ARGS__ ">"; \ + } +#define DOCTEST_TYPE_TO_STRING(...) \ + namespace doctest { namespace detail { \ + DOCTEST_TYPE_TO_STRING_IMPL(__VA_ARGS__) \ + } \ + } \ + typedef int DOCTEST_ANONYMOUS(_DOCTEST_ANON_FOR_SEMICOLON_) + +// for typed tests +#define DOCTEST_REGISTER_TYPED_TEST_CASE_IMPL(func, type, decorators, idx) \ + doctest::detail::regTest( \ + doctest::detail::TestCase(func, __FILE__, __LINE__, \ + doctest_detail_test_suite_ns::getCurrentTestSuite(), \ + doctest::detail::type_to_string(), idx) * \ + decorators) + +#define DOCTEST_TEST_CASE_TEMPLATE_DEFINE_IMPL(dec, T, id, anon) \ + template \ + inline void anon(); \ + template \ + struct DOCTEST_CAT(id, ITERATOR) \ + { \ + DOCTEST_CAT(id, ITERATOR)(int line, int index) { \ + DOCTEST_REGISTER_TYPED_TEST_CASE_IMPL(anon, Type, dec, line * 1000 + index); \ + DOCTEST_CAT(id, ITERATOR)(line, index + 1); \ + } \ + }; \ + template \ + struct DOCTEST_CAT(id, ITERATOR) \ + { \ + DOCTEST_CAT(id, ITERATOR)(int line, int index) { \ + DOCTEST_REGISTER_TYPED_TEST_CASE_IMPL(anon, Type, dec, line * 1000 + index); \ + } \ + } + +#define DOCTEST_TEST_CASE_TEMPLATE_DEFINE_IMPL_PROXY(dec, T, id, anon) \ + DOCTEST_TEST_CASE_TEMPLATE_DEFINE_IMPL(dec, T, id, anon); \ + template \ + inline void anon() + +#define DOCTEST_TEST_CASE_TEMPLATE_DEFINE(dec, T, id) \ + DOCTEST_TEST_CASE_TEMPLATE_DEFINE_IMPL_PROXY(dec, T, id, DOCTEST_ANONYMOUS(_DOCTEST_ANON_TMP_)) + +#define DOCTEST_TEST_CASE_TEMPLATE_INSTANTIATE_IMPL(id, anon, ...) \ + DOCTEST_GLOBAL_NO_WARNINGS(DOCTEST_CAT(anon, DUMMY)) = []() { \ + DOCTEST_CAT(id, ITERATOR)<__VA_ARGS__> DOCTEST_UNUSED DOCTEST_CAT(anon, inner_dummy)( \ + __LINE__, 0); \ + return 0; \ + }(); \ + DOCTEST_GLOBAL_NO_WARNINGS_END() + +#define DOCTEST_TEST_CASE_TEMPLATE_INSTANTIATE(id, ...) \ + DOCTEST_TEST_CASE_TEMPLATE_INSTANTIATE_IMPL(id, DOCTEST_ANONYMOUS(_DOCTEST_ANON_TMP_), \ + __VA_ARGS__) \ + typedef int DOCTEST_ANONYMOUS(_DOCTEST_ANON_FOR_SEMICOLON_) + +#define DOCTEST_TEST_CASE_TEMPLATE_IMPL(dec, T, anon, ...) \ + DOCTEST_TEST_CASE_TEMPLATE_DEFINE_IMPL_PROXY(dec, T, anon, anon); \ + DOCTEST_TEST_CASE_TEMPLATE_INSTANTIATE_IMPL(anon, anon, __VA_ARGS__) \ + template \ + inline void anon() + +#define DOCTEST_TEST_CASE_TEMPLATE(dec, T, ...) \ + DOCTEST_TEST_CASE_TEMPLATE_IMPL(dec, T, DOCTEST_ANONYMOUS(_DOCTEST_ANON_TMP_), __VA_ARGS__) + +// for subcases +#define DOCTEST_SUBCASE(name) \ + if(const doctest::detail::Subcase & DOCTEST_ANONYMOUS(_DOCTEST_ANON_SUBCASE_) DOCTEST_UNUSED = \ + doctest::detail::Subcase(name, __FILE__, __LINE__)) + +// for grouping tests in test suites by using code blocks +#define DOCTEST_TEST_SUITE_IMPL(decorators, ns_name) \ + namespace ns_name { namespace doctest_detail_test_suite_ns { \ + static DOCTEST_NOINLINE doctest::detail::TestSuite& getCurrentTestSuite() { \ + DOCTEST_MSVC_SUPPRESS_WARNING_WITH_PUSH(4640) \ + DOCTEST_CLANG_SUPPRESS_WARNING_WITH_PUSH("-Wexit-time-destructors") \ + static doctest::detail::TestSuite data; \ + static bool inited = false; \ + DOCTEST_MSVC_SUPPRESS_WARNING_POP \ + DOCTEST_CLANG_SUPPRESS_WARNING_POP \ + if(!inited) { \ + data* decorators; \ + inited = true; \ + } \ + return data; \ + } \ + } \ + } \ + namespace ns_name + +#define DOCTEST_TEST_SUITE(decorators) \ + DOCTEST_TEST_SUITE_IMPL(decorators, DOCTEST_ANONYMOUS(_DOCTEST_ANON_SUITE_)) + +// for starting a testsuite block +#define DOCTEST_TEST_SUITE_BEGIN(decorators) \ + DOCTEST_GLOBAL_NO_WARNINGS(DOCTEST_ANONYMOUS(_DOCTEST_ANON_VAR_)) = \ + doctest::detail::setTestSuite(doctest::detail::TestSuite() * decorators); \ + DOCTEST_GLOBAL_NO_WARNINGS_END() \ + typedef int DOCTEST_ANONYMOUS(_DOCTEST_ANON_FOR_SEMICOLON_) + +// for ending a testsuite block +#define DOCTEST_TEST_SUITE_END \ + DOCTEST_GLOBAL_NO_WARNINGS(DOCTEST_ANONYMOUS(_DOCTEST_ANON_VAR_)) = \ + doctest::detail::setTestSuite(doctest::detail::TestSuite() * ""); \ + DOCTEST_GLOBAL_NO_WARNINGS_END() \ + typedef int DOCTEST_ANONYMOUS(_DOCTEST_ANON_FOR_SEMICOLON_) + +// for registering exception translators +#define DOCTEST_REGISTER_EXCEPTION_TRANSLATOR_IMPL(translatorName, signature) \ + inline doctest::String translatorName(signature); \ + DOCTEST_GLOBAL_NO_WARNINGS(DOCTEST_ANONYMOUS(_DOCTEST_ANON_TRANSLATOR_)) = \ + doctest::registerExceptionTranslator(translatorName); \ + DOCTEST_GLOBAL_NO_WARNINGS_END() \ + doctest::String translatorName(signature) + +#define DOCTEST_REGISTER_EXCEPTION_TRANSLATOR(signature) \ + DOCTEST_REGISTER_EXCEPTION_TRANSLATOR_IMPL(DOCTEST_ANONYMOUS(_DOCTEST_ANON_TRANSLATOR_), \ + signature) + +// for registering +#define DOCTEST_REGISTER_REPORTER(name, priority, reporter) \ + DOCTEST_GLOBAL_NO_WARNINGS(DOCTEST_ANONYMOUS(_DOCTEST_ANON_REPORTER_)) = \ + doctest::registerReporter(name, priority, reporter); \ + DOCTEST_GLOBAL_NO_WARNINGS_END() typedef int DOCTEST_ANONYMOUS(_DOCTEST_ANON_FOR_SEMICOLON_) + +// for logging +#define DOCTEST_INFO(x) \ + doctest::detail::ContextScope DOCTEST_ANONYMOUS(_DOCTEST_CAPTURE_)( \ + doctest::detail::ContextBuilder() << x) +#define DOCTEST_CAPTURE(x) DOCTEST_INFO(#x " := " << x) + +#define DOCTEST_ADD_AT_IMPL(type, file, line, mb, x) \ + do { \ + doctest::detail::MessageBuilder mb(file, line, doctest::assertType::type); \ + mb << x; \ + DOCTEST_ASSERT_LOG_AND_REACT(mb); \ + } while((void)0, 0) + +// clang-format off +#define DOCTEST_ADD_MESSAGE_AT(file, line, x) DOCTEST_ADD_AT_IMPL(is_warn, file, line, DOCTEST_ANONYMOUS(_DOCTEST_MESSAGE_), x) +#define DOCTEST_ADD_FAIL_CHECK_AT(file, line, x) DOCTEST_ADD_AT_IMPL(is_check, file, line, DOCTEST_ANONYMOUS(_DOCTEST_MESSAGE_), x) +#define DOCTEST_ADD_FAIL_AT(file, line, x) DOCTEST_ADD_AT_IMPL(is_require, file, line, DOCTEST_ANONYMOUS(_DOCTEST_MESSAGE_), x) +// clang-format on + +#define DOCTEST_MESSAGE(x) DOCTEST_ADD_MESSAGE_AT(__FILE__, __LINE__, x) +#define DOCTEST_FAIL_CHECK(x) DOCTEST_ADD_FAIL_CHECK_AT(__FILE__, __LINE__, x) +#define DOCTEST_FAIL(x) DOCTEST_ADD_FAIL_AT(__FILE__, __LINE__, x) + +// hack for macros like INFO() that require lvalues +#if __cplusplus >= 201402L || (DOCTEST_MSVC >= DOCTEST_COMPILER(19, 10, 0)) +template +constexpr T to_lvalue = x; +#define DOCTEST_TO_LVALUE(...) to_lvalue +#else // TO_LVALUE +#define DOCTEST_TO_LVALUE(...) TO_LVALUE_CAN_BE_USED_ONLY_IN_CPP14_MODE_OR_WITH_VS_2017_OR_NEWER +#endif // TO_LVALUE + +#ifndef DOCTEST_CONFIG_SUPER_FAST_ASSERTS + +#define DOCTEST_ASSERT_IMPLEMENT_2(assert_type, ...) \ + DOCTEST_CLANG_SUPPRESS_WARNING_WITH_PUSH("-Woverloaded-shift-op-parentheses") \ + doctest::detail::ResultBuilder _DOCTEST_RB(doctest::assertType::assert_type, __FILE__, \ + __LINE__, #__VA_ARGS__); \ + DOCTEST_WRAP_IN_TRY(_DOCTEST_RB.setResult( \ + doctest::detail::ExpressionDecomposer(doctest::assertType::assert_type) \ + << __VA_ARGS__)) \ + DOCTEST_ASSERT_LOG_AND_REACT(_DOCTEST_RB) \ + DOCTEST_CLANG_SUPPRESS_WARNING_POP + +#define DOCTEST_ASSERT_IMPLEMENT_1(assert_type, ...) \ + do { \ + DOCTEST_ASSERT_IMPLEMENT_2(assert_type, __VA_ARGS__); \ + } while((void)0, 0) + +#else // DOCTEST_CONFIG_SUPER_FAST_ASSERTS + +#define DOCTEST_ASSERT_IMPLEMENT_1(assert_type, ...) \ + DOCTEST_CLANG_SUPPRESS_WARNING_WITH_PUSH("-Woverloaded-shift-op-parentheses") \ + doctest::detail::decomp_assert( \ + doctest::assertType::assert_type, __FILE__, __LINE__, #__VA_ARGS__, \ + doctest::detail::ExpressionDecomposer(doctest::assertType::assert_type) \ + << __VA_ARGS__) DOCTEST_CLANG_SUPPRESS_WARNING_POP + +#endif // DOCTEST_CONFIG_SUPER_FAST_ASSERTS + +#define DOCTEST_WARN(...) DOCTEST_ASSERT_IMPLEMENT_1(DT_WARN, __VA_ARGS__) +#define DOCTEST_CHECK(...) DOCTEST_ASSERT_IMPLEMENT_1(DT_CHECK, __VA_ARGS__) +#define DOCTEST_REQUIRE(...) DOCTEST_ASSERT_IMPLEMENT_1(DT_REQUIRE, __VA_ARGS__) +#define DOCTEST_WARN_FALSE(...) DOCTEST_ASSERT_IMPLEMENT_1(DT_WARN_FALSE, __VA_ARGS__) +#define DOCTEST_CHECK_FALSE(...) DOCTEST_ASSERT_IMPLEMENT_1(DT_CHECK_FALSE, __VA_ARGS__) +#define DOCTEST_REQUIRE_FALSE(...) DOCTEST_ASSERT_IMPLEMENT_1(DT_REQUIRE_FALSE, __VA_ARGS__) + +// clang-format off +#define DOCTEST_WARN_MESSAGE(cond, msg) do { DOCTEST_INFO(msg); DOCTEST_ASSERT_IMPLEMENT_2(DT_WARN, cond); } while((void)0, 0) +#define DOCTEST_CHECK_MESSAGE(cond, msg) do { DOCTEST_INFO(msg); DOCTEST_ASSERT_IMPLEMENT_2(DT_CHECK, cond); } while((void)0, 0) +#define DOCTEST_REQUIRE_MESSAGE(cond, msg) do { DOCTEST_INFO(msg); DOCTEST_ASSERT_IMPLEMENT_2(DT_REQUIRE, cond); } while((void)0, 0) +#define DOCTEST_WARN_FALSE_MESSAGE(cond, msg) do { DOCTEST_INFO(msg); DOCTEST_ASSERT_IMPLEMENT_2(DT_WARN_FALSE, cond); } while((void)0, 0) +#define DOCTEST_CHECK_FALSE_MESSAGE(cond, msg) do { DOCTEST_INFO(msg); DOCTEST_ASSERT_IMPLEMENT_2(DT_CHECK_FALSE, cond); } while((void)0, 0) +#define DOCTEST_REQUIRE_FALSE_MESSAGE(cond, msg) do { DOCTEST_INFO(msg); DOCTEST_ASSERT_IMPLEMENT_2(DT_REQUIRE_FALSE, cond); } while((void)0, 0) +// clang-format on + +#define DOCTEST_ASSERT_THROWS(expr, assert_type) \ + do { \ + if(!doctest::getContextOptions()->no_throw) { \ + doctest::detail::ResultBuilder _DOCTEST_RB(doctest::assertType::assert_type, __FILE__, \ + __LINE__, #expr); \ + try { \ + expr; \ + } catch(...) { _DOCTEST_RB.m_threw = true; } \ + DOCTEST_ASSERT_LOG_AND_REACT(_DOCTEST_RB); \ + } \ + } while((void)0, 0) + +#define DOCTEST_ASSERT_THROWS_AS(expr, assert_type, ...) \ + do { \ + if(!doctest::getContextOptions()->no_throw) { \ + doctest::detail::ResultBuilder _DOCTEST_RB(doctest::assertType::assert_type, __FILE__, \ + __LINE__, #expr, #__VA_ARGS__); \ + try { \ + expr; \ + } catch(const doctest::detail::remove_const< \ + doctest::detail::remove_reference<__VA_ARGS__>::type>::type&) { \ + _DOCTEST_RB.m_threw = true; \ + _DOCTEST_RB.m_threw_as = true; \ + } catch(...) { _DOCTEST_RB.translateException(); } \ + DOCTEST_ASSERT_LOG_AND_REACT(_DOCTEST_RB); \ + } \ + } while((void)0, 0) + +#define DOCTEST_ASSERT_THROWS_WITH(expr, assert_type, ...) \ + do { \ + if(!doctest::getContextOptions()->no_throw) { \ + doctest::detail::ResultBuilder _DOCTEST_RB(doctest::assertType::assert_type, __FILE__, \ + __LINE__, #expr, __VA_ARGS__); \ + try { \ + expr; \ + } catch(...) { _DOCTEST_RB.translateException(); } \ + DOCTEST_ASSERT_LOG_AND_REACT(_DOCTEST_RB); \ + } \ + } while((void)0, 0) + +#define DOCTEST_ASSERT_NOTHROW(expr, assert_type) \ + do { \ + doctest::detail::ResultBuilder _DOCTEST_RB(doctest::assertType::assert_type, __FILE__, \ + __LINE__, #expr); \ + try { \ + expr; \ + } catch(...) { _DOCTEST_RB.translateException(); } \ + DOCTEST_ASSERT_LOG_AND_REACT(_DOCTEST_RB); \ + } while((void)0, 0) + +// clang-format off +#define DOCTEST_WARN_THROWS(expr) DOCTEST_ASSERT_THROWS(expr, DT_WARN_THROWS) +#define DOCTEST_CHECK_THROWS(expr) DOCTEST_ASSERT_THROWS(expr, DT_CHECK_THROWS) +#define DOCTEST_REQUIRE_THROWS(expr) DOCTEST_ASSERT_THROWS(expr, DT_REQUIRE_THROWS) + +#define DOCTEST_WARN_THROWS_AS(expr, ...) DOCTEST_ASSERT_THROWS_AS(expr, DT_WARN_THROWS_AS, __VA_ARGS__) +#define DOCTEST_CHECK_THROWS_AS(expr, ...) DOCTEST_ASSERT_THROWS_AS(expr, DT_CHECK_THROWS_AS, __VA_ARGS__) +#define DOCTEST_REQUIRE_THROWS_AS(expr, ...) DOCTEST_ASSERT_THROWS_AS(expr, DT_REQUIRE_THROWS_AS, __VA_ARGS__) + +#define DOCTEST_WARN_THROWS_WITH(expr, ...) DOCTEST_ASSERT_THROWS_WITH(expr, DT_WARN_THROWS_WITH, __VA_ARGS__) +#define DOCTEST_CHECK_THROWS_WITH(expr, ...) DOCTEST_ASSERT_THROWS_WITH(expr, DT_CHECK_THROWS_WITH, __VA_ARGS__) +#define DOCTEST_REQUIRE_THROWS_WITH(expr, ...) DOCTEST_ASSERT_THROWS_WITH(expr, DT_REQUIRE_THROWS_WITH, __VA_ARGS__) + +#define DOCTEST_WARN_NOTHROW(expr) DOCTEST_ASSERT_NOTHROW(expr, DT_WARN_NOTHROW) +#define DOCTEST_CHECK_NOTHROW(expr) DOCTEST_ASSERT_NOTHROW(expr, DT_CHECK_NOTHROW) +#define DOCTEST_REQUIRE_NOTHROW(expr) DOCTEST_ASSERT_NOTHROW(expr, DT_REQUIRE_NOTHROW) + +#define DOCTEST_WARN_THROWS_MESSAGE(expr, msg) do { DOCTEST_INFO(msg); DOCTEST_WARN_THROWS(expr); } while((void)0, 0) +#define DOCTEST_CHECK_THROWS_MESSAGE(expr, msg) do { DOCTEST_INFO(msg); DOCTEST_CHECK_THROWS(expr); } while((void)0, 0) +#define DOCTEST_REQUIRE_THROWS_MESSAGE(expr, msg) do { DOCTEST_INFO(msg); DOCTEST_REQUIRE_THROWS(expr); } while((void)0, 0) +#define DOCTEST_WARN_THROWS_AS_MESSAGE(expr, ex, msg) do { DOCTEST_INFO(msg); DOCTEST_WARN_THROWS_AS(expr, ex); } while((void)0, 0) +#define DOCTEST_CHECK_THROWS_AS_MESSAGE(expr, ex, msg) do { DOCTEST_INFO(msg); DOCTEST_CHECK_THROWS_AS(expr, ex); } while((void)0, 0) +#define DOCTEST_REQUIRE_THROWS_AS_MESSAGE(expr, ex, msg) do { DOCTEST_INFO(msg); DOCTEST_REQUIRE_THROWS_AS(expr, ex); } while((void)0, 0) +#define DOCTEST_WARN_THROWS_WITH_MESSAGE(expr, ex, msg) do { DOCTEST_INFO(msg); DOCTEST_WARN_THROWS_WITH(expr, ex); } while((void)0, 0) +#define DOCTEST_CHECK_THROWS_WITH_MESSAGE(expr, ex, msg) do { DOCTEST_INFO(msg); DOCTEST_CHECK_THROWS_WITH(expr, ex); } while((void)0, 0) +#define DOCTEST_REQUIRE_THROWS_WITH_MESSAGE(expr, ex, msg) do { DOCTEST_INFO(msg); DOCTEST_REQUIRE_THROWS_WITH(expr, ex); } while((void)0, 0) +#define DOCTEST_WARN_NOTHROW_MESSAGE(expr, msg) do { DOCTEST_INFO(msg); DOCTEST_WARN_NOTHROW(expr); } while((void)0, 0) +#define DOCTEST_CHECK_NOTHROW_MESSAGE(expr, msg) do { DOCTEST_INFO(msg); DOCTEST_CHECK_NOTHROW(expr); } while((void)0, 0) +#define DOCTEST_REQUIRE_NOTHROW_MESSAGE(expr, msg) do { DOCTEST_INFO(msg); DOCTEST_REQUIRE_NOTHROW(expr); } while((void)0, 0) +// clang-format on + +#ifndef DOCTEST_CONFIG_SUPER_FAST_ASSERTS + +#define DOCTEST_BINARY_ASSERT(assert_type, comp, ...) \ + do { \ + doctest::detail::ResultBuilder _DOCTEST_RB(doctest::assertType::assert_type, __FILE__, \ + __LINE__, #__VA_ARGS__); \ + DOCTEST_WRAP_IN_TRY( \ + _DOCTEST_RB.binary_assert( \ + __VA_ARGS__)) \ + DOCTEST_ASSERT_LOG_AND_REACT(_DOCTEST_RB); \ + } while((void)0, 0) + +#define DOCTEST_UNARY_ASSERT(assert_type, ...) \ + do { \ + doctest::detail::ResultBuilder _DOCTEST_RB(doctest::assertType::assert_type, __FILE__, \ + __LINE__, #__VA_ARGS__); \ + DOCTEST_WRAP_IN_TRY(_DOCTEST_RB.unary_assert(__VA_ARGS__)) \ + DOCTEST_ASSERT_LOG_AND_REACT(_DOCTEST_RB); \ + } while((void)0, 0) + +#else // DOCTEST_CONFIG_SUPER_FAST_ASSERTS + +#define DOCTEST_BINARY_ASSERT(assert_type, comparison, ...) \ + doctest::detail::binary_assert( \ + doctest::assertType::assert_type, __FILE__, __LINE__, #__VA_ARGS__, __VA_ARGS__) + +#define DOCTEST_UNARY_ASSERT(assert_type, ...) \ + doctest::detail::unary_assert(doctest::assertType::assert_type, __FILE__, __LINE__, \ + #__VA_ARGS__, __VA_ARGS__) + +#endif // DOCTEST_CONFIG_SUPER_FAST_ASSERTS + +#define DOCTEST_WARN_EQ(...) DOCTEST_BINARY_ASSERT(DT_WARN_EQ, eq, __VA_ARGS__) +#define DOCTEST_CHECK_EQ(...) DOCTEST_BINARY_ASSERT(DT_CHECK_EQ, eq, __VA_ARGS__) +#define DOCTEST_REQUIRE_EQ(...) DOCTEST_BINARY_ASSERT(DT_REQUIRE_EQ, eq, __VA_ARGS__) +#define DOCTEST_WARN_NE(...) DOCTEST_BINARY_ASSERT(DT_WARN_NE, ne, __VA_ARGS__) +#define DOCTEST_CHECK_NE(...) DOCTEST_BINARY_ASSERT(DT_CHECK_NE, ne, __VA_ARGS__) +#define DOCTEST_REQUIRE_NE(...) DOCTEST_BINARY_ASSERT(DT_REQUIRE_NE, ne, __VA_ARGS__) +#define DOCTEST_WARN_GT(...) DOCTEST_BINARY_ASSERT(DT_WARN_GT, gt, __VA_ARGS__) +#define DOCTEST_CHECK_GT(...) DOCTEST_BINARY_ASSERT(DT_CHECK_GT, gt, __VA_ARGS__) +#define DOCTEST_REQUIRE_GT(...) DOCTEST_BINARY_ASSERT(DT_REQUIRE_GT, gt, __VA_ARGS__) +#define DOCTEST_WARN_LT(...) DOCTEST_BINARY_ASSERT(DT_WARN_LT, lt, __VA_ARGS__) +#define DOCTEST_CHECK_LT(...) DOCTEST_BINARY_ASSERT(DT_CHECK_LT, lt, __VA_ARGS__) +#define DOCTEST_REQUIRE_LT(...) DOCTEST_BINARY_ASSERT(DT_REQUIRE_LT, lt, __VA_ARGS__) +#define DOCTEST_WARN_GE(...) DOCTEST_BINARY_ASSERT(DT_WARN_GE, ge, __VA_ARGS__) +#define DOCTEST_CHECK_GE(...) DOCTEST_BINARY_ASSERT(DT_CHECK_GE, ge, __VA_ARGS__) +#define DOCTEST_REQUIRE_GE(...) DOCTEST_BINARY_ASSERT(DT_REQUIRE_GE, ge, __VA_ARGS__) +#define DOCTEST_WARN_LE(...) DOCTEST_BINARY_ASSERT(DT_WARN_LE, le, __VA_ARGS__) +#define DOCTEST_CHECK_LE(...) DOCTEST_BINARY_ASSERT(DT_CHECK_LE, le, __VA_ARGS__) +#define DOCTEST_REQUIRE_LE(...) DOCTEST_BINARY_ASSERT(DT_REQUIRE_LE, le, __VA_ARGS__) + +#define DOCTEST_WARN_UNARY(...) DOCTEST_UNARY_ASSERT(DT_WARN_UNARY, __VA_ARGS__) +#define DOCTEST_CHECK_UNARY(...) DOCTEST_UNARY_ASSERT(DT_CHECK_UNARY, __VA_ARGS__) +#define DOCTEST_REQUIRE_UNARY(...) DOCTEST_UNARY_ASSERT(DT_REQUIRE_UNARY, __VA_ARGS__) +#define DOCTEST_WARN_UNARY_FALSE(...) DOCTEST_UNARY_ASSERT(DT_WARN_UNARY_FALSE, __VA_ARGS__) +#define DOCTEST_CHECK_UNARY_FALSE(...) DOCTEST_UNARY_ASSERT(DT_CHECK_UNARY_FALSE, __VA_ARGS__) +#define DOCTEST_REQUIRE_UNARY_FALSE(...) DOCTEST_UNARY_ASSERT(DT_REQUIRE_UNARY_FALSE, __VA_ARGS__) + +#ifdef DOCTEST_CONFIG_NO_EXCEPTIONS + +#undef DOCTEST_WARN_THROWS +#undef DOCTEST_CHECK_THROWS +#undef DOCTEST_REQUIRE_THROWS +#undef DOCTEST_WARN_THROWS_AS +#undef DOCTEST_CHECK_THROWS_AS +#undef DOCTEST_REQUIRE_THROWS_AS +#undef DOCTEST_WARN_THROWS_WITH +#undef DOCTEST_CHECK_THROWS_WITH +#undef DOCTEST_REQUIRE_THROWS_WITH +#undef DOCTEST_WARN_NOTHROW +#undef DOCTEST_CHECK_NOTHROW +#undef DOCTEST_REQUIRE_NOTHROW + +#undef DOCTEST_WARN_THROWS_MESSAGE +#undef DOCTEST_CHECK_THROWS_MESSAGE +#undef DOCTEST_REQUIRE_THROWS_MESSAGE +#undef DOCTEST_WARN_THROWS_AS_MESSAGE +#undef DOCTEST_CHECK_THROWS_AS_MESSAGE +#undef DOCTEST_REQUIRE_THROWS_AS_MESSAGE +#undef DOCTEST_WARN_THROWS_WITH_MESSAGE +#undef DOCTEST_CHECK_THROWS_WITH_MESSAGE +#undef DOCTEST_REQUIRE_THROWS_WITH_MESSAGE +#undef DOCTEST_WARN_NOTHROW_MESSAGE +#undef DOCTEST_CHECK_NOTHROW_MESSAGE +#undef DOCTEST_REQUIRE_NOTHROW_MESSAGE + +#ifdef DOCTEST_CONFIG_NO_EXCEPTIONS_BUT_WITH_ALL_ASSERTS + +#define DOCTEST_WARN_THROWS(expr) ((void)0) +#define DOCTEST_CHECK_THROWS(expr) ((void)0) +#define DOCTEST_REQUIRE_THROWS(expr) ((void)0) +#define DOCTEST_WARN_THROWS_AS(expr, ...) ((void)0) +#define DOCTEST_CHECK_THROWS_AS(expr, ...) ((void)0) +#define DOCTEST_REQUIRE_THROWS_AS(expr, ...) ((void)0) +#define DOCTEST_WARN_THROWS_WITH(expr, ...) ((void)0) +#define DOCTEST_CHECK_THROWS_WITH(expr, ...) ((void)0) +#define DOCTEST_REQUIRE_THROWS_WITH(expr, ...) ((void)0) +#define DOCTEST_WARN_NOTHROW(expr) ((void)0) +#define DOCTEST_CHECK_NOTHROW(expr) ((void)0) +#define DOCTEST_REQUIRE_NOTHROW(expr) ((void)0) + +#define DOCTEST_WARN_THROWS_MESSAGE(expr, msg) ((void)0) +#define DOCTEST_CHECK_THROWS_MESSAGE(expr, msg) ((void)0) +#define DOCTEST_REQUIRE_THROWS_MESSAGE(expr, msg) ((void)0) +#define DOCTEST_WARN_THROWS_AS_MESSAGE(expr, ex, msg) ((void)0) +#define DOCTEST_CHECK_THROWS_AS_MESSAGE(expr, ex, msg) ((void)0) +#define DOCTEST_REQUIRE_THROWS_AS_MESSAGE(expr, ex, msg) ((void)0) +#define DOCTEST_WARN_THROWS_WITH_MESSAGE(expr, ex, msg) ((void)0) +#define DOCTEST_CHECK_THROWS_WITH_MESSAGE(expr, ex, msg) ((void)0) +#define DOCTEST_REQUIRE_THROWS_WITH_MESSAGE(expr, ex, msg) ((void)0) +#define DOCTEST_WARN_NOTHROW_MESSAGE(expr, msg) ((void)0) +#define DOCTEST_CHECK_NOTHROW_MESSAGE(expr, msg) ((void)0) +#define DOCTEST_REQUIRE_NOTHROW_MESSAGE(expr, msg) ((void)0) + +#else // DOCTEST_CONFIG_NO_EXCEPTIONS_BUT_WITH_ALL_ASSERTS + +#undef DOCTEST_REQUIRE +#undef DOCTEST_REQUIRE_FALSE +#undef DOCTEST_REQUIRE_MESSAGE +#undef DOCTEST_REQUIRE_FALSE_MESSAGE +#undef DOCTEST_REQUIRE_EQ +#undef DOCTEST_REQUIRE_NE +#undef DOCTEST_REQUIRE_GT +#undef DOCTEST_REQUIRE_LT +#undef DOCTEST_REQUIRE_GE +#undef DOCTEST_REQUIRE_LE +#undef DOCTEST_REQUIRE_UNARY +#undef DOCTEST_REQUIRE_UNARY_FALSE + +#endif // DOCTEST_CONFIG_NO_EXCEPTIONS_BUT_WITH_ALL_ASSERTS + +#endif // DOCTEST_CONFIG_NO_EXCEPTIONS + +// ================================================================================================= +// == WHAT FOLLOWS IS VERSIONS OF THE MACROS THAT DO NOT DO ANY REGISTERING! == +// == THIS CAN BE ENABLED BY DEFINING DOCTEST_CONFIG_DISABLE GLOBALLY! == +// ================================================================================================= +#else // DOCTEST_CONFIG_DISABLE + +#define DOCTEST_IMPLEMENT_FIXTURE(der, base, func, name) \ + namespace { \ + template \ + struct der : public base \ + { void f(); }; \ + } \ + template \ + inline void der::f() + +#define DOCTEST_CREATE_AND_REGISTER_FUNCTION(f, name) \ + template \ + static inline void f() + +// for registering tests +#define DOCTEST_TEST_CASE(name) \ + DOCTEST_CREATE_AND_REGISTER_FUNCTION(DOCTEST_ANONYMOUS(_DOCTEST_ANON_FUNC_), name) + +// for registering tests with a fixture +#define DOCTEST_TEST_CASE_FIXTURE(x, name) \ + DOCTEST_IMPLEMENT_FIXTURE(DOCTEST_ANONYMOUS(_DOCTEST_ANON_CLASS_), x, \ + DOCTEST_ANONYMOUS(_DOCTEST_ANON_FUNC_), name) + +// for converting types to strings without the header and demangling +#define DOCTEST_TYPE_TO_STRING(...) typedef int DOCTEST_ANONYMOUS(_DOCTEST_ANON_FOR_SEMICOLON_) +#define DOCTEST_TYPE_TO_STRING_IMPL(...) + +// for typed tests +#define DOCTEST_TEST_CASE_TEMPLATE(name, type, ...) \ + template \ + inline void DOCTEST_ANONYMOUS(_DOCTEST_ANON_TMP_)() + +#define DOCTEST_TEST_CASE_TEMPLATE_DEFINE(name, type, id) \ + template \ + inline void DOCTEST_ANONYMOUS(_DOCTEST_ANON_TMP_)() + +#define DOCTEST_TEST_CASE_TEMPLATE_INSTANTIATE(id, ...) \ + typedef int DOCTEST_ANONYMOUS(_DOCTEST_ANON_FOR_SEMICOLON_) + +// for subcases +#define DOCTEST_SUBCASE(name) + +// for a testsuite block +#define DOCTEST_TEST_SUITE(name) namespace + +// for starting a testsuite block +#define DOCTEST_TEST_SUITE_BEGIN(name) typedef int DOCTEST_ANONYMOUS(_DOCTEST_ANON_FOR_SEMICOLON_) + +// for ending a testsuite block +#define DOCTEST_TEST_SUITE_END typedef int DOCTEST_ANONYMOUS(_DOCTEST_ANON_FOR_SEMICOLON_) + +#define DOCTEST_REGISTER_EXCEPTION_TRANSLATOR(signature) \ + template \ + static inline doctest::String DOCTEST_ANONYMOUS(_DOCTEST_ANON_TRANSLATOR_)(signature) + +#define DOCTEST_REGISTER_REPORTER(name, priority, reporter) + +#define DOCTEST_INFO(x) ((void)0) +#define DOCTEST_CAPTURE(x) ((void)0) +#define DOCTEST_ADD_MESSAGE_AT(file, line, x) ((void)0) +#define DOCTEST_ADD_FAIL_CHECK_AT(file, line, x) ((void)0) +#define DOCTEST_ADD_FAIL_AT(file, line, x) ((void)0) +#define DOCTEST_MESSAGE(x) ((void)0) +#define DOCTEST_FAIL_CHECK(x) ((void)0) +#define DOCTEST_FAIL(x) ((void)0) + +#define DOCTEST_WARN(...) ((void)0) +#define DOCTEST_CHECK(...) ((void)0) +#define DOCTEST_REQUIRE(...) ((void)0) +#define DOCTEST_WARN_FALSE(...) ((void)0) +#define DOCTEST_CHECK_FALSE(...) ((void)0) +#define DOCTEST_REQUIRE_FALSE(...) ((void)0) + +#define DOCTEST_WARN_MESSAGE(cond, msg) ((void)0) +#define DOCTEST_CHECK_MESSAGE(cond, msg) ((void)0) +#define DOCTEST_REQUIRE_MESSAGE(cond, msg) ((void)0) +#define DOCTEST_WARN_FALSE_MESSAGE(cond, msg) ((void)0) +#define DOCTEST_CHECK_FALSE_MESSAGE(cond, msg) ((void)0) +#define DOCTEST_REQUIRE_FALSE_MESSAGE(cond, msg) ((void)0) + +#define DOCTEST_WARN_THROWS(expr) ((void)0) +#define DOCTEST_CHECK_THROWS(expr) ((void)0) +#define DOCTEST_REQUIRE_THROWS(expr) ((void)0) +#define DOCTEST_WARN_THROWS_AS(expr, ...) ((void)0) +#define DOCTEST_CHECK_THROWS_AS(expr, ...) ((void)0) +#define DOCTEST_REQUIRE_THROWS_AS(expr, ...) ((void)0) +#define DOCTEST_WARN_THROWS_WITH(expr, ...) ((void)0) +#define DOCTEST_CHECK_THROWS_WITH(expr, ...) ((void)0) +#define DOCTEST_REQUIRE_THROWS_WITH(expr, ...) ((void)0) +#define DOCTEST_WARN_NOTHROW(expr) ((void)0) +#define DOCTEST_CHECK_NOTHROW(expr) ((void)0) +#define DOCTEST_REQUIRE_NOTHROW(expr) ((void)0) + +#define DOCTEST_WARN_THROWS_MESSAGE(expr, msg) ((void)0) +#define DOCTEST_CHECK_THROWS_MESSAGE(expr, msg) ((void)0) +#define DOCTEST_REQUIRE_THROWS_MESSAGE(expr, msg) ((void)0) +#define DOCTEST_WARN_THROWS_AS_MESSAGE(expr, ex, msg) ((void)0) +#define DOCTEST_CHECK_THROWS_AS_MESSAGE(expr, ex, msg) ((void)0) +#define DOCTEST_REQUIRE_THROWS_AS_MESSAGE(expr, ex, msg) ((void)0) +#define DOCTEST_WARN_THROWS_WITH_MESSAGE(expr, ex, msg) ((void)0) +#define DOCTEST_CHECK_THROWS_WITH_MESSAGE(expr, ex, msg) ((void)0) +#define DOCTEST_REQUIRE_THROWS_WITH_MESSAGE(expr, ex, msg) ((void)0) +#define DOCTEST_WARN_NOTHROW_MESSAGE(expr, msg) ((void)0) +#define DOCTEST_CHECK_NOTHROW_MESSAGE(expr, msg) ((void)0) +#define DOCTEST_REQUIRE_NOTHROW_MESSAGE(expr, msg) ((void)0) + +#define DOCTEST_WARN_EQ(...) ((void)0) +#define DOCTEST_CHECK_EQ(...) ((void)0) +#define DOCTEST_REQUIRE_EQ(...) ((void)0) +#define DOCTEST_WARN_NE(...) ((void)0) +#define DOCTEST_CHECK_NE(...) ((void)0) +#define DOCTEST_REQUIRE_NE(...) ((void)0) +#define DOCTEST_WARN_GT(...) ((void)0) +#define DOCTEST_CHECK_GT(...) ((void)0) +#define DOCTEST_REQUIRE_GT(...) ((void)0) +#define DOCTEST_WARN_LT(...) ((void)0) +#define DOCTEST_CHECK_LT(...) ((void)0) +#define DOCTEST_REQUIRE_LT(...) ((void)0) +#define DOCTEST_WARN_GE(...) ((void)0) +#define DOCTEST_CHECK_GE(...) ((void)0) +#define DOCTEST_REQUIRE_GE(...) ((void)0) +#define DOCTEST_WARN_LE(...) ((void)0) +#define DOCTEST_CHECK_LE(...) ((void)0) +#define DOCTEST_REQUIRE_LE(...) ((void)0) + +#define DOCTEST_WARN_UNARY(...) ((void)0) +#define DOCTEST_CHECK_UNARY(...) ((void)0) +#define DOCTEST_REQUIRE_UNARY(...) ((void)0) +#define DOCTEST_WARN_UNARY_FALSE(...) ((void)0) +#define DOCTEST_CHECK_UNARY_FALSE(...) ((void)0) +#define DOCTEST_REQUIRE_UNARY_FALSE(...) ((void)0) + +#endif // DOCTEST_CONFIG_DISABLE + +// clang-format off +// KEPT FOR BACKWARDS COMPATIBILITY - FORWARDING TO THE RIGHT MACROS +#define DOCTEST_FAST_WARN_EQ DOCTEST_WARN_EQ +#define DOCTEST_FAST_CHECK_EQ DOCTEST_CHECK_EQ +#define DOCTEST_FAST_REQUIRE_EQ DOCTEST_REQUIRE_EQ +#define DOCTEST_FAST_WARN_NE DOCTEST_WARN_NE +#define DOCTEST_FAST_CHECK_NE DOCTEST_CHECK_NE +#define DOCTEST_FAST_REQUIRE_NE DOCTEST_REQUIRE_NE +#define DOCTEST_FAST_WARN_GT DOCTEST_WARN_GT +#define DOCTEST_FAST_CHECK_GT DOCTEST_CHECK_GT +#define DOCTEST_FAST_REQUIRE_GT DOCTEST_REQUIRE_GT +#define DOCTEST_FAST_WARN_LT DOCTEST_WARN_LT +#define DOCTEST_FAST_CHECK_LT DOCTEST_CHECK_LT +#define DOCTEST_FAST_REQUIRE_LT DOCTEST_REQUIRE_LT +#define DOCTEST_FAST_WARN_GE DOCTEST_WARN_GE +#define DOCTEST_FAST_CHECK_GE DOCTEST_CHECK_GE +#define DOCTEST_FAST_REQUIRE_GE DOCTEST_REQUIRE_GE +#define DOCTEST_FAST_WARN_LE DOCTEST_WARN_LE +#define DOCTEST_FAST_CHECK_LE DOCTEST_CHECK_LE +#define DOCTEST_FAST_REQUIRE_LE DOCTEST_REQUIRE_LE + +#define DOCTEST_FAST_WARN_UNARY DOCTEST_WARN_UNARY +#define DOCTEST_FAST_CHECK_UNARY DOCTEST_CHECK_UNARY +#define DOCTEST_FAST_REQUIRE_UNARY DOCTEST_REQUIRE_UNARY +#define DOCTEST_FAST_WARN_UNARY_FALSE DOCTEST_WARN_UNARY_FALSE +#define DOCTEST_FAST_CHECK_UNARY_FALSE DOCTEST_CHECK_UNARY_FALSE +#define DOCTEST_FAST_REQUIRE_UNARY_FALSE DOCTEST_REQUIRE_UNARY_FALSE +// clang-format on + +// BDD style macros +// clang-format off +#define DOCTEST_SCENARIO(name) DOCTEST_TEST_CASE(" Scenario: " name) +#define DOCTEST_SCENARIO_TEMPLATE(name, T, ...) DOCTEST_TEST_CASE_TEMPLATE(" Scenario: " name, T, __VA_ARGS__) +#define DOCTEST_SCENARIO_TEMPLATE_DEFINE(name, T, id) DOCTEST_TEST_CASE_TEMPLATE_DEFINE(" Scenario: " name, T, id) + +#define DOCTEST_GIVEN(name) SUBCASE(" Given: " name) +#define DOCTEST_WHEN(name) SUBCASE(" When: " name) +#define DOCTEST_AND_WHEN(name) SUBCASE("And when: " name) +#define DOCTEST_THEN(name) SUBCASE(" Then: " name) +#define DOCTEST_AND_THEN(name) SUBCASE(" And: " name) +// clang-format on + +// == SHORT VERSIONS OF THE MACROS +#if !defined(DOCTEST_CONFIG_NO_SHORT_MACRO_NAMES) + +#define TEST_CASE DOCTEST_TEST_CASE +#define TEST_CASE_FIXTURE DOCTEST_TEST_CASE_FIXTURE +#define TYPE_TO_STRING DOCTEST_TYPE_TO_STRING +#define TEST_CASE_TEMPLATE DOCTEST_TEST_CASE_TEMPLATE +#define TEST_CASE_TEMPLATE_DEFINE DOCTEST_TEST_CASE_TEMPLATE_DEFINE +#define TEST_CASE_TEMPLATE_INSTANTIATE DOCTEST_TEST_CASE_TEMPLATE_INSTANTIATE +#define SUBCASE DOCTEST_SUBCASE +#define TEST_SUITE DOCTEST_TEST_SUITE +#define TEST_SUITE_BEGIN DOCTEST_TEST_SUITE_BEGIN +#define TEST_SUITE_END DOCTEST_TEST_SUITE_END +#define REGISTER_EXCEPTION_TRANSLATOR DOCTEST_REGISTER_EXCEPTION_TRANSLATOR +#define REGISTER_REPORTER DOCTEST_REGISTER_REPORTER +#define INFO DOCTEST_INFO +#define CAPTURE DOCTEST_CAPTURE +#define ADD_MESSAGE_AT DOCTEST_ADD_MESSAGE_AT +#define ADD_FAIL_CHECK_AT DOCTEST_ADD_FAIL_CHECK_AT +#define ADD_FAIL_AT DOCTEST_ADD_FAIL_AT +#define MESSAGE DOCTEST_MESSAGE +#define FAIL_CHECK DOCTEST_FAIL_CHECK +#define FAIL DOCTEST_FAIL +#define TO_LVALUE DOCTEST_TO_LVALUE + +#define WARN DOCTEST_WARN +#define WARN_FALSE DOCTEST_WARN_FALSE +#define WARN_THROWS DOCTEST_WARN_THROWS +#define WARN_THROWS_AS DOCTEST_WARN_THROWS_AS +#define WARN_THROWS_WITH DOCTEST_WARN_THROWS_WITH +#define WARN_NOTHROW DOCTEST_WARN_NOTHROW +#define CHECK DOCTEST_CHECK +#define CHECK_FALSE DOCTEST_CHECK_FALSE +#define CHECK_THROWS DOCTEST_CHECK_THROWS +#define CHECK_THROWS_AS DOCTEST_CHECK_THROWS_AS +#define CHECK_THROWS_WITH DOCTEST_CHECK_THROWS_WITH +#define CHECK_NOTHROW DOCTEST_CHECK_NOTHROW +#define REQUIRE DOCTEST_REQUIRE +#define REQUIRE_FALSE DOCTEST_REQUIRE_FALSE +#define REQUIRE_THROWS DOCTEST_REQUIRE_THROWS +#define REQUIRE_THROWS_AS DOCTEST_REQUIRE_THROWS_AS +#define REQUIRE_THROWS_WITH DOCTEST_REQUIRE_THROWS_WITH +#define REQUIRE_NOTHROW DOCTEST_REQUIRE_NOTHROW + +#define WARN_MESSAGE DOCTEST_WARN_MESSAGE +#define WARN_FALSE_MESSAGE DOCTEST_WARN_FALSE_MESSAGE +#define WARN_THROWS_MESSAGE DOCTEST_WARN_THROWS_MESSAGE +#define WARN_THROWS_AS_MESSAGE DOCTEST_WARN_THROWS_AS_MESSAGE +#define WARN_THROWS_WITH_MESSAGE DOCTEST_WARN_THROWS_WITH_MESSAGE +#define WARN_NOTHROW_MESSAGE DOCTEST_WARN_NOTHROW_MESSAGE +#define CHECK_MESSAGE DOCTEST_CHECK_MESSAGE +#define CHECK_FALSE_MESSAGE DOCTEST_CHECK_FALSE_MESSAGE +#define CHECK_THROWS_MESSAGE DOCTEST_CHECK_THROWS_MESSAGE +#define CHECK_THROWS_AS_MESSAGE DOCTEST_CHECK_THROWS_AS_MESSAGE +#define CHECK_THROWS_WITH_MESSAGE DOCTEST_CHECK_THROWS_WITH_MESSAGE +#define CHECK_NOTHROW_MESSAGE DOCTEST_CHECK_NOTHROW_MESSAGE +#define REQUIRE_MESSAGE DOCTEST_REQUIRE_MESSAGE +#define REQUIRE_FALSE_MESSAGE DOCTEST_REQUIRE_FALSE_MESSAGE +#define REQUIRE_THROWS_MESSAGE DOCTEST_REQUIRE_THROWS_MESSAGE +#define REQUIRE_THROWS_AS_MESSAGE DOCTEST_REQUIRE_THROWS_AS_MESSAGE +#define REQUIRE_THROWS_WITH_MESSAGE DOCTEST_REQUIRE_THROWS_WITH_MESSAGE +#define REQUIRE_NOTHROW_MESSAGE DOCTEST_REQUIRE_NOTHROW_MESSAGE + +#define SCENARIO DOCTEST_SCENARIO +#define SCENARIO_TEMPLATE DOCTEST_SCENARIO_TEMPLATE +#define SCENARIO_TEMPLATE_DEFINE DOCTEST_SCENARIO_TEMPLATE_DEFINE +#define GIVEN DOCTEST_GIVEN +#define WHEN DOCTEST_WHEN +#define AND_WHEN DOCTEST_AND_WHEN +#define THEN DOCTEST_THEN +#define AND_THEN DOCTEST_AND_THEN + +#define WARN_EQ DOCTEST_WARN_EQ +#define CHECK_EQ DOCTEST_CHECK_EQ +#define REQUIRE_EQ DOCTEST_REQUIRE_EQ +#define WARN_NE DOCTEST_WARN_NE +#define CHECK_NE DOCTEST_CHECK_NE +#define REQUIRE_NE DOCTEST_REQUIRE_NE +#define WARN_GT DOCTEST_WARN_GT +#define CHECK_GT DOCTEST_CHECK_GT +#define REQUIRE_GT DOCTEST_REQUIRE_GT +#define WARN_LT DOCTEST_WARN_LT +#define CHECK_LT DOCTEST_CHECK_LT +#define REQUIRE_LT DOCTEST_REQUIRE_LT +#define WARN_GE DOCTEST_WARN_GE +#define CHECK_GE DOCTEST_CHECK_GE +#define REQUIRE_GE DOCTEST_REQUIRE_GE +#define WARN_LE DOCTEST_WARN_LE +#define CHECK_LE DOCTEST_CHECK_LE +#define REQUIRE_LE DOCTEST_REQUIRE_LE +#define WARN_UNARY DOCTEST_WARN_UNARY +#define CHECK_UNARY DOCTEST_CHECK_UNARY +#define REQUIRE_UNARY DOCTEST_REQUIRE_UNARY +#define WARN_UNARY_FALSE DOCTEST_WARN_UNARY_FALSE +#define CHECK_UNARY_FALSE DOCTEST_CHECK_UNARY_FALSE +#define REQUIRE_UNARY_FALSE DOCTEST_REQUIRE_UNARY_FALSE + +// KEPT FOR BACKWARDS COMPATIBILITY +#define FAST_WARN_EQ DOCTEST_FAST_WARN_EQ +#define FAST_CHECK_EQ DOCTEST_FAST_CHECK_EQ +#define FAST_REQUIRE_EQ DOCTEST_FAST_REQUIRE_EQ +#define FAST_WARN_NE DOCTEST_FAST_WARN_NE +#define FAST_CHECK_NE DOCTEST_FAST_CHECK_NE +#define FAST_REQUIRE_NE DOCTEST_FAST_REQUIRE_NE +#define FAST_WARN_GT DOCTEST_FAST_WARN_GT +#define FAST_CHECK_GT DOCTEST_FAST_CHECK_GT +#define FAST_REQUIRE_GT DOCTEST_FAST_REQUIRE_GT +#define FAST_WARN_LT DOCTEST_FAST_WARN_LT +#define FAST_CHECK_LT DOCTEST_FAST_CHECK_LT +#define FAST_REQUIRE_LT DOCTEST_FAST_REQUIRE_LT +#define FAST_WARN_GE DOCTEST_FAST_WARN_GE +#define FAST_CHECK_GE DOCTEST_FAST_CHECK_GE +#define FAST_REQUIRE_GE DOCTEST_FAST_REQUIRE_GE +#define FAST_WARN_LE DOCTEST_FAST_WARN_LE +#define FAST_CHECK_LE DOCTEST_FAST_CHECK_LE +#define FAST_REQUIRE_LE DOCTEST_FAST_REQUIRE_LE +#define FAST_WARN_UNARY DOCTEST_FAST_WARN_UNARY +#define FAST_CHECK_UNARY DOCTEST_FAST_CHECK_UNARY +#define FAST_REQUIRE_UNARY DOCTEST_FAST_REQUIRE_UNARY +#define FAST_WARN_UNARY_FALSE DOCTEST_FAST_WARN_UNARY_FALSE +#define FAST_CHECK_UNARY_FALSE DOCTEST_FAST_CHECK_UNARY_FALSE +#define FAST_REQUIRE_UNARY_FALSE DOCTEST_FAST_REQUIRE_UNARY_FALSE + +#endif // DOCTEST_CONFIG_NO_SHORT_MACRO_NAMES + +#if !defined(DOCTEST_CONFIG_DISABLE) + +// this is here to clear the 'current test suite' for the current translation unit - at the top +DOCTEST_TEST_SUITE_END(); + +// add stringification for primitive/fundamental types +namespace doctest { namespace detail { + DOCTEST_TYPE_TO_STRING_IMPL(bool) + DOCTEST_TYPE_TO_STRING_IMPL(float) + DOCTEST_TYPE_TO_STRING_IMPL(double) + DOCTEST_TYPE_TO_STRING_IMPL(long double) + DOCTEST_TYPE_TO_STRING_IMPL(char) + DOCTEST_TYPE_TO_STRING_IMPL(signed char) + DOCTEST_TYPE_TO_STRING_IMPL(unsigned char) + DOCTEST_TYPE_TO_STRING_IMPL(wchar_t) + DOCTEST_TYPE_TO_STRING_IMPL(short int) + DOCTEST_TYPE_TO_STRING_IMPL(unsigned short int) + DOCTEST_TYPE_TO_STRING_IMPL(int) + DOCTEST_TYPE_TO_STRING_IMPL(unsigned int) + DOCTEST_TYPE_TO_STRING_IMPL(long int) + DOCTEST_TYPE_TO_STRING_IMPL(unsigned long int) + DOCTEST_TYPE_TO_STRING_IMPL(long long int) + DOCTEST_TYPE_TO_STRING_IMPL(unsigned long long int) +}} // namespace doctest::detail + +#endif // DOCTEST_CONFIG_DISABLE + +DOCTEST_CLANG_SUPPRESS_WARNING_POP +DOCTEST_MSVC_SUPPRESS_WARNING_POP +DOCTEST_GCC_SUPPRESS_WARNING_POP + +#endif // DOCTEST_LIBRARY_INCLUDED + +#ifndef DOCTEST_SINGLE_HEADER +#define DOCTEST_SINGLE_HEADER +#endif // DOCTEST_SINGLE_HEADER + +#if defined(DOCTEST_CONFIG_IMPLEMENT) || !defined(DOCTEST_SINGLE_HEADER) +#ifndef DOCTEST_LIBRARY_IMPLEMENTATION +#define DOCTEST_LIBRARY_IMPLEMENTATION + +#ifndef DOCTEST_SINGLE_HEADER +#include "doctest_fwd.h" +#endif // DOCTEST_SINGLE_HEADER + +DOCTEST_CLANG_SUPPRESS_WARNING_PUSH +DOCTEST_CLANG_SUPPRESS_WARNING("-Wunknown-pragmas") +DOCTEST_CLANG_SUPPRESS_WARNING("-Wpadded") +DOCTEST_CLANG_SUPPRESS_WARNING("-Wweak-vtables") +DOCTEST_CLANG_SUPPRESS_WARNING("-Wglobal-constructors") +DOCTEST_CLANG_SUPPRESS_WARNING("-Wexit-time-destructors") +DOCTEST_CLANG_SUPPRESS_WARNING("-Wmissing-prototypes") +DOCTEST_CLANG_SUPPRESS_WARNING("-Wsign-conversion") +DOCTEST_CLANG_SUPPRESS_WARNING("-Wshorten-64-to-32") +DOCTEST_CLANG_SUPPRESS_WARNING("-Wmissing-variable-declarations") +DOCTEST_CLANG_SUPPRESS_WARNING("-Wswitch") +DOCTEST_CLANG_SUPPRESS_WARNING("-Wswitch-enum") +DOCTEST_CLANG_SUPPRESS_WARNING("-Wcovered-switch-default") +DOCTEST_CLANG_SUPPRESS_WARNING("-Wmissing-noreturn") +DOCTEST_CLANG_SUPPRESS_WARNING("-Wunused-local-typedef") +DOCTEST_CLANG_SUPPRESS_WARNING("-Wdisabled-macro-expansion") +DOCTEST_CLANG_SUPPRESS_WARNING("-Wmissing-braces") +DOCTEST_CLANG_SUPPRESS_WARNING("-Wmissing-field-initializers") +DOCTEST_CLANG_SUPPRESS_WARNING("-Wc++98-compat") +DOCTEST_CLANG_SUPPRESS_WARNING("-Wc++98-compat-pedantic") + +DOCTEST_GCC_SUPPRESS_WARNING_PUSH +DOCTEST_GCC_SUPPRESS_WARNING("-Wunknown-pragmas") +DOCTEST_GCC_SUPPRESS_WARNING("-Wpragmas") +DOCTEST_GCC_SUPPRESS_WARNING("-Wconversion") +DOCTEST_GCC_SUPPRESS_WARNING("-Weffc++") +DOCTEST_GCC_SUPPRESS_WARNING("-Wsign-conversion") +DOCTEST_GCC_SUPPRESS_WARNING("-Wstrict-overflow") +DOCTEST_GCC_SUPPRESS_WARNING("-Wstrict-aliasing") +DOCTEST_GCC_SUPPRESS_WARNING("-Wmissing-field-initializers") +DOCTEST_GCC_SUPPRESS_WARNING("-Wmissing-braces") +DOCTEST_GCC_SUPPRESS_WARNING("-Wmissing-declarations") +DOCTEST_GCC_SUPPRESS_WARNING("-Winline") +DOCTEST_GCC_SUPPRESS_WARNING("-Wswitch") +DOCTEST_GCC_SUPPRESS_WARNING("-Wswitch-enum") +DOCTEST_GCC_SUPPRESS_WARNING("-Wswitch-default") +DOCTEST_GCC_SUPPRESS_WARNING("-Wunsafe-loop-optimizations") +DOCTEST_GCC_SUPPRESS_WARNING("-Wold-style-cast") +DOCTEST_GCC_SUPPRESS_WARNING("-Wunused-local-typedefs") +DOCTEST_GCC_SUPPRESS_WARNING("-Wuseless-cast") + +DOCTEST_MSVC_SUPPRESS_WARNING_PUSH +DOCTEST_MSVC_SUPPRESS_WARNING(4616) // invalid compiler warning +DOCTEST_MSVC_SUPPRESS_WARNING(4619) // invalid compiler warning +DOCTEST_MSVC_SUPPRESS_WARNING(4996) // The compiler encountered a deprecated declaration +DOCTEST_MSVC_SUPPRESS_WARNING(4267) // 'var' : conversion from 'x' to 'y', possible loss of data +DOCTEST_MSVC_SUPPRESS_WARNING(4706) // assignment within conditional expression +DOCTEST_MSVC_SUPPRESS_WARNING(4512) // 'class' : assignment operator could not be generated +DOCTEST_MSVC_SUPPRESS_WARNING(4127) // conditional expression is constant +DOCTEST_MSVC_SUPPRESS_WARNING(4530) // C++ exception handler used, but unwind semantics not enabled +DOCTEST_MSVC_SUPPRESS_WARNING(4577) // 'noexcept' used with no exception handling mode specified +DOCTEST_MSVC_SUPPRESS_WARNING(4774) // format string expected in argument is not a string literal +DOCTEST_MSVC_SUPPRESS_WARNING(4365) // conversion from 'int' to 'unsigned', signed/unsigned mismatch +DOCTEST_MSVC_SUPPRESS_WARNING(4820) // padding in structs +DOCTEST_MSVC_SUPPRESS_WARNING(4640) // construction of local static object is not thread-safe +DOCTEST_MSVC_SUPPRESS_WARNING(5039) // pointer to potentially throwing function passed to extern C +DOCTEST_MSVC_SUPPRESS_WARNING(5045) // Spectre mitigation stuff +DOCTEST_MSVC_SUPPRESS_WARNING(4626) // assignment operator was implicitly defined as deleted +DOCTEST_MSVC_SUPPRESS_WARNING(5027) // move assignment operator was implicitly defined as deleted +DOCTEST_MSVC_SUPPRESS_WARNING(5026) // move constructor was implicitly defined as deleted +DOCTEST_MSVC_SUPPRESS_WARNING(4625) // copy constructor was implicitly defined as deleted +DOCTEST_MSVC_SUPPRESS_WARNING(4800) // forcing value to bool 'true' or 'false' (performance warning) +// static analysis +DOCTEST_MSVC_SUPPRESS_WARNING(26439) // This kind of function may not throw. Declare it 'noexcept' +DOCTEST_MSVC_SUPPRESS_WARNING(26495) // Always initialize a member variable +DOCTEST_MSVC_SUPPRESS_WARNING(26451) // Arithmetic overflow ... +DOCTEST_MSVC_SUPPRESS_WARNING(26444) // Avoid unnamed objects with custom construction and dtor... + +DOCTEST_MAKE_STD_HEADERS_CLEAN_FROM_WARNINGS_ON_WALL_BEGIN + +// required includes - will go only in one translation unit! +#include +#include +#include +// borland (Embarcadero) compiler requires math.h and not cmath - https://github.com/onqtam/doctest/pull/37 +#ifdef __BORLANDC__ +#include +#endif // __BORLANDC__ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#ifdef DOCTEST_PLATFORM_MAC +#include +#include +#include +#endif // DOCTEST_PLATFORM_MAC + +DOCTEST_MAKE_STD_HEADERS_CLEAN_FROM_WARNINGS_ON_WALL_END + +// counts the number of elements in a C array +#define DOCTEST_COUNTOF(x) (sizeof(x) / sizeof(x[0])) + +#ifdef DOCTEST_CONFIG_DISABLE +#define DOCTEST_BRANCH_ON_DISABLED(if_disabled, if_not_disabled) if_disabled +#else // DOCTEST_CONFIG_DISABLE +#define DOCTEST_BRANCH_ON_DISABLED(if_disabled, if_not_disabled) if_not_disabled +#endif // DOCTEST_CONFIG_DISABLE + +#ifndef DOCTEST_CONFIG_OPTIONS_PREFIX +#define DOCTEST_CONFIG_OPTIONS_PREFIX "dt-" +#endif + +#ifndef DOCTEST_THREAD_LOCAL +#define DOCTEST_THREAD_LOCAL thread_local +#endif + +#ifdef DOCTEST_CONFIG_NO_UNPREFIXED_OPTIONS +#define DOCTEST_OPTIONS_PREFIX_DISPLAY DOCTEST_CONFIG_OPTIONS_PREFIX +#else +#define DOCTEST_OPTIONS_PREFIX_DISPLAY "" +#endif + +namespace doctest { + +bool is_running_in_test = false; + +namespace { + using namespace detail; + // case insensitive strcmp + int stricmp(const char* a, const char* b) { + for(;; a++, b++) { + const int d = tolower(*a) - tolower(*b); + if(d != 0 || !*a) + return d; + } + } + + template + String fpToString(T value, int precision) { + std::ostringstream oss; + oss << std::setprecision(precision) << std::fixed << value; + std::string d = oss.str(); + size_t i = d.find_last_not_of('0'); + if(i != std::string::npos && i != d.size() - 1) { + if(d[i] == '.') + i++; + d = d.substr(0, i + 1); + } + return d.c_str(); + } + + struct Endianness + { + enum Arch + { + Big, + Little + }; + + static Arch which() { + union _ + { + int asInt; + char asChar[sizeof(int)]; + } u; + + u.asInt = 1; // NOLINT + return (u.asChar[sizeof(int) - 1] == 1) ? Big : Little; // NOLINT + } + }; +} // namespace + +namespace detail { + void my_memcpy(void* dest, const void* src, unsigned num) { memcpy(dest, src, num); } + + String rawMemoryToString(const void* object, unsigned size) { + // Reverse order for little endian architectures + int i = 0, end = static_cast(size), inc = 1; + if(Endianness::which() == Endianness::Little) { + i = end - 1; + end = inc = -1; + } + + unsigned const char* bytes = static_cast(object); + std::ostringstream oss; + oss << "0x" << std::setfill('0') << std::hex; + for(; i != end; i += inc) + oss << std::setw(2) << static_cast(bytes[i]); + return oss.str().c_str(); + } + + DOCTEST_THREAD_LOCAL std::ostringstream g_oss; + + std::ostream* getTlsOss() { + g_oss.clear(); // there shouldn't be anything worth clearing in the flags + g_oss.str(""); // the slow way of resetting a string stream + //g_oss.seekp(0); // optimal reset - as seen here: https://stackoverflow.com/a/624291/3162383 + return &g_oss; + } + + String getTlsOssResult() { + //g_oss << std::ends; // needed - as shown here: https://stackoverflow.com/a/624291/3162383 + return g_oss.str().c_str(); + } + +#ifndef DOCTEST_CONFIG_DISABLE + // this holds both parameters from the command line and runtime data for tests + struct ContextState : ContextOptions, TestRunStats, CurrentTestCaseStats + { + std::atomic numAssertsForCurrentTestCase_atomic; + std::atomic numAssertsFailedForCurrentTestCase_atomic; + + std::vector > filters = decltype(filters)(9); // 9 different filters + + std::vector reporters_currently_used; + + const TestCase* currentTest = nullptr; + + assert_handler ah = nullptr; + + std::vector stringifiedContexts; // logging from INFO() due to an exception + + // stuff for subcases + std::set subcasesPassed; + std::set subcasesEnteredLevels; + int subcasesCurrentLevel; + + void resetRunData() { + numTestCases = 0; + numTestCasesPassingFilters = 0; + numTestSuitesPassingFilters = 0; + numTestCasesFailed = 0; + numAsserts = 0; + numAssertsFailed = 0; + } + }; + + ContextState* g_cs = nullptr; + DOCTEST_THREAD_LOCAL bool g_no_colors; // used to avoid locks for the debug output + +#endif // DOCTEST_CONFIG_DISABLE +} // namespace detail + +void String::setOnHeap() { *reinterpret_cast(&buf[last]) = 128; } +void String::setLast(unsigned in) { buf[last] = char(in); } + +void String::copy(const String& other) { + if(other.isOnStack()) { + memcpy(buf, other.buf, len); + } else { + setOnHeap(); + data.size = other.data.size; + data.capacity = data.size + 1; + data.ptr = new char[data.capacity]; + memcpy(data.ptr, other.data.ptr, data.size + 1); + } +} + +String::String() { + buf[0] = '\0'; + setLast(); +} + +String::~String() { + if(!isOnStack()) + delete[] data.ptr; +} + +String::String(const char* in) + : String(in, strlen(in)) {} + +String::String(const char* in, unsigned in_size) { + if(in_size <= last) { + memcpy(buf, in, in_size + 1); + setLast(last - in_size); + } else { + setOnHeap(); + data.size = in_size; + data.capacity = data.size + 1; + data.ptr = new char[data.capacity]; + memcpy(data.ptr, in, in_size + 1); + } +} + +String::String(const String& other) { copy(other); } + +String& String::operator=(const String& other) { + if(this != &other) { + if(!isOnStack()) + delete[] data.ptr; + + copy(other); + } + + return *this; +} + +String& String::operator+=(const String& other) { + const unsigned my_old_size = size(); + const unsigned other_size = other.size(); + const unsigned total_size = my_old_size + other_size; + if(isOnStack()) { + if(total_size < len) { + // append to the current stack space + memcpy(buf + my_old_size, other.c_str(), other_size + 1); + setLast(last - total_size); + } else { + // alloc new chunk + char* temp = new char[total_size + 1]; + // copy current data to new location before writing in the union + memcpy(temp, buf, my_old_size); // skip the +1 ('\0') for speed + // update data in union + setOnHeap(); + data.size = total_size; + data.capacity = data.size + 1; + data.ptr = temp; + // transfer the rest of the data + memcpy(data.ptr + my_old_size, other.c_str(), other_size + 1); + } + } else { + if(data.capacity > total_size) { + // append to the current heap block + data.size = total_size; + memcpy(data.ptr + my_old_size, other.c_str(), other_size + 1); + } else { + // resize + data.capacity *= 2; + if(data.capacity <= total_size) + data.capacity = total_size + 1; + // alloc new chunk + char* temp = new char[data.capacity]; + // copy current data to new location before releasing it + memcpy(temp, data.ptr, my_old_size); // skip the +1 ('\0') for speed + // release old chunk + delete[] data.ptr; + // update the rest of the union members + data.size = total_size; + data.ptr = temp; + // transfer the rest of the data + memcpy(data.ptr + my_old_size, other.c_str(), other_size + 1); + } + } + + return *this; +} + +String String::operator+(const String& other) const { return String(*this) += other; } + +String::String(String&& other) { + memcpy(buf, other.buf, len); + other.buf[0] = '\0'; + other.setLast(); +} + +String& String::operator=(String&& other) { + if(this != &other) { + if(!isOnStack()) + delete[] data.ptr; + memcpy(buf, other.buf, len); + other.buf[0] = '\0'; + other.setLast(); + } + return *this; +} + +char String::operator[](unsigned i) const { + return const_cast(this)->operator[](i); // NOLINT +} + +char& String::operator[](unsigned i) { + if(isOnStack()) + return reinterpret_cast(buf)[i]; + return data.ptr[i]; +} + +DOCTEST_GCC_SUPPRESS_WARNING_WITH_PUSH("-Wmaybe-uninitialized") +unsigned String::size() const { + if(isOnStack()) + return last - (unsigned(buf[last]) & 31); // using "last" would work only if "len" is 32 + return data.size; +} +DOCTEST_GCC_SUPPRESS_WARNING_POP + +unsigned String::capacity() const { + if(isOnStack()) + return len; + return data.capacity; +} + +int String::compare(const char* other, bool no_case) const { + if(no_case) + return stricmp(c_str(), other); + return std::strcmp(c_str(), other); +} + +int String::compare(const String& other, bool no_case) const { + return compare(other.c_str(), no_case); +} + +// clang-format off +bool operator==(const String& lhs, const String& rhs) { return lhs.compare(rhs) == 0; } +bool operator!=(const String& lhs, const String& rhs) { return lhs.compare(rhs) != 0; } +bool operator< (const String& lhs, const String& rhs) { return lhs.compare(rhs) < 0; } +bool operator> (const String& lhs, const String& rhs) { return lhs.compare(rhs) > 0; } +bool operator<=(const String& lhs, const String& rhs) { return (lhs != rhs) ? lhs.compare(rhs) < 0 : true; } +bool operator>=(const String& lhs, const String& rhs) { return (lhs != rhs) ? lhs.compare(rhs) > 0 : true; } +// clang-format on + +std::ostream& operator<<(std::ostream& s, const String& in) { return s << in.c_str(); } + +namespace { + void color_to_stream(std::ostream&, Color::Enum) DOCTEST_BRANCH_ON_DISABLED({}, ;) +} // namespace + +namespace Color { + std::ostream& operator<<(std::ostream& s, Color::Enum code) { + color_to_stream(s, code); + return s; + } +} // namespace Color + +// clang-format off +const char* assertString(assertType::Enum at) { + DOCTEST_MSVC_SUPPRESS_WARNING_WITH_PUSH(4062) // enum 'x' in switch of enum 'y' is not handled + switch(at) { //!OCLINT missing default in switch statements + case assertType::DT_WARN : return "WARN"; + case assertType::DT_CHECK : return "CHECK"; + case assertType::DT_REQUIRE : return "REQUIRE"; + + case assertType::DT_WARN_FALSE : return "WARN_FALSE"; + case assertType::DT_CHECK_FALSE : return "CHECK_FALSE"; + case assertType::DT_REQUIRE_FALSE : return "REQUIRE_FALSE"; + + case assertType::DT_WARN_THROWS : return "WARN_THROWS"; + case assertType::DT_CHECK_THROWS : return "CHECK_THROWS"; + case assertType::DT_REQUIRE_THROWS : return "REQUIRE_THROWS"; + + case assertType::DT_WARN_THROWS_AS : return "WARN_THROWS_AS"; + case assertType::DT_CHECK_THROWS_AS : return "CHECK_THROWS_AS"; + case assertType::DT_REQUIRE_THROWS_AS : return "REQUIRE_THROWS_AS"; + + case assertType::DT_WARN_THROWS_WITH : return "WARN_THROWS_WITH"; + case assertType::DT_CHECK_THROWS_WITH : return "CHECK_THROWS_WITH"; + case assertType::DT_REQUIRE_THROWS_WITH : return "REQUIRE_THROWS_WITH"; + + case assertType::DT_WARN_NOTHROW : return "WARN_NOTHROW"; + case assertType::DT_CHECK_NOTHROW : return "CHECK_NOTHROW"; + case assertType::DT_REQUIRE_NOTHROW : return "REQUIRE_NOTHROW"; + + case assertType::DT_WARN_EQ : return "WARN_EQ"; + case assertType::DT_CHECK_EQ : return "CHECK_EQ"; + case assertType::DT_REQUIRE_EQ : return "REQUIRE_EQ"; + case assertType::DT_WARN_NE : return "WARN_NE"; + case assertType::DT_CHECK_NE : return "CHECK_NE"; + case assertType::DT_REQUIRE_NE : return "REQUIRE_NE"; + case assertType::DT_WARN_GT : return "WARN_GT"; + case assertType::DT_CHECK_GT : return "CHECK_GT"; + case assertType::DT_REQUIRE_GT : return "REQUIRE_GT"; + case assertType::DT_WARN_LT : return "WARN_LT"; + case assertType::DT_CHECK_LT : return "CHECK_LT"; + case assertType::DT_REQUIRE_LT : return "REQUIRE_LT"; + case assertType::DT_WARN_GE : return "WARN_GE"; + case assertType::DT_CHECK_GE : return "CHECK_GE"; + case assertType::DT_REQUIRE_GE : return "REQUIRE_GE"; + case assertType::DT_WARN_LE : return "WARN_LE"; + case assertType::DT_CHECK_LE : return "CHECK_LE"; + case assertType::DT_REQUIRE_LE : return "REQUIRE_LE"; + + case assertType::DT_WARN_UNARY : return "WARN_UNARY"; + case assertType::DT_CHECK_UNARY : return "CHECK_UNARY"; + case assertType::DT_REQUIRE_UNARY : return "REQUIRE_UNARY"; + case assertType::DT_WARN_UNARY_FALSE : return "WARN_UNARY_FALSE"; + case assertType::DT_CHECK_UNARY_FALSE : return "CHECK_UNARY_FALSE"; + case assertType::DT_REQUIRE_UNARY_FALSE : return "REQUIRE_UNARY_FALSE"; + } + DOCTEST_MSVC_SUPPRESS_WARNING_POP + return ""; +} +// clang-format on + +const char* failureString(assertType::Enum at) { + if(at & assertType::is_warn) //!OCLINT bitwise operator in conditional + return "WARNING: "; + if(at & assertType::is_check) //!OCLINT bitwise operator in conditional + return "ERROR: "; + if(at & assertType::is_require) //!OCLINT bitwise operator in conditional + return "FATAL ERROR: "; + return ""; +} + +DOCTEST_CLANG_SUPPRESS_WARNING_WITH_PUSH("-Wnull-dereference") +DOCTEST_GCC_SUPPRESS_WARNING_WITH_PUSH("-Wnull-dereference") +// depending on the current options this will remove the path of filenames +const char* removePathFromFilename(const char* file) { + if(getContextOptions()->no_path_in_filenames) { + auto back = std::strrchr(file, '\\'); + auto forward = std::strrchr(file, '/'); + if(back || forward) { + if(back > forward) + forward = back; + return forward + 1; + } + } + return file; +} +DOCTEST_CLANG_SUPPRESS_WARNING_POP +DOCTEST_GCC_SUPPRESS_WARNING_POP + +DOCTEST_DEFINE_DEFAULTS(TestCaseData); +DOCTEST_DEFINE_COPIES(TestCaseData); + +DOCTEST_DEFINE_DEFAULTS(AssertData); + +DOCTEST_DEFINE_DEFAULTS(MessageData); + +SubcaseSignature::SubcaseSignature(const char* name, const char* file, int line) + : m_name(name) + , m_file(file) + , m_line(line) {} + +DOCTEST_DEFINE_DEFAULTS(SubcaseSignature); +DOCTEST_DEFINE_COPIES(SubcaseSignature); + +bool SubcaseSignature::operator<(const SubcaseSignature& other) const { + if(m_line != other.m_line) + return m_line < other.m_line; + if(std::strcmp(m_file, other.m_file) != 0) + return std::strcmp(m_file, other.m_file) < 0; + return std::strcmp(m_name, other.m_name) < 0; +} + +IContextScope::IContextScope() = default; +IContextScope::~IContextScope() = default; + +DOCTEST_DEFINE_DEFAULTS(ContextOptions); + +#ifdef DOCTEST_CONFIG_TREAT_CHAR_STAR_AS_STRING +String toString(char* in) { return toString(static_cast(in)); } +String toString(const char* in) { return String("\"") + (in ? in : "{null string}") + "\""; } +#endif // DOCTEST_CONFIG_TREAT_CHAR_STAR_AS_STRING +String toString(bool in) { return in ? "true" : "false"; } +String toString(float in) { return fpToString(in, 5) + "f"; } +String toString(double in) { return fpToString(in, 10); } +String toString(double long in) { return fpToString(in, 15); } + +#define DOCTEST_TO_STRING_OVERLOAD(type, fmt) \ + String toString(type in) { \ + char buf[64]; \ + std::sprintf(buf, fmt, in); \ + return buf; \ + } + +DOCTEST_TO_STRING_OVERLOAD(char, "%d") +DOCTEST_TO_STRING_OVERLOAD(char signed, "%d") +DOCTEST_TO_STRING_OVERLOAD(char unsigned, "%u") +DOCTEST_TO_STRING_OVERLOAD(int short, "%d") +DOCTEST_TO_STRING_OVERLOAD(int short unsigned, "%u") +DOCTEST_TO_STRING_OVERLOAD(int, "%d") +DOCTEST_TO_STRING_OVERLOAD(unsigned, "%u") +DOCTEST_TO_STRING_OVERLOAD(int long, "%ld") +DOCTEST_TO_STRING_OVERLOAD(int long unsigned, "%lu") +DOCTEST_TO_STRING_OVERLOAD(int long long, "%lld") +DOCTEST_TO_STRING_OVERLOAD(int long long unsigned, "%llu") + +String toString(std::nullptr_t) { return "NULL"; } + +Approx::Approx(double value) + : m_epsilon(static_cast(std::numeric_limits::epsilon()) * 100) + , m_scale(1.0) + , m_value(value) {} + +DOCTEST_DEFINE_COPIES(Approx); + +Approx Approx::operator()(double value) const { + Approx approx(value); + approx.epsilon(m_epsilon); + approx.scale(m_scale); + return approx; +} + +Approx& Approx::epsilon(double newEpsilon) { + m_epsilon = newEpsilon; + return *this; +} +Approx& Approx::scale(double newScale) { + m_scale = newScale; + return *this; +} + +bool operator==(double lhs, const Approx& rhs) { + // Thanks to Richard Harris for his help refining this formula + return std::fabs(lhs - rhs.m_value) < + rhs.m_epsilon * (rhs.m_scale + std::max(std::fabs(lhs), std::fabs(rhs.m_value))); +} +bool operator==(const Approx& lhs, double rhs) { return operator==(rhs, lhs); } +bool operator!=(double lhs, const Approx& rhs) { return !operator==(lhs, rhs); } +bool operator!=(const Approx& lhs, double rhs) { return !operator==(rhs, lhs); } +bool operator<=(double lhs, const Approx& rhs) { return lhs < rhs.m_value || lhs == rhs; } +bool operator<=(const Approx& lhs, double rhs) { return lhs.m_value < rhs || lhs == rhs; } +bool operator>=(double lhs, const Approx& rhs) { return lhs > rhs.m_value || lhs == rhs; } +bool operator>=(const Approx& lhs, double rhs) { return lhs.m_value > rhs || lhs == rhs; } +bool operator<(double lhs, const Approx& rhs) { return lhs < rhs.m_value && lhs != rhs; } +bool operator<(const Approx& lhs, double rhs) { return lhs.m_value < rhs && lhs != rhs; } +bool operator>(double lhs, const Approx& rhs) { return lhs > rhs.m_value && lhs != rhs; } +bool operator>(const Approx& lhs, double rhs) { return lhs.m_value > rhs && lhs != rhs; } + +String toString(const Approx& in) { + return String("Approx( ") + doctest::toString(in.m_value) + " )"; +} +const ContextOptions* getContextOptions() { return DOCTEST_BRANCH_ON_DISABLED(nullptr, g_cs); } + +} // namespace doctest + +#ifdef DOCTEST_CONFIG_DISABLE +namespace doctest { +Context::Context(int, const char* const*) {} +Context::~Context() = default; +void Context::applyCommandLine(int, const char* const*) {} +void Context::addFilter(const char*, const char*) {} +void Context::clearFilters() {} +void Context::setOption(const char*, int) {} +void Context::setOption(const char*, const char*) {} +bool Context::shouldExit() { return false; } +void Context::setAsDefaultForAssertsOutOfTestCases() {} +void Context::setAssertHandler(detail::assert_handler) {} +int Context::run() { return 0; } + +DOCTEST_DEFINE_DEFAULTS(CurrentTestCaseStats); + +DOCTEST_DEFINE_DEFAULTS(TestRunStats); + +IReporter::~IReporter() = default; + +int IReporter::get_num_active_contexts() { return 0; } +const IContextScope* const* IReporter::get_active_contexts() { return nullptr; } +int IReporter::get_num_stringified_contexts() { return 0; } +const String* IReporter::get_stringified_contexts() { return nullptr; } + +int registerReporter(const char*, int, IReporter*) { return 0; } + +} // namespace doctest +#else // DOCTEST_CONFIG_DISABLE + +#if !defined(DOCTEST_CONFIG_COLORS_NONE) +#if !defined(DOCTEST_CONFIG_COLORS_WINDOWS) && !defined(DOCTEST_CONFIG_COLORS_ANSI) +#ifdef DOCTEST_PLATFORM_WINDOWS +#define DOCTEST_CONFIG_COLORS_WINDOWS +#else // linux +#define DOCTEST_CONFIG_COLORS_ANSI +#endif // platform +#endif // DOCTEST_CONFIG_COLORS_WINDOWS && DOCTEST_CONFIG_COLORS_ANSI +#endif // DOCTEST_CONFIG_COLORS_NONE + +#if DOCTEST_MSVC || defined(__MINGW32__) +#if DOCTEST_MSVC +#define DOCTEST_WINDOWS_SAL_IN_OPT _In_opt_ +#else // MSVC +#define DOCTEST_WINDOWS_SAL_IN_OPT +#endif // MSVC +extern "C" __declspec(dllimport) void __stdcall OutputDebugStringA( + DOCTEST_WINDOWS_SAL_IN_OPT const char*); +extern "C" __declspec(dllimport) int __stdcall IsDebuggerPresent(); +#endif // MSVC || __MINGW32__ + +#ifdef DOCTEST_CONFIG_COLORS_ANSI +#include +#endif // DOCTEST_CONFIG_COLORS_ANSI + +#ifdef DOCTEST_PLATFORM_WINDOWS + +// defines for a leaner windows.h +#ifndef WIN32_LEAN_AND_MEAN +#define WIN32_LEAN_AND_MEAN +#endif // WIN32_LEAN_AND_MEAN +#ifndef VC_EXTRA_LEAN +#define VC_EXTRA_LEAN +#endif // VC_EXTRA_LEAN +#ifndef NOMINMAX +#define NOMINMAX +#endif // NOMINMAX + +DOCTEST_MAKE_STD_HEADERS_CLEAN_FROM_WARNINGS_ON_WALL_BEGIN + +// not sure what AfxWin.h is for - here I do what Catch does +#ifdef __AFXDLL +#include +#else +#include +#endif +#include + +DOCTEST_MAKE_STD_HEADERS_CLEAN_FROM_WARNINGS_ON_WALL_END + +#else // DOCTEST_PLATFORM_WINDOWS + +#include + +#endif // DOCTEST_PLATFORM_WINDOWS + +namespace doctest_detail_test_suite_ns { +// holds the current test suite +doctest::detail::TestSuite& getCurrentTestSuite() { + static doctest::detail::TestSuite data; + return data; +} +} // namespace doctest_detail_test_suite_ns + +namespace doctest { +namespace { + using namespace detail; + typedef std::map, IReporter*> reporterMap; + reporterMap& getReporters() { + static reporterMap data; + return data; + } +} // namespace +namespace detail { +#define DOCTEST_ITERATE_THROUGH_REPORTERS(function, ...) \ + for(auto& curr_rep : g_cs->reporters_currently_used) \ + curr_rep->function(__VA_ARGS__) + + DOCTEST_DEFINE_DEFAULTS(TestFailureException); + DOCTEST_DEFINE_COPIES(TestFailureException); + bool checkIfShouldThrow(assertType::Enum at) { + if(at & assertType::is_require) //!OCLINT bitwise operator in conditional + return true; + + if((at & assertType::is_check) //!OCLINT bitwise operator in conditional + && getContextOptions()->abort_after > 0 && + (g_cs->numAssertsFailed + g_cs->numAssertsFailedForCurrentTestCase_atomic) >= + getContextOptions()->abort_after) + return true; + + return false; + } + + void throwException() { +#ifndef DOCTEST_CONFIG_NO_EXCEPTIONS + throw TestFailureException(); +#endif // DOCTEST_CONFIG_NO_EXCEPTIONS + } +} // namespace detail + +namespace { + using namespace detail; + // matching of a string against a wildcard mask (case sensitivity configurable) taken from + // https://www.codeproject.com/Articles/1088/Wildcard-string-compare-globbing + int wildcmp(const char* str, const char* wild, bool caseSensitive) { + const char* cp = nullptr; + const char* mp = nullptr; + + while((*str) && (*wild != '*')) { + if((caseSensitive ? (*wild != *str) : (tolower(*wild) != tolower(*str))) && + (*wild != '?')) { + return 0; + } + wild++; + str++; + } + + while(*str) { + if(*wild == '*') { + if(!*++wild) { + return 1; + } + mp = wild; + cp = str + 1; + } else if((caseSensitive ? (*wild == *str) : (tolower(*wild) == tolower(*str))) || + (*wild == '?')) { + wild++; + str++; + } else { + wild = mp; //!OCLINT parameter reassignment + str = cp++; //!OCLINT parameter reassignment + } + } + + while(*wild == '*') { + wild++; + } + return !*wild; + } + + //// C string hash function (djb2) - taken from http://www.cse.yorku.ca/~oz/hash.html + //unsigned hashStr(unsigned const char* str) { + // unsigned long hash = 5381; + // char c; + // while((c = *str++)) + // hash = ((hash << 5) + hash) + c; // hash * 33 + c + // return hash; + //} + + // checks if the name matches any of the filters (and can be configured what to do when empty) + bool matchesAny(const char* name, const std::vector& filters, bool matchEmpty, + bool caseSensitive) { + if(filters.empty() && matchEmpty) + return true; + for(auto& curr : filters) + if(wildcmp(name, curr.c_str(), caseSensitive)) + return true; + return false; + } + +#ifdef DOCTEST_PLATFORM_WINDOWS + + typedef unsigned long long UInt64; + + UInt64 getCurrentTicks() { + static UInt64 hz = 0, hzo = 0; + if(!hz) { + QueryPerformanceFrequency(reinterpret_cast(&hz)); + QueryPerformanceCounter(reinterpret_cast(&hzo)); + } + UInt64 t; + QueryPerformanceCounter(reinterpret_cast(&t)); + return ((t - hzo) * 1000000) / hz; + } +#else // DOCTEST_PLATFORM_WINDOWS + + typedef uint64_t UInt64; + + UInt64 getCurrentTicks() { + timeval t; + gettimeofday(&t, nullptr); + return static_cast(t.tv_sec) * 1000000 + static_cast(t.tv_usec); + } +#endif // DOCTEST_PLATFORM_WINDOWS + + struct Timer + { + void start() { m_ticks = getCurrentTicks(); } + unsigned int getElapsedMicroseconds() const { + return static_cast(getCurrentTicks() - m_ticks); + } + //unsigned int getElapsedMilliseconds() const { + // return static_cast(getElapsedMicroseconds() / 1000); + //} + double getElapsedSeconds() const { return getElapsedMicroseconds() / 1000000.0; } + + private: + UInt64 m_ticks = 0; + }; + + Timer g_timer; +} // namespace +namespace detail { + + Subcase::Subcase(const char* name, const char* file, int line) + : m_signature(name, file, line) { + ContextState* s = g_cs; + + // if we have already completed it + if(s->subcasesPassed.count(m_signature) != 0) + return; + + // check subcase filters + if(s->subcasesCurrentLevel < s->subcase_filter_levels) { + if(!matchesAny(m_signature.m_name, s->filters[6], true, s->case_sensitive)) + return; + if(matchesAny(m_signature.m_name, s->filters[7], false, s->case_sensitive)) + return; + } + + // if a Subcase on the same level has already been entered + if(s->subcasesEnteredLevels.count(s->subcasesCurrentLevel) != 0) { + s->should_reenter = true; + return; + } + + s->subcasesEnteredLevels.insert(s->subcasesCurrentLevel++); + m_entered = true; + + DOCTEST_ITERATE_THROUGH_REPORTERS(subcase_start, m_signature); + } + + Subcase::~Subcase() { + if(m_entered) { + ContextState* s = g_cs; + + s->subcasesCurrentLevel--; + // only mark the subcase as passed if no subcases have been skipped + if(s->should_reenter == false) + s->subcasesPassed.insert(m_signature); + + DOCTEST_ITERATE_THROUGH_REPORTERS(subcase_end, m_signature); + } + } + + Subcase::operator bool() const { return m_entered; } + + Result::Result(bool passed, const String& decomposition) + : m_passed(passed) + , m_decomp(decomposition) {} + + DOCTEST_DEFINE_DEFAULTS(Result); + DOCTEST_DEFINE_COPIES(Result); + + ExpressionDecomposer::ExpressionDecomposer(assertType::Enum at) + : m_at(at) {} + + DOCTEST_DEFINE_DEFAULTS(ExpressionDecomposer); + + DOCTEST_DEFINE_DEFAULTS(TestSuite); + DOCTEST_DEFINE_COPIES(TestSuite); + + TestSuite& TestSuite::operator*(const char* in) { + m_test_suite = in; + // clear state + m_description = nullptr; + m_skip = false; + m_may_fail = false; + m_should_fail = false; + m_expected_failures = 0; + m_timeout = 0; + return *this; + } + + TestCase::TestCase(funcType test, const char* file, unsigned line, const TestSuite& test_suite, + const char* type, int template_id) { + m_file = file; + m_line = line; + m_name = nullptr; + m_test_suite = test_suite.m_test_suite; + m_description = test_suite.m_description; + m_skip = test_suite.m_skip; + m_may_fail = test_suite.m_may_fail; + m_should_fail = test_suite.m_should_fail; + m_expected_failures = test_suite.m_expected_failures; + m_timeout = test_suite.m_timeout; + + m_test = test; + m_type = type; + m_template_id = template_id; + } + + DOCTEST_DEFINE_DEFAULTS(TestCase); + + TestCase::TestCase(const TestCase& other) + : TestCaseData() { + *this = other; + } + + DOCTEST_MSVC_SUPPRESS_WARNING_WITH_PUSH(26434) // hides a non-virtual function + DOCTEST_MSVC_SUPPRESS_WARNING(26437) // Do not slice + TestCase& TestCase::operator=(const TestCase& other) { + static_cast(*this) = static_cast(other); + + m_test = other.m_test; + m_type = other.m_type; + m_template_id = other.m_template_id; + m_full_name = other.m_full_name; + + if(m_template_id != -1) + m_name = m_full_name.c_str(); + return *this; + } + DOCTEST_MSVC_SUPPRESS_WARNING_POP + + TestCase& TestCase::operator*(const char* in) { + m_name = in; + // make a new name with an appended type for templated test case + if(m_template_id != -1) { + m_full_name = String(m_name) + m_type; + // redirect the name to point to the newly constructed full name + m_name = m_full_name.c_str(); + } + return *this; + } + + bool TestCase::operator<(const TestCase& other) const { + if(m_line != other.m_line) + return m_line < other.m_line; + const int file_cmp = std::strcmp(m_file, other.m_file); + if(file_cmp != 0) + return file_cmp < 0; + return m_template_id < other.m_template_id; + } +} // namespace detail +namespace { + using namespace detail; + // for sorting tests by file/line + int fileOrderComparator(const void* a, const void* b) { + auto lhs = *static_cast(a); + auto rhs = *static_cast(b); +#if DOCTEST_MSVC + // this is needed because MSVC gives different case for drive letters + // for __FILE__ when evaluated in a header and a source file + const int res = stricmp(lhs->m_file, rhs->m_file); +#else // MSVC + const int res = std::strcmp(lhs->m_file, rhs->m_file); +#endif // MSVC + if(res != 0) + return res; + return static_cast(lhs->m_line) - static_cast(rhs->m_line); + } + + // for sorting tests by suite/file/line + int suiteOrderComparator(const void* a, const void* b) { + auto lhs = *static_cast(a); + auto rhs = *static_cast(b); + + const int res = std::strcmp(lhs->m_test_suite, rhs->m_test_suite); + if(res != 0) + return res; + return fileOrderComparator(a, b); + } + + // for sorting tests by name/suite/file/line + int nameOrderComparator(const void* a, const void* b) { + auto lhs = *static_cast(a); + auto rhs = *static_cast(b); + + const int res_name = std::strcmp(lhs->m_name, rhs->m_name); + if(res_name != 0) + return res_name; + return suiteOrderComparator(a, b); + } + + // all the registered tests + std::set& getRegisteredTests() { + static std::set data; + return data; + } + +#ifdef DOCTEST_CONFIG_COLORS_WINDOWS + HANDLE g_stdoutHandle; + WORD g_origFgAttrs; + WORD g_origBgAttrs; + bool g_attrsInitted = false; + + int colors_init() { + if(!g_attrsInitted) { + g_stdoutHandle = GetStdHandle(STD_OUTPUT_HANDLE); + g_attrsInitted = true; + CONSOLE_SCREEN_BUFFER_INFO csbiInfo; + GetConsoleScreenBufferInfo(g_stdoutHandle, &csbiInfo); + g_origFgAttrs = csbiInfo.wAttributes & ~(BACKGROUND_GREEN | BACKGROUND_RED | + BACKGROUND_BLUE | BACKGROUND_INTENSITY); + g_origBgAttrs = csbiInfo.wAttributes & ~(FOREGROUND_GREEN | FOREGROUND_RED | + FOREGROUND_BLUE | FOREGROUND_INTENSITY); + } + return 0; + } + + int dumy_init_console_colors = colors_init(); +#endif // DOCTEST_CONFIG_COLORS_WINDOWS + + DOCTEST_CLANG_SUPPRESS_WARNING_WITH_PUSH("-Wdeprecated-declarations") + void color_to_stream(std::ostream& s, Color::Enum code) { + ((void)s); // for DOCTEST_CONFIG_COLORS_NONE or DOCTEST_CONFIG_COLORS_WINDOWS + ((void)code); // for DOCTEST_CONFIG_COLORS_NONE +#ifdef DOCTEST_CONFIG_COLORS_ANSI + if(g_no_colors || + (isatty(STDOUT_FILENO) == false && getContextOptions()->force_colors == false)) + return; + + auto col = ""; + // clang-format off + switch(code) { //!OCLINT missing break in switch statement / unnecessary default statement in covered switch statement + case Color::Red: col = "[0;31m"; break; + case Color::Green: col = "[0;32m"; break; + case Color::Blue: col = "[0;34m"; break; + case Color::Cyan: col = "[0;36m"; break; + case Color::Yellow: col = "[0;33m"; break; + case Color::Grey: col = "[1;30m"; break; + case Color::LightGrey: col = "[0;37m"; break; + case Color::BrightRed: col = "[1;31m"; break; + case Color::BrightGreen: col = "[1;32m"; break; + case Color::BrightWhite: col = "[1;37m"; break; + case Color::Bright: // invalid + case Color::None: + case Color::White: + default: col = "[0m"; + } + // clang-format on + s << "\033" << col; +#endif // DOCTEST_CONFIG_COLORS_ANSI + +#ifdef DOCTEST_CONFIG_COLORS_WINDOWS + if(g_no_colors || + (isatty(fileno(stdout)) == false && getContextOptions()->force_colors == false)) + return; + +#define DOCTEST_SET_ATTR(x) SetConsoleTextAttribute(g_stdoutHandle, x | g_origBgAttrs) + + // clang-format off + switch (code) { + case Color::White: DOCTEST_SET_ATTR(FOREGROUND_GREEN | FOREGROUND_RED | FOREGROUND_BLUE); break; + case Color::Red: DOCTEST_SET_ATTR(FOREGROUND_RED); break; + case Color::Green: DOCTEST_SET_ATTR(FOREGROUND_GREEN); break; + case Color::Blue: DOCTEST_SET_ATTR(FOREGROUND_BLUE); break; + case Color::Cyan: DOCTEST_SET_ATTR(FOREGROUND_BLUE | FOREGROUND_GREEN); break; + case Color::Yellow: DOCTEST_SET_ATTR(FOREGROUND_RED | FOREGROUND_GREEN); break; + case Color::Grey: DOCTEST_SET_ATTR(0); break; + case Color::LightGrey: DOCTEST_SET_ATTR(FOREGROUND_INTENSITY); break; + case Color::BrightRed: DOCTEST_SET_ATTR(FOREGROUND_INTENSITY | FOREGROUND_RED); break; + case Color::BrightGreen: DOCTEST_SET_ATTR(FOREGROUND_INTENSITY | FOREGROUND_GREEN); break; + case Color::BrightWhite: DOCTEST_SET_ATTR(FOREGROUND_INTENSITY | FOREGROUND_GREEN | FOREGROUND_RED | FOREGROUND_BLUE); break; + case Color::None: + case Color::Bright: // invalid + default: DOCTEST_SET_ATTR(g_origFgAttrs); + } + // clang-format on +#endif // DOCTEST_CONFIG_COLORS_WINDOWS + } + DOCTEST_CLANG_SUPPRESS_WARNING_POP + + std::vector& getExceptionTranslators() { + static std::vector data; + return data; + } + + String translateActiveException() { +#ifndef DOCTEST_CONFIG_NO_EXCEPTIONS + String res; + auto& translators = getExceptionTranslators(); + for(auto& curr : translators) + if(curr->translate(res)) + return res; + // clang-format off + try { + throw; + } catch(std::exception& ex) { + return ex.what(); + } catch(std::string& msg) { + return msg.c_str(); + } catch(const char* msg) { + return msg; + } catch(...) { + return "unknown exception"; + } +// clang-format on +#else // DOCTEST_CONFIG_NO_EXCEPTIONS + return ""; +#endif // DOCTEST_CONFIG_NO_EXCEPTIONS + } +} // namespace + +namespace detail { + // used by the macros for registering tests + int regTest(const TestCase& tc) { + getRegisteredTests().insert(tc); + return 0; + } + + // sets the current test suite + int setTestSuite(const TestSuite& ts) { + doctest_detail_test_suite_ns::getCurrentTestSuite() = ts; + return 0; + } + +#ifdef DOCTEST_PLATFORM_MAC + // The following function is taken directly from the following technical note: + // http://developer.apple.com/library/mac/#qa/qa2004/qa1361.html + // Returns true if the current process is being debugged (either + // running under the debugger or has a debugger attached post facto). + bool isDebuggerActive() { + int mib[4]; + kinfo_proc info; + size_t size; + // Initialize the flags so that, if sysctl fails for some bizarre + // reason, we get a predictable result. + info.kp_proc.p_flag = 0; + // Initialize mib, which tells sysctl the info we want, in this case + // we're looking for information about a specific process ID. + mib[0] = CTL_KERN; + mib[1] = KERN_PROC; + mib[2] = KERN_PROC_PID; + mib[3] = getpid(); + // Call sysctl. + size = sizeof(info); + if(sysctl(mib, DOCTEST_COUNTOF(mib), &info, &size, 0, 0) != 0) { + fprintf(stderr, "\n** Call to sysctl failed - unable to determine if debugger is " + "active **\n\n"); + return false; + } + // We're being debugged if the P_TRACED flag is set. + return ((info.kp_proc.p_flag & P_TRACED) != 0); + } +#elif DOCTEST_MSVC || defined(__MINGW32__) + bool isDebuggerActive() { return ::IsDebuggerPresent() != 0; } +#else + bool isDebuggerActive() { return false; } +#endif // Platform + + void registerExceptionTranslatorImpl(const IExceptionTranslator* et) { + if(std::find(getExceptionTranslators().begin(), getExceptionTranslators().end(), et) == + getExceptionTranslators().end()) + getExceptionTranslators().push_back(et); + } + + void writeStringToStream(std::ostream* s, const String& str) { *s << str; } + +#ifdef DOCTEST_CONFIG_TREAT_CHAR_STAR_AS_STRING + void toStream(std::ostream* s, char* in) { *s << in; } + void toStream(std::ostream* s, const char* in) { *s << in; } +#endif // DOCTEST_CONFIG_TREAT_CHAR_STAR_AS_STRING + void toStream(std::ostream* s, bool in) { *s << std::boolalpha << in << std::noboolalpha; } + void toStream(std::ostream* s, float in) { *s << in; } + void toStream(std::ostream* s, double in) { *s << in; } + void toStream(std::ostream* s, double long in) { *s << in; } + + void toStream(std::ostream* s, char in) { *s << in; } + void toStream(std::ostream* s, char signed in) { *s << in; } + void toStream(std::ostream* s, char unsigned in) { *s << in; } + void toStream(std::ostream* s, int short in) { *s << in; } + void toStream(std::ostream* s, int short unsigned in) { *s << in; } + void toStream(std::ostream* s, int in) { *s << in; } + void toStream(std::ostream* s, int unsigned in) { *s << in; } + void toStream(std::ostream* s, int long in) { *s << in; } + void toStream(std::ostream* s, int long unsigned in) { *s << in; } + void toStream(std::ostream* s, int long long in) { *s << in; } + void toStream(std::ostream* s, int long long unsigned in) { *s << in; } + + DOCTEST_THREAD_LOCAL std::vector g_infoContexts; // for logging with INFO() + + ContextBuilder::ICapture::ICapture() = default; + ContextBuilder::ICapture::~ICapture() = default; + + ContextBuilder::Chunk::Chunk() = default; + ContextBuilder::Chunk::~Chunk() = default; + + ContextBuilder::Node::Node() = default; + ContextBuilder::Node::~Node() = default; + + // steal the contents of the other - acting as a move constructor... + ContextBuilder::ContextBuilder(ContextBuilder& other) + : numCaptures(other.numCaptures) + , head(other.head) + , tail(other.tail) { + other.numCaptures = 0; + other.head = nullptr; + other.tail = nullptr; + memcpy(stackChunks, other.stackChunks, + unsigned(int(sizeof(Chunk)) * DOCTEST_CONFIG_NUM_CAPTURES_ON_STACK)); + } + + DOCTEST_GCC_SUPPRESS_WARNING_WITH_PUSH("-Wcast-align") + void ContextBuilder::stringify(std::ostream* s) const { + int curr = 0; + // iterate over small buffer + while(curr < numCaptures && curr < DOCTEST_CONFIG_NUM_CAPTURES_ON_STACK) + reinterpret_cast(stackChunks[curr++].buf)->toStream(s); + // iterate over list + auto curr_elem = head; + while(curr < numCaptures) { + reinterpret_cast(curr_elem->chunk.buf)->toStream(s); + curr_elem = curr_elem->next; + ++curr; + } + } + DOCTEST_GCC_SUPPRESS_WARNING_POP + + ContextBuilder::ContextBuilder() = default; + + ContextBuilder::~ContextBuilder() { + // free the linked list - the ones on the stack are left as-is + // no destructors are called at all - there is no need + while(head) { + auto next = head->next; + delete head; + head = next; + } + } + + ContextScope::ContextScope(ContextBuilder& temp) + : contextBuilder(temp) { + g_infoContexts.push_back(this); + } + + DOCTEST_MSVC_SUPPRESS_WARNING_WITH_PUSH(4996) // std::uncaught_exception is deprecated in C++17 + DOCTEST_GCC_SUPPRESS_WARNING_WITH_PUSH("-Wdeprecated-declarations") + DOCTEST_CLANG_SUPPRESS_WARNING_WITH_PUSH("-Wdeprecated-declarations") + ContextScope::~ContextScope() { + if(std::uncaught_exception()) { + std::ostringstream s; + this->stringify(&s); + g_cs->stringifiedContexts.push_back(s.str().c_str()); + } + g_infoContexts.pop_back(); + } + DOCTEST_CLANG_SUPPRESS_WARNING_POP + DOCTEST_GCC_SUPPRESS_WARNING_POP + DOCTEST_MSVC_SUPPRESS_WARNING_POP + + void ContextScope::stringify(std::ostream* s) const { contextBuilder.stringify(s); } +} // namespace detail +namespace { + using namespace detail; +#if !defined(DOCTEST_CONFIG_POSIX_SIGNALS) && !defined(DOCTEST_CONFIG_WINDOWS_SEH) + struct FatalConditionHandler + { + void reset() {} + }; +#else // DOCTEST_CONFIG_POSIX_SIGNALS || DOCTEST_CONFIG_WINDOWS_SEH + + void reportFatal(const std::string&); + +#ifdef DOCTEST_PLATFORM_WINDOWS + + struct SignalDefs + { + DWORD id; + const char* name; + }; + // There is no 1-1 mapping between signals and windows exceptions. + // Windows can easily distinguish between SO and SigSegV, + // but SigInt, SigTerm, etc are handled differently. + SignalDefs signalDefs[] = { + {EXCEPTION_ILLEGAL_INSTRUCTION, "SIGILL - Illegal instruction signal"}, + {EXCEPTION_STACK_OVERFLOW, "SIGSEGV - Stack overflow"}, + {EXCEPTION_ACCESS_VIOLATION, "SIGSEGV - Segmentation violation signal"}, + {EXCEPTION_INT_DIVIDE_BY_ZERO, "Divide by zero error"}, + }; + + struct FatalConditionHandler + { + static LONG CALLBACK handleVectoredException(PEXCEPTION_POINTERS ExceptionInfo) { + for(size_t i = 0; i < DOCTEST_COUNTOF(signalDefs); ++i) { + if(ExceptionInfo->ExceptionRecord->ExceptionCode == signalDefs[i].id) { + reportFatal(signalDefs[i].name); + } + } + // If its not an exception we care about, pass it along. + // This stops us from eating debugger breaks etc. + return EXCEPTION_CONTINUE_SEARCH; + } + + FatalConditionHandler() { + isSet = true; + // 32k seems enough for doctest to handle stack overflow, + // but the value was found experimentally, so there is no strong guarantee + guaranteeSize = 32 * 1024; + exceptionHandlerHandle = nullptr; + // Register as first handler in current chain + exceptionHandlerHandle = AddVectoredExceptionHandler(1, handleVectoredException); + // Pass in guarantee size to be filled + SetThreadStackGuarantee(&guaranteeSize); + } + + static void reset() { + if(isSet) { + // Unregister handler and restore the old guarantee + RemoveVectoredExceptionHandler(exceptionHandlerHandle); + SetThreadStackGuarantee(&guaranteeSize); + exceptionHandlerHandle = nullptr; + isSet = false; + } + } + + ~FatalConditionHandler() { reset(); } + + private: + static bool isSet; + static ULONG guaranteeSize; + static PVOID exceptionHandlerHandle; + }; + + bool FatalConditionHandler::isSet = false; + ULONG FatalConditionHandler::guaranteeSize = 0; + PVOID FatalConditionHandler::exceptionHandlerHandle = nullptr; + +#else // DOCTEST_PLATFORM_WINDOWS + + struct SignalDefs + { + int id; + const char* name; + }; + SignalDefs signalDefs[] = {{SIGINT, "SIGINT - Terminal interrupt signal"}, + {SIGILL, "SIGILL - Illegal instruction signal"}, + {SIGFPE, "SIGFPE - Floating point error signal"}, + {SIGSEGV, "SIGSEGV - Segmentation violation signal"}, + {SIGTERM, "SIGTERM - Termination request signal"}, + {SIGABRT, "SIGABRT - Abort (abnormal termination) signal"}}; + + struct FatalConditionHandler + { + static bool isSet; + static struct sigaction oldSigActions[DOCTEST_COUNTOF(signalDefs)]; + static stack_t oldSigStack; + static char altStackMem[4 * SIGSTKSZ]; + + static void handleSignal(int sig) { + const char* name = ""; + for(std::size_t i = 0; i < DOCTEST_COUNTOF(signalDefs); ++i) { + SignalDefs& def = signalDefs[i]; + if(sig == def.id) { + name = def.name; + break; + } + } + reset(); + reportFatal(name); + raise(sig); + } + + FatalConditionHandler() { + isSet = true; + stack_t sigStack; + sigStack.ss_sp = altStackMem; + sigStack.ss_size = sizeof(altStackMem); + sigStack.ss_flags = 0; + sigaltstack(&sigStack, &oldSigStack); + struct sigaction sa = {}; + sa.sa_handler = handleSignal; // NOLINT + sa.sa_flags = SA_ONSTACK; + for(std::size_t i = 0; i < DOCTEST_COUNTOF(signalDefs); ++i) { + sigaction(signalDefs[i].id, &sa, &oldSigActions[i]); + } + } + + ~FatalConditionHandler() { reset(); } + static void reset() { + if(isSet) { + // Set signals back to previous values -- hopefully nobody overwrote them in the meantime + for(std::size_t i = 0; i < DOCTEST_COUNTOF(signalDefs); ++i) { + sigaction(signalDefs[i].id, &oldSigActions[i], nullptr); + } + // Return the old stack + sigaltstack(&oldSigStack, nullptr); + isSet = false; + } + } + }; + + bool FatalConditionHandler::isSet = false; + struct sigaction FatalConditionHandler::oldSigActions[DOCTEST_COUNTOF(signalDefs)] = {}; + stack_t FatalConditionHandler::oldSigStack = {}; + char FatalConditionHandler::altStackMem[] = {}; + +#endif // DOCTEST_PLATFORM_WINDOWS +#endif // DOCTEST_CONFIG_POSIX_SIGNALS || DOCTEST_CONFIG_WINDOWS_SEH + +} // namespace + +namespace { + using namespace detail; + +#ifdef DOCTEST_PLATFORM_WINDOWS +#define DOCTEST_OUTPUT_DEBUG_STRING(text) ::OutputDebugStringA(text) +#else + // TODO: integration with XCode and other IDEs +#define DOCTEST_OUTPUT_DEBUG_STRING(text) +#endif // Platform + + void addAssert(assertType::Enum at) { + if((at & assertType::is_warn) == 0) //!OCLINT bitwise operator in conditional + g_cs->numAssertsForCurrentTestCase_atomic++; + } + + void addFailedAssert(assertType::Enum at) { + if((at & assertType::is_warn) == 0) //!OCLINT bitwise operator in conditional + g_cs->numAssertsFailedForCurrentTestCase_atomic++; + } + +#if defined(DOCTEST_CONFIG_POSIX_SIGNALS) || defined(DOCTEST_CONFIG_WINDOWS_SEH) + void reportFatal(const std::string& message) { + g_cs->seconds_so_far += g_timer.getElapsedSeconds(); + g_cs->failure_flags |= TestCaseFailureReason::Crash; + g_cs->error_string = message.c_str(); + g_cs->should_reenter = false; + + // TODO: end all currently opened subcases...? + + DOCTEST_ITERATE_THROUGH_REPORTERS(test_case_end, *g_cs); + + g_cs->numTestCasesFailed++; + + DOCTEST_ITERATE_THROUGH_REPORTERS(test_run_end, *g_cs); + } +#endif // DOCTEST_CONFIG_POSIX_SIGNALS || DOCTEST_CONFIG_WINDOWS_SEH +} // namespace +namespace detail { + + ResultBuilder::ResultBuilder(assertType::Enum at, const char* file, int line, const char* expr, + const char* exception_type) { + m_test_case = g_cs->currentTest; + m_at = at; + m_file = file; + m_line = line; + m_expr = expr; + m_failed = true; + m_threw = false; + m_threw_as = false; + m_exception_type = exception_type; +#if DOCTEST_MSVC + if(m_expr[0] == ' ') // this happens when variadic macros are disabled under MSVC + ++m_expr; +#endif // MSVC + } + + DOCTEST_DEFINE_DEFAULTS(ResultBuilder); + + void ResultBuilder::setResult(const Result& res) { + m_decomp = res.m_decomp; + m_failed = !res.m_passed; + } + + void ResultBuilder::translateException() { + m_threw = true; + m_exception = translateActiveException(); + } + + bool ResultBuilder::log() { + if(m_at & assertType::is_throws) { //!OCLINT bitwise operator in conditional + m_failed = !m_threw; + } else if(m_at & assertType::is_throws_as) { //!OCLINT bitwise operator in conditional + m_failed = !m_threw_as; + } else if(m_at & assertType::is_throws_with) { //!OCLINT bitwise operator in conditional + m_failed = m_exception != m_exception_type; + } else if(m_at & assertType::is_nothrow) { //!OCLINT bitwise operator in conditional + m_failed = m_threw; + } + + if(m_exception.size()) + m_exception = String("\"") + m_exception + "\""; + + if(is_running_in_test) { + addAssert(m_at); + DOCTEST_ITERATE_THROUGH_REPORTERS(log_assert, *this); + + if(m_failed) + addFailedAssert(m_at); + } else if(m_failed) { + failed_out_of_a_testing_context(*this); + } + + return m_failed && isDebuggerActive() && + !getContextOptions()->no_breaks; // break into debugger + } + + void ResultBuilder::react() const { + if(m_failed && checkIfShouldThrow(m_at)) + throwException(); + } + + void failed_out_of_a_testing_context(const AssertData& ad) { + if(g_cs->ah) + g_cs->ah(ad); + else + std::abort(); + } + + void decomp_assert(assertType::Enum at, const char* file, int line, const char* expr, + Result result) { + bool failed = !result.m_passed; + + // ################################################################################### + // IF THE DEBUGGER BREAKS HERE - GO 1 LEVEL UP IN THE CALLSTACK FOR THE FAILING ASSERT + // THIS IS THE EFFECT OF HAVING 'DOCTEST_CONFIG_SUPER_FAST_ASSERTS' DEFINED + // ################################################################################### + DOCTEST_ASSERT_OUT_OF_TESTS(result.m_decomp); + DOCTEST_ASSERT_IN_TESTS(result.m_decomp); + } + + MessageBuilder::MessageBuilder(const char* file, int line, assertType::Enum severity) { + m_stream = getTlsOss(); + m_file = file; + m_line = line; + m_severity = severity; + } + + IExceptionTranslator::IExceptionTranslator() = default; + IExceptionTranslator::~IExceptionTranslator() = default; + + bool MessageBuilder::log() { + m_string = getTlsOssResult(); + DOCTEST_ITERATE_THROUGH_REPORTERS(log_message, *this); + + const bool isWarn = m_severity & assertType::is_warn; + + // warn is just a message in this context so we dont treat it as an assert + if(!isWarn) { + addAssert(m_severity); + addFailedAssert(m_severity); + } + + return isDebuggerActive() && !getContextOptions()->no_breaks && !isWarn; // break + } + + void MessageBuilder::react() { + if(m_severity & assertType::is_require) //!OCLINT bitwise operator in conditional + throwException(); + } + + MessageBuilder::~MessageBuilder() = default; +} // namespace detail +namespace { + std::mutex g_mutex; + + using namespace detail; + struct ConsoleReporter : public IReporter + { + std::ostream& s; + bool hasLoggedCurrentTestStart; + std::vector subcasesStack; + + // caching pointers to objects of these types - safe to do + const ContextOptions* opt; + const TestCaseData* tc; + + ConsoleReporter(std::ostream& in) + : s(in) {} + + // ========================================================================================= + // WHAT FOLLOWS ARE HELPERS USED BY THE OVERRIDES OF THE VIRTUAL METHODS OF THE INTERFACE + // ========================================================================================= + + void separator_to_stream() { + s << Color::Yellow + << "=============================================================================" + "==" + "\n"; + } + + void file_line_to_stream(const char* file, int line, const char* tail = "") { + s << Color::LightGrey << removePathFromFilename(file) + << (opt->gnu_file_line ? ":" : "(") + << (opt->no_line_numbers ? 0 : line) // 0 or the real num depending on the option + << (opt->gnu_file_line ? ":" : "):") << tail; + } + + const char* getSuccessOrFailString(bool success, assertType::Enum at, + const char* success_str) { + if(success) + return success_str; + return failureString(at); + } + + Color::Enum getSuccessOrFailColor(bool success, assertType::Enum at) { + return success ? Color::BrightGreen : + (at & assertType::is_warn) ? Color::Yellow : Color::Red; + } + + void successOrFailColoredStringToStream(bool success, assertType::Enum at, + const char* success_str = "SUCCESS: ") { + s << getSuccessOrFailColor(success, at) + << getSuccessOrFailString(success, at, success_str); + } + + void log_contexts() { + int num_contexts = get_num_active_contexts(); + if(num_contexts) { + auto contexts = get_active_contexts(); + + s << Color::None << " logged: "; + for(int i = 0; i < num_contexts; ++i) { + s << (i == 0 ? "" : " "); + contexts[i]->stringify(&s); + s << "\n"; + } + } + + s << "\n"; + } + + void logTestStart() { + if(hasLoggedCurrentTestStart) + return; + + separator_to_stream(); + file_line_to_stream(tc->m_file, tc->m_line, "\n"); + if(tc->m_description) + s << Color::Yellow << "DESCRIPTION: " << Color::None << tc->m_description << "\n"; + if(tc->m_test_suite && tc->m_test_suite[0] != '\0') + s << Color::Yellow << "TEST SUITE: " << Color::None << tc->m_test_suite << "\n"; + if(strncmp(tc->m_name, " Scenario:", 11) != 0) + s << Color::None << "TEST CASE: "; + s << Color::None << tc->m_name << "\n"; + + for(auto& curr : subcasesStack) + if(curr.m_name[0] != '\0') + s << " " << curr.m_name << "\n"; + + s << "\n"; + + hasLoggedCurrentTestStart = true; + } + + // ========================================================================================= + // WHAT FOLLOWS ARE OVERRIDES OF THE VIRTUAL METHODS OF THE REPORTER INTERFACE + // ========================================================================================= + + void test_run_start(const ContextOptions& o) override { opt = &o; } + + void test_run_end(const TestRunStats& p) override { + separator_to_stream(); + + const bool anythingFailed = p.numTestCasesFailed > 0 || p.numAssertsFailed > 0; + s << Color::Cyan << "[doctest] " << Color::None << "test cases: " << std::setw(6) + << p.numTestCasesPassingFilters << " | " + << ((p.numTestCasesPassingFilters == 0 || anythingFailed) ? Color::None : + Color::Green) + << std::setw(6) << p.numTestCasesPassingFilters - p.numTestCasesFailed << " passed" + << Color::None << " | " << (p.numTestCasesFailed > 0 ? Color::Red : Color::None) + << std::setw(6) << p.numTestCasesFailed << " failed" << Color::None << " | "; + if(opt->no_skipped_summary == false) { + const int numSkipped = p.numTestCases - p.numTestCasesPassingFilters; + s << (numSkipped == 0 ? Color::None : Color::Yellow) << std::setw(6) << numSkipped + << " skipped" << Color::None; + } + s << "\n"; + s << Color::Cyan << "[doctest] " << Color::None << "assertions: " << std::setw(6) + << p.numAsserts << " | " + << ((p.numAsserts == 0 || anythingFailed) ? Color::None : Color::Green) + << std::setw(6) << (p.numAsserts - p.numAssertsFailed) << " passed" << Color::None + << " | " << (p.numAssertsFailed > 0 ? Color::Red : Color::None) << std::setw(6) + << p.numAssertsFailed << " failed" << Color::None << " |\n"; + s << Color::Cyan << "[doctest] " << Color::None + << "Status: " << (p.numTestCasesFailed > 0 ? Color::Red : Color::Green) + << ((p.numTestCasesFailed > 0) ? "FAILURE!\n" : "SUCCESS!\n") << Color::None; + } + + void test_case_start(const TestCaseData& in) override { + hasLoggedCurrentTestStart = false; + tc = ∈ + } + + void test_case_end(const CurrentTestCaseStats& st) override { + // log the preamble of the test case only if there is something + // else to print - something other than that an assert has failed + if(opt->duration || + (st.failure_flags && st.failure_flags != TestCaseFailureReason::AssertFailure)) + logTestStart(); + + // report test case exceptions and crashes + bool crashed = st.failure_flags & TestCaseFailureReason::Crash; + if(crashed || (st.failure_flags & TestCaseFailureReason::Exception)) { + file_line_to_stream(tc->m_file, tc->m_line, " "); + successOrFailColoredStringToStream(false, crashed ? assertType::is_require : + assertType::is_check); + s << Color::Red << (crashed ? "test case CRASHED: " : "test case THREW exception: ") + << Color::Cyan << st.error_string << "\n"; + + int num_stringified_contexts = get_num_stringified_contexts(); + if(num_stringified_contexts) { + auto stringified_contexts = get_stringified_contexts(); + s << Color::None << " logged: "; + for(int i = num_stringified_contexts - 1; i >= 0; --i) { + s << (i == num_stringified_contexts - 1 ? "" : " ") + << stringified_contexts[i] << "\n"; + } + } + s << "\n"; + } + + // means the test case will be re-entered because there are untraversed (but discovered) subcases + if(st.should_reenter) + return; + + if(opt->duration) + s << Color::None << std::setprecision(6) << std::fixed << st.seconds_so_far + << " s: " << tc->m_name << "\n"; + + if(st.failure_flags & TestCaseFailureReason::Timeout) + s << Color::Red << "Test case exceeded time limit of " << std::setprecision(6) + << std::fixed << tc->m_timeout << "!\n"; + + if(st.failure_flags & TestCaseFailureReason::ShouldHaveFailedButDidnt) { + s << Color::Red << "Should have failed but didn't! Marking it as failed!\n"; + } else if(st.failure_flags & TestCaseFailureReason::ShouldHaveFailedAndDid) { + s << Color::Yellow << "Failed as expected so marking it as not failed\n"; + } else if(st.failure_flags & TestCaseFailureReason::CouldHaveFailedAndDid) { + s << Color::Yellow << "Allowed to fail so marking it as not failed\n"; + } else if(st.failure_flags & TestCaseFailureReason::DidntFailExactlyNumTimes) { + s << Color::Red << "Didn't fail exactly " << tc->m_expected_failures + << " times so marking it as failed!\n"; + } else if(st.failure_flags & TestCaseFailureReason::FailedExactlyNumTimes) { + s << Color::Yellow << "Failed exactly " << tc->m_expected_failures + << " times as expected so marking it as not failed!\n"; + } + if(st.failure_flags & TestCaseFailureReason::TooManyFailedAsserts) { + s << Color::Red << "Aborting - too many failed asserts!\n"; + } + s << Color::None; + } + + void subcase_start(const SubcaseSignature& subc) override { + subcasesStack.push_back(subc); + hasLoggedCurrentTestStart = false; + } + + void subcase_end(const SubcaseSignature& /*subc*/) override { + subcasesStack.pop_back(); + hasLoggedCurrentTestStart = false; + } + + void log_assert(const AssertData& rb) override { + if(!rb.m_failed && !opt->success) + return; + + std::lock_guard lock(g_mutex); + + logTestStart(); + + file_line_to_stream(rb.m_file, rb.m_line, " "); + successOrFailColoredStringToStream(!rb.m_failed, rb.m_at); + if((rb.m_at & (assertType::is_throws_as | assertType::is_throws_with)) == + 0) //!OCLINT bitwise operator in conditional + s << Color::Cyan << assertString(rb.m_at) << "( " << rb.m_expr << " ) " + << Color::None; + + if(rb.m_at & assertType::is_throws) { //!OCLINT bitwise operator in conditional + s << (rb.m_threw ? "threw as expected!" : "did NOT throw at all!") << "\n"; + } else if(rb.m_at & + assertType::is_throws_as) { //!OCLINT bitwise operator in conditional + s << Color::Cyan << assertString(rb.m_at) << "( " << rb.m_expr << ", " + << rb.m_exception_type << " ) " << Color::None + << (rb.m_threw ? (rb.m_threw_as ? "threw as expected!" : + "threw a DIFFERENT exception: ") : + "did NOT throw at all!") + << Color::Cyan << rb.m_exception << "\n"; + } else if(rb.m_at & + assertType::is_throws_with) { //!OCLINT bitwise operator in conditional + s << Color::Cyan << assertString(rb.m_at) << "( " << rb.m_expr << ", \"" + << rb.m_exception_type << "\" ) " << Color::None + << (rb.m_threw ? (!rb.m_failed ? "threw as expected!" : + "threw a DIFFERENT exception: ") : + "did NOT throw at all!") + << Color::Cyan << rb.m_exception << "\n"; + } else if(rb.m_at & assertType::is_nothrow) { //!OCLINT bitwise operator in conditional + s << (rb.m_threw ? "THREW exception: " : "didn't throw!") << Color::Cyan + << rb.m_exception << "\n"; + } else { + s << (rb.m_threw ? "THREW exception: " : + (!rb.m_failed ? "is correct!\n" : "is NOT correct!\n")); + if(rb.m_threw) + s << rb.m_exception << "\n"; + else + s << " values: " << assertString(rb.m_at) << "( " << rb.m_decomp << " )\n"; + } + + log_contexts(); + } + + void log_message(const MessageData& mb) override { + std::lock_guard lock(g_mutex); + + logTestStart(); + + file_line_to_stream(mb.m_file, mb.m_line, " "); + s << getSuccessOrFailColor(false, mb.m_severity) + << getSuccessOrFailString(mb.m_severity & assertType::is_warn, mb.m_severity, + "MESSAGE: "); + s << Color::None << mb.m_string << "\n"; + log_contexts(); + } + + void test_case_skipped(const TestCaseData&) override {} + }; + + struct Whitespace + { + int nrSpaces; + explicit Whitespace(int nr) + : nrSpaces(nr) {} + }; + + std::ostream& operator<<(std::ostream& out, const Whitespace& ws) { + if(ws.nrSpaces != 0) + out << std::setw(ws.nrSpaces) << ' '; + return out; + } + + // extension of the console reporter - with a bunch of helpers for the stdout stream redirection + struct ConsoleReporterWithHelpers : public ConsoleReporter + { + ConsoleReporterWithHelpers(std::ostream& in) + : ConsoleReporter(in) {} + + void printVersion() { + if(getContextOptions()->no_version == false) + s << Color::Cyan << "[doctest] " << Color::None << "doctest version is \"" + << DOCTEST_VERSION_STR << "\"\n"; + } + + void printIntro() { + printVersion(); + s << Color::Cyan << "[doctest] " << Color::None + << "run with \"--" DOCTEST_OPTIONS_PREFIX_DISPLAY "help\" for options\n"; + } + + void printHelp() { + int sizePrefixDisplay = static_cast(strlen(DOCTEST_OPTIONS_PREFIX_DISPLAY)); + printVersion(); + // clang-format off + s << Color::Cyan << "[doctest]\n" << Color::None; + s << Color::Cyan << "[doctest] " << Color::None; + s << "boolean values: \"1/on/yes/true\" or \"0/off/no/false\"\n"; + s << Color::Cyan << "[doctest] " << Color::None; + s << "filter values: \"str1,str2,str3\" (comma separated strings)\n"; + s << Color::Cyan << "[doctest]\n" << Color::None; + s << Color::Cyan << "[doctest] " << Color::None; + s << "filters use wildcards for matching strings\n"; + s << Color::Cyan << "[doctest] " << Color::None; + s << "something passes a filter if any of the strings in a filter matches\n"; +#ifndef DOCTEST_CONFIG_NO_UNPREFIXED_OPTIONS + s << Color::Cyan << "[doctest]\n" << Color::None; + s << Color::Cyan << "[doctest] " << Color::None; + s << "ALL FLAGS, OPTIONS AND FILTERS ALSO AVAILABLE WITH A \"" DOCTEST_CONFIG_OPTIONS_PREFIX "\" PREFIX!!!\n"; +#endif + s << Color::Cyan << "[doctest]\n" << Color::None; + s << Color::Cyan << "[doctest] " << Color::None; + s << "Query flags - the program quits after them. Available:\n\n"; + s << " -" DOCTEST_OPTIONS_PREFIX_DISPLAY "?, --" DOCTEST_OPTIONS_PREFIX_DISPLAY "help, -" DOCTEST_OPTIONS_PREFIX_DISPLAY "h " + << Whitespace(sizePrefixDisplay*0) << "prints this message\n"; + s << " -" DOCTEST_OPTIONS_PREFIX_DISPLAY "v, --" DOCTEST_OPTIONS_PREFIX_DISPLAY "version " + << Whitespace(sizePrefixDisplay*1) << "prints the version\n"; + s << " -" DOCTEST_OPTIONS_PREFIX_DISPLAY "c, --" DOCTEST_OPTIONS_PREFIX_DISPLAY "count " + << Whitespace(sizePrefixDisplay*1) << "prints the number of matching tests\n"; + s << " -" DOCTEST_OPTIONS_PREFIX_DISPLAY "ltc, --" DOCTEST_OPTIONS_PREFIX_DISPLAY "list-test-cases " + << Whitespace(sizePrefixDisplay*1) << "lists all matching tests by name\n"; + s << " -" DOCTEST_OPTIONS_PREFIX_DISPLAY "lts, --" DOCTEST_OPTIONS_PREFIX_DISPLAY "list-test-suites " + << Whitespace(sizePrefixDisplay*1) << "lists all matching test suites\n"; + s << " -" DOCTEST_OPTIONS_PREFIX_DISPLAY "lr, --" DOCTEST_OPTIONS_PREFIX_DISPLAY "list-reporters " + << Whitespace(sizePrefixDisplay*1) << "lists all registered reporters\n\n"; + // ================================================================================== << 79 + s << Color::Cyan << "[doctest] " << Color::None; + s << "The available / options/filters are:\n\n"; + s << " -" DOCTEST_OPTIONS_PREFIX_DISPLAY "tc, --" DOCTEST_OPTIONS_PREFIX_DISPLAY "test-case= " + << Whitespace(sizePrefixDisplay*1) << "filters tests by their name\n"; + s << " -" DOCTEST_OPTIONS_PREFIX_DISPLAY "tce, --" DOCTEST_OPTIONS_PREFIX_DISPLAY "test-case-exclude= " + << Whitespace(sizePrefixDisplay*1) << "filters OUT tests by their name\n"; + s << " -" DOCTEST_OPTIONS_PREFIX_DISPLAY "sf, --" DOCTEST_OPTIONS_PREFIX_DISPLAY "source-file= " + << Whitespace(sizePrefixDisplay*1) << "filters tests by their file\n"; + s << " -" DOCTEST_OPTIONS_PREFIX_DISPLAY "sfe, --" DOCTEST_OPTIONS_PREFIX_DISPLAY "source-file-exclude= " + << Whitespace(sizePrefixDisplay*1) << "filters OUT tests by their file\n"; + s << " -" DOCTEST_OPTIONS_PREFIX_DISPLAY "ts, --" DOCTEST_OPTIONS_PREFIX_DISPLAY "test-suite= " + << Whitespace(sizePrefixDisplay*1) << "filters tests by their test suite\n"; + s << " -" DOCTEST_OPTIONS_PREFIX_DISPLAY "tse, --" DOCTEST_OPTIONS_PREFIX_DISPLAY "test-suite-exclude= " + << Whitespace(sizePrefixDisplay*1) << "filters OUT tests by their test suite\n"; + s << " -" DOCTEST_OPTIONS_PREFIX_DISPLAY "sc, --" DOCTEST_OPTIONS_PREFIX_DISPLAY "subcase= " + << Whitespace(sizePrefixDisplay*1) << "filters subcases by their name\n"; + s << " -" DOCTEST_OPTIONS_PREFIX_DISPLAY "sce, --" DOCTEST_OPTIONS_PREFIX_DISPLAY "subcase-exclude= " + << Whitespace(sizePrefixDisplay*1) << "filters OUT subcases by their name\n"; + s << " -" DOCTEST_OPTIONS_PREFIX_DISPLAY "r, --" DOCTEST_OPTIONS_PREFIX_DISPLAY "reporters= " + << Whitespace(sizePrefixDisplay*1) << "reporters to use (console is default)\n"; + s << " -" DOCTEST_OPTIONS_PREFIX_DISPLAY "ob, --" DOCTEST_OPTIONS_PREFIX_DISPLAY "order-by= " + << Whitespace(sizePrefixDisplay*1) << "how the tests should be ordered\n"; + s << Whitespace(sizePrefixDisplay*3) << " - by [file/suite/name/rand]\n"; + s << " -" DOCTEST_OPTIONS_PREFIX_DISPLAY "rs, --" DOCTEST_OPTIONS_PREFIX_DISPLAY "rand-seed= " + << Whitespace(sizePrefixDisplay*1) << "seed for random ordering\n"; + s << " -" DOCTEST_OPTIONS_PREFIX_DISPLAY "f, --" DOCTEST_OPTIONS_PREFIX_DISPLAY "first= " + << Whitespace(sizePrefixDisplay*1) << "the first test passing the filters to\n"; + s << Whitespace(sizePrefixDisplay*3) << " execute - for range-based execution\n"; + s << " -" DOCTEST_OPTIONS_PREFIX_DISPLAY "l, --" DOCTEST_OPTIONS_PREFIX_DISPLAY "last= " + << Whitespace(sizePrefixDisplay*1) << "the last test passing the filters to\n"; + s << Whitespace(sizePrefixDisplay*3) << " execute - for range-based execution\n"; + s << " -" DOCTEST_OPTIONS_PREFIX_DISPLAY "aa, --" DOCTEST_OPTIONS_PREFIX_DISPLAY "abort-after= " + << Whitespace(sizePrefixDisplay*1) << "stop after failed assertions\n"; + s << " -" DOCTEST_OPTIONS_PREFIX_DISPLAY "scfl,--" DOCTEST_OPTIONS_PREFIX_DISPLAY "subcase-filter-levels= " + << Whitespace(sizePrefixDisplay*1) << "apply filters for the first levels\n"; + s << Color::Cyan << "\n[doctest] " << Color::None; + s << "Bool options - can be used like flags and true is assumed. Available:\n\n"; + s << " -" DOCTEST_OPTIONS_PREFIX_DISPLAY "s, --" DOCTEST_OPTIONS_PREFIX_DISPLAY "success= " + << Whitespace(sizePrefixDisplay*1) << "include successful assertions in output\n"; + s << " -" DOCTEST_OPTIONS_PREFIX_DISPLAY "cs, --" DOCTEST_OPTIONS_PREFIX_DISPLAY "case-sensitive= " + << Whitespace(sizePrefixDisplay*1) << "filters being treated as case sensitive\n"; + s << " -" DOCTEST_OPTIONS_PREFIX_DISPLAY "e, --" DOCTEST_OPTIONS_PREFIX_DISPLAY "exit= " + << Whitespace(sizePrefixDisplay*1) << "exits after the tests finish\n"; + s << " -" DOCTEST_OPTIONS_PREFIX_DISPLAY "d, --" DOCTEST_OPTIONS_PREFIX_DISPLAY "duration= " + << Whitespace(sizePrefixDisplay*1) << "prints the time duration of each test\n"; + s << " -" DOCTEST_OPTIONS_PREFIX_DISPLAY "nt, --" DOCTEST_OPTIONS_PREFIX_DISPLAY "no-throw= " + << Whitespace(sizePrefixDisplay*1) << "skips exceptions-related assert checks\n"; + s << " -" DOCTEST_OPTIONS_PREFIX_DISPLAY "ne, --" DOCTEST_OPTIONS_PREFIX_DISPLAY "no-exitcode= " + << Whitespace(sizePrefixDisplay*1) << "returns (or exits) always with success\n"; + s << " -" DOCTEST_OPTIONS_PREFIX_DISPLAY "nr, --" DOCTEST_OPTIONS_PREFIX_DISPLAY "no-run= " + << Whitespace(sizePrefixDisplay*1) << "skips all runtime doctest operations\n"; + s << " -" DOCTEST_OPTIONS_PREFIX_DISPLAY "nv, --" DOCTEST_OPTIONS_PREFIX_DISPLAY "no-version= " + << Whitespace(sizePrefixDisplay*1) << "omit the framework version in the output\n"; + s << " -" DOCTEST_OPTIONS_PREFIX_DISPLAY "nc, --" DOCTEST_OPTIONS_PREFIX_DISPLAY "no-colors= " + << Whitespace(sizePrefixDisplay*1) << "disables colors in output\n"; + s << " -" DOCTEST_OPTIONS_PREFIX_DISPLAY "fc, --" DOCTEST_OPTIONS_PREFIX_DISPLAY "force-colors= " + << Whitespace(sizePrefixDisplay*1) << "use colors even when not in a tty\n"; + s << " -" DOCTEST_OPTIONS_PREFIX_DISPLAY "nb, --" DOCTEST_OPTIONS_PREFIX_DISPLAY "no-breaks= " + << Whitespace(sizePrefixDisplay*1) << "disables breakpoints in debuggers\n"; + s << " -" DOCTEST_OPTIONS_PREFIX_DISPLAY "ns, --" DOCTEST_OPTIONS_PREFIX_DISPLAY "no-skip= " + << Whitespace(sizePrefixDisplay*1) << "don't skip test cases marked as skip\n"; + s << " -" DOCTEST_OPTIONS_PREFIX_DISPLAY "gfl, --" DOCTEST_OPTIONS_PREFIX_DISPLAY "gnu-file-line= " + << Whitespace(sizePrefixDisplay*1) << ":n: vs (n): for line numbers in output\n"; + s << " -" DOCTEST_OPTIONS_PREFIX_DISPLAY "npf, --" DOCTEST_OPTIONS_PREFIX_DISPLAY "no-path-filenames= " + << Whitespace(sizePrefixDisplay*1) << "only filenames and no paths in output\n"; + s << " -" DOCTEST_OPTIONS_PREFIX_DISPLAY "nln, --" DOCTEST_OPTIONS_PREFIX_DISPLAY "no-line-numbers= " + << Whitespace(sizePrefixDisplay*1) << "0 instead of real line numbers in output\n"; + // ================================================================================== << 79 + // clang-format on + + s << Color::Cyan << "\n[doctest] " << Color::None; + s << "for more information visit the project documentation\n\n"; + } + + void printRegisteredReporters() { + printVersion(); + s << Color::Cyan << "[doctest] " << Color::None << "listing all registered reporters\n"; + for(auto& curr : getReporters()) + s << "priority: " << std::setw(5) << curr.first.first + << " name: " << curr.first.second << "\n"; + } + + void output_query_results() { + separator_to_stream(); + if(getContextOptions()->count || getContextOptions()->list_test_cases) { + s << Color::Cyan << "[doctest] " << Color::None + << "unskipped test cases passing the current filters: " + << g_cs->numTestCasesPassingFilters << "\n"; + } else if(getContextOptions()->list_test_suites) { + s << Color::Cyan << "[doctest] " << Color::None + << "unskipped test cases passing the current filters: " + << g_cs->numTestCasesPassingFilters << "\n"; + s << Color::Cyan << "[doctest] " << Color::None + << "test suites with unskipped test cases passing the current filters: " + << g_cs->numTestSuitesPassingFilters << "\n"; + } + } + + void output_query_preamble_test_cases() { + s << Color::Cyan << "[doctest] " << Color::None << "listing all test case names\n"; + separator_to_stream(); + } + + void output_query_preamble_test_suites() { + s << Color::Cyan << "[doctest] " << Color::None << "listing all test suites\n"; + separator_to_stream(); + } + + void output_c_string_with_newline(const char* str) { s << Color::None << str << "\n"; } + }; + +#ifdef DOCTEST_PLATFORM_WINDOWS + struct DebugOutputWindowReporter : public ConsoleReporter + { + DOCTEST_THREAD_LOCAL static std::ostringstream oss; + + DebugOutputWindowReporter() + : ConsoleReporter(oss) {} + +#define DOCTEST_DEBUG_OUTPUT_WINDOW_REPORTER_OVERRIDE(func, type) \ + void func(type in) override { \ + if(isDebuggerActive()) { \ + bool with_col = g_no_colors; \ + g_no_colors = false; \ + ConsoleReporter::func(in); \ + DOCTEST_OUTPUT_DEBUG_STRING(oss.str().c_str()); \ + oss.str(""); \ + g_no_colors = with_col; \ + } \ + } + + DOCTEST_DEBUG_OUTPUT_WINDOW_REPORTER_OVERRIDE(test_run_start, const ContextOptions&) + DOCTEST_DEBUG_OUTPUT_WINDOW_REPORTER_OVERRIDE(test_run_end, const TestRunStats&) + DOCTEST_DEBUG_OUTPUT_WINDOW_REPORTER_OVERRIDE(test_case_start, const TestCaseData&) + DOCTEST_DEBUG_OUTPUT_WINDOW_REPORTER_OVERRIDE(test_case_end, const CurrentTestCaseStats&) + DOCTEST_DEBUG_OUTPUT_WINDOW_REPORTER_OVERRIDE(subcase_start, const SubcaseSignature&) + DOCTEST_DEBUG_OUTPUT_WINDOW_REPORTER_OVERRIDE(subcase_end, const SubcaseSignature&) + DOCTEST_DEBUG_OUTPUT_WINDOW_REPORTER_OVERRIDE(log_assert, const AssertData&) + DOCTEST_DEBUG_OUTPUT_WINDOW_REPORTER_OVERRIDE(log_message, const MessageData&) + DOCTEST_DEBUG_OUTPUT_WINDOW_REPORTER_OVERRIDE(test_case_skipped, const TestCaseData&) + }; + + DOCTEST_THREAD_LOCAL std::ostringstream DebugOutputWindowReporter::oss; + + DebugOutputWindowReporter g_debug_output_rep; +#endif // DOCTEST_PLATFORM_WINDOWS + + // the implementation of parseFlag() + bool parseFlagImpl(int argc, const char* const* argv, const char* pattern) { + for(int i = argc - 1; i >= 0; --i) { + auto temp = std::strstr(argv[i], pattern); + if(temp && strlen(temp) == strlen(pattern)) { + // eliminate strings in which the chars before the option are not '-' + bool noBadCharsFound = true; //!OCLINT prefer early exits and continue + while(temp != argv[i]) { + if(*--temp != '-') { + noBadCharsFound = false; + break; + } + } + if(noBadCharsFound && argv[i][0] == '-') + return true; + } + } + return false; + } + + // locates a flag on the command line + bool parseFlag(int argc, const char* const* argv, const char* pattern) { +#ifndef DOCTEST_CONFIG_NO_UNPREFIXED_OPTIONS + // offset (normally 3 for "dt-") to skip prefix + if(parseFlagImpl(argc, argv, pattern + strlen(DOCTEST_CONFIG_OPTIONS_PREFIX))) + return true; +#endif // DOCTEST_CONFIG_NO_UNPREFIXED_OPTIONS + return parseFlagImpl(argc, argv, pattern); + } + + // the implementation of parseOption() + bool parseOptionImpl(int argc, const char* const* argv, const char* pattern, String& res) { + for(int i = argc - 1; i >= 0; --i) { + auto temp = std::strstr(argv[i], pattern); + if(temp) { //!OCLINT prefer early exits and continue + // eliminate matches in which the chars before the option are not '-' + bool noBadCharsFound = true; + auto curr = argv[i]; + while(curr != temp) { + if(*curr++ != '-') { + noBadCharsFound = false; + break; + } + } + if(noBadCharsFound && argv[i][0] == '-') { + temp += strlen(pattern); + const unsigned len = strlen(temp); + if(len) { + res = temp; + return true; + } + } + } + } + return false; + } + + // parses an option and returns the string after the '=' character + bool parseOption(int argc, const char* const* argv, const char* pattern, String& res, + const String& defaultVal = String()) { + res = defaultVal; +#ifndef DOCTEST_CONFIG_NO_UNPREFIXED_OPTIONS + // offset (normally 3 for "dt-") to skip prefix + if(parseOptionImpl(argc, argv, pattern + strlen(DOCTEST_CONFIG_OPTIONS_PREFIX), res)) + return true; +#endif // DOCTEST_CONFIG_NO_UNPREFIXED_OPTIONS + return parseOptionImpl(argc, argv, pattern, res); + } + + // parses a comma separated list of words after a pattern in one of the arguments in argv + bool parseCommaSepArgs(int argc, const char* const* argv, const char* pattern, + std::vector& res) { + String filtersString; + if(parseOption(argc, argv, pattern, filtersString)) { + // tokenize with "," as a separator + // cppcheck-suppress strtokCalled + DOCTEST_CLANG_SUPPRESS_WARNING_WITH_PUSH("-Wdeprecated-declarations") + auto pch = std::strtok(filtersString.c_str(), ","); // modifies the string + while(pch != nullptr) { + if(strlen(pch)) + res.push_back(pch); + // uses the strtok() internal state to go to the next token + // cppcheck-suppress strtokCalled + pch = std::strtok(nullptr, ","); + } + DOCTEST_CLANG_SUPPRESS_WARNING_POP + return true; + } + return false; + } + + enum optionType + { + option_bool, + option_int + }; + + // parses an int/bool option from the command line + bool parseIntOption(int argc, const char* const* argv, const char* pattern, optionType type, + int& res) { + String parsedValue; + if(!parseOption(argc, argv, pattern, parsedValue)) + return false; + + if(type == 0) { + // boolean + const char positive[][5] = {"1", "true", "on", "yes"}; // 5 - strlen("true") + 1 + const char negative[][6] = {"0", "false", "off", "no"}; // 6 - strlen("false") + 1 + + // if the value matches any of the positive/negative possibilities + for(unsigned i = 0; i < 4; i++) { + if(parsedValue.compare(positive[i], true) == 0) { + res = 1; //!OCLINT parameter reassignment + return true; + } + if(parsedValue.compare(negative[i], true) == 0) { + res = 0; //!OCLINT parameter reassignment + return true; + } + } + } else { + // integer + // TODO: change this to use std::stoi or something else! currently it uses undefined behavior - assumes '0' on unsuccessful parse... + int theInt = std::atoi(parsedValue.c_str()); // NOLINT + if(theInt != 0) { + res = theInt; //!OCLINT parameter reassignment + return true; + } + } + return false; + } +} // namespace + +Context::Context(int argc, const char* const* argv) + : p(new detail::ContextState) { + parseArgs(argc, argv, true); +} + +Context::~Context() { + if(g_cs == p) + g_cs = nullptr; + delete p; +} + +void Context::applyCommandLine(int argc, const char* const* argv) { parseArgs(argc, argv); } + +// parses args +void Context::parseArgs(int argc, const char* const* argv, bool withDefaults) { + using namespace detail; + + // clang-format off + parseCommaSepArgs(argc, argv, DOCTEST_CONFIG_OPTIONS_PREFIX "source-file=", p->filters[0]); + parseCommaSepArgs(argc, argv, DOCTEST_CONFIG_OPTIONS_PREFIX "sf=", p->filters[0]); + parseCommaSepArgs(argc, argv, DOCTEST_CONFIG_OPTIONS_PREFIX "source-file-exclude=",p->filters[1]); + parseCommaSepArgs(argc, argv, DOCTEST_CONFIG_OPTIONS_PREFIX "sfe=", p->filters[1]); + parseCommaSepArgs(argc, argv, DOCTEST_CONFIG_OPTIONS_PREFIX "test-suite=", p->filters[2]); + parseCommaSepArgs(argc, argv, DOCTEST_CONFIG_OPTIONS_PREFIX "ts=", p->filters[2]); + parseCommaSepArgs(argc, argv, DOCTEST_CONFIG_OPTIONS_PREFIX "test-suite-exclude=", p->filters[3]); + parseCommaSepArgs(argc, argv, DOCTEST_CONFIG_OPTIONS_PREFIX "tse=", p->filters[3]); + parseCommaSepArgs(argc, argv, DOCTEST_CONFIG_OPTIONS_PREFIX "test-case=", p->filters[4]); + parseCommaSepArgs(argc, argv, DOCTEST_CONFIG_OPTIONS_PREFIX "tc=", p->filters[4]); + parseCommaSepArgs(argc, argv, DOCTEST_CONFIG_OPTIONS_PREFIX "test-case-exclude=", p->filters[5]); + parseCommaSepArgs(argc, argv, DOCTEST_CONFIG_OPTIONS_PREFIX "tce=", p->filters[5]); + parseCommaSepArgs(argc, argv, DOCTEST_CONFIG_OPTIONS_PREFIX "subcase=", p->filters[6]); + parseCommaSepArgs(argc, argv, DOCTEST_CONFIG_OPTIONS_PREFIX "sc=", p->filters[6]); + parseCommaSepArgs(argc, argv, DOCTEST_CONFIG_OPTIONS_PREFIX "subcase-exclude=", p->filters[7]); + parseCommaSepArgs(argc, argv, DOCTEST_CONFIG_OPTIONS_PREFIX "sce=", p->filters[7]); + parseCommaSepArgs(argc, argv, DOCTEST_CONFIG_OPTIONS_PREFIX "reporters=", p->filters[8]); + parseCommaSepArgs(argc, argv, DOCTEST_CONFIG_OPTIONS_PREFIX "r=", p->filters[8]); + // clang-format on + + int intRes = 0; + String strRes; + +#define DOCTEST_PARSE_AS_BOOL_OR_FLAG(name, sname, var, default) \ + if(parseIntOption(argc, argv, DOCTEST_CONFIG_OPTIONS_PREFIX name "=", option_bool, intRes) || \ + parseIntOption(argc, argv, DOCTEST_CONFIG_OPTIONS_PREFIX sname "=", option_bool, intRes)) \ + p->var = !!intRes; \ + else if(parseFlag(argc, argv, DOCTEST_CONFIG_OPTIONS_PREFIX name) || \ + parseFlag(argc, argv, DOCTEST_CONFIG_OPTIONS_PREFIX sname)) \ + p->var = true; \ + else if(withDefaults) \ + p->var = default + +#define DOCTEST_PARSE_INT_OPTION(name, sname, var, default) \ + if(parseIntOption(argc, argv, DOCTEST_CONFIG_OPTIONS_PREFIX name "=", option_int, intRes) || \ + parseIntOption(argc, argv, DOCTEST_CONFIG_OPTIONS_PREFIX sname "=", option_int, intRes)) \ + p->var = intRes; \ + else if(withDefaults) \ + p->var = default + +#define DOCTEST_PARSE_STR_OPTION(name, sname, var, default) \ + if(parseOption(argc, argv, DOCTEST_CONFIG_OPTIONS_PREFIX name "=", strRes, default) || \ + parseOption(argc, argv, DOCTEST_CONFIG_OPTIONS_PREFIX sname "=", strRes, default) || \ + withDefaults) \ + p->var = strRes + + // clang-format off + DOCTEST_PARSE_STR_OPTION("order-by", "ob", order_by, "file"); + DOCTEST_PARSE_INT_OPTION("rand-seed", "rs", rand_seed, 0); + + DOCTEST_PARSE_INT_OPTION("first", "f", first, 0); + DOCTEST_PARSE_INT_OPTION("last", "l", last, UINT_MAX); + + DOCTEST_PARSE_INT_OPTION("abort-after", "aa", abort_after, 0); + DOCTEST_PARSE_INT_OPTION("subcase-filter-levels", "scfl", subcase_filter_levels, 2000000000); + + DOCTEST_PARSE_AS_BOOL_OR_FLAG("success", "s", success, false); + DOCTEST_PARSE_AS_BOOL_OR_FLAG("case-sensitive", "cs", case_sensitive, false); + DOCTEST_PARSE_AS_BOOL_OR_FLAG("exit", "e", exit, false); + DOCTEST_PARSE_AS_BOOL_OR_FLAG("duration", "d", duration, false); + DOCTEST_PARSE_AS_BOOL_OR_FLAG("no-throw", "nt", no_throw, false); + DOCTEST_PARSE_AS_BOOL_OR_FLAG("no-exitcode", "ne", no_exitcode, false); + DOCTEST_PARSE_AS_BOOL_OR_FLAG("no-run", "nr", no_run, false); + DOCTEST_PARSE_AS_BOOL_OR_FLAG("no-version", "nv", no_version, false); + DOCTEST_PARSE_AS_BOOL_OR_FLAG("no-colors", "nc", no_colors, false); + DOCTEST_PARSE_AS_BOOL_OR_FLAG("force-colors", "fc", force_colors, false); + DOCTEST_PARSE_AS_BOOL_OR_FLAG("no-breaks", "nb", no_breaks, false); + DOCTEST_PARSE_AS_BOOL_OR_FLAG("no-skip", "ns", no_skip, false); + DOCTEST_PARSE_AS_BOOL_OR_FLAG("gnu-file-line", "gfl", gnu_file_line, !bool(DOCTEST_MSVC)); + DOCTEST_PARSE_AS_BOOL_OR_FLAG("no-path-filenames", "npf", no_path_in_filenames, false); + DOCTEST_PARSE_AS_BOOL_OR_FLAG("no-line-numbers", "nln", no_line_numbers, false); + DOCTEST_PARSE_AS_BOOL_OR_FLAG("no-skipped-summary", "nss", no_skipped_summary, false); + // clang-format on + + if(withDefaults) { + p->help = false; + p->version = false; + p->count = false; + p->list_test_cases = false; + p->list_test_suites = false; + p->list_reporters = false; + } + if(parseFlag(argc, argv, DOCTEST_CONFIG_OPTIONS_PREFIX "help") || + parseFlag(argc, argv, DOCTEST_CONFIG_OPTIONS_PREFIX "h") || + parseFlag(argc, argv, DOCTEST_CONFIG_OPTIONS_PREFIX "?")) { + p->help = true; + p->exit = true; + } + if(parseFlag(argc, argv, DOCTEST_CONFIG_OPTIONS_PREFIX "version") || + parseFlag(argc, argv, DOCTEST_CONFIG_OPTIONS_PREFIX "v")) { + p->version = true; + p->exit = true; + } + if(parseFlag(argc, argv, DOCTEST_CONFIG_OPTIONS_PREFIX "count") || + parseFlag(argc, argv, DOCTEST_CONFIG_OPTIONS_PREFIX "c")) { + p->count = true; + p->exit = true; + } + if(parseFlag(argc, argv, DOCTEST_CONFIG_OPTIONS_PREFIX "list-test-cases") || + parseFlag(argc, argv, DOCTEST_CONFIG_OPTIONS_PREFIX "ltc")) { + p->list_test_cases = true; + p->exit = true; + } + if(parseFlag(argc, argv, DOCTEST_CONFIG_OPTIONS_PREFIX "list-test-suites") || + parseFlag(argc, argv, DOCTEST_CONFIG_OPTIONS_PREFIX "lts")) { + p->list_test_suites = true; + p->exit = true; + } + if(parseFlag(argc, argv, DOCTEST_CONFIG_OPTIONS_PREFIX "list-reporters") || + parseFlag(argc, argv, DOCTEST_CONFIG_OPTIONS_PREFIX "lr")) { + p->list_reporters = true; + p->exit = true; + } +} + +// allows the user to add procedurally to the filters from the command line +void Context::addFilter(const char* filter, const char* value) { setOption(filter, value); } + +// allows the user to clear all filters from the command line +void Context::clearFilters() { + for(auto& curr : p->filters) + curr.clear(); +} + +// allows the user to override procedurally the int/bool options from the command line +void Context::setOption(const char* option, int value) { + setOption(option, toString(value).c_str()); +} + +// allows the user to override procedurally the string options from the command line +void Context::setOption(const char* option, const char* value) { + auto argv = String("-") + option + "=" + value; + auto lvalue = argv.c_str(); + parseArgs(1, &lvalue); +} + +// users should query this in their main() and exit the program if true +bool Context::shouldExit() { return p->exit; } + +void Context::setAsDefaultForAssertsOutOfTestCases() { g_cs = p; } + +void Context::setAssertHandler(detail::assert_handler ah) { p->ah = ah; } + +// the main function that does all the filtering and test running +int Context::run() { + using namespace detail; + + auto old_cs = g_cs; + g_cs = p; + is_running_in_test = true; + g_no_colors = p->no_colors; + p->resetRunData(); + + ConsoleReporterWithHelpers g_con_rep(std::cout); + registerReporter("console", 0, g_con_rep); + + // setup default reporter if none is given through the command line + p->reporters_currently_used.clear(); + if(p->filters[8].empty()) + p->reporters_currently_used.push_back(getReporters()[reporterMap::key_type(0, "console")]); + + // check to see if any of the registered reporters has been selected + for(auto& curr : getReporters()) { + if(matchesAny(curr.first.second.c_str(), p->filters[8], false, p->case_sensitive)) + p->reporters_currently_used.push_back(curr.second); + } + + // always use the debug output window reporter +#ifdef DOCTEST_PLATFORM_WINDOWS + if(isDebuggerActive()) + p->reporters_currently_used.push_back(&g_debug_output_rep); +#endif // DOCTEST_PLATFORM_WINDOWS + + // handle version, help and no_run + if(p->no_run || p->version || p->help || p->list_reporters) { + if(p->version) + g_con_rep.printVersion(); + if(p->help) + g_con_rep.printHelp(); + if(p->list_reporters) + g_con_rep.printRegisteredReporters(); + + g_cs = old_cs; + is_running_in_test = false; + + return EXIT_SUCCESS; + } + + g_con_rep.printIntro(); + + std::vector testArray; + for(auto& curr : getRegisteredTests()) + testArray.push_back(&curr); + p->numTestCases = testArray.size(); + + // sort the collected records + if(!testArray.empty()) { + if(p->order_by.compare("file", true) == 0) { + std::qsort(&testArray[0], testArray.size(), sizeof(TestCase*), fileOrderComparator); + } else if(p->order_by.compare("suite", true) == 0) { + std::qsort(&testArray[0], testArray.size(), sizeof(TestCase*), suiteOrderComparator); + } else if(p->order_by.compare("name", true) == 0) { + std::qsort(&testArray[0], testArray.size(), sizeof(TestCase*), nameOrderComparator); + } else if(p->order_by.compare("rand", true) == 0) { + std::srand(p->rand_seed); + + // random_shuffle implementation + const auto first = &testArray[0]; + for(size_t i = testArray.size() - 1; i > 0; --i) { + int idxToSwap = std::rand() % (i + 1); // NOLINT + + const auto temp = first[i]; + + first[i] = first[idxToSwap]; + first[idxToSwap] = temp; + } + } + } + + if(p->list_test_cases) + g_con_rep.output_query_preamble_test_cases(); + + std::set testSuitesPassingFilt; + if(p->list_test_suites) + g_con_rep.output_query_preamble_test_suites(); + + bool query_mode = p->count || p->list_test_cases || p->list_test_suites; + + if(!query_mode) + DOCTEST_ITERATE_THROUGH_REPORTERS(test_run_start, *g_cs); + + // invoke the registered functions if they match the filter criteria (or just count them) + for(auto& curr : testArray) { + const auto tc = *curr; + + bool skip_me = false; + if(tc.m_skip && !p->no_skip) + skip_me = true; + + if(!matchesAny(tc.m_file, p->filters[0], true, p->case_sensitive)) + skip_me = true; + if(matchesAny(tc.m_file, p->filters[1], false, p->case_sensitive)) + skip_me = true; + if(!matchesAny(tc.m_test_suite, p->filters[2], true, p->case_sensitive)) + skip_me = true; + if(matchesAny(tc.m_test_suite, p->filters[3], false, p->case_sensitive)) + skip_me = true; + if(!matchesAny(tc.m_name, p->filters[4], true, p->case_sensitive)) + skip_me = true; + if(matchesAny(tc.m_name, p->filters[5], false, p->case_sensitive)) + skip_me = true; + + if(!skip_me) + p->numTestCasesPassingFilters++; + + // skip the test if it is not in the execution range + if((p->last < p->numTestCasesPassingFilters && p->first <= p->last) || + (p->first > p->numTestCasesPassingFilters)) + skip_me = true; + + if(skip_me) { + if(!query_mode) + DOCTEST_ITERATE_THROUGH_REPORTERS(test_case_skipped, tc); + continue; + } + + // do not execute the test if we are to only count the number of filter passing tests + if(p->count) + continue; + + // print the name of the test and don't execute it + if(p->list_test_cases) { + g_con_rep.output_c_string_with_newline(tc.m_name); + continue; + } + + // print the name of the test suite if not done already and don't execute it + if(p->list_test_suites) { + if((testSuitesPassingFilt.count(tc.m_test_suite) == 0) && tc.m_test_suite[0] != '\0') { + g_con_rep.output_c_string_with_newline(tc.m_test_suite); + testSuitesPassingFilt.insert(tc.m_test_suite); + p->numTestSuitesPassingFilters++; + } + continue; + } + + // execute the test if it passes all the filtering + { + p->currentTest = &tc; + + p->failure_flags = TestCaseFailureReason::None; + p->seconds_so_far = 0; + p->error_string = ""; + + // reset non-atomic counters + p->numAssertsFailedForCurrentTestCase = 0; + p->numAssertsForCurrentTestCase = 0; + + p->subcasesPassed.clear(); + do { + // reset some of the fields for subcases (except for the set of fully passed ones) + p->should_reenter = false; + p->subcasesCurrentLevel = 0; + p->subcasesEnteredLevels.clear(); + + // reset stuff for logging with INFO() + p->stringifiedContexts.clear(); + + // reset atomic counters + p->numAssertsFailedForCurrentTestCase_atomic = 0; + p->numAssertsForCurrentTestCase_atomic = 0; + + DOCTEST_ITERATE_THROUGH_REPORTERS(test_case_start, tc); + + g_timer.start(); + +#ifndef DOCTEST_CONFIG_NO_EXCEPTIONS + try { +#endif // DOCTEST_CONFIG_NO_EXCEPTIONS + FatalConditionHandler fatalConditionHandler; // Handle signals + // execute the test + tc.m_test(); + fatalConditionHandler.reset(); +#ifndef DOCTEST_CONFIG_NO_EXCEPTIONS + } catch(const TestFailureException&) { + p->failure_flags |= TestCaseFailureReason::AssertFailure; + } catch(...) { + p->error_string = translateActiveException(); + p->failure_flags |= TestCaseFailureReason::Exception; + } +#endif // DOCTEST_CONFIG_NO_EXCEPTIONS + + p->seconds_so_far += g_timer.getElapsedSeconds(); + + // update the non-atomic counters + p->numAsserts += p->numAssertsForCurrentTestCase_atomic; + p->numAssertsForCurrentTestCase += p->numAssertsForCurrentTestCase_atomic; + p->numAssertsFailed += p->numAssertsFailedForCurrentTestCase_atomic; + p->numAssertsFailedForCurrentTestCase += + p->numAssertsFailedForCurrentTestCase_atomic; + + // exit this loop if enough assertions have failed - even if there are more subcases + if(p->abort_after > 0 && p->numAssertsFailed >= p->abort_after) { + p->should_reenter = false; + p->failure_flags |= TestCaseFailureReason::TooManyFailedAsserts; + } + + // call it from here only if we will continue looping for other subcases and + // call it again outside of the loop for one final time - with updated flags + if(p->should_reenter == true) { + DOCTEST_ITERATE_THROUGH_REPORTERS(test_case_end, *g_cs); + // remove these flags - it is expected that the reporters have handled these issues + p->failure_flags &= ~TestCaseFailureReason::Exception; + p->failure_flags &= ~TestCaseFailureReason::AssertFailure; + } + } while(p->should_reenter == true); + + if(p->numAssertsFailedForCurrentTestCase) + p->failure_flags |= TestCaseFailureReason::AssertFailure; + + if(Approx(p->currentTest->m_timeout).epsilon(DBL_EPSILON) != 0 && + Approx(p->seconds_so_far).epsilon(DBL_EPSILON) > p->currentTest->m_timeout) + p->failure_flags |= TestCaseFailureReason::Timeout; + + if(tc.m_should_fail) { + if(p->failure_flags) { + p->failure_flags |= TestCaseFailureReason::ShouldHaveFailedAndDid; + } else { + p->failure_flags |= TestCaseFailureReason::ShouldHaveFailedButDidnt; + } + } else if(p->failure_flags && tc.m_may_fail) { + p->failure_flags |= TestCaseFailureReason::CouldHaveFailedAndDid; + } else if(tc.m_expected_failures > 0) { + if(p->numAssertsFailedForCurrentTestCase == tc.m_expected_failures) { + p->failure_flags |= TestCaseFailureReason::FailedExactlyNumTimes; + } else { + p->failure_flags |= TestCaseFailureReason::DidntFailExactlyNumTimes; + } + } + + bool ok_to_fail = (TestCaseFailureReason::ShouldHaveFailedAndDid & p->failure_flags) || + (TestCaseFailureReason::CouldHaveFailedAndDid & p->failure_flags) || + (TestCaseFailureReason::FailedExactlyNumTimes & p->failure_flags); + + // if any subcase has failed - the whole test case has failed + if(p->failure_flags && !ok_to_fail) + p->numTestCasesFailed++; + + DOCTEST_ITERATE_THROUGH_REPORTERS(test_case_end, *g_cs); + + p->currentTest = nullptr; + + // stop executing tests if enough assertions have failed + if(p->abort_after > 0 && p->numAssertsFailed >= p->abort_after) + break; + } + } + + if(!query_mode) + DOCTEST_ITERATE_THROUGH_REPORTERS(test_run_end, *g_cs); + else + g_con_rep.output_query_results(); + + g_cs = old_cs; + is_running_in_test = false; + + if(p->numTestCasesFailed && !p->no_exitcode) + return EXIT_FAILURE; + return EXIT_SUCCESS; +} + +DOCTEST_DEFINE_DEFAULTS(CurrentTestCaseStats); + +DOCTEST_DEFINE_DEFAULTS(TestRunStats); + +IReporter::~IReporter() = default; + +int IReporter::get_num_active_contexts() { return detail::g_infoContexts.size(); } +const IContextScope* const* IReporter::get_active_contexts() { + return get_num_active_contexts() ? &detail::g_infoContexts[0] : nullptr; +} + +int IReporter::get_num_stringified_contexts() { return detail::g_cs->stringifiedContexts.size(); } +const String* IReporter::get_stringified_contexts() { + return get_num_stringified_contexts() ? &detail::g_cs->stringifiedContexts[0] : nullptr; +} + +int registerReporter(const char* name, int priority, IReporter& r) { + getReporters().insert(reporterMap::value_type(reporterMap::key_type(priority, name), &r)); + return 0; +} + +// see these issues on the reasoning for this: +// - https://github.com/onqtam/doctest/issues/143#issuecomment-414418903 +// - https://github.com/onqtam/doctest/issues/126 +void DOCTEST_FIX_FOR_MACOS_LIBCPP_IOSFWD_STRING_LINK_ERRORS() { std::cout << std::string(); } + +} // namespace doctest + +#endif // DOCTEST_CONFIG_DISABLE + +#ifdef DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN +int main(int argc, char** argv) { return doctest::Context(argc, argv).run(); } +#endif // DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN + +DOCTEST_CLANG_SUPPRESS_WARNING_POP +DOCTEST_MSVC_SUPPRESS_WARNING_POP +DOCTEST_GCC_SUPPRESS_WARNING_POP + +#endif // DOCTEST_LIBRARY_IMPLEMENTATION +#endif // DOCTEST_CONFIG_IMPLEMENT diff --git a/test/thirdparty/doctest/doctest_compatibility.h b/test/thirdparty/doctest/doctest_compatibility.h new file mode 100644 index 00000000..e9d035ce --- /dev/null +++ b/test/thirdparty/doctest/doctest_compatibility.h @@ -0,0 +1,35 @@ +#ifndef DOCTEST_COMPATIBILITY +#define DOCTEST_COMPATIBILITY + +#include "doctest.h" + +// Catch doesn't require a semicolon after CAPTURE but doctest does +#undef CAPTURE +#define CAPTURE(x) DOCTEST_CAPTURE(x); + +// Sections from Catch are called Subcases in doctest and don't work with std::string by default +#undef SUBCASE +#define SECTION(x) DOCTEST_SUBCASE(x) + +// convenience macro around INFO since it doesn't support temporaries (it is optimized to avoid allocations for runtime speed) +#define INFO_WITH_TEMP_IMPL(x, var_name) const auto var_name = x; INFO(var_name) // lvalue! +#define INFO_WITH_TEMP(x) INFO_WITH_TEMP_IMPL(x, DOCTEST_ANONYMOUS(DOCTEST_STD_STRING_)) + +// doctest doesn't support THROWS_WITH for std::string out of the box (has to include ...) +#define CHECK_THROWS_WITH_STD_STR_IMPL(expr, str, var_name) \ + do { \ + std::string var_name = str; \ + CHECK_THROWS_WITH(expr, var_name.c_str()); \ + } while (false) +#define CHECK_THROWS_WITH_STD_STR(expr, str) \ + CHECK_THROWS_WITH_STD_STR_IMPL(expr, str, DOCTEST_ANONYMOUS(DOCTEST_STD_STRING_)) + +// included here because for some tests in the json repository private is defined as +// public and if no STL header is included before that then in the json include when STL +// stuff is included the MSVC STL complains (errors) that C++ keywords are being redefined +#include + +// Catch does this by default +using doctest::Approx; + +#endif From 3340162efdb9c05132f8dd6bb9a9b225a892a352 Mon Sep 17 00:00:00 2001 From: onqtam Date: Tue, 15 Jan 2019 22:48:37 +0200 Subject: [PATCH 002/106] fixing osx builds - had forgotten to define this for the object file where the test runner is compiled --- test/CMakeLists.txt | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index f314ea66..63b3dd58 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -61,9 +61,13 @@ add_library(doctest_main OBJECT "src/unit.cpp" ) set_target_properties(doctest_main PROPERTIES - COMPILE_DEFINITIONS "$<$:_SCL_SECURE_NO_WARNINGS>" COMPILE_OPTIONS "$<$:/EHsc;$<$:/Od>>" ) +target_compile_definitions(doctest_main PUBLIC + "$<$:_SCL_SECURE_NO_WARNINGS>" + "DOCTEST_THREAD_LOCAL" + "DOCTEST_CONFIG_SUPER_FAST_ASSERTS" +) target_compile_features(doctest_main PUBLIC cxx_std_11) target_include_directories(doctest_main PRIVATE "thirdparty/doctest") @@ -96,10 +100,6 @@ foreach(file ${files}) string(REGEX REPLACE "unit-([^$]+)" "test-\\1" testcase ${file_basename}) add_executable(${testcase} $ ${file}) - target_compile_definitions(${testcase} PRIVATE - DOCTEST_CONFIG_SUPER_FAST_ASSERTS - DOCTEST_THREAD_LOCAL - ) target_compile_options(${testcase} PRIVATE $<$:/EHsc;$<$:/Od>> $<$>:-Wno-deprecated;-Wno-float-equal> From a2c074fd4d96b2c61d0c5d35d1e5fbee7b8b2a77 Mon Sep 17 00:00:00 2001 From: onqtam Date: Tue, 15 Jan 2019 22:58:12 +0200 Subject: [PATCH 003/106] this should really fix the XCode 6/7 builds --- test/CMakeLists.txt | 9 ++++----- test/thirdparty/doctest/doctest_compatibility.h | 1 + 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 63b3dd58..5886d7f3 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -61,13 +61,9 @@ add_library(doctest_main OBJECT "src/unit.cpp" ) set_target_properties(doctest_main PROPERTIES + COMPILE_DEFINITIONS "$<$:_SCL_SECURE_NO_WARNINGS>" COMPILE_OPTIONS "$<$:/EHsc;$<$:/Od>>" ) -target_compile_definitions(doctest_main PUBLIC - "$<$:_SCL_SECURE_NO_WARNINGS>" - "DOCTEST_THREAD_LOCAL" - "DOCTEST_CONFIG_SUPER_FAST_ASSERTS" -) target_compile_features(doctest_main PUBLIC cxx_std_11) target_include_directories(doctest_main PRIVATE "thirdparty/doctest") @@ -100,6 +96,9 @@ foreach(file ${files}) string(REGEX REPLACE "unit-([^$]+)" "test-\\1" testcase ${file_basename}) add_executable(${testcase} $ ${file}) + target_compile_definitions(${testcase} PRIVATE + DOCTEST_CONFIG_SUPER_FAST_ASSERTS + ) target_compile_options(${testcase} PRIVATE $<$:/EHsc;$<$:/Od>> $<$>:-Wno-deprecated;-Wno-float-equal> diff --git a/test/thirdparty/doctest/doctest_compatibility.h b/test/thirdparty/doctest/doctest_compatibility.h index e9d035ce..cfbe6a46 100644 --- a/test/thirdparty/doctest/doctest_compatibility.h +++ b/test/thirdparty/doctest/doctest_compatibility.h @@ -1,6 +1,7 @@ #ifndef DOCTEST_COMPATIBILITY #define DOCTEST_COMPATIBILITY +#define DOCTEST_THREAD_LOCAL // enable single-threaded builds on XCode 6/7 - https://github.com/onqtam/doctest/issues/172 #include "doctest.h" // Catch doesn't require a semicolon after CAPTURE but doctest does From 155d196bfab4416c5c7431b96644df7311576f55 Mon Sep 17 00:00:00 2001 From: Viktor Kirilov Date: Mon, 18 Mar 2019 17:58:35 +0200 Subject: [PATCH 004/106] Update CMakeLists.txt --- test/CMakeLists.txt | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 1ac271c1..b2f59d5f 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -65,11 +65,7 @@ set_target_properties(doctest_main PROPERTIES COMPILE_OPTIONS "$<$:/EHsc;$<$:/Od>>" ) -if (${CMAKE_VERSION} VERSION_LESS "3.8.0") - target_compile_features(catch_main PUBLIC cxx_range_for) -else() - target_compile_features(catch_main PUBLIC cxx_std_11) -endif() +target_compile_features(doctest_main PUBLIC cxx_std_11) target_include_directories(doctest_main PRIVATE "thirdparty/doctest") # https://stackoverflow.com/questions/2368811/how-to-set-warning-level-in-cmake From baaa2a4d0ffe210b32405e76fc007c46ecdc33ff Mon Sep 17 00:00:00 2001 From: Niels Lohmann Date: Thu, 21 Mar 2019 14:09:29 +0100 Subject: [PATCH 005/106] :checkered_flag: trying to use constructors from std::allocator #1536 --- test/src/unit-allocator.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test/src/unit-allocator.cpp b/test/src/unit-allocator.cpp index 60d2f44f..2edbc34a 100644 --- a/test/src/unit-allocator.cpp +++ b/test/src/unit-allocator.cpp @@ -71,6 +71,8 @@ static bool next_deallocate_fails = false; template struct my_allocator : std::allocator { + using std::allocator::allocator; + template void construct(T* p, Args&& ... args) { From 72dd6f349ef02bf100f2fc5c192032a99d7e5cd7 Mon Sep 17 00:00:00 2001 From: Niels Lohmann Date: Sat, 23 Mar 2019 23:18:27 +0100 Subject: [PATCH 006/106] :construction_worker: trying doozer --- .doozer.json | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 .doozer.json diff --git a/.doozer.json b/.doozer.json new file mode 100644 index 00000000..3071e682 --- /dev/null +++ b/.doozer.json @@ -0,0 +1,14 @@ +{ + "targets": { + "xenial-amd64": { + "buildenv": "xenial-amd64", + "builddeps": ["build-essential"], + "buildcmd": [ + "mkdir build", + "cd build", + "cmake ..", + "make" + ] + } + } +} From 2fcca259b04eb66e41c531e96b7d912128474548 Mon Sep 17 00:00:00 2001 From: Niels Lohmann Date: Sat, 23 Mar 2019 23:21:17 +0100 Subject: [PATCH 007/106] :construction_worker: added cmake --- .doozer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.doozer.json b/.doozer.json index 3071e682..82b74115 100644 --- a/.doozer.json +++ b/.doozer.json @@ -2,7 +2,7 @@ "targets": { "xenial-amd64": { "buildenv": "xenial-amd64", - "builddeps": ["build-essential"], + "builddeps": ["build-essential", "cmake"], "buildcmd": [ "mkdir build", "cd build", From 490c6e926eb4e4ac7b9fc1b1b25f04a92427f715 Mon Sep 17 00:00:00 2001 From: Niels Lohmann Date: Sat, 23 Mar 2019 23:27:39 +0100 Subject: [PATCH 008/106] :construction_worker: using raspbian --- .doozer.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.doozer.json b/.doozer.json index 82b74115..2c9d85f5 100644 --- a/.doozer.json +++ b/.doozer.json @@ -1,13 +1,14 @@ { "targets": { - "xenial-amd64": { + "raspbian-jessie": { "buildenv": "xenial-amd64", "builddeps": ["build-essential", "cmake"], "buildcmd": [ "mkdir build", "cd build", "cmake ..", - "make" + "make", + "ctest" ] } } From 7dd3e6384b4cbed874451ec7982d1dca1fa37ff1 Mon Sep 17 00:00:00 2001 From: Niels Lohmann Date: Sat, 23 Mar 2019 23:42:29 +0100 Subject: [PATCH 009/106] :construction_worker: added Fedora and CentOS --- .doozer.json | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/.doozer.json b/.doozer.json index 2c9d85f5..fa2f3b64 100644 --- a/.doozer.json +++ b/.doozer.json @@ -7,8 +7,30 @@ "mkdir build", "cd build", "cmake ..", - "make", - "ctest" + "make -j8", + "ctest -j8" + ] + }, + "fedora24-x86_64": { + "buildenv": "xenial-amd64", + "builddeps": ["build-essential", "cmake"], + "buildcmd": [ + "mkdir build", + "cd build", + "cmake ..", + "make -j8", + "ctest -j8" + ] + }, + "centos7-x86_64": { + "buildenv": "xenial-amd64", + "builddeps": ["build-essential", "cmake"], + "buildcmd": [ + "mkdir build", + "cd build", + "cmake ..", + "make -j8", + "ctest -j8" ] } } From bc5089e8032198e04083dc99c9e2d47f1f76ccd2 Mon Sep 17 00:00:00 2001 From: Niels Lohmann Date: Sun, 24 Mar 2019 00:02:41 +0100 Subject: [PATCH 010/106] :construction_worker: add test output to avoid timeout --- .doozer.json | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/.doozer.json b/.doozer.json index fa2f3b64..62d267d4 100644 --- a/.doozer.json +++ b/.doozer.json @@ -4,33 +4,36 @@ "buildenv": "xenial-amd64", "builddeps": ["build-essential", "cmake"], "buildcmd": [ + "uname -a", "mkdir build", "cd build", "cmake ..", "make -j8", - "ctest -j8" + "ctest -VV -j8" ] }, "fedora24-x86_64": { "buildenv": "xenial-amd64", "builddeps": ["build-essential", "cmake"], "buildcmd": [ + "uname -a", "mkdir build", "cd build", "cmake ..", "make -j8", - "ctest -j8" + "ctest -VV -j8" ] }, "centos7-x86_64": { "buildenv": "xenial-amd64", "builddeps": ["build-essential", "cmake"], "buildcmd": [ + "uname -a", "mkdir build", "cd build", "cmake ..", "make -j8", - "ctest -j8" + "ctest -VV -j8" ] } } From 6e3e2ee2e429385ed7f0974c9453cb9d60fcfeb8 Mon Sep 17 00:00:00 2001 From: Niels Lohmann Date: Sun, 24 Mar 2019 00:11:20 +0100 Subject: [PATCH 011/106] :construction_worker: fixed buildenv values --- .doozer.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.doozer.json b/.doozer.json index 62d267d4..f7c6a210 100644 --- a/.doozer.json +++ b/.doozer.json @@ -1,7 +1,7 @@ { "targets": { "raspbian-jessie": { - "buildenv": "xenial-amd64", + "buildenv": "raspbian-jessie", "builddeps": ["build-essential", "cmake"], "buildcmd": [ "uname -a", @@ -13,7 +13,7 @@ ] }, "fedora24-x86_64": { - "buildenv": "xenial-amd64", + "buildenv": "edora24-x86_64", "builddeps": ["build-essential", "cmake"], "buildcmd": [ "uname -a", @@ -25,7 +25,7 @@ ] }, "centos7-x86_64": { - "buildenv": "xenial-amd64", + "buildenv": "centos7-x86_64", "builddeps": ["build-essential", "cmake"], "buildcmd": [ "uname -a", From fabf953305857e80c8f52e183490ca9183ad8f78 Mon Sep 17 00:00:00 2001 From: Niels Lohmann Date: Sun, 24 Mar 2019 00:12:36 +0100 Subject: [PATCH 012/106] :construction_worker: fixed a typo --- .doozer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.doozer.json b/.doozer.json index f7c6a210..51c4c962 100644 --- a/.doozer.json +++ b/.doozer.json @@ -13,7 +13,7 @@ ] }, "fedora24-x86_64": { - "buildenv": "edora24-x86_64", + "buildenv": "fedora24-x86_64", "builddeps": ["build-essential", "cmake"], "buildcmd": [ "uname -a", From 4327ae0bef5e65ec975d09a08417ae93b8fa157b Mon Sep 17 00:00:00 2001 From: Niels Lohmann Date: Sun, 24 Mar 2019 00:15:57 +0100 Subject: [PATCH 013/106] :construction_worker: need more recent cmake for CentOS --- .doozer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.doozer.json b/.doozer.json index 51c4c962..1115916d 100644 --- a/.doozer.json +++ b/.doozer.json @@ -26,7 +26,7 @@ }, "centos7-x86_64": { "buildenv": "centos7-x86_64", - "builddeps": ["build-essential", "cmake"], + "builddeps": ["build-essential", "cmake3"], "buildcmd": [ "uname -a", "mkdir build", From a72ac18514fd1e8e88ec09b329a45871384cfc86 Mon Sep 17 00:00:00 2001 From: Niels Lohmann Date: Sun, 24 Mar 2019 00:36:05 +0100 Subject: [PATCH 014/106] :construction_worker: use recent cmake --- .doozer.json | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/.doozer.json b/.doozer.json index 1115916d..d1ef850c 100644 --- a/.doozer.json +++ b/.doozer.json @@ -2,19 +2,25 @@ "targets": { "raspbian-jessie": { "buildenv": "raspbian-jessie", - "builddeps": ["build-essential", "cmake"], + "builddeps": ["build-essential", "cmake", "wget"], "buildcmd": [ "uname -a", + "wget https://github.com/Kitware/CMake/releases/download/v3.14.0/cmake-3.14.0.tar.gz", + "tar xfz cmake-3.14.0.tar.gz", + "cd cmake-3.14.0" + "cmake . -DBUILD_TESTING=OFF", + "make -j8", + "cd .." "mkdir build", "cd build", - "cmake ..", + "../../cmake-3.14.0/bin/cmake ..", "make -j8", "ctest -VV -j8" ] }, "fedora24-x86_64": { "buildenv": "fedora24-x86_64", - "builddeps": ["build-essential", "cmake"], + "builddeps": ["cmake"], "buildcmd": [ "uname -a", "mkdir build", @@ -26,7 +32,7 @@ }, "centos7-x86_64": { "buildenv": "centos7-x86_64", - "builddeps": ["build-essential", "cmake3"], + "builddeps": ["build-essential", "cmake"], "buildcmd": [ "uname -a", "mkdir build", From 65cdccfa8a13e0952e73fdefaaf5cad04ff15e2a Mon Sep 17 00:00:00 2001 From: Niels Lohmann Date: Sun, 24 Mar 2019 00:36:46 +0100 Subject: [PATCH 015/106] :construction_worker: fixed syntax error --- .doozer.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.doozer.json b/.doozer.json index d1ef850c..bac79dc6 100644 --- a/.doozer.json +++ b/.doozer.json @@ -7,10 +7,10 @@ "uname -a", "wget https://github.com/Kitware/CMake/releases/download/v3.14.0/cmake-3.14.0.tar.gz", "tar xfz cmake-3.14.0.tar.gz", - "cd cmake-3.14.0" + "cd cmake-3.14.0", "cmake . -DBUILD_TESTING=OFF", "make -j8", - "cd .." + "cd ..", "mkdir build", "cd build", "../../cmake-3.14.0/bin/cmake ..", From c94b764a6e10d01f7ab046b9683351033713d98b Mon Sep 17 00:00:00 2001 From: Niels Lohmann Date: Sun, 24 Mar 2019 00:43:01 +0100 Subject: [PATCH 016/106] :construction_worker: fixed installation --- .doozer.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.doozer.json b/.doozer.json index bac79dc6..0e037e8d 100644 --- a/.doozer.json +++ b/.doozer.json @@ -8,7 +8,7 @@ "wget https://github.com/Kitware/CMake/releases/download/v3.14.0/cmake-3.14.0.tar.gz", "tar xfz cmake-3.14.0.tar.gz", "cd cmake-3.14.0", - "cmake . -DBUILD_TESTING=OFF", + "./bootstrap", "make -j8", "cd ..", "mkdir build", @@ -20,7 +20,7 @@ }, "fedora24-x86_64": { "buildenv": "fedora24-x86_64", - "builddeps": ["cmake"], + "builddeps": ["cmake", "make", "gcc"], "buildcmd": [ "uname -a", "mkdir build", From 63d619e21fbe4b99de9ba7fd4d609d037647b264 Mon Sep 17 00:00:00 2001 From: Niels Lohmann Date: Sun, 24 Mar 2019 00:48:59 +0100 Subject: [PATCH 017/106] :construction_worker: need to install g++ --- .doozer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.doozer.json b/.doozer.json index 0e037e8d..3c468df2 100644 --- a/.doozer.json +++ b/.doozer.json @@ -20,7 +20,7 @@ }, "fedora24-x86_64": { "buildenv": "fedora24-x86_64", - "builddeps": ["cmake", "make", "gcc"], + "builddeps": ["cmake", "make", "g++"], "buildcmd": [ "uname -a", "mkdir build", From c871c9a01c1fa01f80ea9942b5037bea25aeb6af Mon Sep 17 00:00:00 2001 From: Niels Lohmann Date: Sun, 24 Mar 2019 06:51:10 +0100 Subject: [PATCH 018/106] :construction_worker: install correct g++ --- .doozer.json | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/.doozer.json b/.doozer.json index 3c468df2..0ba65fdf 100644 --- a/.doozer.json +++ b/.doozer.json @@ -13,14 +13,14 @@ "cd ..", "mkdir build", "cd build", - "../../cmake-3.14.0/bin/cmake ..", + "../cmake-3.14.0/bin/cmake ..", "make -j8", "ctest -VV -j8" ] }, "fedora24-x86_64": { "buildenv": "fedora24-x86_64", - "builddeps": ["cmake", "make", "g++"], + "builddeps": ["cmake", "make", "gcc gcc-c++"], "buildcmd": [ "uname -a", "mkdir build", @@ -32,12 +32,18 @@ }, "centos7-x86_64": { "buildenv": "centos7-x86_64", - "builddeps": ["build-essential", "cmake"], + "builddeps": ["build-essential", "cmake", "wget"], "buildcmd": [ "uname -a", + "wget https://github.com/Kitware/CMake/releases/download/v3.14.0/cmake-3.14.0.tar.gz", + "tar xfz cmake-3.14.0.tar.gz", + "cd cmake-3.14.0", + "./bootstrap", + "make -j8", + "cd ..", "mkdir build", "cd build", - "cmake ..", + "../cmake-3.14.0/bin/cmake ..", "make -j8", "ctest -VV -j8" ] From 5e1cae0a7dbcf5d1c6dc5aae2084a38c46d59717 Mon Sep 17 00:00:00 2001 From: Niels Lohmann Date: Sun, 24 Mar 2019 08:24:50 +0100 Subject: [PATCH 019/106] :construction_worker: install g++ --- .doozer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.doozer.json b/.doozer.json index 0ba65fdf..6d5b29c8 100644 --- a/.doozer.json +++ b/.doozer.json @@ -32,7 +32,7 @@ }, "centos7-x86_64": { "buildenv": "centos7-x86_64", - "builddeps": ["build-essential", "cmake", "wget"], + "builddeps": ["cmake", "make", "wget", "gcc-g++"], "buildcmd": [ "uname -a", "wget https://github.com/Kitware/CMake/releases/download/v3.14.0/cmake-3.14.0.tar.gz", From 30211477b76d077060571b67f7ee9fdfe1eb826d Mon Sep 17 00:00:00 2001 From: Niels Lohmann Date: Sun, 24 Mar 2019 08:36:01 +0100 Subject: [PATCH 020/106] :construction_worker: fixed package name --- .doozer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.doozer.json b/.doozer.json index 6d5b29c8..a5a507c0 100644 --- a/.doozer.json +++ b/.doozer.json @@ -32,7 +32,7 @@ }, "centos7-x86_64": { "buildenv": "centos7-x86_64", - "builddeps": ["cmake", "make", "wget", "gcc-g++"], + "builddeps": ["cmake", "make", "wget", "gcc-c++"], "buildcmd": [ "uname -a", "wget https://github.com/Kitware/CMake/releases/download/v3.14.0/cmake-3.14.0.tar.gz", From 1e86976cfeceb2575da71e2c39988fd8fe81c11e Mon Sep 17 00:00:00 2001 From: Niels Lohmann Date: Sun, 24 Mar 2019 08:53:30 +0100 Subject: [PATCH 021/106] :construction_worker: fixed paths --- .doozer.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.doozer.json b/.doozer.json index a5a507c0..f9b10b9d 100644 --- a/.doozer.json +++ b/.doozer.json @@ -35,15 +35,16 @@ "builddeps": ["cmake", "make", "wget", "gcc-c++"], "buildcmd": [ "uname -a", + "cd", "wget https://github.com/Kitware/CMake/releases/download/v3.14.0/cmake-3.14.0.tar.gz", "tar xfz cmake-3.14.0.tar.gz", "cd cmake-3.14.0", "./bootstrap", "make -j8", - "cd ..", + "cd", "mkdir build", "cd build", - "../cmake-3.14.0/bin/cmake ..", + "../cmake-3.14.0/bin/cmake /project/repo/checkout", "make -j8", "ctest -VV -j8" ] From 842d42b135de2048f580a8378f22c9fc15667392 Mon Sep 17 00:00:00 2001 From: Niels Lohmann Date: Sun, 24 Mar 2019 09:02:06 +0100 Subject: [PATCH 022/106] :construction_worker: unified paths --- .doozer.json | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/.doozer.json b/.doozer.json index f9b10b9d..c0e4cdde 100644 --- a/.doozer.json +++ b/.doozer.json @@ -5,15 +5,16 @@ "builddeps": ["build-essential", "cmake", "wget"], "buildcmd": [ "uname -a", + "cd", "wget https://github.com/Kitware/CMake/releases/download/v3.14.0/cmake-3.14.0.tar.gz", "tar xfz cmake-3.14.0.tar.gz", "cd cmake-3.14.0", "./bootstrap", "make -j8", - "cd ..", + "cd", "mkdir build", "cd build", - "../cmake-3.14.0/bin/cmake ..", + "../cmake-3.14.0/bin/cmake /project/repo/checkout", "make -j8", "ctest -VV -j8" ] @@ -23,9 +24,10 @@ "builddeps": ["cmake", "make", "gcc gcc-c++"], "buildcmd": [ "uname -a", + "cd" "mkdir build", "cd build", - "cmake ..", + "cmake /project/repo/checkout", "make -j8", "ctest -VV -j8" ] From dcbc028b5be56f6588ae4ac9286fd01142cc4807 Mon Sep 17 00:00:00 2001 From: Niels Lohmann Date: Sun, 24 Mar 2019 09:02:46 +0100 Subject: [PATCH 023/106] :construction_worker: fixed syntax --- .doozer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.doozer.json b/.doozer.json index c0e4cdde..25906879 100644 --- a/.doozer.json +++ b/.doozer.json @@ -24,7 +24,7 @@ "builddeps": ["cmake", "make", "gcc gcc-c++"], "buildcmd": [ "uname -a", - "cd" + "cd", "mkdir build", "cd build", "cmake /project/repo/checkout", From ff51a32be1b1d113d4e7d71139e33e5b8ea243d2 Mon Sep 17 00:00:00 2001 From: onqtam Date: Sun, 24 Mar 2019 17:28:52 +0200 Subject: [PATCH 024/106] updated doctest to version 2.3.1 released today --- test/thirdparty/doctest/doctest.h | 1953 ++++++++++++++++++++--------- 1 file changed, 1342 insertions(+), 611 deletions(-) diff --git a/test/thirdparty/doctest/doctest.h b/test/thirdparty/doctest/doctest.h index eda93fc7..30d7c293 100644 --- a/test/thirdparty/doctest/doctest.h +++ b/test/thirdparty/doctest/doctest.h @@ -1,10 +1,10 @@ -// ====================================================================== +// ====================================================================== lgtm [cpp/missing-header-guard] // == DO NOT MODIFY THIS FILE BY HAND - IT IS AUTO GENERATED BY CMAKE! == // ====================================================================== // // doctest.h - the lightest feature-rich C++ single-header testing framework for unit tests and TDD // -// Copyright (c) 2016-2018 Viktor Kirilov +// Copyright (c) 2016-2019 Viktor Kirilov // // Distributed under the MIT Software License // See accompanying file LICENSE.txt or copy at @@ -17,9 +17,9 @@ // ================================================================================================= // ================================================================================================= // -// The library is heavily influenced by Catch - https://github.com/philsquared/Catch +// The library is heavily influenced by Catch - https://github.com/catchorg/Catch2 // which uses the Boost Software License - Version 1.0 -// see here - https://github.com/philsquared/Catch/blob/master/LICENSE.txt +// see here - https://github.com/catchorg/Catch2/blob/master/LICENSE.txt // // The concept of subcases (sections in Catch) and expression decomposition are from there. // Some parts of the code are taken directly: @@ -29,6 +29,7 @@ // - breaking into a debugger // - signal / SEH handling // - timer +// - XmlWriter class - thanks to Phil Nash for allowing the direct reuse (AKA copy/paste) // // The expression decomposing templates are taken from lest - https://github.com/martinmoene/lest // which uses the Boost Software License - Version 1.0 @@ -46,9 +47,9 @@ // ================================================================================================= #define DOCTEST_VERSION_MAJOR 2 -#define DOCTEST_VERSION_MINOR 2 +#define DOCTEST_VERSION_MINOR 3 #define DOCTEST_VERSION_PATCH 1 -#define DOCTEST_VERSION_STR "2.2.1" +#define DOCTEST_VERSION_STR "2.3.1" #define DOCTEST_VERSION \ (DOCTEST_VERSION_MAJOR * 10000 + DOCTEST_VERSION_MINOR * 100 + DOCTEST_VERSION_PATCH) @@ -210,7 +211,8 @@ DOCTEST_MSVC_SUPPRESS_WARNING(26444) // Avoid unnamed objects with custom constr DOCTEST_MSVC_SUPPRESS_WARNING(5027) \ DOCTEST_MSVC_SUPPRESS_WARNING(5026) \ DOCTEST_MSVC_SUPPRESS_WARNING(4623) \ - DOCTEST_MSVC_SUPPRESS_WARNING(5039) + DOCTEST_MSVC_SUPPRESS_WARNING(5039) \ + DOCTEST_MSVC_SUPPRESS_WARNING(5045) #define DOCTEST_MAKE_STD_HEADERS_CLEAN_FROM_WARNINGS_ON_WALL_END DOCTEST_MSVC_SUPPRESS_WARNING_POP @@ -222,13 +224,15 @@ DOCTEST_MSVC_SUPPRESS_WARNING(26444) // Avoid unnamed objects with custom constr // MSVC C++11 feature support table: https://msdn.microsoft.com/en-us/library/hh567368.aspx // GCC C++11 feature support table: https://gcc.gnu.org/projects/cxx-status.html // MSVC version table: -// MSVC++ 15.0 _MSC_VER == 1910 (Visual Studio 2017) -// MSVC++ 14.0 _MSC_VER == 1900 (Visual Studio 2015) -// MSVC++ 12.0 _MSC_VER == 1800 (Visual Studio 2013) -// MSVC++ 11.0 _MSC_VER == 1700 (Visual Studio 2012) -// MSVC++ 10.0 _MSC_VER == 1600 (Visual Studio 2010) -// MSVC++ 9.0 _MSC_VER == 1500 (Visual Studio 2008) -// MSVC++ 8.0 _MSC_VER == 1400 (Visual Studio 2005) +// https://en.wikipedia.org/wiki/Microsoft_Visual_C%2B%2B#Internal_version_numbering +// MSVC++ 14.2 (16) _MSC_VER == 1920 (Visual Studio 2019) << NOT YET RELEASED - April 2 2019 +// MSVC++ 14.1 (15) _MSC_VER == 1910 (Visual Studio 2017) +// MSVC++ 14.0 _MSC_VER == 1900 (Visual Studio 2015) +// MSVC++ 12.0 _MSC_VER == 1800 (Visual Studio 2013) +// MSVC++ 11.0 _MSC_VER == 1700 (Visual Studio 2012) +// MSVC++ 10.0 _MSC_VER == 1600 (Visual Studio 2010) +// MSVC++ 9.0 _MSC_VER == 1500 (Visual Studio 2008) +// MSVC++ 8.0 _MSC_VER == 1400 (Visual Studio 2005) #if DOCTEST_MSVC && !defined(DOCTEST_CONFIG_WINDOWS_SEH) #define DOCTEST_CONFIG_WINDOWS_SEH @@ -237,7 +241,8 @@ DOCTEST_MSVC_SUPPRESS_WARNING(26444) // Avoid unnamed objects with custom constr #undef DOCTEST_CONFIG_WINDOWS_SEH #endif // DOCTEST_CONFIG_NO_WINDOWS_SEH -#if !defined(_WIN32) && !defined(__QNX__) && !defined(DOCTEST_CONFIG_POSIX_SIGNALS) +#if !defined(_WIN32) && !defined(__QNX__) && !defined(DOCTEST_CONFIG_POSIX_SIGNALS) && \ + !defined(__EMSCRIPTEN__) #define DOCTEST_CONFIG_POSIX_SIGNALS #endif // _WIN32 #if defined(DOCTEST_CONFIG_NO_POSIX_SIGNALS) && defined(DOCTEST_CONFIG_POSIX_SIGNALS) @@ -245,12 +250,9 @@ DOCTEST_MSVC_SUPPRESS_WARNING(26444) // Avoid unnamed objects with custom constr #endif // DOCTEST_CONFIG_NO_POSIX_SIGNALS #ifndef DOCTEST_CONFIG_NO_EXCEPTIONS -#if(DOCTEST_GCC || (DOCTEST_CLANG && !DOCTEST_MSVC)) && !defined(__EXCEPTIONS) +#if !defined(__cpp_exceptions) && !defined(__EXCEPTIONS) && !defined(_CPPUNWIND) #define DOCTEST_CONFIG_NO_EXCEPTIONS -#endif // clang and gcc -#if DOCTEST_MSVC && (defined(_HAS_EXCEPTIONS) && _HAS_EXCEPTIONS == 0) -#define DOCTEST_CONFIG_NO_EXCEPTIONS -#endif // MSVC +#endif // no exceptions #endif // DOCTEST_CONFIG_NO_EXCEPTIONS #ifdef DOCTEST_CONFIG_NO_EXCEPTIONS_BUT_WITH_ALL_ASSERTS @@ -290,6 +292,8 @@ DOCTEST_MSVC_SUPPRESS_WARNING(26444) // Avoid unnamed objects with custom constr #define DOCTEST_INTERFACE #endif // DOCTEST_CONFIG_IMPLEMENTATION_IN_DLL +#define DOCTEST_EMPTY + #if DOCTEST_MSVC #define DOCTEST_NOINLINE __declspec(noinline) #define DOCTEST_UNUSED @@ -317,6 +321,8 @@ DOCTEST_MSVC_SUPPRESS_WARNING(26444) // Avoid unnamed objects with custom constr #define DOCTEST_ANONYMOUS(x) DOCTEST_CAT(x, __LINE__) #endif // __COUNTER__ +#define DOCTEST_TOSTR(x) #x + #ifndef DOCTEST_CONFIG_ASSERTION_PARAMETERS_BY_VALUE #define DOCTEST_REF_WRAP(x) x& #else // DOCTEST_CONFIG_ASSERTION_PARAMETERS_BY_VALUE @@ -324,7 +330,7 @@ DOCTEST_MSVC_SUPPRESS_WARNING(26444) // Avoid unnamed objects with custom constr #endif // DOCTEST_CONFIG_ASSERTION_PARAMETERS_BY_VALUE // not using __APPLE__ because... this is how Catch does it -#if defined(__MAC_OS_X_VERSION_MIN_REQUIRED) +#ifdef __MAC_OS_X_VERSION_MIN_REQUIRED #define DOCTEST_PLATFORM_MAC #elif defined(__IPHONE_OS_VERSION_MIN_REQUIRED) #define DOCTEST_PLATFORM_IPHONE @@ -359,40 +365,49 @@ extern "C" __declspec(dllimport) void __stdcall DebugBreak(); #define DOCTEST_BREAK_INTO_DEBUGGER() ((void)0) #endif // linux +// this is kept here for backwards compatibility since the config option was changed +#ifdef DOCTEST_CONFIG_USE_IOSFWD +#define DOCTEST_CONFIG_USE_STD_HEADERS +#endif // DOCTEST_CONFIG_USE_IOSFWD + +#ifdef DOCTEST_CONFIG_USE_STD_HEADERS +#include +#include +#else // DOCTEST_CONFIG_USE_STD_HEADERS + #if DOCTEST_CLANG // to detect if libc++ is being used with clang (the _LIBCPP_VERSION identifier) #include #endif // clang +#ifdef _LIBCPP_VERSION +#define DOCTEST_STD_NAMESPACE_BEGIN _LIBCPP_BEGIN_NAMESPACE_STD +#define DOCTEST_STD_NAMESPACE_END _LIBCPP_END_NAMESPACE_STD +#else // _LIBCPP_VERSION +#define DOCTEST_STD_NAMESPACE_BEGIN namespace std { +#define DOCTEST_STD_NAMESPACE_END } +#endif // _LIBCPP_VERSION + // Forward declaring 'X' in namespace std is not permitted by the C++ Standard. DOCTEST_MSVC_SUPPRESS_WARNING_WITH_PUSH(4643) -#if defined(_LIBCPP_VERSION) || defined(DOCTEST_CONFIG_USE_IOSFWD) -// not forward declaring ostream for libc++ because I had some problems (inline namespaces vs c++98) -// so the header is used - also it is very light and doesn't drag a ton of stuff -#include -#else // _LIBCPP_VERSION -namespace std { +DOCTEST_STD_NAMESPACE_BEGIN +typedef decltype(nullptr) nullptr_t; template struct char_traits; template <> struct char_traits; template class basic_ostream; -typedef basic_ostream > ostream; -} // namespace std -#endif // _LIBCPP_VERSION || DOCTEST_CONFIG_USE_IOSFWD - -#ifdef _LIBCPP_VERSION -#include -#else // _LIBCPP_VERSION -namespace std { -typedef decltype(nullptr) nullptr_t; -} -#endif // _LIBCPP_VERSION +typedef basic_ostream> ostream; +template +class tuple; +DOCTEST_STD_NAMESPACE_END DOCTEST_MSVC_SUPPRESS_WARNING_POP +#endif // DOCTEST_CONFIG_USE_STD_HEADERS + #ifdef DOCTEST_CONFIG_INCLUDE_TYPE_TRAITS #include #endif // DOCTEST_CONFIG_INCLUDE_TYPE_TRAITS @@ -449,6 +464,7 @@ public: String(); ~String(); + // cppcheck-suppress noExplicitConstructor String(const char* in); String(const char* in, unsigned in_size); @@ -600,7 +616,7 @@ namespace assertType { DOCTEST_INTERFACE const char* assertString(assertType::Enum at); DOCTEST_INTERFACE const char* failureString(assertType::Enum at); -DOCTEST_INTERFACE const char* removePathFromFilename(const char* file); +DOCTEST_INTERFACE const char* skipPathFromFilename(const char* file); struct DOCTEST_INTERFACE TestCaseData { @@ -680,7 +696,12 @@ struct DOCTEST_INTERFACE IContextScope struct ContextOptions //!OCLINT too many fields { + std::ostream* cout; // stdout stream - std::cout by default + std::ostream* cerr; // stderr stream - std::cerr by default + String binary_name; // the test binary name + // == parameters from the command line + String out; // output filename String order_by; // how tests should be ordered unsigned rand_seed; // the seed for rand ordering @@ -764,7 +785,7 @@ namespace detail { { static std::ostream& s; static const DOCTEST_REF_WRAP(T) t; - static const bool value = sizeof(testStreamable(s << t)) == sizeof(yes); + static const bool value = sizeof(decltype(testStreamable(s << t))) == sizeof(yes); }; } // namespace has_insertion_operator_impl @@ -1004,6 +1025,9 @@ namespace detail { return Result(res); \ } + // more checks could be added - like in Catch: + // https://github.com/catchorg/Catch2/pull/1480/files + // https://github.com/catchorg/Catch2/pull/1481/files #define DOCTEST_FORBIT_EXPRESSION(rt, op) \ template \ rt& operator op(const R&) { \ @@ -1188,8 +1212,8 @@ namespace detail { // The right operator for capturing expressions is "<=" instead of "<<" (based on the operator precedence table) // but then there will be warnings from GCC about "-Wparentheses" and since "_Pragma()" is problematic this will stay for now... - // https://github.com/philsquared/Catch/issues/870 - // https://github.com/philsquared/Catch/issues/565 + // https://github.com/catchorg/Catch2/issues/870 + // https://github.com/catchorg/Catch2/issues/565 template Expression_lhs operator<<(const DOCTEST_REF_WRAP(L) operand) { return Expression_lhs(operand, m_at); @@ -1403,10 +1427,10 @@ namespace detail { explicit ExceptionTranslator(String (*translateFunction)(T)) : m_translateFunction(translateFunction) {} - bool translate(String& res) const { + bool translate(String& res) const override { #ifndef DOCTEST_CONFIG_NO_EXCEPTIONS try { - throw; + throw; // lgtm [cpp/rethrow-no-exception] // cppcheck-suppress catchExceptionByValue } catch(T ex) { // NOLINT res = m_translateFunction(ex); //!OCLINT parameter reassignment @@ -1423,21 +1447,17 @@ namespace detail { DOCTEST_INTERFACE void registerExceptionTranslatorImpl(const IExceptionTranslator* et); - // FIX FOR VISUAL STUDIO VERSIONS PRIOR TO 2015 - they failed to compile the call to operator<< with - // std::ostream passed as a reference noting that there is a use of an undefined type (which there isn't) - DOCTEST_INTERFACE void writeStringToStream(std::ostream* s, const String& str); - template struct StringStreamBase { template static void convert(std::ostream* s, const T& in) { - writeStringToStream(s, toString(in)); + *s << toString(in); } // always treat char* as a string in this context - no matter // if DOCTEST_CONFIG_TREAT_CHAR_STAR_AS_STRING is defined - static void convert(std::ostream* s, const char* in) { writeStringToStream(s, String(in)); } + static void convert(std::ostream* s, const char* in) { *s << String(in); } }; template <> @@ -1699,17 +1719,21 @@ namespace TestCaseFailureReason { struct DOCTEST_INTERFACE CurrentTestCaseStats { - int numAssertsForCurrentTestCase; - int numAssertsFailedForCurrentTestCase; - double seconds_so_far; + int numAssertsCurrentTest; + int numAssertsFailedCurrentTest; + double seconds; int failure_flags; // use TestCaseFailureReason::Enum - String error_string; - bool should_reenter; // means we are not done with the test case because of subcases DOCTEST_DECLARE_DEFAULTS(CurrentTestCaseStats); DOCTEST_DELETE_COPIES(CurrentTestCaseStats); }; +struct DOCTEST_INTERFACE TestCaseException +{ + String error_string; + bool is_crash; +}; + struct DOCTEST_INTERFACE TestRunStats { unsigned numTestCases; @@ -1723,23 +1747,39 @@ struct DOCTEST_INTERFACE TestRunStats DOCTEST_DELETE_COPIES(TestRunStats); }; +struct QueryData +{ + const TestRunStats* run_stats = nullptr; + String* data = nullptr; + unsigned num_data = 0; +}; + struct DOCTEST_INTERFACE IReporter { - // called when the whole test run starts (safe to cache a pointer to the input) - virtual void test_run_start(const ContextOptions&) = 0; + // The constructor has to accept "const ContextOptions&" as a single argument + // which has most of the options for the run + a pointer to the stdout stream + // Reporter(const ContextOptions& in) + + // called when a query should be reported (listing test cases, printing the version, etc.) + virtual void report_query(const QueryData&) = 0; + + // called when the whole test run starts + virtual void test_run_start() = 0; // called when the whole test run ends (caching a pointer to the input doesn't make sense here) virtual void test_run_end(const TestRunStats&) = 0; // called when a test case is started (safe to cache a pointer to the input) virtual void test_case_start(const TestCaseData&) = 0; - // called when a test case has ended - could be re-entered if more subcases have to be - // traversed - check CurrentTestCaseStats::should_reenter (caching a pointer to the input doesn't make sense here) + // called when a test case has ended virtual void test_case_end(const CurrentTestCaseStats&) = 0; + // called when an exception is thrown from the test case (or it crashes) + virtual void test_case_exception(const TestCaseException&) = 0; + // called whenever a subcase is entered (don't cache pointers to the input) virtual void subcase_start(const SubcaseSignature&) = 0; // called whenever a subcase is exited (don't cache pointers to the input) - virtual void subcase_end(const SubcaseSignature&) = 0; + virtual void subcase_end() = 0; // called for each assert (don't cache pointers to the input) virtual void log_assert(const AssertData&) = 0; @@ -1762,8 +1802,22 @@ struct DOCTEST_INTERFACE IReporter static const String* get_stringified_contexts(); }; -int registerReporter(const char* name, int priority, IReporter& r); +namespace detail { + typedef IReporter* (*reporterCreatorFunc)(const ContextOptions&); + DOCTEST_INTERFACE void registerReporterImpl(const char* name, int prio, reporterCreatorFunc c); + + template + IReporter* reporterCreator(const ContextOptions& o) { + return new Reporter(o); + } +} // namespace detail + +template +int registerReporter(const char* name, int priority) { + detail::registerReporterImpl(name, priority, detail::reporterCreator); + return 0; +} } // namespace doctest // if registering is not disabled @@ -1785,11 +1839,13 @@ int registerReporter(const char* name, int priority, IReporter& r); #endif // DOCTEST_CONFIG_NO_TRY_CATCH_IN_ASSERTS // registers the test by initializing a dummy var with a function -#define DOCTEST_REGISTER_FUNCTION(f, decorators) \ - DOCTEST_GLOBAL_NO_WARNINGS(DOCTEST_ANONYMOUS(_DOCTEST_ANON_VAR_)) = doctest::detail::regTest( \ - doctest::detail::TestCase(f, __FILE__, __LINE__, \ - doctest_detail_test_suite_ns::getCurrentTestSuite()) * \ - decorators); \ +#define DOCTEST_REGISTER_FUNCTION(global_prefix, f, decorators) \ + global_prefix DOCTEST_GLOBAL_NO_WARNINGS(DOCTEST_ANONYMOUS(_DOCTEST_ANON_VAR_)) = \ + doctest::detail::regTest( \ + doctest::detail::TestCase( \ + f, __FILE__, __LINE__, \ + doctest_detail_test_suite_ns::getCurrentTestSuite()) * \ + decorators); \ DOCTEST_GLOBAL_NO_WARNINGS_END() #define DOCTEST_IMPLEMENT_FIXTURE(der, base, func, decorators) \ @@ -1802,19 +1858,35 @@ int registerReporter(const char* name, int priority, IReporter& r); der v; \ v.f(); \ } \ - DOCTEST_REGISTER_FUNCTION(func, decorators) \ + DOCTEST_REGISTER_FUNCTION(DOCTEST_EMPTY, func, decorators) \ } \ inline DOCTEST_NOINLINE void der::f() #define DOCTEST_CREATE_AND_REGISTER_FUNCTION(f, decorators) \ static void f(); \ - DOCTEST_REGISTER_FUNCTION(f, decorators) \ + DOCTEST_REGISTER_FUNCTION(DOCTEST_EMPTY, f, decorators) \ + static void f() + +#define DOCTEST_CREATE_AND_REGISTER_FUNCTION_IN_CLASS(f, proxy, decorators) \ + static doctest::detail::funcType proxy() { return f; } \ + DOCTEST_REGISTER_FUNCTION(inline const, proxy(), decorators) \ static void f() // for registering tests #define DOCTEST_TEST_CASE(decorators) \ DOCTEST_CREATE_AND_REGISTER_FUNCTION(DOCTEST_ANONYMOUS(_DOCTEST_ANON_FUNC_), decorators) +// for registering tests in classes - requires C++17 for inline variables! +#if __cplusplus >= 201703L || (DOCTEST_MSVC >= DOCTEST_COMPILER(19, 12, 0) && _MSVC_LANG >= 201703L) +#define DOCTEST_TEST_CASE_CLASS(decorators) \ + DOCTEST_CREATE_AND_REGISTER_FUNCTION_IN_CLASS(DOCTEST_ANONYMOUS(_DOCTEST_ANON_FUNC_), \ + DOCTEST_ANONYMOUS(_DOCTEST_ANON_PROXY_), \ + decorators) +#else // DOCTEST_TEST_CASE_CLASS +#define DOCTEST_TEST_CASE_CLASS(...) \ + TEST_CASES_CAN_BE_REGISTERED_IN_CLASSES_ONLY_IN_CPP17_MODE_OR_WITH_VS_2017_OR_NEWER +#endif // DOCTEST_TEST_CASE_CLASS + // for registering tests with a fixture #define DOCTEST_TEST_CASE_FIXTURE(c, decorators) \ DOCTEST_IMPLEMENT_FIXTURE(DOCTEST_ANONYMOUS(_DOCTEST_ANON_CLASS_), c, \ @@ -1841,49 +1913,58 @@ int registerReporter(const char* name, int priority, IReporter& r); doctest::detail::type_to_string(), idx) * \ decorators) -#define DOCTEST_TEST_CASE_TEMPLATE_DEFINE_IMPL(dec, T, id, anon) \ +#define DOCTEST_TEST_CASE_TEMPLATE_DEFINE_IMPL(dec, T, iter, func) \ template \ - inline void anon(); \ + inline void func(); \ + template \ + struct iter; \ template \ - struct DOCTEST_CAT(id, ITERATOR) \ + struct iter> \ { \ - DOCTEST_CAT(id, ITERATOR)(int line, int index) { \ - DOCTEST_REGISTER_TYPED_TEST_CASE_IMPL(anon, Type, dec, line * 1000 + index); \ - DOCTEST_CAT(id, ITERATOR)(line, index + 1); \ + iter(int line, int index) { \ + DOCTEST_REGISTER_TYPED_TEST_CASE_IMPL(func, Type, dec, line * 1000 + index); \ + iter>(line, index + 1); \ } \ }; \ - template \ - struct DOCTEST_CAT(id, ITERATOR) \ + template <> \ + struct iter> \ { \ - DOCTEST_CAT(id, ITERATOR)(int line, int index) { \ - DOCTEST_REGISTER_TYPED_TEST_CASE_IMPL(anon, Type, dec, line * 1000 + index); \ - } \ - } - -#define DOCTEST_TEST_CASE_TEMPLATE_DEFINE_IMPL_PROXY(dec, T, id, anon) \ - DOCTEST_TEST_CASE_TEMPLATE_DEFINE_IMPL(dec, T, id, anon); \ + iter(int, int) {} \ + }; \ template \ - inline void anon() + inline void func() #define DOCTEST_TEST_CASE_TEMPLATE_DEFINE(dec, T, id) \ - DOCTEST_TEST_CASE_TEMPLATE_DEFINE_IMPL_PROXY(dec, T, id, DOCTEST_ANONYMOUS(_DOCTEST_ANON_TMP_)) + DOCTEST_TEST_CASE_TEMPLATE_DEFINE_IMPL(dec, T, DOCTEST_CAT(id, ITERATOR), \ + DOCTEST_ANONYMOUS(_DOCTEST_ANON_TMP_)) -#define DOCTEST_TEST_CASE_TEMPLATE_INSTANTIATE_IMPL(id, anon, ...) \ - DOCTEST_GLOBAL_NO_WARNINGS(DOCTEST_CAT(anon, DUMMY)) = []() { \ +#define DOCTEST_TEST_CASE_TEMPLATE_INVOKE_IMPL(id, anon, ...) \ + DOCTEST_GLOBAL_NO_WARNINGS(DOCTEST_CAT(anon, DUMMY)) = [] { \ + DOCTEST_CAT(id, ITERATOR)> DOCTEST_UNUSED DOCTEST_CAT( \ + anon, inner_dummy)(__LINE__, 0); \ + return 0; \ + }(); \ + DOCTEST_GLOBAL_NO_WARNINGS_END() + +#define DOCTEST_TEST_CASE_TEMPLATE_INVOKE(id, ...) \ + DOCTEST_TEST_CASE_TEMPLATE_INVOKE_IMPL(id, DOCTEST_ANONYMOUS(_DOCTEST_ANON_TMP_), __VA_ARGS__) \ + typedef int DOCTEST_ANONYMOUS(_DOCTEST_ANON_FOR_SEMICOLON_) + +#define DOCTEST_TEST_CASE_TEMPLATE_APPLY_IMPL(id, anon, ...) \ + DOCTEST_GLOBAL_NO_WARNINGS(DOCTEST_CAT(anon, DUMMY)) = [] { \ DOCTEST_CAT(id, ITERATOR)<__VA_ARGS__> DOCTEST_UNUSED DOCTEST_CAT(anon, inner_dummy)( \ __LINE__, 0); \ return 0; \ }(); \ DOCTEST_GLOBAL_NO_WARNINGS_END() -#define DOCTEST_TEST_CASE_TEMPLATE_INSTANTIATE(id, ...) \ - DOCTEST_TEST_CASE_TEMPLATE_INSTANTIATE_IMPL(id, DOCTEST_ANONYMOUS(_DOCTEST_ANON_TMP_), \ - __VA_ARGS__) \ +#define DOCTEST_TEST_CASE_TEMPLATE_APPLY(id, ...) \ + DOCTEST_TEST_CASE_TEMPLATE_APPLY_IMPL(id, DOCTEST_ANONYMOUS(_DOCTEST_ANON_TMP_), __VA_ARGS__) \ typedef int DOCTEST_ANONYMOUS(_DOCTEST_ANON_FOR_SEMICOLON_) #define DOCTEST_TEST_CASE_TEMPLATE_IMPL(dec, T, anon, ...) \ - DOCTEST_TEST_CASE_TEMPLATE_DEFINE_IMPL_PROXY(dec, T, anon, anon); \ - DOCTEST_TEST_CASE_TEMPLATE_INSTANTIATE_IMPL(anon, anon, __VA_ARGS__) \ + DOCTEST_TEST_CASE_TEMPLATE_DEFINE_IMPL(dec, T, DOCTEST_CAT(anon, ITERATOR), anon); \ + DOCTEST_TEST_CASE_TEMPLATE_INVOKE_IMPL(anon, anon, __VA_ARGS__) \ template \ inline void anon() @@ -1947,7 +2028,7 @@ int registerReporter(const char* name, int priority, IReporter& r); // for registering #define DOCTEST_REGISTER_REPORTER(name, priority, reporter) \ DOCTEST_GLOBAL_NO_WARNINGS(DOCTEST_ANONYMOUS(_DOCTEST_ANON_REPORTER_)) = \ - doctest::registerReporter(name, priority, reporter); \ + doctest::registerReporter(name, priority); \ DOCTEST_GLOBAL_NO_WARNINGS_END() typedef int DOCTEST_ANONYMOUS(_DOCTEST_ANON_FOR_SEMICOLON_) // for logging @@ -2026,17 +2107,7 @@ constexpr T to_lvalue = x; #define DOCTEST_REQUIRE_FALSE_MESSAGE(cond, msg) do { DOCTEST_INFO(msg); DOCTEST_ASSERT_IMPLEMENT_2(DT_REQUIRE_FALSE, cond); } while((void)0, 0) // clang-format on -#define DOCTEST_ASSERT_THROWS(expr, assert_type) \ - do { \ - if(!doctest::getContextOptions()->no_throw) { \ - doctest::detail::ResultBuilder _DOCTEST_RB(doctest::assertType::assert_type, __FILE__, \ - __LINE__, #expr); \ - try { \ - expr; \ - } catch(...) { _DOCTEST_RB.m_threw = true; } \ - DOCTEST_ASSERT_LOG_AND_REACT(_DOCTEST_RB); \ - } \ - } while((void)0, 0) +#define DOCTEST_ASSERT_THROWS(expr, assert_type) DOCTEST_ASSERT_THROWS_WITH(expr, assert_type, "") #define DOCTEST_ASSERT_THROWS_AS(expr, assert_type, ...) \ do { \ @@ -2047,7 +2118,7 @@ constexpr T to_lvalue = x; expr; \ } catch(const doctest::detail::remove_const< \ doctest::detail::remove_reference<__VA_ARGS__>::type>::type&) { \ - _DOCTEST_RB.m_threw = true; \ + _DOCTEST_RB.translateException(); \ _DOCTEST_RB.m_threw_as = true; \ } catch(...) { _DOCTEST_RB.translateException(); } \ DOCTEST_ASSERT_LOG_AND_REACT(_DOCTEST_RB); \ @@ -2263,6 +2334,10 @@ constexpr T to_lvalue = x; #define DOCTEST_TEST_CASE(name) \ DOCTEST_CREATE_AND_REGISTER_FUNCTION(DOCTEST_ANONYMOUS(_DOCTEST_ANON_FUNC_), name) +// for registering tests in classes +#define DOCTEST_TEST_CASE_CLASS(name) \ + DOCTEST_CREATE_AND_REGISTER_FUNCTION(DOCTEST_ANONYMOUS(_DOCTEST_ANON_FUNC_), name) + // for registering tests with a fixture #define DOCTEST_TEST_CASE_FIXTURE(x, name) \ DOCTEST_IMPLEMENT_FIXTURE(DOCTEST_ANONYMOUS(_DOCTEST_ANON_CLASS_), x, \ @@ -2281,7 +2356,10 @@ constexpr T to_lvalue = x; template \ inline void DOCTEST_ANONYMOUS(_DOCTEST_ANON_TMP_)() -#define DOCTEST_TEST_CASE_TEMPLATE_INSTANTIATE(id, ...) \ +#define DOCTEST_TEST_CASE_TEMPLATE_INVOKE(id, ...) \ + typedef int DOCTEST_ANONYMOUS(_DOCTEST_ANON_FOR_SEMICOLON_) + +#define DOCTEST_TEST_CASE_TEMPLATE_APPLY(id, ...) \ typedef int DOCTEST_ANONYMOUS(_DOCTEST_ANON_FOR_SEMICOLON_) // for subcases @@ -2406,11 +2484,14 @@ constexpr T to_lvalue = x; #define DOCTEST_FAST_WARN_UNARY_FALSE DOCTEST_WARN_UNARY_FALSE #define DOCTEST_FAST_CHECK_UNARY_FALSE DOCTEST_CHECK_UNARY_FALSE #define DOCTEST_FAST_REQUIRE_UNARY_FALSE DOCTEST_REQUIRE_UNARY_FALSE + +#define DOCTEST_TEST_CASE_TEMPLATE_INSTANTIATE DOCTEST_TEST_CASE_TEMPLATE_INVOKE // clang-format on // BDD style macros // clang-format off #define DOCTEST_SCENARIO(name) DOCTEST_TEST_CASE(" Scenario: " name) +#define DOCTEST_SCENARIO_CLASS(name) DOCTEST_TEST_CASE_CLASS(" Scenario: " name) #define DOCTEST_SCENARIO_TEMPLATE(name, T, ...) DOCTEST_TEST_CASE_TEMPLATE(" Scenario: " name, T, __VA_ARGS__) #define DOCTEST_SCENARIO_TEMPLATE_DEFINE(name, T, id) DOCTEST_TEST_CASE_TEMPLATE_DEFINE(" Scenario: " name, T, id) @@ -2425,11 +2506,13 @@ constexpr T to_lvalue = x; #if !defined(DOCTEST_CONFIG_NO_SHORT_MACRO_NAMES) #define TEST_CASE DOCTEST_TEST_CASE +#define TEST_CASE_CLASS DOCTEST_TEST_CASE_CLASS #define TEST_CASE_FIXTURE DOCTEST_TEST_CASE_FIXTURE #define TYPE_TO_STRING DOCTEST_TYPE_TO_STRING #define TEST_CASE_TEMPLATE DOCTEST_TEST_CASE_TEMPLATE #define TEST_CASE_TEMPLATE_DEFINE DOCTEST_TEST_CASE_TEMPLATE_DEFINE -#define TEST_CASE_TEMPLATE_INSTANTIATE DOCTEST_TEST_CASE_TEMPLATE_INSTANTIATE +#define TEST_CASE_TEMPLATE_INVOKE DOCTEST_TEST_CASE_TEMPLATE_INVOKE +#define TEST_CASE_TEMPLATE_APPLY DOCTEST_TEST_CASE_TEMPLATE_APPLY #define SUBCASE DOCTEST_SUBCASE #define TEST_SUITE DOCTEST_TEST_SUITE #define TEST_SUITE_BEGIN DOCTEST_TEST_SUITE_BEGIN @@ -2485,6 +2568,7 @@ constexpr T to_lvalue = x; #define REQUIRE_NOTHROW_MESSAGE DOCTEST_REQUIRE_NOTHROW_MESSAGE #define SCENARIO DOCTEST_SCENARIO +#define SCENARIO_CLASS DOCTEST_SCENARIO_CLASS #define SCENARIO_TEMPLATE DOCTEST_SCENARIO_TEMPLATE #define SCENARIO_TEMPLATE_DEFINE DOCTEST_SCENARIO_TEMPLATE_DEFINE #define GIVEN DOCTEST_GIVEN @@ -2537,6 +2621,7 @@ constexpr T to_lvalue = x; #define FAST_WARN_LE DOCTEST_FAST_WARN_LE #define FAST_CHECK_LE DOCTEST_FAST_CHECK_LE #define FAST_REQUIRE_LE DOCTEST_FAST_REQUIRE_LE + #define FAST_WARN_UNARY DOCTEST_FAST_WARN_UNARY #define FAST_CHECK_UNARY DOCTEST_FAST_CHECK_UNARY #define FAST_REQUIRE_UNARY DOCTEST_FAST_REQUIRE_UNARY @@ -2544,6 +2629,8 @@ constexpr T to_lvalue = x; #define FAST_CHECK_UNARY_FALSE DOCTEST_FAST_CHECK_UNARY_FALSE #define FAST_REQUIRE_UNARY_FALSE DOCTEST_FAST_REQUIRE_UNARY_FALSE +#define TEST_CASE_TEMPLATE_INSTANTIATE DOCTEST_TEST_CASE_TEMPLATE_INSTANTIATE + #endif // DOCTEST_CONFIG_NO_SHORT_MACRO_NAMES #if !defined(DOCTEST_CONFIG_DISABLE) @@ -2560,7 +2647,9 @@ namespace doctest { namespace detail { DOCTEST_TYPE_TO_STRING_IMPL(char) DOCTEST_TYPE_TO_STRING_IMPL(signed char) DOCTEST_TYPE_TO_STRING_IMPL(unsigned char) +#if !DOCTEST_MSVC || defined(_NATIVE_WCHAR_T_DEFINED) DOCTEST_TYPE_TO_STRING_IMPL(wchar_t) +#endif // not MSVC or wchar_t support enabled DOCTEST_TYPE_TO_STRING_IMPL(short int) DOCTEST_TYPE_TO_STRING_IMPL(unsigned short int) DOCTEST_TYPE_TO_STRING_IMPL(int) @@ -2611,6 +2700,7 @@ DOCTEST_CLANG_SUPPRESS_WARNING("-Wmissing-braces") DOCTEST_CLANG_SUPPRESS_WARNING("-Wmissing-field-initializers") DOCTEST_CLANG_SUPPRESS_WARNING("-Wc++98-compat") DOCTEST_CLANG_SUPPRESS_WARNING("-Wc++98-compat-pedantic") +DOCTEST_CLANG_SUPPRESS_WARNING("-Wunused-member-function") DOCTEST_GCC_SUPPRESS_WARNING_PUSH DOCTEST_GCC_SUPPRESS_WARNING("-Wunknown-pragmas") @@ -2631,6 +2721,7 @@ DOCTEST_GCC_SUPPRESS_WARNING("-Wunsafe-loop-optimizations") DOCTEST_GCC_SUPPRESS_WARNING("-Wold-style-cast") DOCTEST_GCC_SUPPRESS_WARNING("-Wunused-local-typedefs") DOCTEST_GCC_SUPPRESS_WARNING("-Wuseless-cast") +DOCTEST_GCC_SUPPRESS_WARNING("-Wunused-function") DOCTEST_MSVC_SUPPRESS_WARNING_PUSH DOCTEST_MSVC_SUPPRESS_WARNING(4616) // invalid compiler warning @@ -2675,6 +2766,7 @@ DOCTEST_MAKE_STD_HEADERS_CLEAN_FROM_WARNINGS_ON_WALL_BEGIN #include #include #include +#include #include #include #include @@ -2686,7 +2778,9 @@ DOCTEST_MAKE_STD_HEADERS_CLEAN_FROM_WARNINGS_ON_WALL_BEGIN #include #include #include +#ifdef DOCTEST_CONFIG_POSIX_SIGNALS #include +#endif // DOCTEST_CONFIG_POSIX_SIGNALS #include #include #include @@ -2697,6 +2791,34 @@ DOCTEST_MAKE_STD_HEADERS_CLEAN_FROM_WARNINGS_ON_WALL_BEGIN #include #endif // DOCTEST_PLATFORM_MAC +#ifdef DOCTEST_PLATFORM_WINDOWS + +// defines for a leaner windows.h +#ifndef WIN32_LEAN_AND_MEAN +#define WIN32_LEAN_AND_MEAN +#endif // WIN32_LEAN_AND_MEAN +#ifndef VC_EXTRA_LEAN +#define VC_EXTRA_LEAN +#endif // VC_EXTRA_LEAN +#ifndef NOMINMAX +#define NOMINMAX +#endif // NOMINMAX + +// not sure what AfxWin.h is for - here I do what Catch does +#ifdef __AFXDLL +#include +#else +#include +#endif +#include + +#else // DOCTEST_PLATFORM_WINDOWS + +#include +#include + +#endif // DOCTEST_PLATFORM_WINDOWS + DOCTEST_MAKE_STD_HEADERS_CLEAN_FROM_WARNINGS_ON_WALL_END // counts the number of elements in a C array @@ -2760,14 +2882,12 @@ namespace { }; static Arch which() { - union _ - { - int asInt; - char asChar[sizeof(int)]; - } u; - - u.asInt = 1; // NOLINT - return (u.asChar[sizeof(int) - 1] == 1) ? Big : Little; // NOLINT + int x = 1; + // casting any data pointer to char* is allowed + auto ptr = reinterpret_cast(&x); + if(*ptr) + return Little; + return Big; } }; } // namespace @@ -2806,13 +2926,52 @@ namespace detail { } #ifndef DOCTEST_CONFIG_DISABLE + + typedef uint64_t UInt64; + +#ifdef DOCTEST_CONFIG_GETCURRENTTICKS + UInt64 getCurrentTicks() { return DOCTEST_CONFIG_GETCURRENTTICKS(); } +#elif defined(DOCTEST_PLATFORM_WINDOWS) + UInt64 getCurrentTicks() { + static UInt64 hz = 0, hzo = 0; + if(!hz) { + QueryPerformanceFrequency(reinterpret_cast(&hz)); + QueryPerformanceCounter(reinterpret_cast(&hzo)); + } + UInt64 t; + QueryPerformanceCounter(reinterpret_cast(&t)); + return ((t - hzo) * 1000000) / hz; + } +#else // DOCTEST_PLATFORM_WINDOWS + UInt64 getCurrentTicks() { + timeval t; + gettimeofday(&t, nullptr); + return static_cast(t.tv_sec) * 1000000 + static_cast(t.tv_usec); + } +#endif // DOCTEST_PLATFORM_WINDOWS + + struct Timer + { + void start() { m_ticks = getCurrentTicks(); } + unsigned int getElapsedMicroseconds() const { + return static_cast(getCurrentTicks() - m_ticks); + } + //unsigned int getElapsedMilliseconds() const { + // return static_cast(getElapsedMicroseconds() / 1000); + //} + double getElapsedSeconds() const { return getElapsedMicroseconds() / 1000000.0; } + + private: + UInt64 m_ticks = 0; + }; + // this holds both parameters from the command line and runtime data for tests struct ContextState : ContextOptions, TestRunStats, CurrentTestCaseStats { - std::atomic numAssertsForCurrentTestCase_atomic; - std::atomic numAssertsFailedForCurrentTestCase_atomic; + std::atomic numAssertsCurrentTest_atomic; + std::atomic numAssertsFailedCurrentTest_atomic; - std::vector > filters = decltype(filters)(9); // 9 different filters + std::vector> filters = decltype(filters)(9); // 9 different filters std::vector reporters_currently_used; @@ -2820,12 +2979,15 @@ namespace detail { assert_handler ah = nullptr; + Timer timer; + std::vector stringifiedContexts; // logging from INFO() due to an exception // stuff for subcases std::set subcasesPassed; std::set subcasesEnteredLevels; int subcasesCurrentLevel; + bool should_reenter; void resetRunData() { numTestCases = 0; @@ -2834,11 +2996,58 @@ namespace detail { numTestCasesFailed = 0; numAsserts = 0; numAssertsFailed = 0; + numAssertsCurrentTest = 0; + numAssertsFailedCurrentTest = 0; + } + + void finalizeTestCaseData() { + seconds = timer.getElapsedSeconds(); + + // update the non-atomic counters + numAsserts += numAssertsCurrentTest_atomic; + numAssertsFailed += numAssertsFailedCurrentTest_atomic; + numAssertsCurrentTest = numAssertsCurrentTest_atomic; + numAssertsFailedCurrentTest = numAssertsFailedCurrentTest_atomic; + + if(numAssertsFailedCurrentTest) + failure_flags |= TestCaseFailureReason::AssertFailure; + + if(Approx(currentTest->m_timeout).epsilon(DBL_EPSILON) != 0 && + Approx(seconds).epsilon(DBL_EPSILON) > currentTest->m_timeout) + failure_flags |= TestCaseFailureReason::Timeout; + + if(currentTest->m_should_fail) { + if(failure_flags) { + failure_flags |= TestCaseFailureReason::ShouldHaveFailedAndDid; + } else { + failure_flags |= TestCaseFailureReason::ShouldHaveFailedButDidnt; + } + } else if(failure_flags && currentTest->m_may_fail) { + failure_flags |= TestCaseFailureReason::CouldHaveFailedAndDid; + } else if(currentTest->m_expected_failures > 0) { + if(numAssertsFailedCurrentTest == currentTest->m_expected_failures) { + failure_flags |= TestCaseFailureReason::FailedExactlyNumTimes; + } else { + failure_flags |= TestCaseFailureReason::DidntFailExactlyNumTimes; + } + } + + bool ok_to_fail = (TestCaseFailureReason::ShouldHaveFailedAndDid & failure_flags) || + (TestCaseFailureReason::CouldHaveFailedAndDid & failure_flags) || + (TestCaseFailureReason::FailedExactlyNumTimes & failure_flags); + + // if any subcase has failed - the whole test case has failed + if(failure_flags && !ok_to_fail) + numTestCasesFailed++; } }; - ContextState* g_cs = nullptr; - DOCTEST_THREAD_LOCAL bool g_no_colors; // used to avoid locks for the debug output + ContextState* g_cs = nullptr; + + // used to avoid locks for the debug output + // TODO: figure out if this is indeed necessary/correct - seems like either there still + // could be a race or that there wouldn't be a race even if using the context directly + DOCTEST_THREAD_LOCAL bool g_no_colors; #endif // DOCTEST_CONFIG_DISABLE } // namespace detail @@ -3082,18 +3291,18 @@ const char* assertString(assertType::Enum at) { const char* failureString(assertType::Enum at) { if(at & assertType::is_warn) //!OCLINT bitwise operator in conditional - return "WARNING: "; + return "WARNING"; if(at & assertType::is_check) //!OCLINT bitwise operator in conditional - return "ERROR: "; + return "ERROR"; if(at & assertType::is_require) //!OCLINT bitwise operator in conditional - return "FATAL ERROR: "; + return "FATAL ERROR"; return ""; } DOCTEST_CLANG_SUPPRESS_WARNING_WITH_PUSH("-Wnull-dereference") DOCTEST_GCC_SUPPRESS_WARNING_WITH_PUSH("-Wnull-dereference") // depending on the current options this will remove the path of filenames -const char* removePathFromFilename(const char* file) { +const char* skipPathFromFilename(const char* file) { if(getContextOptions()->no_path_in_filenames) { auto back = std::strrchr(file, '\\'); auto forward = std::strrchr(file, '/'); @@ -3253,52 +3462,6 @@ int registerReporter(const char*, int, IReporter*) { return 0; } #endif // DOCTEST_CONFIG_COLORS_WINDOWS && DOCTEST_CONFIG_COLORS_ANSI #endif // DOCTEST_CONFIG_COLORS_NONE -#if DOCTEST_MSVC || defined(__MINGW32__) -#if DOCTEST_MSVC -#define DOCTEST_WINDOWS_SAL_IN_OPT _In_opt_ -#else // MSVC -#define DOCTEST_WINDOWS_SAL_IN_OPT -#endif // MSVC -extern "C" __declspec(dllimport) void __stdcall OutputDebugStringA( - DOCTEST_WINDOWS_SAL_IN_OPT const char*); -extern "C" __declspec(dllimport) int __stdcall IsDebuggerPresent(); -#endif // MSVC || __MINGW32__ - -#ifdef DOCTEST_CONFIG_COLORS_ANSI -#include -#endif // DOCTEST_CONFIG_COLORS_ANSI - -#ifdef DOCTEST_PLATFORM_WINDOWS - -// defines for a leaner windows.h -#ifndef WIN32_LEAN_AND_MEAN -#define WIN32_LEAN_AND_MEAN -#endif // WIN32_LEAN_AND_MEAN -#ifndef VC_EXTRA_LEAN -#define VC_EXTRA_LEAN -#endif // VC_EXTRA_LEAN -#ifndef NOMINMAX -#define NOMINMAX -#endif // NOMINMAX - -DOCTEST_MAKE_STD_HEADERS_CLEAN_FROM_WARNINGS_ON_WALL_BEGIN - -// not sure what AfxWin.h is for - here I do what Catch does -#ifdef __AFXDLL -#include -#else -#include -#endif -#include - -DOCTEST_MAKE_STD_HEADERS_CLEAN_FROM_WARNINGS_ON_WALL_END - -#else // DOCTEST_PLATFORM_WINDOWS - -#include - -#endif // DOCTEST_PLATFORM_WINDOWS - namespace doctest_detail_test_suite_ns { // holds the current test suite doctest::detail::TestSuite& getCurrentTestSuite() { @@ -3309,9 +3472,10 @@ doctest::detail::TestSuite& getCurrentTestSuite() { namespace doctest { namespace { - using namespace detail; - typedef std::map, IReporter*> reporterMap; - reporterMap& getReporters() { + // the int (priority) is part of the key for automatic sorting - sadly one can register a + // reporter with a duplicate name and a different priority but hopefully that won't happen often :| + typedef std::map, reporterCreatorFunc> reporterMap; + reporterMap& getReporters() { static reporterMap data; return data; } @@ -3329,7 +3493,7 @@ namespace detail { if((at & assertType::is_check) //!OCLINT bitwise operator in conditional && getContextOptions()->abort_after > 0 && - (g_cs->numAssertsFailed + g_cs->numAssertsFailedForCurrentTestCase_atomic) >= + (g_cs->numAssertsFailed + g_cs->numAssertsFailedCurrentTest_atomic) >= getContextOptions()->abort_after) return true; @@ -3402,48 +3566,6 @@ namespace { return true; return false; } - -#ifdef DOCTEST_PLATFORM_WINDOWS - - typedef unsigned long long UInt64; - - UInt64 getCurrentTicks() { - static UInt64 hz = 0, hzo = 0; - if(!hz) { - QueryPerformanceFrequency(reinterpret_cast(&hz)); - QueryPerformanceCounter(reinterpret_cast(&hzo)); - } - UInt64 t; - QueryPerformanceCounter(reinterpret_cast(&t)); - return ((t - hzo) * 1000000) / hz; - } -#else // DOCTEST_PLATFORM_WINDOWS - - typedef uint64_t UInt64; - - UInt64 getCurrentTicks() { - timeval t; - gettimeofday(&t, nullptr); - return static_cast(t.tv_sec) * 1000000 + static_cast(t.tv_usec); - } -#endif // DOCTEST_PLATFORM_WINDOWS - - struct Timer - { - void start() { m_ticks = getCurrentTicks(); } - unsigned int getElapsedMicroseconds() const { - return static_cast(getCurrentTicks() - m_ticks); - } - //unsigned int getElapsedMilliseconds() const { - // return static_cast(getElapsedMicroseconds() / 1000); - //} - double getElapsedSeconds() const { return getElapsedMicroseconds() / 1000000.0; } - - private: - UInt64 m_ticks = 0; - }; - - Timer g_timer; } // namespace namespace detail { @@ -3484,7 +3606,7 @@ namespace detail { if(s->should_reenter == false) s->subcasesPassed.insert(m_signature); - DOCTEST_ITERATE_THROUGH_REPORTERS(subcase_end, m_signature); + DOCTEST_ITERATE_THROUGH_REPORTERS(subcase_end, DOCTEST_EMPTY); } } @@ -3581,9 +3703,7 @@ namespace detail { namespace { using namespace detail; // for sorting tests by file/line - int fileOrderComparator(const void* a, const void* b) { - auto lhs = *static_cast(a); - auto rhs = *static_cast(b); + bool fileOrderComparator(const TestCase* lhs, const TestCase* rhs) { #if DOCTEST_MSVC // this is needed because MSVC gives different case for drive letters // for __FILE__ when evaluated in a header and a source file @@ -3592,30 +3712,26 @@ namespace { const int res = std::strcmp(lhs->m_file, rhs->m_file); #endif // MSVC if(res != 0) - return res; - return static_cast(lhs->m_line) - static_cast(rhs->m_line); + return res < 0; + if(lhs->m_line != rhs->m_line) + return lhs->m_line < rhs->m_line; + return lhs->m_template_id < rhs->m_template_id; } // for sorting tests by suite/file/line - int suiteOrderComparator(const void* a, const void* b) { - auto lhs = *static_cast(a); - auto rhs = *static_cast(b); - + bool suiteOrderComparator(const TestCase* lhs, const TestCase* rhs) { const int res = std::strcmp(lhs->m_test_suite, rhs->m_test_suite); if(res != 0) - return res; - return fileOrderComparator(a, b); + return res < 0; + return fileOrderComparator(lhs, rhs); } // for sorting tests by name/suite/file/line - int nameOrderComparator(const void* a, const void* b) { - auto lhs = *static_cast(a); - auto rhs = *static_cast(b); - - const int res_name = std::strcmp(lhs->m_name, rhs->m_name); - if(res_name != 0) - return res_name; - return suiteOrderComparator(a, b); + bool nameOrderComparator(const TestCase* lhs, const TestCase* rhs) { + const int res = std::strcmp(lhs->m_name, rhs->m_name); + if(res != 0) + return res < 0; + return suiteOrderComparator(lhs, rhs); } // all the registered tests @@ -3772,8 +3888,7 @@ namespace detail { // Call sysctl. size = sizeof(info); if(sysctl(mib, DOCTEST_COUNTOF(mib), &info, &size, 0, 0) != 0) { - fprintf(stderr, "\n** Call to sysctl failed - unable to determine if debugger is " - "active **\n\n"); + std::cerr << "\nCall to sysctl failed - unable to determine if debugger is active **\n"; return false; } // We're being debugged if the P_TRACED flag is set. @@ -3791,8 +3906,6 @@ namespace detail { getExceptionTranslators().push_back(et); } - void writeStringToStream(std::ostream* s, const String& str) { *s << str; } - #ifdef DOCTEST_CONFIG_TREAT_CHAR_STAR_AS_STRING void toStream(std::ostream* s, char* in) { *s << in; } void toStream(std::ostream* s, const char* in) { *s << in; } @@ -3889,6 +4002,16 @@ namespace detail { } // namespace detail namespace { using namespace detail; + + std::ostream& file_line_to_stream(std::ostream& s, const char* file, int line, + const char* tail = "") { + const auto opt = getContextOptions(); + s << Color::LightGrey << skipPathFromFilename(file) << (opt->gnu_file_line ? ":" : "(") + << (opt->no_line_numbers ? 0 : line) // 0 or the real num depending on the option + << (opt->gnu_file_line ? ":" : "):") << tail; + return s; + } + #if !defined(DOCTEST_CONFIG_POSIX_SIGNALS) && !defined(DOCTEST_CONFIG_WINDOWS_SEH) struct FatalConditionHandler { @@ -3902,7 +4025,7 @@ namespace { struct SignalDefs { - DWORD id; + DWORD id; const char* name; }; // There is no 1-1 mapping between signals and windows exceptions. @@ -3932,7 +4055,7 @@ namespace { isSet = true; // 32k seems enough for doctest to handle stack overflow, // but the value was found experimentally, so there is no strong guarantee - guaranteeSize = 32 * 1024; + guaranteeSize = 32 * 1024; exceptionHandlerHandle = nullptr; // Register as first handler in current chain exceptionHandlerHandle = AddVectoredExceptionHandler(1, handleVectoredException); @@ -3946,20 +4069,20 @@ namespace { RemoveVectoredExceptionHandler(exceptionHandlerHandle); SetThreadStackGuarantee(&guaranteeSize); exceptionHandlerHandle = nullptr; - isSet = false; + isSet = false; } } ~FatalConditionHandler() { reset(); } private: - static bool isSet; + static bool isSet; static ULONG guaranteeSize; static PVOID exceptionHandlerHandle; }; - bool FatalConditionHandler::isSet = false; - ULONG FatalConditionHandler::guaranteeSize = 0; + bool FatalConditionHandler::isSet = false; + ULONG FatalConditionHandler::guaranteeSize = 0; PVOID FatalConditionHandler::exceptionHandlerHandle = nullptr; #else // DOCTEST_PLATFORM_WINDOWS @@ -4048,27 +4171,27 @@ namespace { void addAssert(assertType::Enum at) { if((at & assertType::is_warn) == 0) //!OCLINT bitwise operator in conditional - g_cs->numAssertsForCurrentTestCase_atomic++; + g_cs->numAssertsCurrentTest_atomic++; } void addFailedAssert(assertType::Enum at) { if((at & assertType::is_warn) == 0) //!OCLINT bitwise operator in conditional - g_cs->numAssertsFailedForCurrentTestCase_atomic++; + g_cs->numAssertsFailedCurrentTest_atomic++; } #if defined(DOCTEST_CONFIG_POSIX_SIGNALS) || defined(DOCTEST_CONFIG_WINDOWS_SEH) void reportFatal(const std::string& message) { - g_cs->seconds_so_far += g_timer.getElapsedSeconds(); g_cs->failure_flags |= TestCaseFailureReason::Crash; - g_cs->error_string = message.c_str(); - g_cs->should_reenter = false; - // TODO: end all currently opened subcases...? + DOCTEST_ITERATE_THROUGH_REPORTERS(test_case_exception, {message.c_str(), true}); + + while(g_cs->subcasesCurrentLevel--) + DOCTEST_ITERATE_THROUGH_REPORTERS(subcase_end, DOCTEST_EMPTY); + + g_cs->finalizeTestCaseData(); DOCTEST_ITERATE_THROUGH_REPORTERS(test_case_end, *g_cs); - g_cs->numTestCasesFailed++; - DOCTEST_ITERATE_THROUGH_REPORTERS(test_run_end, *g_cs); } #endif // DOCTEST_CONFIG_POSIX_SIGNALS || DOCTEST_CONFIG_WINDOWS_SEH @@ -4189,21 +4312,655 @@ namespace detail { MessageBuilder::~MessageBuilder() = default; } // namespace detail namespace { - std::mutex g_mutex; - using namespace detail; + + template + [[noreturn]] void throw_exception(Ex const& e) { +#ifndef DOCTEST_CONFIG_NO_EXCEPTIONS + throw e; +#else // DOCTEST_CONFIG_NO_EXCEPTIONS + std::cerr << "doctest will terminate because it needed to throw an exception.\n" + << "The message was: " << e.what() << '\n'; + std::terminate(); +#endif // DOCTEST_CONFIG_NO_EXCEPTIONS + } + +#define DOCTEST_INTERNAL_ERROR(msg) \ + throw_exception(std::logic_error( \ + __FILE__ ":" DOCTEST_TOSTR(__LINE__) ": Internal doctest error: " msg)) + + // clang-format off + +// ================================================================================================= +// The following code has been taken verbatim from Catch2/include/internal/catch_xmlwriter.h/cpp +// This is done so cherry-picking bug fixes is trivial - even the style/formatting is untouched. +// ================================================================================================= + + class XmlEncode { + public: + enum ForWhat { ForTextNodes, ForAttributes }; + + XmlEncode( std::string const& str, ForWhat forWhat = ForTextNodes ); + + void encodeTo( std::ostream& os ) const; + + friend std::ostream& operator << ( std::ostream& os, XmlEncode const& xmlEncode ); + + private: + std::string m_str; + ForWhat m_forWhat; + }; + + class XmlWriter { + public: + + class ScopedElement { + public: + ScopedElement( XmlWriter* writer ); + + ScopedElement( ScopedElement&& other ) noexcept; + ScopedElement& operator=( ScopedElement&& other ) noexcept; + + ~ScopedElement(); + + ScopedElement& writeText( std::string const& text, bool indent = true ); + + template + ScopedElement& writeAttribute( std::string const& name, T const& attribute ) { + m_writer->writeAttribute( name, attribute ); + return *this; + } + + private: + mutable XmlWriter* m_writer = nullptr; + }; + + XmlWriter( std::ostream& os = std::cout ); + ~XmlWriter(); + + XmlWriter( XmlWriter const& ) = delete; + XmlWriter& operator=( XmlWriter const& ) = delete; + + XmlWriter& startElement( std::string const& name ); + + ScopedElement scopedElement( std::string const& name ); + + XmlWriter& endElement(); + + XmlWriter& writeAttribute( std::string const& name, std::string const& attribute ); + + XmlWriter& writeAttribute( std::string const& name, const char* attribute ); + + XmlWriter& writeAttribute( std::string const& name, bool attribute ); + + template + XmlWriter& writeAttribute( std::string const& name, T const& attribute ) { + std::stringstream rss; + rss << attribute; + return writeAttribute( name, rss.str() ); + } + + XmlWriter& writeText( std::string const& text, bool indent = true ); + + //XmlWriter& writeComment( std::string const& text ); + + //void writeStylesheetRef( std::string const& url ); + + //XmlWriter& writeBlankLine(); + + void ensureTagClosed(); + + private: + + void writeDeclaration(); + + void newlineIfNecessary(); + + bool m_tagIsOpen = false; + bool m_needsNewline = false; + std::vector m_tags; + std::string m_indent; + std::ostream& m_os; + }; + +// ================================================================================================= +// The following code has been taken verbatim from Catch2/include/internal/catch_xmlwriter.h/cpp +// This is done so cherry-picking bug fixes is trivial - even the style/formatting is untouched. +// ================================================================================================= + +using uchar = unsigned char; + +namespace { + + size_t trailingBytes(unsigned char c) { + if ((c & 0xE0) == 0xC0) { + return 2; + } + if ((c & 0xF0) == 0xE0) { + return 3; + } + if ((c & 0xF8) == 0xF0) { + return 4; + } + DOCTEST_INTERNAL_ERROR("Invalid multibyte utf-8 start byte encountered"); + } + + uint32_t headerValue(unsigned char c) { + if ((c & 0xE0) == 0xC0) { + return c & 0x1F; + } + if ((c & 0xF0) == 0xE0) { + return c & 0x0F; + } + if ((c & 0xF8) == 0xF0) { + return c & 0x07; + } + DOCTEST_INTERNAL_ERROR("Invalid multibyte utf-8 start byte encountered"); + } + + void hexEscapeChar(std::ostream& os, unsigned char c) { + std::ios_base::fmtflags f(os.flags()); + os << "\\x" + << std::uppercase << std::hex << std::setfill('0') << std::setw(2) + << static_cast(c); + os.flags(f); + } + +} // anonymous namespace + + XmlEncode::XmlEncode( std::string const& str, ForWhat forWhat ) + : m_str( str ), + m_forWhat( forWhat ) + {} + + void XmlEncode::encodeTo( std::ostream& os ) const { + // Apostrophe escaping not necessary if we always use " to write attributes + // (see: http://www.w3.org/TR/xml/#syntax) + + for( std::size_t idx = 0; idx < m_str.size(); ++ idx ) { + uchar c = m_str[idx]; + switch (c) { + case '<': os << "<"; break; + case '&': os << "&"; break; + + case '>': + // See: http://www.w3.org/TR/xml/#syntax + if (idx > 2 && m_str[idx - 1] == ']' && m_str[idx - 2] == ']') + os << ">"; + else + os << c; + break; + + case '\"': + if (m_forWhat == ForAttributes) + os << """; + else + os << c; + break; + + default: + // Check for control characters and invalid utf-8 + + // Escape control characters in standard ascii + // see http://stackoverflow.com/questions/404107/why-are-control-characters-illegal-in-xml-1-0 + if (c < 0x09 || (c > 0x0D && c < 0x20) || c == 0x7F) { + hexEscapeChar(os, c); + break; + } + + // Plain ASCII: Write it to stream + if (c < 0x7F) { + os << c; + break; + } + + // UTF-8 territory + // Check if the encoding is valid and if it is not, hex escape bytes. + // Important: We do not check the exact decoded values for validity, only the encoding format + // First check that this bytes is a valid lead byte: + // This means that it is not encoded as 1111 1XXX + // Or as 10XX XXXX + if (c < 0xC0 || + c >= 0xF8) { + hexEscapeChar(os, c); + break; + } + + auto encBytes = trailingBytes(c); + // Are there enough bytes left to avoid accessing out-of-bounds memory? + if (idx + encBytes - 1 >= m_str.size()) { + hexEscapeChar(os, c); + break; + } + // The header is valid, check data + // The next encBytes bytes must together be a valid utf-8 + // This means: bitpattern 10XX XXXX and the extracted value is sane (ish) + bool valid = true; + uint32_t value = headerValue(c); + for (std::size_t n = 1; n < encBytes; ++n) { + uchar nc = m_str[idx + n]; + valid &= ((nc & 0xC0) == 0x80); + value = (value << 6) | (nc & 0x3F); + } + + if ( + // Wrong bit pattern of following bytes + (!valid) || + // Overlong encodings + (value < 0x80) || + ( value < 0x800 && encBytes > 2) || // removed "0x80 <= value &&" because redundant + (0x800 < value && value < 0x10000 && encBytes > 3) || + // Encoded value out of range + (value >= 0x110000) + ) { + hexEscapeChar(os, c); + break; + } + + // If we got here, this is in fact a valid(ish) utf-8 sequence + for (std::size_t n = 0; n < encBytes; ++n) { + os << m_str[idx + n]; + } + idx += encBytes - 1; + break; + } + } + } + + std::ostream& operator << ( std::ostream& os, XmlEncode const& xmlEncode ) { + xmlEncode.encodeTo( os ); + return os; + } + + XmlWriter::ScopedElement::ScopedElement( XmlWriter* writer ) + : m_writer( writer ) + {} + + XmlWriter::ScopedElement::ScopedElement( ScopedElement&& other ) noexcept + : m_writer( other.m_writer ){ + other.m_writer = nullptr; + } + XmlWriter::ScopedElement& XmlWriter::ScopedElement::operator=( ScopedElement&& other ) noexcept { + if ( m_writer ) { + m_writer->endElement(); + } + m_writer = other.m_writer; + other.m_writer = nullptr; + return *this; + } + + + XmlWriter::ScopedElement::~ScopedElement() { + if( m_writer ) + m_writer->endElement(); + } + + XmlWriter::ScopedElement& XmlWriter::ScopedElement::writeText( std::string const& text, bool indent ) { + m_writer->writeText( text, indent ); + return *this; + } + + XmlWriter::XmlWriter( std::ostream& os ) : m_os( os ) + { + writeDeclaration(); + } + + XmlWriter::~XmlWriter() { + while( !m_tags.empty() ) + endElement(); + } + + XmlWriter& XmlWriter::startElement( std::string const& name ) { + ensureTagClosed(); + newlineIfNecessary(); + m_os << m_indent << '<' << name; + m_tags.push_back( name ); + m_indent += " "; + m_tagIsOpen = true; + return *this; + } + + XmlWriter::ScopedElement XmlWriter::scopedElement( std::string const& name ) { + ScopedElement scoped( this ); + startElement( name ); + return scoped; + } + + XmlWriter& XmlWriter::endElement() { + newlineIfNecessary(); + m_indent = m_indent.substr( 0, m_indent.size()-2 ); + if( m_tagIsOpen ) { + m_os << "/>"; + m_tagIsOpen = false; + } + else { + m_os << m_indent << ""; + } + m_os << std::endl; + m_tags.pop_back(); + return *this; + } + + XmlWriter& XmlWriter::writeAttribute( std::string const& name, std::string const& attribute ) { + if( !name.empty() && !attribute.empty() ) + m_os << ' ' << name << "=\"" << XmlEncode( attribute, XmlEncode::ForAttributes ) << '"'; + return *this; + } + + XmlWriter& XmlWriter::writeAttribute( std::string const& name, const char* attribute ) { + if( !name.empty() && attribute && attribute[0] != '\0' ) + m_os << ' ' << name << "=\"" << XmlEncode( attribute, XmlEncode::ForAttributes ) << '"'; + return *this; + } + + XmlWriter& XmlWriter::writeAttribute( std::string const& name, bool attribute ) { + m_os << ' ' << name << "=\"" << ( attribute ? "true" : "false" ) << '"'; + return *this; + } + + XmlWriter& XmlWriter::writeText( std::string const& text, bool indent ) { + if( !text.empty() ){ + bool tagWasOpen = m_tagIsOpen; + ensureTagClosed(); + if( tagWasOpen && indent ) + m_os << m_indent; + m_os << XmlEncode( text ); + m_needsNewline = true; + } + return *this; + } + + //XmlWriter& XmlWriter::writeComment( std::string const& text ) { + // ensureTagClosed(); + // m_os << m_indent << ""; + // m_needsNewline = true; + // return *this; + //} + + //void XmlWriter::writeStylesheetRef( std::string const& url ) { + // m_os << "\n"; + //} + + //XmlWriter& XmlWriter::writeBlankLine() { + // ensureTagClosed(); + // m_os << '\n'; + // return *this; + //} + + void XmlWriter::ensureTagClosed() { + if( m_tagIsOpen ) { + m_os << ">" << std::endl; + m_tagIsOpen = false; + } + } + + void XmlWriter::writeDeclaration() { + m_os << "\n"; + } + + void XmlWriter::newlineIfNecessary() { + if( m_needsNewline ) { + m_os << std::endl; + m_needsNewline = false; + } + } + +// ================================================================================================= +// End of copy-pasted code from Catch +// ================================================================================================= + + // clang-format on + + struct XmlReporter : public IReporter + { + XmlWriter xml; + std::mutex mutex; + + // caching pointers/references to objects of these types - safe to do + const ContextOptions& opt; + const TestCaseData* tc = nullptr; + + XmlReporter(const ContextOptions& co) + : xml(*co.cout) + , opt(co) {} + + void log_contexts() { + int num_contexts = get_num_active_contexts(); + if(num_contexts) { + auto contexts = get_active_contexts(); + std::stringstream ss; + for(int i = 0; i < num_contexts; ++i) { + contexts[i]->stringify(&ss); + xml.scopedElement("Info").writeText(ss.str()); + ss.str(""); + } + } + } + + unsigned line(unsigned l) const { return opt.no_line_numbers ? 0 : l; } + + void test_case_start_impl(const TestCaseData& in) { + bool open_ts_tag = false; + if(tc != nullptr) { // we have already opened a test suite + if(strcmp(tc->m_test_suite, in.m_test_suite) != 0) { + xml.endElement(); + open_ts_tag = true; + } + } + else { + open_ts_tag = true; // first test case ==> first test suite + } + + if(open_ts_tag) { + xml.startElement("TestSuite"); + xml.writeAttribute("name", in.m_test_suite); + } + + tc = ∈ + xml.startElement("TestCase") + .writeAttribute("name", in.m_name) + .writeAttribute("filename", skipPathFromFilename(in.m_file)) + .writeAttribute("line", line(in.m_line)) + .writeAttribute("description", in.m_description); + + if(Approx(in.m_timeout) != 0) + xml.writeAttribute("timeout", in.m_timeout); + if(in.m_may_fail) + xml.writeAttribute("may_fail", true); + if(in.m_should_fail) + xml.writeAttribute("should_fail", true); + } + + // ========================================================================================= + // WHAT FOLLOWS ARE OVERRIDES OF THE VIRTUAL METHODS OF THE REPORTER INTERFACE + // ========================================================================================= + + void report_query(const QueryData& in) override { + test_run_start(); + if(opt.list_reporters) { + for(auto& curr : getReporters()) + xml.scopedElement("Reporter") + .writeAttribute("priority", curr.first.first) + .writeAttribute("name", curr.first.second); + } else if(opt.count || opt.list_test_cases) { + for(unsigned i = 0; i < in.num_data; ++i) + xml.scopedElement("TestCase").writeAttribute("name", in.data[i]); + xml.scopedElement("OverallResultsTestCases") + .writeAttribute("unskipped", in.run_stats->numTestCasesPassingFilters); + } else if(opt.list_test_suites) { + for(unsigned i = 0; i < in.num_data; ++i) + xml.scopedElement("TestSuite").writeAttribute("name", in.data[i]); + xml.scopedElement("OverallResultsTestCases") + .writeAttribute("unskipped", in.run_stats->numTestCasesPassingFilters); + xml.scopedElement("OverallResultsTestSuites") + .writeAttribute("unskipped", in.run_stats->numTestSuitesPassingFilters); + } + xml.endElement(); + } + + void test_run_start() override { + // remove .exe extension - mainly to have the same output on UNIX and Windows + std::string binary_name = skipPathFromFilename(opt.binary_name.c_str()); +#ifdef DOCTEST_PLATFORM_WINDOWS + if(binary_name.rfind(".exe") != std::string::npos) + binary_name = binary_name.substr(0, binary_name.length() - 4); +#endif // DOCTEST_PLATFORM_WINDOWS + + xml.startElement("doctest").writeAttribute("binary", binary_name); + if(opt.no_version == false) + xml.writeAttribute("version", DOCTEST_VERSION_STR); + + // only the consequential ones (TODO: filters) + xml.scopedElement("Options") + .writeAttribute("order_by", opt.order_by.c_str()) + .writeAttribute("rand_seed", opt.rand_seed) + .writeAttribute("first", opt.first) + .writeAttribute("last", opt.last) + .writeAttribute("abort_after", opt.abort_after) + .writeAttribute("subcase_filter_levels", opt.subcase_filter_levels) + .writeAttribute("case_sensitive", opt.case_sensitive) + .writeAttribute("no_throw", opt.no_throw) + .writeAttribute("no_skip", opt.no_skip); + } + + void test_run_end(const TestRunStats& p) override { + if(tc) // the TestSuite tag - only if there has been at least 1 test case + xml.endElement(); + + xml.scopedElement("OverallResultsAsserts") + .writeAttribute("successes", p.numAsserts - p.numAssertsFailed) + .writeAttribute("failures", p.numAssertsFailed); + + xml.startElement("OverallResultsTestCases") + .writeAttribute("successes", + p.numTestCasesPassingFilters - p.numTestCasesFailed) + .writeAttribute("failures", p.numTestCasesFailed); + if(opt.no_skipped_summary == false) + xml.writeAttribute("skipped", p.numTestCases - p.numTestCasesPassingFilters); + xml.endElement(); + + xml.endElement(); + } + + void test_case_start(const TestCaseData& in) override { + test_case_start_impl(in); + xml.ensureTagClosed(); + } + + void test_case_end(const CurrentTestCaseStats& st) override { + xml.startElement("OverallResultsAsserts") + .writeAttribute("successes", + st.numAssertsCurrentTest - st.numAssertsFailedCurrentTest) + .writeAttribute("failures", st.numAssertsFailedCurrentTest); + if(opt.duration) + xml.writeAttribute("duration", st.seconds); + if(tc->m_expected_failures) + xml.writeAttribute("expected_failures", tc->m_expected_failures); + xml.endElement(); + + xml.endElement(); + } + + void test_case_exception(const TestCaseException& e) override { + xml.scopedElement("Exception") + .writeAttribute("crash", e.is_crash) + .writeText(e.error_string.c_str()); + } + + void subcase_start(const SubcaseSignature& in) override { + xml.startElement("SubCase") + .writeAttribute("name", in.m_name) + .writeAttribute("filename", skipPathFromFilename(in.m_file)) + .writeAttribute("line", line(in.m_line)); + } + + void subcase_end() override { xml.endElement(); } + + void log_assert(const AssertData& rb) override { + if(!rb.m_failed && !opt.success) + return; + + std::lock_guard lock(mutex); + + xml.startElement("Expression") + .writeAttribute("success", !rb.m_failed) + .writeAttribute("type", assertString(rb.m_at)) + .writeAttribute("filename", skipPathFromFilename(rb.m_file)) + .writeAttribute("line", line(rb.m_line)); + + xml.scopedElement("Original").writeText(rb.m_expr); + + if(rb.m_threw) + xml.scopedElement("Exception").writeText(rb.m_exception.c_str()); + + if(rb.m_at & (assertType::is_throws_as | assertType::is_throws_with)) { + xml.scopedElement("ExpectedException").writeText(rb.m_exception_type); + } else if((rb.m_at & assertType::is_normal) && !rb.m_threw) { + xml.scopedElement("Expanded").writeText(rb.m_decomp.c_str()); + } + + log_contexts(); + + xml.endElement(); + } + + void log_message(const MessageData& mb) override { + std::lock_guard lock(mutex); + + xml.startElement("Message") + .writeAttribute("type", failureString(mb.m_severity)) + .writeAttribute("filename", skipPathFromFilename(mb.m_file)) + .writeAttribute("line", line(mb.m_line)); + + xml.scopedElement("Text").writeText(mb.m_string.c_str()); + + log_contexts(); + + xml.endElement(); + } + + void test_case_skipped(const TestCaseData& in) override { + if(opt.no_skipped_summary == false) { + test_case_start_impl(in); + xml.writeAttribute("skipped", "true"); + xml.endElement(); + } + } + }; + + DOCTEST_REGISTER_REPORTER("xml", 0, XmlReporter); + + struct Whitespace + { + int nrSpaces; + explicit Whitespace(int nr) + : nrSpaces(nr) {} + }; + + std::ostream& operator<<(std::ostream& out, const Whitespace& ws) { + if(ws.nrSpaces != 0) + out << std::setw(ws.nrSpaces) << ' '; + return out; + } + struct ConsoleReporter : public IReporter { std::ostream& s; bool hasLoggedCurrentTestStart; std::vector subcasesStack; + std::mutex mutex; - // caching pointers to objects of these types - safe to do - const ContextOptions* opt; + // caching pointers/references to objects of these types - safe to do + const ContextOptions& opt; const TestCaseData* tc; - ConsoleReporter(std::ostream& in) - : s(in) {} + ConsoleReporter(const ContextOptions& co) + : s(*co.cout) + , opt(co) {} + + ConsoleReporter(const ContextOptions& co, std::ostream& ostr) + : s(ostr) + , opt(co) {} // ========================================================================================= // WHAT FOLLOWS ARE HELPERS USED BY THE OVERRIDES OF THE VIRTUAL METHODS OF THE INTERFACE @@ -4211,18 +4968,10 @@ namespace { void separator_to_stream() { s << Color::Yellow - << "=============================================================================" - "==" + << "===============================================================================" "\n"; } - void file_line_to_stream(const char* file, int line, const char* tail = "") { - s << Color::LightGrey << removePathFromFilename(file) - << (opt->gnu_file_line ? ":" : "(") - << (opt->no_line_numbers ? 0 : line) // 0 or the real num depending on the option - << (opt->gnu_file_line ? ":" : "):") << tail; - } - const char* getSuccessOrFailString(bool success, assertType::Enum at, const char* success_str) { if(success) @@ -4236,9 +4985,9 @@ namespace { } void successOrFailColoredStringToStream(bool success, assertType::Enum at, - const char* success_str = "SUCCESS: ") { + const char* success_str = "SUCCESS") { s << getSuccessOrFailColor(success, at) - << getSuccessOrFailString(success, at, success_str); + << getSuccessOrFailString(success, at, success_str) << ": "; } void log_contexts() { @@ -4262,7 +5011,7 @@ namespace { return; separator_to_stream(); - file_line_to_stream(tc->m_file, tc->m_line, "\n"); + file_line_to_stream(s, tc->m_file, tc->m_line, "\n"); if(tc->m_description) s << Color::Yellow << "DESCRIPTION: " << Color::None << tc->m_description << "\n"; if(tc->m_test_suite && tc->m_test_suite[0] != '\0') @@ -4280,199 +5029,8 @@ namespace { hasLoggedCurrentTestStart = true; } - // ========================================================================================= - // WHAT FOLLOWS ARE OVERRIDES OF THE VIRTUAL METHODS OF THE REPORTER INTERFACE - // ========================================================================================= - - void test_run_start(const ContextOptions& o) override { opt = &o; } - - void test_run_end(const TestRunStats& p) override { - separator_to_stream(); - - const bool anythingFailed = p.numTestCasesFailed > 0 || p.numAssertsFailed > 0; - s << Color::Cyan << "[doctest] " << Color::None << "test cases: " << std::setw(6) - << p.numTestCasesPassingFilters << " | " - << ((p.numTestCasesPassingFilters == 0 || anythingFailed) ? Color::None : - Color::Green) - << std::setw(6) << p.numTestCasesPassingFilters - p.numTestCasesFailed << " passed" - << Color::None << " | " << (p.numTestCasesFailed > 0 ? Color::Red : Color::None) - << std::setw(6) << p.numTestCasesFailed << " failed" << Color::None << " | "; - if(opt->no_skipped_summary == false) { - const int numSkipped = p.numTestCases - p.numTestCasesPassingFilters; - s << (numSkipped == 0 ? Color::None : Color::Yellow) << std::setw(6) << numSkipped - << " skipped" << Color::None; - } - s << "\n"; - s << Color::Cyan << "[doctest] " << Color::None << "assertions: " << std::setw(6) - << p.numAsserts << " | " - << ((p.numAsserts == 0 || anythingFailed) ? Color::None : Color::Green) - << std::setw(6) << (p.numAsserts - p.numAssertsFailed) << " passed" << Color::None - << " | " << (p.numAssertsFailed > 0 ? Color::Red : Color::None) << std::setw(6) - << p.numAssertsFailed << " failed" << Color::None << " |\n"; - s << Color::Cyan << "[doctest] " << Color::None - << "Status: " << (p.numTestCasesFailed > 0 ? Color::Red : Color::Green) - << ((p.numTestCasesFailed > 0) ? "FAILURE!\n" : "SUCCESS!\n") << Color::None; - } - - void test_case_start(const TestCaseData& in) override { - hasLoggedCurrentTestStart = false; - tc = ∈ - } - - void test_case_end(const CurrentTestCaseStats& st) override { - // log the preamble of the test case only if there is something - // else to print - something other than that an assert has failed - if(opt->duration || - (st.failure_flags && st.failure_flags != TestCaseFailureReason::AssertFailure)) - logTestStart(); - - // report test case exceptions and crashes - bool crashed = st.failure_flags & TestCaseFailureReason::Crash; - if(crashed || (st.failure_flags & TestCaseFailureReason::Exception)) { - file_line_to_stream(tc->m_file, tc->m_line, " "); - successOrFailColoredStringToStream(false, crashed ? assertType::is_require : - assertType::is_check); - s << Color::Red << (crashed ? "test case CRASHED: " : "test case THREW exception: ") - << Color::Cyan << st.error_string << "\n"; - - int num_stringified_contexts = get_num_stringified_contexts(); - if(num_stringified_contexts) { - auto stringified_contexts = get_stringified_contexts(); - s << Color::None << " logged: "; - for(int i = num_stringified_contexts - 1; i >= 0; --i) { - s << (i == num_stringified_contexts - 1 ? "" : " ") - << stringified_contexts[i] << "\n"; - } - } - s << "\n"; - } - - // means the test case will be re-entered because there are untraversed (but discovered) subcases - if(st.should_reenter) - return; - - if(opt->duration) - s << Color::None << std::setprecision(6) << std::fixed << st.seconds_so_far - << " s: " << tc->m_name << "\n"; - - if(st.failure_flags & TestCaseFailureReason::Timeout) - s << Color::Red << "Test case exceeded time limit of " << std::setprecision(6) - << std::fixed << tc->m_timeout << "!\n"; - - if(st.failure_flags & TestCaseFailureReason::ShouldHaveFailedButDidnt) { - s << Color::Red << "Should have failed but didn't! Marking it as failed!\n"; - } else if(st.failure_flags & TestCaseFailureReason::ShouldHaveFailedAndDid) { - s << Color::Yellow << "Failed as expected so marking it as not failed\n"; - } else if(st.failure_flags & TestCaseFailureReason::CouldHaveFailedAndDid) { - s << Color::Yellow << "Allowed to fail so marking it as not failed\n"; - } else if(st.failure_flags & TestCaseFailureReason::DidntFailExactlyNumTimes) { - s << Color::Red << "Didn't fail exactly " << tc->m_expected_failures - << " times so marking it as failed!\n"; - } else if(st.failure_flags & TestCaseFailureReason::FailedExactlyNumTimes) { - s << Color::Yellow << "Failed exactly " << tc->m_expected_failures - << " times as expected so marking it as not failed!\n"; - } - if(st.failure_flags & TestCaseFailureReason::TooManyFailedAsserts) { - s << Color::Red << "Aborting - too many failed asserts!\n"; - } - s << Color::None; - } - - void subcase_start(const SubcaseSignature& subc) override { - subcasesStack.push_back(subc); - hasLoggedCurrentTestStart = false; - } - - void subcase_end(const SubcaseSignature& /*subc*/) override { - subcasesStack.pop_back(); - hasLoggedCurrentTestStart = false; - } - - void log_assert(const AssertData& rb) override { - if(!rb.m_failed && !opt->success) - return; - - std::lock_guard lock(g_mutex); - - logTestStart(); - - file_line_to_stream(rb.m_file, rb.m_line, " "); - successOrFailColoredStringToStream(!rb.m_failed, rb.m_at); - if((rb.m_at & (assertType::is_throws_as | assertType::is_throws_with)) == - 0) //!OCLINT bitwise operator in conditional - s << Color::Cyan << assertString(rb.m_at) << "( " << rb.m_expr << " ) " - << Color::None; - - if(rb.m_at & assertType::is_throws) { //!OCLINT bitwise operator in conditional - s << (rb.m_threw ? "threw as expected!" : "did NOT throw at all!") << "\n"; - } else if(rb.m_at & - assertType::is_throws_as) { //!OCLINT bitwise operator in conditional - s << Color::Cyan << assertString(rb.m_at) << "( " << rb.m_expr << ", " - << rb.m_exception_type << " ) " << Color::None - << (rb.m_threw ? (rb.m_threw_as ? "threw as expected!" : - "threw a DIFFERENT exception: ") : - "did NOT throw at all!") - << Color::Cyan << rb.m_exception << "\n"; - } else if(rb.m_at & - assertType::is_throws_with) { //!OCLINT bitwise operator in conditional - s << Color::Cyan << assertString(rb.m_at) << "( " << rb.m_expr << ", \"" - << rb.m_exception_type << "\" ) " << Color::None - << (rb.m_threw ? (!rb.m_failed ? "threw as expected!" : - "threw a DIFFERENT exception: ") : - "did NOT throw at all!") - << Color::Cyan << rb.m_exception << "\n"; - } else if(rb.m_at & assertType::is_nothrow) { //!OCLINT bitwise operator in conditional - s << (rb.m_threw ? "THREW exception: " : "didn't throw!") << Color::Cyan - << rb.m_exception << "\n"; - } else { - s << (rb.m_threw ? "THREW exception: " : - (!rb.m_failed ? "is correct!\n" : "is NOT correct!\n")); - if(rb.m_threw) - s << rb.m_exception << "\n"; - else - s << " values: " << assertString(rb.m_at) << "( " << rb.m_decomp << " )\n"; - } - - log_contexts(); - } - - void log_message(const MessageData& mb) override { - std::lock_guard lock(g_mutex); - - logTestStart(); - - file_line_to_stream(mb.m_file, mb.m_line, " "); - s << getSuccessOrFailColor(false, mb.m_severity) - << getSuccessOrFailString(mb.m_severity & assertType::is_warn, mb.m_severity, - "MESSAGE: "); - s << Color::None << mb.m_string << "\n"; - log_contexts(); - } - - void test_case_skipped(const TestCaseData&) override {} - }; - - struct Whitespace - { - int nrSpaces; - explicit Whitespace(int nr) - : nrSpaces(nr) {} - }; - - std::ostream& operator<<(std::ostream& out, const Whitespace& ws) { - if(ws.nrSpaces != 0) - out << std::setw(ws.nrSpaces) << ' '; - return out; - } - - // extension of the console reporter - with a bunch of helpers for the stdout stream redirection - struct ConsoleReporterWithHelpers : public ConsoleReporter - { - ConsoleReporterWithHelpers(std::ostream& in) - : ConsoleReporter(in) {} - void printVersion() { - if(getContextOptions()->no_version == false) + if(opt.no_version == false) s << Color::Cyan << "[doctest] " << Color::None << "doctest version is \"" << DOCTEST_VERSION_STR << "\"\n"; } @@ -4538,6 +5096,8 @@ namespace { << Whitespace(sizePrefixDisplay*1) << "filters OUT subcases by their name\n"; s << " -" DOCTEST_OPTIONS_PREFIX_DISPLAY "r, --" DOCTEST_OPTIONS_PREFIX_DISPLAY "reporters= " << Whitespace(sizePrefixDisplay*1) << "reporters to use (console is default)\n"; + s << " -" DOCTEST_OPTIONS_PREFIX_DISPLAY "o, --" DOCTEST_OPTIONS_PREFIX_DISPLAY "out= " + << Whitespace(sizePrefixDisplay*1) << "output filename\n"; s << " -" DOCTEST_OPTIONS_PREFIX_DISPLAY "ob, --" DOCTEST_OPTIONS_PREFIX_DISPLAY "order-by= " << Whitespace(sizePrefixDisplay*1) << "how the tests should be ordered\n"; s << Whitespace(sizePrefixDisplay*3) << " - by [file/suite/name/rand]\n"; @@ -4600,13 +5160,13 @@ namespace { << " name: " << curr.first.second << "\n"; } - void output_query_results() { + void list_query_results() { separator_to_stream(); - if(getContextOptions()->count || getContextOptions()->list_test_cases) { + if(opt.count || opt.list_test_cases) { s << Color::Cyan << "[doctest] " << Color::None << "unskipped test cases passing the current filters: " << g_cs->numTestCasesPassingFilters << "\n"; - } else if(getContextOptions()->list_test_suites) { + } else if(opt.list_test_suites) { s << Color::Cyan << "[doctest] " << Color::None << "unskipped test cases passing the current filters: " << g_cs->numTestCasesPassingFilters << "\n"; @@ -4616,53 +5176,248 @@ namespace { } } - void output_query_preamble_test_cases() { - s << Color::Cyan << "[doctest] " << Color::None << "listing all test case names\n"; - separator_to_stream(); + // ========================================================================================= + // WHAT FOLLOWS ARE OVERRIDES OF THE VIRTUAL METHODS OF THE REPORTER INTERFACE + // ========================================================================================= + + void report_query(const QueryData& in) override { + if(opt.version) { + printVersion(); + } else if(opt.help) { + printHelp(); + } else if(opt.list_reporters) { + printRegisteredReporters(); + } else if(opt.count || opt.list_test_cases) { + if(opt.list_test_cases) { + s << Color::Cyan << "[doctest] " << Color::None + << "listing all test case names\n"; + separator_to_stream(); + } + + for(unsigned i = 0; i < in.num_data; ++i) + s << Color::None << in.data[i] << "\n"; + + separator_to_stream(); + + s << Color::Cyan << "[doctest] " << Color::None + << "unskipped test cases passing the current filters: " + << g_cs->numTestCasesPassingFilters << "\n"; + + } else if(opt.list_test_suites) { + s << Color::Cyan << "[doctest] " << Color::None << "listing all test suites\n"; + separator_to_stream(); + + for(unsigned i = 0; i < in.num_data; ++i) + s << Color::None << in.data[i] << "\n"; + + separator_to_stream(); + + s << Color::Cyan << "[doctest] " << Color::None + << "unskipped test cases passing the current filters: " + << g_cs->numTestCasesPassingFilters << "\n"; + s << Color::Cyan << "[doctest] " << Color::None + << "test suites with unskipped test cases passing the current filters: " + << g_cs->numTestSuitesPassingFilters << "\n"; + } } - void output_query_preamble_test_suites() { - s << Color::Cyan << "[doctest] " << Color::None << "listing all test suites\n"; + void test_run_start() override { printIntro(); } + + void test_run_end(const TestRunStats& p) override { separator_to_stream(); + + const bool anythingFailed = p.numTestCasesFailed > 0 || p.numAssertsFailed > 0; + s << Color::Cyan << "[doctest] " << Color::None << "test cases: " << std::setw(6) + << p.numTestCasesPassingFilters << " | " + << ((p.numTestCasesPassingFilters == 0 || anythingFailed) ? Color::None : + Color::Green) + << std::setw(6) << p.numTestCasesPassingFilters - p.numTestCasesFailed << " passed" + << Color::None << " | " << (p.numTestCasesFailed > 0 ? Color::Red : Color::None) + << std::setw(6) << p.numTestCasesFailed << " failed" << Color::None << " | "; + if(opt.no_skipped_summary == false) { + const int numSkipped = p.numTestCases - p.numTestCasesPassingFilters; + s << (numSkipped == 0 ? Color::None : Color::Yellow) << std::setw(6) << numSkipped + << " skipped" << Color::None; + } + s << "\n"; + s << Color::Cyan << "[doctest] " << Color::None << "assertions: " << std::setw(6) + << p.numAsserts << " | " + << ((p.numAsserts == 0 || anythingFailed) ? Color::None : Color::Green) + << std::setw(6) << (p.numAsserts - p.numAssertsFailed) << " passed" << Color::None + << " | " << (p.numAssertsFailed > 0 ? Color::Red : Color::None) << std::setw(6) + << p.numAssertsFailed << " failed" << Color::None << " |\n"; + s << Color::Cyan << "[doctest] " << Color::None + << "Status: " << (p.numTestCasesFailed > 0 ? Color::Red : Color::Green) + << ((p.numTestCasesFailed > 0) ? "FAILURE!" : "SUCCESS!") << Color::None << std::endl; } - void output_c_string_with_newline(const char* str) { s << Color::None << str << "\n"; } + void test_case_start(const TestCaseData& in) override { + hasLoggedCurrentTestStart = false; + tc = ∈ + } + + void test_case_end(const CurrentTestCaseStats& st) override { + // log the preamble of the test case only if there is something + // else to print - something other than that an assert has failed + if(opt.duration || + (st.failure_flags && st.failure_flags != TestCaseFailureReason::AssertFailure)) + logTestStart(); + + if(opt.duration) + s << Color::None << std::setprecision(6) << std::fixed << st.seconds + << " s: " << tc->m_name << "\n"; + + if(st.failure_flags & TestCaseFailureReason::Timeout) + s << Color::Red << "Test case exceeded time limit of " << std::setprecision(6) + << std::fixed << tc->m_timeout << "!\n"; + + if(st.failure_flags & TestCaseFailureReason::ShouldHaveFailedButDidnt) { + s << Color::Red << "Should have failed but didn't! Marking it as failed!\n"; + } else if(st.failure_flags & TestCaseFailureReason::ShouldHaveFailedAndDid) { + s << Color::Yellow << "Failed as expected so marking it as not failed\n"; + } else if(st.failure_flags & TestCaseFailureReason::CouldHaveFailedAndDid) { + s << Color::Yellow << "Allowed to fail so marking it as not failed\n"; + } else if(st.failure_flags & TestCaseFailureReason::DidntFailExactlyNumTimes) { + s << Color::Red << "Didn't fail exactly " << tc->m_expected_failures + << " times so marking it as failed!\n"; + } else if(st.failure_flags & TestCaseFailureReason::FailedExactlyNumTimes) { + s << Color::Yellow << "Failed exactly " << tc->m_expected_failures + << " times as expected so marking it as not failed!\n"; + } + if(st.failure_flags & TestCaseFailureReason::TooManyFailedAsserts) { + s << Color::Red << "Aborting - too many failed asserts!\n"; + } + s << Color::None; + } + + void test_case_exception(const TestCaseException& e) override { + logTestStart(); + + file_line_to_stream(s, tc->m_file, tc->m_line, " "); + successOrFailColoredStringToStream(false, e.is_crash ? assertType::is_require : + assertType::is_check); + s << Color::Red << (e.is_crash ? "test case CRASHED: " : "test case THREW exception: ") + << Color::Cyan << e.error_string << "\n"; + + int num_stringified_contexts = get_num_stringified_contexts(); + if(num_stringified_contexts) { + auto stringified_contexts = get_stringified_contexts(); + s << Color::None << " logged: "; + for(int i = num_stringified_contexts - 1; i >= 0; --i) { + s << (i == num_stringified_contexts - 1 ? "" : " ") + << stringified_contexts[i] << "\n"; + } + } + s << "\n" << Color::None; + } + + void subcase_start(const SubcaseSignature& subc) override { + subcasesStack.push_back(subc); + hasLoggedCurrentTestStart = false; + } + + void subcase_end() override { + subcasesStack.pop_back(); + hasLoggedCurrentTestStart = false; + } + + void log_assert(const AssertData& rb) override { + if(!rb.m_failed && !opt.success) + return; + + std::lock_guard lock(mutex); + + logTestStart(); + + file_line_to_stream(s, rb.m_file, rb.m_line, " "); + successOrFailColoredStringToStream(!rb.m_failed, rb.m_at); + if((rb.m_at & (assertType::is_throws_as | assertType::is_throws_with)) == + 0) //!OCLINT bitwise operator in conditional + s << Color::Cyan << assertString(rb.m_at) << "( " << rb.m_expr << " ) " + << Color::None; + + if(rb.m_at & assertType::is_throws) { //!OCLINT bitwise operator in conditional + s << (rb.m_threw ? "threw as expected!" : "did NOT throw at all!") << "\n"; + } else if(rb.m_at & + assertType::is_throws_as) { //!OCLINT bitwise operator in conditional + s << Color::Cyan << assertString(rb.m_at) << "( " << rb.m_expr << ", " + << rb.m_exception_type << " ) " << Color::None + << (rb.m_threw ? (rb.m_threw_as ? "threw as expected!" : + "threw a DIFFERENT exception: ") : + "did NOT throw at all!") + << Color::Cyan << rb.m_exception << "\n"; + } else if(rb.m_at & + assertType::is_throws_with) { //!OCLINT bitwise operator in conditional + s << Color::Cyan << assertString(rb.m_at) << "( " << rb.m_expr << ", \"" + << rb.m_exception_type << "\" ) " << Color::None + << (rb.m_threw ? (!rb.m_failed ? "threw as expected!" : + "threw a DIFFERENT exception: ") : + "did NOT throw at all!") + << Color::Cyan << rb.m_exception << "\n"; + } else if(rb.m_at & assertType::is_nothrow) { //!OCLINT bitwise operator in conditional + s << (rb.m_threw ? "THREW exception: " : "didn't throw!") << Color::Cyan + << rb.m_exception << "\n"; + } else { + s << (rb.m_threw ? "THREW exception: " : + (!rb.m_failed ? "is correct!\n" : "is NOT correct!\n")); + if(rb.m_threw) + s << rb.m_exception << "\n"; + else + s << " values: " << assertString(rb.m_at) << "( " << rb.m_decomp << " )\n"; + } + + log_contexts(); + } + + void log_message(const MessageData& mb) override { + std::lock_guard lock(mutex); + + logTestStart(); + + file_line_to_stream(s, mb.m_file, mb.m_line, " "); + s << getSuccessOrFailColor(false, mb.m_severity) + << getSuccessOrFailString(mb.m_severity & assertType::is_warn, mb.m_severity, + "MESSAGE") << ": "; + s << Color::None << mb.m_string << "\n"; + log_contexts(); + } + + void test_case_skipped(const TestCaseData&) override {} }; + DOCTEST_REGISTER_REPORTER("console", 0, ConsoleReporter); + #ifdef DOCTEST_PLATFORM_WINDOWS struct DebugOutputWindowReporter : public ConsoleReporter { DOCTEST_THREAD_LOCAL static std::ostringstream oss; - DebugOutputWindowReporter() - : ConsoleReporter(oss) {} + DebugOutputWindowReporter(const ContextOptions& co) + : ConsoleReporter(co, oss) {} -#define DOCTEST_DEBUG_OUTPUT_WINDOW_REPORTER_OVERRIDE(func, type) \ - void func(type in) override { \ - if(isDebuggerActive()) { \ - bool with_col = g_no_colors; \ - g_no_colors = false; \ - ConsoleReporter::func(in); \ - DOCTEST_OUTPUT_DEBUG_STRING(oss.str().c_str()); \ - oss.str(""); \ - g_no_colors = with_col; \ - } \ +#define DOCTEST_DEBUG_OUTPUT_REPORTER_OVERRIDE(func, type, arg) \ + void func(type arg) override { \ + bool with_col = g_no_colors; \ + g_no_colors = false; \ + ConsoleReporter::func(arg); \ + DOCTEST_OUTPUT_DEBUG_STRING(oss.str().c_str()); \ + oss.str(""); \ + g_no_colors = with_col; \ } - DOCTEST_DEBUG_OUTPUT_WINDOW_REPORTER_OVERRIDE(test_run_start, const ContextOptions&) - DOCTEST_DEBUG_OUTPUT_WINDOW_REPORTER_OVERRIDE(test_run_end, const TestRunStats&) - DOCTEST_DEBUG_OUTPUT_WINDOW_REPORTER_OVERRIDE(test_case_start, const TestCaseData&) - DOCTEST_DEBUG_OUTPUT_WINDOW_REPORTER_OVERRIDE(test_case_end, const CurrentTestCaseStats&) - DOCTEST_DEBUG_OUTPUT_WINDOW_REPORTER_OVERRIDE(subcase_start, const SubcaseSignature&) - DOCTEST_DEBUG_OUTPUT_WINDOW_REPORTER_OVERRIDE(subcase_end, const SubcaseSignature&) - DOCTEST_DEBUG_OUTPUT_WINDOW_REPORTER_OVERRIDE(log_assert, const AssertData&) - DOCTEST_DEBUG_OUTPUT_WINDOW_REPORTER_OVERRIDE(log_message, const MessageData&) - DOCTEST_DEBUG_OUTPUT_WINDOW_REPORTER_OVERRIDE(test_case_skipped, const TestCaseData&) + DOCTEST_DEBUG_OUTPUT_REPORTER_OVERRIDE(test_run_start, DOCTEST_EMPTY, DOCTEST_EMPTY) + DOCTEST_DEBUG_OUTPUT_REPORTER_OVERRIDE(test_run_end, const TestRunStats&, in) + DOCTEST_DEBUG_OUTPUT_REPORTER_OVERRIDE(test_case_start, const TestCaseData&, in) + DOCTEST_DEBUG_OUTPUT_REPORTER_OVERRIDE(test_case_end, const CurrentTestCaseStats&, in) + DOCTEST_DEBUG_OUTPUT_REPORTER_OVERRIDE(test_case_exception, const TestCaseException&, in) + DOCTEST_DEBUG_OUTPUT_REPORTER_OVERRIDE(subcase_start, const SubcaseSignature&, in) + DOCTEST_DEBUG_OUTPUT_REPORTER_OVERRIDE(subcase_end, DOCTEST_EMPTY, DOCTEST_EMPTY) + DOCTEST_DEBUG_OUTPUT_REPORTER_OVERRIDE(log_assert, const AssertData&, in) + DOCTEST_DEBUG_OUTPUT_REPORTER_OVERRIDE(log_message, const MessageData&, in) + DOCTEST_DEBUG_OUTPUT_REPORTER_OVERRIDE(test_case_skipped, const TestCaseData&, in) }; DOCTEST_THREAD_LOCAL std::ostringstream DebugOutputWindowReporter::oss; - - DebugOutputWindowReporter g_debug_output_rep; #endif // DOCTEST_PLATFORM_WINDOWS // the implementation of parseFlag() @@ -4787,7 +5542,7 @@ namespace { } } else { // integer - // TODO: change this to use std::stoi or something else! currently it uses undefined behavior - assumes '0' on unsuccessful parse... + // TODO: change this to use std::stoi or something else! currently it uses undefined behavior - assumes '0' on failed parse... int theInt = std::atoi(parsedValue.c_str()); // NOLINT if(theInt != 0) { res = theInt; //!OCLINT parameter reassignment @@ -4801,6 +5556,8 @@ namespace { Context::Context(int argc, const char* const* argv) : p(new detail::ContextState) { parseArgs(argc, argv, true); + if(argc) + p->binary_name = argv[0]; } Context::~Context() { @@ -4809,7 +5566,11 @@ Context::~Context() { delete p; } -void Context::applyCommandLine(int argc, const char* const* argv) { parseArgs(argc, argv); } +void Context::applyCommandLine(int argc, const char* const* argv) { + parseArgs(argc, argv); + if(argc) + p->binary_name = argv[0]; +} // parses args void Context::parseArgs(int argc, const char* const* argv, bool withDefaults) { @@ -4863,6 +5624,7 @@ void Context::parseArgs(int argc, const char* const* argv, bool withDefaults) { p->var = strRes // clang-format off + DOCTEST_PARSE_STR_OPTION("out", "o", out, ""); DOCTEST_PARSE_STR_OPTION("order-by", "ob", order_by, "file"); DOCTEST_PARSE_INT_OPTION("rand-seed", "rs", rand_seed, 0); @@ -4870,7 +5632,7 @@ void Context::parseArgs(int argc, const char* const* argv, bool withDefaults) { DOCTEST_PARSE_INT_OPTION("last", "l", last, UINT_MAX); DOCTEST_PARSE_INT_OPTION("abort-after", "aa", abort_after, 0); - DOCTEST_PARSE_INT_OPTION("subcase-filter-levels", "scfl", subcase_filter_levels, 2000000000); + DOCTEST_PARSE_INT_OPTION("subcase-filter-levels", "scfl", subcase_filter_levels, INT_MAX); DOCTEST_PARSE_AS_BOOL_OR_FLAG("success", "s", success, false); DOCTEST_PARSE_AS_BOOL_OR_FLAG("case-sensitive", "cs", case_sensitive, false); @@ -4963,49 +5725,68 @@ void Context::setAssertHandler(detail::assert_handler ah) { p->ah = ah; } int Context::run() { using namespace detail; - auto old_cs = g_cs; + // save the old context state in case such was setup - for using asserts out of a testing context + auto old_cs = g_cs; + // this is the current contest g_cs = p; is_running_in_test = true; - g_no_colors = p->no_colors; + + g_no_colors = p->no_colors; p->resetRunData(); - ConsoleReporterWithHelpers g_con_rep(std::cout); - registerReporter("console", 0, g_con_rep); + // stdout by default + p->cout = &std::cout; + p->cerr = &std::cerr; + + // or to a file if specified + std::fstream fstr; + if(p->out.size()) { + fstr.open(p->out.c_str(), std::fstream::out); + p->cout = &fstr; + } + + auto cleanup_and_return = [&]() { + if(fstr.is_open()) + fstr.close(); + + // restore context + g_cs = old_cs; + is_running_in_test = false; + + // we have to free the reporters which were allocated when the run started + for(auto& curr : p->reporters_currently_used) + delete curr; + p->reporters_currently_used.clear(); + + if(p->numTestCasesFailed && !p->no_exitcode) + return EXIT_FAILURE; + return EXIT_SUCCESS; + }; + + DOCTEST_REGISTER_REPORTER("console", 0, ConsoleReporter); // setup default reporter if none is given through the command line - p->reporters_currently_used.clear(); if(p->filters[8].empty()) - p->reporters_currently_used.push_back(getReporters()[reporterMap::key_type(0, "console")]); + p->filters[8].push_back("console"); // check to see if any of the registered reporters has been selected for(auto& curr : getReporters()) { if(matchesAny(curr.first.second.c_str(), p->filters[8], false, p->case_sensitive)) - p->reporters_currently_used.push_back(curr.second); + p->reporters_currently_used.push_back(curr.second(*g_cs)); } - // always use the debug output window reporter #ifdef DOCTEST_PLATFORM_WINDOWS if(isDebuggerActive()) - p->reporters_currently_used.push_back(&g_debug_output_rep); + p->reporters_currently_used.push_back(new DebugOutputWindowReporter(*g_cs)); #endif // DOCTEST_PLATFORM_WINDOWS // handle version, help and no_run if(p->no_run || p->version || p->help || p->list_reporters) { - if(p->version) - g_con_rep.printVersion(); - if(p->help) - g_con_rep.printHelp(); - if(p->list_reporters) - g_con_rep.printRegisteredReporters(); + DOCTEST_ITERATE_THROUGH_REPORTERS(report_query, QueryData()); - g_cs = old_cs; - is_running_in_test = false; - - return EXIT_SUCCESS; + return cleanup_and_return(); } - g_con_rep.printIntro(); - std::vector testArray; for(auto& curr : getRegisteredTests()) testArray.push_back(&curr); @@ -5014,11 +5795,11 @@ int Context::run() { // sort the collected records if(!testArray.empty()) { if(p->order_by.compare("file", true) == 0) { - std::qsort(&testArray[0], testArray.size(), sizeof(TestCase*), fileOrderComparator); + std::sort(testArray.begin(), testArray.end(), fileOrderComparator); } else if(p->order_by.compare("suite", true) == 0) { - std::qsort(&testArray[0], testArray.size(), sizeof(TestCase*), suiteOrderComparator); + std::sort(testArray.begin(), testArray.end(), suiteOrderComparator); } else if(p->order_by.compare("name", true) == 0) { - std::qsort(&testArray[0], testArray.size(), sizeof(TestCase*), nameOrderComparator); + std::sort(testArray.begin(), testArray.end(), nameOrderComparator); } else if(p->order_by.compare("rand", true) == 0) { std::srand(p->rand_seed); @@ -5035,21 +5816,17 @@ int Context::run() { } } - if(p->list_test_cases) - g_con_rep.output_query_preamble_test_cases(); - std::set testSuitesPassingFilt; - if(p->list_test_suites) - g_con_rep.output_query_preamble_test_suites(); - bool query_mode = p->count || p->list_test_cases || p->list_test_suites; + bool query_mode = p->count || p->list_test_cases || p->list_test_suites; + std::vector queryResults; if(!query_mode) - DOCTEST_ITERATE_THROUGH_REPORTERS(test_run_start, *g_cs); + DOCTEST_ITERATE_THROUGH_REPORTERS(test_run_start, DOCTEST_EMPTY); // invoke the registered functions if they match the filter criteria (or just count them) for(auto& curr : testArray) { - const auto tc = *curr; + const auto& tc = *curr; bool skip_me = false; if(tc.m_skip && !p->no_skip) @@ -5088,14 +5865,14 @@ int Context::run() { // print the name of the test and don't execute it if(p->list_test_cases) { - g_con_rep.output_c_string_with_newline(tc.m_name); + queryResults.push_back(tc.m_name); continue; } // print the name of the test suite if not done already and don't execute it if(p->list_test_suites) { if((testSuitesPassingFilt.count(tc.m_test_suite) == 0) && tc.m_test_suite[0] != '\0') { - g_con_rep.output_c_string_with_newline(tc.m_test_suite); + queryResults.push_back(tc.m_test_suite); testSuitesPassingFilt.insert(tc.m_test_suite); p->numTestSuitesPassingFilters++; } @@ -5106,15 +5883,19 @@ int Context::run() { { p->currentTest = &tc; - p->failure_flags = TestCaseFailureReason::None; - p->seconds_so_far = 0; - p->error_string = ""; + p->failure_flags = TestCaseFailureReason::None; + p->seconds = 0; - // reset non-atomic counters - p->numAssertsFailedForCurrentTestCase = 0; - p->numAssertsForCurrentTestCase = 0; + // reset atomic counters + p->numAssertsFailedCurrentTest_atomic = 0; + p->numAssertsCurrentTest_atomic = 0; p->subcasesPassed.clear(); + + DOCTEST_ITERATE_THROUGH_REPORTERS(test_case_start, tc); + + p->timer.start(); + do { // reset some of the fields for subcases (except for the set of fully passed ones) p->should_reenter = false; @@ -5124,14 +5905,6 @@ int Context::run() { // reset stuff for logging with INFO() p->stringifiedContexts.clear(); - // reset atomic counters - p->numAssertsFailedForCurrentTestCase_atomic = 0; - p->numAssertsForCurrentTestCase_atomic = 0; - - DOCTEST_ITERATE_THROUGH_REPORTERS(test_case_start, tc); - - g_timer.start(); - #ifndef DOCTEST_CONFIG_NO_EXCEPTIONS try { #endif // DOCTEST_CONFIG_NO_EXCEPTIONS @@ -5143,66 +5916,21 @@ int Context::run() { } catch(const TestFailureException&) { p->failure_flags |= TestCaseFailureReason::AssertFailure; } catch(...) { - p->error_string = translateActiveException(); + DOCTEST_ITERATE_THROUGH_REPORTERS(test_case_exception, + {translateActiveException(), false}); p->failure_flags |= TestCaseFailureReason::Exception; } #endif // DOCTEST_CONFIG_NO_EXCEPTIONS - p->seconds_so_far += g_timer.getElapsedSeconds(); - - // update the non-atomic counters - p->numAsserts += p->numAssertsForCurrentTestCase_atomic; - p->numAssertsForCurrentTestCase += p->numAssertsForCurrentTestCase_atomic; - p->numAssertsFailed += p->numAssertsFailedForCurrentTestCase_atomic; - p->numAssertsFailedForCurrentTestCase += - p->numAssertsFailedForCurrentTestCase_atomic; - // exit this loop if enough assertions have failed - even if there are more subcases - if(p->abort_after > 0 && p->numAssertsFailed >= p->abort_after) { + if(p->abort_after > 0 && + p->numAssertsFailed + p->numAssertsFailedCurrentTest_atomic >= p->abort_after) { p->should_reenter = false; p->failure_flags |= TestCaseFailureReason::TooManyFailedAsserts; } - - // call it from here only if we will continue looping for other subcases and - // call it again outside of the loop for one final time - with updated flags - if(p->should_reenter == true) { - DOCTEST_ITERATE_THROUGH_REPORTERS(test_case_end, *g_cs); - // remove these flags - it is expected that the reporters have handled these issues - p->failure_flags &= ~TestCaseFailureReason::Exception; - p->failure_flags &= ~TestCaseFailureReason::AssertFailure; - } } while(p->should_reenter == true); - if(p->numAssertsFailedForCurrentTestCase) - p->failure_flags |= TestCaseFailureReason::AssertFailure; - - if(Approx(p->currentTest->m_timeout).epsilon(DBL_EPSILON) != 0 && - Approx(p->seconds_so_far).epsilon(DBL_EPSILON) > p->currentTest->m_timeout) - p->failure_flags |= TestCaseFailureReason::Timeout; - - if(tc.m_should_fail) { - if(p->failure_flags) { - p->failure_flags |= TestCaseFailureReason::ShouldHaveFailedAndDid; - } else { - p->failure_flags |= TestCaseFailureReason::ShouldHaveFailedButDidnt; - } - } else if(p->failure_flags && tc.m_may_fail) { - p->failure_flags |= TestCaseFailureReason::CouldHaveFailedAndDid; - } else if(tc.m_expected_failures > 0) { - if(p->numAssertsFailedForCurrentTestCase == tc.m_expected_failures) { - p->failure_flags |= TestCaseFailureReason::FailedExactlyNumTimes; - } else { - p->failure_flags |= TestCaseFailureReason::DidntFailExactlyNumTimes; - } - } - - bool ok_to_fail = (TestCaseFailureReason::ShouldHaveFailedAndDid & p->failure_flags) || - (TestCaseFailureReason::CouldHaveFailedAndDid & p->failure_flags) || - (TestCaseFailureReason::FailedExactlyNumTimes & p->failure_flags); - - // if any subcase has failed - the whole test case has failed - if(p->failure_flags && !ok_to_fail) - p->numTestCasesFailed++; + p->finalizeTestCaseData(); DOCTEST_ITERATE_THROUGH_REPORTERS(test_case_end, *g_cs); @@ -5214,17 +5942,17 @@ int Context::run() { } } - if(!query_mode) + if(!query_mode) { DOCTEST_ITERATE_THROUGH_REPORTERS(test_run_end, *g_cs); - else - g_con_rep.output_query_results(); + } else { + QueryData qdata; + qdata.run_stats = g_cs; + qdata.data = queryResults.data(); + qdata.num_data = unsigned(queryResults.size()); + DOCTEST_ITERATE_THROUGH_REPORTERS(report_query, qdata); + } - g_cs = old_cs; - is_running_in_test = false; - - if(p->numTestCasesFailed && !p->no_exitcode) - return EXIT_FAILURE; - return EXIT_SUCCESS; + return cleanup_and_return(); } DOCTEST_DEFINE_DEFAULTS(CurrentTestCaseStats); @@ -5243,10 +5971,11 @@ const String* IReporter::get_stringified_contexts() { return get_num_stringified_contexts() ? &detail::g_cs->stringifiedContexts[0] : nullptr; } -int registerReporter(const char* name, int priority, IReporter& r) { - getReporters().insert(reporterMap::value_type(reporterMap::key_type(priority, name), &r)); - return 0; -} +namespace detail { + void registerReporterImpl(const char* name, int priority, reporterCreatorFunc c) { + getReporters().insert(reporterMap::value_type(reporterMap::key_type(priority, name), c)); + } +} // namespace detail // see these issues on the reasoning for this: // - https://github.com/onqtam/doctest/issues/143#issuecomment-414418903 @@ -5258,7 +5987,9 @@ void DOCTEST_FIX_FOR_MACOS_LIBCPP_IOSFWD_STRING_LINK_ERRORS() { std::cout << std #endif // DOCTEST_CONFIG_DISABLE #ifdef DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN +DOCTEST_MSVC_SUPPRESS_WARNING_WITH_PUSH(4007) // 'function' : must be 'attribute' - see issue #182 int main(int argc, char** argv) { return doctest::Context(argc, argv).run(); } +DOCTEST_MSVC_SUPPRESS_WARNING_POP #endif // DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN DOCTEST_CLANG_SUPPRESS_WARNING_POP @@ -5266,4 +5997,4 @@ DOCTEST_MSVC_SUPPRESS_WARNING_POP DOCTEST_GCC_SUPPRESS_WARNING_POP #endif // DOCTEST_LIBRARY_IMPLEMENTATION -#endif // DOCTEST_CONFIG_IMPLEMENT +#endif // DOCTEST_CONFIG_IMPLEMENT \ No newline at end of file From 28dfbedda7fc5df9c6614bbcb1733ace0649a661 Mon Sep 17 00:00:00 2001 From: Niels Lohmann Date: Sun, 24 Mar 2019 18:14:59 +0100 Subject: [PATCH 025/106] :construction_worker: fixed timeout --- .doozer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.doozer.json b/.doozer.json index 25906879..af012c34 100644 --- a/.doozer.json +++ b/.doozer.json @@ -16,7 +16,7 @@ "cd build", "../cmake-3.14.0/bin/cmake /project/repo/checkout", "make -j8", - "ctest -VV -j8" + "ctest -VV -j4 --timeout 3000" ] }, "fedora24-x86_64": { From f091fe31bc7ebd2bd30904cbc5723e7405182c8c Mon Sep 17 00:00:00 2001 From: Niels Lohmann Date: Mon, 25 Mar 2019 06:39:41 +0100 Subject: [PATCH 026/106] :construction_worker: increased timeout --- .doozer.json | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/.doozer.json b/.doozer.json index af012c34..db588e4f 100644 --- a/.doozer.json +++ b/.doozer.json @@ -16,7 +16,20 @@ "cd build", "../cmake-3.14.0/bin/cmake /project/repo/checkout", "make -j8", - "ctest -VV -j4 --timeout 3000" + "ctest -VV -j4 --timeout 10000" + ] + }, + "jessie-i386": { + "buildenv": "jessie-i386", + "builddeps": ["cmake", "build-essential"], + "buildcmd": [ + "uname -a", + "cd", + "mkdir build", + "cd build", + "cmake /project/repo/checkout", + "make -j8", + "ctest -VV -j8" ] }, "fedora24-x86_64": { From cde0b243896d1133dc3dff40ef63765c639ccc82 Mon Sep 17 00:00:00 2001 From: Niels Lohmann Date: Mon, 25 Mar 2019 06:43:14 +0100 Subject: [PATCH 027/106] :construction_worker: fixed required packages --- .doozer.json | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/.doozer.json b/.doozer.json index db588e4f..0ce54b78 100644 --- a/.doozer.json +++ b/.doozer.json @@ -2,7 +2,7 @@ "targets": { "raspbian-jessie": { "buildenv": "raspbian-jessie", - "builddeps": ["build-essential", "cmake", "wget"], + "builddeps": ["build-essential", "wget"], "buildcmd": [ "uname -a", "cd", @@ -21,13 +21,19 @@ }, "jessie-i386": { "buildenv": "jessie-i386", - "builddeps": ["cmake", "build-essential"], + "builddeps": ["build-essential", "wget"], "buildcmd": [ "uname -a", "cd", + "wget https://github.com/Kitware/CMake/releases/download/v3.14.0/cmake-3.14.0.tar.gz", + "tar xfz cmake-3.14.0.tar.gz", + "cd cmake-3.14.0", + "./bootstrap", + "make -j8", + "cd", "mkdir build", "cd build", - "cmake /project/repo/checkout", + "../cmake-3.14.0/bin/cmake /project/repo/checkout", "make -j8", "ctest -VV -j8" ] @@ -47,7 +53,7 @@ }, "centos7-x86_64": { "buildenv": "centos7-x86_64", - "builddeps": ["cmake", "make", "wget", "gcc-c++"], + "builddeps": ["make", "wget", "gcc-c++"], "buildcmd": [ "uname -a", "cd", From e27b282033bb3a3c2d1b346719931f4d4e34ad18 Mon Sep 17 00:00:00 2001 From: Niels Lohmann Date: Mon, 25 Mar 2019 06:45:35 +0100 Subject: [PATCH 028/106] :construction_worker: skip certificate check --- .doozer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.doozer.json b/.doozer.json index 0ce54b78..1d6dbf4d 100644 --- a/.doozer.json +++ b/.doozer.json @@ -25,7 +25,7 @@ "buildcmd": [ "uname -a", "cd", - "wget https://github.com/Kitware/CMake/releases/download/v3.14.0/cmake-3.14.0.tar.gz", + "wget --no-check-certificate https://github.com/Kitware/CMake/releases/download/v3.14.0/cmake-3.14.0.tar.gz", "tar xfz cmake-3.14.0.tar.gz", "cd cmake-3.14.0", "./bootstrap", From 0a67b51fce56d1b875c9bb743eed384904766e89 Mon Sep 17 00:00:00 2001 From: Niels Lohmann Date: Mon, 25 Mar 2019 07:03:41 +0100 Subject: [PATCH 029/106] :construction_worker: forgot path to ctest --- .doozer.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.doozer.json b/.doozer.json index 1d6dbf4d..0a07ce0d 100644 --- a/.doozer.json +++ b/.doozer.json @@ -16,7 +16,7 @@ "cd build", "../cmake-3.14.0/bin/cmake /project/repo/checkout", "make -j8", - "ctest -VV -j4 --timeout 10000" + "../cmake-3.14.0/bin/ctest -VV -j4 --timeout 10000" ] }, "jessie-i386": { @@ -35,7 +35,7 @@ "cd build", "../cmake-3.14.0/bin/cmake /project/repo/checkout", "make -j8", - "ctest -VV -j8" + "../cmake-3.14.0/bin/ctest -VV -j8" ] }, "fedora24-x86_64": { @@ -67,7 +67,7 @@ "cd build", "../cmake-3.14.0/bin/cmake /project/repo/checkout", "make -j8", - "ctest -VV -j8" + "../cmake-3.14.0/bin/ctest -VV -j8" ] } } From af9da22b877b158a5374f40501e08e622b7e3b70 Mon Sep 17 00:00:00 2001 From: Niels Lohmann Date: Mon, 25 Mar 2019 07:15:03 +0100 Subject: [PATCH 030/106] :construction_worker: adding xenial-armhf --- .doozer.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.doozer.json b/.doozer.json index 0a07ce0d..134aa2f6 100644 --- a/.doozer.json +++ b/.doozer.json @@ -19,8 +19,8 @@ "../cmake-3.14.0/bin/ctest -VV -j4 --timeout 10000" ] }, - "jessie-i386": { - "buildenv": "jessie-i386", + "xenial-armhf": { + "buildenv": "xenial-armhf", "builddeps": ["build-essential", "wget"], "buildcmd": [ "uname -a", From 9d2f0391e070fa0ded1ec1be3ff8dc09c0465dc0 Mon Sep 17 00:00:00 2001 From: Niels Lohmann Date: Mon, 25 Mar 2019 12:30:45 +0100 Subject: [PATCH 031/106] :construction_worker: fixed timeout --- .doozer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.doozer.json b/.doozer.json index 134aa2f6..48049f40 100644 --- a/.doozer.json +++ b/.doozer.json @@ -35,7 +35,7 @@ "cd build", "../cmake-3.14.0/bin/cmake /project/repo/checkout", "make -j8", - "../cmake-3.14.0/bin/ctest -VV -j8" + "../cmake-3.14.0/bin/ctest -VV -j4 --timeout 10000" ] }, "fedora24-x86_64": { From 0caf98650595aae4e83053cf65bb4853594331ef Mon Sep 17 00:00:00 2001 From: onqtam Date: Mon, 25 Mar 2019 22:04:37 +0200 Subject: [PATCH 032/106] reverted the removal of this if/else branching - this is the easiest way to get -std=c++0x support --- test/CMakeLists.txt | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index b2f59d5f..53fd3ae6 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -65,7 +65,11 @@ set_target_properties(doctest_main PROPERTIES COMPILE_OPTIONS "$<$:/EHsc;$<$:/Od>>" ) -target_compile_features(doctest_main PUBLIC cxx_std_11) +if (${CMAKE_VERSION} VERSION_LESS "3.8.0") + target_compile_features(doctest_main PUBLIC cxx_range_for) +else() + target_compile_features(doctest_main PUBLIC cxx_std_11) +endif() target_include_directories(doctest_main PRIVATE "thirdparty/doctest") # https://stackoverflow.com/questions/2368811/how-to-set-warning-level-in-cmake From 099182458457d1b8d37079097cee7005ed66d698 Mon Sep 17 00:00:00 2001 From: Niels Lohmann Date: Tue, 26 Mar 2019 10:41:05 +0100 Subject: [PATCH 033/106] :construction_worker: version output --- .doozer.json | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/.doozer.json b/.doozer.json index 48049f40..687aead8 100644 --- a/.doozer.json +++ b/.doozer.json @@ -5,6 +5,8 @@ "builddeps": ["build-essential", "wget"], "buildcmd": [ "uname -a", + "cat /etc/os-release", + "g++ --version", "cd", "wget https://github.com/Kitware/CMake/releases/download/v3.14.0/cmake-3.14.0.tar.gz", "tar xfz cmake-3.14.0.tar.gz", @@ -24,6 +26,8 @@ "builddeps": ["build-essential", "wget"], "buildcmd": [ "uname -a", + "lsb_release -a", + "g++ --version", "cd", "wget --no-check-certificate https://github.com/Kitware/CMake/releases/download/v3.14.0/cmake-3.14.0.tar.gz", "tar xfz cmake-3.14.0.tar.gz", @@ -43,6 +47,8 @@ "builddeps": ["cmake", "make", "gcc gcc-c++"], "buildcmd": [ "uname -a", + "cat /etc/fedora-release", + "g++ --version", "cd", "mkdir build", "cd build", @@ -56,6 +62,8 @@ "builddeps": ["make", "wget", "gcc-c++"], "buildcmd": [ "uname -a", + "rpm -q centos-release", + "g++ --version", "cd", "wget https://github.com/Kitware/CMake/releases/download/v3.14.0/cmake-3.14.0.tar.gz", "tar xfz cmake-3.14.0.tar.gz", From 24d91cf36f09b598e7e8de4699f9f3152bb325a5 Mon Sep 17 00:00:00 2001 From: Niels Lohmann Date: Tue, 26 Mar 2019 10:49:14 +0100 Subject: [PATCH 034/106] :memo: added Doozer to README --- README.md | 59 ++++++++++++++++++++++++++++++------------------------- 1 file changed, 32 insertions(+), 27 deletions(-) diff --git a/README.md b/README.md index 08fbb14a..53a9c390 100644 --- a/README.md +++ b/README.md @@ -1021,35 +1021,39 @@ Please note: - Unsupported versions of GCC and Clang are rejected by `#error` directives. This can be switched off by defining `JSON_SKIP_UNSUPPORTED_COMPILER_CHECK`. Note that you can expect no support in this case. -The following compilers are currently used in continuous integration at [Travis](https://travis-ci.org/nlohmann/json) and [AppVeyor](https://ci.appveyor.com/project/nlohmann/json): +The following compilers are currently used in continuous integration at [Travis](https://travis-ci.org/nlohmann/json), [AppVeyor](https://ci.appveyor.com/project/nlohmann/json), and [Doozer](https://doozer.io): -| Compiler | Operating System | Version String | -|-----------------|------------------------------|----------------| -| GCC 4.8.5 | Ubuntu 14.04.5 LTS | g++-4.8 (Ubuntu 4.8.5-2ubuntu1~14.04.2) 4.8.5 | -| GCC 4.9.4 | Ubuntu 14.04.1 LTS | g++-4.9 (Ubuntu 4.9.4-2ubuntu1~14.04.1) 4.9.4 | -| GCC 5.5.0 | Ubuntu 14.04.1 LTS | g++-5 (Ubuntu 5.5.0-12ubuntu1~14.04) 5.5.0 20171010 | -| GCC 6.4.0 | Ubuntu 14.04.1 LTS | g++-6 (Ubuntu 6.4.0-17ubuntu1~14.04) 6.4.0 20180424 | -| GCC 7.3.0 | Ubuntu 14.04.1 LTS | g++-7 (Ubuntu 7.3.0-21ubuntu1~14.04) 7.3.0 | -| GCC 7.3.0 | Windows Server 2012 R2 (x64) | g++ (x86_64-posix-seh-rev0, Built by MinGW-W64 project) 7.3.0 | -| GCC 8.1.0 | Ubuntu 14.04.1 LTS | g++-8 (Ubuntu 8.1.0-5ubuntu1~14.04) 8.1.0 | -| Clang 3.5.0 | Ubuntu 14.04.1 LTS | clang version 3.5.0-4ubuntu2~trusty2 (tags/RELEASE_350/final) (based on LLVM 3.5.0) | -| Clang 3.6.2 | Ubuntu 14.04.1 LTS | clang version 3.6.2-svn240577-1~exp1 (branches/release_36) (based on LLVM 3.6.2) | -| Clang 3.7.1 | Ubuntu 14.04.1 LTS | clang version 3.7.1-svn253571-1~exp1 (branches/release_37) (based on LLVM 3.7.1) | -| Clang 3.8.0 | Ubuntu 14.04.1 LTS | clang version 3.8.0-2ubuntu3~trusty5 (tags/RELEASE_380/final) | -| Clang 3.9.1 | Ubuntu 14.04.1 LTS | clang version 3.9.1-4ubuntu3~14.04.3 (tags/RELEASE_391/rc2) | -| Clang 4.0.1 | Ubuntu 14.04.1 LTS | clang version 4.0.1-svn305264-1~exp1 (branches/release_40) | -| Clang 5.0.2 | Ubuntu 14.04.1 LTS | clang version 5.0.2-svn328729-1~exp1~20180509123505.100 (branches/release_50) | -| Clang 6.0.1 | Ubuntu 14.04.1 LTS | clang version 6.0.1-svn334776-1~exp1~20180726133705.85 (branches/release_60) | -| Clang 7.0.1 | Ubuntu 14.04.1 LTS | clang version 7.0.1-svn348686-1~exp1~20181213084532.54 (branches/release_70) | -| Clang Xcode 8.3 | OSX 10.11.6 | Apple LLVM version 8.1.0 (clang-802.0.38) | -| Clang Xcode 9.0 | OSX 10.12.6 | Apple LLVM version 9.0.0 (clang-900.0.37) | -| Clang Xcode 9.1 | OSX 10.12.6 | Apple LLVM version 9.0.0 (clang-900.0.38) | -| Clang Xcode 9.2 | OSX 10.13.3 | Apple LLVM version 9.1.0 (clang-902.0.39.1) | -| Clang Xcode 9.3 | OSX 10.13.3 | Apple LLVM version 9.1.0 (clang-902.0.39.2) | -| Clang Xcode 10.0 | OSX 10.13.3 | Apple LLVM version 10.0.0 (clang-1000.11.45.2) | -| Clang Xcode 10.1 | OSX 10.13.3 | Apple LLVM version 10.0.0 (clang-1000.11.45.5) | +| Compiler | Operating System | Version String | +|-----------------------|------------------------------|----------------| +| GCC 4.8.5 | Ubuntu 14.04.5 LTS | g++-4.8 (Ubuntu 4.8.5-2ubuntu1~14.04.2) 4.8.5 | +| GCC 4.8.5 | CentOS Release-7-6.1810.2.el7.centos.x86_64 | g++ (GCC) 4.8.5 20150623 (Red Hat 4.8.5-36) | +| GCC 4.9.2 (armv7l) | Raspbian GNU/Linux 8 (jessie) | g++ (Raspbian 4.9.2-10+deb8u2) 4.9.2 | +| GCC 4.9.4 | Ubuntu 14.04.1 LTS | g++-4.9 (Ubuntu 4.9.4-2ubuntu1~14.04.1) 4.9.4 | +| GCC 5.3.1 (armv7l) | Ubuntu 16.04 LTS | g++ (Ubuntu/Linaro 5.3.1-14ubuntu2) 5.3.1 20160413 | +| GCC 5.5.0 | Ubuntu 14.04.1 LTS | g++-5 (Ubuntu 5.5.0-12ubuntu1~14.04) 5.5.0 20171010 | +| GCC 6.3.1 | Fedora release 24 (Twenty Four) | g++ (GCC) 6.3.1 20161221 (Red Hat 6.3.1-1) | +| GCC 6.4.0 | Ubuntu 14.04.1 LTS | g++-6 (Ubuntu 6.4.0-17ubuntu1~14.04) 6.4.0 20180424 | +| GCC 7.3.0 | Ubuntu 14.04.1 LTS | g++-7 (Ubuntu 7.3.0-21ubuntu1~14.04) 7.3.0 | +| GCC 7.3.0 | Windows Server 2012 R2 (x64) | g++ (x86_64-posix-seh-rev0, Built by MinGW-W64 project) 7.3.0 | +| GCC 8.1.0 | Ubuntu 14.04.1 LTS | g++-8 (Ubuntu 8.1.0-5ubuntu1~14.04) 8.1.0 | +| Clang 3.5.0 | Ubuntu 14.04.1 LTS | clang version 3.5.0-4ubuntu2~trusty2 (tags/RELEASE_350/final) (based on LLVM 3.5.0) | +| Clang 3.6.2 | Ubuntu 14.04.1 LTS | clang version 3.6.2-svn240577-1~exp1 (branches/release_36) (based on LLVM 3.6.2) | +| Clang 3.7.1 | Ubuntu 14.04.1 LTS | clang version 3.7.1-svn253571-1~exp1 (branches/release_37) (based on LLVM 3.7.1) | +| Clang 3.8.0 | Ubuntu 14.04.1 LTS | clang version 3.8.0-2ubuntu3~trusty5 (tags/RELEASE_380/final) | +| Clang 3.9.1 | Ubuntu 14.04.1 LTS | clang version 3.9.1-4ubuntu3~14.04.3 (tags/RELEASE_391/rc2) | +| Clang 4.0.1 | Ubuntu 14.04.1 LTS | clang version 4.0.1-svn305264-1~exp1 (branches/release_40) | +| Clang 5.0.2 | Ubuntu 14.04.1 LTS | clang version 5.0.2-svn328729-1~exp1~20180509123505.100 (branches/release_50) | +| Clang 6.0.1 | Ubuntu 14.04.1 LTS | clang version 6.0.1-svn334776-1~exp1~20180726133705.85 (branches/release_60) | +| Clang 7.0.1 | Ubuntu 14.04.1 LTS | clang version 7.0.1-svn348686-1~exp1~20181213084532.54 (branches/release_70) | +| Clang Xcode 8.3 | OSX 10.11.6 | Apple LLVM version 8.1.0 (clang-802.0.38) | +| Clang Xcode 9.0 | OSX 10.12.6 | Apple LLVM version 9.0.0 (clang-900.0.37) | +| Clang Xcode 9.1 | OSX 10.12.6 | Apple LLVM version 9.0.0 (clang-900.0.38) | +| Clang Xcode 9.2 | OSX 10.13.3 | Apple LLVM version 9.1.0 (clang-902.0.39.1) | +| Clang Xcode 9.3 | OSX 10.13.3 | Apple LLVM version 9.1.0 (clang-902.0.39.2) | +| Clang Xcode 10.0 | OSX 10.13.3 | Apple LLVM version 10.0.0 (clang-1000.11.45.2) | +| Clang Xcode 10.1 | OSX 10.13.3 | Apple LLVM version 10.0.0 (clang-1000.11.45.5) | | Visual Studio 14 2015 | Windows Server 2012 R2 (x64) | Microsoft (R) Build Engine version 14.0.25420.1, MSVC 19.0.24215.1 | -| Visual Studio 2017 | Windows Server 2016 | Microsoft (R) Build Engine version 15.7.180.61344, MSVC 19.14.26433.0 | +| Visual Studio 2017 | Windows Server 2016 | Microsoft (R) Build Engine version 15.7.180.61344, MSVC 19.14.26433.0 | ## License @@ -1273,6 +1277,7 @@ The library itself consists of a single header file licensed under the MIT licen - [**Coveralls**](https://coveralls.io) to measure [code coverage](https://coveralls.io/github/nlohmann/json) - [**Coverity Scan**](https://scan.coverity.com) for [static analysis](https://scan.coverity.com/projects/nlohmann-json) - [**cppcheck**](http://cppcheck.sourceforge.net) for static analysis +- [**Doozer**](https://doozer.io) for [continuous integration](https://doozer.io/nlohmann/json) on Linux (CentOS, Raspbian, Fedora) - [**Doxygen**](http://www.stack.nl/~dimitri/doxygen/) to generate [documentation](https://nlohmann.github.io/json/) - [**git-update-ghpages**](https://github.com/rstacruz/git-update-ghpages) to upload the documentation to gh-pages - [**GitHub Changelog Generator**](https://github.com/skywinder/github-changelog-generator) to generate the [ChangeLog](https://github.com/nlohmann/json/blob/develop/ChangeLog.md) From 5d511a6e96160458039ace79890e0528414c073d Mon Sep 17 00:00:00 2001 From: onqtam Date: Wed, 27 Mar 2019 00:58:53 +0200 Subject: [PATCH 035/106] fixed a bunch of warnings from the Makefile from the root of the repo --- Makefile | 2 ++ test/src/unit-allocator.cpp | 22 +++++++++--------- test/src/unit-regression.cpp | 2 +- test/src/unit-testsuites.cpp | 4 ++-- test/thirdparty/doctest/doctest.h | 11 +++++++-- .../doctest/doctest_compatibility.h | 23 +++++++++++++++++++ 6 files changed, 48 insertions(+), 16 deletions(-) diff --git a/Makefile b/Makefile index 3dcdf26c..51376aac 100644 --- a/Makefile +++ b/Makefile @@ -116,6 +116,7 @@ doctest: # calling Clang with all warnings, except: # -Wno-documentation-unknown-command: code uses user-defined commands like @complexity +# -Wno-exit-time-destructors: warning in json code triggered by NLOHMANN_JSON_SERIALIZE_ENUM # -Wno-keyword-macro: unit-tests use "#define private public" # -Wno-deprecated-declarations: the library deprecated some functions # -Wno-weak-vtables: exception class is defined inline, but has virtual method @@ -130,6 +131,7 @@ pedantic_clang: -Werror \ -Weverything \ -Wno-documentation-unknown-command \ + -Wno-exit-time-destructors \ -Wno-keyword-macro \ -Wno-deprecated-declarations \ -Wno-weak-vtables \ diff --git a/test/src/unit-allocator.cpp b/test/src/unit-allocator.cpp index b22794d7..079b8cae 100644 --- a/test/src/unit-allocator.cpp +++ b/test/src/unit-allocator.cpp @@ -61,7 +61,7 @@ TEST_CASE("bad_alloc") bad_allocator>; // creating an object should throw - CHECK_THROWS_AS(auto tmp = bad_json(bad_json::value_t::object), std::bad_alloc&); + CHECK_THROWS_AS(bad_json(bad_json::value_t::object), std::bad_alloc&); } } @@ -153,7 +153,7 @@ TEST_CASE("controlled bad_alloc") auto t = my_json::value_t::object; CHECK_NOTHROW(my_allocator_clean_up(my_json::json_value(t).object)); next_construct_fails = true; - CHECK_THROWS_AS(auto tmp = my_json::json_value(t), std::bad_alloc&); + CHECK_THROWS_AS(my_json::json_value(t), std::bad_alloc&); next_construct_fails = false; } SECTION("array") @@ -162,7 +162,7 @@ TEST_CASE("controlled bad_alloc") auto t = my_json::value_t::array; CHECK_NOTHROW(my_allocator_clean_up(my_json::json_value(t).array)); next_construct_fails = true; - CHECK_THROWS_AS(auto tmp = my_json::json_value(t), std::bad_alloc&); + CHECK_THROWS_AS(my_json::json_value(t), std::bad_alloc&); next_construct_fails = false; } SECTION("string") @@ -171,7 +171,7 @@ TEST_CASE("controlled bad_alloc") auto t = my_json::value_t::string; CHECK_NOTHROW(my_allocator_clean_up(my_json::json_value(t).string)); next_construct_fails = true; - CHECK_THROWS_AS(auto tmp = my_json::json_value(t), std::bad_alloc&); + CHECK_THROWS_AS(my_json::json_value(t), std::bad_alloc&); next_construct_fails = false; } } @@ -182,7 +182,7 @@ TEST_CASE("controlled bad_alloc") my_json::string_t v("foo"); CHECK_NOTHROW(my_allocator_clean_up(my_json::json_value(v).string)); next_construct_fails = true; - CHECK_THROWS_AS(auto tmp = my_json::json_value(v), std::bad_alloc&); + CHECK_THROWS_AS(my_json::json_value(v), std::bad_alloc&); next_construct_fails = false; } } @@ -193,9 +193,9 @@ TEST_CASE("controlled bad_alloc") { next_construct_fails = false; std::map v {{"foo", "bar"}}; - CHECK_NOTHROW(auto tmp = my_json(v)); + CHECK_NOTHROW(my_json(v)); next_construct_fails = true; - CHECK_THROWS_AS(auto tmp = my_json(v), std::bad_alloc&); + CHECK_THROWS_AS(my_json(v), std::bad_alloc&); next_construct_fails = false; } @@ -203,9 +203,9 @@ TEST_CASE("controlled bad_alloc") { next_construct_fails = false; std::vector v {"foo", "bar", "baz"}; - CHECK_NOTHROW(auto tmp = my_json(v)); + CHECK_NOTHROW(my_json(v)); next_construct_fails = true; - CHECK_THROWS_AS(auto tmp = my_json(v), std::bad_alloc&); + CHECK_THROWS_AS(my_json(v), std::bad_alloc&); next_construct_fails = false; } @@ -222,9 +222,9 @@ TEST_CASE("controlled bad_alloc") { next_construct_fails = false; std::string s("foo"); - CHECK_NOTHROW(auto tmp = my_json(s)); + CHECK_NOTHROW(my_json(s)); next_construct_fails = true; - CHECK_THROWS_AS(auto tmp = my_json(s), std::bad_alloc&); + CHECK_THROWS_AS(my_json(s), std::bad_alloc&); next_construct_fails = false; } } diff --git a/test/src/unit-regression.cpp b/test/src/unit-regression.cpp index a5989229..6fc8eeaa 100644 --- a/test/src/unit-regression.cpp +++ b/test/src/unit-regression.cpp @@ -292,7 +292,7 @@ TEST_CASE("regression tests") int number = j["Number"]; CHECK(number == 100); float foo = j["Foo"]; - CHECK(foo == Approx(42.42)); + CHECK(static_cast(foo) == Approx(42.42)); } SECTION("issue #89 - nonstandard integer type") diff --git a/test/src/unit-testsuites.cpp b/test/src/unit-testsuites.cpp index b894a58a..c38b24ef 100644 --- a/test/src/unit-testsuites.cpp +++ b/test/src/unit-testsuites.cpp @@ -457,7 +457,7 @@ TEST_CASE("RFC 7159 examples") } )"; - CHECK_NOTHROW(auto tmp = json(json_contents)); + CHECK_NOTHROW(json(json_contents)); } { @@ -484,7 +484,7 @@ TEST_CASE("RFC 7159 examples") "Country": "US" } ])"; - CHECK_NOTHROW(auto tmp = json(json_contents)); + CHECK_NOTHROW(json(json_contents)); } CHECK(json::parse("\"Hello world!\"") == json("Hello world!")); diff --git a/test/thirdparty/doctest/doctest.h b/test/thirdparty/doctest/doctest.h index 30d7c293..4a2c90fa 100644 --- a/test/thirdparty/doctest/doctest.h +++ b/test/thirdparty/doctest/doctest.h @@ -160,6 +160,7 @@ DOCTEST_GCC_SUPPRESS_WARNING("-Wnon-virtual-dtor") DOCTEST_GCC_SUPPRESS_WARNING("-Winline") DOCTEST_GCC_SUPPRESS_WARNING("-Wunused-local-typedefs") DOCTEST_GCC_SUPPRESS_WARNING("-Wuseless-cast") +DOCTEST_GCC_SUPPRESS_WARNING("-Wnoexcept") DOCTEST_MSVC_SUPPRESS_WARNING_PUSH DOCTEST_MSVC_SUPPRESS_WARNING(4616) // invalid compiler warning @@ -1599,7 +1600,7 @@ namespace detail { ~ContextScope(); - void stringify(std::ostream* s) const; + void stringify(std::ostream* s) const override; }; struct DOCTEST_INTERFACE MessageBuilder : public MessageData @@ -2722,6 +2723,9 @@ DOCTEST_GCC_SUPPRESS_WARNING("-Wold-style-cast") DOCTEST_GCC_SUPPRESS_WARNING("-Wunused-local-typedefs") DOCTEST_GCC_SUPPRESS_WARNING("-Wuseless-cast") DOCTEST_GCC_SUPPRESS_WARNING("-Wunused-function") +DOCTEST_GCC_SUPPRESS_WARNING("-Wmultiple-inheritance") +DOCTEST_GCC_SUPPRESS_WARNING("-Wnoexcept") +DOCTEST_GCC_SUPPRESS_WARNING("-Wsuggest-attribute") DOCTEST_MSVC_SUPPRESS_WARNING_PUSH DOCTEST_MSVC_SUPPRESS_WARNING(4616) // invalid compiler warning @@ -3836,6 +3840,7 @@ namespace { if(curr->translate(res)) return res; // clang-format off + DOCTEST_GCC_SUPPRESS_WARNING_WITH_PUSH("-Wcatch-value") try { throw; } catch(std::exception& ex) { @@ -3847,6 +3852,7 @@ namespace { } catch(...) { return "unknown exception"; } + DOCTEST_GCC_SUPPRESS_WARNING_POP // clang-format on #else // DOCTEST_CONFIG_NO_EXCEPTIONS return ""; @@ -4872,6 +4878,7 @@ namespace { .writeAttribute("name", in.m_name) .writeAttribute("filename", skipPathFromFilename(in.m_file)) .writeAttribute("line", line(in.m_line)); + xml.ensureTagClosed(); } void subcase_end() override { xml.endElement(); } @@ -5997,4 +6004,4 @@ DOCTEST_MSVC_SUPPRESS_WARNING_POP DOCTEST_GCC_SUPPRESS_WARNING_POP #endif // DOCTEST_LIBRARY_IMPLEMENTATION -#endif // DOCTEST_CONFIG_IMPLEMENT \ No newline at end of file +#endif // DOCTEST_CONFIG_IMPLEMENT diff --git a/test/thirdparty/doctest/doctest_compatibility.h b/test/thirdparty/doctest/doctest_compatibility.h index cfbe6a46..b63b0b0a 100644 --- a/test/thirdparty/doctest/doctest_compatibility.h +++ b/test/thirdparty/doctest/doctest_compatibility.h @@ -25,6 +25,29 @@ #define CHECK_THROWS_WITH_STD_STR(expr, str) \ CHECK_THROWS_WITH_STD_STR_IMPL(expr, str, DOCTEST_ANONYMOUS(DOCTEST_STD_STRING_)) +#undef CHECK_THROWS +#undef CHECK_THROWS_AS +#undef CHECK_THROWS_WITH +#undef CHECK_NOTHROW + +#undef REQUIRE_THROWS +#undef REQUIRE_THROWS_AS +#undef REQUIRE_THROWS_WITH +#undef REQUIRE_NOTHROW + +// doctest allows multiple statements in these macros (even blocks of code) but json +// tests rely on passing single function/constructor calls which have a [[nodiscard]] +// attribute so here we static_cast to void - just like Catch does +#define CHECK_THROWS(expr) DOCTEST_CHECK_THROWS(static_cast(expr)) +#define CHECK_THROWS_AS(expr, e) DOCTEST_CHECK_THROWS_AS(static_cast(expr), e) +#define CHECK_THROWS_WITH(expr, e) DOCTEST_CHECK_THROWS_WITH(static_cast(expr), e) +#define CHECK_NOTHROW(expr) DOCTEST_CHECK_NOTHROW(static_cast(expr)) + +#define REQUIRE_THROWS(expr) DOCTEST_REQUIRE_THROWS(static_cast(expr)) +#define REQUIRE_THROWS_AS(expr, e) DOCTEST_REQUIRE_THROWS_AS(static_cast(expr), e) +#define REQUIRE_THROWS_WITH(expr, e) DOCTEST_REQUIRE_THROWS_WITH(static_cast(expr), e) +#define REQUIRE_NOTHROW(expr) DOCTEST_REQUIRE_NOTHROW(static_cast(expr)) + // included here because for some tests in the json repository private is defined as // public and if no STL header is included before that then in the json include when STL // stuff is included the MSVC STL complains (errors) that C++ keywords are being redefined From a0000c32355a0ed5284c366380ec730b350ad988 Mon Sep 17 00:00:00 2001 From: onqtam Date: Wed, 27 Mar 2019 01:09:47 +0200 Subject: [PATCH 036/106] finished the last of the warnings --- test/src/unit-cbor.cpp | 4 ++++ test/src/unit-constructor1.cpp | 2 ++ test/src/unit-conversions.cpp | 1 + test/src/unit-readme.cpp | 2 ++ test/src/unit-reference_access.cpp | 2 ++ test/src/unit-regression.cpp | 7 +++++++ 6 files changed, 18 insertions(+) diff --git a/test/src/unit-cbor.cpp b/test/src/unit-cbor.cpp index 110b1c7b..3d7be8c1 100644 --- a/test/src/unit-cbor.cpp +++ b/test/src/unit-cbor.cpp @@ -876,7 +876,9 @@ TEST_CASE("CBOR") { json j = json::from_cbor(std::vector({0xf9, 0x7c, 0x00})); json::number_float_t d = j; + DOCTEST_GCC_SUPPRESS_WARNING_WITH_PUSH("-Wfloat-equal") CHECK(d == std::numeric_limits::infinity()); + DOCTEST_GCC_SUPPRESS_WARNING_POP CHECK(j.dump() == "null"); } @@ -895,7 +897,9 @@ TEST_CASE("CBOR") { json j = json::from_cbor(std::vector({0xf9, 0x3c, 0x00})); json::number_float_t d = j; + DOCTEST_GCC_SUPPRESS_WARNING_WITH_PUSH("-Wfloat-equal") CHECK(d == 1); + DOCTEST_GCC_SUPPRESS_WARNING_POP } SECTION("-2 (1 10000 0000000000)") diff --git a/test/src/unit-constructor1.cpp b/test/src/unit-constructor1.cpp index b6c20332..115df7b7 100644 --- a/test/src/unit-constructor1.cpp +++ b/test/src/unit-constructor1.cpp @@ -351,7 +351,9 @@ TEST_CASE("constructors") CHECK(jva.size() == va.size()); for (size_t i = 0; i < jva.size(); ++i) { + DOCTEST_GCC_SUPPRESS_WARNING_WITH_PUSH("-Wfloat-equal") CHECK(va[i] == jva[i]); + DOCTEST_GCC_SUPPRESS_WARNING_POP } } diff --git a/test/src/unit-conversions.cpp b/test/src/unit-conversions.cpp index 1476b6e6..53ac1200 100644 --- a/test/src/unit-conversions.cpp +++ b/test/src/unit-conversions.cpp @@ -28,6 +28,7 @@ SOFTWARE. */ #include "doctest_compatibility.h" +DOCTEST_GCC_SUPPRESS_WARNING_WITH_PUSH("-Wsign-promo") #define private public #include diff --git a/test/src/unit-readme.cpp b/test/src/unit-readme.cpp index 3a93f57f..8a64d680 100644 --- a/test/src/unit-readme.cpp +++ b/test/src/unit-readme.cpp @@ -269,7 +269,9 @@ TEST_CASE("README" * doctest::skip()) int i = 42; json jn = i; double f = jn; + DOCTEST_GCC_SUPPRESS_WARNING_WITH_PUSH("-Wfloat-equal") CHECK(f == 42); + DOCTEST_GCC_SUPPRESS_WARNING_POP // etc. diff --git a/test/src/unit-reference_access.cpp b/test/src/unit-reference_access.cpp index fb8d8ea9..f0c64422 100644 --- a/test/src/unit-reference_access.cpp +++ b/test/src/unit-reference_access.cpp @@ -287,7 +287,9 @@ TEST_CASE("reference access") // check if references are returned correctly test_type& p1 = value.get_ref(); CHECK(&p1 == value.get_ptr()); + DOCTEST_GCC_SUPPRESS_WARNING_WITH_PUSH("-Wfloat-equal") CHECK(p1 == value.get()); + DOCTEST_GCC_SUPPRESS_WARNING_POP const test_type& p2 = value.get_ref(); CHECK(&p2 == value.get_ptr()); diff --git a/test/src/unit-regression.cpp b/test/src/unit-regression.cpp index 6fc8eeaa..bb3cc756 100644 --- a/test/src/unit-regression.cpp +++ b/test/src/unit-regression.cpp @@ -28,6 +28,7 @@ SOFTWARE. */ #include "doctest_compatibility.h" +DOCTEST_GCC_SUPPRESS_WARNING_WITH_PUSH("-Wsign-promo") // for some reason including this after the json header leads to linker errors with VS 2017... #include @@ -314,7 +315,9 @@ TEST_CASE("regression tests") // unsigned integer parsing - expected to overflow and be stored as a float j = custom_json::parse("4294967296"); // 2^32 CHECK(static_cast(j.type()) == static_cast(custom_json::value_t::number_float)); + DOCTEST_GCC_SUPPRESS_WARNING_WITH_PUSH("-Wfloat-equal") CHECK(j.get() == 4294967296.0f); + DOCTEST_GCC_SUPPRESS_WARNING_POP // integer object creation - expected to wrap and still be stored as an integer j = -2147483649LL; // -2^31-1 @@ -479,7 +482,9 @@ TEST_CASE("regression tests") json j; j = json::parse("-0.0"); + DOCTEST_GCC_SUPPRESS_WARNING_WITH_PUSH("-Wfloat-equal") CHECK(j.get() == -0.0); + DOCTEST_GCC_SUPPRESS_WARNING_POP j = json::parse("2.22507385850720113605740979670913197593481954635164564e-308"); CHECK(j.get() == 2.2250738585072009e-308); @@ -517,7 +522,9 @@ TEST_CASE("regression tests") // long double nlohmann::basic_json j_long_double = 1.23e45L; + DOCTEST_GCC_SUPPRESS_WARNING_WITH_PUSH("-Wfloat-equal") CHECK(j_long_double.get() == 1.23e45L); + DOCTEST_GCC_SUPPRESS_WARNING_POP } SECTION("issue #228 - double values are serialized with commas as decimal points") From b4def6dcba553dc7ce65cf9a1c0086016aa88394 Mon Sep 17 00:00:00 2001 From: onqtam Date: Wed, 27 Mar 2019 01:13:10 +0200 Subject: [PATCH 037/106] tabs instead of spaces... --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 51376aac..39f3493f 100644 --- a/Makefile +++ b/Makefile @@ -131,7 +131,7 @@ pedantic_clang: -Werror \ -Weverything \ -Wno-documentation-unknown-command \ - -Wno-exit-time-destructors \ + -Wno-exit-time-destructors \ -Wno-keyword-macro \ -Wno-deprecated-declarations \ -Wno-weak-vtables \ From 5ccdaf643f3df1679a5386402e8cc1508b239915 Mon Sep 17 00:00:00 2001 From: "Watal M. Iwasaki" Date: Thu, 28 Mar 2019 14:38:58 +0900 Subject: [PATCH 038/106] Remove C++17 extension warning from clang; #1535 - Switch off `nodiscard` for clang unless C++17 is detected. - Detect C++ standard before the switch. --- include/nlohmann/detail/macro_scope.hpp | 22 +++++++++++++--------- single_include/nlohmann/json.hpp | 22 +++++++++++++--------- 2 files changed, 26 insertions(+), 18 deletions(-) diff --git a/include/nlohmann/detail/macro_scope.hpp b/include/nlohmann/detail/macro_scope.hpp index ef138100..e41180a9 100644 --- a/include/nlohmann/detail/macro_scope.hpp +++ b/include/nlohmann/detail/macro_scope.hpp @@ -18,6 +18,14 @@ #endif #endif +// C++ language standard detection +#if (defined(__cplusplus) && __cplusplus >= 201703L) || (defined(_HAS_CXX17) && _HAS_CXX17 == 1) // fix for issue #464 + #define JSON_HAS_CPP_17 + #define JSON_HAS_CPP_14 +#elif (defined(__cplusplus) && __cplusplus >= 201402L) || (defined(_HAS_CXX14) && _HAS_CXX14 == 1) + #define JSON_HAS_CPP_14 +#endif + // disable float-equal warnings on GCC/clang #if defined(__clang__) || defined(__GNUC__) || defined(__GNUG__) #pragma GCC diagnostic push @@ -42,7 +50,11 @@ // allow for portable nodiscard warnings #if defined(__has_cpp_attribute) #if __has_cpp_attribute(nodiscard) - #define JSON_NODISCARD [[nodiscard]] + #if defined(__clang__) && !defined(JSON_HAS_CPP_17) // issue #1535 + #define JSON_NODISCARD + #else + #define JSON_NODISCARD [[nodiscard]] + #endif #elif __has_cpp_attribute(gnu::warn_unused_result) #define JSON_NODISCARD [[gnu::warn_unused_result]] #else @@ -95,14 +107,6 @@ #define JSON_UNLIKELY(x) x #endif -// C++ language standard detection -#if (defined(__cplusplus) && __cplusplus >= 201703L) || (defined(_HAS_CXX17) && _HAS_CXX17 == 1) // fix for issue #464 - #define JSON_HAS_CPP_17 - #define JSON_HAS_CPP_14 -#elif (defined(__cplusplus) && __cplusplus >= 201402L) || (defined(_HAS_CXX14) && _HAS_CXX14 == 1) - #define JSON_HAS_CPP_14 -#endif - /*! @brief macro to briefly define a mapping between an enum and JSON @def NLOHMANN_JSON_SERIALIZE_ENUM diff --git a/single_include/nlohmann/json.hpp b/single_include/nlohmann/json.hpp index 5003a4fa..1f11538c 100644 --- a/single_include/nlohmann/json.hpp +++ b/single_include/nlohmann/json.hpp @@ -469,6 +469,14 @@ class other_error : public exception #endif #endif +// C++ language standard detection +#if (defined(__cplusplus) && __cplusplus >= 201703L) || (defined(_HAS_CXX17) && _HAS_CXX17 == 1) // fix for issue #464 + #define JSON_HAS_CPP_17 + #define JSON_HAS_CPP_14 +#elif (defined(__cplusplus) && __cplusplus >= 201402L) || (defined(_HAS_CXX14) && _HAS_CXX14 == 1) + #define JSON_HAS_CPP_14 +#endif + // disable float-equal warnings on GCC/clang #if defined(__clang__) || defined(__GNUC__) || defined(__GNUG__) #pragma GCC diagnostic push @@ -493,7 +501,11 @@ class other_error : public exception // allow for portable nodiscard warnings #if defined(__has_cpp_attribute) #if __has_cpp_attribute(nodiscard) - #define JSON_NODISCARD [[nodiscard]] + #if defined(__clang__) && !defined(JSON_HAS_CPP_17) // issue #1535 + #define JSON_NODISCARD + #else + #define JSON_NODISCARD [[nodiscard]] + #endif #elif __has_cpp_attribute(gnu::warn_unused_result) #define JSON_NODISCARD [[gnu::warn_unused_result]] #else @@ -546,14 +558,6 @@ class other_error : public exception #define JSON_UNLIKELY(x) x #endif -// C++ language standard detection -#if (defined(__cplusplus) && __cplusplus >= 201703L) || (defined(_HAS_CXX17) && _HAS_CXX17 == 1) // fix for issue #464 - #define JSON_HAS_CPP_17 - #define JSON_HAS_CPP_14 -#elif (defined(__cplusplus) && __cplusplus >= 201402L) || (defined(_HAS_CXX14) && _HAS_CXX14 == 1) - #define JSON_HAS_CPP_14 -#endif - /*! @brief macro to briefly define a mapping between an enum and JSON @def NLOHMANN_JSON_SERIALIZE_ENUM From 191aa0fd6f72b4387cc31f3d2dfaa721c3e6207f Mon Sep 17 00:00:00 2001 From: Niels Lohmann Date: Thu, 28 Mar 2019 14:22:48 +0100 Subject: [PATCH 039/106] :wrench: overworked maintaner targets --- CMakeLists.txt | 5 +- Makefile | 215 +++++++++++++++++++++++++++++--------------- test/CMakeLists.txt | 4 +- 3 files changed, 146 insertions(+), 78 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 9887657f..1b0bca9f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -23,8 +23,7 @@ option(JSON_MultipleHeaders "Use non-amalgamated version of the library." OFF) ## CONFIGURATION ## set(NLOHMANN_JSON_TARGET_NAME ${PROJECT_NAME}) -set(NLOHMANN_JSON_CONFIG_INSTALL_DIR "lib/cmake/${PROJECT_NAME}" - CACHE INTERNAL "") +set(NLOHMANN_JSON_CONFIG_INSTALL_DIR "lib/cmake/${PROJECT_NAME}" CACHE INTERNAL "") set(NLOHMANN_JSON_INCLUDE_INSTALL_DIR "include") set(NLOHMANN_JSON_TARGETS_EXPORT_NAME "${PROJECT_NAME}Targets") set(NLOHMANN_JSON_CMAKE_CONFIG_TEMPLATE "cmake/config.cmake.in") @@ -47,7 +46,7 @@ endif() ## add_library(${NLOHMANN_JSON_TARGET_NAME} INTERFACE) add_library(${PROJECT_NAME}::${NLOHMANN_JSON_TARGET_NAME} ALIAS ${NLOHMANN_JSON_TARGET_NAME}) -if (${CMAKE_VERSION} VERSION_LESS "3.8.0") +if (${CMAKE_VERSION} VERSION_LESS "3.8.0") target_compile_features(${NLOHMANN_JSON_TARGET_NAME} INTERFACE cxx_range_for) else() target_compile_features(${NLOHMANN_JSON_TARGET_NAME} INTERFACE cxx_std_11) diff --git a/Makefile b/Makefile index 24c77f51..127bafd8 100644 --- a/Makefile +++ b/Makefile @@ -1,44 +1,31 @@ -.PHONY: pretty clean ChangeLog.md +.PHONY: pretty clean ChangeLog.md release -SRCS = include/nlohmann/json.hpp \ - include/nlohmann/json_fwd.hpp \ - include/nlohmann/adl_serializer.hpp \ - include/nlohmann/detail/conversions/from_json.hpp \ - include/nlohmann/detail/conversions/to_chars.hpp \ - include/nlohmann/detail/conversions/to_json.hpp \ - include/nlohmann/detail/exceptions.hpp \ - include/nlohmann/detail/input/binary_reader.hpp \ - include/nlohmann/detail/input/input_adapters.hpp \ - include/nlohmann/detail/input/json_sax.hpp \ - include/nlohmann/detail/input/lexer.hpp \ - include/nlohmann/detail/input/parser.hpp \ - include/nlohmann/detail/input/position_t.hpp \ - include/nlohmann/detail/iterators/internal_iterator.hpp \ - include/nlohmann/detail/iterators/iter_impl.hpp \ - include/nlohmann/detail/iterators/iteration_proxy.hpp \ - include/nlohmann/detail/iterators/json_reverse_iterator.hpp \ - include/nlohmann/detail/iterators/primitive_iterator.hpp \ - include/nlohmann/detail/json_pointer.hpp \ - include/nlohmann/detail/json_ref.hpp \ - include/nlohmann/detail/macro_scope.hpp \ - include/nlohmann/detail/macro_unscope.hpp \ - include/nlohmann/detail/meta/cpp_future.hpp \ - include/nlohmann/detail/meta/detected.hpp \ - include/nlohmann/detail/meta/type_traits.hpp \ - include/nlohmann/detail/meta/void_t.hpp \ - include/nlohmann/detail/output/binary_writer.hpp \ - include/nlohmann/detail/output/output_adapters.hpp \ - include/nlohmann/detail/output/serializer.hpp \ - include/nlohmann/detail/value_t.hpp - -UNAME = $(shell uname) -CXX=clang++ - -AMALGAMATED_FILE=single_include/nlohmann/json.hpp +########################################################################## +# configuration +########################################################################## # directory to recent compiler binaries COMPILER_DIR=/Users/niels/Documents/projects/compilers/local/bin +# find GNU sed to use `-i` parameter +SED:=$(shell command -v gsed || which sed) + + +########################################################################## +# source files +########################################################################## + +# the list of sources in the include folder +SRCS=$(shell find include -type f | sort) + +# the single header (amalgamated from the source files) +AMALGAMATED_FILE=single_include/nlohmann/json.hpp + + +########################################################################## +# documentation of the Makefile's targets +########################################################################## + # main target all: @echo "amalgamate - amalgamate file single_include/nlohmann/json.hpp from the include/nlohmann sources" @@ -64,6 +51,7 @@ all: @echo "pretty - beautify code with Artistic Style" @echo "run_benchmarks - build and run benchmarks" + ########################################################################## # unit tests ########################################################################## @@ -76,25 +64,19 @@ json_unit: check: $(MAKE) check -C test +# run unit tests and skip expensive tests check-fast: $(MAKE) check -C test TEST_PATTERN="" -# clean up -clean: - rm -fr json_unit json_benchmarks fuzz fuzz-testing *.dSYM test/*.dSYM - rm -fr benchmarks/files/numbers/*.json - rm -fr build_coverage build_benchmarks - $(MAKE) clean -Cdoc - $(MAKE) clean -Ctest - ########################################################################## # coverage ########################################################################## coverage: + rm -fr build_coverage mkdir build_coverage - cd build_coverage ; CXX=g++-7 cmake .. -GNinja -DJSON_Coverage=ON -DJSON_MultipleHeaders=ON + cd build_coverage ; CXX=$(COMPILER_DIR)/g++ cmake .. -GNinja -DJSON_Coverage=ON -DJSON_MultipleHeaders=ON cd build_coverage ; ninja cd build_coverage ; ctest -E '.*_default' -j10 cd build_coverage ; ninja lcov_html @@ -372,9 +354,10 @@ pedantic_gcc: ########################################################################## run_benchmarks: + rm -fr build_benchmarks mkdir build_benchmarks - cd build_benchmarks ; cmake ../benchmarks - cd build_benchmarks ; make + cd build_benchmarks ; cmake ../benchmarks -GNinja -DCMAKE_BUILD_TYPE=Release + cd build_benchmarks ; ninja cd build_benchmarks ; ./json_benchmarks ########################################################################## @@ -436,28 +419,39 @@ fuzzing-stop: -killall fuzzer -killall afl-fuzz + ########################################################################## -# static analyzer +# Static analysis ########################################################################## -# call cppcheck on the main header file +# call cppcheck +# Note: this target is called by Travis cppcheck: cppcheck --enable=warning --inline-suppr --inconclusive --force --std=c++11 $(SRCS) --error-exitcode=1 -# compile and check with Clang Static Analyzer +# call Clang Static Analyzer clang_analyze: rm -fr clang_analyze_build mkdir clang_analyze_build cd clang_analyze_build ; CCC_CXX=$(COMPILER_DIR)/clang++ CXX=$(COMPILER_DIR)/clang++ $(COMPILER_DIR)/scan-build cmake .. -GNinja - cd clang_analyze_build ; $(COMPILER_DIR)/scan-build -enable-checker alpha.core.BoolAssignment,alpha.core.CallAndMessageUnInitRefArg,alpha.core.CastSize,alpha.core.CastToStruct,alpha.core.Conversion,alpha.core.DynamicTypeChecker,alpha.core.FixedAddr,alpha.core.PointerArithm,alpha.core.PointerSub,alpha.core.SizeofPtr,alpha.core.StackAddressAsyncEscape,alpha.core.TestAfterDivZero,alpha.deadcode.UnreachableCode,core.builtin.BuiltinFunctions,core.builtin.NoReturnFunctions,core.CallAndMessage,core.DivideZero,core.DynamicTypePropagation,core.NonnilStringConstants,core.NonNullParamChecker,core.NullDereference,core.StackAddressEscape,core.UndefinedBinaryOperatorResult,core.uninitialized.ArraySubscript,core.uninitialized.Assign,core.uninitialized.Branch,core.uninitialized.CapturedBlockVariable,core.uninitialized.UndefReturn,core.VLASize,cplusplus.InnerPointer,cplusplus.Move,cplusplus.NewDelete,cplusplus.NewDeleteLeaks,cplusplus.SelfAssignment,deadcode.DeadStores,nullability.NullableDereferenced,nullability.NullablePassedToNonnull,nullability.NullableReturnedFromNonnull,nullability.NullPassedToNonnull,nullability.NullReturnedFromNonnull --use-c++=$(COMPILER_DIR)/clang++ --view -analyze-headers -o clang_analyze_build/report.html ninja + cd clang_analyze_build ; \ + $(COMPILER_DIR)/scan-build \ + -enable-checker alpha.core.BoolAssignment,alpha.core.CallAndMessageUnInitRefArg,alpha.core.CastSize,alpha.core.CastToStruct,alpha.core.Conversion,alpha.core.DynamicTypeChecker,alpha.core.FixedAddr,alpha.core.PointerArithm,alpha.core.PointerSub,alpha.core.SizeofPtr,alpha.core.StackAddressAsyncEscape,alpha.core.TestAfterDivZero,alpha.deadcode.UnreachableCode,core.builtin.BuiltinFunctions,core.builtin.NoReturnFunctions,core.CallAndMessage,core.DivideZero,core.DynamicTypePropagation,core.NonnilStringConstants,core.NonNullParamChecker,core.NullDereference,core.StackAddressEscape,core.UndefinedBinaryOperatorResult,core.uninitialized.ArraySubscript,core.uninitialized.Assign,core.uninitialized.Branch,core.uninitialized.CapturedBlockVariable,core.uninitialized.UndefReturn,core.VLASize,cplusplus.InnerPointer,cplusplus.Move,cplusplus.NewDelete,cplusplus.NewDeleteLeaks,cplusplus.SelfAssignment,deadcode.DeadStores,nullability.NullableDereferenced,nullability.NullablePassedToNonnull,nullability.NullableReturnedFromNonnull,nullability.NullPassedToNonnull,nullability.NullReturnedFromNonnull \ + --use-c++=$(COMPILER_DIR)/clang++ -analyze-headers -o report ninja + open clang_analyze_build/report/*/index.html -# call cpplint (some errors expected due to false positives) +# call cpplint +# Note: some errors expected due to false positives cpplint: - third_party/cpplint/cpplint.py --filter=-whitespace,-legal,-readability/alt_tokens,-runtime/references,-runtime/explicit --quiet --recursive include + third_party/cpplint/cpplint.py \ + --filter=-whitespace,-legal,-readability/alt_tokens,-runtime/references,-runtime/explicit \ + --quiet --recursive $(SRCS) +# call Clang-Tidy clang_tidy: $(COMPILER_DIR)/clang-tidy $(SRCS) -- -Iinclude -std=c++11 +# call PVS-Studio Analyzer pvs_studio: rm -fr pvs_studio_build mkdir pvs_studio_build @@ -466,45 +460,70 @@ pvs_studio: cd pvs_studio_build ; plog-converter -a'GA:1,2;64:1;CS' -t fullhtml PVS-Studio.log -o pvs open pvs_studio_build/pvs/index.html +# call Infer static analyzer infer: rm -fr infer_build mkdir infer_build cd infer_build ; infer compile -- cmake .. ; infer run -- make -j 4 +# call OCLint static analyzer oclint: oclint $(SRCS) -report-type html -enable-global-analysis -o oclint_report.html -max-priority-1=10000 -max-priority-2=10000 -max-priority-3=10000 -- -std=c++11 -Iinclude open oclint_report.html +# execute the test suite with Clang sanitizers (address and undefined behavior) +clang_sanitize: + rm -fr clang_sanitize_build + mkdir clang_sanitize_build + cd clang_sanitize_build ; CXX=$(COMPILER_DIR)/clang++ cmake .. -DJSON_Sanitizer=On -DJSON_MultipleHeaders=ON -GNinja + cd clang_sanitize_build ; ninja + cd clang_sanitize_build ; ctest -E '.*_default' -j10 + + ########################################################################## -# maintainer targets +# Code format and source amalgamation ########################################################################## -# pretty printer +# call the Artistic Style pretty printer on all source files pretty: - astyle --style=allman --indent=spaces=4 --indent-modifiers \ - --indent-switches --indent-preproc-block --indent-preproc-define \ - --indent-col1-comments --pad-oper --pad-header --align-pointer=type \ - --align-reference=type --add-brackets --convert-tabs --close-templates \ - --lineend=linux --preserve-date --suffix=none --formatted \ - $(SRCS) $(AMALGAMATED_FILE) test/src/*.cpp \ - benchmarks/src/benchmarks.cpp doc/examples/*.cpp + astyle \ + --style=allman \ + --indent=spaces=4 \ + --indent-modifiers \ + --indent-switches \ + --indent-preproc-block \ + --indent-preproc-define \ + --indent-col1-comments \ + --pad-oper \ + --pad-header \ + --align-pointer=type \ + --align-reference=type \ + --add-brackets \ + --convert-tabs \ + --close-templates \ + --lineend=linux \ + --preserve-date \ + --suffix=none \ + --formatted \ + $(SRCS) $(AMALGAMATED_FILE) test/src/*.cpp benchmarks/src/benchmarks.cpp doc/examples/*.cpp # create single header file amalgamate: $(AMALGAMATED_FILE) +# call the amalgamation tool and pretty print $(AMALGAMATED_FILE): $(SRCS) third_party/amalgamate/amalgamate.py -c third_party/amalgamate/config.json -s . --verbose=yes $(MAKE) pretty -# check if single_include/nlohmann/json.hpp has been amalgamated from the nlohmann sources +# check if file single_include/nlohmann/json.hpp has been amalgamated from the nlohmann sources +# Note: this target is called by Travis check-amalgamation: @mv $(AMALGAMATED_FILE) $(AMALGAMATED_FILE)~ @$(MAKE) amalgamate @diff $(AMALGAMATED_FILE) $(AMALGAMATED_FILE)~ || (echo "===================================================================\n Amalgamation required! Please read the contribution guidelines\n in file .github/CONTRIBUTING.md.\n===================================================================" ; mv $(AMALGAMATED_FILE)~ $(AMALGAMATED_FILE) ; false) @mv $(AMALGAMATED_FILE)~ $(AMALGAMATED_FILE) -# check if every header in nlohmann includes sufficient headers to be compiled -# individually +# check if every header in nlohmann includes sufficient headers to be compiled individually check-single-includes: @for x in $(SRCS); do \ echo "Checking self-sufficiency of $$x..." ; \ @@ -513,29 +532,79 @@ check-single-includes: rm -f single_include_test.cpp single_include_test; \ done + ########################################################################## -# changelog +# CMake ########################################################################## +# grep "^option" CMakeLists.txt test/CMakeLists.txt | sed 's/(/ /' | awk '{print $2}' | xargs + +# check if all flags of our CMake files work +check_cmake_flags_do: + $(CMAKE_BINARY) --version + for flag in '' JSON_BuildTests JSON_Install JSON_MultipleHeaders JSON_Sanitizer JSON_Valgrind JSON_NoExceptions JSON_Coverage; do \ + rm -fr cmake_build; \ + mkdir cmake_build; \ + echo "$(CMAKE_BINARY) .. -D$$flag=On" ; \ + cd cmake_build ; \ + CXX=g++-8 $(CMAKE_BINARY) .. -D$$flag=On -DCMAKE_CXX_COMPILE_FEATURES="cxx_std_11;cxx_range_for" -DCMAKE_CXX_FLAGS="-std=gnu++11" ; \ + test -f Makefile || exit 1 ; \ + cd .. ; \ + done; + +# call target `check_cmake_flags_do` twice: once for minimal required CMake version 3.1.0 and once for the installed version +check_cmake_flags: + wget https://github.com/Kitware/CMake/releases/download/v3.1.0/cmake-3.1.0-Darwin64.tar.gz + tar xfz cmake-3.1.0-Darwin64.tar.gz + CMAKE_BINARY=$(abspath cmake-3.1.0-Darwin64/CMake.app/Contents/bin/cmake) $(MAKE) check_cmake_flags_do + CMAKE_BINARY=$(shell which cmake) $(MAKE) check_cmake_flags_do + + +########################################################################## +# ChangeLog +########################################################################## + +# Create a ChangeLog based on the git log using the GitHub Changelog Generator +# (). + +# variable to control the diffs between the last released version and the current repository state NEXT_VERSION ?= "unreleased" ChangeLog.md: github_changelog_generator -o ChangeLog.md --simple-list --release-url https://github.com/nlohmann/json/releases/tag/%s --future-release $(NEXT_VERSION) - gsed -i 's|https://github.com/nlohmann/json/releases/tag/HEAD|https://github.com/nlohmann/json/tree/HEAD|' ChangeLog.md - gsed -i '2i All notable changes to this project will be documented in this file. This project adheres to [Semantic Versioning](http://semver.org/).' ChangeLog.md + $(SED) -i 's|https://github.com/nlohmann/json/releases/tag/HEAD|https://github.com/nlohmann/json/tree/HEAD|' ChangeLog.md + $(SED) -i '2i All notable changes to this project will be documented in this file. This project adheres to [Semantic Versioning](http://semver.org/).' ChangeLog.md ########################################################################## -# release +# Release files ########################################################################## +# Create the files for a release and add signatures and hashes. We use `--no-extra` to make the resulting ZIP file +# reproducible, see . + release: + rm -fr release_files mkdir release_files - zip -9 -r include.zip include/* + zip -9 --recurse-paths --no-extra include.zip $(SRCS) gpg --armor --detach-sig include.zip mv include.zip include.zip.asc release_files - gpg --armor --detach-sig single_include/nlohmann/json.hpp - cp single_include/nlohmann/json.hpp release_files - mv single_include/nlohmann/json.hpp.asc release_files + gpg --armor --detach-sig $(AMALGAMATED_FILE) + cp $(AMALGAMATED_FILE) release_files + mv $(AMALGAMATED_FILE).asc release_files cd release_files ; shasum -a 256 json.hpp > hashes.txt cd release_files ; shasum -a 256 include.zip >> hashes.txt + + +########################################################################## +# Maintenance +########################################################################## + +# clean up +clean: + rm -fr json_unit json_benchmarks fuzz fuzz-testing *.dSYM test/*.dSYM oclint_report.html + rm -fr benchmarks/files/numbers/*.json + rm -fr cmake-3.1.0-Darwin64.tar.gz cmake-3.1.0-Darwin64 + rm -fr build_coverage build_benchmarks fuzz-testing clang_analyze_build pvs_studio_build infer_build clang_sanitize_build cmake_build + $(MAKE) clean -Cdoc + $(MAKE) clean -Ctest diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 5f253bff..496c154e 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -6,7 +6,7 @@ option(JSON_Coverage "Build test suite with coverage information" OFF) if(JSON_Sanitizer) message(STATUS "Building test suite with Clang sanitizer") if(NOT MSVC) - set(CMAKE_CXX_FLAGS "-g -O2 -fsanitize=address -fsanitize=undefined -fno-omit-frame-pointer") + set(CMAKE_CXX_FLAGS "-g -O2 -fsanitize=address -fsanitize=undefined -fsanitize=implicit-conversion -fsanitize=integer -fsanitize=nullability -fno-omit-frame-pointer") endif() endif() @@ -64,7 +64,7 @@ set_target_properties(catch_main PROPERTIES COMPILE_DEFINITIONS "$<$:_SCL_SECURE_NO_WARNINGS>" COMPILE_OPTIONS "$<$:/EHsc;$<$:/Od>>" ) -if (${CMAKE_VERSION} VERSION_LESS "3.8.0") +if (${CMAKE_VERSION} VERSION_LESS "3.8.0") target_compile_features(catch_main PUBLIC cxx_range_for) else() target_compile_features(catch_main PUBLIC cxx_std_11) From 23635704c3f9fce7d19eeca018277022c11a7b6b Mon Sep 17 00:00:00 2001 From: Niels Lohmann Date: Thu, 28 Mar 2019 14:23:07 +0100 Subject: [PATCH 040/106] :arrow_up: added script to update cpplint --- third_party/cpplint/LICENSE | 0 third_party/cpplint/README.rst | 0 third_party/cpplint/update.sh | 5 +++++ 3 files changed, 5 insertions(+) mode change 100755 => 100644 third_party/cpplint/LICENSE mode change 100755 => 100644 third_party/cpplint/README.rst create mode 100755 third_party/cpplint/update.sh diff --git a/third_party/cpplint/LICENSE b/third_party/cpplint/LICENSE old mode 100755 new mode 100644 diff --git a/third_party/cpplint/README.rst b/third_party/cpplint/README.rst old mode 100755 new mode 100644 diff --git a/third_party/cpplint/update.sh b/third_party/cpplint/update.sh new file mode 100755 index 00000000..03b6785b --- /dev/null +++ b/third_party/cpplint/update.sh @@ -0,0 +1,5 @@ +#!/bin/sh + +wget -N https://raw.githubusercontent.com/cpplint/cpplint/master/cpplint.py +wget -N https://raw.githubusercontent.com/cpplint/cpplint/master/LICENSE +wget -N https://raw.githubusercontent.com/cpplint/cpplint/master/README.rst From d21d298397d349a4a4ade24a5012277199f2d63f Mon Sep 17 00:00:00 2001 From: Niels Lohmann Date: Thu, 28 Mar 2019 14:23:26 +0100 Subject: [PATCH 041/106] :art: fixed indentation --- .../detail/iterators/iterator_traits.hpp | 32 ++-- include/nlohmann/detail/meta/is_sax.hpp | 160 +++++++++--------- 2 files changed, 97 insertions(+), 95 deletions(-) diff --git a/include/nlohmann/detail/iterators/iterator_traits.hpp b/include/nlohmann/detail/iterators/iterator_traits.hpp index 9806be8c..4cced80c 100644 --- a/include/nlohmann/detail/iterators/iterator_traits.hpp +++ b/include/nlohmann/detail/iterators/iterator_traits.hpp @@ -13,15 +13,16 @@ template struct iterator_types {}; template -struct iterator_types< +struct iterator_types < It, void_t> { - using difference_type = typename It::difference_type; - using value_type = typename It::value_type; - using pointer = typename It::pointer; - using reference = typename It::reference; - using iterator_category = typename It::iterator_category; + typename It::reference, typename It::iterator_category >> +{ + using difference_type = typename It::difference_type; + using value_type = typename It::value_type; + using pointer = typename It::pointer; + using reference = typename It::reference; + using iterator_category = typename It::iterator_category; }; // This is required as some compilers implement std::iterator_traits in a way that @@ -32,18 +33,19 @@ struct iterator_traits }; template -struct iterator_traits::value>> - : iterator_types +struct iterator_traits < T, enable_if_t < !std::is_pointer::value >> + : iterator_types { }; template -struct iterator_traits::value>> { - using iterator_category = std::random_access_iterator_tag; - using value_type = T; - using difference_type = ptrdiff_t; - using pointer = T*; - using reference = T&; +struct iterator_traits::value>> +{ + using iterator_category = std::random_access_iterator_tag; + using value_type = T; + using difference_type = ptrdiff_t; + using pointer = T*; + using reference = T&; }; } // namespace detail } // namespace nlohmann diff --git a/include/nlohmann/detail/meta/is_sax.hpp b/include/nlohmann/detail/meta/is_sax.hpp index 4a4f5bbd..88295bec 100644 --- a/include/nlohmann/detail/meta/is_sax.hpp +++ b/include/nlohmann/detail/meta/is_sax.hpp @@ -24,119 +24,119 @@ using number_integer_function_t = template using number_unsigned_function_t = - decltype(std::declval().number_unsigned(std::declval())); + decltype(std::declval().number_unsigned(std::declval())); template -using number_float_function_t = decltype(std::declval().number_float( - std::declval(), std::declval())); +using number_float_function_t = decltype(std::declval().number_float( + std::declval(), std::declval())); template using string_function_t = - decltype(std::declval().string(std::declval())); + decltype(std::declval().string(std::declval())); template using start_object_function_t = - decltype(std::declval().start_object(std::declval())); + decltype(std::declval().start_object(std::declval())); template using key_function_t = - decltype(std::declval().key(std::declval())); + decltype(std::declval().key(std::declval())); template -using end_object_function_t = decltype(std::declval().end_object()); +using end_object_function_t = decltype(std::declval().end_object()); template using start_array_function_t = - decltype(std::declval().start_array(std::declval())); + decltype(std::declval().start_array(std::declval())); template -using end_array_function_t = decltype(std::declval().end_array()); +using end_array_function_t = decltype(std::declval().end_array()); template -using parse_error_function_t = decltype(std::declval().parse_error( - std::declval(), std::declval(), - std::declval())); +using parse_error_function_t = decltype(std::declval().parse_error( + std::declval(), std::declval(), + std::declval())); template struct is_sax { -private: - static_assert(is_basic_json::value, - "BasicJsonType must be of type basic_json<...>"); + private: + static_assert(is_basic_json::value, + "BasicJsonType must be of type basic_json<...>"); - using number_integer_t = typename BasicJsonType::number_integer_t; - using number_unsigned_t = typename BasicJsonType::number_unsigned_t; - using number_float_t = typename BasicJsonType::number_float_t; - using string_t = typename BasicJsonType::string_t; - using exception_t = typename BasicJsonType::exception; + using number_integer_t = typename BasicJsonType::number_integer_t; + using number_unsigned_t = typename BasicJsonType::number_unsigned_t; + using number_float_t = typename BasicJsonType::number_float_t; + using string_t = typename BasicJsonType::string_t; + using exception_t = typename BasicJsonType::exception; -public: - static constexpr bool value = - is_detected_exact::value && - is_detected_exact::value && - is_detected_exact::value && - is_detected_exact::value && - is_detected_exact::value && - is_detected_exact::value && - is_detected_exact::value && - is_detected_exact::value && - is_detected_exact::value && - is_detected_exact::value && - is_detected_exact::value && - is_detected_exact::value; + public: + static constexpr bool value = + is_detected_exact::value && + is_detected_exact::value && + is_detected_exact::value && + is_detected_exact::value && + is_detected_exact::value && + is_detected_exact::value && + is_detected_exact::value && + is_detected_exact::value && + is_detected_exact::value && + is_detected_exact::value && + is_detected_exact::value && + is_detected_exact::value; }; template struct is_sax_static_asserts { -private: - static_assert(is_basic_json::value, - "BasicJsonType must be of type basic_json<...>"); + private: + static_assert(is_basic_json::value, + "BasicJsonType must be of type basic_json<...>"); - using number_integer_t = typename BasicJsonType::number_integer_t; - using number_unsigned_t = typename BasicJsonType::number_unsigned_t; - using number_float_t = typename BasicJsonType::number_float_t; - using string_t = typename BasicJsonType::string_t; - using exception_t = typename BasicJsonType::exception; + using number_integer_t = typename BasicJsonType::number_integer_t; + using number_unsigned_t = typename BasicJsonType::number_unsigned_t; + using number_float_t = typename BasicJsonType::number_float_t; + using string_t = typename BasicJsonType::string_t; + using exception_t = typename BasicJsonType::exception; -public: - static_assert(is_detected_exact::value, - "Missing/invalid function: bool null()"); - static_assert(is_detected_exact::value, - "Missing/invalid function: bool boolean(bool)"); - static_assert(is_detected_exact::value, - "Missing/invalid function: bool boolean(bool)"); - static_assert( - is_detected_exact::value, - "Missing/invalid function: bool number_integer(number_integer_t)"); - static_assert( - is_detected_exact::value, - "Missing/invalid function: bool number_unsigned(number_unsigned_t)"); - static_assert(is_detected_exact::value, - "Missing/invalid function: bool number_float(number_float_t, const string_t&)"); - static_assert( - is_detected_exact::value, - "Missing/invalid function: bool string(string_t&)"); - static_assert(is_detected_exact::value, - "Missing/invalid function: bool start_object(std::size_t)"); - static_assert(is_detected_exact::value, - "Missing/invalid function: bool key(string_t&)"); - static_assert(is_detected_exact::value, - "Missing/invalid function: bool end_object()"); - static_assert(is_detected_exact::value, - "Missing/invalid function: bool start_array(std::size_t)"); - static_assert(is_detected_exact::value, - "Missing/invalid function: bool end_array()"); - static_assert( - is_detected_exact::value, - "Missing/invalid function: bool parse_error(std::size_t, const " - "std::string&, const exception&)"); + public: + static_assert(is_detected_exact::value, + "Missing/invalid function: bool null()"); + static_assert(is_detected_exact::value, + "Missing/invalid function: bool boolean(bool)"); + static_assert(is_detected_exact::value, + "Missing/invalid function: bool boolean(bool)"); + static_assert( + is_detected_exact::value, + "Missing/invalid function: bool number_integer(number_integer_t)"); + static_assert( + is_detected_exact::value, + "Missing/invalid function: bool number_unsigned(number_unsigned_t)"); + static_assert(is_detected_exact::value, + "Missing/invalid function: bool number_float(number_float_t, const string_t&)"); + static_assert( + is_detected_exact::value, + "Missing/invalid function: bool string(string_t&)"); + static_assert(is_detected_exact::value, + "Missing/invalid function: bool start_object(std::size_t)"); + static_assert(is_detected_exact::value, + "Missing/invalid function: bool key(string_t&)"); + static_assert(is_detected_exact::value, + "Missing/invalid function: bool end_object()"); + static_assert(is_detected_exact::value, + "Missing/invalid function: bool start_array(std::size_t)"); + static_assert(is_detected_exact::value, + "Missing/invalid function: bool end_array()"); + static_assert( + is_detected_exact::value, + "Missing/invalid function: bool parse_error(std::size_t, const " + "std::string&, const exception&)"); }; } // namespace detail } // namespace nlohmann From c7878173f98e7f32a900bc4d0bfd2a3d3570fe97 Mon Sep 17 00:00:00 2001 From: Niels Lohmann Date: Fri, 29 Mar 2019 13:10:11 +0100 Subject: [PATCH 042/106] :hammer: minor changes to maintainer targets --- Makefile | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/Makefile b/Makefile index 127bafd8..ff509e39 100644 --- a/Makefile +++ b/Makefile @@ -97,36 +97,35 @@ doctest: ########################################################################## # calling Clang with all warnings, except: +# -Wno-c++2a-compat: u8 literals will behave differently in C++20... +# -Wno-deprecated-declarations: the library deprecated some functions # -Wno-documentation-unknown-command: code uses user-defined commands like @complexity # -Wno-exit-time-destructors: warning in Catch code -# -Wno-keyword-macro: unit-tests use "#define private public" -# -Wno-deprecated-declarations: the library deprecated some functions -# -Wno-weak-vtables: exception class is defined inline, but has virtual method -# -Wno-range-loop-analysis: items tests "for(const auto i...)" # -Wno-float-equal: not all comparisons in the tests can be replaced by Approx -# -Wno-switch-enum -Wno-covered-switch-default: pedantic/contradicting warnings about switches -# -Wno-c++2a-compat: u8 literals will behave differently in C++20... +# -Wno-keyword-macro: unit-tests use "#define private public" # -Wno-padded: padding is nothing to warn about +# -Wno-range-loop-analysis: items tests "for(const auto i...)" +# -Wno-switch-enum -Wno-covered-switch-default: pedantic/contradicting warnings about switches +# -Wno-weak-vtables: exception class is defined inline, but has virtual method pedantic_clang: $(MAKE) json_unit CXX=$(COMPILER_DIR)/clang++ CXXFLAGS=" \ -std=c++11 -Wno-c++98-compat -Wno-c++98-compat-pedantic \ -Werror \ -Weverything \ + -Wno-c++2a-compat \ + -Wno-deprecated-declarations \ -Wno-documentation-unknown-command \ -Wno-exit-time-destructors \ - -Wno-keyword-macro \ - -Wno-deprecated-declarations \ - -Wno-weak-vtables \ - -Wno-range-loop-analysis \ -Wno-float-equal \ + -Wno-keyword-macro \ + -Wno-padded \ + -Wno-range-loop-analysis \ -Wno-switch-enum -Wno-covered-switch-default \ - -Wno-c++2a-compat \ - -Wno-c++17-extensions \ - -Wno-padded" + -Wno-weak-vtables" # calling GCC with most warnings pedantic_gcc: - $(MAKE) json_unit CXX=$(COMPILER_DIR)/g++ CXXFLAGS=" \ + $(MAKE) json_unit CXX=$(COMPILER_DIR)/g++ CXXFLAGS="-D_Atomic=volatile \ -std=c++11 \ -Waddress \ -Waddress-of-packed-member \ From b21c04c93893bb8e277eaff9d54cfe28bc6ca131 Mon Sep 17 00:00:00 2001 From: Niels Lohmann Date: Fri, 29 Mar 2019 17:34:58 +0100 Subject: [PATCH 043/106] :fire: removed unsupported flag --- test/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 496c154e..74df7522 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -6,7 +6,7 @@ option(JSON_Coverage "Build test suite with coverage information" OFF) if(JSON_Sanitizer) message(STATUS "Building test suite with Clang sanitizer") if(NOT MSVC) - set(CMAKE_CXX_FLAGS "-g -O2 -fsanitize=address -fsanitize=undefined -fsanitize=implicit-conversion -fsanitize=integer -fsanitize=nullability -fno-omit-frame-pointer") + set(CMAKE_CXX_FLAGS "-g -O2 -fsanitize=address -fsanitize=undefined -fsanitize=integer -fsanitize=nullability -fno-omit-frame-pointer") endif() endif() From b12287b36292f1895f0ded7477b397552f155776 Mon Sep 17 00:00:00 2001 From: Niels Lohmann Date: Sat, 30 Mar 2019 09:12:32 +0100 Subject: [PATCH 044/106] :alembic: trying fastcov --- Makefile | 10 +- test/CMakeLists.txt | 11 ++ test/thirdparty/fastcov/LICENSE | 21 +++ test/thirdparty/fastcov/README.md | 46 +++++ test/thirdparty/fastcov/fastcov.py | 189 +++++++++++++++++++ test/thirdparty/fastcov/fastcov_legacy.py | 218 ++++++++++++++++++++++ 6 files changed, 494 insertions(+), 1 deletion(-) create mode 100644 test/thirdparty/fastcov/LICENSE create mode 100644 test/thirdparty/fastcov/README.md create mode 100755 test/thirdparty/fastcov/fastcov.py create mode 100755 test/thirdparty/fastcov/fastcov_legacy.py diff --git a/Makefile b/Makefile index ff509e39..ec1b9321 100644 --- a/Makefile +++ b/Makefile @@ -76,12 +76,20 @@ check-fast: coverage: rm -fr build_coverage mkdir build_coverage - cd build_coverage ; CXX=$(COMPILER_DIR)/g++ cmake .. -GNinja -DJSON_Coverage=ON -DJSON_MultipleHeaders=ON + cd build_coverage ; CXX=g++-7 cmake .. -GNinja -DJSON_Coverage=ON -DJSON_MultipleHeaders=ON cd build_coverage ; ninja cd build_coverage ; ctest -E '.*_default' -j10 cd build_coverage ; ninja lcov_html open build_coverage/test/html/index.html +fast-cov: + rm -fr build_coverage + mkdir build_coverage + cd build_coverage ; CXX=$(COMPILER_DIR)/g++ cmake .. -GNinja -DJSON_Coverage=ON -DJSON_MultipleHeaders=ON + cd build_coverage ; ninja + cd build_coverage ; ctest -E '.*_default' -j10 + cd build_coverage ; ninja lcov_html2 + open build_coverage/test/html/index.html ########################################################################## # documentation tests diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 74df7522..6be68a53 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -51,6 +51,17 @@ if(JSON_Coverage) COMMAND genhtml --title "JSON for Modern C++" --legend --demangle-cpp --output-directory html --show-details --branch-coverage json.info.filtered.noexcept COMMENT "Generating HTML report test/html/index.html" ) + + # add target to collect coverage information and generate HTML file + # (filter script from https://stackoverflow.com/a/43726240/266378) + add_custom_target(lcov_html2 + COMMAND ${CMAKE_SOURCE_DIR}/test/thirdparty/fastcov/fastcov.py --lcov -o json.info --gcov ${GCOV_BIN} + COMMAND gsed -i 's%build_coverage/%%g' json.info + COMMAND lcov -e json.info ${SOURCE_FILES} --output-file json.info.filtered --rc lcov_branch_coverage=1 + COMMAND ${CMAKE_SOURCE_DIR}/test/thirdparty/imapdl/filterbr.py json.info.filtered > json.info.filtered.noexcept + COMMAND genhtml --title "JSON for Modern C++" --legend --demangle-cpp --output-directory html --show-details --branch-coverage json.info.filtered.noexcept + COMMENT "Generating HTML report test/html/index.html" + ) endif() ############################################################################# diff --git a/test/thirdparty/fastcov/LICENSE b/test/thirdparty/fastcov/LICENSE new file mode 100644 index 00000000..cd26c490 --- /dev/null +++ b/test/thirdparty/fastcov/LICENSE @@ -0,0 +1,21 @@ +The MIT License + +Copyright (c) 2018-2019 Bryan Gillespie + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/test/thirdparty/fastcov/README.md b/test/thirdparty/fastcov/README.md new file mode 100644 index 00000000..9a2e3782 --- /dev/null +++ b/test/thirdparty/fastcov/README.md @@ -0,0 +1,46 @@ +# fastcov +A massively parallel gcov wrapper for generating intermediate coverage formats *fast* + +The goal of fastcov is to generate code coverage intermediate formats *as fast as possible* (ideally < 1 second), even for large projects with hundreds of gcda objects. The intermediate formats may then be consumed by a report generator such as lcov's genhtml, or a dedicated front end such as coveralls. fastcov was originally designed to be a drop-in replacement for lcov (application coverage only, not kernel coverage). + +Currently the only intermediate formats supported are gcov json format and lcov info format. Adding support for other formats should require just a few lines of python to transform gcov json format to the desired shape. + +In order to achieve the massive speed gains, a few constraints apply: + +1. GCC version >= 9.0.0 + +These versions of GCOV have support for JSON intermediate format as well as streaming report data straight to stdout + +2. Object files must be either be built: + +- Using absolute paths for all `-I` flags passed to the compiler +- Invoking the compiler from the same root directory + +If you use CMake, you are almost certainly satisfying the second constraint (unless you care about `ExternalProject` coverage). + +## Sample Usage: +```bash +$ cd build_dir +$ fastcov.py --zerocounters +$ +$ fastcov.py --exclude /usr/include --lcov -o report.info +$ genhtml -o code_coverage report.info +``` + +## Legacy fastcov + +It is possible to reap most of the benefits of fastcov for GCC version < 9.0.0 and >= 7.1.0. However, there will be a *potential* header file loss of correctness. + +`fastcov_legacy.py` can be used with pre GCC-9 down to GCC 7.1.0 but with a few penalties due to gcov limitations. This is because running gcov in parallel generates .gcov header reports in parallel which overwrite each other. This isn't a problem unless your header files have actual logic (i.e. header only library) that you want to measure coverage for. Use the `-F` flag to specify which gcda files should not be run in parallel in order to capture accurate header file data just for those. I don't plan on supporting `fastcov_legacy.py` aside from basic bug fixes. + +## Benchmarks + +Anecdotal testing on my own projects indicate that fastcov is over 100x faster than lcov and over 30x faster than gcovr: + +Project Size: ~250 .gcda, ~500 .gcov generated by gcov + +Time to process all gcda and parse all gcov: + +- fastcov: ~700ms +- lcov: ~90s +- gcovr: ~30s diff --git a/test/thirdparty/fastcov/fastcov.py b/test/thirdparty/fastcov/fastcov.py new file mode 100755 index 00000000..ee7fbe78 --- /dev/null +++ b/test/thirdparty/fastcov/fastcov.py @@ -0,0 +1,189 @@ +#!/usr/bin/env python3 +""" + Author: Bryan Gillespie + + A massively parallel gcov wrapper for generating intermediate coverage formats fast + + The goal of fastcov is to generate code coverage intermediate formats as fast as possible + (ideally < 1 second), even for large projects with hundreds of gcda objects. The intermediate + formats may then be consumed by a report generator such as lcov's genhtml, or a dedicated front + end such as coveralls. + + Sample Usage: + $ cd build_dir + $ ./fastcov.py --zerocounters + $ + $ ./fastcov.py --exclude-gcov /usr/include --lcov -o report.info + $ genhtml -o code_coverage report.info +""" + +import re +import os +import sys +import glob +import json +import argparse +import threading +import subprocess +import multiprocessing + +MINIMUM_GCOV = (9,0,0) +MINIMUM_CHUNK_SIZE = 10 + +# Interesting metrics +GCOVS_TOTAL = [] +GCOVS_SKIPPED = [] + +def chunks(l, n): + """Yield successive n-sized chunks from l.""" + for i in range(0, len(l), n): + yield l[i:i + n] + +def getGcovVersion(gcov): + p = subprocess.Popen([gcov, "-v"], stdout=subprocess.PIPE) + output = p.communicate()[0].decode('UTF-8') + p.wait() + version_str = re.search(r'\s([\d.]+)\s', output.split("\n")[0]).group(1) + version = tuple(map(int, version_str.split("."))) + return version + +def removeFiles(files): + for file in files: + os.remove(file) + +def getFilteredGcdaFiles(gcda_files, exclude): + def excludeGcda(gcda): + for ex in exclude: + if ex in gcda: + return False + return True + return list(filter(excludeGcda, gcda_files)) + +def getGcdaFiles(cwd, gcda_files): + if not gcda_files: + gcda_files = glob.glob(os.path.join(cwd, "**/*.gcda"), recursive=True) + return gcda_files + +def gcovWorker(cwd, gcov, files, chunk, exclude): + p = subprocess.Popen([gcov, "-it"] + chunk, cwd=cwd, stdout=subprocess.PIPE, stderr=subprocess.DEVNULL) + for line in iter(p.stdout.readline, b''): + intermediate_json = json.loads(line.decode(sys.stdout.encoding)) + intermediate_json_files = processGcovs(intermediate_json["files"], exclude) + for f in intermediate_json_files: + files.append(f) #thread safe, there might be a better way to do this though + GCOVS_TOTAL.append(len(intermediate_json["files"])) + GCOVS_SKIPPED.append(len(intermediate_json["files"])-len(intermediate_json_files)) + p.wait() + +def processGcdas(cwd, gcov, jobs, gcda_files, exclude): + chunk_size = max(MINIMUM_CHUNK_SIZE, int(len(gcda_files) / jobs) + 1) + + threads = [] + intermediate_json_files = [] + for chunk in chunks(gcda_files, chunk_size): + t = threading.Thread(target=gcovWorker, args=(cwd, gcov, intermediate_json_files, chunk, exclude)) + threads.append(t) + t.start() + + log("Spawned %d gcov processes each processing at most %d gcda files" % (len(threads), chunk_size)) + for t in threads: + t.join() + + return intermediate_json_files + +def processGcov(gcov, files, exclude): + for ex in exclude: + if ex in gcov["file"]: + return + files.append(gcov) + +def processGcovs(gcov_files, exclude): + files = [] + for gcov in gcov_files: + processGcov(gcov, files, exclude) + return files + +def dumpToLcovInfo(cwd, intermediate, output): + with open(output, "w") as f: + for file in intermediate: + #Convert to absolute path so it plays nice with genhtml + sf = file["file"] + if not os.path.isabs(file["file"]): + sf = os.path.abspath(os.path.join(cwd, file["file"])) + f.write("SF:%s\n" % sf) + fn_miss = 0 + for function in file["functions"]: + f.write("FN:%s,%s\n" % (function["start_line"], function["name"])) + f.write("FNDA:%s,%s\n" % (function["execution_count"], function["name"])) + fn_miss += int(not function["execution_count"] == 0) + f.write("FNF:%s\n" % len(file["functions"])) + f.write("FNH:%s\n" % (len(file["functions"]) - fn_miss)) + line_miss = 0 + for line in file["lines"]: + f.write("DA:%s,%s\n" % (line["line_number"], line["count"])) + line_miss += int(not line["count"] == 0) + f.write("LF:%s\n" % len(file["lines"])) + f.write("LH:%s\n" % (len(file["lines"]) - line_miss)) + f.write("end_of_record\n") + +def dumpToGcovJson(intermediate, output): + with open(output, "w") as f: + json.dump(intermediate, f) + +def log(line): + if not args.quiet: + print(line) + +def main(args): + # Need at least gcov 9.0.0 because that's when gcov JSON and stdout streaming was introduced + current_gcov_version = getGcovVersion(args.gcov) + if current_gcov_version < MINIMUM_GCOV: + sys.stderr.write("Minimum gcov version {} required, found {}\n".format(".".join(map(str, MINIMUM_GCOV)), ".".join(map(str, current_gcov_version)))) + exit(1) + + gcda_files = getGcdaFiles(args.directory, args.gcda_files) + log("%d .gcda files" % len(gcda_files)) + + if args.excludepre: + gcda_files = getFilteredGcdaFiles(gcda_files, args.excludepre) + log("%d .gcda files after filtering" % len(gcda_files)) + + # We "zero" the "counters" by simply deleting all gcda files + if args.zerocounters: + removeFiles(gcda_files) + log("%d .gcda files removed" % len(gcda_files)) + return + + intermediate_json_files = processGcdas(args.cdirectory, args.gcov, args.jobs, gcda_files, args.excludepost) + + gcov_total = sum(GCOVS_TOTAL) + gcov_skipped = sum(GCOVS_SKIPPED) + log("%d .gcov files generated by gcov" % gcov_total) + log("%d .gcov files processed by fastcov (%d skipped)" % (gcov_total - gcov_skipped, gcov_skipped)) + + if args.lcov: + dumpToLcovInfo(args.cdirectory, intermediate_json_files, args.output) + log("Created lcov info file '%s'" % args.output) + else: + dumpToGcovJson(intermediate_json_files, args.output) + log("Created gcov json file '%s'" % args.output) + +if __name__ == '__main__': + parser = argparse.ArgumentParser(description='A parallel gcov wrapper for fast coverage report generation') + parser.add_argument('-z', '--zerocounters', dest='zerocounters', action="store_true", help='Recursively delete all gcda files') + + parser.add_argument('-f', '--gcda-files', dest='gcda_files', nargs="+", default=[], help='Specify exactly which gcda files should be processed instead of recursivly searching the search directory.') + parser.add_argument('-E', '--exclude-gcda', dest='excludepre', nargs="+", default=[], help='.gcda filter - Exclude gcda files from being processed via simple find matching (not regex)') + parser.add_argument('-e', '--exclude-gcov', dest='excludepost', nargs="+", default=[], help='.gcov filter - Exclude gcov files from being processed via simple find matching (not regex)') + + parser.add_argument('-g', '--gcov', dest='gcov', default='gcov', help='which gcov binary to use') + + parser.add_argument('-d', '--search-directory', dest='directory', default=".", help='Base directory to recursively search for gcda files (default: .)') + parser.add_argument('-c', '--compiler-directory', dest='cdirectory', default=".", help='Base directory compiler was invoked from (default: .)') + parser.add_argument('-j', '--jobs', dest='jobs', type=int, default=multiprocessing.cpu_count(), help='Number of parallel gcov to spawn (default: %d).' % multiprocessing.cpu_count()) + + parser.add_argument('-o', '--output', dest='output', default="coverage.json", help='Name of output file (default: coverage.json)') + parser.add_argument('-i', '--lcov', dest='lcov', action="store_true", help='Output in lcov info format instead of gcov json') + parser.add_argument('-q', '--quiet', dest='quiet', action="store_true", help='Suppress output to stdout') + args = parser.parse_args() + main(args) \ No newline at end of file diff --git a/test/thirdparty/fastcov/fastcov_legacy.py b/test/thirdparty/fastcov/fastcov_legacy.py new file mode 100755 index 00000000..3e0151ab --- /dev/null +++ b/test/thirdparty/fastcov/fastcov_legacy.py @@ -0,0 +1,218 @@ +#!/usr/bin/env python3 +""" + Author: Bryan Gillespie + + Legacy version... supports versions 7.1.0 <= GCC < 9.0.0 + + A massively parallel gcov wrapper for generating intermediate coverage formats fast + + The goal of fastcov is to generate code coverage intermediate formats as fast as possible + (ideally < 1 second), even for large projects with hundreds of gcda objects. The intermediate + formats may then be consumed by a report generator such as lcov's genhtml, or a dedicated front + end such as coveralls. + + Sample Usage: + $ cd build_dir + $ ./fastcov.py --exclude-gcov /usr/include --lcov -o report.info + $ genhtml -o code_coverage report.info +""" + +import re +import os +import glob +import json +import argparse +import subprocess +import multiprocessing +from random import shuffle + +MINIMUM_GCOV = (7,1,0) +MINIMUM_CHUNK_SIZE = 10 + +def chunks(l, n): + """Yield successive n-sized chunks from l.""" + for i in range(0, len(l), n): + yield l[i:i + n] + +def getGcovVersion(gcov): + p = subprocess.Popen([gcov, "-v"], stdout=subprocess.PIPE) + output = p.communicate()[0].decode('UTF-8') + p.wait() + version_str = re.search(r'\s([\d.]+)\s', output.split("\n")[0]).group(1) + version = tuple(map(int, version_str.split("."))) + return version + +def removeFiles(files): + for file in files: + os.remove(file) + +def getFilteredGcdaFiles(gcda_files, exclude): + def excludeGcda(gcda): + for ex in exclude: + if ex in gcda: + return False + return True + return list(filter(excludeGcda, gcda_files)) + +def getGcdaFiles(cwd, gcda_files, exclude): + if not gcda_files: + gcda_files = glob.glob(os.path.join(cwd, "**/*.gcda"), recursive=True) + if exclude: + return getFilteredGcdaFiles(gcda_files, exclude) + return gcda_files + +def getGcovFiles(cwd): + return glob.glob(os.path.join(cwd, "*.gcov")) + +def filterGcovFiles(gcov): + with open(gcov) as f: + path = f.readline()[5:] + for ex in args.exclude: + if ex in path: + return False + return True + +def processGcdasPre9(cwd, gcov, jobs, gcda_files): + chunk_size = min(MINIMUM_CHUNK_SIZE, int(len(gcda_files) / jobs) + 1) + + processes = [] + # shuffle(gcda_files) # improves performance by preventing any one gcov from bottlenecking on a list of sequential, expensive gcdas (?) + for chunk in chunks(gcda_files, chunk_size): + processes.append(subprocess.Popen([gcov, "-i"] + chunk, cwd=cwd, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)) + + for p in processes: + p.wait() + +def processGcdasPre9Accurate(cwd, gcov, gcda_files, exclude): + intermediate_json_files = [] + for gcda in gcda_files: + subprocess.Popen([gcov, "-i", gcda], cwd=cwd, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL).wait() + gcov_files = getGcovFiles(cwd) + intermediate_json_files += processGcovs(gcov_files, exclude) + removeFiles(gcov_files) + return intermediate_json_files + +def processGcovLine(file, line): + line_type, data = line.split(":", 1) + if line_type == "lcount": + num, count = data.split(",") + hit = (count != 0) + file["lines_hit"] += int(hit) + file["lines"].append({ + "branches": [], + "line_number": num, + "count": count, + "unexecuted_block": not hit + }) + elif line_type == "function": + num, count, name = data.split(",") + hit = (count != 0) + file["functions_hit"] += int(hit) + file["functions"].append({ + "name": name, + "execution_count": count, + "start_line": num, + "end_line": None, + "blocks": None, + "blocks_executed": None, + "demangled_name": None + }) + +def processGcov(files, gcov, exclude): + with open(gcov) as f: + path = f.readline()[5:].rstrip() + for ex in exclude: + if ex in path: + return False + file = { + "file": path, + "functions": [], + "functions_hit": 0, + "lines": [], + "lines_hit": 0 + } + for line in f: + processGcovLine(file, line.rstrip()) + files.append(file) + return True + +def processGcovs(gcov_files, exclude): + files = [] + filtered = 0 + for gcov in gcov_files: + filtered += int(not processGcov(files, gcov, exclude)) + print("Skipped %d .gcov files" % filtered) + return files + +def dumpToLcovInfo(intermediate, output): + with open(output, "w") as f: + for file in intermediate: + f.write("SF:%s\n" % file["file"]) + for function in file["functions"]: + f.write("FN:%s,%s\n" % (function["start_line"], function["name"])) + f.write("FNDA:%s,%s\n" % (function["execution_count"], function["name"])) + f.write("FNF:%s\n" % len(file["functions"])) + f.write("FNH:%s\n" % file["functions_hit"]) + for line in file["lines"]: + f.write("DA:%s,%s\n" % (line["line_number"], line["count"])) + f.write("LF:%s\n" % len(file["lines"])) + f.write("LH:%s\n" % file["lines_hit"]) + f.write("end_of_record\n") + +def dumpToGcovJson(intermediate, output): + with open(output, "w") as f: + json.dump(intermediate, f) + +def main(args): + # Need at least gcov 7.1.0 because of bug not allowing -i in conjunction with multiple files + # See: https://github.com/gcc-mirror/gcc/commit/41da7513d5aaaff3a5651b40edeccc1e32ea785a + current_gcov_version = getGcovVersion(args.gcov) + if current_gcov_version < MINIMUM_GCOV: + print("Minimum gcov version {} required, found {}".format(".".join(map(str, MINIMUM_GCOV)), ".".join(map(str, current_gcov_version)))) + exit(1) + + gcda_files = getGcdaFiles(args.directory, args.gcda_files, args.excludepre) + print("Found %d .gcda files" % len(gcda_files)) + + # We "zero" the "counters" by simply deleting all gcda files + if args.zerocounters: + removeFiles(gcda_files) + print("Removed %d .gcda files" % len(gcda_files)) + return + + # If we are less than gcov 9.0.0, convert .gcov files to GCOV 9 JSON format + processGcdasPre9(args.cdirectory, args.gcov, args.jobs, gcda_files) + gcov_files = getGcovFiles(args.cdirectory) + + print("Found %d .gcov files" % len(gcov_files)) + + intermediate_json_files = processGcovs(gcov_files, args.excludepost) + removeFiles(gcov_files) + + intermediate_json_files += processGcdasPre9Accurate(args.cdirectory, args.gcov, args.gcda_files_accurate, args.excludepost) + + if args.lcov: + dumpToLcovInfo(intermediate_json_files, args.output) + else: + dumpToGcovJson(intermediate_json_files, args.output) + +if __name__ == '__main__': + parser = argparse.ArgumentParser(description='A parallel gcov wrapper for fast coverage report generation') + parser.add_argument('-z', '--zerocounters', dest='zerocounters', action="store_true", help='Recursively delete all gcda files') + + parser.add_argument('-f', '--gcda-files', dest='gcda_files', nargs="+", default=[], help='Specify exactly which gcda files should be processed instead of recursivly searching the search directory.') + parser.add_argument('-F', '--gcda-files-accurate', dest='gcda_files_accurate', nargs="+", default=[], help='(< gcov 9.0.0) Get accurate header coverage information for just these. These files cannot be processed in parallel') + parser.add_argument('-E', '--exclude-gcda', dest='excludepre', nargs="+", default=[], help='.gcda filter - Exclude gcda files from being processed via simple find matching (not regex)') + parser.add_argument('-e', '--exclude-gcov', dest='excludepost', nargs="+", default=[], help='.gcov filter - Exclude gcov files from being processed via simple find matching (not regex)') + + parser.add_argument('-g', '--gcov', dest='gcov', default='gcov', help='which gcov binary to use') + + parser.add_argument('-d', '--search-directory', dest='directory', default=".", help='Base directory to recursively search for gcda files (default: .)') + parser.add_argument('-c', '--compiler-directory', dest='cdirectory', default=".", help='Base directory compiler was invoked from (default: .)') + parser.add_argument('-j', '--jobs', dest='jobs', type=int, default=multiprocessing.cpu_count(), help='Number of parallel gcov to spawn (default: %d).' % multiprocessing.cpu_count()) + + + parser.add_argument('-o', '--output', dest='output', default="coverage.json", help='Name of output file (default: coverage.json)') + parser.add_argument('-i', '--lcov', dest='lcov', action="store_true", help='Output in lcov info format instead of gcov json') + args = parser.parse_args() + main(args) \ No newline at end of file From 53001414c7b6e84a971774aee479d955e85c73bb Mon Sep 17 00:00:00 2001 From: Niels Lohmann Date: Sat, 30 Mar 2019 17:00:30 +0100 Subject: [PATCH 045/106] :hammer: using --exclude-gcov to exclude files --- test/CMakeLists.txt | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 6be68a53..52196ca1 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -55,10 +55,9 @@ if(JSON_Coverage) # add target to collect coverage information and generate HTML file # (filter script from https://stackoverflow.com/a/43726240/266378) add_custom_target(lcov_html2 - COMMAND ${CMAKE_SOURCE_DIR}/test/thirdparty/fastcov/fastcov.py --lcov -o json.info --gcov ${GCOV_BIN} + COMMAND ${CMAKE_SOURCE_DIR}/test/thirdparty/fastcov/fastcov.py --lcov -o json.info --gcov ${GCOV_BIN} --exclude-gcov /usr 9.0.1/ test/ COMMAND gsed -i 's%build_coverage/%%g' json.info - COMMAND lcov -e json.info ${SOURCE_FILES} --output-file json.info.filtered --rc lcov_branch_coverage=1 - COMMAND ${CMAKE_SOURCE_DIR}/test/thirdparty/imapdl/filterbr.py json.info.filtered > json.info.filtered.noexcept + COMMAND ${CMAKE_SOURCE_DIR}/test/thirdparty/imapdl/filterbr.py json.info > json.info.filtered.noexcept COMMAND genhtml --title "JSON for Modern C++" --legend --demangle-cpp --output-directory html --show-details --branch-coverage json.info.filtered.noexcept COMMENT "Generating HTML report test/html/index.html" ) From ecf4d5e91d09f988a294c85f55e5520ca71f1062 Mon Sep 17 00:00:00 2001 From: Niels Lohmann Date: Sat, 30 Mar 2019 17:05:43 +0100 Subject: [PATCH 046/106] :construction_worker: trying CircleCI --- .circleci/config.yml | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 .circleci/config.yml diff --git a/.circleci/config.yml b/.circleci/config.yml new file mode 100644 index 00000000..d1d8ddec --- /dev/null +++ b/.circleci/config.yml @@ -0,0 +1,16 @@ +version: 2 +jobs: + build: + docker: + - image: debian:stretch + + steps: + - checkout + + - run: + name: Greeting + command: echo Hello, world. + + - run: + name: Print the Current Time + command: date From 5ebe7220456b9caba131a8b4e89d4bad80eebf3b Mon Sep 17 00:00:00 2001 From: Niels Lohmann Date: Sat, 30 Mar 2019 17:14:50 +0100 Subject: [PATCH 047/106] :construction_worker: full workflow --- .circleci/config.yml | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index d1d8ddec..40571d62 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -8,9 +8,20 @@ jobs: - checkout - run: - name: Greeting - command: echo Hello, world. - + name: Install sudo + command: 'apt-get update && apt-get install -y sudo && rm -rf /var/lib/apt/lists/*' - run: - name: Print the Current Time - command: date + name: Install GCC + command: 'apt-get update && apt-get install -y gcc g++' + - run: + name: Install CMake + command: 'apt-get update && sudo apt-get install -y cmake' + - run: + name: Create build files + command: 'cmake -Bbuild' + - run: + name: Compile + command: 'cmake --build build' + - run: + name: Execute test suite + command: 'cd build ; ctest' From a5e00f2cf7bbc3cace67d3e3414940b7045541dd Mon Sep 17 00:00:00 2001 From: Niels Lohmann Date: Sat, 30 Mar 2019 17:19:27 +0100 Subject: [PATCH 048/106] :construction_worker: fixed path --- .circleci/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 40571d62..528e25a8 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -18,7 +18,7 @@ jobs: command: 'apt-get update && sudo apt-get install -y cmake' - run: name: Create build files - command: 'cmake -Bbuild' + command: 'mkdir build ; cd build ; cmake ..' - run: name: Compile command: 'cmake --build build' From 0a57c51a699df917207399c4e236fba9eb7114c4 Mon Sep 17 00:00:00 2001 From: Niels Lohmann Date: Sat, 30 Mar 2019 17:32:52 +0100 Subject: [PATCH 049/106] :construction_worker: adding concurrency --- .circleci/config.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 528e25a8..f164c28d 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -14,14 +14,14 @@ jobs: name: Install GCC command: 'apt-get update && apt-get install -y gcc g++' - run: - name: Install CMake - command: 'apt-get update && sudo apt-get install -y cmake' + name: Install CMake and Ninja + command: 'apt-get update && sudo apt-get install -y cmake ninja-build' - run: name: Create build files - command: 'mkdir build ; cd build ; cmake ..' + command: 'mkdir build ; cd build ; cmake .. -GNinja' - run: name: Compile command: 'cmake --build build' - run: name: Execute test suite - command: 'cd build ; ctest' + command: 'cd build ; ctest -j 10' From 80daa193317acf6757f46cd6b6cf0bb56badda84 Mon Sep 17 00:00:00 2001 From: Niels Lohmann Date: Sat, 30 Mar 2019 17:39:50 +0100 Subject: [PATCH 050/106] :construction_worker: Ninja seems not to work --- .circleci/config.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index f164c28d..0d2edbf6 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -14,14 +14,14 @@ jobs: name: Install GCC command: 'apt-get update && apt-get install -y gcc g++' - run: - name: Install CMake and Ninja - command: 'apt-get update && sudo apt-get install -y cmake ninja-build' + name: Install CMake + command: 'apt-get update && sudo apt-get install -y cmake' - run: name: Create build files - command: 'mkdir build ; cd build ; cmake .. -GNinja' + command: 'mkdir build ; cd build ; cmake ..' - run: name: Compile command: 'cmake --build build' - run: name: Execute test suite - command: 'cd build ; ctest -j 10' + command: 'cd build ; ctest -j 2' From da5b7833a0d934a779d84c097a2576bf7bd9d44a Mon Sep 17 00:00:00 2001 From: onqtam Date: Sun, 31 Mar 2019 13:57:44 +0300 Subject: [PATCH 051/106] fixing the remaining of the pedantic gcc/clang target warnings --- test/src/unit-cbor.cpp | 5 +-- test/src/unit-constructor1.cpp | 3 +- test/src/unit-conversions.cpp | 1 - test/src/unit-readme.cpp | 3 +- test/src/unit-reference_access.cpp | 3 +- test/src/unit-regression.cpp | 8 +--- test/thirdparty/doctest/doctest.h | 42 +++++++++++++------ .../doctest/doctest_compatibility.h | 24 +---------- 8 files changed, 36 insertions(+), 53 deletions(-) diff --git a/test/src/unit-cbor.cpp b/test/src/unit-cbor.cpp index 3d7be8c1..43073bd0 100644 --- a/test/src/unit-cbor.cpp +++ b/test/src/unit-cbor.cpp @@ -28,6 +28,7 @@ SOFTWARE. */ #include "doctest_compatibility.h" +DOCTEST_GCC_SUPPRESS_WARNING("-Wfloat-equal") #include using nlohmann::json; @@ -876,9 +877,7 @@ TEST_CASE("CBOR") { json j = json::from_cbor(std::vector({0xf9, 0x7c, 0x00})); json::number_float_t d = j; - DOCTEST_GCC_SUPPRESS_WARNING_WITH_PUSH("-Wfloat-equal") CHECK(d == std::numeric_limits::infinity()); - DOCTEST_GCC_SUPPRESS_WARNING_POP CHECK(j.dump() == "null"); } @@ -897,9 +896,7 @@ TEST_CASE("CBOR") { json j = json::from_cbor(std::vector({0xf9, 0x3c, 0x00})); json::number_float_t d = j; - DOCTEST_GCC_SUPPRESS_WARNING_WITH_PUSH("-Wfloat-equal") CHECK(d == 1); - DOCTEST_GCC_SUPPRESS_WARNING_POP } SECTION("-2 (1 10000 0000000000)") diff --git a/test/src/unit-constructor1.cpp b/test/src/unit-constructor1.cpp index 115df7b7..f7b6c775 100644 --- a/test/src/unit-constructor1.cpp +++ b/test/src/unit-constructor1.cpp @@ -28,6 +28,7 @@ SOFTWARE. */ #include "doctest_compatibility.h" +DOCTEST_GCC_SUPPRESS_WARNING("-Wfloat-equal") #define private public #include @@ -351,9 +352,7 @@ TEST_CASE("constructors") CHECK(jva.size() == va.size()); for (size_t i = 0; i < jva.size(); ++i) { - DOCTEST_GCC_SUPPRESS_WARNING_WITH_PUSH("-Wfloat-equal") CHECK(va[i] == jva[i]); - DOCTEST_GCC_SUPPRESS_WARNING_POP } } diff --git a/test/src/unit-conversions.cpp b/test/src/unit-conversions.cpp index 53ac1200..1476b6e6 100644 --- a/test/src/unit-conversions.cpp +++ b/test/src/unit-conversions.cpp @@ -28,7 +28,6 @@ SOFTWARE. */ #include "doctest_compatibility.h" -DOCTEST_GCC_SUPPRESS_WARNING_WITH_PUSH("-Wsign-promo") #define private public #include diff --git a/test/src/unit-readme.cpp b/test/src/unit-readme.cpp index 8a64d680..4af68449 100644 --- a/test/src/unit-readme.cpp +++ b/test/src/unit-readme.cpp @@ -28,6 +28,7 @@ SOFTWARE. */ #include "doctest_compatibility.h" +DOCTEST_GCC_SUPPRESS_WARNING("-Wfloat-equal") #include using nlohmann::json; @@ -269,9 +270,7 @@ TEST_CASE("README" * doctest::skip()) int i = 42; json jn = i; double f = jn; - DOCTEST_GCC_SUPPRESS_WARNING_WITH_PUSH("-Wfloat-equal") CHECK(f == 42); - DOCTEST_GCC_SUPPRESS_WARNING_POP // etc. diff --git a/test/src/unit-reference_access.cpp b/test/src/unit-reference_access.cpp index f0c64422..a9a0f6e5 100644 --- a/test/src/unit-reference_access.cpp +++ b/test/src/unit-reference_access.cpp @@ -28,6 +28,7 @@ SOFTWARE. */ #include "doctest_compatibility.h" +DOCTEST_GCC_SUPPRESS_WARNING("-Wfloat-equal") #include using nlohmann::json; @@ -287,9 +288,7 @@ TEST_CASE("reference access") // check if references are returned correctly test_type& p1 = value.get_ref(); CHECK(&p1 == value.get_ptr()); - DOCTEST_GCC_SUPPRESS_WARNING_WITH_PUSH("-Wfloat-equal") CHECK(p1 == value.get()); - DOCTEST_GCC_SUPPRESS_WARNING_POP const test_type& p2 = value.get_ref(); CHECK(&p2 == value.get_ptr()); diff --git a/test/src/unit-regression.cpp b/test/src/unit-regression.cpp index bb3cc756..6b7d90aa 100644 --- a/test/src/unit-regression.cpp +++ b/test/src/unit-regression.cpp @@ -28,7 +28,7 @@ SOFTWARE. */ #include "doctest_compatibility.h" -DOCTEST_GCC_SUPPRESS_WARNING_WITH_PUSH("-Wsign-promo") +DOCTEST_GCC_SUPPRESS_WARNING("-Wfloat-equal") // for some reason including this after the json header leads to linker errors with VS 2017... #include @@ -315,9 +315,7 @@ TEST_CASE("regression tests") // unsigned integer parsing - expected to overflow and be stored as a float j = custom_json::parse("4294967296"); // 2^32 CHECK(static_cast(j.type()) == static_cast(custom_json::value_t::number_float)); - DOCTEST_GCC_SUPPRESS_WARNING_WITH_PUSH("-Wfloat-equal") CHECK(j.get() == 4294967296.0f); - DOCTEST_GCC_SUPPRESS_WARNING_POP // integer object creation - expected to wrap and still be stored as an integer j = -2147483649LL; // -2^31-1 @@ -482,9 +480,7 @@ TEST_CASE("regression tests") json j; j = json::parse("-0.0"); - DOCTEST_GCC_SUPPRESS_WARNING_WITH_PUSH("-Wfloat-equal") CHECK(j.get() == -0.0); - DOCTEST_GCC_SUPPRESS_WARNING_POP j = json::parse("2.22507385850720113605740979670913197593481954635164564e-308"); CHECK(j.get() == 2.2250738585072009e-308); @@ -522,9 +518,7 @@ TEST_CASE("regression tests") // long double nlohmann::basic_json j_long_double = 1.23e45L; - DOCTEST_GCC_SUPPRESS_WARNING_WITH_PUSH("-Wfloat-equal") CHECK(j_long_double.get() == 1.23e45L); - DOCTEST_GCC_SUPPRESS_WARNING_POP } SECTION("issue #228 - double values are serialized with commas as decimal points") diff --git a/test/thirdparty/doctest/doctest.h b/test/thirdparty/doctest/doctest.h index 4a2c90fa..dbbcd3f5 100644 --- a/test/thirdparty/doctest/doctest.h +++ b/test/thirdparty/doctest/doctest.h @@ -161,6 +161,7 @@ DOCTEST_GCC_SUPPRESS_WARNING("-Winline") DOCTEST_GCC_SUPPRESS_WARNING("-Wunused-local-typedefs") DOCTEST_GCC_SUPPRESS_WARNING("-Wuseless-cast") DOCTEST_GCC_SUPPRESS_WARNING("-Wnoexcept") +DOCTEST_GCC_SUPPRESS_WARNING("-Wsign-promo") DOCTEST_MSVC_SUPPRESS_WARNING_PUSH DOCTEST_MSVC_SUPPRESS_WARNING(4616) // invalid compiler warning @@ -994,6 +995,10 @@ namespace detail { }; DOCTEST_INTERFACE bool checkIfShouldThrow(assertType::Enum at); + +#ifndef DOCTEST_CONFIG_NO_EXCEPTIONS + [[noreturn]] +#endif // DOCTEST_CONFIG_NO_EXCEPTIONS DOCTEST_INTERFACE void throwException(); struct DOCTEST_INTERFACE Subcase @@ -1598,7 +1603,7 @@ namespace detail { DOCTEST_DELETE_COPIES(ContextScope); - ~ContextScope(); + ~ContextScope() override; void stringify(std::ostream* s) const override; }; @@ -1839,6 +1844,15 @@ int registerReporter(const char* name, int priority) { } catch(...) { _DOCTEST_RB.translateException(); } #endif // DOCTEST_CONFIG_NO_TRY_CATCH_IN_ASSERTS +#ifdef DOCTEST_CONFIG_VOID_CAST_EXPRESSIONS +#define DOCTEST_CAST_TO_VOID(x) \ + DOCTEST_GCC_SUPPRESS_WARNING_WITH_PUSH("-Wuseless-cast") \ + static_cast(x); \ + DOCTEST_GCC_SUPPRESS_WARNING_POP +#else // DOCTEST_CONFIG_VOID_CAST_EXPRESSIONS +#define DOCTEST_CAST_TO_VOID(x) x; +#endif // DOCTEST_CONFIG_VOID_CAST_EXPRESSIONS + // registers the test by initializing a dummy var with a function #define DOCTEST_REGISTER_FUNCTION(global_prefix, f, decorators) \ global_prefix DOCTEST_GLOBAL_NO_WARNINGS(DOCTEST_ANONYMOUS(_DOCTEST_ANON_VAR_)) = \ @@ -2108,15 +2122,13 @@ constexpr T to_lvalue = x; #define DOCTEST_REQUIRE_FALSE_MESSAGE(cond, msg) do { DOCTEST_INFO(msg); DOCTEST_ASSERT_IMPLEMENT_2(DT_REQUIRE_FALSE, cond); } while((void)0, 0) // clang-format on -#define DOCTEST_ASSERT_THROWS(expr, assert_type) DOCTEST_ASSERT_THROWS_WITH(expr, assert_type, "") - #define DOCTEST_ASSERT_THROWS_AS(expr, assert_type, ...) \ do { \ if(!doctest::getContextOptions()->no_throw) { \ doctest::detail::ResultBuilder _DOCTEST_RB(doctest::assertType::assert_type, __FILE__, \ __LINE__, #expr, #__VA_ARGS__); \ try { \ - expr; \ + DOCTEST_CAST_TO_VOID(expr) \ } catch(const doctest::detail::remove_const< \ doctest::detail::remove_reference<__VA_ARGS__>::type>::type&) { \ _DOCTEST_RB.translateException(); \ @@ -2132,7 +2144,7 @@ constexpr T to_lvalue = x; doctest::detail::ResultBuilder _DOCTEST_RB(doctest::assertType::assert_type, __FILE__, \ __LINE__, #expr, __VA_ARGS__); \ try { \ - expr; \ + DOCTEST_CAST_TO_VOID(expr) \ } catch(...) { _DOCTEST_RB.translateException(); } \ DOCTEST_ASSERT_LOG_AND_REACT(_DOCTEST_RB); \ } \ @@ -2143,15 +2155,15 @@ constexpr T to_lvalue = x; doctest::detail::ResultBuilder _DOCTEST_RB(doctest::assertType::assert_type, __FILE__, \ __LINE__, #expr); \ try { \ - expr; \ + DOCTEST_CAST_TO_VOID(expr) \ } catch(...) { _DOCTEST_RB.translateException(); } \ DOCTEST_ASSERT_LOG_AND_REACT(_DOCTEST_RB); \ } while((void)0, 0) // clang-format off -#define DOCTEST_WARN_THROWS(expr) DOCTEST_ASSERT_THROWS(expr, DT_WARN_THROWS) -#define DOCTEST_CHECK_THROWS(expr) DOCTEST_ASSERT_THROWS(expr, DT_CHECK_THROWS) -#define DOCTEST_REQUIRE_THROWS(expr) DOCTEST_ASSERT_THROWS(expr, DT_REQUIRE_THROWS) +#define DOCTEST_WARN_THROWS(expr) DOCTEST_ASSERT_THROWS_WITH(expr, DT_WARN_THROWS, "") +#define DOCTEST_CHECK_THROWS(expr) DOCTEST_ASSERT_THROWS_WITH(expr, DT_CHECK_THROWS, "") +#define DOCTEST_REQUIRE_THROWS(expr) DOCTEST_ASSERT_THROWS_WITH(expr, DT_REQUIRE_THROWS, "") #define DOCTEST_WARN_THROWS_AS(expr, ...) DOCTEST_ASSERT_THROWS_AS(expr, DT_WARN_THROWS_AS, __VA_ARGS__) #define DOCTEST_CHECK_THROWS_AS(expr, ...) DOCTEST_ASSERT_THROWS_AS(expr, DT_CHECK_THROWS_AS, __VA_ARGS__) @@ -3504,11 +3516,11 @@ namespace detail { return false; } - void throwException() { #ifndef DOCTEST_CONFIG_NO_EXCEPTIONS - throw TestFailureException(); + [[noreturn]] void throwException() { throw TestFailureException(); } +#else // DOCTEST_CONFIG_NO_EXCEPTIONS + void throwException() {} #endif // DOCTEST_CONFIG_NO_EXCEPTIONS - } } // namespace detail namespace { @@ -4868,12 +4880,16 @@ namespace { } void test_case_exception(const TestCaseException& e) override { + std::lock_guard lock(mutex); + xml.scopedElement("Exception") .writeAttribute("crash", e.is_crash) .writeText(e.error_string.c_str()); } void subcase_start(const SubcaseSignature& in) override { + std::lock_guard lock(mutex); + xml.startElement("SubCase") .writeAttribute("name", in.m_name) .writeAttribute("filename", skipPathFromFilename(in.m_file)) @@ -5319,11 +5335,13 @@ namespace { } void subcase_start(const SubcaseSignature& subc) override { + std::lock_guard lock(mutex); subcasesStack.push_back(subc); hasLoggedCurrentTestStart = false; } void subcase_end() override { + std::lock_guard lock(mutex); subcasesStack.pop_back(); hasLoggedCurrentTestStart = false; } diff --git a/test/thirdparty/doctest/doctest_compatibility.h b/test/thirdparty/doctest/doctest_compatibility.h index b63b0b0a..6194e26b 100644 --- a/test/thirdparty/doctest/doctest_compatibility.h +++ b/test/thirdparty/doctest/doctest_compatibility.h @@ -1,6 +1,7 @@ #ifndef DOCTEST_COMPATIBILITY #define DOCTEST_COMPATIBILITY +#define DOCTEST_CONFIG_VOID_CAST_EXPRESSIONS #define DOCTEST_THREAD_LOCAL // enable single-threaded builds on XCode 6/7 - https://github.com/onqtam/doctest/issues/172 #include "doctest.h" @@ -25,29 +26,6 @@ #define CHECK_THROWS_WITH_STD_STR(expr, str) \ CHECK_THROWS_WITH_STD_STR_IMPL(expr, str, DOCTEST_ANONYMOUS(DOCTEST_STD_STRING_)) -#undef CHECK_THROWS -#undef CHECK_THROWS_AS -#undef CHECK_THROWS_WITH -#undef CHECK_NOTHROW - -#undef REQUIRE_THROWS -#undef REQUIRE_THROWS_AS -#undef REQUIRE_THROWS_WITH -#undef REQUIRE_NOTHROW - -// doctest allows multiple statements in these macros (even blocks of code) but json -// tests rely on passing single function/constructor calls which have a [[nodiscard]] -// attribute so here we static_cast to void - just like Catch does -#define CHECK_THROWS(expr) DOCTEST_CHECK_THROWS(static_cast(expr)) -#define CHECK_THROWS_AS(expr, e) DOCTEST_CHECK_THROWS_AS(static_cast(expr), e) -#define CHECK_THROWS_WITH(expr, e) DOCTEST_CHECK_THROWS_WITH(static_cast(expr), e) -#define CHECK_NOTHROW(expr) DOCTEST_CHECK_NOTHROW(static_cast(expr)) - -#define REQUIRE_THROWS(expr) DOCTEST_REQUIRE_THROWS(static_cast(expr)) -#define REQUIRE_THROWS_AS(expr, e) DOCTEST_REQUIRE_THROWS_AS(static_cast(expr), e) -#define REQUIRE_THROWS_WITH(expr, e) DOCTEST_REQUIRE_THROWS_WITH(static_cast(expr), e) -#define REQUIRE_NOTHROW(expr) DOCTEST_REQUIRE_NOTHROW(static_cast(expr)) - // included here because for some tests in the json repository private is defined as // public and if no STL header is included before that then in the json include when STL // stuff is included the MSVC STL complains (errors) that C++ keywords are being redefined From 2806b201a85d418d6b1aa3f4af25f198495e0744 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Th=C3=A9o=20DELRIEU?= Date: Mon, 1 Apr 2019 13:09:38 +0200 Subject: [PATCH 052/106] make sure values are overwritten in from_json overloads Caused unexpected behaviors when using get_to with values previously set. Fixes !1511 --- .../nlohmann/detail/conversions/from_json.hpp | 17 ++- include/nlohmann/detail/meta/type_traits.hpp | 41 ++++-- single_include/nlohmann/json.hpp | 58 +++++--- test/src/unit-conversions.cpp | 131 +++++++++++++++++- 4 files changed, 206 insertions(+), 41 deletions(-) diff --git a/include/nlohmann/detail/conversions/from_json.hpp b/include/nlohmann/detail/conversions/from_json.hpp index 8f8162ff..bb049aa8 100644 --- a/include/nlohmann/detail/conversions/from_json.hpp +++ b/include/nlohmann/detail/conversions/from_json.hpp @@ -136,6 +136,7 @@ void from_json(const BasicJsonType& j, std::forward_list& l) { JSON_THROW(type_error::create(302, "type must be array, but is " + std::string(j.type_name()))); } + l.clear(); std::transform(j.rbegin(), j.rend(), std::front_inserter(l), [](const BasicJsonType & i) { @@ -182,14 +183,16 @@ auto from_json_array_impl(const BasicJsonType& j, ConstructibleArrayType& arr, p { using std::end; - arr.reserve(j.size()); + ConstructibleArrayType ret; + ret.reserve(j.size()); std::transform(j.begin(), j.end(), - std::inserter(arr, end(arr)), [](const BasicJsonType & i) + std::inserter(ret, end(ret)), [](const BasicJsonType & i) { // get() returns *this, this won't call a from_json // method when value_type is BasicJsonType return i.template get(); }); + arr = std::move(ret); } template @@ -198,14 +201,16 @@ void from_json_array_impl(const BasicJsonType& j, ConstructibleArrayType& arr, { using std::end; + ConstructibleArrayType ret; std::transform( - j.begin(), j.end(), std::inserter(arr, end(arr)), + j.begin(), j.end(), std::inserter(ret, end(ret)), [](const BasicJsonType & i) { // get() returns *this, this won't call a from_json // method when value_type is BasicJsonType return i.template get(); }); + arr = std::move(ret); } template (); using value_type = typename ConstructibleObjectType::value_type; std::transform( inner_object->begin(), inner_object->end(), - std::inserter(obj, obj.begin()), + std::inserter(ret, ret.begin()), [](typename BasicJsonType::object_t::value_type const & p) { return value_type(p.first, p.second.template get()); }); + obj = std::move(ret); } // overload for arithmetic types, not chosen for basic_json template arguments @@ -319,6 +326,7 @@ void from_json(const BasicJsonType& j, std::map& { JSON_THROW(type_error::create(302, "type must be array, but is " + std::string(j.type_name()))); } + m.clear(); for (const auto& p : j) { if (JSON_UNLIKELY(not p.is_array())) @@ -338,6 +346,7 @@ void from_json(const BasicJsonType& j, std::unordered_map::value and - std::is_same::value) or - (has_from_json::value or - has_non_default_from_json::value); + (std::is_default_constructible::value and + (std::is_move_assignable::value or + std::is_copy_assignable::value) and + (std::is_constructible::value and + std::is_same < + typename object_t::mapped_type, + typename ConstructibleObjectType::mapped_type >::value)) or + (has_from_json::value or + has_non_default_from_json < + BasicJsonType, + typename ConstructibleObjectType::mapped_type >::value); }; template @@ -278,20 +287,24 @@ struct is_constructible_array_type_impl < BasicJsonType, ConstructibleArrayType, enable_if_t::value and - is_detected::value and - is_detected::value and - is_complete_type< - detected_t>::value >> + std::is_default_constructible::value and +(std::is_move_assignable::value or + std::is_copy_assignable::value) and +is_detected::value and +is_detected::value and +is_complete_type< +detected_t>::value >> { static constexpr bool value = // This is needed because json_reverse_iterator has a ::iterator type, - // furthermore, std::back_insert_iterator (and other iterators) have a base class `iterator`... - // Therefore it is detected as a ConstructibleArrayType. - // The real fix would be to have an Iterable concept. - not is_iterator_traits < - iterator_traits>::value and + // furthermore, std::back_insert_iterator (and other iterators) have a + // base class `iterator`... Therefore it is detected as a + // ConstructibleArrayType. The real fix would be to have an Iterable + // concept. + not is_iterator_traits>::value and - (std::is_same::value or + (std::is_same::value or has_from_json::value or has_non_default_from_json < diff --git a/single_include/nlohmann/json.hpp b/single_include/nlohmann/json.hpp index 1f11538c..240b08f2 100644 --- a/single_include/nlohmann/json.hpp +++ b/single_include/nlohmann/json.hpp @@ -1059,10 +1059,19 @@ struct is_constructible_object_type_impl < using object_t = typename BasicJsonType::object_t; static constexpr bool value = - (std::is_constructible::value and - std::is_same::value) or - (has_from_json::value or - has_non_default_from_json::value); + (std::is_default_constructible::value and + (std::is_move_assignable::value or + std::is_copy_assignable::value) and + (std::is_constructible::value and + std::is_same < + typename object_t::mapped_type, + typename ConstructibleObjectType::mapped_type >::value)) or + (has_from_json::value or + has_non_default_from_json < + BasicJsonType, + typename ConstructibleObjectType::mapped_type >::value); }; template @@ -1145,20 +1154,24 @@ struct is_constructible_array_type_impl < BasicJsonType, ConstructibleArrayType, enable_if_t::value and - is_detected::value and - is_detected::value and - is_complete_type< - detected_t>::value >> + std::is_default_constructible::value and +(std::is_move_assignable::value or + std::is_copy_assignable::value) and +is_detected::value and +is_detected::value and +is_complete_type< +detected_t>::value >> { static constexpr bool value = // This is needed because json_reverse_iterator has a ::iterator type, - // furthermore, std::back_insert_iterator (and other iterators) have a base class `iterator`... - // Therefore it is detected as a ConstructibleArrayType. - // The real fix would be to have an Iterable concept. - not is_iterator_traits < - iterator_traits>::value and + // furthermore, std::back_insert_iterator (and other iterators) have a + // base class `iterator`... Therefore it is detected as a + // ConstructibleArrayType. The real fix would be to have an Iterable + // concept. + not is_iterator_traits>::value and - (std::is_same::value or + (std::is_same::value or has_from_json::value or has_non_default_from_json < @@ -1411,6 +1424,7 @@ void from_json(const BasicJsonType& j, std::forward_list& l) { JSON_THROW(type_error::create(302, "type must be array, but is " + std::string(j.type_name()))); } + l.clear(); std::transform(j.rbegin(), j.rend(), std::front_inserter(l), [](const BasicJsonType & i) { @@ -1457,14 +1471,16 @@ auto from_json_array_impl(const BasicJsonType& j, ConstructibleArrayType& arr, p { using std::end; - arr.reserve(j.size()); + ConstructibleArrayType ret; + ret.reserve(j.size()); std::transform(j.begin(), j.end(), - std::inserter(arr, end(arr)), [](const BasicJsonType & i) + std::inserter(ret, end(ret)), [](const BasicJsonType & i) { // get() returns *this, this won't call a from_json // method when value_type is BasicJsonType return i.template get(); }); + arr = std::move(ret); } template @@ -1473,14 +1489,16 @@ void from_json_array_impl(const BasicJsonType& j, ConstructibleArrayType& arr, { using std::end; + ConstructibleArrayType ret; std::transform( - j.begin(), j.end(), std::inserter(arr, end(arr)), + j.begin(), j.end(), std::inserter(ret, end(ret)), [](const BasicJsonType & i) { // get() returns *this, this won't call a from_json // method when value_type is BasicJsonType return i.template get(); }); + arr = std::move(ret); } template (); using value_type = typename ConstructibleObjectType::value_type; std::transform( inner_object->begin(), inner_object->end(), - std::inserter(obj, obj.begin()), + std::inserter(ret, ret.begin()), [](typename BasicJsonType::object_t::value_type const & p) { return value_type(p.first, p.second.template get()); }); + obj = std::move(ret); } // overload for arithmetic types, not chosen for basic_json template arguments @@ -1594,6 +1614,7 @@ void from_json(const BasicJsonType& j, std::map& { JSON_THROW(type_error::create(302, "type must be array, but is " + std::string(j.type_name()))); } + m.clear(); for (const auto& p : j) { if (JSON_UNLIKELY(not p.is_array())) @@ -1613,6 +1634,7 @@ void from_json(const BasicJsonType& j, std::unordered_map") + { + std::map o{{"previous", "value"}}; + j.get_to(o); + CHECK(json(o) == j); + } + + SECTION("std::multimap") + { + std::multimap o{{"previous", "value"}}; + j.get_to(o); + CHECK(json(o) == j); + } + + SECTION("std::unordered_map") + { + std::unordered_map o{{"previous", "value"}}; + j.get_to(o); + CHECK(json(o) == j); + } + + SECTION("std::unordered_multimap") + { + std::unordered_multimap o{{"previous", "value"}}; + j.get_to(o); + CHECK(json(o) == j); + } + } + + SECTION("get an object (implicit)") { json::object_t o_reference = {{"object", json::object()}, @@ -226,11 +274,6 @@ TEST_CASE("value conversion") #if not defined(JSON_NOEXCEPTION) SECTION("reserve is called on containers that supports it") { - // making the call to from_json throw in order to check capacity - std::vector v; - CHECK_THROWS_AS(nlohmann::from_json(j, v), json::type_error&); - CHECK(v.capacity() == j.size()); - // make sure all values are properly copied std::vector v2 = json({1, 2, 3, 4, 5, 6, 7, 8, 9, 10}); CHECK(v2.size() == 10); @@ -302,6 +345,55 @@ TEST_CASE("value conversion") } } + SECTION("get an array (explicit, get_to)") + { + json::array_t a_reference{json(1), json(1u), json(2.2), + json(false), json("string"), json()}; + json j(a_reference); + + SECTION("json::array_t") + { + json::array_t a{"previous", "value"}; + j.get_to(a); + CHECK(json(a) == j); + } + + SECTION("std::valarray") + { + std::valarray a{"previous", "value"}; + j.get_to(a); + CHECK(json(a) == j); + } + + SECTION("std::list") + { + std::list a{"previous", "value"}; + j.get_to(a); + CHECK(json(a) == j); + } + + SECTION("std::forward_list") + { + std::forward_list a{"previous", "value"}; + j.get_to(a); + CHECK(json(a) == j); + } + + SECTION("std::vector") + { + std::vector a{"previous", "value"}; + j.get_to(a); + CHECK(json(a) == j); + } + + SECTION("std::deque") + { + std::deque a{"previous", "value"}; + j.get_to(a); + CHECK(json(a) == j); + } + } + SECTION("get an array (implicit)") { json::array_t a_reference{json(1), json(1u), json(2.2), @@ -433,6 +525,35 @@ TEST_CASE("value conversion") #endif } + SECTION("get a string (explicit, get_to)") + { + json::string_t s_reference{"Hello world"}; + json j(s_reference); + + SECTION("string_t") + { + json::string_t s = "previous value"; + j.get_to(s); + CHECK(json(s) == j); + } + + SECTION("std::string") + { + std::string s = "previous value"; + j.get_to(s); + CHECK(json(s) == j); + } +#if defined(JSON_HAS_CPP_17) + SECTION("std::string_view") + { + std::string s = "previous value"; + std::string_view sv = s; + j.get_to(sv); + CHECK(json(sv) == j); + } +#endif + } + SECTION("get null (explicit)") { std::nullptr_t n = nullptr; From e6e6805c6c80d6ec82ba719afd435fd2280535da Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Th=C3=A9o=20DELRIEU?= Date: Mon, 1 Apr 2019 13:32:06 +0200 Subject: [PATCH 053/106] add built-in array support in get_to --- .../nlohmann/detail/conversions/from_json.hpp | 10 ++++++++ include/nlohmann/json.hpp | 13 +++++++++++ single_include/nlohmann/json.hpp | 23 +++++++++++++++++++ test/src/unit-conversions.cpp | 10 ++++++++ 4 files changed, 56 insertions(+) diff --git a/include/nlohmann/detail/conversions/from_json.hpp b/include/nlohmann/detail/conversions/from_json.hpp index bb049aa8..08a841b4 100644 --- a/include/nlohmann/detail/conversions/from_json.hpp +++ b/include/nlohmann/detail/conversions/from_json.hpp @@ -157,6 +157,16 @@ void from_json(const BasicJsonType& j, std::valarray& l) std::copy(j.m_value.array->begin(), j.m_value.array->end(), std::begin(l)); } +template +auto from_json(const BasicJsonType& j, T (&arr)[N]) +-> decltype(j.template get(), void()) +{ + for (std::size_t i = 0; i < N; ++i) + { + arr[i] = j.at(i).template get(); + } +} + template void from_json_array_impl(const BasicJsonType& j, typename BasicJsonType::array_t& arr, priority_tag<3> /*unused*/) { diff --git a/include/nlohmann/json.hpp b/include/nlohmann/json.hpp index b9558a93..017ce929 100644 --- a/include/nlohmann/json.hpp +++ b/include/nlohmann/json.hpp @@ -2684,6 +2684,19 @@ class basic_json return v; } + template < + typename T, std::size_t N, + typename Array = T (&)[N], + detail::enable_if_t < + detail::has_from_json::value, int > = 0 > + Array get_to(T (&v)[N]) const + noexcept(noexcept(JSONSerializer::from_json( + std::declval(), v))) + { + JSONSerializer::from_json(*this, v); + return v; + } + /*! @brief get a pointer value (implicit) diff --git a/single_include/nlohmann/json.hpp b/single_include/nlohmann/json.hpp index 240b08f2..1f82da44 100644 --- a/single_include/nlohmann/json.hpp +++ b/single_include/nlohmann/json.hpp @@ -1445,6 +1445,16 @@ void from_json(const BasicJsonType& j, std::valarray& l) std::copy(j.m_value.array->begin(), j.m_value.array->end(), std::begin(l)); } +template +auto from_json(const BasicJsonType& j, T (&arr)[N]) +-> decltype(j.template get(), void()) +{ + for (std::size_t i = 0; i < N; ++i) + { + arr[i] = j.at(i).template get(); + } +} + template void from_json_array_impl(const BasicJsonType& j, typename BasicJsonType::array_t& arr, priority_tag<3> /*unused*/) { @@ -15475,6 +15485,19 @@ class basic_json return v; } + template < + typename T, std::size_t N, + typename Array = T (&)[N], + detail::enable_if_t < + detail::has_from_json::value, int > = 0 > + Array get_to(T (&v)[N]) const + noexcept(noexcept(JSONSerializer::from_json( + std::declval(), v))) + { + JSONSerializer::from_json(*this, v); + return v; + } + /*! @brief get a pointer value (implicit) diff --git a/test/src/unit-conversions.cpp b/test/src/unit-conversions.cpp index 800dded1..c81720d2 100644 --- a/test/src/unit-conversions.cpp +++ b/test/src/unit-conversions.cpp @@ -386,6 +386,16 @@ TEST_CASE("value conversion") CHECK(json(a) == j); } + SECTION("built-in arrays") + { + const int nbs[] = {0, 1, 2}; + int nbs2[] = {0, 0, 0}; + + json j2 = nbs; + j2.get_to(nbs2); + CHECK(std::equal(std::begin(nbs), std::end(nbs), std::begin(nbs2))); + } + SECTION("std::deque") { std::deque a{"previous", "value"}; From d66abda4ee24111809dfe1846a0840eb1a1709af Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Th=C3=A9o=20DELRIEU?= Date: Wed, 3 Apr 2019 12:34:15 +0200 Subject: [PATCH 054/106] tests: fix coverage --- test/src/unit-conversions.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/test/src/unit-conversions.cpp b/test/src/unit-conversions.cpp index c81720d2..25d4f18a 100644 --- a/test/src/unit-conversions.cpp +++ b/test/src/unit-conversions.cpp @@ -634,13 +634,19 @@ TEST_CASE("value conversion") CHECK(json(b) == j); } + SECTION("uint8_t") + { + auto n = j.get(); + CHECK(n == 1); + } + SECTION("bool") { bool b = j.get(); CHECK(json(b) == j); } - SECTION("exception in case of a non-string type") + SECTION("exception in case of a non-number type") { CHECK_THROWS_AS(json(json::value_t::null).get(), json::type_error&); @@ -650,6 +656,8 @@ TEST_CASE("value conversion") json::type_error&); CHECK_THROWS_AS(json(json::value_t::string).get(), json::type_error&); + CHECK_THROWS_AS(json(json::value_t::string).get(), + json::type_error&); CHECK_THROWS_AS( json(json::value_t::number_integer).get(), json::type_error&); From 2f9095ddab7d04f1da5c058272af9eac7dcc2e5a Mon Sep 17 00:00:00 2001 From: Niels Lohmann Date: Wed, 3 Apr 2019 17:28:47 +0200 Subject: [PATCH 055/106] :hammer: relaxed requirements to coverage --- Makefile | 2 +- test/CMakeLists.txt | 14 +++++++------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/Makefile b/Makefile index ff509e39..f739634e 100644 --- a/Makefile +++ b/Makefile @@ -76,7 +76,7 @@ check-fast: coverage: rm -fr build_coverage mkdir build_coverage - cd build_coverage ; CXX=$(COMPILER_DIR)/g++ cmake .. -GNinja -DJSON_Coverage=ON -DJSON_MultipleHeaders=ON + cd build_coverage ; CXX=g++-8 cmake .. -GNinja -DJSON_Coverage=ON -DJSON_MultipleHeaders=ON cd build_coverage ; ninja cd build_coverage ; ctest -E '.*_default' -j10 cd build_coverage ; ninja lcov_html diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 74df7522..63ba35cd 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -27,17 +27,17 @@ endif() if(JSON_Coverage) message(STATUS "Building test suite with coverage information") - if(NOT "${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") - message(FATAL_ERROR "JSON_Coverage requires GCC.") - endif() + #if(NOT "${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") + # message(FATAL_ERROR "JSON_Coverage requires GCC.") + #endif() # enable profiling set(CMAKE_CXX_FLAGS "--coverage -g -O0 -fprofile-arcs -ftest-coverage") # from https://github.com/RWTH-HPC/CMake-codecov/blob/master/cmake/FindGcov.cmake - get_filename_component(COMPILER_PATH "${CMAKE_CXX_COMPILER}" PATH) - string(REGEX MATCH "^[0-9]+" GCC_VERSION "${CMAKE_CXX_COMPILER_VERSION}") - find_program(GCOV_BIN NAMES gcov-${GCC_VERSION} gcov HINTS ${COMPILER_PATH}) + #get_filename_component(COMPILER_PATH "${CMAKE_CXX_COMPILER}" PATH) + #string(REGEX MATCH "^[0-9]+" GCC_VERSION "${CMAKE_CXX_COMPILER_VERSION}") + #find_program(GCOV_BIN NAMES gcov-${GCC_VERSION} gcov HINTS ${COMPILER_PATH}) # collect all source files from the chosen include dir file(GLOB_RECURSE SOURCE_FILES ${NLOHMANN_JSON_INCLUDE_BUILD_DIR}*.hpp) @@ -45,7 +45,7 @@ if(JSON_Coverage) # add target to collect coverage information and generate HTML file # (filter script from https://stackoverflow.com/a/43726240/266378) add_custom_target(lcov_html - COMMAND lcov --directory . --capture --output-file json.info --gcov-tool ${GCOV_BIN} --rc lcov_branch_coverage=1 + COMMAND lcov --directory . --capture --output-file json.info --rc lcov_branch_coverage=1 COMMAND lcov -e json.info ${SOURCE_FILES} --output-file json.info.filtered --rc lcov_branch_coverage=1 COMMAND ${CMAKE_SOURCE_DIR}/test/thirdparty/imapdl/filterbr.py json.info.filtered > json.info.filtered.noexcept COMMAND genhtml --title "JSON for Modern C++" --legend --demangle-cpp --output-directory html --show-details --branch-coverage json.info.filtered.noexcept From 0da99027b77f0fa6e01466b5519ed5a258d740ad Mon Sep 17 00:00:00 2001 From: Niels Lohmann Date: Wed, 3 Apr 2019 17:44:09 +0200 Subject: [PATCH 056/106] :rotating_light: silenced a warning --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 553af908..2a871dc8 100644 --- a/Makefile +++ b/Makefile @@ -182,7 +182,6 @@ pedantic_gcc: -Wextra \ -Wextra-semi \ -Wfloat-conversion \ - -Wfloat-equal \ -Wformat \ -Wformat-contains-nul \ -Wformat-extra-args \ @@ -232,6 +231,7 @@ pedantic_gcc: -Wmultistatement-macros \ -Wnarrowing \ -Wno-deprecated-declarations \ + -Wno-float-equal \ -Wno-long-long \ -Wno-namespaces \ -Wno-padded \ From f05614b240a6ed2ebafd256101a22acf2224e393 Mon Sep 17 00:00:00 2001 From: Niels Lohmann Date: Thu, 4 Apr 2019 08:56:36 +0200 Subject: [PATCH 057/106] :building_construction: adding anonymous namespace --- test/src/unit-allocator.cpp | 7 ++++++- test/src/unit-alt-string.cpp | 4 ---- test/src/unit-bson.cpp | 3 +++ test/src/unit-cbor.cpp | 3 +++ test/src/unit-class_lexer.cpp | 3 +++ test/src/unit-class_parser.cpp | 3 +++ test/src/unit-comparison.cpp | 3 +++ test/src/unit-convenience.cpp | 3 +++ test/src/unit-deserialization.cpp | 3 +++ test/src/unit-msgpack.cpp | 5 +++-- test/src/unit-noexcept.cpp | 3 +++ test/src/unit-testsuites.cpp | 4 +++- test/src/unit-to_chars.cpp | 3 +++ test/src/unit-ubjson.cpp | 3 +++ test/src/unit-unicode.cpp | 6 ++++++ test/src/unit-wstring.cpp | 3 +++ 16 files changed, 51 insertions(+), 8 deletions(-) diff --git a/test/src/unit-allocator.cpp b/test/src/unit-allocator.cpp index 079b8cae..6374640f 100644 --- a/test/src/unit-allocator.cpp +++ b/test/src/unit-allocator.cpp @@ -34,8 +34,9 @@ SOFTWARE. using nlohmann::json; #undef private +namespace +{ // special test case to check if memory is leaked if constructor throws - template struct bad_allocator : std::allocator { @@ -45,6 +46,7 @@ struct bad_allocator : std::allocator throw std::bad_alloc(); } }; +} TEST_CASE("bad_alloc") { @@ -65,6 +67,8 @@ TEST_CASE("bad_alloc") } } +namespace +{ static bool next_construct_fails = false; static bool next_destroy_fails = false; static bool next_deallocate_fails = false; @@ -130,6 +134,7 @@ void my_allocator_clean_up(T* p) alloc.destroy(p); alloc.deallocate(p, 1); } +} TEST_CASE("controlled bad_alloc") { diff --git a/test/src/unit-alt-string.cpp b/test/src/unit-alt-string.cpp index 941a59e7..39206b65 100644 --- a/test/src/unit-alt-string.cpp +++ b/test/src/unit-alt-string.cpp @@ -39,7 +39,6 @@ SOFTWARE. class alt_string; bool operator<(const char* op1, const alt_string& op2); - /* * This is virtually a string class. * It covers std::string under the hood. @@ -155,7 +154,6 @@ class alt_string friend bool ::operator<(const char*, const alt_string&); }; - using alt_json = nlohmann::basic_json < std::map, std::vector, @@ -173,8 +171,6 @@ bool operator<(const char* op1, const alt_string& op2) return op1 < op2.str_impl; } - - TEST_CASE("alternative string type") { SECTION("dump") diff --git a/test/src/unit-bson.cpp b/test/src/unit-bson.cpp index 64de0aa0..2689dcec 100644 --- a/test/src/unit-bson.cpp +++ b/test/src/unit-bson.cpp @@ -608,6 +608,8 @@ TEST_CASE("BSON input/output_adapters") } } +namespace +{ class SaxCountdown { public: @@ -677,6 +679,7 @@ class SaxCountdown private: int events_left = 0; }; +} TEST_CASE("Incomplete BSON Input") { diff --git a/test/src/unit-cbor.cpp b/test/src/unit-cbor.cpp index 43073bd0..69368b41 100644 --- a/test/src/unit-cbor.cpp +++ b/test/src/unit-cbor.cpp @@ -38,6 +38,8 @@ using nlohmann::json; #include #include +namespace +{ class SaxCountdown { public: @@ -107,6 +109,7 @@ class SaxCountdown private: int events_left = 0; }; +} TEST_CASE("CBOR") { diff --git a/test/src/unit-class_lexer.cpp b/test/src/unit-class_lexer.cpp index 70c11252..64737b57 100644 --- a/test/src/unit-class_lexer.cpp +++ b/test/src/unit-class_lexer.cpp @@ -34,12 +34,15 @@ SOFTWARE. using nlohmann::json; #undef private +namespace +{ // shortcut to scan a string literal json::lexer::token_type scan_string(const char* s); json::lexer::token_type scan_string(const char* s) { return json::lexer(nlohmann::detail::input_adapter(s)).scan(); } +} TEST_CASE("lexer class") { diff --git a/test/src/unit-class_parser.cpp b/test/src/unit-class_parser.cpp index 95df17d6..edbef499 100644 --- a/test/src/unit-class_parser.cpp +++ b/test/src/unit-class_parser.cpp @@ -36,6 +36,8 @@ using nlohmann::json; #include +namespace +{ class SaxEventLogger { public: @@ -256,6 +258,7 @@ bool accept_helper(const std::string& s) // 7. return result return ok_accept; } +} TEST_CASE("parser class") { diff --git a/test/src/unit-comparison.cpp b/test/src/unit-comparison.cpp index dadb0986..6d02f581 100644 --- a/test/src/unit-comparison.cpp +++ b/test/src/unit-comparison.cpp @@ -32,6 +32,8 @@ SOFTWARE. #include using nlohmann::json; +namespace +{ // helper function to check std::less // see https://en.cppreference.com/w/cpp/utility/functional/less template > @@ -39,6 +41,7 @@ bool f(A a, B b, U u = U()) { return u(a, b); } +} TEST_CASE("lexicographical comparison operators") { diff --git a/test/src/unit-convenience.cpp b/test/src/unit-convenience.cpp index d8fc861f..030b04f6 100644 --- a/test/src/unit-convenience.cpp +++ b/test/src/unit-convenience.cpp @@ -36,6 +36,8 @@ using nlohmann::json; #include +namespace +{ void check_escaped(const char* original, const char* escaped = "", const bool ensure_ascii = false); void check_escaped(const char* original, const char* escaped, const bool ensure_ascii) { @@ -44,6 +46,7 @@ void check_escaped(const char* original, const char* escaped, const bool ensure_ s.dump_escaped(original, ensure_ascii); CHECK(ss.str() == escaped); } +} TEST_CASE("convenience functions") { diff --git a/test/src/unit-deserialization.cpp b/test/src/unit-deserialization.cpp index 90af61fd..10bece66 100644 --- a/test/src/unit-deserialization.cpp +++ b/test/src/unit-deserialization.cpp @@ -36,6 +36,8 @@ using nlohmann::json; #include #include +namespace +{ struct SaxEventLogger : public nlohmann::json_sax { bool null() override @@ -167,6 +169,7 @@ struct SaxEventLoggerExitAfterStartArray : public SaxEventLogger return false; } }; +} TEST_CASE("deserialization") { diff --git a/test/src/unit-msgpack.cpp b/test/src/unit-msgpack.cpp index c71bafdd..cc1b8ae3 100644 --- a/test/src/unit-msgpack.cpp +++ b/test/src/unit-msgpack.cpp @@ -37,6 +37,8 @@ using nlohmann::json; #include #include +namespace +{ class SaxCountdown { public: @@ -106,6 +108,7 @@ class SaxCountdown private: int events_left = 0; }; +} TEST_CASE("MessagePack") { @@ -1300,7 +1303,6 @@ TEST_CASE("MessagePack") } } - // use this testcase outside [hide] to run it with Valgrind TEST_CASE("single MessagePack roundtrip") { @@ -1347,7 +1349,6 @@ TEST_CASE("single MessagePack roundtrip") } } - TEST_CASE("MessagePack roundtrips" * doctest::skip()) { SECTION("input from msgpack-python") diff --git a/test/src/unit-noexcept.cpp b/test/src/unit-noexcept.cpp index 78d72f2c..89049bfe 100644 --- a/test/src/unit-noexcept.cpp +++ b/test/src/unit-noexcept.cpp @@ -33,6 +33,8 @@ SOFTWARE. using nlohmann::json; +namespace +{ enum test { }; @@ -59,6 +61,7 @@ static_assert(noexcept(json(pod{})), ""); static_assert(noexcept(j.get()), ""); static_assert(not noexcept(j.get()), ""); static_assert(noexcept(json(pod{})), ""); +} TEST_CASE("runtime checks") { diff --git a/test/src/unit-testsuites.cpp b/test/src/unit-testsuites.cpp index c38b24ef..6496be10 100644 --- a/test/src/unit-testsuites.cpp +++ b/test/src/unit-testsuites.cpp @@ -418,7 +418,6 @@ TEST_CASE("json.org examples") json j; CHECK_NOTHROW(j.parse(f.get())); } - } TEST_CASE("RFC 7159 examples") @@ -1352,6 +1351,8 @@ TEST_CASE("nst's JSONTestSuite (2)") } } +namespace +{ std::string trim(const std::string& str); // from http://stackoverflow.com/a/25829178/266378 @@ -1365,6 +1366,7 @@ std::string trim(const std::string& str) size_t last = str.find_last_not_of(' '); return str.substr(first, (last - first + 1)); } +} TEST_CASE("Big List of Naughty Strings") { diff --git a/test/src/unit-to_chars.cpp b/test/src/unit-to_chars.cpp index 3399513b..dbd5e175 100644 --- a/test/src/unit-to_chars.cpp +++ b/test/src/unit-to_chars.cpp @@ -36,6 +36,8 @@ SOFTWARE. #include using nlohmann::detail::dtoa_impl::reinterpret_bits; +namespace +{ static float make_float(uint32_t sign_bit, uint32_t biased_exponent, uint32_t significand) { assert(sign_bit == 0 || sign_bit == 1); @@ -139,6 +141,7 @@ static double make_double(uint64_t f, int e) uint64_t bits = (f & kSignificandMask) | (biased_exponent << kPhysicalSignificandSize); return reinterpret_bits(bits); } +} TEST_CASE("digit gen") { diff --git a/test/src/unit-ubjson.cpp b/test/src/unit-ubjson.cpp index 86f35b02..ca6b70fd 100644 --- a/test/src/unit-ubjson.cpp +++ b/test/src/unit-ubjson.cpp @@ -35,6 +35,8 @@ using nlohmann::json; #include #include +namespace +{ class SaxCountdown { public: @@ -104,6 +106,7 @@ class SaxCountdown private: int events_left = 0; }; +} TEST_CASE("UBJSON") { diff --git a/test/src/unit-unicode.cpp b/test/src/unit-unicode.cpp index aa854280..e69639f4 100644 --- a/test/src/unit-unicode.cpp +++ b/test/src/unit-unicode.cpp @@ -42,6 +42,8 @@ using nlohmann::json; #include #include +namespace +{ extern size_t calls; size_t calls = 0; @@ -165,6 +167,7 @@ void check_utf8string(bool success_expected, int byte1, int byte2 = -1, int byte CHECK_THROWS_AS(json::parse(json_string), json::parse_error&); } } +} TEST_CASE("Unicode" * doctest::skip()) { @@ -1205,6 +1208,8 @@ TEST_CASE("Unicode" * doctest::skip()) } } +namespace +{ void roundtrip(bool success_expected, const std::string& s); void roundtrip(bool success_expected, const std::string& s) @@ -1244,6 +1249,7 @@ void roundtrip(bool success_expected, const std::string& s) CHECK_THROWS_AS(json::parse(ps), json::parse_error&); } } +} TEST_CASE("Markus Kuhn's UTF-8 decoder capability and stress test") { diff --git a/test/src/unit-wstring.cpp b/test/src/unit-wstring.cpp index 66bb5938..85aa04db 100644 --- a/test/src/unit-wstring.cpp +++ b/test/src/unit-wstring.cpp @@ -32,6 +32,8 @@ SOFTWARE. #include using nlohmann::json; +namespace +{ bool wstring_is_utf16(); bool wstring_is_utf16() { @@ -49,6 +51,7 @@ bool u32string_is_utf32() { return (std::u32string(U"💩") == std::u32string(U"\U0001F4A9")); } +} TEST_CASE("wide strings") { From 4676f759e8b514a71e63a039fe496c3ef1bd639e Mon Sep 17 00:00:00 2001 From: Niels Lohmann Date: Thu, 4 Apr 2019 09:50:27 +0200 Subject: [PATCH 058/106] :arrow_up: updated fastcov --- test/CMakeLists.txt | 8 +- test/thirdparty/fastcov/fastcov.py | 122 ++++++++---- test/thirdparty/fastcov/fastcov_legacy.py | 218 ---------------------- 3 files changed, 92 insertions(+), 256 deletions(-) delete mode 100755 test/thirdparty/fastcov/fastcov_legacy.py diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 5001be66..4d542917 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -35,9 +35,9 @@ if(JSON_Coverage) set(CMAKE_CXX_FLAGS "--coverage -g -O0 -fprofile-arcs -ftest-coverage") # from https://github.com/RWTH-HPC/CMake-codecov/blob/master/cmake/FindGcov.cmake - #get_filename_component(COMPILER_PATH "${CMAKE_CXX_COMPILER}" PATH) - #string(REGEX MATCH "^[0-9]+" GCC_VERSION "${CMAKE_CXX_COMPILER_VERSION}") - #find_program(GCOV_BIN NAMES gcov-${GCC_VERSION} gcov HINTS ${COMPILER_PATH}) + get_filename_component(COMPILER_PATH "${CMAKE_CXX_COMPILER}" PATH) + string(REGEX MATCH "^[0-9]+" GCC_VERSION "${CMAKE_CXX_COMPILER_VERSION}") + find_program(GCOV_BIN NAMES gcov-${GCC_VERSION} gcov HINTS ${COMPILER_PATH}) # collect all source files from the chosen include dir file(GLOB_RECURSE SOURCE_FILES ${NLOHMANN_JSON_INCLUDE_BUILD_DIR}*.hpp) @@ -55,7 +55,7 @@ if(JSON_Coverage) # add target to collect coverage information and generate HTML file # (filter script from https://stackoverflow.com/a/43726240/266378) add_custom_target(lcov_html2 - COMMAND ${CMAKE_SOURCE_DIR}/test/thirdparty/fastcov/fastcov.py --lcov -o json.info --gcov ${GCOV_BIN} --exclude-gcov /usr 9.0.1/ test/ + COMMAND ${CMAKE_SOURCE_DIR}/test/thirdparty/fastcov/fastcov.py --branch-coverage --lcov -o json.info --gcov ${GCOV_BIN} COMMAND gsed -i 's%build_coverage/%%g' json.info COMMAND ${CMAKE_SOURCE_DIR}/test/thirdparty/imapdl/filterbr.py json.info > json.info.filtered.noexcept COMMAND genhtml --title "JSON for Modern C++" --legend --demangle-cpp --output-directory html --show-details --branch-coverage json.info.filtered.noexcept diff --git a/test/thirdparty/fastcov/fastcov.py b/test/thirdparty/fastcov/fastcov.py index ee7fbe78..dd4c9132 100755 --- a/test/thirdparty/fastcov/fastcov.py +++ b/test/thirdparty/fastcov/fastcov.py @@ -13,7 +13,7 @@ $ cd build_dir $ ./fastcov.py --zerocounters $ - $ ./fastcov.py --exclude-gcov /usr/include --lcov -o report.info + $ ./fastcov.py --exclude /usr/include test/ --lcov -o report.info $ genhtml -o code_coverage report.info """ @@ -64,24 +64,28 @@ def getGcdaFiles(cwd, gcda_files): gcda_files = glob.glob(os.path.join(cwd, "**/*.gcda"), recursive=True) return gcda_files -def gcovWorker(cwd, gcov, files, chunk, exclude): - p = subprocess.Popen([gcov, "-it"] + chunk, cwd=cwd, stdout=subprocess.PIPE, stderr=subprocess.DEVNULL) +def gcovWorker(cwd, gcov, files, chunk, gcov_filter_options, branch_coverage): + gcov_args = "-it" + if branch_coverage: + gcov_args += "b" + + p = subprocess.Popen([gcov, gcov_args] + chunk, cwd=cwd, stdout=subprocess.PIPE, stderr=subprocess.DEVNULL) for line in iter(p.stdout.readline, b''): intermediate_json = json.loads(line.decode(sys.stdout.encoding)) - intermediate_json_files = processGcovs(intermediate_json["files"], exclude) + intermediate_json_files = processGcovs(intermediate_json["files"], gcov_filter_options) for f in intermediate_json_files: files.append(f) #thread safe, there might be a better way to do this though GCOVS_TOTAL.append(len(intermediate_json["files"])) GCOVS_SKIPPED.append(len(intermediate_json["files"])-len(intermediate_json_files)) p.wait() -def processGcdas(cwd, gcov, jobs, gcda_files, exclude): +def processGcdas(cwd, gcov, jobs, gcda_files, gcov_filter_options, branch_coverage): chunk_size = max(MINIMUM_CHUNK_SIZE, int(len(gcda_files) / jobs) + 1) threads = [] intermediate_json_files = [] for chunk in chunks(gcda_files, chunk_size): - t = threading.Thread(target=gcovWorker, args=(cwd, gcov, intermediate_json_files, chunk, exclude)) + t = threading.Thread(target=gcovWorker, args=(cwd, gcov, intermediate_json_files, chunk, gcov_filter_options, branch_coverage)) threads.append(t) t.start() @@ -91,39 +95,75 @@ def processGcdas(cwd, gcov, jobs, gcda_files, exclude): return intermediate_json_files -def processGcov(gcov, files, exclude): - for ex in exclude: +def processGcov(gcov, files, gcov_filter_options): + # If explicit sources were passed, check for match + source_file = os.path.abspath(gcov["file"]) + if gcov_filter_options["sources"]: + if source_file in gcov_filter_options["sources"]: + files.append(gcov) + return + + # Check include filter + if gcov_filter_options["include"]: + for ex in gcov_filter_options["include"]: + if ex in gcov["file"]: + files.append(gcov) + break + return + + # Check exclude filter + for ex in gcov_filter_options["exclude"]: if ex in gcov["file"]: return + files.append(gcov) -def processGcovs(gcov_files, exclude): +def processGcovs(gcov_files, gcov_filter_options): files = [] for gcov in gcov_files: - processGcov(gcov, files, exclude) + processGcov(gcov, files, gcov_filter_options) return files -def dumpToLcovInfo(cwd, intermediate, output): +def dumpBranchCoverageToLcovInfo(f, source): + branch_miss = 0 + branch_total = 0 + for line in source["lines"]: + if not line["branches"]: + continue + branch_total += len(line["branches"]) + for i, branch in enumerate(line["branches"]): + #Branch (, , , ) + f.write("BRDA:%d,%d,%d,%d\n" % (line["line_number"], int(i/2), i, branch["count"])) + branch_miss += int(branch["count"] == 0) + f.write("BRF:%d\n" % branch_total) #Branches Found + f.write("BRH:%d\n" % (branch_total - branch_miss)) #Branches Hit + +def dumpToLcovInfo(cwd, intermediate, output, branch_coverage): with open(output, "w") as f: - for file in intermediate: + for source in intermediate: #Convert to absolute path so it plays nice with genhtml - sf = file["file"] - if not os.path.isabs(file["file"]): - sf = os.path.abspath(os.path.join(cwd, file["file"])) - f.write("SF:%s\n" % sf) + sf = source["file"] + if not os.path.isabs(source["file"]): + sf = os.path.abspath(os.path.join(cwd, source["file"])) + f.write("SF:%s\n" % sf) #Source File + fn_miss = 0 - for function in file["functions"]: - f.write("FN:%s,%s\n" % (function["start_line"], function["name"])) - f.write("FNDA:%s,%s\n" % (function["execution_count"], function["name"])) - fn_miss += int(not function["execution_count"] == 0) - f.write("FNF:%s\n" % len(file["functions"])) - f.write("FNH:%s\n" % (len(file["functions"]) - fn_miss)) + for function in source["functions"]: + f.write("FN:%d,%s\n" % (function["start_line"], function["name"])) #Function Start Line + f.write("FNDA:%d,%s\n" % (function["execution_count"], function["name"])) #Function Hits + fn_miss += int(function["execution_count"] == 0) + f.write("FNF:%d\n" % len(source["functions"])) #Functions Found + f.write("FNH:%d\n" % (len(source["functions"]) - fn_miss)) #Functions Hit + + if branch_coverage: + dumpBranchCoverageToLcovInfo(f, source) + line_miss = 0 - for line in file["lines"]: - f.write("DA:%s,%s\n" % (line["line_number"], line["count"])) - line_miss += int(not line["count"] == 0) - f.write("LF:%s\n" % len(file["lines"])) - f.write("LH:%s\n" % (len(file["lines"]) - line_miss)) + for line in source["lines"]: + f.write("DA:%d,%d\n" % (line["line_number"], line["count"])) #Line + line_miss += int(line["count"] == 0) + f.write("LF:%d\n" % len(source["lines"])) #Lines Found + f.write("LH:%d\n" % (len(source["lines"]) - line_miss)) #Lines Hit f.write("end_of_record\n") def dumpToGcovJson(intermediate, output): @@ -134,6 +174,13 @@ def log(line): if not args.quiet: print(line) +def getGcovFilterOptions(args): + return { + "sources": set([os.path.abspath(s) for s in args.sources]), #Make paths absolute + "include": args.includepost, + "exclude": args.excludepost, + } + def main(args): # Need at least gcov 9.0.0 because that's when gcov JSON and stdout streaming was introduced current_gcov_version = getGcovVersion(args.gcov) @@ -154,7 +201,8 @@ def main(args): log("%d .gcda files removed" % len(gcda_files)) return - intermediate_json_files = processGcdas(args.cdirectory, args.gcov, args.jobs, gcda_files, args.excludepost) + gcov_filter_options = getGcovFilterOptions(args) + intermediate_json_files = processGcdas(args.cdirectory, args.gcov, args.jobs, gcda_files, gcov_filter_options, args.branchcoverage) gcov_total = sum(GCOVS_TOTAL) gcov_skipped = sum(GCOVS_SKIPPED) @@ -162,7 +210,7 @@ def main(args): log("%d .gcov files processed by fastcov (%d skipped)" % (gcov_total - gcov_skipped, gcov_skipped)) if args.lcov: - dumpToLcovInfo(args.cdirectory, intermediate_json_files, args.output) + dumpToLcovInfo(args.cdirectory, intermediate_json_files, args.output, args.branchcoverage) log("Created lcov info file '%s'" % args.output) else: dumpToGcovJson(intermediate_json_files, args.output) @@ -172,18 +220,24 @@ if __name__ == '__main__': parser = argparse.ArgumentParser(description='A parallel gcov wrapper for fast coverage report generation') parser.add_argument('-z', '--zerocounters', dest='zerocounters', action="store_true", help='Recursively delete all gcda files') - parser.add_argument('-f', '--gcda-files', dest='gcda_files', nargs="+", default=[], help='Specify exactly which gcda files should be processed instead of recursivly searching the search directory.') - parser.add_argument('-E', '--exclude-gcda', dest='excludepre', nargs="+", default=[], help='.gcda filter - Exclude gcda files from being processed via simple find matching (not regex)') - parser.add_argument('-e', '--exclude-gcov', dest='excludepost', nargs="+", default=[], help='.gcov filter - Exclude gcov files from being processed via simple find matching (not regex)') + # Enable Branch Coverage + parser.add_argument('-b', '--branch-coverage', dest='branchcoverage', action="store_true", help='Include branch counts in the coverage report') - parser.add_argument('-g', '--gcov', dest='gcov', default='gcov', help='which gcov binary to use') + # Filtering Options + parser.add_argument('-s', '--source-files', dest='sources', nargs="+", default=[], help='Filter: Specify exactly which source files should be included in the final report. Paths must be either absolute or relative to current directory.') + parser.add_argument('-e', '--exclude', dest='excludepost', nargs="+", default=[], help='Filter: Exclude source files from final report if they contain one of the provided substrings (i.e. /usr/include test/, etc.)') + parser.add_argument('-i', '--include', dest='includepost', nargs="+", default=[], help='Filter: Only include source files in final report that contain one of the provided substrings (i.e. src/ etc.)') + parser.add_argument('-f', '--gcda-files', dest='gcda_files', nargs="+", default=[], help='Filter: Specify exactly which gcda files should be processed instead of recursively searching the search directory.') + parser.add_argument('-E', '--exclude-gcda', dest='excludepre', nargs="+", default=[], help='Filter: Exclude gcda files from being processed via simple find matching (not regex)') + + parser.add_argument('-g', '--gcov', dest='gcov', default='gcov', help='Which gcov binary to use') parser.add_argument('-d', '--search-directory', dest='directory', default=".", help='Base directory to recursively search for gcda files (default: .)') parser.add_argument('-c', '--compiler-directory', dest='cdirectory', default=".", help='Base directory compiler was invoked from (default: .)') parser.add_argument('-j', '--jobs', dest='jobs', type=int, default=multiprocessing.cpu_count(), help='Number of parallel gcov to spawn (default: %d).' % multiprocessing.cpu_count()) parser.add_argument('-o', '--output', dest='output', default="coverage.json", help='Name of output file (default: coverage.json)') - parser.add_argument('-i', '--lcov', dest='lcov', action="store_true", help='Output in lcov info format instead of gcov json') + parser.add_argument('-l', '--lcov', dest='lcov', action="store_true", help='Output in lcov info format instead of gcov json') parser.add_argument('-q', '--quiet', dest='quiet', action="store_true", help='Suppress output to stdout') args = parser.parse_args() main(args) \ No newline at end of file diff --git a/test/thirdparty/fastcov/fastcov_legacy.py b/test/thirdparty/fastcov/fastcov_legacy.py deleted file mode 100755 index 3e0151ab..00000000 --- a/test/thirdparty/fastcov/fastcov_legacy.py +++ /dev/null @@ -1,218 +0,0 @@ -#!/usr/bin/env python3 -""" - Author: Bryan Gillespie - - Legacy version... supports versions 7.1.0 <= GCC < 9.0.0 - - A massively parallel gcov wrapper for generating intermediate coverage formats fast - - The goal of fastcov is to generate code coverage intermediate formats as fast as possible - (ideally < 1 second), even for large projects with hundreds of gcda objects. The intermediate - formats may then be consumed by a report generator such as lcov's genhtml, or a dedicated front - end such as coveralls. - - Sample Usage: - $ cd build_dir - $ ./fastcov.py --exclude-gcov /usr/include --lcov -o report.info - $ genhtml -o code_coverage report.info -""" - -import re -import os -import glob -import json -import argparse -import subprocess -import multiprocessing -from random import shuffle - -MINIMUM_GCOV = (7,1,0) -MINIMUM_CHUNK_SIZE = 10 - -def chunks(l, n): - """Yield successive n-sized chunks from l.""" - for i in range(0, len(l), n): - yield l[i:i + n] - -def getGcovVersion(gcov): - p = subprocess.Popen([gcov, "-v"], stdout=subprocess.PIPE) - output = p.communicate()[0].decode('UTF-8') - p.wait() - version_str = re.search(r'\s([\d.]+)\s', output.split("\n")[0]).group(1) - version = tuple(map(int, version_str.split("."))) - return version - -def removeFiles(files): - for file in files: - os.remove(file) - -def getFilteredGcdaFiles(gcda_files, exclude): - def excludeGcda(gcda): - for ex in exclude: - if ex in gcda: - return False - return True - return list(filter(excludeGcda, gcda_files)) - -def getGcdaFiles(cwd, gcda_files, exclude): - if not gcda_files: - gcda_files = glob.glob(os.path.join(cwd, "**/*.gcda"), recursive=True) - if exclude: - return getFilteredGcdaFiles(gcda_files, exclude) - return gcda_files - -def getGcovFiles(cwd): - return glob.glob(os.path.join(cwd, "*.gcov")) - -def filterGcovFiles(gcov): - with open(gcov) as f: - path = f.readline()[5:] - for ex in args.exclude: - if ex in path: - return False - return True - -def processGcdasPre9(cwd, gcov, jobs, gcda_files): - chunk_size = min(MINIMUM_CHUNK_SIZE, int(len(gcda_files) / jobs) + 1) - - processes = [] - # shuffle(gcda_files) # improves performance by preventing any one gcov from bottlenecking on a list of sequential, expensive gcdas (?) - for chunk in chunks(gcda_files, chunk_size): - processes.append(subprocess.Popen([gcov, "-i"] + chunk, cwd=cwd, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)) - - for p in processes: - p.wait() - -def processGcdasPre9Accurate(cwd, gcov, gcda_files, exclude): - intermediate_json_files = [] - for gcda in gcda_files: - subprocess.Popen([gcov, "-i", gcda], cwd=cwd, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL).wait() - gcov_files = getGcovFiles(cwd) - intermediate_json_files += processGcovs(gcov_files, exclude) - removeFiles(gcov_files) - return intermediate_json_files - -def processGcovLine(file, line): - line_type, data = line.split(":", 1) - if line_type == "lcount": - num, count = data.split(",") - hit = (count != 0) - file["lines_hit"] += int(hit) - file["lines"].append({ - "branches": [], - "line_number": num, - "count": count, - "unexecuted_block": not hit - }) - elif line_type == "function": - num, count, name = data.split(",") - hit = (count != 0) - file["functions_hit"] += int(hit) - file["functions"].append({ - "name": name, - "execution_count": count, - "start_line": num, - "end_line": None, - "blocks": None, - "blocks_executed": None, - "demangled_name": None - }) - -def processGcov(files, gcov, exclude): - with open(gcov) as f: - path = f.readline()[5:].rstrip() - for ex in exclude: - if ex in path: - return False - file = { - "file": path, - "functions": [], - "functions_hit": 0, - "lines": [], - "lines_hit": 0 - } - for line in f: - processGcovLine(file, line.rstrip()) - files.append(file) - return True - -def processGcovs(gcov_files, exclude): - files = [] - filtered = 0 - for gcov in gcov_files: - filtered += int(not processGcov(files, gcov, exclude)) - print("Skipped %d .gcov files" % filtered) - return files - -def dumpToLcovInfo(intermediate, output): - with open(output, "w") as f: - for file in intermediate: - f.write("SF:%s\n" % file["file"]) - for function in file["functions"]: - f.write("FN:%s,%s\n" % (function["start_line"], function["name"])) - f.write("FNDA:%s,%s\n" % (function["execution_count"], function["name"])) - f.write("FNF:%s\n" % len(file["functions"])) - f.write("FNH:%s\n" % file["functions_hit"]) - for line in file["lines"]: - f.write("DA:%s,%s\n" % (line["line_number"], line["count"])) - f.write("LF:%s\n" % len(file["lines"])) - f.write("LH:%s\n" % file["lines_hit"]) - f.write("end_of_record\n") - -def dumpToGcovJson(intermediate, output): - with open(output, "w") as f: - json.dump(intermediate, f) - -def main(args): - # Need at least gcov 7.1.0 because of bug not allowing -i in conjunction with multiple files - # See: https://github.com/gcc-mirror/gcc/commit/41da7513d5aaaff3a5651b40edeccc1e32ea785a - current_gcov_version = getGcovVersion(args.gcov) - if current_gcov_version < MINIMUM_GCOV: - print("Minimum gcov version {} required, found {}".format(".".join(map(str, MINIMUM_GCOV)), ".".join(map(str, current_gcov_version)))) - exit(1) - - gcda_files = getGcdaFiles(args.directory, args.gcda_files, args.excludepre) - print("Found %d .gcda files" % len(gcda_files)) - - # We "zero" the "counters" by simply deleting all gcda files - if args.zerocounters: - removeFiles(gcda_files) - print("Removed %d .gcda files" % len(gcda_files)) - return - - # If we are less than gcov 9.0.0, convert .gcov files to GCOV 9 JSON format - processGcdasPre9(args.cdirectory, args.gcov, args.jobs, gcda_files) - gcov_files = getGcovFiles(args.cdirectory) - - print("Found %d .gcov files" % len(gcov_files)) - - intermediate_json_files = processGcovs(gcov_files, args.excludepost) - removeFiles(gcov_files) - - intermediate_json_files += processGcdasPre9Accurate(args.cdirectory, args.gcov, args.gcda_files_accurate, args.excludepost) - - if args.lcov: - dumpToLcovInfo(intermediate_json_files, args.output) - else: - dumpToGcovJson(intermediate_json_files, args.output) - -if __name__ == '__main__': - parser = argparse.ArgumentParser(description='A parallel gcov wrapper for fast coverage report generation') - parser.add_argument('-z', '--zerocounters', dest='zerocounters', action="store_true", help='Recursively delete all gcda files') - - parser.add_argument('-f', '--gcda-files', dest='gcda_files', nargs="+", default=[], help='Specify exactly which gcda files should be processed instead of recursivly searching the search directory.') - parser.add_argument('-F', '--gcda-files-accurate', dest='gcda_files_accurate', nargs="+", default=[], help='(< gcov 9.0.0) Get accurate header coverage information for just these. These files cannot be processed in parallel') - parser.add_argument('-E', '--exclude-gcda', dest='excludepre', nargs="+", default=[], help='.gcda filter - Exclude gcda files from being processed via simple find matching (not regex)') - parser.add_argument('-e', '--exclude-gcov', dest='excludepost', nargs="+", default=[], help='.gcov filter - Exclude gcov files from being processed via simple find matching (not regex)') - - parser.add_argument('-g', '--gcov', dest='gcov', default='gcov', help='which gcov binary to use') - - parser.add_argument('-d', '--search-directory', dest='directory', default=".", help='Base directory to recursively search for gcda files (default: .)') - parser.add_argument('-c', '--compiler-directory', dest='cdirectory', default=".", help='Base directory compiler was invoked from (default: .)') - parser.add_argument('-j', '--jobs', dest='jobs', type=int, default=multiprocessing.cpu_count(), help='Number of parallel gcov to spawn (default: %d).' % multiprocessing.cpu_count()) - - - parser.add_argument('-o', '--output', dest='output', default="coverage.json", help='Name of output file (default: coverage.json)') - parser.add_argument('-i', '--lcov', dest='lcov', action="store_true", help='Output in lcov info format instead of gcov json') - args = parser.parse_args() - main(args) \ No newline at end of file From 0a1ddd6882e34dd551b116c08db1f6f6d33762a6 Mon Sep 17 00:00:00 2001 From: Niels Lohmann Date: Fri, 5 Apr 2019 07:54:46 +0200 Subject: [PATCH 059/106] :arrow_up: updated fastcov --- test/CMakeLists.txt | 3 +-- test/thirdparty/fastcov/fastcov.py | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 4d542917..c8bdda47 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -55,8 +55,7 @@ if(JSON_Coverage) # add target to collect coverage information and generate HTML file # (filter script from https://stackoverflow.com/a/43726240/266378) add_custom_target(lcov_html2 - COMMAND ${CMAKE_SOURCE_DIR}/test/thirdparty/fastcov/fastcov.py --branch-coverage --lcov -o json.info --gcov ${GCOV_BIN} - COMMAND gsed -i 's%build_coverage/%%g' json.info + COMMAND ${CMAKE_SOURCE_DIR}/test/thirdparty/fastcov/fastcov.py --branch-coverage --lcov -o json.info --gcov ${GCOV_BIN} --compiler-directory ${CMAKE_BINARY_DIR} #--source-files ${SOURCE_FILES} COMMAND ${CMAKE_SOURCE_DIR}/test/thirdparty/imapdl/filterbr.py json.info > json.info.filtered.noexcept COMMAND genhtml --title "JSON for Modern C++" --legend --demangle-cpp --output-directory html --show-details --branch-coverage json.info.filtered.noexcept COMMENT "Generating HTML report test/html/index.html" diff --git a/test/thirdparty/fastcov/fastcov.py b/test/thirdparty/fastcov/fastcov.py index dd4c9132..8fc1eab5 100755 --- a/test/thirdparty/fastcov/fastcov.py +++ b/test/thirdparty/fastcov/fastcov.py @@ -61,7 +61,7 @@ def getFilteredGcdaFiles(gcda_files, exclude): def getGcdaFiles(cwd, gcda_files): if not gcda_files: - gcda_files = glob.glob(os.path.join(cwd, "**/*.gcda"), recursive=True) + gcda_files = glob.glob(os.path.join(os.path.abspath(cwd), "**/*.gcda"), recursive=True) return gcda_files def gcovWorker(cwd, gcov, files, chunk, gcov_filter_options, branch_coverage): From 63fe1cbbcf01c0a22c5088e5828d7a70a40093e9 Mon Sep 17 00:00:00 2001 From: Niels Lohmann Date: Fri, 5 Apr 2019 18:29:57 +0200 Subject: [PATCH 060/106] :memo: updated README --- README.md | 51 +++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 41 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index f05af440..dcb3641b 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,7 @@ [![Build Status](https://travis-ci.org/nlohmann/json.svg?branch=master)](https://travis-ci.org/nlohmann/json) [![Build Status](https://ci.appveyor.com/api/projects/status/1acb366xfyg3qybk/branch/develop?svg=true)](https://ci.appveyor.com/project/nlohmann/json) +[![Build Status](https://circleci.com/gh/nlohmann/json.svg?style=svg)](https://circleci.com/gh/nlohmann/json) [![Coverage Status](https://img.shields.io/coveralls/nlohmann/json.svg)](https://coveralls.io/r/nlohmann/json) [![Coverity Scan Build Status](https://scan.coverity.com/projects/5550/badge.svg)](https://scan.coverity.com/projects/nlohmann-json) [![Codacy Badge](https://api.codacy.com/project/badge/Grade/f3732b3327e34358a0e9d1fe9f661f08)](https://www.codacy.com/app/nlohmann/json?utm_source=github.com&utm_medium=referral&utm_content=nlohmann/json&utm_campaign=Badge_Grade) @@ -1269,7 +1270,8 @@ The library itself consists of a single header file licensed under the MIT licen - [**amalgamate.py - Amalgamate C source and header files**](https://github.com/edlund/amalgamate) to create a single header file - [**American fuzzy lop**](http://lcamtuf.coredump.cx/afl/) for fuzz testing - [**AppVeyor**](https://www.appveyor.com) for [continuous integration](https://ci.appveyor.com/project/nlohmann/json) on Windows -- [**Artistic Style**](http://astyle.sourceforge.net) for automatic source code identation +- [**Artistic Style**](http://astyle.sourceforge.net) for automatic source code indentation +- [**CircleCI**](http://circleci.com) for [continuous integration](https://circleci.com/gh/nlohmann/json). - [**Clang**](http://clang.llvm.org) for compilation with code sanitizers - [**CMake**](https://cmake.org) for build automation - [**Codacity**](https://www.codacy.com) for further [code analysis](https://www.codacy.com/app/nlohmann/json) @@ -1298,18 +1300,47 @@ The library is currently used in Apple macOS Sierra and iOS 10. I am not sure wh ## Notes +### Character encoding + +The library supports **Unicode input** as follows: + +- Only **UTF-8** encoded input is supported which is the default encoding for JSON according to [RFC 8259](https://tools.ietf.org/html/rfc8259.html#section-8.1). +- `std::u16string` and `std::u32string` can be parsed, assuming UTF-16 and UTF-32 encoding, respectively. These encodings are not supported when reading from files or other input containers. +- Other encodings such as Latin-1 or ISO 8859-1 are **not** supported and will yield parse or serialization errors. +- [Unicode noncharacters](http://www.unicode.org/faq/private_use.html#nonchar1) will not be replaced by the library. +- Invalid surrogates (e.g., incomplete pairs such as `\uDEAD`) will yield parse errors. +- The strings stored in the library are UTF-8 encoded. When using the default string type (`std::string`), note that its length/size functions return the number of stored bytes rather than the number of characters or glyphs. +- When you store strings with different encodings in the library, calling [`dump()`](https://nlohmann.github.io/json/classnlohmann_1_1basic__json_a50ec80b02d0f3f51130d4abb5d1cfdc5.html#a50ec80b02d0f3f51130d4abb5d1cfdc5) may throw an exception unless `json::error_handler_t::replace` or `json::error_handler_t::ignore` are used as error handlers. + +### Comments in JSON + +This library does not support comments. It does so for three reasons: + +1. Comments are not part of the [JSON specification](https://tools.ietf.org/html/rfc8259). You may argue that `//` or `/* */` are allowed in JavaScript, but JSON is not JavaScript. +2. This was not an oversight: Douglas Crockford [wrote on this](https://plus.google.com/118095276221607585885/posts/RK8qyGVaGSr) in May 2012: + + > I removed comments from JSON because I saw people were using them to hold parsing directives, a practice which would have destroyed interoperability. I know that the lack of comments makes some people sad, but it shouldn't. + + > Suppose you are using JSON to keep configuration files, which you would like to annotate. Go ahead and insert all the comments you like. Then pipe it through JSMin before handing it to your JSON parser. + +3. It dangerous for interoperability if some libraries would add comment support while others don't. Please check [The Harmful Consequences of the Robustness Principle](https://tools.ietf.org/html/draft-iab-protocol-maintenance-01) on this. + +This library will not support comments in the future. If you wish to use comments, I see three options: + +1. Strip comments before using this library. +2. Use a different JSON library with comment support. +3. Use a format that natively supports comments (e.g., YAML or JSON5). + +### Order of object keys + +By default, the library does not preserve the **insertion order of object elements**. This is standards-compliant, as the [JSON standard](https://tools.ietf.org/html/rfc8259.html) defines objects as "an unordered collection of zero or more name/value pairs". If you do want to preserve the insertion order, you can specialize the object type with containers like [`tsl::ordered_map`](https://github.com/Tessil/ordered-map) ([integration](https://github.com/nlohmann/json/issues/546#issuecomment-304447518)) or [`nlohmann::fifo_map`](https://github.com/nlohmann/fifo_map) ([integration](https://github.com/nlohmann/json/issues/485#issuecomment-333652309)). + +### Further notes + - The code contains numerous debug **assertions** which can be switched off by defining the preprocessor macro `NDEBUG`, see the [documentation of `assert`](https://en.cppreference.com/w/cpp/error/assert). In particular, note [`operator[]`](https://nlohmann.github.io/json/classnlohmann_1_1basic__json_a233b02b0839ef798942dd46157cc0fe6.html#a233b02b0839ef798942dd46157cc0fe6) implements **unchecked access** for const objects: If the given key is not present, the behavior is undefined (think of a dereferenced null pointer) and yields an [assertion failure](https://github.com/nlohmann/json/issues/289) if assertions are switched on. If you are not sure whether an element in an object exists, use checked access with the [`at()` function](https://nlohmann.github.io/json/classnlohmann_1_1basic__json_a73ae333487310e3302135189ce8ff5d8.html#a73ae333487310e3302135189ce8ff5d8). -- As the exact type of a number is not defined in the [JSON specification](https://tools.ietf.org/html/rfc7159.html), this library tries to choose the best fitting C++ number type automatically. As a result, the type `double` may be used to store numbers which may yield [**floating-point exceptions**](https://github.com/nlohmann/json/issues/181) in certain rare situations if floating-point exceptions have been unmasked in the calling code. These exceptions are not caused by the library and need to be fixed in the calling code, such as by re-masking the exceptions prior to calling library functions. -- The library supports **Unicode input** as follows: - - Only **UTF-8** encoded input is supported which is the default encoding for JSON according to [RFC 7159](https://tools.ietf.org/html/rfc7159.html#section-8.1). - - Other encodings such as Latin-1, UTF-16, or UTF-32 are not supported and will yield parse or serialization errors. - - [Unicode noncharacters](http://www.unicode.org/faq/private_use.html#nonchar1) will not be replaced by the library. - - Invalid surrogates (e.g., incomplete pairs such as `\uDEAD`) will yield parse errors. - - The strings stored in the library are UTF-8 encoded. When using the default string type (`std::string`), note that its length/size functions return the number of stored bytes rather than the number of characters or glyphs. +- As the exact type of a number is not defined in the [JSON specification](https://tools.ietf.org/html/rfc8259.html), this library tries to choose the best fitting C++ number type automatically. As a result, the type `double` may be used to store numbers which may yield [**floating-point exceptions**](https://github.com/nlohmann/json/issues/181) in certain rare situations if floating-point exceptions have been unmasked in the calling code. These exceptions are not caused by the library and need to be fixed in the calling code, such as by re-masking the exceptions prior to calling library functions. - The code can be compiled without C++ **runtime type identification** features; that is, you can use the `-fno-rtti` compiler flag. - **Exceptions** are used widely within the library. They can, however, be switched off with either using the compiler flag `-fno-exceptions` or by defining the symbol `JSON_NOEXCEPTION`. In this case, exceptions are replaced by an `abort()` call. -- By default, the library does not preserve the **insertion order of object elements**. This is standards-compliant, as the [JSON standard](https://tools.ietf.org/html/rfc7159.html) defines objects as "an unordered collection of zero or more name/value pairs". If you do want to preserve the insertion order, you can specialize the object type with containers like [`tsl::ordered_map`](https://github.com/Tessil/ordered-map) ([integration](https://github.com/nlohmann/json/issues/546#issuecomment-304447518)) or [`nlohmann::fifo_map`](https://github.com/nlohmann/fifo_map) ([integration](https://github.com/nlohmann/json/issues/485#issuecomment-333652309)). - ## Execute unit tests From e65cff2a8fca5512898d8bc539bd9002f7f42692 Mon Sep 17 00:00:00 2001 From: Niels Lohmann Date: Fri, 5 Apr 2019 23:31:04 +0200 Subject: [PATCH 061/106] :hammer: small cleanup --- Makefile | 2 +- test/src/unit-allocator.cpp | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index 2a871dc8..c6a1aae5 100644 --- a/Makefile +++ b/Makefile @@ -125,7 +125,7 @@ pedantic_clang: # calling GCC with most warnings pedantic_gcc: - $(MAKE) json_unit CXX=$(COMPILER_DIR)/g++ CXXFLAGS="-D_Atomic=volatile \ + $(MAKE) json_unit CXX=$(COMPILER_DIR)/g++ CXXFLAGS=" \ -std=c++11 \ -Waddress \ -Waddress-of-packed-member \ diff --git a/test/src/unit-allocator.cpp b/test/src/unit-allocator.cpp index 6374640f..c46afc59 100644 --- a/test/src/unit-allocator.cpp +++ b/test/src/unit-allocator.cpp @@ -69,9 +69,9 @@ TEST_CASE("bad_alloc") namespace { -static bool next_construct_fails = false; -static bool next_destroy_fails = false; -static bool next_deallocate_fails = false; +bool next_construct_fails = false; +bool next_destroy_fails = false; +bool next_deallocate_fails = false; template struct my_allocator : std::allocator From b4b06d89b5c55fe1d357ed0878f16e4386b70351 Mon Sep 17 00:00:00 2001 From: Niels Lohmann Date: Sat, 6 Apr 2019 00:24:19 +0200 Subject: [PATCH 062/106] :arrow_up: updated fastcov --- test/CMakeLists.txt | 2 +- test/thirdparty/fastcov/fastcov.py | 253 ++++++++++++++++++++++------- 2 files changed, 192 insertions(+), 63 deletions(-) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index c8bdda47..1a816dbf 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -55,7 +55,7 @@ if(JSON_Coverage) # add target to collect coverage information and generate HTML file # (filter script from https://stackoverflow.com/a/43726240/266378) add_custom_target(lcov_html2 - COMMAND ${CMAKE_SOURCE_DIR}/test/thirdparty/fastcov/fastcov.py --branch-coverage --lcov -o json.info --gcov ${GCOV_BIN} --compiler-directory ${CMAKE_BINARY_DIR} #--source-files ${SOURCE_FILES} + COMMAND ${CMAKE_SOURCE_DIR}/test/thirdparty/fastcov/fastcov.py --branch-coverage --lcov -o json.info --gcov ${GCOV_BIN} --compiler-directory ${CMAKE_BINARY_DIR} --source-files ${SOURCE_FILES} COMMAND ${CMAKE_SOURCE_DIR}/test/thirdparty/imapdl/filterbr.py json.info > json.info.filtered.noexcept COMMAND genhtml --title "JSON for Modern C++" --legend --demangle-cpp --output-directory html --show-details --branch-coverage json.info.filtered.noexcept COMMENT "Generating HTML report test/html/index.html" diff --git a/test/thirdparty/fastcov/fastcov.py b/test/thirdparty/fastcov/fastcov.py index 8fc1eab5..de330078 100755 --- a/test/thirdparty/fastcov/fastcov.py +++ b/test/thirdparty/fastcov/fastcov.py @@ -22,15 +22,17 @@ import os import sys import glob import json +import time import argparse import threading import subprocess import multiprocessing MINIMUM_GCOV = (9,0,0) -MINIMUM_CHUNK_SIZE = 10 +MINIMUM_CHUNK_SIZE = 5 # Interesting metrics +START_TIME = time.time() GCOVS_TOTAL = [] GCOVS_SKIPPED = [] @@ -39,13 +41,28 @@ def chunks(l, n): for i in range(0, len(l), n): yield l[i:i + n] +def stopwatch(): + """Return number of seconds since last time this was called""" + global START_TIME + end_time = time.time() + delta = end_time - START_TIME + START_TIME = end_time + return delta + +def parseVersionFromLine(version_str): + """Given a string containing a dotted integer version, parse out integers and return as tuple""" + version = re.search(r'(\d+\.\d+\.\d+)[^\.]', version_str) + + if not version: + return (0,0,0) + + return tuple(map(int, version.group(1).split("."))) + def getGcovVersion(gcov): p = subprocess.Popen([gcov, "-v"], stdout=subprocess.PIPE) output = p.communicate()[0].decode('UTF-8') p.wait() - version_str = re.search(r'\s([\d.]+)\s', output.split("\n")[0]).group(1) - version = tuple(map(int, version_str.split("."))) - return version + return parseVersionFromLine(output.split("\n")[0]) def removeFiles(files): for file in files: @@ -72,7 +89,7 @@ def gcovWorker(cwd, gcov, files, chunk, gcov_filter_options, branch_coverage): p = subprocess.Popen([gcov, gcov_args] + chunk, cwd=cwd, stdout=subprocess.PIPE, stderr=subprocess.DEVNULL) for line in iter(p.stdout.readline, b''): intermediate_json = json.loads(line.decode(sys.stdout.encoding)) - intermediate_json_files = processGcovs(intermediate_json["files"], gcov_filter_options) + intermediate_json_files = processGcovs(cwd, intermediate_json["files"], gcov_filter_options) for f in intermediate_json_files: files.append(f) #thread safe, there might be a better way to do this though GCOVS_TOTAL.append(len(intermediate_json["files"])) @@ -89,17 +106,19 @@ def processGcdas(cwd, gcov, jobs, gcda_files, gcov_filter_options, branch_covera threads.append(t) t.start() - log("Spawned %d gcov processes each processing at most %d gcda files" % (len(threads), chunk_size)) + log("Spawned %d gcov threads, each processing at most %d gcda files" % (len(threads), chunk_size)) for t in threads: t.join() return intermediate_json_files -def processGcov(gcov, files, gcov_filter_options): +def processGcov(cwd, gcov, files, gcov_filter_options): + # Add absolute path + gcov["file_abs"] = os.path.abspath(os.path.join(cwd, gcov["file"])) + # If explicit sources were passed, check for match - source_file = os.path.abspath(gcov["file"]) if gcov_filter_options["sources"]: - if source_file in gcov_filter_options["sources"]: + if gcov["file_abs"] in gcov_filter_options["sources"]: files.append(gcov) return @@ -118,65 +137,155 @@ def processGcov(gcov, files, gcov_filter_options): files.append(gcov) -def processGcovs(gcov_files, gcov_filter_options): +def processGcovs(cwd, gcov_files, gcov_filter_options): files = [] for gcov in gcov_files: - processGcov(gcov, files, gcov_filter_options) + processGcov(cwd, gcov, files, gcov_filter_options) return files -def dumpBranchCoverageToLcovInfo(f, source): +def dumpBranchCoverageToLcovInfo(f, branches): branch_miss = 0 - branch_total = 0 - for line in source["lines"]: - if not line["branches"]: - continue - branch_total += len(line["branches"]) - for i, branch in enumerate(line["branches"]): + for line_num, branch_counts in branches.items(): + for i, count in enumerate(branch_counts): #Branch (, , , ) - f.write("BRDA:%d,%d,%d,%d\n" % (line["line_number"], int(i/2), i, branch["count"])) - branch_miss += int(branch["count"] == 0) - f.write("BRF:%d\n" % branch_total) #Branches Found - f.write("BRH:%d\n" % (branch_total - branch_miss)) #Branches Hit + f.write("BRDA:%s,%d,%d,%d\n" % (line_num, int(i/2), i, count)) + branch_miss += int(count == 0) + f.write("BRF:%d\n" % len(branches)) #Branches Found + f.write("BRH:%d\n" % (len(branches) - branch_miss)) #Branches Hit -def dumpToLcovInfo(cwd, intermediate, output, branch_coverage): +def dumpToLcovInfo(fastcov_json, output): with open(output, "w") as f: - for source in intermediate: - #Convert to absolute path so it plays nice with genhtml - sf = source["file"] - if not os.path.isabs(source["file"]): - sf = os.path.abspath(os.path.join(cwd, source["file"])) + for sf, data in fastcov_json["sources"].items(): f.write("SF:%s\n" % sf) #Source File fn_miss = 0 - for function in source["functions"]: - f.write("FN:%d,%s\n" % (function["start_line"], function["name"])) #Function Start Line - f.write("FNDA:%d,%s\n" % (function["execution_count"], function["name"])) #Function Hits - fn_miss += int(function["execution_count"] == 0) - f.write("FNF:%d\n" % len(source["functions"])) #Functions Found - f.write("FNH:%d\n" % (len(source["functions"]) - fn_miss)) #Functions Hit + for function, fdata in data["functions"].items(): + f.write("FN:%d,%s\n" % (fdata["start_line"], function)) #Function Start Line + f.write("FNDA:%d,%s\n" % (fdata["execution_count"], function)) #Function Hits + fn_miss += int(fdata["execution_count"] == 0) + f.write("FNF:%d\n" % len(data["functions"])) #Functions Found + f.write("FNH:%d\n" % (len(data["functions"]) - fn_miss)) #Functions Hit - if branch_coverage: - dumpBranchCoverageToLcovInfo(f, source) + if data["branches"]: + dumpBranchCoverageToLcovInfo(f, data["branches"]) line_miss = 0 - for line in source["lines"]: - f.write("DA:%d,%d\n" % (line["line_number"], line["count"])) #Line - line_miss += int(line["count"] == 0) - f.write("LF:%d\n" % len(source["lines"])) #Lines Found - f.write("LH:%d\n" % (len(source["lines"]) - line_miss)) #Lines Hit + for line_num, count in data["lines"].items(): + f.write("DA:%s,%d\n" % (line_num, count)) #Line + line_miss += int(count == 0) + f.write("LF:%d\n" % len(data["lines"])) #Lines Found + f.write("LH:%d\n" % (len(data["lines"]) - line_miss)) #Lines Hit f.write("end_of_record\n") -def dumpToGcovJson(intermediate, output): +def exclMarkerWorker(fastcov_sources, chunk): + for source in chunk: + # If there are no covered lines, skip + if not fastcov_sources[source]["lines"]: + continue + + start_line = 0 + end_line = 0 + with open(source) as f: + for i, line in enumerate(f, 1): #Start enumeration at line 1 + if not "LCOV_EXCL" in line: + continue + + if "LCOV_EXCL_LINE" in line: + if str(i) in fastcov_sources[source]["lines"]: + del fastcov_sources[source]["lines"][str(i)] + if str(i) in fastcov_sources[source]["branches"]: + del fastcov_sources[source]["branches"][str(i)] + elif "LCOV_EXCL_START" in line: + start_line = i + elif "LCOV_EXCL_STOP" in line: + end_line = i + + if not start_line: + end_line = 0 + continue + + for key in ["lines", "branches"]: + for line_num in list(fastcov_sources[source][key].keys()): + if int(line_num) <= end_line and int(line_num) >= start_line: + del fastcov_sources[source][key][line_num] + + start_line = end_line = 0 + +def scanExclusionMarkers(fastcov_json, jobs): + chunk_size = max(MINIMUM_CHUNK_SIZE, int(len(fastcov_json["sources"]) / jobs) + 1) + + threads = [] + for chunk in chunks(list(fastcov_json["sources"].keys()), chunk_size): + t = threading.Thread(target=exclMarkerWorker, args=(fastcov_json["sources"], chunk)) + threads.append(t) + t.start() + + log("Spawned %d threads each scanning at most %d source files" % (len(threads), chunk_size)) + for t in threads: + t.join() + +def distillFunction(function_raw, functions): + function_name = function_raw["name"] + if function_name not in functions: + functions[function_name] = { + "start_line": function_raw["start_line"], + "execution_count": function_raw["execution_count"] + } + else: + functions[function_name]["execution_count"] += function_raw["execution_count"] + +def distillLine(line_raw, lines, branches): + line_number = str(line_raw["line_number"]) + if line_number not in lines: + lines[line_number] = line_raw["count"] + else: + lines[line_number] += line_raw["count"] + + for i, branch in enumerate(line_raw["branches"]): + if line_number not in branches: + branches[line_number] = [] + blen = len(branches[line_number]) + glen = len(line_raw["branches"]) + if blen < glen: + branches[line_number] += [0] * (glen - blen) + branches[line_number][i] += branch["count"] + +def distillSource(source_raw, sources): + source_name = source_raw["file_abs"] + if source_name not in sources: + sources[source_name] = { + "functions": {}, + "branches": {}, + "lines": {}, + } + + for function in source_raw["functions"]: + distillFunction(function, sources[source_name]["functions"]) + + for line in source_raw["lines"]: + distillLine(line, sources[source_name]["lines"], sources[source_name]["branches"]) + +def distillReport(report_raw): + report_json = { + "sources": {} + } + + for source in report_raw: + distillSource(source, report_json["sources"]) + + return report_json + +def dumpToJson(intermediate, output): with open(output, "w") as f: json.dump(intermediate, f) def log(line): if not args.quiet: - print(line) + print("[{:.3f}s] {}".format(stopwatch(), line)) def getGcovFilterOptions(args): return { - "sources": set([os.path.abspath(s) for s in args.sources]), #Make paths absolute + "sources": set([os.path.abspath(s) for s in args.sources]), #Make paths absolute, use set for fast lookups "include": args.includepost, "exclude": args.excludepost, } @@ -188,33 +297,47 @@ def main(args): sys.stderr.write("Minimum gcov version {} required, found {}\n".format(".".join(map(str, MINIMUM_GCOV)), ".".join(map(str, current_gcov_version)))) exit(1) + # Get list of gcda files to process gcda_files = getGcdaFiles(args.directory, args.gcda_files) - log("%d .gcda files" % len(gcda_files)) + log("Found {} .gcda files ".format(len(gcda_files))) + # If gcda filtering is enabled, filter them out now if args.excludepre: gcda_files = getFilteredGcdaFiles(gcda_files, args.excludepre) - log("%d .gcda files after filtering" % len(gcda_files)) + log("{} .gcda files after filtering".format(len(gcda_files))) # We "zero" the "counters" by simply deleting all gcda files if args.zerocounters: removeFiles(gcda_files) - log("%d .gcda files removed" % len(gcda_files)) + log("{} .gcda files removed".format(len(gcda_files))) return + # Fire up one gcov per cpu and start processing gcdas gcov_filter_options = getGcovFilterOptions(args) intermediate_json_files = processGcdas(args.cdirectory, args.gcov, args.jobs, gcda_files, gcov_filter_options, args.branchcoverage) + # Summarize processing results gcov_total = sum(GCOVS_TOTAL) gcov_skipped = sum(GCOVS_SKIPPED) - log("%d .gcov files generated by gcov" % gcov_total) - log("%d .gcov files processed by fastcov (%d skipped)" % (gcov_total - gcov_skipped, gcov_skipped)) + log("Processed {} .gcov files ({} total, {} skipped)".format(gcov_total - gcov_skipped, gcov_total, gcov_skipped)) + # Distill all the extraneous info gcov gives us down to the core report + fastcov_json = distillReport(intermediate_json_files) + log("Aggregated raw gcov JSON into fastcov JSON report") + + # Dump to desired file format if args.lcov: - dumpToLcovInfo(args.cdirectory, intermediate_json_files, args.output, args.branchcoverage) - log("Created lcov info file '%s'" % args.output) + scanExclusionMarkers(fastcov_json, args.jobs) + log("Scanned {} source files for exclusion markers".format(len(fastcov_json["sources"]))) + dumpToLcovInfo(fastcov_json, args.output) + log("Created lcov info file '{}'".format(args.output)) + elif args.gcov_raw: + dumpToJson(intermediate_json_files, args.output) + log("Created gcov raw json file '{}'".format(args.output)) else: - dumpToGcovJson(intermediate_json_files, args.output) - log("Created gcov json file '%s'" % args.output) + dumpToJson(fastcov_json, args.output) + log("Created fastcov json file '{}'".format(args.output)) + if __name__ == '__main__': parser = argparse.ArgumentParser(description='A parallel gcov wrapper for fast coverage report generation') @@ -224,20 +347,26 @@ if __name__ == '__main__': parser.add_argument('-b', '--branch-coverage', dest='branchcoverage', action="store_true", help='Include branch counts in the coverage report') # Filtering Options - parser.add_argument('-s', '--source-files', dest='sources', nargs="+", default=[], help='Filter: Specify exactly which source files should be included in the final report. Paths must be either absolute or relative to current directory.') - parser.add_argument('-e', '--exclude', dest='excludepost', nargs="+", default=[], help='Filter: Exclude source files from final report if they contain one of the provided substrings (i.e. /usr/include test/, etc.)') - parser.add_argument('-i', '--include', dest='includepost', nargs="+", default=[], help='Filter: Only include source files in final report that contain one of the provided substrings (i.e. src/ etc.)') - parser.add_argument('-f', '--gcda-files', dest='gcda_files', nargs="+", default=[], help='Filter: Specify exactly which gcda files should be processed instead of recursively searching the search directory.') - parser.add_argument('-E', '--exclude-gcda', dest='excludepre', nargs="+", default=[], help='Filter: Exclude gcda files from being processed via simple find matching (not regex)') + parser.add_argument('-s', '--source-files', dest='sources', nargs="+", metavar='', default=[], help='Filter: Specify exactly which source files should be included in the final report. Paths must be either absolute or relative to current directory.') + parser.add_argument('-e', '--exclude', dest='excludepost', nargs="+", metavar='', default=[], help='Filter: Exclude source files from final report if they contain one of the provided substrings (i.e. /usr/include test/, etc.)') + parser.add_argument('-i', '--include', dest='includepost', nargs="+", metavar='', default=[], help='Filter: Only include source files in final report that contain one of the provided substrings (i.e. src/ etc.)') + parser.add_argument('-f', '--gcda-files', dest='gcda_files', nargs="+", metavar='', default=[], help='Filter: Specify exactly which gcda files should be processed instead of recursively searching the search directory.') + parser.add_argument('-E', '--exclude-gcda', dest='excludepre', nargs="+", metavar='', default=[], help='Filter: Exclude gcda files from being processed via simple find matching (not regex)') parser.add_argument('-g', '--gcov', dest='gcov', default='gcov', help='Which gcov binary to use') parser.add_argument('-d', '--search-directory', dest='directory', default=".", help='Base directory to recursively search for gcda files (default: .)') - parser.add_argument('-c', '--compiler-directory', dest='cdirectory', default=".", help='Base directory compiler was invoked from (default: .)') - parser.add_argument('-j', '--jobs', dest='jobs', type=int, default=multiprocessing.cpu_count(), help='Number of parallel gcov to spawn (default: %d).' % multiprocessing.cpu_count()) + parser.add_argument('-c', '--compiler-directory', dest='cdirectory', default=".", help='Base directory compiler was invoked from (default: .) \ + This needs to be set if invoking fastcov from somewhere other than the base compiler directory.') - parser.add_argument('-o', '--output', dest='output', default="coverage.json", help='Name of output file (default: coverage.json)') - parser.add_argument('-l', '--lcov', dest='lcov', action="store_true", help='Output in lcov info format instead of gcov json') + parser.add_argument('-j', '--jobs', dest='jobs', type=int, default=multiprocessing.cpu_count(), help='Number of parallel gcov to spawn (default: %d).' % multiprocessing.cpu_count()) + parser.add_argument('-m', '--minimum-chunk-size', dest='minimum_chunk', type=int, default=5, help='Minimum number of files a thread should process (default: 5). \ + If you have only 4 gcda files but they are monstrously huge, you could change this value to a 1 so that each thread will only process 1 gcda. Otherise fastcov will spawn only 1 thread to process all of them.') + + parser.add_argument('-l', '--lcov', dest='lcov', action="store_true", help='Output in lcov info format instead of fastcov json') + parser.add_argument('-r', '--gcov-raw', dest='gcov_raw', action="store_true", help='Output in gcov raw json instead of fastcov json') + parser.add_argument('-o', '--output', dest='output', default="coverage.json", help='Name of output file (default: coverage.json)') parser.add_argument('-q', '--quiet', dest='quiet', action="store_true", help='Suppress output to stdout') + args = parser.parse_args() main(args) \ No newline at end of file From f0bc16d89985b22235c14c42b07fec343e82a00d Mon Sep 17 00:00:00 2001 From: Niels Lohmann Date: Sat, 6 Apr 2019 09:02:17 +0200 Subject: [PATCH 063/106] :hammer: overworked coverage targets --- Makefile | 5 +++-- README.md | 2 ++ test/CMakeLists.txt | 16 +++++++--------- 3 files changed, 12 insertions(+), 11 deletions(-) diff --git a/Makefile b/Makefile index 2de47b19..46a33b4b 100644 --- a/Makefile +++ b/Makefile @@ -35,6 +35,7 @@ all: @echo "check-fast - compile and execute test suite (skip long-running tests)" @echo "clean - remove built files" @echo "coverage - create coverage information with lcov" + @echo "coverage-fast - create coverage information with fastcov" @echo "cppcheck - analyze code with cppcheck" @echo "cpplint - analyze code with cpplint" @echo "clang_tidy - analyze code with Clang-Tidy" @@ -82,13 +83,13 @@ coverage: cd build_coverage ; ninja lcov_html open build_coverage/test/html/index.html -fast-cov: +coverage-fast: rm -fr build_coverage mkdir build_coverage cd build_coverage ; CXX=$(COMPILER_DIR)/g++ cmake .. -GNinja -DJSON_Coverage=ON -DJSON_MultipleHeaders=ON cd build_coverage ; ninja cd build_coverage ; ctest -E '.*_default' -j10 - cd build_coverage ; ninja lcov_html2 + cd build_coverage ; ninja fastcov_html open build_coverage/test/html/index.html ########################################################################## diff --git a/README.md b/README.md index f05af440..ee0e249f 100644 --- a/README.md +++ b/README.md @@ -1279,9 +1279,11 @@ The library itself consists of a single header file licensed under the MIT licen - [**doctest**](https://github.com/onqtam/doctest) for the unit tests - [**Doozer**](https://doozer.io) for [continuous integration](https://doozer.io/nlohmann/json) on Linux (CentOS, Raspbian, Fedora) - [**Doxygen**](http://www.stack.nl/~dimitri/doxygen/) to generate [documentation](https://nlohmann.github.io/json/) +- [**fastcov**](https://github.com/RPGillespie6/fastcov) to process coverage information - [**git-update-ghpages**](https://github.com/rstacruz/git-update-ghpages) to upload the documentation to gh-pages - [**GitHub Changelog Generator**](https://github.com/skywinder/github-changelog-generator) to generate the [ChangeLog](https://github.com/nlohmann/json/blob/develop/ChangeLog.md) - [**Google Benchmark**](https://github.com/google/benchmark) to implement the benchmarks +- [**lcov**](http://ltp.sourceforge.net/coverage/lcov.php) to process coverage information and create a HTML view - [**libFuzzer**](http://llvm.org/docs/LibFuzzer.html) to implement fuzz testing for OSS-Fuzz - [**OSS-Fuzz**](https://github.com/google/oss-fuzz) for continuous fuzz testing of the library ([project repository](https://github.com/google/oss-fuzz/tree/master/projects/json)) - [**Probot**](https://probot.github.io) for automating maintainer tasks such as closing stale issues, requesting missing information, or detecting toxic comments. diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 1a816dbf..b73dfc9a 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -27,9 +27,9 @@ endif() if(JSON_Coverage) message(STATUS "Building test suite with coverage information") - #if(NOT "${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") - # message(FATAL_ERROR "JSON_Coverage requires GCC.") - #endif() + if(NOT "${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") + message(FATAL_ERROR "JSON_Coverage requires GCC.") + endif() # enable profiling set(CMAKE_CXX_FLAGS "--coverage -g -O0 -fprofile-arcs -ftest-coverage") @@ -46,18 +46,16 @@ if(JSON_Coverage) # (filter script from https://stackoverflow.com/a/43726240/266378) add_custom_target(lcov_html COMMAND lcov --directory . --capture --output-file json.info --rc lcov_branch_coverage=1 - COMMAND lcov -e json.info ${SOURCE_FILES} --output-file json.info.filtered --rc lcov_branch_coverage=1 + COMMAND lcov -e json.info ${SOURCE_FILES} --output-file json.info.filtered --gcov-tool ${GCOV_BIN} --rc lcov_branch_coverage=1 COMMAND ${CMAKE_SOURCE_DIR}/test/thirdparty/imapdl/filterbr.py json.info.filtered > json.info.filtered.noexcept COMMAND genhtml --title "JSON for Modern C++" --legend --demangle-cpp --output-directory html --show-details --branch-coverage json.info.filtered.noexcept COMMENT "Generating HTML report test/html/index.html" ) - # add target to collect coverage information and generate HTML file - # (filter script from https://stackoverflow.com/a/43726240/266378) - add_custom_target(lcov_html2 + add_custom_target(fastcov_html COMMAND ${CMAKE_SOURCE_DIR}/test/thirdparty/fastcov/fastcov.py --branch-coverage --lcov -o json.info --gcov ${GCOV_BIN} --compiler-directory ${CMAKE_BINARY_DIR} --source-files ${SOURCE_FILES} - COMMAND ${CMAKE_SOURCE_DIR}/test/thirdparty/imapdl/filterbr.py json.info > json.info.filtered.noexcept - COMMAND genhtml --title "JSON for Modern C++" --legend --demangle-cpp --output-directory html --show-details --branch-coverage json.info.filtered.noexcept + COMMAND ${CMAKE_SOURCE_DIR}/test/thirdparty/imapdl/filterbr.py json.info > json.info.noexcept + COMMAND genhtml --title "JSON for Modern C++" --legend --demangle-cpp --output-directory html --show-details --branch-coverage json.info.noexcept COMMENT "Generating HTML report test/html/index.html" ) endif() From 293cd6b7940cc7ceab3ad3617fb9f47b3988826a Mon Sep 17 00:00:00 2001 From: Macr0Nerd Date: Thu, 25 Apr 2019 22:12:15 -0500 Subject: [PATCH 064/106] Added to_string and added basic tests --- include/nlohmann/json.hpp | 14 ++++++++++++++ single_include/nlohmann/json.hpp | 14 ++++++++++++++ test/src/unit-serialization.cpp | 15 +++++++++++++++ 3 files changed, 43 insertions(+) diff --git a/include/nlohmann/json.hpp b/include/nlohmann/json.hpp index 017ce929..43d7eac4 100644 --- a/include/nlohmann/json.hpp +++ b/include/nlohmann/json.hpp @@ -7965,6 +7965,20 @@ class basic_json /// @} }; + +/*! +@brief user-defined to_string function for JSON values + +This function implements a user-defined to_string for JSON objects. + +@param[in] j a JSON object +@return a std::string object +*/ + +template +std::string to_string(const T& j){ + return j.dump(); +} } // namespace nlohmann /////////////////////// diff --git a/single_include/nlohmann/json.hpp b/single_include/nlohmann/json.hpp index 1f82da44..c13473e6 100644 --- a/single_include/nlohmann/json.hpp +++ b/single_include/nlohmann/json.hpp @@ -20766,6 +20766,20 @@ class basic_json /// @} }; + +/*! +@brief user-defined to_string function for JSON values + +This function implements a user-defined to_string for JSON objects. + +@param[in] j a JSON object +@return a std::string object +*/ + +template +std::string to_string(const T& j){ + return j.dump(); +} } // namespace nlohmann /////////////////////// diff --git a/test/src/unit-serialization.cpp b/test/src/unit-serialization.cpp index 785373f0..7df2bf9c 100644 --- a/test/src/unit-serialization.cpp +++ b/test/src/unit-serialization.cpp @@ -173,4 +173,19 @@ TEST_CASE("serialization") test("\xE1\x80\xE2\xF0\x91\x92\xF1\xBF\x41", "\\ufffd" "\\ufffd" "\\ufffd" "\\ufffd" "\x41"); } } + + SECTION("to_string") + { + auto test = [&](std::string const & input, std::string const & expected) + { + using std::to_string; + json j = input; + CHECK(to_string(j) == "\"" + expected + "\""); + }; + + test("{\"x\":5,\"y\":6}", "{\\\"x\\\":5,\\\"y\\\":6}"); + test("{\"x\":[10,null,null,null]}", "{\\\"x\\\":[10,null,null,null]}"); + test("test", "test"); + test("[3,\"false\",false]", "[3,\\\"false\\\",false]"); + } } From aa4c45ee4d3842452843a1ea728049b745751dc1 Mon Sep 17 00:00:00 2001 From: Macr0Nerd Date: Thu, 25 Apr 2019 22:12:15 -0500 Subject: [PATCH 065/106] Added to_string (with ugly macro) and tests --- include/nlohmann/json.hpp | 15 +++++++++++++++ single_include/nlohmann/json.hpp | 15 +++++++++++++++ test/src/unit-serialization.cpp | 15 +++++++++++++++ 3 files changed, 45 insertions(+) diff --git a/include/nlohmann/json.hpp b/include/nlohmann/json.hpp index 017ce929..daaf2d66 100644 --- a/include/nlohmann/json.hpp +++ b/include/nlohmann/json.hpp @@ -7965,6 +7965,21 @@ class basic_json /// @} }; + +/*! +@brief user-defined to_string function for JSON values + +This function implements a user-defined to_string for JSON objects. + +@param[in] j a JSON object +@return a std::string object +*/ + +NLOHMANN_BASIC_JSON_TPL_DECLARATION +std::string to_string(const NLOHMANN_BASIC_JSON_TPL& j) +{ + return j.dump(); +} } // namespace nlohmann /////////////////////// diff --git a/single_include/nlohmann/json.hpp b/single_include/nlohmann/json.hpp index 1f82da44..08ac166b 100644 --- a/single_include/nlohmann/json.hpp +++ b/single_include/nlohmann/json.hpp @@ -20766,6 +20766,21 @@ class basic_json /// @} }; + +/*! +@brief user-defined to_string function for JSON values + +This function implements a user-defined to_string for JSON objects. + +@param[in] j a JSON object +@return a std::string object +*/ + +NLOHMANN_BASIC_JSON_TPL_DECLARATION +std::string to_string(const NLOHMANN_BASIC_JSON_TPL& j) +{ + return j.dump(); +} } // namespace nlohmann /////////////////////// diff --git a/test/src/unit-serialization.cpp b/test/src/unit-serialization.cpp index 785373f0..7df2bf9c 100644 --- a/test/src/unit-serialization.cpp +++ b/test/src/unit-serialization.cpp @@ -173,4 +173,19 @@ TEST_CASE("serialization") test("\xE1\x80\xE2\xF0\x91\x92\xF1\xBF\x41", "\\ufffd" "\\ufffd" "\\ufffd" "\\ufffd" "\x41"); } } + + SECTION("to_string") + { + auto test = [&](std::string const & input, std::string const & expected) + { + using std::to_string; + json j = input; + CHECK(to_string(j) == "\"" + expected + "\""); + }; + + test("{\"x\":5,\"y\":6}", "{\\\"x\\\":5,\\\"y\\\":6}"); + test("{\"x\":[10,null,null,null]}", "{\\\"x\\\":[10,null,null,null]}"); + test("test", "test"); + test("[3,\"false\",false]", "[3,\\\"false\\\",false]"); + } } From 40c3d5024a62a280d555e44c026fd4ca065026c1 Mon Sep 17 00:00:00 2001 From: Isaac Nickaein Date: Sun, 12 May 2019 22:04:01 +0430 Subject: [PATCH 066/106] Fix broken links to documentation Fixes #1597 and some other links --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 67dc4e07..670d7e1e 100644 --- a/README.md +++ b/README.md @@ -243,7 +243,7 @@ json j2 = { }; ``` -Note that in all these cases, you never need to "tell" the compiler which JSON value type you want to use. If you want to be explicit or express some edge cases, the functions [`json::array`](https://nlohmann.github.io/json/classnlohmann_1_1basic__json_aa80485befaffcadaa39965494e0b4d2e.html#aa80485befaffcadaa39965494e0b4d2e) and [`json::object`](https://nlohmann.github.io/json/classnlohmann_1_1basic__json_aa13f7c0615867542ce80337cbcf13ada.html#aa13f7c0615867542ce80337cbcf13ada) will help: +Note that in all these cases, you never need to "tell" the compiler which JSON value type you want to use. If you want to be explicit or express some edge cases, the functions [`json::array()`](https://nlohmann.github.io/json/classnlohmann_1_1basic__json_a9ad7ec0bc1082ed09d10900fbb20a21f.html#a9ad7ec0bc1082ed09d10900fbb20a21f) and [`json::object()`](https://nlohmann.github.io/json/classnlohmann_1_1basic__json_aaf509a7c029100d292187068f61c99b8.html#aaf509a7c029100d292187068f61c99b8) will help: ```cpp // a way to express the empty array [] @@ -278,7 +278,7 @@ auto j2 = R"( Note that without appending the `_json` suffix, the passed string literal is not parsed, but just used as JSON string value. That is, `json j = "{ \"happy\": true, \"pi\": 3.141 }"` would just store the string `"{ "happy": true, "pi": 3.141 }"` rather than parsing the actual object. -The above example can also be expressed explicitly using [`json::parse()`](https://nlohmann.github.io/json/classnlohmann_1_1basic__json_a5a0339361f3282cb8fd2f9ede6e17d72.html#a5a0339361f3282cb8fd2f9ede6e17d72): +The above example can also be expressed explicitly using [`json::parse()`](https://nlohmann.github.io/json/classnlohmann_1_1basic__json_afd4ef1ac8ad50a5894a9afebca69140a.html#afd4ef1ac8ad50a5894a9afebca69140a): ```cpp // parse explicitly @@ -321,7 +321,7 @@ std::cout << cpp_string << " == " << cpp_string2 << " == " << j_string.get()`](https://nlohmann.github.io/json/classnlohmann_1_1basic__json_a16f9445f7629f634221a42b967cdcd43.html#a16f9445f7629f634221a42b967cdcd43) returns the originally stored string value. +[`.dump()`](https://nlohmann.github.io/json/classnlohmann_1_1basic__json_a50ec80b02d0f3f51130d4abb5d1cfdc5.html#a50ec80b02d0f3f51130d4abb5d1cfdc5) always returns the serialized value, and [`.get()`](https://nlohmann.github.io/json/classnlohmann_1_1basic__json_aa6602bb24022183ab989439e19345d08.html#aa6602bb24022183ab989439e19345d08) returns the originally stored string value. Note the library only supports UTF-8. When you store strings with different encodings in the library, calling [`dump()`](https://nlohmann.github.io/json/classnlohmann_1_1basic__json_a50ec80b02d0f3f51130d4abb5d1cfdc5.html#a50ec80b02d0f3f51130d4abb5d1cfdc5) may throw an exception unless `json::error_handler_t::replace` or `json::error_handler_t::ignore` are used as error handlers. From 0d55ddc5bf67e2664df40f767ad0eed47c2237a7 Mon Sep 17 00:00:00 2001 From: Isaac Nickaein Date: Tue, 4 Jun 2019 11:24:22 +0430 Subject: [PATCH 067/106] :pencil2: Fix a typo in README --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 670d7e1e..a1e6edfb 100644 --- a/README.md +++ b/README.md @@ -1325,7 +1325,7 @@ This library does not support comments. It does so for three reasons: > Suppose you are using JSON to keep configuration files, which you would like to annotate. Go ahead and insert all the comments you like. Then pipe it through JSMin before handing it to your JSON parser. -3. It dangerous for interoperability if some libraries would add comment support while others don't. Please check [The Harmful Consequences of the Robustness Principle](https://tools.ietf.org/html/draft-iab-protocol-maintenance-01) on this. +3. It is dangerous for interoperability if some libraries would add comment support while others don't. Please check [The Harmful Consequences of the Robustness Principle](https://tools.ietf.org/html/draft-iab-protocol-maintenance-01) on this. This library will not support comments in the future. If you wish to use comments, I see three options: From b22c577e83873f991128e0f1f65de3a5226e9968 Mon Sep 17 00:00:00 2001 From: Isaac Nickaein Date: Tue, 4 Jun 2019 11:25:44 +0430 Subject: [PATCH 068/106] :pencil2: Fix brew instructions in README --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index a1e6edfb..4104418d 100644 --- a/README.md +++ b/README.md @@ -150,7 +150,7 @@ endif() ### Package Managers -:beer: If you are using OS X and [Homebrew](http://brew.sh), just type `brew tap nlohmann/json` and `brew install nlohmann_json` and you're set. If you want the bleeding edge rather than the latest release, use `brew install nlohmann_json --HEAD`. +:beer: If you are using OS X and [Homebrew](http://brew.sh), just type `brew tap nlohmann/json` and `brew install nlohmann-json` and you're set. If you want the bleeding edge rather than the latest release, use `brew install nlohmann-json --HEAD`. If you are using the [Meson Build System](http://mesonbuild.com), then you can get a wrap file by downloading it from [Meson WrapDB](https://wrapdb.mesonbuild.com/nlohmann_json), or simply use `meson wrap install nlohmann_json`. From 0c214949f5eefaf420e8994e1192b70e9a8fc339 Mon Sep 17 00:00:00 2001 From: Isaac Nickaein Date: Tue, 4 Jun 2019 11:27:10 +0430 Subject: [PATCH 069/106] :pencil2: Fix links to create an issue page --- .github/CONTRIBUTING.md | 6 +++--- README.md | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index f274b10d..2287cad4 100644 --- a/.github/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -4,7 +4,7 @@ This project started as a little excuse to exercise some of the cool new C++11 features. Over time, people actually started to use the JSON library (yey!) and started to help improve it by proposing features, finding bugs, or even fixing my mistakes. I am really [thankful](https://github.com/nlohmann/json/blob/master/README.md#thanks) for this and try to keep track of all the helpers. -To make it as easy as possible for you to contribute and for me to keep an overview, here are a few guidelines which should help us avoid all kinds of unnecessary work or disappointment. And of course, this document is subject to discussion, so please [create an issue](https://github.com/nlohmann/json/issues/new) or a pull request if you find a way to improve it! +To make it as easy as possible for you to contribute and for me to keep an overview, here are a few guidelines which should help us avoid all kinds of unnecessary work or disappointment. And of course, this document is subject to discussion, so please [create an issue](https://github.com/nlohmann/json/issues/new/choose) or a pull request if you find a way to improve it! ## Private reports @@ -12,7 +12,7 @@ Usually, all issues are tracked publicly on [GitHub](https://github.com/nlohmann ## Prerequisites -Please [create an issue](https://github.com/nlohmann/json/issues/new), assuming one does not already exist, and describe your concern. Note you need a [GitHub account](https://github.com/signup/free) for this. +Please [create an issue](https://github.com/nlohmann/json/issues/new/choose), assuming one does not already exist, and describe your concern. Note you need a [GitHub account](https://github.com/signup/free) for this. ## Describe your issue @@ -22,7 +22,7 @@ Clearly describe the issue: - If you propose a change or addition, try to give an **example** how the improved code could look like or how to use it. - If you found a compilation error, please tell us which **compiler** (version and operating system) you used and paste the (relevant part of) the error messages to the ticket. -Please stick to the [issue template](https://github.com/nlohmann/json/blob/develop/.github/ISSUE_TEMPLATE.md) if possible. +Please stick to the provided issue templates ([bug report](https://github.com/nlohmann/json/blob/develop/.github/ISSUE_TEMPLATE/Bug_report.md), [feature request](https://github.com/nlohmann/json/blob/develop/.github/ISSUE_TEMPLATE/Feature_request.md), or [question](https://github.com/nlohmann/json/blob/develop/.github/ISSUE_TEMPLATE/question.md)) if possible. ## Files to change diff --git a/README.md b/README.md index 4104418d..9ebd0789 100644 --- a/README.md +++ b/README.md @@ -1078,7 +1078,7 @@ The class contains a slightly modified version of the Grisu2 algorithm from Flor ## Contact -If you have questions regarding the library, I would like to invite you to [open an issue at GitHub](https://github.com/nlohmann/json/issues/new). Please describe your request, problem, or question as detailed as possible, and also mention the version of the library you are using as well as the version of your compiler and operating system. Opening an issue at GitHub allows other users and contributors to this library to collaborate. For instance, I have little experience with MSVC, and most issues in this regard have been solved by a growing community. If you have a look at the [closed issues](https://github.com/nlohmann/json/issues?q=is%3Aissue+is%3Aclosed), you will see that we react quite timely in most cases. +If you have questions regarding the library, I would like to invite you to [open an issue at GitHub](https://github.com/nlohmann/json/issues/new/choose). Please describe your request, problem, or question as detailed as possible, and also mention the version of the library you are using as well as the version of your compiler and operating system. Opening an issue at GitHub allows other users and contributors to this library to collaborate. For instance, I have little experience with MSVC, and most issues in this regard have been solved by a growing community. If you have a look at the [closed issues](https://github.com/nlohmann/json/issues?q=is%3Aissue+is%3Aclosed), you will see that we react quite timely in most cases. Only if your request would contain confidential information, please [send me an email](mailto:mail@nlohmann.me). For encrypted messages, please use [this key](https://keybase.io/nlohmann/pgp_keys.asc). From 2f389cdde72ccb978644e6ce48629981139d6495 Mon Sep 17 00:00:00 2001 From: Taylor Howard Date: Sun, 16 Jun 2019 14:49:01 +1000 Subject: [PATCH 070/106] Added explicit converstion to std::string_view. Fixes failing test with GCC 8.3 --- test/src/unit-conversions.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/src/unit-conversions.cpp b/test/src/unit-conversions.cpp index 275d5270..fa75428c 100644 --- a/test/src/unit-conversions.cpp +++ b/test/src/unit-conversions.cpp @@ -613,7 +613,7 @@ TEST_CASE("value conversion") #if defined(JSON_HAS_CPP_17) SECTION("std::string_view") { - std::string_view s = j; + std::string_view s = j.get(); CHECK(json(s) == j); } #endif From f4fca2d59ab9d02f5b602ef70f9955ec63b3cc6d Mon Sep 17 00:00:00 2001 From: kevinlul <6320810+kevinlul@users.noreply.github.com> Date: Sun, 16 Jun 2019 18:22:40 -0400 Subject: [PATCH 071/106] Fix #1642 While in our case, only the string case was affected, to be safe and allow the library to work with other unforeseen cases, all of the cases have been wrapped with parentheses. Thank you @DyXel and @edo9300 --- include/nlohmann/json.hpp | 12 ++++++------ single_include/nlohmann/json.hpp | 12 ++++++------ 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/include/nlohmann/json.hpp b/include/nlohmann/json.hpp index daaf2d66..6aeb33dd 100644 --- a/include/nlohmann/json.hpp +++ b/include/nlohmann/json.hpp @@ -5746,25 +5746,25 @@ class basic_json return (*lhs.m_value.array) < (*rhs.m_value.array); case value_t::object: - return *lhs.m_value.object < *rhs.m_value.object; + return (*lhs.m_value.object) < (*rhs.m_value.object); case value_t::null: return false; case value_t::string: - return *lhs.m_value.string < *rhs.m_value.string; + return (*lhs.m_value.string) < (*rhs.m_value.string); case value_t::boolean: - return lhs.m_value.boolean < rhs.m_value.boolean; + return (lhs.m_value.boolean) < (rhs.m_value.boolean); case value_t::number_integer: - return lhs.m_value.number_integer < rhs.m_value.number_integer; + return (lhs.m_value.number_integer) < (rhs.m_value.number_integer); case value_t::number_unsigned: - return lhs.m_value.number_unsigned < rhs.m_value.number_unsigned; + return (lhs.m_value.number_unsigned) < (rhs.m_value.number_unsigned); case value_t::number_float: - return lhs.m_value.number_float < rhs.m_value.number_float; + return (lhs.m_value.number_float) < (rhs.m_value.number_float); default: return false; diff --git a/single_include/nlohmann/json.hpp b/single_include/nlohmann/json.hpp index 08ac166b..d06cde78 100644 --- a/single_include/nlohmann/json.hpp +++ b/single_include/nlohmann/json.hpp @@ -18547,25 +18547,25 @@ class basic_json return (*lhs.m_value.array) < (*rhs.m_value.array); case value_t::object: - return *lhs.m_value.object < *rhs.m_value.object; + return (*lhs.m_value.object) < (*rhs.m_value.object); case value_t::null: return false; case value_t::string: - return *lhs.m_value.string < *rhs.m_value.string; + return (*lhs.m_value.string) < (*rhs.m_value.string); case value_t::boolean: - return lhs.m_value.boolean < rhs.m_value.boolean; + return (lhs.m_value.boolean) < (rhs.m_value.boolean); case value_t::number_integer: - return lhs.m_value.number_integer < rhs.m_value.number_integer; + return (lhs.m_value.number_integer) < (rhs.m_value.number_integer); case value_t::number_unsigned: - return lhs.m_value.number_unsigned < rhs.m_value.number_unsigned; + return (lhs.m_value.number_unsigned) < (rhs.m_value.number_unsigned); case value_t::number_float: - return lhs.m_value.number_float < rhs.m_value.number_float; + return (lhs.m_value.number_float) < (rhs.m_value.number_float); default: return false; From 3b82a350ed2e567e9e6e0ddfdd688c6625128be6 Mon Sep 17 00:00:00 2001 From: Niels Lohmann Date: Sat, 22 Jun 2019 09:44:12 +0200 Subject: [PATCH 072/106] :memo: mention 302 exception in value() documentation #1601 --- include/nlohmann/json.hpp | 4 ++++ single_include/nlohmann/json.hpp | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/include/nlohmann/json.hpp b/include/nlohmann/json.hpp index daaf2d66..58db19d7 100644 --- a/include/nlohmann/json.hpp +++ b/include/nlohmann/json.hpp @@ -3388,6 +3388,8 @@ class basic_json @return copy of the element at key @a key or @a default_value if @a key is not found + @throw type_error.302 if @a default_value does not match the type of the + value at @a key @throw type_error.306 if the JSON value is not an object; in that case, using `value()` with a key makes no sense. @@ -3461,6 +3463,8 @@ class basic_json @return copy of the element at key @a key or @a default_value if @a key is not found + @throw type_error.302 if @a default_value does not match the type of the + value at @a ptr @throw type_error.306 if the JSON value is not an object; in that case, using `value()` with a key makes no sense. diff --git a/single_include/nlohmann/json.hpp b/single_include/nlohmann/json.hpp index 08ac166b..bb2dacbc 100644 --- a/single_include/nlohmann/json.hpp +++ b/single_include/nlohmann/json.hpp @@ -16189,6 +16189,8 @@ class basic_json @return copy of the element at key @a key or @a default_value if @a key is not found + @throw type_error.302 if @a default_value does not match the type of the + value at @a key @throw type_error.306 if the JSON value is not an object; in that case, using `value()` with a key makes no sense. @@ -16262,6 +16264,8 @@ class basic_json @return copy of the element at key @a key or @a default_value if @a key is not found + @throw type_error.302 if @a default_value does not match the type of the + value at @a ptr @throw type_error.306 if the JSON value is not an object; in that case, using `value()` with a key makes no sense. From 39011a1759387440dc6afa32c90772b557206c5e Mon Sep 17 00:00:00 2001 From: Niels Lohmann Date: Sat, 22 Jun 2019 09:54:59 +0200 Subject: [PATCH 073/106] :memo: mention json type in documentation start page #1616 --- doc/index.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/doc/index.md b/doc/index.md index 85bd9011..9b2ca947 100644 --- a/doc/index.md +++ b/doc/index.md @@ -4,7 +4,9 @@ These pages contain the API documentation of JSON for Modern C++, a C++11 header # Contents -- @link nlohmann::basic_json `basic_json` class @endlink +- Classes + - @link nlohmann::basic_json `basic_json`@endlink -- class template for JSON values + - @link nlohmann::json `json`@endlink -- the default specialization of `basic_json`, defined as `basic_json<>` - [Functions](functions_func.html) - object inspection - @link nlohmann::basic_json::dump dump @endlink -- value serialization From ec43d27f9fec220c7b01b27619a84cb75f6b3d55 Mon Sep 17 00:00:00 2001 From: Isaac Nickaein Date: Mon, 22 Apr 2019 08:15:53 +0430 Subject: [PATCH 074/106] Add Debug builds for AppVeyor --- appveyor.yml | 30 +++++++++++++++++++++++++++--- 1 file changed, 27 insertions(+), 3 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index 0dfc34e9..9ecbabed 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -2,6 +2,28 @@ version: '{build}' environment: matrix: + - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015 + configuration: Debug + platform: x86 + CXX_FLAGS: "" + LINKER_FLAGS: "" + GENERATOR: Visual Studio 14 2015 + + - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017 + configuration: Debug + platform: x86 + CXX_FLAGS: "" + LINKER_FLAGS: "" + GENERATOR: Visual Studio 15 2017 + + - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015 + configuration: Debug + COMPILER: mingw + platform: x86 + CXX_FLAGS: "" + LINKER_FLAGS: "" + GENERATOR: Ninja + - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015 COMPILER: mingw platform: x86 @@ -48,6 +70,8 @@ environment: init: - cmake --version - msbuild /version + # set the default build configuration to Release + - if "%configuration%"=="" (set configuration="Release") install: - if "%COMPILER%"=="mingw" appveyor DownloadFile https://github.com/ninja-build/ninja/releases/download/v1.6.0/ninja-win.zip -FileName ninja.zip @@ -57,10 +81,10 @@ install: - if "%COMPILER%"=="mingw" g++ --version before_build: - - cmake . -G "%GENERATOR%" -DCMAKE_CXX_FLAGS="%CXX_FLAGS%" -DCMAKE_EXE_LINKER_FLAGS="%LINKER_FLAGS%" -DCMAKE_IGNORE_PATH="C:/Program Files/Git/usr/bin" + - cmake . -G "%GENERATOR%" -DCMAKE_BUILD_TYPE="%configuration%" -DCMAKE_CXX_FLAGS="%CXX_FLAGS%" -DCMAKE_EXE_LINKER_FLAGS="%LINKER_FLAGS%" -DCMAKE_IGNORE_PATH="C:/Program Files/Git/usr/bin" build_script: - - cmake --build . --config Release + - cmake --build . --config "%configuration%" test_script: - - ctest -C Release -V -j + - ctest -C "%configuration%" -V -j From 4ac0fe262807e2ee86216bf7449626db921bcfb3 Mon Sep 17 00:00:00 2001 From: Isaac Nickaein Date: Mon, 22 Apr 2019 08:16:10 +0430 Subject: [PATCH 075/106] Increase timeout of test-unicode_all in Debug build --- test/CMakeLists.txt | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index b73dfc9a..8b1809dd 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -133,6 +133,12 @@ foreach(file ${files}) ) set_tests_properties("${testcase}_all" PROPERTIES LABELS "all") + # Increase timeout for test-unicode_all on Debug build + string(TOUPPER "${CMAKE_BUILD_TYPE}" uppercase_CMAKE_BUILD_TYPE) + if (("${testcase}" STREQUAL "test-unicode") AND (uppercase_CMAKE_BUILD_TYPE STREQUAL DEBUG)) + set_tests_properties("${testcase}_all" PROPERTIES TIMEOUT 3600) + endif() + if(JSON_Valgrind) add_test(NAME "${testcase}_valgrind" COMMAND ${memcheck_command} ${CMAKE_CURRENT_BINARY_DIR}/${testcase} ${DOCTEST_TEST_FILTER} From d28b4b900e47f0d5144182d16097dfd035a4203a Mon Sep 17 00:00:00 2001 From: Isaac Nickaein Date: Tue, 21 May 2019 17:26:30 +0430 Subject: [PATCH 076/106] Add a separate build with Windows.h included --- appveyor.yml | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/appveyor.yml b/appveyor.yml index 9ecbabed..038d282d 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -37,6 +37,13 @@ environment: LINKER_FLAGS: "" GENERATOR: Visual Studio 14 2015 + - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015 + platform: x86 + name: with_win_header + CXX_FLAGS: "" + LINKER_FLAGS: "" + GENERATOR: Visual Studio 14 2015 + - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017 platform: x86 CXX_FLAGS: "" @@ -81,6 +88,9 @@ install: - if "%COMPILER%"=="mingw" g++ --version before_build: + # for with_win_header build, inject the inclusion of Windows.h to the single-header library + - ps: if ($env:name -Eq "with_win_header") { $header_path = "single_include\nlohmann\json.hpp" } + - ps: if ($env:name -Eq "with_win_header") { "#include `n" + (Get-Content $header_path | Out-String) | Set-Content $header_path } - cmake . -G "%GENERATOR%" -DCMAKE_BUILD_TYPE="%configuration%" -DCMAKE_CXX_FLAGS="%CXX_FLAGS%" -DCMAKE_EXE_LINKER_FLAGS="%LINKER_FLAGS%" -DCMAKE_IGNORE_PATH="C:/Program Files/Git/usr/bin" build_script: From 798e83a038ed7b0ae048ee508e7aaf0cfb62ceba Mon Sep 17 00:00:00 2001 From: Isaac Nickaein Date: Fri, 21 Jun 2019 23:16:42 +0430 Subject: [PATCH 077/106] Workaround msvc2015 bug with explicit copy-constructor for const_iterator --- include/nlohmann/detail/iterators/iter_impl.hpp | 7 +++++++ single_include/nlohmann/json.hpp | 7 +++++++ 2 files changed, 14 insertions(+) diff --git a/include/nlohmann/detail/iterators/iter_impl.hpp b/include/nlohmann/detail/iterators/iter_impl.hpp index 0b0282c2..8492c234 100644 --- a/include/nlohmann/detail/iterators/iter_impl.hpp +++ b/include/nlohmann/detail/iterators/iter_impl.hpp @@ -118,6 +118,13 @@ class iter_impl to iterator is not defined. */ + /* We had to explicitly define the copy constructor for the const + case to circumvent a bug on msvc 2015 debug build. + More info: https://github.com/nlohmann/json/issues/1608 + */ + iter_impl(const iter_impl& other) noexcept + : m_object(other.m_object), m_it(other.m_it) {} + /*! @brief converting constructor @param[in] other non-const iterator to copy from diff --git a/single_include/nlohmann/json.hpp b/single_include/nlohmann/json.hpp index bb2dacbc..c652b35a 100644 --- a/single_include/nlohmann/json.hpp +++ b/single_include/nlohmann/json.hpp @@ -7821,6 +7821,13 @@ class iter_impl to iterator is not defined. */ + /* We had to explicitly define the copy constructor for the const + case to circumvent a bug on msvc 2015 debug build. + More info: https://github.com/nlohmann/json/issues/1608 + */ + iter_impl(const iter_impl& other) noexcept + : m_object(other.m_object), m_it(other.m_it) {} + /*! @brief converting constructor @param[in] other non-const iterator to copy from From eba8244ead0e0beb50bed694d2d2eea432e09234 Mon Sep 17 00:00:00 2001 From: Isaac Nickaein Date: Sat, 22 Jun 2019 02:33:13 +0430 Subject: [PATCH 078/106] Avoid collision of ::max with windows.h macro --- test/src/unit-concepts.cpp | 4 ++-- test/src/unit-regression.cpp | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/test/src/unit-concepts.cpp b/test/src/unit-concepts.cpp index 9649af40..f28f0432 100644 --- a/test/src/unit-concepts.cpp +++ b/test/src/unit-concepts.cpp @@ -73,8 +73,8 @@ TEST_CASE("concepts") // X::size_type must return an unsigned integer CHECK((std::is_unsigned::value)); // X::size_type can represent any non-negative value of X::difference_type - CHECK(static_cast(std::numeric_limits::max()) <= - std::numeric_limits::max()); + CHECK(static_cast((std::numeric_limits::max)()) <= + (std::numeric_limits::max)()); // the expression "X u" has the post-condition "u.empty()" { diff --git a/test/src/unit-regression.cpp b/test/src/unit-regression.cpp index 6b7d90aa..88b12114 100644 --- a/test/src/unit-regression.cpp +++ b/test/src/unit-regression.cpp @@ -719,7 +719,7 @@ TEST_CASE("regression tests") }; check_roundtrip(100000000000.1236); - check_roundtrip(std::numeric_limits::max()); + check_roundtrip((std::numeric_limits::max)()); // Some more numbers which fail to roundtrip when serialized with digits10 significand digits (instead of max_digits10) check_roundtrip(1.541888611948064e-17); From f559142008291e1b6e9a6d028b6ce076b90a4197 Mon Sep 17 00:00:00 2001 From: Isaac Nickaein Date: Sat, 22 Jun 2019 20:48:02 +0430 Subject: [PATCH 079/106] Appveyor: Set build mode explicitly --- appveyor.yml | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index 038d282d..aa5bb339 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -25,6 +25,7 @@ environment: GENERATOR: Ninja - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015 + configuration: Release COMPILER: mingw platform: x86 CXX_FLAGS: "" @@ -32,12 +33,14 @@ environment: GENERATOR: Ninja - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015 + configuration: Release platform: x86 CXX_FLAGS: "" LINKER_FLAGS: "" GENERATOR: Visual Studio 14 2015 - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015 + configuration: Release platform: x86 name: with_win_header CXX_FLAGS: "" @@ -45,30 +48,35 @@ environment: GENERATOR: Visual Studio 14 2015 - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017 + configuration: Release platform: x86 CXX_FLAGS: "" LINKER_FLAGS: "" GENERATOR: Visual Studio 15 2017 - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017 + configuration: Release platform: x86 CXX_FLAGS: "/permissive- /std:c++latest /utf-8" LINKER_FLAGS: "" GENERATOR: Visual Studio 15 2017 - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015 + configuration: Release platform: x64 CXX_FLAGS: "" LINKER_FLAGS: "" GENERATOR: Visual Studio 14 2015 Win64 - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017 + configuration: Release platform: x64 CXX_FLAGS: "" LINKER_FLAGS: "" GENERATOR: Visual Studio 15 2017 Win64 - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017 + configuration: Release platform: x64 CXX_FLAGS: "/permissive- /std:c++latest /utf-8 /F4000000" LINKER_FLAGS: "/STACK:4000000" @@ -77,8 +85,6 @@ environment: init: - cmake --version - msbuild /version - # set the default build configuration to Release - - if "%configuration%"=="" (set configuration="Release") install: - if "%COMPILER%"=="mingw" appveyor DownloadFile https://github.com/ninja-build/ninja/releases/download/v1.6.0/ninja-win.zip -FileName ninja.zip From 0a137b78ac4ebde994e68e2edc1380fe65bf0c75 Mon Sep 17 00:00:00 2001 From: Isaac Nickaein Date: Sat, 22 Jun 2019 21:05:15 +0430 Subject: [PATCH 080/106] Appveyor: Set timeout of unit-tests in appveyor.yml instead of CMake --- appveyor.yml | 4 +++- test/CMakeLists.txt | 6 ------ 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index aa5bb339..ae8dbfa9 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -103,4 +103,6 @@ build_script: - cmake --build . --config "%configuration%" test_script: - - ctest -C "%configuration%" -V -j + # Set 1 hour timeout to avoid the occasional + # timeouts on test-unicode_all + - ctest --timeout 3600 -C "%configuration%" -V -j diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 8b1809dd..b73dfc9a 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -133,12 +133,6 @@ foreach(file ${files}) ) set_tests_properties("${testcase}_all" PROPERTIES LABELS "all") - # Increase timeout for test-unicode_all on Debug build - string(TOUPPER "${CMAKE_BUILD_TYPE}" uppercase_CMAKE_BUILD_TYPE) - if (("${testcase}" STREQUAL "test-unicode") AND (uppercase_CMAKE_BUILD_TYPE STREQUAL DEBUG)) - set_tests_properties("${testcase}_all" PROPERTIES TIMEOUT 3600) - endif() - if(JSON_Valgrind) add_test(NAME "${testcase}_valgrind" COMMAND ${memcheck_command} ${CMAKE_CURRENT_BINARY_DIR}/${testcase} ${DOCTEST_TEST_FILTER} From 3db14cbfae858707b31419877d37be46bcbd95a3 Mon Sep 17 00:00:00 2001 From: Isaac Nickaein Date: Mon, 24 Jun 2019 15:40:01 +0430 Subject: [PATCH 081/106] :memo: Improve doc on const_inter constructor --- include/nlohmann/detail/iterators/iter_impl.hpp | 11 +++++++---- single_include/nlohmann/json.hpp | 11 +++++++---- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/include/nlohmann/detail/iterators/iter_impl.hpp b/include/nlohmann/detail/iterators/iter_impl.hpp index 8492c234..bc87de29 100644 --- a/include/nlohmann/detail/iterators/iter_impl.hpp +++ b/include/nlohmann/detail/iterators/iter_impl.hpp @@ -118,10 +118,13 @@ class iter_impl to iterator is not defined. */ - /* We had to explicitly define the copy constructor for the const - case to circumvent a bug on msvc 2015 debug build. - More info: https://github.com/nlohmann/json/issues/1608 - */ + /*! + @brief const copy constructor + @param[in] other const iterator to copy from + @note This copy constuctor had to be defined explicitely to circumvent a bug + occuring on msvc v19.0 compiler (VS 2015) debug build. For more + information refer to: https://github.com/nlohmann/json/issues/1608 + */ iter_impl(const iter_impl& other) noexcept : m_object(other.m_object), m_it(other.m_it) {} diff --git a/single_include/nlohmann/json.hpp b/single_include/nlohmann/json.hpp index c652b35a..08c4fc64 100644 --- a/single_include/nlohmann/json.hpp +++ b/single_include/nlohmann/json.hpp @@ -7821,10 +7821,13 @@ class iter_impl to iterator is not defined. */ - /* We had to explicitly define the copy constructor for the const - case to circumvent a bug on msvc 2015 debug build. - More info: https://github.com/nlohmann/json/issues/1608 - */ + /*! + @brief const copy constructor + @param[in] other const iterator to copy from + @note This copy constuctor had to be defined explicitely to circumvent a bug + occuring on msvc v19.0 compiler (VS 2015) debug build. For more + information refer to: https://github.com/nlohmann/json/issues/1608 + */ iter_impl(const iter_impl& other) noexcept : m_object(other.m_object), m_it(other.m_it) {} From 5b2e2305a054a2ea3354a124bda467e5018b8ce6 Mon Sep 17 00:00:00 2001 From: Isaac Nickaein Date: Mon, 24 Jun 2019 20:11:56 +0430 Subject: [PATCH 082/106] CI: Skip test-unit_all on MSVC Debug builds --- appveyor.yml | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index ae8dbfa9..0a92a6c9 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -103,6 +103,9 @@ build_script: - cmake --build . --config "%configuration%" test_script: - # Set 1 hour timeout to avoid the occasional - # timeouts on test-unicode_all - - ctest --timeout 3600 -C "%configuration%" -V -j + - if "%configuration%"=="Release" ctest -C "%configuration%" -V -j + # On Debug builds, skip test-unicode_all + # as it is extremely slow to run and cause + # occasional timeouts on AppVeyor. + # More info: https://github.com/nlohmann/json/pull/1570 + - if "%configuration%"=="Debug" ctest --exclude-regex "test-unicode_all" -C "%configuration%" -V -j From 855156b5e87e246acbe607ef68a94412dbf4d01e Mon Sep 17 00:00:00 2001 From: kevinlul <6320810+kevinlul@users.noreply.github.com> Date: Sat, 29 Jun 2019 19:26:38 -0400 Subject: [PATCH 083/106] Add regression tests for #1642 --- test/src/unit-regression.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/test/src/unit-regression.cpp b/test/src/unit-regression.cpp index 6b7d90aa..b4850d6b 100644 --- a/test/src/unit-regression.cpp +++ b/test/src/unit-regression.cpp @@ -1799,3 +1799,14 @@ TEST_CASE("regression tests, exceptions dependent") } } #endif + +///////////////////////////////////////////////////////////////////// +// for #1642 +///////////////////////////////////////////////////////////////////// +template class array {}; +template class object {}; +template class string {}; +template class boolean {}; +template class number_integer {}; +template class number_unsigned {}; +template class number_float {}; \ No newline at end of file From 258fa798f15a0010d04eaa23010be8b53afd2f4d Mon Sep 17 00:00:00 2001 From: Niels Lohmann Date: Sun, 30 Jun 2019 10:03:08 +0200 Subject: [PATCH 084/106] :sparkles: add contains function for JSON pointers --- doc/examples/contains_json_pointer.cpp | 45 ++++++++ doc/examples/contains_json_pointer.link | 1 + doc/examples/contains_json_pointer.output | 10 ++ include/nlohmann/detail/json_pointer.hpp | 90 +++++++++++++-- include/nlohmann/json.hpp | 37 ++++++- single_include/nlohmann/json.hpp | 127 ++++++++++++++++++++-- test/src/unit-json_pointer.cpp | 51 ++++++++- 7 files changed, 338 insertions(+), 23 deletions(-) create mode 100644 doc/examples/contains_json_pointer.cpp create mode 100644 doc/examples/contains_json_pointer.link create mode 100644 doc/examples/contains_json_pointer.output diff --git a/doc/examples/contains_json_pointer.cpp b/doc/examples/contains_json_pointer.cpp new file mode 100644 index 00000000..ed45fcee --- /dev/null +++ b/doc/examples/contains_json_pointer.cpp @@ -0,0 +1,45 @@ +#include +#include + +using json = nlohmann::json; + +int main() +{ + // create a JSON value + json j = + { + {"number", 1}, {"string", "foo"}, {"array", {1, 2}} + }; + + std::cout << std::boolalpha + << j.contains("/number"_json_pointer) << '\n' + << j.contains("/string"_json_pointer) << '\n' + << j.contains("/string"_json_pointer) << '\n' + << j.contains("/array"_json_pointer) << '\n' + << j.contains("/array/1"_json_pointer) << '\n' + << j.contains("/array/-"_json_pointer) << '\n' + << j.contains("/array/4"_json_pointer) << '\n' + << j.contains("/baz"_json_pointer) << std::endl; + + // out_of_range.106 + try + { + // try to use an array index with leading '0' + j.contains("/array/01"_json_pointer); + } + catch (json::parse_error& e) + { + std::cout << e.what() << '\n'; + } + + // out_of_range.109 + try + { + // try to use an array index that is not a number + j.contains("/array/one"_json_pointer); + } + catch (json::parse_error& e) + { + std::cout << e.what() << '\n'; + } +} diff --git a/doc/examples/contains_json_pointer.link b/doc/examples/contains_json_pointer.link new file mode 100644 index 00000000..778e151f --- /dev/null +++ b/doc/examples/contains_json_pointer.link @@ -0,0 +1 @@ +online \ No newline at end of file diff --git a/doc/examples/contains_json_pointer.output b/doc/examples/contains_json_pointer.output new file mode 100644 index 00000000..82ec3675 --- /dev/null +++ b/doc/examples/contains_json_pointer.output @@ -0,0 +1,10 @@ +true +true +true +true +true +false +false +false +[json.exception.parse_error.106] parse error: array index '01' must not begin with '0' +[json.exception.parse_error.109] parse error: array index 'one' is not a number diff --git a/include/nlohmann/detail/json_pointer.hpp b/include/nlohmann/detail/json_pointer.hpp index 465e5165..51c51efa 100644 --- a/include/nlohmann/detail/json_pointer.hpp +++ b/include/nlohmann/detail/json_pointer.hpp @@ -2,6 +2,7 @@ #include // all_of #include // assert +#include // isdigit #include // accumulate #include // string #include // move @@ -369,7 +370,7 @@ class json_pointer // j which will be overwritten by a primitive value for (const auto& reference_token : reference_tokens) { - switch (result->m_type) + switch (result->type()) { case detail::value_t::null: { @@ -446,14 +447,14 @@ class json_pointer for (const auto& reference_token : reference_tokens) { // convert null values to arrays or objects before continuing - if (ptr->m_type == detail::value_t::null) + if (ptr->is_null()) { // check if reference token is a number const bool nums = std::all_of(reference_token.begin(), reference_token.end(), - [](const char x) + [](const unsigned char x) { - return x >= '0' and x <= '9'; + return std::isdigit(x); }); // change value to array for numbers or "-" or to object otherwise @@ -462,7 +463,7 @@ class json_pointer : detail::value_t::object; } - switch (ptr->m_type) + switch (ptr->type()) { case detail::value_t::object: { @@ -521,7 +522,7 @@ class json_pointer using size_type = typename BasicJsonType::size_type; for (const auto& reference_token : reference_tokens) { - switch (ptr->m_type) + switch (ptr->type()) { case detail::value_t::object: { @@ -586,7 +587,7 @@ class json_pointer using size_type = typename BasicJsonType::size_type; for (const auto& reference_token : reference_tokens) { - switch (ptr->m_type) + switch (ptr->type()) { case detail::value_t::object: { @@ -645,7 +646,7 @@ class json_pointer using size_type = typename BasicJsonType::size_type; for (const auto& reference_token : reference_tokens) { - switch (ptr->m_type) + switch (ptr->type()) { case detail::value_t::object: { @@ -692,6 +693,77 @@ class json_pointer return *ptr; } + /*! + @throw parse_error.106 if an array index begins with '0' + @throw parse_error.109 if an array index was not a number + */ + bool contains(const BasicJsonType* ptr) const + { + using size_type = typename BasicJsonType::size_type; + for (const auto& reference_token : reference_tokens) + { + switch (ptr->type()) + { + case detail::value_t::object: + { + if (not ptr->contains(reference_token)) + { + // we did not find the key in the object + return false; + } + + ptr = &ptr->operator[](reference_token); + break; + } + + case detail::value_t::array: + { + if (JSON_UNLIKELY(reference_token == "-")) + { + // "-" always fails the range check + return false; + } + + // error condition (cf. RFC 6901, Sect. 4) + if (JSON_UNLIKELY(reference_token.size() > 1 and reference_token[0] == '0')) + { + JSON_THROW(detail::parse_error::create(106, 0, + "array index '" + reference_token + + "' must not begin with '0'")); + } + + JSON_TRY + { + const auto idx = static_cast(array_index(reference_token)); + if (idx >= ptr->size()) + { + // index out of range + return false; + } + + ptr = &ptr->operator[](idx); + break; + } + JSON_CATCH(std::invalid_argument&) + { + JSON_THROW(detail::parse_error::create(109, 0, "array index '" + reference_token + "' is not a number")); + } + break; + } + + default: + { + // we do not expect primitive values if there is still a + // reference token to process + return false; + } + } + } + + // no reference token left means we found a primitive value + return true; + } + /*! @brief split the string input to reference tokens @@ -813,7 +885,7 @@ class json_pointer const BasicJsonType& value, BasicJsonType& result) { - switch (value.m_type) + switch (value.type()) { case detail::value_t::array: { diff --git a/include/nlohmann/json.hpp b/include/nlohmann/json.hpp index 58db19d7..bef79c2c 100644 --- a/include/nlohmann/json.hpp +++ b/include/nlohmann/json.hpp @@ -4001,15 +4001,48 @@ class basic_json @liveexample{The following code shows an example for `contains()`.,contains} @sa @ref find(KeyT&&) -- returns an iterator to an object element + @sa @ref contains(const json_pointer&) const -- checks the existence for a JSON pointer @since version 3.6.0 */ - template - bool contains(KeyT&& key) const + template::value, int>::type = 0> + bool contains(KeyT && key) const { return is_object() and m_value.object->find(std::forward(key)) != m_value.object->end(); } + /*! + @brief check the existence of an element in a JSON object given a JSON pointer + + Check wehther the given JSON pointer @a ptr can be resolved in the current + JSON value. + + @note This method can be executed on any JSON value type. + + @param[in] ptr JSON pointer to check its existence. + + @return true if the JSON pointer can be resolved to a stored value, false + otherwise. + + @post If `j.contains(ptr)` returns true, it is safe to call `j[ptr]`. + + @throw parse_error.106 if an array index begins with '0' + @throw parse_error.109 if an array index was not a number + + @complexity Logarithmic in the size of the JSON object. + + @liveexample{The following code shows an example for `contains()`.,contains_json_pointer} + + @sa @ref contains(KeyT &&) const -- checks the existence of a key + + @since version 3.7.0 + */ + bool contains(const json_pointer& ptr) const + { + return ptr.contains(this); + } + /// @} diff --git a/single_include/nlohmann/json.hpp b/single_include/nlohmann/json.hpp index bb2dacbc..872a9b69 100644 --- a/single_include/nlohmann/json.hpp +++ b/single_include/nlohmann/json.hpp @@ -8445,6 +8445,7 @@ class json_reverse_iterator : public std::reverse_iterator #include // all_of #include // assert +#include // isdigit #include // accumulate #include // string #include // move @@ -8815,7 +8816,7 @@ class json_pointer // j which will be overwritten by a primitive value for (const auto& reference_token : reference_tokens) { - switch (result->m_type) + switch (result->type()) { case detail::value_t::null: { @@ -8892,14 +8893,14 @@ class json_pointer for (const auto& reference_token : reference_tokens) { // convert null values to arrays or objects before continuing - if (ptr->m_type == detail::value_t::null) + if (ptr->is_null()) { // check if reference token is a number const bool nums = std::all_of(reference_token.begin(), reference_token.end(), - [](const char x) + [](const unsigned char x) { - return x >= '0' and x <= '9'; + return std::isdigit(x); }); // change value to array for numbers or "-" or to object otherwise @@ -8908,7 +8909,7 @@ class json_pointer : detail::value_t::object; } - switch (ptr->m_type) + switch (ptr->type()) { case detail::value_t::object: { @@ -8967,7 +8968,7 @@ class json_pointer using size_type = typename BasicJsonType::size_type; for (const auto& reference_token : reference_tokens) { - switch (ptr->m_type) + switch (ptr->type()) { case detail::value_t::object: { @@ -9032,7 +9033,7 @@ class json_pointer using size_type = typename BasicJsonType::size_type; for (const auto& reference_token : reference_tokens) { - switch (ptr->m_type) + switch (ptr->type()) { case detail::value_t::object: { @@ -9091,7 +9092,7 @@ class json_pointer using size_type = typename BasicJsonType::size_type; for (const auto& reference_token : reference_tokens) { - switch (ptr->m_type) + switch (ptr->type()) { case detail::value_t::object: { @@ -9138,6 +9139,77 @@ class json_pointer return *ptr; } + /*! + @throw parse_error.106 if an array index begins with '0' + @throw parse_error.109 if an array index was not a number + */ + bool contains(const BasicJsonType* ptr) const + { + using size_type = typename BasicJsonType::size_type; + for (const auto& reference_token : reference_tokens) + { + switch (ptr->type()) + { + case detail::value_t::object: + { + if (not ptr->contains(reference_token)) + { + // we did not find the key in the object + return false; + } + + ptr = &ptr->operator[](reference_token); + break; + } + + case detail::value_t::array: + { + if (JSON_UNLIKELY(reference_token == "-")) + { + // "-" always fails the range check + return false; + } + + // error condition (cf. RFC 6901, Sect. 4) + if (JSON_UNLIKELY(reference_token.size() > 1 and reference_token[0] == '0')) + { + JSON_THROW(detail::parse_error::create(106, 0, + "array index '" + reference_token + + "' must not begin with '0'")); + } + + JSON_TRY + { + const auto idx = static_cast(array_index(reference_token)); + if (idx >= ptr->size()) + { + // index out of range + return false; + } + + ptr = &ptr->operator[](idx); + break; + } + JSON_CATCH(std::invalid_argument&) + { + JSON_THROW(detail::parse_error::create(109, 0, "array index '" + reference_token + "' is not a number")); + } + break; + } + + default: + { + // we do not expect primitive values if there is still a + // reference token to process + return false; + } + } + } + + // no reference token left means we found a primitive value + return true; + } + /*! @brief split the string input to reference tokens @@ -9259,7 +9331,7 @@ class json_pointer const BasicJsonType& value, BasicJsonType& result) { - switch (value.m_type) + switch (value.type()) { case detail::value_t::array: { @@ -16802,15 +16874,48 @@ class basic_json @liveexample{The following code shows an example for `contains()`.,contains} @sa @ref find(KeyT&&) -- returns an iterator to an object element + @sa @ref contains(const json_pointer&) const -- checks the existence for a JSON pointer @since version 3.6.0 */ - template - bool contains(KeyT&& key) const + template::value, int>::type = 0> + bool contains(KeyT && key) const { return is_object() and m_value.object->find(std::forward(key)) != m_value.object->end(); } + /*! + @brief check the existence of an element in a JSON object given a JSON pointer + + Check wehther the given JSON pointer @a ptr can be resolved in the current + JSON value. + + @note This method can be executed on any JSON value type. + + @param[in] ptr JSON pointer to check its existence. + + @return true if the JSON pointer can be resolved to a stored value, false + otherwise. + + @post If `j.contains(ptr)` returns true, it is safe to call `j[ptr]`. + + @throw parse_error.106 if an array index begins with '0' + @throw parse_error.109 if an array index was not a number + + @complexity Logarithmic in the size of the JSON object. + + @liveexample{The following code shows an example for `contains()`.,contains_json_pointer} + + @sa @ref contains(KeyT &&) const -- checks the existence of a key + + @since version 3.7.0 + */ + bool contains(const json_pointer& ptr) const + { + return ptr.contains(this); + } + /// @} diff --git a/test/src/unit-json_pointer.cpp b/test/src/unit-json_pointer.cpp index 6e6a1d79..598f36b0 100644 --- a/test/src/unit-json_pointer.cpp +++ b/test/src/unit-json_pointer.cpp @@ -90,12 +90,18 @@ TEST_CASE("JSON pointers") // the whole document CHECK(j[json::json_pointer()] == j); CHECK(j[json::json_pointer("")] == j); + CHECK(j.contains(json::json_pointer())); + CHECK(j.contains(json::json_pointer(""))); // array access CHECK(j[json::json_pointer("/foo")] == j["foo"]); + CHECK(j.contains(json::json_pointer("/foo"))); CHECK(j[json::json_pointer("/foo/0")] == j["foo"][0]); CHECK(j[json::json_pointer("/foo/1")] == j["foo"][1]); CHECK(j["/foo/1"_json_pointer] == j["foo"][1]); + CHECK(j.contains(json::json_pointer("/foo/0"))); + CHECK(j.contains(json::json_pointer("/foo/1"))); + CHECK(not j.contains(json::json_pointer("/foo/-"))); // checked array access CHECK(j.at(json::json_pointer("/foo/0")) == j["foo"][0]); @@ -103,6 +109,8 @@ TEST_CASE("JSON pointers") // empty string access CHECK(j[json::json_pointer("/")] == j[""]); + CHECK(j.contains(json::json_pointer(""))); + CHECK(j.contains(json::json_pointer("/"))); // other cases CHECK(j[json::json_pointer("/ ")] == j[" "]); @@ -112,6 +120,14 @@ TEST_CASE("JSON pointers") CHECK(j[json::json_pointer("/i\\j")] == j["i\\j"]); CHECK(j[json::json_pointer("/k\"l")] == j["k\"l"]); + // contains + CHECK(j.contains(json::json_pointer("/ "))); + CHECK(j.contains(json::json_pointer("/c%d"))); + CHECK(j.contains(json::json_pointer("/e^f"))); + CHECK(j.contains(json::json_pointer("/g|h"))); + CHECK(j.contains(json::json_pointer("/i\\j"))); + CHECK(j.contains(json::json_pointer("/k\"l"))); + // checked access CHECK(j.at(json::json_pointer("/ ")) == j[" "]); CHECK(j.at(json::json_pointer("/c%d")) == j["c%d"]); @@ -123,14 +139,24 @@ TEST_CASE("JSON pointers") // escaped access CHECK(j[json::json_pointer("/a~1b")] == j["a/b"]); CHECK(j[json::json_pointer("/m~0n")] == j["m~n"]); + CHECK(j.contains(json::json_pointer("/a~1b"))); + CHECK(j.contains(json::json_pointer("/m~0n"))); // unescaped access // access to nonexisting values yield object creation + CHECK(not j.contains(json::json_pointer("/a/b"))); CHECK_NOTHROW(j[json::json_pointer("/a/b")] = 42); + CHECK(j.contains(json::json_pointer("/a/b"))); CHECK(j["a"]["b"] == json(42)); + + CHECK(not j.contains(json::json_pointer("/a/c/1"))); CHECK_NOTHROW(j[json::json_pointer("/a/c/1")] = 42); CHECK(j["a"]["c"] == json({nullptr, 42})); + CHECK(j.contains(json::json_pointer("/a/c/1"))); + + CHECK(not j.contains(json::json_pointer("/a/d/-"))); CHECK_NOTHROW(j[json::json_pointer("/a/d/-")] = 42); + CHECK(not j.contains(json::json_pointer("/a/d/-"))); CHECK(j["a"]["d"] == json::array({42})); // "/a/b" works for JSON {"a": {"b": 42}} CHECK(json({{"a", {{"b", 42}}}})[json::json_pointer("/a/b")] == json(42)); @@ -143,6 +169,7 @@ TEST_CASE("JSON pointers") CHECK_THROWS_AS(j_primitive.at("/foo"_json_pointer), json::out_of_range&); CHECK_THROWS_WITH(j_primitive.at("/foo"_json_pointer), "[json.exception.out_of_range.404] unresolved reference token 'foo'"); + CHECK(not j_primitive.contains(json::json_pointer("/foo"))); } SECTION("const access") @@ -233,11 +260,16 @@ TEST_CASE("JSON pointers") // the whole document CHECK(j[""_json_pointer] == j); + CHECK(j.contains(""_json_pointer)); // array access CHECK(j["/foo"_json_pointer] == j["foo"]); CHECK(j["/foo/0"_json_pointer] == j["foo"][0]); CHECK(j["/foo/1"_json_pointer] == j["foo"][1]); + CHECK(j.contains("/foo"_json_pointer)); + CHECK(j.contains("/foo/0"_json_pointer)); + CHECK(j.contains("/foo/1"_json_pointer)); + CHECK(not j.contains("/foo/-"_json_pointer)); } } @@ -278,6 +310,12 @@ TEST_CASE("JSON pointers") CHECK_THROWS_AS(j_const.at("/01"_json_pointer), json::parse_error&); CHECK_THROWS_WITH(j_const.at("/01"_json_pointer), "[json.exception.parse_error.106] parse error: array index '01' must not begin with '0'"); + CHECK_THROWS_AS(j.contains("/01"_json_pointer), json::parse_error&); + CHECK_THROWS_WITH(j.contains("/01"_json_pointer), + "[json.exception.parse_error.106] parse error: array index '01' must not begin with '0'"); + CHECK_THROWS_AS(j_const.contains("/01"_json_pointer), json::parse_error&); + CHECK_THROWS_WITH(j_const.contains("/01"_json_pointer), + "[json.exception.parse_error.106] parse error: array index '01' must not begin with '0'"); // error with incorrect numbers CHECK_THROWS_AS(j["/one"_json_pointer] = 1, json::parse_error&); @@ -294,6 +332,13 @@ TEST_CASE("JSON pointers") CHECK_THROWS_WITH(j_const.at("/one"_json_pointer) == 1, "[json.exception.parse_error.109] parse error: array index 'one' is not a number"); + CHECK_THROWS_AS(j.contains("/one"_json_pointer), json::parse_error&); + CHECK_THROWS_WITH(j.contains("/one"_json_pointer), + "[json.exception.parse_error.109] parse error: array index 'one' is not a number"); + CHECK_THROWS_AS(j_const.contains("/one"_json_pointer), json::parse_error&); + CHECK_THROWS_WITH(j_const.contains("/one"_json_pointer), + "[json.exception.parse_error.109] parse error: array index 'one' is not a number"); + CHECK_THROWS_AS(json({{"/list/0", 1}, {"/list/1", 2}, {"/list/three", 3}}).unflatten(), json::parse_error&); CHECK_THROWS_WITH(json({{"/list/0", 1}, {"/list/1", 2}, {"/list/three", 3}}).unflatten(), "[json.exception.parse_error.109] parse error: array index 'three' is not a number"); @@ -306,6 +351,7 @@ TEST_CASE("JSON pointers") CHECK_THROWS_AS(j_const["/-"_json_pointer], json::out_of_range&); CHECK_THROWS_WITH(j_const["/-"_json_pointer], "[json.exception.out_of_range.402] array index '-' (3) is out of range"); + CHECK(not j_const.contains("/-"_json_pointer)); // error when using "-" with at CHECK_THROWS_AS(j.at("/-"_json_pointer), json::out_of_range&); @@ -314,6 +360,7 @@ TEST_CASE("JSON pointers") CHECK_THROWS_AS(j_const.at("/-"_json_pointer), json::out_of_range&); CHECK_THROWS_WITH(j_const.at("/-"_json_pointer), "[json.exception.out_of_range.402] array index '-' (3) is out of range"); + CHECK(not j_const.contains("/-"_json_pointer)); } SECTION("const access") @@ -329,11 +376,13 @@ TEST_CASE("JSON pointers") CHECK_THROWS_AS(j.at("/3"_json_pointer), json::out_of_range&); CHECK_THROWS_WITH(j.at("/3"_json_pointer), "[json.exception.out_of_range.401] array index 3 is out of range"); + CHECK(not j.contains("/3"_json_pointer)); // assign to nonexisting index (with gap) CHECK_THROWS_AS(j.at("/5"_json_pointer), json::out_of_range&); CHECK_THROWS_WITH(j.at("/5"_json_pointer), "[json.exception.out_of_range.401] array index 5 is out of range"); + CHECK(not j.contains("/5"_json_pointer)); // assign to "-" CHECK_THROWS_AS(j["/-"_json_pointer], json::out_of_range&); @@ -342,8 +391,8 @@ TEST_CASE("JSON pointers") CHECK_THROWS_AS(j.at("/-"_json_pointer), json::out_of_range&); CHECK_THROWS_WITH(j.at("/-"_json_pointer), "[json.exception.out_of_range.402] array index '-' (3) is out of range"); + CHECK(not j.contains("/-"_json_pointer)); } - } SECTION("flatten") From 1be63431f3910f09aa5ada66bc691ac391e50794 Mon Sep 17 00:00:00 2001 From: Niels Lohmann Date: Sun, 30 Jun 2019 12:19:41 +0200 Subject: [PATCH 085/106] :sparkles: make emplace_back return a reference #1609 --- include/nlohmann/json.hpp | 11 +++++++++-- single_include/nlohmann/json.hpp | 11 +++++++++-- test/src/unit-modifiers.cpp | 12 ++++++++---- 3 files changed, 26 insertions(+), 8 deletions(-) diff --git a/include/nlohmann/json.hpp b/include/nlohmann/json.hpp index 58db19d7..7e94518a 100644 --- a/include/nlohmann/json.hpp +++ b/include/nlohmann/json.hpp @@ -4952,6 +4952,8 @@ class basic_json @param[in] args arguments to forward to a constructor of @ref basic_json @tparam Args compatible types to create a @ref basic_json object + @return reference to the inserted element + @throw type_error.311 when called on a type other than JSON array or null; example: `"cannot use emplace_back() with number"` @@ -4961,10 +4963,10 @@ class basic_json elements to a JSON array. Note how the `null` value was silently converted to a JSON array.,emplace_back} - @since version 2.0.8 + @since version 2.0.8, returns reference since 3.7.0 */ template - void emplace_back(Args&& ... args) + reference emplace_back(Args&& ... args) { // emplace_back only works for null objects or arrays if (JSON_UNLIKELY(not(is_null() or is_array()))) @@ -4981,7 +4983,12 @@ class basic_json } // add element to array (perfect forwarding) +#ifdef JSON_HAS_CPP_17 + return m_value.array->emplace_back(std::forward(args)...); +#else m_value.array->emplace_back(std::forward(args)...); + return m_value.array->back(); +#endif } /*! diff --git a/single_include/nlohmann/json.hpp b/single_include/nlohmann/json.hpp index 08c4fc64..c2dd4e9a 100644 --- a/single_include/nlohmann/json.hpp +++ b/single_include/nlohmann/json.hpp @@ -17763,6 +17763,8 @@ class basic_json @param[in] args arguments to forward to a constructor of @ref basic_json @tparam Args compatible types to create a @ref basic_json object + @return reference to the inserted element + @throw type_error.311 when called on a type other than JSON array or null; example: `"cannot use emplace_back() with number"` @@ -17772,10 +17774,10 @@ class basic_json elements to a JSON array. Note how the `null` value was silently converted to a JSON array.,emplace_back} - @since version 2.0.8 + @since version 2.0.8, returns reference since 3.7.0 */ template - void emplace_back(Args&& ... args) + reference emplace_back(Args&& ... args) { // emplace_back only works for null objects or arrays if (JSON_UNLIKELY(not(is_null() or is_array()))) @@ -17792,7 +17794,12 @@ class basic_json } // add element to array (perfect forwarding) +#ifdef JSON_HAS_CPP_17 + return m_value.array->emplace_back(std::forward(args)...); +#else m_value.array->emplace_back(std::forward(args)...); + return m_value.array->back(); +#endif } /*! diff --git a/test/src/unit-modifiers.cpp b/test/src/unit-modifiers.cpp index 17081f22..cbfd09e4 100644 --- a/test/src/unit-modifiers.cpp +++ b/test/src/unit-modifiers.cpp @@ -290,8 +290,10 @@ TEST_CASE("modifiers") SECTION("null") { json j; - j.emplace_back(1); - j.emplace_back(2); + auto& x1 = j.emplace_back(1); + CHECK(x1 == 1); + auto& x2 = j.emplace_back(2); + CHECK(x2 == 2); CHECK(j.type() == json::value_t::array); CHECK(j == json({1, 2})); } @@ -299,7 +301,8 @@ TEST_CASE("modifiers") SECTION("array") { json j = {1, 2, 3}; - j.emplace_back("Hello"); + auto& x = j.emplace_back("Hello"); + CHECK(x == "Hello"); CHECK(j.type() == json::value_t::array); CHECK(j == json({1, 2, 3, "Hello"})); } @@ -307,7 +310,8 @@ TEST_CASE("modifiers") SECTION("multiple values") { json j; - j.emplace_back(3, "foo"); + auto& x = j.emplace_back(3, "foo"); + CHECK(x == json({"foo", "foo", "foo"})); CHECK(j.type() == json::value_t::array); CHECK(j == json({{"foo", "foo", "foo"}})); } From e616d095ab24a924d5e01200f57cc074dc477ca8 Mon Sep 17 00:00:00 2001 From: kevinlul <6320810+kevinlul@users.noreply.github.com> Date: Sun, 30 Jun 2019 11:57:57 -0400 Subject: [PATCH 086/106] Remove boolean regression test for #1642 --- test/src/unit-regression.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/test/src/unit-regression.cpp b/test/src/unit-regression.cpp index b4850d6b..3dfcef0b 100644 --- a/test/src/unit-regression.cpp +++ b/test/src/unit-regression.cpp @@ -1806,7 +1806,6 @@ TEST_CASE("regression tests, exceptions dependent") template class array {}; template class object {}; template class string {}; -template class boolean {}; template class number_integer {}; template class number_unsigned {}; template class number_float {}; \ No newline at end of file From 1720bfedd14ca8225fb4cb33d6d08551ce296237 Mon Sep 17 00:00:00 2001 From: Niels Lohmann Date: Sun, 30 Jun 2019 22:14:02 +0200 Subject: [PATCH 087/106] :alembic: add Hedley annotations --- .../nlohmann/detail/conversions/from_json.hpp | 26 +- .../nlohmann/detail/conversions/to_chars.hpp | 9 + .../nlohmann/detail/conversions/to_json.hpp | 2 +- include/nlohmann/detail/exceptions.hpp | 7 + .../nlohmann/detail/input/binary_reader.hpp | 114 +- .../nlohmann/detail/input/input_adapters.hpp | 7 +- include/nlohmann/detail/input/json_sax.hpp | 9 +- include/nlohmann/detail/input/lexer.hpp | 38 +- include/nlohmann/detail/input/parser.hpp | 46 +- .../nlohmann/detail/iterators/iter_impl.hpp | 28 +- include/nlohmann/detail/json_pointer.hpp | 34 +- include/nlohmann/detail/macro_scope.hpp | 36 +- include/nlohmann/detail/macro_unscope.hpp | 4 - .../nlohmann/detail/output/binary_writer.hpp | 3 +- .../detail/output/output_adapters.hpp | 4 + include/nlohmann/detail/output/serializer.hpp | 6 +- include/nlohmann/json.hpp | 165 +- include/nlohmann/thirdparty/hedley/hedley.hpp | 1505 +++++++++++ single_include/nlohmann/json.hpp | 2288 ++++++++++++++--- 19 files changed, 3689 insertions(+), 642 deletions(-) create mode 100644 include/nlohmann/thirdparty/hedley/hedley.hpp diff --git a/include/nlohmann/detail/conversions/from_json.hpp b/include/nlohmann/detail/conversions/from_json.hpp index 08a841b4..b7848c9e 100644 --- a/include/nlohmann/detail/conversions/from_json.hpp +++ b/include/nlohmann/detail/conversions/from_json.hpp @@ -26,7 +26,7 @@ namespace detail template void from_json(const BasicJsonType& j, typename std::nullptr_t& n) { - if (JSON_UNLIKELY(not j.is_null())) + if (HEDLEY_UNLIKELY(not j.is_null())) { JSON_THROW(type_error::create(302, "type must be null, but is " + std::string(j.type_name()))); } @@ -66,7 +66,7 @@ void get_arithmetic_value(const BasicJsonType& j, ArithmeticType& val) template void from_json(const BasicJsonType& j, typename BasicJsonType::boolean_t& b) { - if (JSON_UNLIKELY(not j.is_boolean())) + if (HEDLEY_UNLIKELY(not j.is_boolean())) { JSON_THROW(type_error::create(302, "type must be boolean, but is " + std::string(j.type_name()))); } @@ -76,7 +76,7 @@ void from_json(const BasicJsonType& j, typename BasicJsonType::boolean_t& b) template void from_json(const BasicJsonType& j, typename BasicJsonType::string_t& s) { - if (JSON_UNLIKELY(not j.is_string())) + if (HEDLEY_UNLIKELY(not j.is_string())) { JSON_THROW(type_error::create(302, "type must be string, but is " + std::string(j.type_name()))); } @@ -92,7 +92,7 @@ template < int > = 0 > void from_json(const BasicJsonType& j, ConstructibleStringType& s) { - if (JSON_UNLIKELY(not j.is_string())) + if (HEDLEY_UNLIKELY(not j.is_string())) { JSON_THROW(type_error::create(302, "type must be string, but is " + std::string(j.type_name()))); } @@ -132,7 +132,7 @@ template::value, int> = 0> void from_json(const BasicJsonType& j, std::forward_list& l) { - if (JSON_UNLIKELY(not j.is_array())) + if (HEDLEY_UNLIKELY(not j.is_array())) { JSON_THROW(type_error::create(302, "type must be array, but is " + std::string(j.type_name()))); } @@ -149,7 +149,7 @@ template::value, int> = 0> void from_json(const BasicJsonType& j, std::valarray& l) { - if (JSON_UNLIKELY(not j.is_array())) + if (HEDLEY_UNLIKELY(not j.is_array())) { JSON_THROW(type_error::create(302, "type must be array, but is " + std::string(j.type_name()))); } @@ -236,7 +236,7 @@ auto from_json(const BasicJsonType& j, ConstructibleArrayType& arr) j.template get(), void()) { - if (JSON_UNLIKELY(not j.is_array())) + if (HEDLEY_UNLIKELY(not j.is_array())) { JSON_THROW(type_error::create(302, "type must be array, but is " + std::string(j.type_name()))); @@ -249,7 +249,7 @@ template::value, int> = 0> void from_json(const BasicJsonType& j, ConstructibleObjectType& obj) { - if (JSON_UNLIKELY(not j.is_object())) + if (HEDLEY_UNLIKELY(not j.is_object())) { JSON_THROW(type_error::create(302, "type must be object, but is " + std::string(j.type_name()))); } @@ -332,14 +332,14 @@ template ::value>> void from_json(const BasicJsonType& j, std::map& m) { - if (JSON_UNLIKELY(not j.is_array())) + if (HEDLEY_UNLIKELY(not j.is_array())) { JSON_THROW(type_error::create(302, "type must be array, but is " + std::string(j.type_name()))); } m.clear(); for (const auto& p : j) { - if (JSON_UNLIKELY(not p.is_array())) + if (HEDLEY_UNLIKELY(not p.is_array())) { JSON_THROW(type_error::create(302, "type must be array, but is " + std::string(p.type_name()))); } @@ -352,14 +352,14 @@ template ::value>> void from_json(const BasicJsonType& j, std::unordered_map& m) { - if (JSON_UNLIKELY(not j.is_array())) + if (HEDLEY_UNLIKELY(not j.is_array())) { JSON_THROW(type_error::create(302, "type must be array, but is " + std::string(j.type_name()))); } m.clear(); for (const auto& p : j) { - if (JSON_UNLIKELY(not p.is_array())) + if (HEDLEY_UNLIKELY(not p.is_array())) { JSON_THROW(type_error::create(302, "type must be array, but is " + std::string(p.type_name()))); } @@ -386,4 +386,4 @@ namespace { constexpr const auto& from_json = detail::static_const::value; } // namespace -} // namespace nlohmann +} // namespace nlohmann diff --git a/include/nlohmann/detail/conversions/to_chars.hpp b/include/nlohmann/detail/conversions/to_chars.hpp index 2a264a87..6edc57ff 100644 --- a/include/nlohmann/detail/conversions/to_chars.hpp +++ b/include/nlohmann/detail/conversions/to_chars.hpp @@ -8,6 +8,7 @@ #include // memcpy, memmove #include // numeric_limits #include // conditional +#include namespace nlohmann { @@ -818,6 +819,7 @@ v = buf * 10^decimal_exponent len is the length of the buffer (number of decimal digits) The buffer must be large enough, i.e. >= max_digits10. */ +HEDLEY_NON_NULL(1) inline void grisu2(char* buf, int& len, int& decimal_exponent, diyfp m_minus, diyfp v, diyfp m_plus) { @@ -877,6 +879,7 @@ len is the length of the buffer (number of decimal digits) The buffer must be large enough, i.e. >= max_digits10. */ template +HEDLEY_NON_NULL(1) void grisu2(char* buf, int& len, int& decimal_exponent, FloatType value) { static_assert(diyfp::kPrecision >= std::numeric_limits::digits + 3, @@ -915,6 +918,8 @@ void grisu2(char* buf, int& len, int& decimal_exponent, FloatType value) @return a pointer to the element following the exponent. @pre -1000 < e < 1000 */ +HEDLEY_NON_NULL(1) +HEDLEY_RETURNS_NON_NULL inline char* append_exponent(char* buf, int e) { assert(e > -1000); @@ -965,6 +970,8 @@ notation. Otherwise it will be printed in exponential notation. @pre min_exp < 0 @pre max_exp > 0 */ +HEDLEY_NON_NULL(1) +HEDLEY_RETURNS_NON_NULL inline char* format_buffer(char* buf, int len, int decimal_exponent, int min_exp, int max_exp) { @@ -1048,6 +1055,8 @@ format. Returns an iterator pointing past-the-end of the decimal representation. @note The result is NOT null-terminated. */ template +HEDLEY_NON_NULL(1, 2) +HEDLEY_RETURNS_NON_NULL char* to_chars(char* first, const char* last, FloatType value) { static_cast(last); // maybe unused - fix warning diff --git a/include/nlohmann/detail/conversions/to_json.hpp b/include/nlohmann/detail/conversions/to_json.hpp index 227d7455..db9eaf2b 100644 --- a/include/nlohmann/detail/conversions/to_json.hpp +++ b/include/nlohmann/detail/conversions/to_json.hpp @@ -341,4 +341,4 @@ namespace { constexpr const auto& to_json = detail::static_const::value; } // namespace -} // namespace nlohmann +} // namespace nlohmann diff --git a/include/nlohmann/detail/exceptions.hpp b/include/nlohmann/detail/exceptions.hpp index 519a5975..bff13194 100644 --- a/include/nlohmann/detail/exceptions.hpp +++ b/include/nlohmann/detail/exceptions.hpp @@ -5,6 +5,7 @@ #include // to_string #include +#include namespace nlohmann { @@ -46,6 +47,7 @@ class exception : public std::exception { public: /// returns the explanatory string + HEDLEY_RETURNS_NON_NULL const char* what() const noexcept override { return m.what(); @@ -55,6 +57,7 @@ class exception : public std::exception const int id; protected: + HEDLEY_NON_NULL(3) exception(int id_, const char* what_arg) : id(id_), m(what_arg) {} static std::string name(const std::string& ename, int id_) @@ -207,6 +210,7 @@ class invalid_iterator : public exception } private: + HEDLEY_NON_NULL(3) invalid_iterator(int id_, const char* what_arg) : exception(id_, what_arg) {} }; @@ -260,6 +264,7 @@ class type_error : public exception } private: + HEDLEY_NON_NULL(3) type_error(int id_, const char* what_arg) : exception(id_, what_arg) {} }; @@ -306,6 +311,7 @@ class out_of_range : public exception } private: + HEDLEY_NON_NULL(3) out_of_range(int id_, const char* what_arg) : exception(id_, what_arg) {} }; @@ -343,6 +349,7 @@ class other_error : public exception } private: + HEDLEY_NON_NULL(3) other_error(int id_, const char* what_arg) : exception(id_, what_arg) {} }; } // namespace detail diff --git a/include/nlohmann/detail/input/binary_reader.hpp b/include/nlohmann/detail/input/binary_reader.hpp index 42976d70..33af9c36 100644 --- a/include/nlohmann/detail/input/binary_reader.hpp +++ b/include/nlohmann/detail/input/binary_reader.hpp @@ -66,6 +66,7 @@ class binary_reader @return */ + HEDLEY_NON_NULL(3) bool sax_parse(const input_format_t format, json_sax_t* sax_, const bool strict = true) @@ -107,7 +108,7 @@ class binary_reader get(); } - if (JSON_UNLIKELY(current != std::char_traits::eof())) + if (HEDLEY_UNLIKELY(current != std::char_traits::eof())) { return sax->parse_error(chars_read, get_token_string(), parse_error::create(110, chars_read, exception_message(format, "expected end of input; last byte: 0x" + get_token_string(), "value"))); @@ -143,12 +144,12 @@ class binary_reader std::int32_t document_size; get_number(input_format_t::bson, document_size); - if (JSON_UNLIKELY(not sax->start_object(std::size_t(-1)))) + if (HEDLEY_UNLIKELY(not sax->start_object(std::size_t(-1)))) { return false; } - if (JSON_UNLIKELY(not parse_bson_element_list(/*is_array*/false))) + if (HEDLEY_UNLIKELY(not parse_bson_element_list(/*is_array*/false))) { return false; } @@ -169,7 +170,7 @@ class binary_reader while (true) { get(); - if (JSON_UNLIKELY(not unexpect_eof(input_format_t::bson, "cstring"))) + if (HEDLEY_UNLIKELY(not unexpect_eof(input_format_t::bson, "cstring"))) { return false; } @@ -197,7 +198,7 @@ class binary_reader template bool get_bson_string(const NumberType len, string_t& result) { - if (JSON_UNLIKELY(len < 1)) + if (HEDLEY_UNLIKELY(len < 1)) { auto last_token = get_token_string(); return sax->parse_error(chars_read, last_token, parse_error::create(112, chars_read, exception_message(input_format_t::bson, "string length must be at least 1, is " + std::to_string(len), "string"))); @@ -292,13 +293,13 @@ class binary_reader string_t key; while (int element_type = get()) { - if (JSON_UNLIKELY(not unexpect_eof(input_format_t::bson, "element list"))) + if (HEDLEY_UNLIKELY(not unexpect_eof(input_format_t::bson, "element list"))) { return false; } const std::size_t element_type_parse_position = chars_read; - if (JSON_UNLIKELY(not get_bson_cstr(key))) + if (HEDLEY_UNLIKELY(not get_bson_cstr(key))) { return false; } @@ -308,7 +309,7 @@ class binary_reader return false; } - if (JSON_UNLIKELY(not parse_bson_element_internal(element_type, element_type_parse_position))) + if (HEDLEY_UNLIKELY(not parse_bson_element_internal(element_type, element_type_parse_position))) { return false; } @@ -329,12 +330,12 @@ class binary_reader std::int32_t document_size; get_number(input_format_t::bson, document_size); - if (JSON_UNLIKELY(not sax->start_array(std::size_t(-1)))) + if (HEDLEY_UNLIKELY(not sax->start_array(std::size_t(-1)))) { return false; } - if (JSON_UNLIKELY(not parse_bson_element_list(/*is_array*/true))) + if (HEDLEY_UNLIKELY(not parse_bson_element_list(/*is_array*/true))) { return false; } @@ -619,12 +620,12 @@ class binary_reader case 0xF9: // Half-Precision Float (two-byte IEEE 754) { const int byte1_raw = get(); - if (JSON_UNLIKELY(not unexpect_eof(input_format_t::cbor, "number"))) + if (HEDLEY_UNLIKELY(not unexpect_eof(input_format_t::cbor, "number"))) { return false; } const int byte2_raw = get(); - if (JSON_UNLIKELY(not unexpect_eof(input_format_t::cbor, "number"))) + if (HEDLEY_UNLIKELY(not unexpect_eof(input_format_t::cbor, "number"))) { return false; } @@ -697,7 +698,7 @@ class binary_reader */ bool get_cbor_string(string_t& result) { - if (JSON_UNLIKELY(not unexpect_eof(input_format_t::cbor, "string"))) + if (HEDLEY_UNLIKELY(not unexpect_eof(input_format_t::cbor, "string"))) { return false; } @@ -786,7 +787,7 @@ class binary_reader */ bool get_cbor_array(const std::size_t len) { - if (JSON_UNLIKELY(not sax->start_array(len))) + if (HEDLEY_UNLIKELY(not sax->start_array(len))) { return false; } @@ -795,7 +796,7 @@ class binary_reader { for (std::size_t i = 0; i < len; ++i) { - if (JSON_UNLIKELY(not parse_cbor_internal())) + if (HEDLEY_UNLIKELY(not parse_cbor_internal())) { return false; } @@ -805,7 +806,7 @@ class binary_reader { while (get() != 0xFF) { - if (JSON_UNLIKELY(not parse_cbor_internal(false))) + if (HEDLEY_UNLIKELY(not parse_cbor_internal(false))) { return false; } @@ -822,7 +823,7 @@ class binary_reader */ bool get_cbor_object(const std::size_t len) { - if (JSON_UNLIKELY(not sax->start_object(len))) + if (HEDLEY_UNLIKELY(not sax->start_object(len))) { return false; } @@ -833,12 +834,12 @@ class binary_reader for (std::size_t i = 0; i < len; ++i) { get(); - if (JSON_UNLIKELY(not get_cbor_string(key) or not sax->key(key))) + if (HEDLEY_UNLIKELY(not get_cbor_string(key) or not sax->key(key))) { return false; } - if (JSON_UNLIKELY(not parse_cbor_internal())) + if (HEDLEY_UNLIKELY(not parse_cbor_internal())) { return false; } @@ -849,12 +850,12 @@ class binary_reader { while (get() != 0xFF) { - if (JSON_UNLIKELY(not get_cbor_string(key) or not sax->key(key))) + if (HEDLEY_UNLIKELY(not get_cbor_string(key) or not sax->key(key))) { return false; } - if (JSON_UNLIKELY(not parse_cbor_internal())) + if (HEDLEY_UNLIKELY(not parse_cbor_internal())) { return false; } @@ -1243,7 +1244,7 @@ class binary_reader */ bool get_msgpack_string(string_t& result) { - if (JSON_UNLIKELY(not unexpect_eof(input_format_t::msgpack, "string"))) + if (HEDLEY_UNLIKELY(not unexpect_eof(input_format_t::msgpack, "string"))) { return false; } @@ -1319,14 +1320,14 @@ class binary_reader */ bool get_msgpack_array(const std::size_t len) { - if (JSON_UNLIKELY(not sax->start_array(len))) + if (HEDLEY_UNLIKELY(not sax->start_array(len))) { return false; } for (std::size_t i = 0; i < len; ++i) { - if (JSON_UNLIKELY(not parse_msgpack_internal())) + if (HEDLEY_UNLIKELY(not parse_msgpack_internal())) { return false; } @@ -1341,7 +1342,7 @@ class binary_reader */ bool get_msgpack_object(const std::size_t len) { - if (JSON_UNLIKELY(not sax->start_object(len))) + if (HEDLEY_UNLIKELY(not sax->start_object(len))) { return false; } @@ -1350,12 +1351,12 @@ class binary_reader for (std::size_t i = 0; i < len; ++i) { get(); - if (JSON_UNLIKELY(not get_msgpack_string(key) or not sax->key(key))) + if (HEDLEY_UNLIKELY(not get_msgpack_string(key) or not sax->key(key))) { return false; } - if (JSON_UNLIKELY(not parse_msgpack_internal())) + if (HEDLEY_UNLIKELY(not parse_msgpack_internal())) { return false; } @@ -1402,7 +1403,7 @@ class binary_reader get(); // TODO(niels): may we ignore N here? } - if (JSON_UNLIKELY(not unexpect_eof(input_format_t::ubjson, "value"))) + if (HEDLEY_UNLIKELY(not unexpect_eof(input_format_t::ubjson, "value"))) { return false; } @@ -1456,7 +1457,7 @@ class binary_reader case 'U': { std::uint8_t number; - if (JSON_UNLIKELY(not get_number(input_format_t::ubjson, number))) + if (HEDLEY_UNLIKELY(not get_number(input_format_t::ubjson, number))) { return false; } @@ -1467,7 +1468,7 @@ class binary_reader case 'i': { std::int8_t number; - if (JSON_UNLIKELY(not get_number(input_format_t::ubjson, number))) + if (HEDLEY_UNLIKELY(not get_number(input_format_t::ubjson, number))) { return false; } @@ -1478,7 +1479,7 @@ class binary_reader case 'I': { std::int16_t number; - if (JSON_UNLIKELY(not get_number(input_format_t::ubjson, number))) + if (HEDLEY_UNLIKELY(not get_number(input_format_t::ubjson, number))) { return false; } @@ -1489,7 +1490,7 @@ class binary_reader case 'l': { std::int32_t number; - if (JSON_UNLIKELY(not get_number(input_format_t::ubjson, number))) + if (HEDLEY_UNLIKELY(not get_number(input_format_t::ubjson, number))) { return false; } @@ -1500,7 +1501,7 @@ class binary_reader case 'L': { std::int64_t number; - if (JSON_UNLIKELY(not get_number(input_format_t::ubjson, number))) + if (HEDLEY_UNLIKELY(not get_number(input_format_t::ubjson, number))) { return false; } @@ -1536,15 +1537,15 @@ class binary_reader if (current == '$') { result.second = get(); // must not ignore 'N', because 'N' maybe the type - if (JSON_UNLIKELY(not unexpect_eof(input_format_t::ubjson, "type"))) + if (HEDLEY_UNLIKELY(not unexpect_eof(input_format_t::ubjson, "type"))) { return false; } get_ignore_noop(); - if (JSON_UNLIKELY(current != '#')) + if (HEDLEY_UNLIKELY(current != '#')) { - if (JSON_UNLIKELY(not unexpect_eof(input_format_t::ubjson, "value"))) + if (HEDLEY_UNLIKELY(not unexpect_eof(input_format_t::ubjson, "value"))) { return false; } @@ -1627,11 +1628,11 @@ class binary_reader case 'C': // char { get(); - if (JSON_UNLIKELY(not unexpect_eof(input_format_t::ubjson, "char"))) + if (HEDLEY_UNLIKELY(not unexpect_eof(input_format_t::ubjson, "char"))) { return false; } - if (JSON_UNLIKELY(current > 127)) + if (HEDLEY_UNLIKELY(current > 127)) { auto last_token = get_token_string(); return sax->parse_error(chars_read, last_token, parse_error::create(113, chars_read, exception_message(input_format_t::ubjson, "byte after 'C' must be in range 0x00..0x7F; last byte: 0x" + last_token, "char"))); @@ -1666,14 +1667,14 @@ class binary_reader bool get_ubjson_array() { std::pair size_and_type; - if (JSON_UNLIKELY(not get_ubjson_size_type(size_and_type))) + if (HEDLEY_UNLIKELY(not get_ubjson_size_type(size_and_type))) { return false; } if (size_and_type.first != string_t::npos) { - if (JSON_UNLIKELY(not sax->start_array(size_and_type.first))) + if (HEDLEY_UNLIKELY(not sax->start_array(size_and_type.first))) { return false; } @@ -1684,7 +1685,7 @@ class binary_reader { for (std::size_t i = 0; i < size_and_type.first; ++i) { - if (JSON_UNLIKELY(not get_ubjson_value(size_and_type.second))) + if (HEDLEY_UNLIKELY(not get_ubjson_value(size_and_type.second))) { return false; } @@ -1695,7 +1696,7 @@ class binary_reader { for (std::size_t i = 0; i < size_and_type.first; ++i) { - if (JSON_UNLIKELY(not parse_ubjson_internal())) + if (HEDLEY_UNLIKELY(not parse_ubjson_internal())) { return false; } @@ -1704,14 +1705,14 @@ class binary_reader } else { - if (JSON_UNLIKELY(not sax->start_array(std::size_t(-1)))) + if (HEDLEY_UNLIKELY(not sax->start_array(std::size_t(-1)))) { return false; } while (current != ']') { - if (JSON_UNLIKELY(not parse_ubjson_internal(false))) + if (HEDLEY_UNLIKELY(not parse_ubjson_internal(false))) { return false; } @@ -1728,7 +1729,7 @@ class binary_reader bool get_ubjson_object() { std::pair size_and_type; - if (JSON_UNLIKELY(not get_ubjson_size_type(size_and_type))) + if (HEDLEY_UNLIKELY(not get_ubjson_size_type(size_and_type))) { return false; } @@ -1736,7 +1737,7 @@ class binary_reader string_t key; if (size_and_type.first != string_t::npos) { - if (JSON_UNLIKELY(not sax->start_object(size_and_type.first))) + if (HEDLEY_UNLIKELY(not sax->start_object(size_and_type.first))) { return false; } @@ -1745,11 +1746,11 @@ class binary_reader { for (std::size_t i = 0; i < size_and_type.first; ++i) { - if (JSON_UNLIKELY(not get_ubjson_string(key) or not sax->key(key))) + if (HEDLEY_UNLIKELY(not get_ubjson_string(key) or not sax->key(key))) { return false; } - if (JSON_UNLIKELY(not get_ubjson_value(size_and_type.second))) + if (HEDLEY_UNLIKELY(not get_ubjson_value(size_and_type.second))) { return false; } @@ -1760,11 +1761,11 @@ class binary_reader { for (std::size_t i = 0; i < size_and_type.first; ++i) { - if (JSON_UNLIKELY(not get_ubjson_string(key) or not sax->key(key))) + if (HEDLEY_UNLIKELY(not get_ubjson_string(key) or not sax->key(key))) { return false; } - if (JSON_UNLIKELY(not parse_ubjson_internal())) + if (HEDLEY_UNLIKELY(not parse_ubjson_internal())) { return false; } @@ -1774,18 +1775,18 @@ class binary_reader } else { - if (JSON_UNLIKELY(not sax->start_object(std::size_t(-1)))) + if (HEDLEY_UNLIKELY(not sax->start_object(std::size_t(-1)))) { return false; } while (current != '}') { - if (JSON_UNLIKELY(not get_ubjson_string(key, false) or not sax->key(key))) + if (HEDLEY_UNLIKELY(not get_ubjson_string(key, false) or not sax->key(key))) { return false; } - if (JSON_UNLIKELY(not parse_ubjson_internal())) + if (HEDLEY_UNLIKELY(not parse_ubjson_internal())) { return false; } @@ -1851,7 +1852,7 @@ class binary_reader for (std::size_t i = 0; i < sizeof(NumberType); ++i) { get(); - if (JSON_UNLIKELY(not unexpect_eof(format, "number"))) + if (HEDLEY_UNLIKELY(not unexpect_eof(format, "number"))) { return false; } @@ -1895,7 +1896,7 @@ class binary_reader std::generate_n(std::back_inserter(result), len, [this, &success, &format]() { get(); - if (JSON_UNLIKELY(not unexpect_eof(format, "string"))) + if (HEDLEY_UNLIKELY(not unexpect_eof(format, "string"))) { success = false; } @@ -1909,9 +1910,10 @@ class binary_reader @param[in] context further context information (for diagnostics) @return whether the last read character is not EOF */ + HEDLEY_NON_NULL(3) bool unexpect_eof(const input_format_t format, const char* context) const { - if (JSON_UNLIKELY(current == std::char_traits::eof())) + if (HEDLEY_UNLIKELY(current == std::char_traits::eof())) { return sax->parse_error(chars_read, "", parse_error::create(110, chars_read, exception_message(format, "unexpected end of input", context))); diff --git a/include/nlohmann/detail/input/input_adapters.hpp b/include/nlohmann/detail/input/input_adapters.hpp index 5d9e200e..487cb525 100644 --- a/include/nlohmann/detail/input/input_adapters.hpp +++ b/include/nlohmann/detail/input/input_adapters.hpp @@ -55,6 +55,7 @@ Input adapter for stdio file access. This adapter read only 1 byte and do not us class file_input_adapter : public input_adapter_protocol { public: + HEDLEY_NON_NULL(2) explicit file_input_adapter(std::FILE* f) noexcept : m_file(f) {} @@ -130,6 +131,7 @@ class input_stream_adapter : public input_adapter_protocol class input_buffer_adapter : public input_adapter_protocol { public: + HEDLEY_NON_NULL(2) input_buffer_adapter(const char* b, const std::size_t l) noexcept : cursor(b), limit(b + l) {} @@ -143,7 +145,7 @@ class input_buffer_adapter : public input_adapter_protocol std::char_traits::int_type get_character() noexcept override { - if (JSON_LIKELY(cursor < limit)) + if (HEDLEY_LIKELY(cursor < limit)) { return std::char_traits::to_int_type(*(cursor++)); } @@ -333,6 +335,7 @@ class input_adapter { public: // native support + HEDLEY_NON_NULL(2) input_adapter(std::FILE* file) : ia(std::make_shared(file)) {} /// input adapter for input stream @@ -401,7 +404,7 @@ class input_adapter "each element in the iterator range must have the size of 1 byte"); const auto len = static_cast(std::distance(first, last)); - if (JSON_LIKELY(len > 0)) + if (HEDLEY_LIKELY(len > 0)) { // there is at least one element: use the address of first ia = std::make_shared(reinterpret_cast(&(*first)), len); diff --git a/include/nlohmann/detail/input/json_sax.hpp b/include/nlohmann/detail/input/json_sax.hpp index 66651a90..b4cd1c9b 100644 --- a/include/nlohmann/detail/input/json_sax.hpp +++ b/include/nlohmann/detail/input/json_sax.hpp @@ -206,7 +206,7 @@ class json_sax_dom_parser { ref_stack.push_back(handle_value(BasicJsonType::value_t::object)); - if (JSON_UNLIKELY(len != std::size_t(-1) and len > ref_stack.back()->max_size())) + if (HEDLEY_UNLIKELY(len != std::size_t(-1) and len > ref_stack.back()->max_size())) { JSON_THROW(out_of_range::create(408, "excessive object size: " + std::to_string(len))); @@ -232,7 +232,7 @@ class json_sax_dom_parser { ref_stack.push_back(handle_value(BasicJsonType::value_t::array)); - if (JSON_UNLIKELY(len != std::size_t(-1) and len > ref_stack.back()->max_size())) + if (HEDLEY_UNLIKELY(len != std::size_t(-1) and len > ref_stack.back()->max_size())) { JSON_THROW(out_of_range::create(408, "excessive array size: " + std::to_string(len))); @@ -288,6 +288,7 @@ class json_sax_dom_parser object to which we can add elements */ template + HEDLEY_RETURNS_NON_NULL BasicJsonType* handle_value(Value&& v) { if (ref_stack.empty()) @@ -394,7 +395,7 @@ class json_sax_dom_callback_parser ref_stack.push_back(val.second); // check object limit - if (ref_stack.back() and JSON_UNLIKELY(len != std::size_t(-1) and len > ref_stack.back()->max_size())) + if (ref_stack.back() and HEDLEY_UNLIKELY(len != std::size_t(-1) and len > ref_stack.back()->max_size())) { JSON_THROW(out_of_range::create(408, "excessive object size: " + std::to_string(len))); } @@ -457,7 +458,7 @@ class json_sax_dom_callback_parser ref_stack.push_back(val.second); // check array limit - if (ref_stack.back() and JSON_UNLIKELY(len != std::size_t(-1) and len > ref_stack.back()->max_size())) + if (ref_stack.back() and HEDLEY_UNLIKELY(len != std::size_t(-1) and len > ref_stack.back()->max_size())) { JSON_THROW(out_of_range::create(408, "excessive array size: " + std::to_string(len))); } diff --git a/include/nlohmann/detail/input/lexer.hpp b/include/nlohmann/detail/input/lexer.hpp index c135420f..04b9a31e 100644 --- a/include/nlohmann/detail/input/lexer.hpp +++ b/include/nlohmann/detail/input/lexer.hpp @@ -59,6 +59,7 @@ class lexer }; /// return name of values of type token_type (only used for errors) + HEDLEY_RETURNS_NON_NULL static const char* token_type_name(const token_type t) noexcept { switch (t) @@ -200,7 +201,7 @@ class lexer for (auto range = ranges.begin(); range != ranges.end(); ++range) { get(); - if (JSON_LIKELY(*range <= current and current <= *(++range))) + if (HEDLEY_LIKELY(*range <= current and current <= *(++range))) { add(current); } @@ -299,7 +300,7 @@ class lexer const int codepoint1 = get_codepoint(); int codepoint = codepoint1; // start with codepoint1 - if (JSON_UNLIKELY(codepoint1 == -1)) + if (HEDLEY_UNLIKELY(codepoint1 == -1)) { error_message = "invalid string: '\\u' must be followed by 4 hex digits"; return token_type::parse_error; @@ -309,18 +310,18 @@ class lexer if (0xD800 <= codepoint1 and codepoint1 <= 0xDBFF) { // expect next \uxxxx entry - if (JSON_LIKELY(get() == '\\' and get() == 'u')) + if (HEDLEY_LIKELY(get() == '\\' and get() == 'u')) { const int codepoint2 = get_codepoint(); - if (JSON_UNLIKELY(codepoint2 == -1)) + if (HEDLEY_UNLIKELY(codepoint2 == -1)) { error_message = "invalid string: '\\u' must be followed by 4 hex digits"; return token_type::parse_error; } // check if codepoint2 is a low surrogate - if (JSON_LIKELY(0xDC00 <= codepoint2 and codepoint2 <= 0xDFFF)) + if (HEDLEY_LIKELY(0xDC00 <= codepoint2 and codepoint2 <= 0xDFFF)) { // overwrite codepoint codepoint = static_cast( @@ -347,7 +348,7 @@ class lexer } else { - if (JSON_UNLIKELY(0xDC00 <= codepoint1 and codepoint1 <= 0xDFFF)) + if (HEDLEY_UNLIKELY(0xDC00 <= codepoint1 and codepoint1 <= 0xDFFF)) { error_message = "invalid string: surrogate U+DC00..U+DFFF must follow U+D800..U+DBFF"; return token_type::parse_error; @@ -722,7 +723,7 @@ class lexer case 0xDE: case 0xDF: { - if (JSON_UNLIKELY(not next_byte_in_range({0x80, 0xBF}))) + if (HEDLEY_UNLIKELY(not next_byte_in_range({0x80, 0xBF}))) { return token_type::parse_error; } @@ -732,7 +733,7 @@ class lexer // U+0800..U+0FFF: bytes E0 A0..BF 80..BF case 0xE0: { - if (JSON_UNLIKELY(not (next_byte_in_range({0xA0, 0xBF, 0x80, 0xBF})))) + if (HEDLEY_UNLIKELY(not (next_byte_in_range({0xA0, 0xBF, 0x80, 0xBF})))) { return token_type::parse_error; } @@ -756,7 +757,7 @@ class lexer case 0xEE: case 0xEF: { - if (JSON_UNLIKELY(not (next_byte_in_range({0x80, 0xBF, 0x80, 0xBF})))) + if (HEDLEY_UNLIKELY(not (next_byte_in_range({0x80, 0xBF, 0x80, 0xBF})))) { return token_type::parse_error; } @@ -766,7 +767,7 @@ class lexer // U+D000..U+D7FF: bytes ED 80..9F 80..BF case 0xED: { - if (JSON_UNLIKELY(not (next_byte_in_range({0x80, 0x9F, 0x80, 0xBF})))) + if (HEDLEY_UNLIKELY(not (next_byte_in_range({0x80, 0x9F, 0x80, 0xBF})))) { return token_type::parse_error; } @@ -776,7 +777,7 @@ class lexer // U+10000..U+3FFFF F0 90..BF 80..BF 80..BF case 0xF0: { - if (JSON_UNLIKELY(not (next_byte_in_range({0x90, 0xBF, 0x80, 0xBF, 0x80, 0xBF})))) + if (HEDLEY_UNLIKELY(not (next_byte_in_range({0x90, 0xBF, 0x80, 0xBF, 0x80, 0xBF})))) { return token_type::parse_error; } @@ -788,7 +789,7 @@ class lexer case 0xF2: case 0xF3: { - if (JSON_UNLIKELY(not (next_byte_in_range({0x80, 0xBF, 0x80, 0xBF, 0x80, 0xBF})))) + if (HEDLEY_UNLIKELY(not (next_byte_in_range({0x80, 0xBF, 0x80, 0xBF, 0x80, 0xBF})))) { return token_type::parse_error; } @@ -798,7 +799,7 @@ class lexer // U+100000..U+10FFFF F4 80..8F 80..BF 80..BF case 0xF4: { - if (JSON_UNLIKELY(not (next_byte_in_range({0x80, 0x8F, 0x80, 0xBF, 0x80, 0xBF})))) + if (HEDLEY_UNLIKELY(not (next_byte_in_range({0x80, 0x8F, 0x80, 0xBF, 0x80, 0xBF})))) { return token_type::parse_error; } @@ -815,16 +816,19 @@ class lexer } } + HEDLEY_NON_NULL(2) static void strtof(float& f, const char* str, char** endptr) noexcept { f = std::strtof(str, endptr); } + HEDLEY_NON_NULL(2) static void strtof(double& f, const char* str, char** endptr) noexcept { f = std::strtod(str, endptr); } + HEDLEY_NON_NULL(2) static void strtof(long double& f, const char* str, char** endptr) noexcept { f = std::strtold(str, endptr); @@ -1200,13 +1204,14 @@ scan_number_done: @param[in] length the length of the passed literal text @param[in] return_type the token type to return on success */ + HEDLEY_NON_NULL(2) token_type scan_literal(const char* literal_text, const std::size_t length, token_type return_type) { assert(current == literal_text[0]); for (std::size_t i = 1; i < length; ++i) { - if (JSON_UNLIKELY(get() != literal_text[i])) + if (HEDLEY_UNLIKELY(get() != literal_text[i])) { error_message = "invalid literal"; return token_type::parse_error; @@ -1252,7 +1257,7 @@ scan_number_done: current = ia->get_character(); } - if (JSON_LIKELY(current != std::char_traits::eof())) + if (HEDLEY_LIKELY(current != std::char_traits::eof())) { token_string.push_back(std::char_traits::to_char_type(current)); } @@ -1293,7 +1298,7 @@ scan_number_done: --position.chars_read_current_line; } - if (JSON_LIKELY(current != std::char_traits::eof())) + if (HEDLEY_LIKELY(current != std::char_traits::eof())) { assert(not token_string.empty()); token_string.pop_back(); @@ -1372,6 +1377,7 @@ scan_number_done: } /// return syntax error message + HEDLEY_RETURNS_NON_NULL constexpr const char* get_error_message() const noexcept { return error_message; diff --git a/include/nlohmann/detail/input/parser.hpp b/include/nlohmann/detail/input/parser.hpp index 6c03181e..55a972e3 100644 --- a/include/nlohmann/detail/input/parser.hpp +++ b/include/nlohmann/detail/input/parser.hpp @@ -147,6 +147,7 @@ class parser } template + HEDLEY_NON_NULL(2) bool sax_parse(SAX* sax, const bool strict = true) { (void)detail::is_sax_static_asserts {}; @@ -166,6 +167,7 @@ class parser private: template + HEDLEY_NON_NULL(2) bool sax_parse_internal(SAX* sax) { // stack to remember the hierarchy of structured values we are parsing @@ -183,7 +185,7 @@ class parser { case token_type::begin_object: { - if (JSON_UNLIKELY(not sax->start_object(std::size_t(-1)))) + if (HEDLEY_UNLIKELY(not sax->start_object(std::size_t(-1)))) { return false; } @@ -191,7 +193,7 @@ class parser // closing } -> we are done if (get_token() == token_type::end_object) { - if (JSON_UNLIKELY(not sax->end_object())) + if (HEDLEY_UNLIKELY(not sax->end_object())) { return false; } @@ -199,20 +201,20 @@ class parser } // parse key - if (JSON_UNLIKELY(last_token != token_type::value_string)) + if (HEDLEY_UNLIKELY(last_token != token_type::value_string)) { return sax->parse_error(m_lexer.get_position(), m_lexer.get_token_string(), parse_error::create(101, m_lexer.get_position(), exception_message(token_type::value_string, "object key"))); } - if (JSON_UNLIKELY(not sax->key(m_lexer.get_string()))) + if (HEDLEY_UNLIKELY(not sax->key(m_lexer.get_string()))) { return false; } // parse separator (:) - if (JSON_UNLIKELY(get_token() != token_type::name_separator)) + if (HEDLEY_UNLIKELY(get_token() != token_type::name_separator)) { return sax->parse_error(m_lexer.get_position(), m_lexer.get_token_string(), @@ -230,7 +232,7 @@ class parser case token_type::begin_array: { - if (JSON_UNLIKELY(not sax->start_array(std::size_t(-1)))) + if (HEDLEY_UNLIKELY(not sax->start_array(std::size_t(-1)))) { return false; } @@ -238,7 +240,7 @@ class parser // closing ] -> we are done if (get_token() == token_type::end_array) { - if (JSON_UNLIKELY(not sax->end_array())) + if (HEDLEY_UNLIKELY(not sax->end_array())) { return false; } @@ -256,14 +258,14 @@ class parser { const auto res = m_lexer.get_number_float(); - if (JSON_UNLIKELY(not std::isfinite(res))) + if (HEDLEY_UNLIKELY(not std::isfinite(res))) { return sax->parse_error(m_lexer.get_position(), m_lexer.get_token_string(), out_of_range::create(406, "number overflow parsing '" + m_lexer.get_token_string() + "'")); } - if (JSON_UNLIKELY(not sax->number_float(res, m_lexer.get_string()))) + if (HEDLEY_UNLIKELY(not sax->number_float(res, m_lexer.get_string()))) { return false; } @@ -273,7 +275,7 @@ class parser case token_type::literal_false: { - if (JSON_UNLIKELY(not sax->boolean(false))) + if (HEDLEY_UNLIKELY(not sax->boolean(false))) { return false; } @@ -282,7 +284,7 @@ class parser case token_type::literal_null: { - if (JSON_UNLIKELY(not sax->null())) + if (HEDLEY_UNLIKELY(not sax->null())) { return false; } @@ -291,7 +293,7 @@ class parser case token_type::literal_true: { - if (JSON_UNLIKELY(not sax->boolean(true))) + if (HEDLEY_UNLIKELY(not sax->boolean(true))) { return false; } @@ -300,7 +302,7 @@ class parser case token_type::value_integer: { - if (JSON_UNLIKELY(not sax->number_integer(m_lexer.get_number_integer()))) + if (HEDLEY_UNLIKELY(not sax->number_integer(m_lexer.get_number_integer()))) { return false; } @@ -309,7 +311,7 @@ class parser case token_type::value_string: { - if (JSON_UNLIKELY(not sax->string(m_lexer.get_string()))) + if (HEDLEY_UNLIKELY(not sax->string(m_lexer.get_string()))) { return false; } @@ -318,7 +320,7 @@ class parser case token_type::value_unsigned: { - if (JSON_UNLIKELY(not sax->number_unsigned(m_lexer.get_number_unsigned()))) + if (HEDLEY_UNLIKELY(not sax->number_unsigned(m_lexer.get_number_unsigned()))) { return false; } @@ -366,9 +368,9 @@ class parser } // closing ] - if (JSON_LIKELY(last_token == token_type::end_array)) + if (HEDLEY_LIKELY(last_token == token_type::end_array)) { - if (JSON_UNLIKELY(not sax->end_array())) + if (HEDLEY_UNLIKELY(not sax->end_array())) { return false; } @@ -394,7 +396,7 @@ class parser if (get_token() == token_type::value_separator) { // parse key - if (JSON_UNLIKELY(get_token() != token_type::value_string)) + if (HEDLEY_UNLIKELY(get_token() != token_type::value_string)) { return sax->parse_error(m_lexer.get_position(), m_lexer.get_token_string(), @@ -402,13 +404,13 @@ class parser exception_message(token_type::value_string, "object key"))); } - if (JSON_UNLIKELY(not sax->key(m_lexer.get_string()))) + if (HEDLEY_UNLIKELY(not sax->key(m_lexer.get_string()))) { return false; } // parse separator (:) - if (JSON_UNLIKELY(get_token() != token_type::name_separator)) + if (HEDLEY_UNLIKELY(get_token() != token_type::name_separator)) { return sax->parse_error(m_lexer.get_position(), m_lexer.get_token_string(), @@ -422,9 +424,9 @@ class parser } // closing } - if (JSON_LIKELY(last_token == token_type::end_object)) + if (HEDLEY_LIKELY(last_token == token_type::end_object)) { - if (JSON_UNLIKELY(not sax->end_object())) + if (HEDLEY_UNLIKELY(not sax->end_object())) { return false; } diff --git a/include/nlohmann/detail/iterators/iter_impl.hpp b/include/nlohmann/detail/iterators/iter_impl.hpp index bc87de29..af03cb60 100644 --- a/include/nlohmann/detail/iterators/iter_impl.hpp +++ b/include/nlohmann/detail/iterators/iter_impl.hpp @@ -126,7 +126,8 @@ class iter_impl information refer to: https://github.com/nlohmann/json/issues/1608 */ iter_impl(const iter_impl& other) noexcept - : m_object(other.m_object), m_it(other.m_it) {} + : m_object(other.m_object), m_it(other.m_it) + {} /*! @brief converting constructor @@ -134,7 +135,8 @@ class iter_impl @note It is not checked whether @a other is initialized. */ iter_impl(const iter_impl::type>& other) noexcept - : m_object(other.m_object), m_it(other.m_it) {} + : m_object(other.m_object), m_it(other.m_it) + {} /*! @brief converting assignment @@ -149,6 +151,14 @@ class iter_impl return *this; } + /// @copydoc operator=(const iter_impl::type>&) + iter_impl& operator=(const iter_impl& other) noexcept + { + m_object = other.m_object; + m_it = other.m_it; + return *this; + } + private: /*! @brief set the iterator to the first value @@ -245,7 +255,7 @@ class iter_impl default: { - if (JSON_LIKELY(m_it.primitive_iterator.is_begin())) + if (HEDLEY_LIKELY(m_it.primitive_iterator.is_begin())) { return *m_object; } @@ -279,7 +289,7 @@ class iter_impl default: { - if (JSON_LIKELY(m_it.primitive_iterator.is_begin())) + if (HEDLEY_LIKELY(m_it.primitive_iterator.is_begin())) { return m_object; } @@ -382,7 +392,7 @@ class iter_impl bool operator==(const iter_impl& other) const { // if objects are not the same, the comparison is undefined - if (JSON_UNLIKELY(m_object != other.m_object)) + if (HEDLEY_UNLIKELY(m_object != other.m_object)) { JSON_THROW(invalid_iterator::create(212, "cannot compare iterators of different containers")); } @@ -418,7 +428,7 @@ class iter_impl bool operator<(const iter_impl& other) const { // if objects are not the same, the comparison is undefined - if (JSON_UNLIKELY(m_object != other.m_object)) + if (HEDLEY_UNLIKELY(m_object != other.m_object)) { JSON_THROW(invalid_iterator::create(212, "cannot compare iterators of different containers")); } @@ -578,7 +588,7 @@ class iter_impl default: { - if (JSON_LIKELY(m_it.primitive_iterator.get_value() == -n)) + if (HEDLEY_LIKELY(m_it.primitive_iterator.get_value() == -n)) { return *m_object; } @@ -596,7 +606,7 @@ class iter_impl { assert(m_object != nullptr); - if (JSON_LIKELY(m_object->is_object())) + if (HEDLEY_LIKELY(m_object->is_object())) { return m_it.object_iterator->first; } @@ -619,5 +629,5 @@ class iter_impl /// the actual iterator of the associated instance internal_iterator::type> m_it {}; }; -} // namespace detail +} // namespace detail } // namespace nlohmann diff --git a/include/nlohmann/detail/json_pointer.hpp b/include/nlohmann/detail/json_pointer.hpp index 465e5165..644504b4 100644 --- a/include/nlohmann/detail/json_pointer.hpp +++ b/include/nlohmann/detail/json_pointer.hpp @@ -244,7 +244,7 @@ class json_pointer */ void pop_back() { - if (JSON_UNLIKELY(empty())) + if (HEDLEY_UNLIKELY(empty())) { JSON_THROW(detail::out_of_range::create(405, "JSON pointer has no parent")); } @@ -268,7 +268,7 @@ class json_pointer */ const std::string& back() { - if (JSON_UNLIKELY(empty())) + if (HEDLEY_UNLIKELY(empty())) { JSON_THROW(detail::out_of_range::create(405, "JSON pointer has no parent")); } @@ -332,7 +332,7 @@ class json_pointer const int res = std::stoi(s, &processed_chars); // check if the string was completely read - if (JSON_UNLIKELY(processed_chars != s.size())) + if (HEDLEY_UNLIKELY(processed_chars != s.size())) { JSON_THROW(detail::out_of_range::create(404, "unresolved reference token '" + s + "'")); } @@ -342,7 +342,7 @@ class json_pointer json_pointer top() const { - if (JSON_UNLIKELY(empty())) + if (HEDLEY_UNLIKELY(empty())) { JSON_THROW(detail::out_of_range::create(405, "JSON pointer has no parent")); } @@ -474,7 +474,7 @@ class json_pointer case detail::value_t::array: { // error condition (cf. RFC 6901, Sect. 4) - if (JSON_UNLIKELY(reference_token.size() > 1 and reference_token[0] == '0')) + if (HEDLEY_UNLIKELY(reference_token.size() > 1 and reference_token[0] == '0')) { JSON_THROW(detail::parse_error::create(106, 0, "array index '" + reference_token + @@ -532,7 +532,7 @@ class json_pointer case detail::value_t::array: { - if (JSON_UNLIKELY(reference_token == "-")) + if (HEDLEY_UNLIKELY(reference_token == "-")) { // "-" always fails the range check JSON_THROW(detail::out_of_range::create(402, @@ -541,7 +541,7 @@ class json_pointer } // error condition (cf. RFC 6901, Sect. 4) - if (JSON_UNLIKELY(reference_token.size() > 1 and reference_token[0] == '0')) + if (HEDLEY_UNLIKELY(reference_token.size() > 1 and reference_token[0] == '0')) { JSON_THROW(detail::parse_error::create(106, 0, "array index '" + reference_token + @@ -597,7 +597,7 @@ class json_pointer case detail::value_t::array: { - if (JSON_UNLIKELY(reference_token == "-")) + if (HEDLEY_UNLIKELY(reference_token == "-")) { // "-" cannot be used for const access JSON_THROW(detail::out_of_range::create(402, @@ -606,7 +606,7 @@ class json_pointer } // error condition (cf. RFC 6901, Sect. 4) - if (JSON_UNLIKELY(reference_token.size() > 1 and reference_token[0] == '0')) + if (HEDLEY_UNLIKELY(reference_token.size() > 1 and reference_token[0] == '0')) { JSON_THROW(detail::parse_error::create(106, 0, "array index '" + reference_token + @@ -656,7 +656,7 @@ class json_pointer case detail::value_t::array: { - if (JSON_UNLIKELY(reference_token == "-")) + if (HEDLEY_UNLIKELY(reference_token == "-")) { // "-" always fails the range check JSON_THROW(detail::out_of_range::create(402, @@ -665,7 +665,7 @@ class json_pointer } // error condition (cf. RFC 6901, Sect. 4) - if (JSON_UNLIKELY(reference_token.size() > 1 and reference_token[0] == '0')) + if (HEDLEY_UNLIKELY(reference_token.size() > 1 and reference_token[0] == '0')) { JSON_THROW(detail::parse_error::create(106, 0, "array index '" + reference_token + @@ -712,7 +712,7 @@ class json_pointer } // check if nonempty reference string begins with slash - if (JSON_UNLIKELY(reference_string[0] != '/')) + if (HEDLEY_UNLIKELY(reference_string[0] != '/')) { JSON_THROW(detail::parse_error::create(107, 1, "JSON pointer must be empty or begin with '/' - was: '" + @@ -747,9 +747,9 @@ class json_pointer assert(reference_token[pos] == '~'); // ~ must be followed by 0 or 1 - if (JSON_UNLIKELY(pos == reference_token.size() - 1 or - (reference_token[pos + 1] != '0' and - reference_token[pos + 1] != '1'))) + if (HEDLEY_UNLIKELY(pos == reference_token.size() - 1 or + (reference_token[pos + 1] != '0' and + reference_token[pos + 1] != '1'))) { JSON_THROW(detail::parse_error::create(108, 0, "escape character '~' must be followed with '0' or '1'")); } @@ -874,7 +874,7 @@ class json_pointer static BasicJsonType unflatten(const BasicJsonType& value) { - if (JSON_UNLIKELY(not value.is_object())) + if (HEDLEY_UNLIKELY(not value.is_object())) { JSON_THROW(detail::type_error::create(314, "only objects can be unflattened")); } @@ -884,7 +884,7 @@ class json_pointer // iterate the JSON object values for (const auto& element : *value.m_value.object) { - if (JSON_UNLIKELY(not element.second.is_primitive())) + if (HEDLEY_UNLIKELY(not element.second.is_primitive())) { JSON_THROW(detail::type_error::create(315, "values in object must be primitive")); } diff --git a/include/nlohmann/detail/macro_scope.hpp b/include/nlohmann/detail/macro_scope.hpp index e41180a9..2be7581d 100644 --- a/include/nlohmann/detail/macro_scope.hpp +++ b/include/nlohmann/detail/macro_scope.hpp @@ -1,6 +1,7 @@ #pragma once #include // pair +#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 @@ -38,32 +39,6 @@ #pragma GCC diagnostic ignored "-Wdocumentation" #endif -// allow for portable deprecation warnings -#if defined(__clang__) || defined(__GNUC__) || defined(__GNUG__) - #define JSON_DEPRECATED __attribute__((deprecated)) -#elif defined(_MSC_VER) - #define JSON_DEPRECATED __declspec(deprecated) -#else - #define JSON_DEPRECATED -#endif - -// allow for portable nodiscard warnings -#if defined(__has_cpp_attribute) - #if __has_cpp_attribute(nodiscard) - #if defined(__clang__) && !defined(JSON_HAS_CPP_17) // issue #1535 - #define JSON_NODISCARD - #else - #define JSON_NODISCARD [[nodiscard]] - #endif - #elif __has_cpp_attribute(gnu::warn_unused_result) - #define JSON_NODISCARD [[gnu::warn_unused_result]] - #else - #define JSON_NODISCARD - #endif -#else - #define JSON_NODISCARD -#endif - // allow to disable exceptions #if (defined(__cpp_exceptions) || defined(__EXCEPTIONS) || defined(_CPPUNWIND)) && !defined(JSON_NOEXCEPTION) #define JSON_THROW(exception) throw exception @@ -98,15 +73,6 @@ #define JSON_INTERNAL_CATCH JSON_INTERNAL_CATCH_USER #endif -// manual branch prediction -#if defined(__clang__) || defined(__GNUC__) || defined(__GNUG__) - #define JSON_LIKELY(x) __builtin_expect(x, 1) - #define JSON_UNLIKELY(x) __builtin_expect(x, 0) -#else - #define JSON_LIKELY(x) x - #define JSON_UNLIKELY(x) x -#endif - /*! @brief macro to briefly define a mapping between an enum and JSON @def NLOHMANN_JSON_SERIALIZE_ENUM diff --git a/include/nlohmann/detail/macro_unscope.hpp b/include/nlohmann/detail/macro_unscope.hpp index 592debf7..8ad57a57 100644 --- a/include/nlohmann/detail/macro_unscope.hpp +++ b/include/nlohmann/detail/macro_unscope.hpp @@ -13,10 +13,6 @@ #undef JSON_CATCH #undef JSON_THROW #undef JSON_TRY -#undef JSON_LIKELY -#undef JSON_UNLIKELY -#undef JSON_DEPRECATED -#undef JSON_NODISCARD #undef JSON_HAS_CPP_14 #undef JSON_HAS_CPP_17 #undef NLOHMANN_BASIC_JSON_TPL_DECLARATION diff --git a/include/nlohmann/detail/output/binary_writer.hpp b/include/nlohmann/detail/output/binary_writer.hpp index a8fddfee..54206fd4 100644 --- a/include/nlohmann/detail/output/binary_writer.hpp +++ b/include/nlohmann/detail/output/binary_writer.hpp @@ -8,6 +8,7 @@ #include // string #include +#include #include namespace nlohmann @@ -714,7 +715,7 @@ class binary_writer static std::size_t calc_bson_entry_header_size(const string_t& name) { const auto it = name.find(static_cast(0)); - if (JSON_UNLIKELY(it != BasicJsonType::string_t::npos)) + if (HEDLEY_UNLIKELY(it != BasicJsonType::string_t::npos)) { JSON_THROW(out_of_range::create(409, "BSON key cannot contain code point U+0000 (at byte " + std::to_string(it) + ")")); diff --git a/include/nlohmann/detail/output/output_adapters.hpp b/include/nlohmann/detail/output/output_adapters.hpp index 699757d6..65090221 100644 --- a/include/nlohmann/detail/output/output_adapters.hpp +++ b/include/nlohmann/detail/output/output_adapters.hpp @@ -8,6 +8,7 @@ #include // basic_ostream #include // basic_string #include // vector +#include namespace nlohmann { @@ -39,6 +40,7 @@ class output_vector_adapter : public output_adapter_protocol v.push_back(c); } + HEDLEY_NON_NULL(2) void write_characters(const CharType* s, std::size_t length) override { std::copy(s, s + length, std::back_inserter(v)); @@ -62,6 +64,7 @@ class output_stream_adapter : public output_adapter_protocol stream.put(c); } + HEDLEY_NON_NULL(2) void write_characters(const CharType* s, std::size_t length) override { stream.write(s, static_cast(length)); @@ -85,6 +88,7 @@ class output_string_adapter : public output_adapter_protocol str.push_back(c); } + HEDLEY_NON_NULL(2) void write_characters(const CharType* s, std::size_t length) override { str.append(s, length); diff --git a/include/nlohmann/detail/output/serializer.hpp b/include/nlohmann/detail/output/serializer.hpp index bb7f1314..d17f54d4 100644 --- a/include/nlohmann/detail/output/serializer.hpp +++ b/include/nlohmann/detail/output/serializer.hpp @@ -110,7 +110,7 @@ class serializer // variable to hold indentation for recursive calls const auto new_indent = current_indent + indent_step; - if (JSON_UNLIKELY(indent_string.size() < new_indent)) + if (HEDLEY_UNLIKELY(indent_string.size() < new_indent)) { indent_string.resize(indent_string.size() * 2, ' '); } @@ -183,7 +183,7 @@ class serializer // variable to hold indentation for recursive calls const auto new_indent = current_indent + indent_step; - if (JSON_UNLIKELY(indent_string.size() < new_indent)) + if (HEDLEY_UNLIKELY(indent_string.size() < new_indent)) { indent_string.resize(indent_string.size() * 2, ' '); } @@ -498,7 +498,7 @@ class serializer } // we finished processing the string - if (JSON_LIKELY(state == UTF8_ACCEPT)) + if (HEDLEY_LIKELY(state == UTF8_ACCEPT)) { // write buffer if (bytes > 0) diff --git a/include/nlohmann/json.hpp b/include/nlohmann/json.hpp index 58db19d7..2443f319 100644 --- a/include/nlohmann/json.hpp +++ b/include/nlohmann/json.hpp @@ -319,7 +319,7 @@ class basic_json @since 2.1.0 */ - JSON_NODISCARD + HEDLEY_WARN_UNUSED_RESULT static basic_json meta() { basic_json result; @@ -824,6 +824,7 @@ class basic_json /// helper for exception-safe object creation template + HEDLEY_RETURNS_NON_NULL static T* create(Args&& ... args) { AllocatorType alloc; @@ -950,7 +951,7 @@ class basic_json default: { object = nullptr; // silence warning, see #821 - if (JSON_UNLIKELY(t == value_t::null)) + if (HEDLEY_UNLIKELY(t == value_t::null)) { JSON_THROW(other_error::create(500, "961c151d2e87f2686a955a9be24d316f1362bf21 3.6.1")); // LCOV_EXCL_LINE } @@ -1427,7 +1428,7 @@ class basic_json } // if object is wanted but impossible, throw an exception - if (JSON_UNLIKELY(manual_type == value_t::object and not is_an_object)) + if (HEDLEY_UNLIKELY(manual_type == value_t::object and not is_an_object)) { JSON_THROW(type_error::create(301, "cannot create object from initializer list")); } @@ -1494,7 +1495,7 @@ class basic_json @since version 1.0.0 */ - JSON_NODISCARD + HEDLEY_WARN_UNUSED_RESULT static basic_json array(initializer_list_t init = {}) { return basic_json(init, false, value_t::array); @@ -1538,7 +1539,7 @@ class basic_json @since version 1.0.0 */ - JSON_NODISCARD + HEDLEY_WARN_UNUSED_RESULT static basic_json object(initializer_list_t init = {}) { return basic_json(init, false, value_t::object); @@ -1637,7 +1638,7 @@ class basic_json assert(last.m_object != nullptr); // make sure iterator fits the current value - if (JSON_UNLIKELY(first.m_object != last.m_object)) + if (HEDLEY_UNLIKELY(first.m_object != last.m_object)) { JSON_THROW(invalid_iterator::create(201, "iterators are not compatible")); } @@ -1654,8 +1655,8 @@ class basic_json case value_t::number_unsigned: case value_t::string: { - if (JSON_UNLIKELY(not first.m_it.primitive_iterator.is_begin() - or not last.m_it.primitive_iterator.is_end())) + if (HEDLEY_UNLIKELY(not first.m_it.primitive_iterator.is_begin() + or not last.m_it.primitive_iterator.is_end())) { JSON_THROW(invalid_iterator::create(204, "iterators out of range")); } @@ -2368,7 +2369,7 @@ class basic_json /// get a boolean (explicit) boolean_t get_impl(boolean_t* /*unused*/) const { - if (JSON_LIKELY(is_boolean())) + if (HEDLEY_LIKELY(is_boolean())) { return m_value.boolean; } @@ -2477,7 +2478,7 @@ class basic_json // delegate the call to get_ptr<>() auto ptr = obj.template get_ptr::type>(); - if (JSON_LIKELY(ptr != nullptr)) + if (HEDLEY_LIKELY(ptr != nullptr)) { return *ptr; } @@ -2928,7 +2929,7 @@ class basic_json reference at(size_type idx) { // at only works for arrays - if (JSON_LIKELY(is_array())) + if (HEDLEY_LIKELY(is_array())) { JSON_TRY { @@ -2975,7 +2976,7 @@ class basic_json const_reference at(size_type idx) const { // at only works for arrays - if (JSON_LIKELY(is_array())) + if (HEDLEY_LIKELY(is_array())) { JSON_TRY { @@ -3026,7 +3027,7 @@ class basic_json reference at(const typename object_t::key_type& key) { // at only works for objects - if (JSON_LIKELY(is_object())) + if (HEDLEY_LIKELY(is_object())) { JSON_TRY { @@ -3077,7 +3078,7 @@ class basic_json const_reference at(const typename object_t::key_type& key) const { // at only works for objects - if (JSON_LIKELY(is_object())) + if (HEDLEY_LIKELY(is_object())) { JSON_TRY { @@ -3131,7 +3132,7 @@ class basic_json } // operator[] only works for arrays - if (JSON_LIKELY(is_array())) + if (HEDLEY_LIKELY(is_array())) { // fill up array with null values if given idx is outside range if (idx >= m_value.array->size()) @@ -3169,7 +3170,7 @@ class basic_json const_reference operator[](size_type idx) const { // const operator[] only works for arrays - if (JSON_LIKELY(is_array())) + if (HEDLEY_LIKELY(is_array())) { return m_value.array->operator[](idx); } @@ -3215,7 +3216,7 @@ class basic_json } // operator[] only works for objects - if (JSON_LIKELY(is_object())) + if (HEDLEY_LIKELY(is_object())) { return m_value.object->operator[](key); } @@ -3256,7 +3257,7 @@ class basic_json const_reference operator[](const typename object_t::key_type& key) const { // const operator[] only works for objects - if (JSON_LIKELY(is_object())) + if (HEDLEY_LIKELY(is_object())) { assert(m_value.object->find(key) != m_value.object->end()); return m_value.object->find(key)->second; @@ -3293,6 +3294,7 @@ class basic_json @since version 1.1.0 */ template + HEDLEY_NON_NULL(2) reference operator[](T* key) { // implicitly convert null to object @@ -3304,7 +3306,7 @@ class basic_json } // at only works for objects - if (JSON_LIKELY(is_object())) + if (HEDLEY_LIKELY(is_object())) { return m_value.object->operator[](key); } @@ -3343,10 +3345,11 @@ class basic_json @since version 1.1.0 */ template + HEDLEY_NON_NULL(2) const_reference operator[](T* key) const { // at only works for objects - if (JSON_LIKELY(is_object())) + if (HEDLEY_LIKELY(is_object())) { assert(m_value.object->find(key) != m_value.object->end()); return m_value.object->find(key)->second; @@ -3410,7 +3413,7 @@ class basic_json ValueType value(const typename object_t::key_type& key, const ValueType& default_value) const { // at only works for objects - if (JSON_LIKELY(is_object())) + if (HEDLEY_LIKELY(is_object())) { // if key is found, return value and given default value otherwise const auto it = find(key); @@ -3482,7 +3485,7 @@ class basic_json ValueType value(const json_pointer& ptr, const ValueType& default_value) const { // at only works for objects - if (JSON_LIKELY(is_object())) + if (HEDLEY_LIKELY(is_object())) { // if pointer resolves a value, return it or use default value JSON_TRY @@ -3502,6 +3505,7 @@ class basic_json @brief overload for a default value of type const char* @copydoc basic_json::value(const json_pointer&, ValueType) const */ + HEDLEY_NON_NULL(3) string_t value(const json_pointer& ptr, const char* default_value) const { return value(ptr, string_t(default_value)); @@ -3646,7 +3650,7 @@ class basic_json IteratorType erase(IteratorType pos) { // make sure iterator fits the current value - if (JSON_UNLIKELY(this != pos.m_object)) + if (HEDLEY_UNLIKELY(this != pos.m_object)) { JSON_THROW(invalid_iterator::create(202, "iterator does not fit current value")); } @@ -3661,7 +3665,7 @@ class basic_json case value_t::number_unsigned: case value_t::string: { - if (JSON_UNLIKELY(not pos.m_it.primitive_iterator.is_begin())) + if (HEDLEY_UNLIKELY(not pos.m_it.primitive_iterator.is_begin())) { JSON_THROW(invalid_iterator::create(205, "iterator out of range")); } @@ -3751,7 +3755,7 @@ class basic_json IteratorType erase(IteratorType first, IteratorType last) { // make sure iterator fits the current value - if (JSON_UNLIKELY(this != first.m_object or this != last.m_object)) + if (HEDLEY_UNLIKELY(this != first.m_object or this != last.m_object)) { JSON_THROW(invalid_iterator::create(203, "iterators do not fit current value")); } @@ -3766,8 +3770,8 @@ class basic_json case value_t::number_unsigned: case value_t::string: { - if (JSON_LIKELY(not first.m_it.primitive_iterator.is_begin() - or not last.m_it.primitive_iterator.is_end())) + if (HEDLEY_LIKELY(not first.m_it.primitive_iterator.is_begin() + or not last.m_it.primitive_iterator.is_end())) { JSON_THROW(invalid_iterator::create(204, "iterators out of range")); } @@ -3838,7 +3842,7 @@ class basic_json size_type erase(const typename object_t::key_type& key) { // this erase only works for objects - if (JSON_LIKELY(is_object())) + if (HEDLEY_LIKELY(is_object())) { return m_value.object->erase(key); } @@ -3873,9 +3877,9 @@ class basic_json void erase(const size_type idx) { // this erase only works for arrays - if (JSON_LIKELY(is_array())) + if (HEDLEY_LIKELY(is_array())) { - if (JSON_UNLIKELY(idx >= size())) + if (HEDLEY_UNLIKELY(idx >= size())) { JSON_THROW(out_of_range::create(401, "array index " + std::to_string(idx) + " is out of range")); } @@ -4351,7 +4355,7 @@ class basic_json future 4.0.0 of the library. Please use @ref items() instead; that is, replace `json::iterator_wrapper(j)` with `j.items()`. */ - JSON_DEPRECATED + HEDLEY_DEPRECATED(3.1.0) static iteration_proxy iterator_wrapper(reference ref) noexcept { return ref.items(); @@ -4360,7 +4364,7 @@ class basic_json /*! @copydoc iterator_wrapper(reference) */ - JSON_DEPRECATED + HEDLEY_DEPRECATED(3.1.0) static iteration_proxy iterator_wrapper(const_reference ref) noexcept { return ref.items(); @@ -4779,7 +4783,7 @@ class basic_json void push_back(basic_json&& val) { // push_back only works for null objects or arrays - if (JSON_UNLIKELY(not(is_null() or is_array()))) + if (HEDLEY_UNLIKELY(not(is_null() or is_array()))) { JSON_THROW(type_error::create(308, "cannot use push_back() with " + std::string(type_name()))); } @@ -4816,7 +4820,7 @@ class basic_json void push_back(const basic_json& val) { // push_back only works for null objects or arrays - if (JSON_UNLIKELY(not(is_null() or is_array()))) + if (HEDLEY_UNLIKELY(not(is_null() or is_array()))) { JSON_THROW(type_error::create(308, "cannot use push_back() with " + std::string(type_name()))); } @@ -4866,7 +4870,7 @@ class basic_json void push_back(const typename object_t::value_type& val) { // push_back only works for null objects or objects - if (JSON_UNLIKELY(not(is_null() or is_object()))) + if (HEDLEY_UNLIKELY(not(is_null() or is_object()))) { JSON_THROW(type_error::create(308, "cannot use push_back() with " + std::string(type_name()))); } @@ -4967,7 +4971,7 @@ class basic_json void emplace_back(Args&& ... args) { // emplace_back only works for null objects or arrays - if (JSON_UNLIKELY(not(is_null() or is_array()))) + if (HEDLEY_UNLIKELY(not(is_null() or is_array()))) { JSON_THROW(type_error::create(311, "cannot use emplace_back() with " + std::string(type_name()))); } @@ -5015,7 +5019,7 @@ class basic_json std::pair emplace(Args&& ... args) { // emplace only works for null objects or arrays - if (JSON_UNLIKELY(not(is_null() or is_object()))) + if (HEDLEY_UNLIKELY(not(is_null() or is_object()))) { JSON_THROW(type_error::create(311, "cannot use emplace() with " + std::string(type_name()))); } @@ -5083,10 +5087,10 @@ class basic_json iterator insert(const_iterator pos, const basic_json& val) { // insert only works for arrays - if (JSON_LIKELY(is_array())) + if (HEDLEY_LIKELY(is_array())) { // check if iterator pos fits to this JSON value - if (JSON_UNLIKELY(pos.m_object != this)) + if (HEDLEY_UNLIKELY(pos.m_object != this)) { JSON_THROW(invalid_iterator::create(202, "iterator does not fit current value")); } @@ -5134,10 +5138,10 @@ class basic_json iterator insert(const_iterator pos, size_type cnt, const basic_json& val) { // insert only works for arrays - if (JSON_LIKELY(is_array())) + if (HEDLEY_LIKELY(is_array())) { // check if iterator pos fits to this JSON value - if (JSON_UNLIKELY(pos.m_object != this)) + if (HEDLEY_UNLIKELY(pos.m_object != this)) { JSON_THROW(invalid_iterator::create(202, "iterator does not fit current value")); } @@ -5182,24 +5186,24 @@ class basic_json iterator insert(const_iterator pos, const_iterator first, const_iterator last) { // insert only works for arrays - if (JSON_UNLIKELY(not is_array())) + if (HEDLEY_UNLIKELY(not is_array())) { JSON_THROW(type_error::create(309, "cannot use insert() with " + std::string(type_name()))); } // check if iterator pos fits to this JSON value - if (JSON_UNLIKELY(pos.m_object != this)) + if (HEDLEY_UNLIKELY(pos.m_object != this)) { JSON_THROW(invalid_iterator::create(202, "iterator does not fit current value")); } // check if range iterators belong to the same JSON object - if (JSON_UNLIKELY(first.m_object != last.m_object)) + if (HEDLEY_UNLIKELY(first.m_object != last.m_object)) { JSON_THROW(invalid_iterator::create(210, "iterators do not fit")); } - if (JSON_UNLIKELY(first.m_object == this)) + if (HEDLEY_UNLIKELY(first.m_object == this)) { JSON_THROW(invalid_iterator::create(211, "passed iterators may not belong to container")); } @@ -5235,13 +5239,13 @@ class basic_json iterator insert(const_iterator pos, initializer_list_t ilist) { // insert only works for arrays - if (JSON_UNLIKELY(not is_array())) + if (HEDLEY_UNLIKELY(not is_array())) { JSON_THROW(type_error::create(309, "cannot use insert() with " + std::string(type_name()))); } // check if iterator pos fits to this JSON value - if (JSON_UNLIKELY(pos.m_object != this)) + if (HEDLEY_UNLIKELY(pos.m_object != this)) { JSON_THROW(invalid_iterator::create(202, "iterator does not fit current value")); } @@ -5276,19 +5280,19 @@ class basic_json void insert(const_iterator first, const_iterator last) { // insert only works for objects - if (JSON_UNLIKELY(not is_object())) + if (HEDLEY_UNLIKELY(not is_object())) { JSON_THROW(type_error::create(309, "cannot use insert() with " + std::string(type_name()))); } // check if range iterators belong to the same JSON object - if (JSON_UNLIKELY(first.m_object != last.m_object)) + if (HEDLEY_UNLIKELY(first.m_object != last.m_object)) { JSON_THROW(invalid_iterator::create(210, "iterators do not fit")); } // passed iterators must belong to objects - if (JSON_UNLIKELY(not first.m_object->is_object())) + if (HEDLEY_UNLIKELY(not first.m_object->is_object())) { JSON_THROW(invalid_iterator::create(202, "iterators first and last must point to objects")); } @@ -5325,11 +5329,11 @@ class basic_json assert_invariant(); } - if (JSON_UNLIKELY(not is_object())) + if (HEDLEY_UNLIKELY(not is_object())) { JSON_THROW(type_error::create(312, "cannot use update() with " + std::string(type_name()))); } - if (JSON_UNLIKELY(not j.is_object())) + if (HEDLEY_UNLIKELY(not j.is_object())) { JSON_THROW(type_error::create(312, "cannot use update() with " + std::string(j.type_name()))); } @@ -5376,20 +5380,20 @@ class basic_json assert_invariant(); } - if (JSON_UNLIKELY(not is_object())) + if (HEDLEY_UNLIKELY(not is_object())) { JSON_THROW(type_error::create(312, "cannot use update() with " + std::string(type_name()))); } // check if range iterators belong to the same JSON object - if (JSON_UNLIKELY(first.m_object != last.m_object)) + if (HEDLEY_UNLIKELY(first.m_object != last.m_object)) { JSON_THROW(invalid_iterator::create(210, "iterators do not fit")); } // passed iterators must belong to objects - if (JSON_UNLIKELY(not first.m_object->is_object() - or not last.m_object->is_object())) + if (HEDLEY_UNLIKELY(not first.m_object->is_object() + or not last.m_object->is_object())) { JSON_THROW(invalid_iterator::create(202, "iterators first and last must point to objects")); } @@ -5452,7 +5456,7 @@ class basic_json void swap(array_t& other) { // swap only works for arrays - if (JSON_LIKELY(is_array())) + if (HEDLEY_LIKELY(is_array())) { std::swap(*(m_value.array), other); } @@ -5485,7 +5489,7 @@ class basic_json void swap(object_t& other) { // swap only works for objects - if (JSON_LIKELY(is_object())) + if (HEDLEY_LIKELY(is_object())) { std::swap(*(m_value.object), other); } @@ -5518,7 +5522,7 @@ class basic_json void swap(string_t& other) { // swap only works for strings - if (JSON_LIKELY(is_string())) + if (HEDLEY_LIKELY(is_string())) { std::swap(*(m_value.string), other); } @@ -6028,7 +6032,7 @@ class basic_json instead; that is, replace calls like `j >> o;` with `o << j;`. @since version 1.0.0; deprecated since version 3.0.0 */ - JSON_DEPRECATED + HEDLEY_DEPRECATED(3.0.0) friend std::ostream& operator>>(const basic_json& j, std::ostream& o) { return o << j; @@ -6107,7 +6111,7 @@ class basic_json @since version 2.0.3 (contiguous containers) */ - JSON_NODISCARD + HEDLEY_WARN_UNUSED_RESULT static basic_json parse(detail::input_adapter&& i, const parser_callback_t cb = nullptr, const bool allow_exceptions = true) @@ -6176,6 +6180,7 @@ class basic_json @since version 3.2.0 */ template + HEDLEY_NON_NULL(2) static bool sax_parse(detail::input_adapter&& i, SAX* sax, input_format_t format = input_format_t::json, const bool strict = true) @@ -6261,6 +6266,7 @@ class basic_json std::is_base_of< std::random_access_iterator_tag, typename std::iterator_traits::iterator_category>::value, int>::type = 0> + HEDLEY_NON_NULL(3) static bool sax_parse(IteratorType first, IteratorType last, SAX* sax) { return parser(detail::input_adapter(first, last)).sax_parse(sax); @@ -6274,7 +6280,7 @@ class basic_json instead; that is, replace calls like `j << i;` with `i >> j;`. @since version 1.0.0; deprecated since version 3.0.0 */ - JSON_DEPRECATED + HEDLEY_DEPRECATED(3.0.0) friend std::istream& operator<<(basic_json& j, std::istream& i) { return operator>>(i, j); @@ -6347,6 +6353,7 @@ class basic_json @since version 1.0.0, public since 2.1.0, `const char*` and `noexcept` since 3.0.0 */ + HEDLEY_RETURNS_NON_NULL const char* type_name() const noexcept { { @@ -6876,7 +6883,7 @@ class basic_json @a strict parameter since 3.0.0; added @a allow_exceptions parameter since 3.2.0 */ - JSON_NODISCARD + HEDLEY_WARN_UNUSED_RESULT static basic_json from_cbor(detail::input_adapter&& i, const bool strict = true, const bool allow_exceptions = true) @@ -6892,7 +6899,7 @@ class basic_json */ template::value, int> = 0> - JSON_NODISCARD + HEDLEY_WARN_UNUSED_RESULT static basic_json from_cbor(A1 && a1, A2 && a2, const bool strict = true, const bool allow_exceptions = true) @@ -6985,7 +6992,7 @@ class basic_json @a strict parameter since 3.0.0; added @a allow_exceptions parameter since 3.2.0 */ - JSON_NODISCARD + HEDLEY_WARN_UNUSED_RESULT static basic_json from_msgpack(detail::input_adapter&& i, const bool strict = true, const bool allow_exceptions = true) @@ -7001,7 +7008,7 @@ class basic_json */ template::value, int> = 0> - JSON_NODISCARD + HEDLEY_WARN_UNUSED_RESULT static basic_json from_msgpack(A1 && a1, A2 && a2, const bool strict = true, const bool allow_exceptions = true) @@ -7073,7 +7080,7 @@ class basic_json @since version 3.1.0; added @a allow_exceptions parameter since 3.2.0 */ - JSON_NODISCARD + HEDLEY_WARN_UNUSED_RESULT static basic_json from_ubjson(detail::input_adapter&& i, const bool strict = true, const bool allow_exceptions = true) @@ -7089,7 +7096,7 @@ class basic_json */ template::value, int> = 0> - JSON_NODISCARD + HEDLEY_WARN_UNUSED_RESULT static basic_json from_ubjson(A1 && a1, A2 && a2, const bool strict = true, const bool allow_exceptions = true) @@ -7160,7 +7167,7 @@ class basic_json @sa @ref from_ubjson(detail::input_adapter&&, const bool, const bool) for the related UBJSON format */ - JSON_NODISCARD + HEDLEY_WARN_UNUSED_RESULT static basic_json from_bson(detail::input_adapter&& i, const bool strict = true, const bool allow_exceptions = true) @@ -7176,7 +7183,7 @@ class basic_json */ template::value, int> = 0> - JSON_NODISCARD + HEDLEY_WARN_UNUSED_RESULT static basic_json from_bson(A1 && a1, A2 && a2, const bool strict = true, const bool allow_exceptions = true) @@ -7550,7 +7557,7 @@ class basic_json else { const auto idx = json_pointer::array_index(last_path); - if (JSON_UNLIKELY(static_cast(idx) > parent.size())) + if (HEDLEY_UNLIKELY(static_cast(idx) > parent.size())) { // avoid undefined behavior JSON_THROW(out_of_range::create(401, "array index " + std::to_string(idx) + " is out of range")); @@ -7581,7 +7588,7 @@ class basic_json { // perform range check auto it = parent.find(last_path); - if (JSON_LIKELY(it != parent.end())) + if (HEDLEY_LIKELY(it != parent.end())) { parent.erase(it); } @@ -7598,7 +7605,7 @@ class basic_json }; // type check: top level value must be an array - if (JSON_UNLIKELY(not json_patch.is_array())) + if (HEDLEY_UNLIKELY(not json_patch.is_array())) { JSON_THROW(parse_error::create(104, 0, "JSON patch must be an array of objects")); } @@ -7618,13 +7625,13 @@ class basic_json const auto error_msg = (op == "op") ? "operation" : "operation '" + op + "'"; // check if desired value is present - if (JSON_UNLIKELY(it == val.m_value.object->end())) + if (HEDLEY_UNLIKELY(it == val.m_value.object->end())) { JSON_THROW(parse_error::create(105, 0, error_msg + " must have member '" + member + "'")); } // check if result is of type string - if (JSON_UNLIKELY(string_type and not it->second.is_string())) + if (HEDLEY_UNLIKELY(string_type and not it->second.is_string())) { JSON_THROW(parse_error::create(105, 0, error_msg + " must have string member '" + member + "'")); } @@ -7634,7 +7641,7 @@ class basic_json }; // type check: every element of the array must be an object - if (JSON_UNLIKELY(not val.is_object())) + if (HEDLEY_UNLIKELY(not val.is_object())) { JSON_THROW(parse_error::create(104, 0, "JSON patch must be an array of objects")); } @@ -7712,7 +7719,7 @@ class basic_json } // throw an exception if test fails - if (JSON_UNLIKELY(not success)) + if (HEDLEY_UNLIKELY(not success)) { JSON_THROW(other_error::create(501, "unsuccessful: " + val.dump())); } @@ -7765,7 +7772,7 @@ class basic_json @since version 2.0.0 */ - JSON_NODISCARD + HEDLEY_WARN_UNUSED_RESULT static basic_json diff(const basic_json& source, const basic_json& target, const std::string& path = "") { @@ -8057,6 +8064,7 @@ if no parse error occurred. @since version 1.0.0 */ +HEDLEY_NON_NULL(1) inline nlohmann::json operator "" _json(const char* s, std::size_t n) { return nlohmann::json::parse(s, s + n); @@ -8075,6 +8083,7 @@ object if no parse error occurred. @since version 2.0.0 */ +HEDLEY_NON_NULL(1) inline nlohmann::json::json_pointer operator "" _json_pointer(const char* s, std::size_t n) { return nlohmann::json::json_pointer(std::string(s, n)); diff --git a/include/nlohmann/thirdparty/hedley/hedley.hpp b/include/nlohmann/thirdparty/hedley/hedley.hpp new file mode 100644 index 00000000..eb4c2018 --- /dev/null +++ b/include/nlohmann/thirdparty/hedley/hedley.hpp @@ -0,0 +1,1505 @@ +/* Hedley - https://nemequ.github.io/hedley + * Created by Evan Nemerson + * + * To the extent possible under law, the author(s) have dedicated all + * copyright and related and neighboring rights to this software to + * the public domain worldwide. This software is distributed without + * any warranty. + * + * For details, see . + * SPDX-License-Identifier: CC0-1.0 + */ + +#if !defined(HEDLEY_VERSION) || (HEDLEY_VERSION < 9) +#if defined(HEDLEY_VERSION) + #undef HEDLEY_VERSION +#endif +#define HEDLEY_VERSION 9 + +#if defined(HEDLEY_STRINGIFY_EX) + #undef HEDLEY_STRINGIFY_EX +#endif +#define HEDLEY_STRINGIFY_EX(x) #x + +#if defined(HEDLEY_STRINGIFY) + #undef HEDLEY_STRINGIFY +#endif +#define HEDLEY_STRINGIFY(x) HEDLEY_STRINGIFY_EX(x) + +#if defined(HEDLEY_CONCAT_EX) + #undef HEDLEY_CONCAT_EX +#endif +#define HEDLEY_CONCAT_EX(a,b) a##b + +#if defined(HEDLEY_CONCAT) + #undef HEDLEY_CONCAT +#endif +#define HEDLEY_CONCAT(a,b) HEDLEY_CONCAT_EX(a,b) + +#if defined(HEDLEY_VERSION_ENCODE) + #undef HEDLEY_VERSION_ENCODE +#endif +#define HEDLEY_VERSION_ENCODE(major,minor,revision) (((major) * 1000000) + ((minor) * 1000) + (revision)) + +#if defined(HEDLEY_VERSION_DECODE_MAJOR) + #undef HEDLEY_VERSION_DECODE_MAJOR +#endif +#define HEDLEY_VERSION_DECODE_MAJOR(version) ((version) / 1000000) + +#if defined(HEDLEY_VERSION_DECODE_MINOR) + #undef HEDLEY_VERSION_DECODE_MINOR +#endif +#define HEDLEY_VERSION_DECODE_MINOR(version) (((version) % 1000000) / 1000) + +#if defined(HEDLEY_VERSION_DECODE_REVISION) + #undef HEDLEY_VERSION_DECODE_REVISION +#endif +#define HEDLEY_VERSION_DECODE_REVISION(version) ((version) % 1000) + +#if defined(HEDLEY_GNUC_VERSION) + #undef HEDLEY_GNUC_VERSION +#endif +#if defined(__GNUC__) && defined(__GNUC_PATCHLEVEL__) + #define HEDLEY_GNUC_VERSION HEDLEY_VERSION_ENCODE(__GNUC__, __GNUC_MINOR__, __GNUC_PATCHLEVEL__) +#elif defined(__GNUC__) + #define HEDLEY_GNUC_VERSION HEDLEY_VERSION_ENCODE(__GNUC__, __GNUC_MINOR__, 0) +#endif + +#if defined(HEDLEY_GNUC_VERSION_CHECK) + #undef HEDLEY_GNUC_VERSION_CHECK +#endif +#if defined(HEDLEY_GNUC_VERSION) + #define HEDLEY_GNUC_VERSION_CHECK(major,minor,patch) (HEDLEY_GNUC_VERSION >= HEDLEY_VERSION_ENCODE(major, minor, patch)) +#else + #define HEDLEY_GNUC_VERSION_CHECK(major,minor,patch) (0) +#endif + +#if defined(HEDLEY_MSVC_VERSION) + #undef HEDLEY_MSVC_VERSION +#endif +#if defined(_MSC_FULL_VER) && (_MSC_FULL_VER >= 140000000) + #define HEDLEY_MSVC_VERSION HEDLEY_VERSION_ENCODE(_MSC_FULL_VER / 10000000, (_MSC_FULL_VER % 10000000) / 100000, (_MSC_FULL_VER % 100000) / 100) +#elif defined(_MSC_FULL_VER) + #define HEDLEY_MSVC_VERSION HEDLEY_VERSION_ENCODE(_MSC_FULL_VER / 1000000, (_MSC_FULL_VER % 1000000) / 10000, (_MSC_FULL_VER % 10000) / 10) +#elif defined(_MSC_VER) + #define HEDLEY_MSVC_VERSION HEDLEY_VERSION_ENCODE(_MSC_VER / 100, _MSC_VER % 100, 0) +#endif + +#if defined(HEDLEY_MSVC_VERSION_CHECK) + #undef HEDLEY_MSVC_VERSION_CHECK +#endif +#if !defined(_MSC_VER) + #define HEDLEY_MSVC_VERSION_CHECK(major,minor,patch) (0) +#elif defined(_MSC_VER) && (_MSC_VER >= 1400) + #define HEDLEY_MSVC_VERSION_CHECK(major,minor,patch) (_MSC_FULL_VER >= ((major * 10000000) + (minor * 100000) + (patch))) +#elif defined(_MSC_VER) && (_MSC_VER >= 1200) + #define HEDLEY_MSVC_VERSION_CHECK(major,minor,patch) (_MSC_FULL_VER >= ((major * 1000000) + (minor * 10000) + (patch))) +#else + #define HEDLEY_MSVC_VERSION_CHECK(major,minor,patch) (_MSC_VER >= ((major * 100) + (minor))) +#endif + +#if defined(HEDLEY_INTEL_VERSION) + #undef HEDLEY_INTEL_VERSION +#endif +#if defined(__INTEL_COMPILER) && defined(__INTEL_COMPILER_UPDATE) + #define HEDLEY_INTEL_VERSION HEDLEY_VERSION_ENCODE(__INTEL_COMPILER / 100, __INTEL_COMPILER % 100, __INTEL_COMPILER_UPDATE) +#elif defined(__INTEL_COMPILER) + #define HEDLEY_INTEL_VERSION HEDLEY_VERSION_ENCODE(__INTEL_COMPILER / 100, __INTEL_COMPILER % 100, 0) +#endif + +#if defined(HEDLEY_INTEL_VERSION_CHECK) + #undef HEDLEY_INTEL_VERSION_CHECK +#endif +#if defined(HEDLEY_INTEL_VERSION) + #define HEDLEY_INTEL_VERSION_CHECK(major,minor,patch) (HEDLEY_INTEL_VERSION >= HEDLEY_VERSION_ENCODE(major, minor, patch)) +#else + #define HEDLEY_INTEL_VERSION_CHECK(major,minor,patch) (0) +#endif + +#if defined(HEDLEY_PGI_VERSION) + #undef HEDLEY_PGI_VERSION +#endif +#if defined(__PGI) && defined(__PGIC__) && defined(__PGIC_MINOR__) && defined(__PGIC_PATCHLEVEL__) + #define HEDLEY_PGI_VERSION HEDLEY_VERSION_ENCODE(__PGIC__, __PGIC_MINOR__, __PGIC_PATCHLEVEL__) +#endif + +#if defined(HEDLEY_PGI_VERSION_CHECK) + #undef HEDLEY_PGI_VERSION_CHECK +#endif +#if defined(HEDLEY_PGI_VERSION) + #define HEDLEY_PGI_VERSION_CHECK(major,minor,patch) (HEDLEY_PGI_VERSION >= HEDLEY_VERSION_ENCODE(major, minor, patch)) +#else + #define HEDLEY_PGI_VERSION_CHECK(major,minor,patch) (0) +#endif + +#if defined(HEDLEY_SUNPRO_VERSION) + #undef HEDLEY_SUNPRO_VERSION +#endif +#if defined(__SUNPRO_C) && (__SUNPRO_C > 0x1000) + #define HEDLEY_SUNPRO_VERSION HEDLEY_VERSION_ENCODE((((__SUNPRO_C >> 16) & 0xf) * 10) + ((__SUNPRO_C >> 12) & 0xf), (((__SUNPRO_C >> 8) & 0xf) * 10) + ((__SUNPRO_C >> 4) & 0xf), (__SUNPRO_C & 0xf) * 10) +#elif defined(__SUNPRO_C) + #define HEDLEY_SUNPRO_VERSION HEDLEY_VERSION_ENCODE((__SUNPRO_C >> 8) & 0xf, (__SUNPRO_C >> 4) & 0xf, (__SUNPRO_C) & 0xf) +#elif defined(__SUNPRO_CC) && (__SUNPRO_CC > 0x1000) + #define HEDLEY_SUNPRO_VERSION HEDLEY_VERSION_ENCODE((((__SUNPRO_CC >> 16) & 0xf) * 10) + ((__SUNPRO_CC >> 12) & 0xf), (((__SUNPRO_CC >> 8) & 0xf) * 10) + ((__SUNPRO_CC >> 4) & 0xf), (__SUNPRO_CC & 0xf) * 10) +#elif defined(__SUNPRO_CC) + #define HEDLEY_SUNPRO_VERSION HEDLEY_VERSION_ENCODE((__SUNPRO_CC >> 8) & 0xf, (__SUNPRO_CC >> 4) & 0xf, (__SUNPRO_CC) & 0xf) +#endif + +#if defined(HEDLEY_SUNPRO_VERSION_CHECK) + #undef HEDLEY_SUNPRO_VERSION_CHECK +#endif +#if defined(HEDLEY_SUNPRO_VERSION) + #define HEDLEY_SUNPRO_VERSION_CHECK(major,minor,patch) (HEDLEY_SUNPRO_VERSION >= HEDLEY_VERSION_ENCODE(major, minor, patch)) +#else + #define HEDLEY_SUNPRO_VERSION_CHECK(major,minor,patch) (0) +#endif + +#if defined(HEDLEY_EMSCRIPTEN_VERSION) + #undef HEDLEY_EMSCRIPTEN_VERSION +#endif +#if defined(__EMSCRIPTEN__) + #define HEDLEY_EMSCRIPTEN_VERSION HEDLEY_VERSION_ENCODE(__EMSCRIPTEN_major__, __EMSCRIPTEN_minor__, __EMSCRIPTEN_tiny__) +#endif + +#if defined(HEDLEY_EMSCRIPTEN_VERSION_CHECK) + #undef HEDLEY_EMSCRIPTEN_VERSION_CHECK +#endif +#if defined(HEDLEY_EMSCRIPTEN_VERSION) + #define HEDLEY_EMSCRIPTEN_VERSION_CHECK(major,minor,patch) (HEDLEY_EMSCRIPTEN_VERSION >= HEDLEY_VERSION_ENCODE(major, minor, patch)) +#else + #define HEDLEY_EMSCRIPTEN_VERSION_CHECK(major,minor,patch) (0) +#endif + +#if defined(HEDLEY_ARM_VERSION) + #undef HEDLEY_ARM_VERSION +#endif +#if defined(__CC_ARM) && defined(__ARMCOMPILER_VERSION) + #define HEDLEY_ARM_VERSION HEDLEY_VERSION_ENCODE(__ARMCOMPILER_VERSION / 1000000, (__ARMCOMPILER_VERSION % 1000000) / 10000, (__ARMCOMPILER_VERSION % 10000) / 100) +#elif defined(__CC_ARM) && defined(__ARMCC_VERSION) + #define HEDLEY_ARM_VERSION HEDLEY_VERSION_ENCODE(__ARMCC_VERSION / 1000000, (__ARMCC_VERSION % 1000000) / 10000, (__ARMCC_VERSION % 10000) / 100) +#endif + +#if defined(HEDLEY_ARM_VERSION_CHECK) + #undef HEDLEY_ARM_VERSION_CHECK +#endif +#if defined(HEDLEY_ARM_VERSION) + #define HEDLEY_ARM_VERSION_CHECK(major,minor,patch) (HEDLEY_ARM_VERSION >= HEDLEY_VERSION_ENCODE(major, minor, patch)) +#else + #define HEDLEY_ARM_VERSION_CHECK(major,minor,patch) (0) +#endif + +#if defined(HEDLEY_IBM_VERSION) + #undef HEDLEY_IBM_VERSION +#endif +#if defined(__ibmxl__) + #define HEDLEY_IBM_VERSION HEDLEY_VERSION_ENCODE(__ibmxl_version__, __ibmxl_release__, __ibmxl_modification__) +#elif defined(__xlC__) && defined(__xlC_ver__) + #define HEDLEY_IBM_VERSION HEDLEY_VERSION_ENCODE(__xlC__ >> 8, __xlC__ & 0xff, (__xlC_ver__ >> 8) & 0xff) +#elif defined(__xlC__) + #define HEDLEY_IBM_VERSION HEDLEY_VERSION_ENCODE(__xlC__ >> 8, __xlC__ & 0xff, 0) +#endif + +#if defined(HEDLEY_IBM_VERSION_CHECK) + #undef HEDLEY_IBM_VERSION_CHECK +#endif +#if defined(HEDLEY_IBM_VERSION) + #define HEDLEY_IBM_VERSION_CHECK(major,minor,patch) (HEDLEY_IBM_VERSION >= HEDLEY_VERSION_ENCODE(major, minor, patch)) +#else + #define HEDLEY_IBM_VERSION_CHECK(major,minor,patch) (0) +#endif + +#if defined(HEDLEY_TI_VERSION) + #undef HEDLEY_TI_VERSION +#endif +#if defined(__TI_COMPILER_VERSION__) + #define HEDLEY_TI_VERSION HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000)) +#endif + +#if defined(HEDLEY_TI_VERSION_CHECK) + #undef HEDLEY_TI_VERSION_CHECK +#endif +#if defined(HEDLEY_TI_VERSION) + #define HEDLEY_TI_VERSION_CHECK(major,minor,patch) (HEDLEY_TI_VERSION >= HEDLEY_VERSION_ENCODE(major, minor, patch)) +#else + #define HEDLEY_TI_VERSION_CHECK(major,minor,patch) (0) +#endif + +#if defined(HEDLEY_CRAY_VERSION) + #undef HEDLEY_CRAY_VERSION +#endif +#if defined(_CRAYC) + #if defined(_RELEASE_PATCHLEVEL) + #define HEDLEY_CRAY_VERSION HEDLEY_VERSION_ENCODE(_RELEASE_MAJOR, _RELEASE_MINOR, _RELEASE_PATCHLEVEL) + #else + #define HEDLEY_CRAY_VERSION HEDLEY_VERSION_ENCODE(_RELEASE_MAJOR, _RELEASE_MINOR, 0) + #endif +#endif + +#if defined(HEDLEY_CRAY_VERSION_CHECK) + #undef HEDLEY_CRAY_VERSION_CHECK +#endif +#if defined(HEDLEY_CRAY_VERSION) + #define HEDLEY_CRAY_VERSION_CHECK(major,minor,patch) (HEDLEY_CRAY_VERSION >= HEDLEY_VERSION_ENCODE(major, minor, patch)) +#else + #define HEDLEY_CRAY_VERSION_CHECK(major,minor,patch) (0) +#endif + +#if defined(HEDLEY_IAR_VERSION) + #undef HEDLEY_IAR_VERSION +#endif +#if defined(__IAR_SYSTEMS_ICC__) + #if __VER__ > 1000 + #define HEDLEY_IAR_VERSION HEDLEY_VERSION_ENCODE((__VER__ / 1000000), ((__VER__ / 1000) % 1000), (__VER__ % 1000)) + #else + #define HEDLEY_IAR_VERSION HEDLEY_VERSION_ENCODE(VER / 100, __VER__ % 100, 0) + #endif +#endif + +#if defined(HEDLEY_IAR_VERSION_CHECK) + #undef HEDLEY_IAR_VERSION_CHECK +#endif +#if defined(HEDLEY_IAR_VERSION) + #define HEDLEY_IAR_VERSION_CHECK(major,minor,patch) (HEDLEY_IAR_VERSION >= HEDLEY_VERSION_ENCODE(major, minor, patch)) +#else + #define HEDLEY_IAR_VERSION_CHECK(major,minor,patch) (0) +#endif + +#if defined(HEDLEY_TINYC_VERSION) + #undef HEDLEY_TINYC_VERSION +#endif +#if defined(__TINYC__) + #define HEDLEY_TINYC_VERSION HEDLEY_VERSION_ENCODE(__TINYC__ / 1000, (__TINYC__ / 100) % 10, __TINYC__ % 100) +#endif + +#if defined(HEDLEY_TINYC_VERSION_CHECK) + #undef HEDLEY_TINYC_VERSION_CHECK +#endif +#if defined(HEDLEY_TINYC_VERSION) + #define HEDLEY_TINYC_VERSION_CHECK(major,minor,patch) (HEDLEY_TINYC_VERSION >= HEDLEY_VERSION_ENCODE(major, minor, patch)) +#else + #define HEDLEY_TINYC_VERSION_CHECK(major,minor,patch) (0) +#endif + +#if defined(HEDLEY_DMC_VERSION) + #undef HEDLEY_DMC_VERSION +#endif +#if defined(__DMC__) + #define HEDLEY_DMC_VERSION HEDLEY_VERSION_ENCODE(__DMC__ >> 8, (__DMC__ >> 4) & 0xf, __DMC__ & 0xf) +#endif + +#if defined(HEDLEY_DMC_VERSION_CHECK) + #undef HEDLEY_DMC_VERSION_CHECK +#endif +#if defined(HEDLEY_DMC_VERSION) + #define HEDLEY_DMC_VERSION_CHECK(major,minor,patch) (HEDLEY_DMC_VERSION >= HEDLEY_VERSION_ENCODE(major, minor, patch)) +#else + #define HEDLEY_DMC_VERSION_CHECK(major,minor,patch) (0) +#endif + +#if defined(HEDLEY_COMPCERT_VERSION) + #undef HEDLEY_COMPCERT_VERSION +#endif +#if defined(__COMPCERT_VERSION__) + #define HEDLEY_COMPCERT_VERSION HEDLEY_VERSION_ENCODE(__COMPCERT_VERSION__ / 10000, (__COMPCERT_VERSION__ / 100) % 100, __COMPCERT_VERSION__ % 100) +#endif + +#if defined(HEDLEY_COMPCERT_VERSION_CHECK) + #undef HEDLEY_COMPCERT_VERSION_CHECK +#endif +#if defined(HEDLEY_COMPCERT_VERSION) + #define HEDLEY_COMPCERT_VERSION_CHECK(major,minor,patch) (HEDLEY_COMPCERT_VERSION >= HEDLEY_VERSION_ENCODE(major, minor, patch)) +#else + #define HEDLEY_COMPCERT_VERSION_CHECK(major,minor,patch) (0) +#endif + +#if defined(HEDLEY_PELLES_VERSION) + #undef HEDLEY_PELLES_VERSION +#endif +#if defined(__POCC__) + #define HEDLEY_PELLES_VERSION HEDLEY_VERSION_ENCODE(__POCC__ / 100, __POCC__ % 100, 0) +#endif + +#if defined(HEDLEY_PELLES_VERSION_CHECK) + #undef HEDLEY_PELLES_VERSION_CHECK +#endif +#if defined(HEDLEY_PELLES_VERSION) + #define HEDLEY_PELLES_VERSION_CHECK(major,minor,patch) (HEDLEY_PELLES_VERSION >= HEDLEY_VERSION_ENCODE(major, minor, patch)) +#else + #define HEDLEY_PELLES_VERSION_CHECK(major,minor,patch) (0) +#endif + +#if defined(HEDLEY_GCC_VERSION) + #undef HEDLEY_GCC_VERSION +#endif +#if \ + defined(HEDLEY_GNUC_VERSION) && \ + !defined(__clang__) && \ + !defined(HEDLEY_INTEL_VERSION) && \ + !defined(HEDLEY_PGI_VERSION) && \ + !defined(HEDLEY_ARM_VERSION) && \ + !defined(HEDLEY_TI_VERSION) && \ + !defined(__COMPCERT__) + #define HEDLEY_GCC_VERSION HEDLEY_GNUC_VERSION +#endif + +#if defined(HEDLEY_GCC_VERSION_CHECK) + #undef HEDLEY_GCC_VERSION_CHECK +#endif +#if defined(HEDLEY_GCC_VERSION) + #define HEDLEY_GCC_VERSION_CHECK(major,minor,patch) (HEDLEY_GCC_VERSION >= HEDLEY_VERSION_ENCODE(major, minor, patch)) +#else + #define HEDLEY_GCC_VERSION_CHECK(major,minor,patch) (0) +#endif + +#if defined(HEDLEY_HAS_ATTRIBUTE) + #undef HEDLEY_HAS_ATTRIBUTE +#endif +#if defined(__has_attribute) + #define HEDLEY_HAS_ATTRIBUTE(attribute) __has_attribute(attribute) +#else + #define HEDLEY_HAS_ATTRIBUTE(attribute) (0) +#endif + +#if defined(HEDLEY_GNUC_HAS_ATTRIBUTE) + #undef HEDLEY_GNUC_HAS_ATTRIBUTE +#endif +#if defined(__has_attribute) + #define HEDLEY_GNUC_HAS_ATTRIBUTE(attribute,major,minor,patch) __has_attribute(attribute) +#else + #define HEDLEY_GNUC_HAS_ATTRIBUTE(attribute,major,minor,patch) HEDLEY_GNUC_VERSION_CHECK(major,minor,patch) +#endif + +#if defined(HEDLEY_GCC_HAS_ATTRIBUTE) + #undef HEDLEY_GCC_HAS_ATTRIBUTE +#endif +#if defined(__has_attribute) + #define HEDLEY_GCC_HAS_ATTRIBUTE(attribute,major,minor,patch) __has_attribute(attribute) +#else + #define HEDLEY_GCC_HAS_ATTRIBUTE(attribute,major,minor,patch) HEDLEY_GCC_VERSION_CHECK(major,minor,patch) +#endif + +#if defined(HEDLEY_HAS_CPP_ATTRIBUTE) + #undef HEDLEY_HAS_CPP_ATTRIBUTE +#endif +#if defined(__has_cpp_attribute) && defined(__cplusplus) + #define HEDLEY_HAS_CPP_ATTRIBUTE(attribute) __has_cpp_attribute(attribute) +#else + #define HEDLEY_HAS_CPP_ATTRIBUTE(attribute) (0) +#endif + +#if defined(HEDLEY_GNUC_HAS_CPP_ATTRIBUTE) + #undef HEDLEY_GNUC_HAS_CPP_ATTRIBUTE +#endif +#if defined(__has_cpp_attribute) && defined(__cplusplus) + #define HEDLEY_GNUC_HAS_CPP_ATTRIBUTE(attribute,major,minor,patch) __has_cpp_attribute(attribute) +#else + #define HEDLEY_GNUC_HAS_CPP_ATTRIBUTE(attribute,major,minor,patch) HEDLEY_GNUC_VERSION_CHECK(major,minor,patch) +#endif + +#if defined(HEDLEY_GCC_HAS_CPP_ATTRIBUTE) + #undef HEDLEY_GCC_HAS_CPP_ATTRIBUTE +#endif +#if defined(__has_cpp_attribute) && defined(__cplusplus) + #define HEDLEY_GCC_HAS_CPP_ATTRIBUTE(attribute,major,minor,patch) __has_cpp_attribute(attribute) +#else + #define HEDLEY_GCC_HAS_CPP_ATTRIBUTE(attribute,major,minor,patch) HEDLEY_GCC_VERSION_CHECK(major,minor,patch) +#endif + +#if defined(HEDLEY_HAS_BUILTIN) + #undef HEDLEY_HAS_BUILTIN +#endif +#if defined(__has_builtin) + #define HEDLEY_HAS_BUILTIN(builtin) __has_builtin(builtin) +#else + #define HEDLEY_HAS_BUILTIN(builtin) (0) +#endif + +#if defined(HEDLEY_GNUC_HAS_BUILTIN) + #undef HEDLEY_GNUC_HAS_BUILTIN +#endif +#if defined(__has_builtin) + #define HEDLEY_GNUC_HAS_BUILTIN(builtin,major,minor,patch) __has_builtin(builtin) +#else + #define HEDLEY_GNUC_HAS_BUILTIN(builtin,major,minor,patch) HEDLEY_GNUC_VERSION_CHECK(major,minor,patch) +#endif + +#if defined(HEDLEY_GCC_HAS_BUILTIN) + #undef HEDLEY_GCC_HAS_BUILTIN +#endif +#if defined(__has_builtin) + #define HEDLEY_GCC_HAS_BUILTIN(builtin,major,minor,patch) __has_builtin(builtin) +#else + #define HEDLEY_GCC_HAS_BUILTIN(builtin,major,minor,patch) HEDLEY_GCC_VERSION_CHECK(major,minor,patch) +#endif + +#if defined(HEDLEY_HAS_FEATURE) + #undef HEDLEY_HAS_FEATURE +#endif +#if defined(__has_feature) + #define HEDLEY_HAS_FEATURE(feature) __has_feature(feature) +#else + #define HEDLEY_HAS_FEATURE(feature) (0) +#endif + +#if defined(HEDLEY_GNUC_HAS_FEATURE) + #undef HEDLEY_GNUC_HAS_FEATURE +#endif +#if defined(__has_feature) + #define HEDLEY_GNUC_HAS_FEATURE(feature,major,minor,patch) __has_feature(feature) +#else + #define HEDLEY_GNUC_HAS_FEATURE(feature,major,minor,patch) HEDLEY_GNUC_VERSION_CHECK(major,minor,patch) +#endif + +#if defined(HEDLEY_GCC_HAS_FEATURE) + #undef HEDLEY_GCC_HAS_FEATURE +#endif +#if defined(__has_feature) + #define HEDLEY_GCC_HAS_FEATURE(feature,major,minor,patch) __has_feature(feature) +#else + #define HEDLEY_GCC_HAS_FEATURE(feature,major,minor,patch) HEDLEY_GCC_VERSION_CHECK(major,minor,patch) +#endif + +#if defined(HEDLEY_HAS_EXTENSION) + #undef HEDLEY_HAS_EXTENSION +#endif +#if defined(__has_extension) + #define HEDLEY_HAS_EXTENSION(extension) __has_extension(extension) +#else + #define HEDLEY_HAS_EXTENSION(extension) (0) +#endif + +#if defined(HEDLEY_GNUC_HAS_EXTENSION) + #undef HEDLEY_GNUC_HAS_EXTENSION +#endif +#if defined(__has_extension) + #define HEDLEY_GNUC_HAS_EXTENSION(extension,major,minor,patch) __has_extension(extension) +#else + #define HEDLEY_GNUC_HAS_EXTENSION(extension,major,minor,patch) HEDLEY_GNUC_VERSION_CHECK(major,minor,patch) +#endif + +#if defined(HEDLEY_GCC_HAS_EXTENSION) + #undef HEDLEY_GCC_HAS_EXTENSION +#endif +#if defined(__has_extension) + #define HEDLEY_GCC_HAS_EXTENSION(extension,major,minor,patch) __has_extension(extension) +#else + #define HEDLEY_GCC_HAS_EXTENSION(extension,major,minor,patch) HEDLEY_GCC_VERSION_CHECK(major,minor,patch) +#endif + +#if defined(HEDLEY_HAS_DECLSPEC_ATTRIBUTE) + #undef HEDLEY_HAS_DECLSPEC_ATTRIBUTE +#endif +#if defined(__has_declspec_attribute) + #define HEDLEY_HAS_DECLSPEC_ATTRIBUTE(attribute) __has_declspec_attribute(attribute) +#else + #define HEDLEY_HAS_DECLSPEC_ATTRIBUTE(attribute) (0) +#endif + +#if defined(HEDLEY_GNUC_HAS_DECLSPEC_ATTRIBUTE) + #undef HEDLEY_GNUC_HAS_DECLSPEC_ATTRIBUTE +#endif +#if defined(__has_declspec_attribute) + #define HEDLEY_GNUC_HAS_DECLSPEC_ATTRIBUTE(attribute,major,minor,patch) __has_declspec_attribute(attribute) +#else + #define HEDLEY_GNUC_HAS_DECLSPEC_ATTRIBUTE(attribute,major,minor,patch) HEDLEY_GNUC_VERSION_CHECK(major,minor,patch) +#endif + +#if defined(HEDLEY_GCC_HAS_DECLSPEC_ATTRIBUTE) + #undef HEDLEY_GCC_HAS_DECLSPEC_ATTRIBUTE +#endif +#if defined(__has_declspec_attribute) + #define HEDLEY_GCC_HAS_DECLSPEC_ATTRIBUTE(attribute,major,minor,patch) __has_declspec_attribute(attribute) +#else + #define HEDLEY_GCC_HAS_DECLSPEC_ATTRIBUTE(attribute,major,minor,patch) HEDLEY_GCC_VERSION_CHECK(major,minor,patch) +#endif + +#if defined(HEDLEY_HAS_WARNING) + #undef HEDLEY_HAS_WARNING +#endif +#if defined(__has_warning) + #define HEDLEY_HAS_WARNING(warning) __has_warning(warning) +#else + #define HEDLEY_HAS_WARNING(warning) (0) +#endif + +#if defined(HEDLEY_GNUC_HAS_WARNING) + #undef HEDLEY_GNUC_HAS_WARNING +#endif +#if defined(__has_warning) + #define HEDLEY_GNUC_HAS_WARNING(warning,major,minor,patch) __has_warning(warning) +#else + #define HEDLEY_GNUC_HAS_WARNING(warning,major,minor,patch) HEDLEY_GNUC_VERSION_CHECK(major,minor,patch) +#endif + +#if defined(HEDLEY_GCC_HAS_WARNING) + #undef HEDLEY_GCC_HAS_WARNING +#endif +#if defined(__has_warning) + #define HEDLEY_GCC_HAS_WARNING(warning,major,minor,patch) __has_warning(warning) +#else + #define HEDLEY_GCC_HAS_WARNING(warning,major,minor,patch) HEDLEY_GCC_VERSION_CHECK(major,minor,patch) +#endif + +#if \ + (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)) || \ + defined(__clang__) || \ + HEDLEY_GCC_VERSION_CHECK(3,0,0) || \ + HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ + HEDLEY_IAR_VERSION_CHECK(8,0,0) || \ + HEDLEY_PGI_VERSION_CHECK(18,4,0) || \ + HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ + HEDLEY_TI_VERSION_CHECK(6,0,0) || \ + HEDLEY_CRAY_VERSION_CHECK(5,0,0) || \ + HEDLEY_TINYC_VERSION_CHECK(0,9,17) || \ + HEDLEY_SUNPRO_VERSION_CHECK(8,0,0) || \ + (HEDLEY_IBM_VERSION_CHECK(10,1,0) && defined(__C99_PRAGMA_OPERATOR)) + #define HEDLEY_PRAGMA(value) _Pragma(#value) +#elif HEDLEY_MSVC_VERSION_CHECK(15,0,0) + #define HEDLEY_PRAGMA(value) __pragma(value) +#else + #define HEDLEY_PRAGMA(value) +#endif + +#if defined(HEDLEY_DIAGNOSTIC_PUSH) + #undef HEDLEY_DIAGNOSTIC_PUSH +#endif +#if defined(HEDLEY_DIAGNOSTIC_POP) + #undef HEDLEY_DIAGNOSTIC_POP +#endif +#if defined(__clang__) + #define HEDLEY_DIAGNOSTIC_PUSH _Pragma("clang diagnostic push") + #define HEDLEY_DIAGNOSTIC_POP _Pragma("clang diagnostic pop") +#elif HEDLEY_INTEL_VERSION_CHECK(13,0,0) + #define HEDLEY_DIAGNOSTIC_PUSH _Pragma("warning(push)") + #define HEDLEY_DIAGNOSTIC_POP _Pragma("warning(pop)") +#elif HEDLEY_GCC_VERSION_CHECK(4,6,0) + #define HEDLEY_DIAGNOSTIC_PUSH _Pragma("GCC diagnostic push") + #define HEDLEY_DIAGNOSTIC_POP _Pragma("GCC diagnostic pop") +#elif HEDLEY_MSVC_VERSION_CHECK(15,0,0) + #define HEDLEY_DIAGNOSTIC_PUSH __pragma(warning(push)) + #define HEDLEY_DIAGNOSTIC_POP __pragma(warning(pop)) +#elif HEDLEY_ARM_VERSION_CHECK(5,6,0) + #define HEDLEY_DIAGNOSTIC_PUSH _Pragma("push") + #define HEDLEY_DIAGNOSTIC_POP _Pragma("pop") +#elif HEDLEY_TI_VERSION_CHECK(8,1,0) + #define HEDLEY_DIAGNOSTIC_PUSH _Pragma("diag_push") + #define HEDLEY_DIAGNOSTIC_POP _Pragma("diag_pop") +#elif HEDLEY_PELLES_VERSION_CHECK(2,90,0) + #define HEDLEY_DIAGNOSTIC_PUSH _Pragma("warning(push)") + #define HEDLEY_DIAGNOSTIC_POP _Pragma("warning(pop)") +#else + #define HEDLEY_DIAGNOSTIC_PUSH + #define HEDLEY_DIAGNOSTIC_POP +#endif + +#if defined(HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED) + #undef HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED +#endif +#if HEDLEY_HAS_WARNING("-Wdeprecated-declarations") + #define HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("clang diagnostic ignored \"-Wdeprecated-declarations\"") +#elif HEDLEY_INTEL_VERSION_CHECK(13,0,0) + #define HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("warning(disable:1478 1786)") +#elif HEDLEY_PGI_VERSION_CHECK(17,10,0) + #define HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("diag_suppress 1215,1444") +#elif HEDLEY_GCC_VERSION_CHECK(4,3,0) + #define HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"") +#elif HEDLEY_MSVC_VERSION_CHECK(15,0,0) + #define HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED __pragma(warning(disable:4996)) +#elif HEDLEY_TI_VERSION_CHECK(8,0,0) + #define HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("diag_suppress 1291,1718") +#elif HEDLEY_SUNPRO_VERSION_CHECK(5,13,0) && !defined(__cplusplus) + #define HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("error_messages(off,E_DEPRECATED_ATT,E_DEPRECATED_ATT_MESS)") +#elif HEDLEY_SUNPRO_VERSION_CHECK(5,13,0) && defined(__cplusplus) + #define HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("error_messages(off,symdeprecated,symdeprecated2)") +#elif HEDLEY_IAR_VERSION_CHECK(8,0,0) + #define HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("diag_suppress=Pe1444,Pe1215") +#elif HEDLEY_PELLES_VERSION_CHECK(2,90,0) + #define HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("warn(disable:2241)") +#else + #define HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED +#endif + +#if defined(HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS) + #undef HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS +#endif +#if HEDLEY_HAS_WARNING("-Wunknown-pragmas") + #define HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("clang diagnostic ignored \"-Wunknown-pragmas\"") +#elif HEDLEY_INTEL_VERSION_CHECK(13,0,0) + #define HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("warning(disable:161)") +#elif HEDLEY_PGI_VERSION_CHECK(17,10,0) + #define HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("diag_suppress 1675") +#elif HEDLEY_GCC_VERSION_CHECK(4,3,0) + #define HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("GCC diagnostic ignored \"-Wunknown-pragmas\"") +#elif HEDLEY_MSVC_VERSION_CHECK(15,0,0) + #define HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS __pragma(warning(disable:4068)) +#elif HEDLEY_TI_VERSION_CHECK(8,0,0) + #define HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("diag_suppress 163") +#elif HEDLEY_IAR_VERSION_CHECK(8,0,0) + #define HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("diag_suppress=Pe161") +#else + #define HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS +#endif + +#if defined(HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL) + #undef HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL +#endif +#if HEDLEY_HAS_WARNING("-Wcast-qual") + #define HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL _Pragma("clang diagnostic ignored \"-Wcast-qual\"") +#elif HEDLEY_INTEL_VERSION_CHECK(13,0,0) + #define HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL _Pragma("warning(disable:2203 2331)") +#elif HEDLEY_GCC_VERSION_CHECK(3,0,0) + #define HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL _Pragma("GCC diagnostic ignored \"-Wcast-qual\"") +#else + #define HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL +#endif + +#if defined(HEDLEY_DEPRECATED) + #undef HEDLEY_DEPRECATED +#endif +#if defined(HEDLEY_DEPRECATED_FOR) + #undef HEDLEY_DEPRECATED_FOR +#endif +#if defined(__cplusplus) && (__cplusplus >= 201402L) + #define HEDLEY_DEPRECATED(since) [[deprecated("Since " #since)]] + #define HEDLEY_DEPRECATED_FOR(since, replacement) [[deprecated("Since " #since "; use " #replacement)]] +#elif \ + HEDLEY_HAS_EXTENSION(attribute_deprecated_with_message) || \ + HEDLEY_GCC_VERSION_CHECK(4,5,0) || \ + HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ + HEDLEY_ARM_VERSION_CHECK(5,6,0) || \ + HEDLEY_SUNPRO_VERSION_CHECK(5,13,0) || \ + HEDLEY_PGI_VERSION_CHECK(17,10,0) || \ + HEDLEY_TI_VERSION_CHECK(8,3,0) + #define HEDLEY_DEPRECATED(since) __attribute__((__deprecated__("Since " #since))) + #define HEDLEY_DEPRECATED_FOR(since, replacement) __attribute__((__deprecated__("Since " #since "; use " #replacement))) +#elif \ + HEDLEY_HAS_ATTRIBUTE(deprecated) || \ + HEDLEY_GCC_VERSION_CHECK(3,1,0) || \ + HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ + HEDLEY_TI_VERSION_CHECK(8,0,0) || \ + (HEDLEY_TI_VERSION_CHECK(7,3,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) + #define HEDLEY_DEPRECATED(since) __attribute__((__deprecated__)) + #define HEDLEY_DEPRECATED_FOR(since, replacement) __attribute__((__deprecated__)) +#elif HEDLEY_MSVC_VERSION_CHECK(14,0,0) + #define HEDLEY_DEPRECATED(since) __declspec(deprecated("Since " # since)) + #define HEDLEY_DEPRECATED_FOR(since, replacement) __declspec(deprecated("Since " #since "; use " #replacement)) +#elif \ + HEDLEY_MSVC_VERSION_CHECK(13,10,0) || \ + HEDLEY_PELLES_VERSION_CHECK(6,50,0) + #define HEDLEY_DEPRECATED(since) _declspec(deprecated) + #define HEDLEY_DEPRECATED_FOR(since, replacement) __declspec(deprecated) +#elif HEDLEY_IAR_VERSION_CHECK(8,0,0) + #define HEDLEY_DEPRECATED(since) _Pragma("deprecated") + #define HEDLEY_DEPRECATED_FOR(since, replacement) _Pragma("deprecated") +#else + #define HEDLEY_DEPRECATED(since) + #define HEDLEY_DEPRECATED_FOR(since, replacement) +#endif + +#if defined(HEDLEY_UNAVAILABLE) + #undef HEDLEY_UNAVAILABLE +#endif +#if \ + HEDLEY_HAS_ATTRIBUTE(warning) || \ + HEDLEY_GCC_VERSION_CHECK(4,3,0) || \ + HEDLEY_INTEL_VERSION_CHECK(13,0,0) + #define HEDLEY_UNAVAILABLE(available_since) __attribute__((__warning__("Not available until " #available_since))) +#else + #define HEDLEY_UNAVAILABLE(available_since) +#endif + +#if defined(HEDLEY_WARN_UNUSED_RESULT) + #undef HEDLEY_WARN_UNUSED_RESULT +#endif +#if defined(__cplusplus) && (__cplusplus >= 201703L) + #define HEDLEY_WARN_UNUSED_RESULT [[nodiscard]] +#elif \ + HEDLEY_HAS_ATTRIBUTE(warn_unused_result) || \ + HEDLEY_GCC_VERSION_CHECK(3,4,0) || \ + HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ + HEDLEY_TI_VERSION_CHECK(8,0,0) || \ + (HEDLEY_TI_VERSION_CHECK(7,3,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ + (HEDLEY_SUNPRO_VERSION_CHECK(5,15,0) && defined(__cplusplus)) || \ + HEDLEY_PGI_VERSION_CHECK(17,10,0) + #define HEDLEY_WARN_UNUSED_RESULT __attribute__((__warn_unused_result__)) +#elif defined(_Check_return_) /* SAL */ + #define HEDLEY_WARN_UNUSED_RESULT _Check_return_ +#else + #define HEDLEY_WARN_UNUSED_RESULT +#endif + +#if defined(HEDLEY_SENTINEL) + #undef HEDLEY_SENTINEL +#endif +#if \ + HEDLEY_HAS_ATTRIBUTE(sentinel) || \ + HEDLEY_GCC_VERSION_CHECK(4,0,0) || \ + HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ + HEDLEY_ARM_VERSION_CHECK(5,4,0) + #define HEDLEY_SENTINEL(position) __attribute__((__sentinel__(position))) +#else + #define HEDLEY_SENTINEL(position) +#endif + +#if defined(HEDLEY_NO_RETURN) + #undef HEDLEY_NO_RETURN +#endif +#if HEDLEY_IAR_VERSION_CHECK(8,0,0) + #define HEDLEY_NO_RETURN __noreturn +#elif HEDLEY_INTEL_VERSION_CHECK(13,0,0) + #define HEDLEY_NO_RETURN __attribute__((__noreturn__)) +#elif defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L + #define HEDLEY_NO_RETURN _Noreturn +#elif defined(__cplusplus) && (__cplusplus >= 201103L) + #define HEDLEY_NO_RETURN [[noreturn]] +#elif \ + HEDLEY_HAS_ATTRIBUTE(noreturn) || \ + HEDLEY_GCC_VERSION_CHECK(3,2,0) || \ + HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \ + HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ + HEDLEY_IBM_VERSION_CHECK(10,1,0) || \ + HEDLEY_TI_VERSION_CHECK(18,0,0) || \ + (HEDLEY_TI_VERSION_CHECK(17,3,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) + #define HEDLEY_NO_RETURN __attribute__((__noreturn__)) +#elif HEDLEY_MSVC_VERSION_CHECK(13,10,0) + #define HEDLEY_NO_RETURN __declspec(noreturn) +#elif HEDLEY_TI_VERSION_CHECK(6,0,0) && defined(__cplusplus) + #define HEDLEY_NO_RETURN _Pragma("FUNC_NEVER_RETURNS;") +#elif HEDLEY_COMPCERT_VERSION_CHECK(3,2,0) + #define HEDLEY_NO_RETURN __attribute((noreturn)) +#elif HEDLEY_PELLES_VERSION_CHECK(9,0,0) + #define HEDLEY_NO_RETURN __declspec(noreturn) +#else + #define HEDLEY_NO_RETURN +#endif + +#if defined(HEDLEY_UNREACHABLE) + #undef HEDLEY_UNREACHABLE +#endif +#if defined(HEDLEY_UNREACHABLE_RETURN) + #undef HEDLEY_UNREACHABLE_RETURN +#endif +#if \ + (HEDLEY_HAS_BUILTIN(__builtin_unreachable) && (!defined(HEDLEY_ARM_VERSION))) || \ + HEDLEY_GCC_VERSION_CHECK(4,5,0) || \ + HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ + HEDLEY_IBM_VERSION_CHECK(13,1,5) + #define HEDLEY_UNREACHABLE() __builtin_unreachable() +#elif HEDLEY_MSVC_VERSION_CHECK(13,10,0) + #define HEDLEY_UNREACHABLE() __assume(0) +#elif HEDLEY_TI_VERSION_CHECK(6,0,0) + #if defined(__cplusplus) + #define HEDLEY_UNREACHABLE() std::_nassert(0) + #else + #define HEDLEY_UNREACHABLE() _nassert(0) + #endif + #define HEDLEY_UNREACHABLE_RETURN(value) return value +#elif defined(EXIT_FAILURE) + #define HEDLEY_UNREACHABLE() abort() +#else + #define HEDLEY_UNREACHABLE() + #define HEDLEY_UNREACHABLE_RETURN(value) return value +#endif +#if !defined(HEDLEY_UNREACHABLE_RETURN) + #define HEDLEY_UNREACHABLE_RETURN(value) HEDLEY_UNREACHABLE() +#endif + +#if defined(HEDLEY_ASSUME) + #undef HEDLEY_ASSUME +#endif +#if \ + HEDLEY_MSVC_VERSION_CHECK(13,10,0) || \ + HEDLEY_INTEL_VERSION_CHECK(13,0,0) + #define HEDLEY_ASSUME(expr) __assume(expr) +#elif HEDLEY_HAS_BUILTIN(__builtin_assume) + #define HEDLEY_ASSUME(expr) __builtin_assume(expr) +#elif HEDLEY_TI_VERSION_CHECK(6,0,0) + #if defined(__cplusplus) + #define HEDLEY_ASSUME(expr) std::_nassert(expr) + #else + #define HEDLEY_ASSUME(expr) _nassert(expr) + #endif +#elif \ + (HEDLEY_HAS_BUILTIN(__builtin_unreachable) && !defined(HEDLEY_ARM_VERSION)) || \ + HEDLEY_GCC_VERSION_CHECK(4,5,0) || \ + HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ + HEDLEY_IBM_VERSION_CHECK(13,1,5) + #define HEDLEY_ASSUME(expr) ((void) ((expr) ? 1 : (__builtin_unreachable(), 1))) +#else + #define HEDLEY_ASSUME(expr) ((void) (expr)) +#endif + + +HEDLEY_DIAGNOSTIC_PUSH +#if \ + HEDLEY_HAS_WARNING("-Wvariadic-macros") || \ + HEDLEY_GCC_VERSION_CHECK(4,0,0) + #if defined(__clang__) + #pragma clang diagnostic ignored "-Wvariadic-macros" + #elif defined(HEDLEY_GCC_VERSION) + #pragma GCC diagnostic ignored "-Wvariadic-macros" + #endif +#endif +#if defined(HEDLEY_NON_NULL) + #undef HEDLEY_NON_NULL +#endif +#if \ + HEDLEY_HAS_ATTRIBUTE(nonnull) || \ + HEDLEY_GCC_VERSION_CHECK(3,3,0) || \ + HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ + HEDLEY_ARM_VERSION_CHECK(4,1,0) + #define HEDLEY_NON_NULL(...) __attribute__((__nonnull__(__VA_ARGS__))) +#else + #define HEDLEY_NON_NULL(...) +#endif +HEDLEY_DIAGNOSTIC_POP + +#if defined(HEDLEY_PRINTF_FORMAT) + #undef HEDLEY_PRINTF_FORMAT +#endif +#if defined(__MINGW32__) && HEDLEY_GCC_HAS_ATTRIBUTE(format,4,4,0) && !defined(__USE_MINGW_ANSI_STDIO) + #define HEDLEY_PRINTF_FORMAT(string_idx,first_to_check) __attribute__((__format__(ms_printf, string_idx, first_to_check))) +#elif defined(__MINGW32__) && HEDLEY_GCC_HAS_ATTRIBUTE(format,4,4,0) && defined(__USE_MINGW_ANSI_STDIO) + #define HEDLEY_PRINTF_FORMAT(string_idx,first_to_check) __attribute__((__format__(gnu_printf, string_idx, first_to_check))) +#elif \ + HEDLEY_HAS_ATTRIBUTE(format) || \ + HEDLEY_GCC_VERSION_CHECK(3,1,0) || \ + HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ + HEDLEY_ARM_VERSION_CHECK(5,6,0) || \ + HEDLEY_IBM_VERSION_CHECK(10,1,0) || \ + HEDLEY_TI_VERSION_CHECK(8,0,0) || \ + (HEDLEY_TI_VERSION_CHECK(7,3,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) + #define HEDLEY_PRINTF_FORMAT(string_idx,first_to_check) __attribute__((__format__(__printf__, string_idx, first_to_check))) +#elif HEDLEY_PELLES_VERSION_CHECK(6,0,0) + #define HEDLEY_PRINTF_FORMAT(string_idx,first_to_check) __declspec(vaformat(printf,string_idx,first_to_check)) +#else + #define HEDLEY_PRINTF_FORMAT(string_idx,first_to_check) +#endif + +#if defined(HEDLEY_CONSTEXPR) + #undef HEDLEY_CONSTEXPR +#endif +#if defined(__cplusplus) + #if __cplusplus >= 201103L + #define HEDLEY_CONSTEXPR constexpr + #endif +#endif +#if !defined(HEDLEY_CONSTEXPR) + #define HEDLEY_CONSTEXPR +#endif + +#if defined(HEDLEY_PREDICT) + #undef HEDLEY_PREDICT +#endif +#if defined(HEDLEY_LIKELY) + #undef HEDLEY_LIKELY +#endif +#if defined(HEDLEY_UNLIKELY) + #undef HEDLEY_UNLIKELY +#endif +#if defined(HEDLEY_UNPREDICTABLE) + #undef HEDLEY_UNPREDICTABLE +#endif +#if HEDLEY_HAS_BUILTIN(__builtin_unpredictable) + #define HEDLEY_UNPREDICTABLE(expr) __builtin_unpredictable(!!(expr)) +#endif +#if \ + HEDLEY_HAS_BUILTIN(__builtin_expect_with_probability) || \ + HEDLEY_GCC_VERSION_CHECK(9,0,0) +# define HEDLEY_PREDICT(expr, value, probability) __builtin_expect_with_probability(expr, value, probability) +# define HEDLEY_PREDICT_TRUE(expr, probability) __builtin_expect_with_probability(!!(expr), 1, probability) +# define HEDLEY_PREDICT_FALSE(expr, probability) __builtin_expect_with_probability(!!(expr), 0, probability) +# define HEDLEY_LIKELY(expr) __builtin_expect(!!(expr), 1) +# define HEDLEY_UNLIKELY(expr) __builtin_expect(!!(expr), 0) +#if !defined(HEDLEY_BUILTIN_UNPREDICTABLE) + #define HEDLEY_BUILTIN_UNPREDICTABLE(expr) __builtin_expect_with_probability(!!(expr), 1, 0.5) +#endif +#elif \ + HEDLEY_HAS_BUILTIN(__builtin_expect) || \ + HEDLEY_GCC_VERSION_CHECK(3,0,0) || \ + HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ + (HEDLEY_SUNPRO_VERSION_CHECK(5,15,0) && defined(__cplusplus)) || \ + HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ + HEDLEY_IBM_VERSION_CHECK(10,1,0) || \ + HEDLEY_TI_VERSION_CHECK(6,1,0) || \ + HEDLEY_TINYC_VERSION_CHECK(0,9,27) +# define HEDLEY_PREDICT(expr, expected, probability) \ + (((probability) >= 0.9) ? __builtin_expect(!!(expr), (expected)) : (((void) (expected)), !!(expr))) +# define HEDLEY_PREDICT_TRUE(expr, probability) \ + (__extension__ ({ \ + HEDLEY_CONSTEXPR double hedley_probability_ = (probability); \ + ((hedley_probability_ >= 0.9) ? __builtin_expect(!!(expr), 1) : ((hedley_probability_ <= 0.1) ? __builtin_expect(!!(expr), 0) : !!(expr))); \ + })) +# define HEDLEY_PREDICT_FALSE(expr, probability) \ + (__extension__ ({ \ + HEDLEY_CONSTEXPR double hedley_probability_ = (probability); \ + ((hedley_probability_ >= 0.9) ? __builtin_expect(!!(expr), 0) : ((hedley_probability_ <= 0.1) ? __builtin_expect(!!(expr), 1) : !!(expr))); \ + })) +# define HEDLEY_LIKELY(expr) __builtin_expect(!!(expr), 1) +# define HEDLEY_UNLIKELY(expr) __builtin_expect(!!(expr), 0) +#else +# define HEDLEY_PREDICT(expr, expected, probability) (((void) (expected)), !!(expr)) +# define HEDLEY_PREDICT_TRUE(expr, probability) (!!(expr)) +# define HEDLEY_PREDICT_FALSE(expr, probability) (!!(expr)) +# define HEDLEY_LIKELY(expr) (!!(expr)) +# define HEDLEY_UNLIKELY(expr) (!!(expr)) +#endif +#if !defined(HEDLEY_UNPREDICTABLE) + #define HEDLEY_UNPREDICTABLE(expr) HEDLEY_PREDICT(expr, 1, 0.5) +#endif + +#if defined(HEDLEY_MALLOC) + #undef HEDLEY_MALLOC +#endif +#if \ + HEDLEY_HAS_ATTRIBUTE(malloc) || \ + HEDLEY_GCC_VERSION_CHECK(3,1,0) || \ + HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ + HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \ + HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ + HEDLEY_IBM_VERSION_CHECK(12,1,0) || \ + HEDLEY_TI_VERSION_CHECK(8,0,0) || \ + (HEDLEY_TI_VERSION_CHECK(7,3,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) + #define HEDLEY_MALLOC __attribute__((__malloc__)) +#elif HEDLEY_MSVC_VERSION_CHECK(14, 0, 0) + #define HEDLEY_MALLOC __declspec(restrict) +#else + #define HEDLEY_MALLOC +#endif + +#if defined(HEDLEY_PURE) + #undef HEDLEY_PURE +#endif +#if \ + HEDLEY_HAS_ATTRIBUTE(pure) || \ + HEDLEY_GCC_VERSION_CHECK(2,96,0) || \ + HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ + HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \ + HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ + HEDLEY_IBM_VERSION_CHECK(10,1,0) || \ + HEDLEY_TI_VERSION_CHECK(8,0,0) || \ + (HEDLEY_TI_VERSION_CHECK(7,3,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ + HEDLEY_PGI_VERSION_CHECK(17,10,0) + #define HEDLEY_PURE __attribute__((__pure__)) +#elif HEDLEY_TI_VERSION_CHECK(6,0,0) && defined(__cplusplus) + #define HEDLEY_PURE _Pragma("FUNC_IS_PURE;") +#else + #define HEDLEY_PURE +#endif + +#if defined(HEDLEY_CONST) + #undef HEDLEY_CONST +#endif +#if \ + HEDLEY_HAS_ATTRIBUTE(const) || \ + HEDLEY_GCC_VERSION_CHECK(2,5,0) || \ + HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ + HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \ + HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ + HEDLEY_IBM_VERSION_CHECK(10,1,0) || \ + HEDLEY_TI_VERSION_CHECK(8,0,0) || \ + (HEDLEY_TI_VERSION_CHECK(7,3,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ + HEDLEY_PGI_VERSION_CHECK(17,10,0) + #define HEDLEY_CONST __attribute__((__const__)) +#else + #define HEDLEY_CONST HEDLEY_PURE +#endif + +#if defined(HEDLEY_RESTRICT) + #undef HEDLEY_RESTRICT +#endif +#if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) && !defined(__cplusplus) + #define HEDLEY_RESTRICT restrict +#elif \ + HEDLEY_GCC_VERSION_CHECK(3,1,0) || \ + HEDLEY_MSVC_VERSION_CHECK(14,0,0) || \ + HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ + HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ + HEDLEY_IBM_VERSION_CHECK(10,1,0) || \ + HEDLEY_PGI_VERSION_CHECK(17,10,0) || \ + HEDLEY_TI_VERSION_CHECK(8,0,0) || \ + (HEDLEY_SUNPRO_VERSION_CHECK(5,14,0) && defined(__cplusplus)) || \ + HEDLEY_IAR_VERSION_CHECK(8,0,0) || \ + defined(__clang__) + #define HEDLEY_RESTRICT __restrict +#elif HEDLEY_SUNPRO_VERSION_CHECK(5,3,0) && !defined(__cplusplus) + #define HEDLEY_RESTRICT _Restrict +#else + #define HEDLEY_RESTRICT +#endif + +#if defined(HEDLEY_INLINE) + #undef HEDLEY_INLINE +#endif +#if \ + (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)) || \ + (defined(__cplusplus) && (__cplusplus >= 199711L)) + #define HEDLEY_INLINE inline +#elif \ + defined(HEDLEY_GCC_VERSION) || \ + HEDLEY_ARM_VERSION_CHECK(6,2,0) + #define HEDLEY_INLINE __inline__ +#elif \ + HEDLEY_MSVC_VERSION_CHECK(12,0,0) || \ + HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ + HEDLEY_TI_VERSION_CHECK(8,0,0) + #define HEDLEY_INLINE __inline +#else + #define HEDLEY_INLINE +#endif + +#if defined(HEDLEY_ALWAYS_INLINE) + #undef HEDLEY_ALWAYS_INLINE +#endif +#if \ + HEDLEY_HAS_ATTRIBUTE(always_inline) || \ + HEDLEY_GCC_VERSION_CHECK(4,0,0) || \ + HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ + HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \ + HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ + HEDLEY_IBM_VERSION_CHECK(10,1,0) || \ + HEDLEY_TI_VERSION_CHECK(8,0,0) || \ + (HEDLEY_TI_VERSION_CHECK(7,3,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) + #define HEDLEY_ALWAYS_INLINE __attribute__((__always_inline__)) HEDLEY_INLINE +#elif HEDLEY_MSVC_VERSION_CHECK(12,0,0) + #define HEDLEY_ALWAYS_INLINE __forceinline +#elif HEDLEY_TI_VERSION_CHECK(7,0,0) && defined(__cplusplus) + #define HEDLEY_ALWAYS_INLINE _Pragma("FUNC_ALWAYS_INLINE;") +#elif HEDLEY_IAR_VERSION_CHECK(8,0,0) + #define HEDLEY_ALWAYS_INLINE _Pragma("inline=forced") +#else + #define HEDLEY_ALWAYS_INLINE HEDLEY_INLINE +#endif + +#if defined(HEDLEY_NEVER_INLINE) + #undef HEDLEY_NEVER_INLINE +#endif +#if \ + HEDLEY_HAS_ATTRIBUTE(noinline) || \ + HEDLEY_GCC_VERSION_CHECK(4,0,0) || \ + HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ + HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \ + HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ + HEDLEY_IBM_VERSION_CHECK(10,1,0) || \ + HEDLEY_TI_VERSION_CHECK(8,0,0) || \ + (HEDLEY_TI_VERSION_CHECK(7,3,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) + #define HEDLEY_NEVER_INLINE __attribute__((__noinline__)) +#elif HEDLEY_MSVC_VERSION_CHECK(13,10,0) + #define HEDLEY_NEVER_INLINE __declspec(noinline) +#elif HEDLEY_PGI_VERSION_CHECK(10,2,0) + #define HEDLEY_NEVER_INLINE _Pragma("noinline") +#elif HEDLEY_TI_VERSION_CHECK(6,0,0) && defined(__cplusplus) + #define HEDLEY_NEVER_INLINE _Pragma("FUNC_CANNOT_INLINE;") +#elif HEDLEY_IAR_VERSION_CHECK(8,0,0) + #define HEDLEY_NEVER_INLINE _Pragma("inline=never") +#elif HEDLEY_COMPCERT_VERSION_CHECK(3,2,0) + #define HEDLEY_NEVER_INLINE __attribute((noinline)) +#elif HEDLEY_PELLES_VERSION_CHECK(9,0,0) + #define HEDLEY_NEVER_INLINE __declspec(noinline) +#else + #define HEDLEY_NEVER_INLINE +#endif + +#if defined(HEDLEY_PRIVATE) + #undef HEDLEY_PRIVATE +#endif +#if defined(HEDLEY_PUBLIC) + #undef HEDLEY_PUBLIC +#endif +#if defined(HEDLEY_IMPORT) + #undef HEDLEY_IMPORT +#endif +#if defined(_WIN32) || defined(__CYGWIN__) + #define HEDLEY_PRIVATE + #define HEDLEY_PUBLIC __declspec(dllexport) + #define HEDLEY_IMPORT __declspec(dllimport) +#else + #if \ + HEDLEY_HAS_ATTRIBUTE(visibility) || \ + HEDLEY_GCC_VERSION_CHECK(3,3,0) || \ + HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \ + HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ + HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ + HEDLEY_IBM_VERSION_CHECK(13,1,0) || \ + HEDLEY_TI_VERSION_CHECK(8,0,0) || \ + (HEDLEY_TI_VERSION_CHECK(7,3,0) && defined(__TI_EABI__) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) + #define HEDLEY_PRIVATE __attribute__((__visibility__("hidden"))) + #define HEDLEY_PUBLIC __attribute__((__visibility__("default"))) + #else + #define HEDLEY_PRIVATE + #define HEDLEY_PUBLIC + #endif + #define HEDLEY_IMPORT extern +#endif + +#if defined(HEDLEY_NO_THROW) + #undef HEDLEY_NO_THROW +#endif +#if \ + HEDLEY_HAS_ATTRIBUTE(nothrow) || \ + HEDLEY_GCC_VERSION_CHECK(3,3,0) || \ + HEDLEY_INTEL_VERSION_CHECK(13,0,0) + #define HEDLEY_NO_THROW __attribute__((__nothrow__)) +#elif \ + HEDLEY_MSVC_VERSION_CHECK(13,1,0) || \ + HEDLEY_ARM_VERSION_CHECK(4,1,0) + #define HEDLEY_NO_THROW __declspec(nothrow) +#else + #define HEDLEY_NO_THROW +#endif + +#if defined(HEDLEY_FALL_THROUGH) + #undef HEDLEY_FALL_THROUGH +#endif +#if \ + defined(__cplusplus) && \ + (!defined(HEDLEY_SUNPRO_VERSION) || HEDLEY_SUNPRO_VERSION_CHECK(5,15,0)) && \ + !defined(HEDLEY_PGI_VERSION) + #if \ + (__cplusplus >= 201703L) || \ + ((__cplusplus >= 201103L) && HEDLEY_HAS_CPP_ATTRIBUTE(fallthrough)) + #define HEDLEY_FALL_THROUGH [[fallthrough]] + #elif (__cplusplus >= 201103L) && HEDLEY_HAS_CPP_ATTRIBUTE(clang::fallthrough) + #define HEDLEY_FALL_THROUGH [[clang::fallthrough]] + #elif (__cplusplus >= 201103L) && HEDLEY_GCC_VERSION_CHECK(7,0,0) + #define HEDLEY_FALL_THROUGH [[gnu::fallthrough]] + #endif +#endif +#if !defined(HEDLEY_FALL_THROUGH) + #if HEDLEY_GNUC_HAS_ATTRIBUTE(fallthrough,7,0,0) && !defined(HEDLEY_PGI_VERSION) + #define HEDLEY_FALL_THROUGH __attribute__((__fallthrough__)) + #elif defined(__fallthrough) /* SAL */ + #define HEDLEY_FALL_THROUGH __fallthrough + #else + #define HEDLEY_FALL_THROUGH + #endif +#endif + +#if defined(HEDLEY_RETURNS_NON_NULL) + #undef HEDLEY_RETURNS_NON_NULL +#endif +#if \ + HEDLEY_HAS_ATTRIBUTE(returns_nonnull) || \ + HEDLEY_GCC_VERSION_CHECK(4,9,0) + #define HEDLEY_RETURNS_NON_NULL __attribute__((__returns_nonnull__)) +#elif defined(_Ret_notnull_) /* SAL */ + #define HEDLEY_RETURNS_NON_NULL _Ret_notnull_ +#else + #define HEDLEY_RETURNS_NON_NULL +#endif + +#if defined(HEDLEY_ARRAY_PARAM) + #undef HEDLEY_ARRAY_PARAM +#endif +#if \ + defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) && \ + !defined(__STDC_NO_VLA__) && \ + !defined(__cplusplus) && \ + !defined(HEDLEY_PGI_VERSION) && \ + !defined(HEDLEY_TINYC_VERSION) + #define HEDLEY_ARRAY_PARAM(name) (name) +#else + #define HEDLEY_ARRAY_PARAM(name) +#endif + +#if defined(HEDLEY_IS_CONSTANT) + #undef HEDLEY_IS_CONSTANT +#endif +#if defined(HEDLEY_REQUIRE_CONSTEXPR) + #undef HEDLEY_REQUIRE_CONSTEXPR +#endif +/* Note the double-underscore. For internal use only; no API + * guarantees! */ +#if defined(HEDLEY__IS_CONSTEXPR) + #undef HEDLEY__IS_CONSTEXPR +#endif + +#if \ + HEDLEY_HAS_BUILTIN(__builtin_constant_p) || \ + HEDLEY_GCC_VERSION_CHECK(3,4,0) || \ + HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ + HEDLEY_TINYC_VERSION_CHECK(0,9,19) || \ + HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ + HEDLEY_IBM_VERSION_CHECK(13,1,0) || \ + HEDLEY_TI_VERSION_CHECK(6,1,0) || \ + HEDLEY_SUNPRO_VERSION_CHECK(5,10,0) || \ + HEDLEY_CRAY_VERSION_CHECK(8,1,0) + #define HEDLEY_IS_CONSTANT(expr) __builtin_constant_p(expr) +#endif +#if !defined(__cplusplus) +# if \ + HEDLEY_HAS_BUILTIN(__builtin_types_compatible_p) || \ + HEDLEY_GCC_VERSION_CHECK(3,4,0) || \ + HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ + HEDLEY_IBM_VERSION_CHECK(13,1,0) || \ + HEDLEY_CRAY_VERSION_CHECK(8,1,0) || \ + HEDLEY_ARM_VERSION_CHECK(5,4,0) || \ + HEDLEY_TINYC_VERSION_CHECK(0,9,24) +#if defined(__INTPTR_TYPE__) + #define HEDLEY__IS_CONSTEXPR(expr) __builtin_types_compatible_p(__typeof__((1 ? (void*) ((__INTPTR_TYPE__) ((expr) * 0)) : (int*) 0)), int*) +#else + #include + #define HEDLEY__IS_CONSTEXPR(expr) __builtin_types_compatible_p(__typeof__((1 ? (void*) ((intptr_t) ((expr) * 0)) : (int*) 0)), int*) +#endif +# elif \ + (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 201112L) && !defined(HEDLEY_SUNPRO_VERSION) && !defined(HEDLEY_PGI_VERSION)) || \ + HEDLEY_HAS_EXTENSION(c_generic_selections) || \ + HEDLEY_GCC_VERSION_CHECK(4,9,0) || \ + HEDLEY_INTEL_VERSION_CHECK(17,0,0) || \ + HEDLEY_IBM_VERSION_CHECK(12,1,0) || \ + HEDLEY_ARM_VERSION_CHECK(5,3,0) +#if defined(__INTPTR_TYPE__) + #define HEDLEY__IS_CONSTEXPR(expr) _Generic((1 ? (void*) ((__INTPTR_TYPE__) ((expr) * 0)) : (int*) 0), int*: 1, void*: 0) +#else + #include + #define HEDLEY__IS_CONSTEXPR(expr) _Generic((1 ? (void*) ((intptr_t) * 0) : (int*) 0), int*: 1, void*: 0) +#endif +# elif \ + defined(HEDLEY_GCC_VERSION) || \ + defined(HEDLEY_INTEL_VERSION) || \ + defined(HEDLEY_TINYC_VERSION) || \ + defined(HEDLEY_TI_VERSION) || \ + defined(__clang__) +# define HEDLEY__IS_CONSTEXPR(expr) ( \ + sizeof(void) != \ + sizeof(*( \ + 1 ? \ + ((void*) ((expr) * 0L) ) : \ +((struct { char v[sizeof(void) * 2]; } *) 1) \ + ) \ + ) \ + ) +# endif +#endif +#if defined(HEDLEY__IS_CONSTEXPR) + #if !defined(HEDLEY_IS_CONSTANT) + #define HEDLEY_IS_CONSTANT(expr) HEDLEY__IS_CONSTEXPR(expr) + #endif + #define HEDLEY_REQUIRE_CONSTEXPR(expr) (HEDLEY__IS_CONSTEXPR(expr) ? (expr) : (-1)) +#else + #if !defined(HEDLEY_IS_CONSTANT) + #define HEDLEY_IS_CONSTANT(expr) (0) + #endif + #define HEDLEY_REQUIRE_CONSTEXPR(expr) (expr) +#endif + +#if defined(HEDLEY_BEGIN_C_DECLS) + #undef HEDLEY_BEGIN_C_DECLS +#endif +#if defined(HEDLEY_END_C_DECLS) + #undef HEDLEY_END_C_DECLS +#endif +#if defined(HEDLEY_C_DECL) + #undef HEDLEY_C_DECL +#endif +#if defined(__cplusplus) + #define HEDLEY_BEGIN_C_DECLS extern "C" { + #define HEDLEY_END_C_DECLS } + #define HEDLEY_C_DECL extern "C" +#else + #define HEDLEY_BEGIN_C_DECLS + #define HEDLEY_END_C_DECLS + #define HEDLEY_C_DECL +#endif + +#if defined(HEDLEY_STATIC_ASSERT) + #undef HEDLEY_STATIC_ASSERT +#endif +#if \ + !defined(__cplusplus) && ( \ + (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 201112L)) || \ + HEDLEY_HAS_FEATURE(c_static_assert) || \ + HEDLEY_GCC_VERSION_CHECK(6,0,0) || \ + HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ + defined(_Static_assert) \ + ) +# define HEDLEY_STATIC_ASSERT(expr, message) _Static_assert(expr, message) +#elif \ + (defined(__cplusplus) && (__cplusplus >= 201703L)) || \ + HEDLEY_MSVC_VERSION_CHECK(16,0,0) || \ + (defined(__cplusplus) && HEDLEY_TI_VERSION_CHECK(8,3,0)) +# define HEDLEY_STATIC_ASSERT(expr, message) static_assert(expr, message) +#elif defined(__cplusplus) && (__cplusplus >= 201103L) +# define HEDLEY_STATIC_ASSERT(expr, message) static_assert(expr) +#else +# define HEDLEY_STATIC_ASSERT(expr, message) +#endif + +#if defined(HEDLEY_CONST_CAST) + #undef HEDLEY_CONST_CAST +#endif +#if defined(__cplusplus) +# define HEDLEY_CONST_CAST(T, expr) (const_cast(expr)) +#elif \ + HEDLEY_HAS_WARNING("-Wcast-qual") || \ + HEDLEY_GCC_VERSION_CHECK(4,6,0) || \ + HEDLEY_INTEL_VERSION_CHECK(13,0,0) +# define HEDLEY_CONST_CAST(T, expr) (__extension__ ({ \ + HEDLEY_DIAGNOSTIC_PUSH \ + HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL \ + ((T) (expr)); \ + HEDLEY_DIAGNOSTIC_POP \ + })) +#else +# define HEDLEY_CONST_CAST(T, expr) ((T) (expr)) +#endif + +#if defined(HEDLEY_REINTERPRET_CAST) + #undef HEDLEY_REINTERPRET_CAST +#endif +#if defined(__cplusplus) + #define HEDLEY_REINTERPRET_CAST(T, expr) (reinterpret_cast(expr)) +#else + #define HEDLEY_REINTERPRET_CAST(T, expr) (*((T*) &(expr))) +#endif + +#if defined(HEDLEY_STATIC_CAST) + #undef HEDLEY_STATIC_CAST +#endif +#if defined(__cplusplus) + #define HEDLEY_STATIC_CAST(T, expr) (static_cast(expr)) +#else + #define HEDLEY_STATIC_CAST(T, expr) ((T) (expr)) +#endif + +#if defined(HEDLEY_CPP_CAST) + #undef HEDLEY_CPP_CAST +#endif +#if defined(__cplusplus) + #define HEDLEY_CPP_CAST(T, expr) static_cast(expr) +#else + #define HEDLEY_CPP_CAST(T, expr) (expr) +#endif + +#if defined(HEDLEY_MESSAGE) + #undef HEDLEY_MESSAGE +#endif +#if HEDLEY_HAS_WARNING("-Wunknown-pragmas") +# define HEDLEY_MESSAGE(msg) \ + HEDLEY_DIAGNOSTIC_PUSH \ + HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS \ + HEDLEY_PRAGMA(message msg) \ + HEDLEY_DIAGNOSTIC_POP +#elif \ + HEDLEY_GCC_VERSION_CHECK(4,4,0) || \ + HEDLEY_INTEL_VERSION_CHECK(13,0,0) +# define HEDLEY_MESSAGE(msg) HEDLEY_PRAGMA(message msg) +#elif HEDLEY_CRAY_VERSION_CHECK(5,0,0) +# define HEDLEY_MESSAGE(msg) HEDLEY_PRAGMA(_CRI message msg) +#elif HEDLEY_IAR_VERSION_CHECK(8,0,0) +# define HEDLEY_MESSAGE(msg) HEDLEY_PRAGMA(message(msg)) +#elif HEDLEY_PELLES_VERSION_CHECK(2,0,0) +# define HEDLEY_MESSAGE(msg) HEDLEY_PRAGMA(message(msg)) +#else +# define HEDLEY_MESSAGE(msg) +#endif + +#if defined(HEDLEY_WARNING) + #undef HEDLEY_WARNING +#endif +#if HEDLEY_HAS_WARNING("-Wunknown-pragmas") +# define HEDLEY_WARNING(msg) \ + HEDLEY_DIAGNOSTIC_PUSH \ + HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS \ + HEDLEY_PRAGMA(clang warning msg) \ + HEDLEY_DIAGNOSTIC_POP +#elif \ + HEDLEY_GCC_VERSION_CHECK(4,8,0) || \ + HEDLEY_PGI_VERSION_CHECK(18,4,0) +# define HEDLEY_WARNING(msg) HEDLEY_PRAGMA(GCC warning msg) +#elif HEDLEY_MSVC_VERSION_CHECK(15,0,0) +# define HEDLEY_WARNING(msg) HEDLEY_PRAGMA(message(msg)) +#else +# define HEDLEY_WARNING(msg) HEDLEY_MESSAGE(msg) +#endif + +#if defined(HEDLEY_REQUIRE_MSG) + #undef HEDLEY_REQUIRE_MSG +#endif +#if HEDLEY_HAS_ATTRIBUTE(diagnose_if) +# if HEDLEY_HAS_WARNING("-Wgcc-compat") +# define HEDLEY_REQUIRE_MSG(expr, msg) \ + HEDLEY_DIAGNOSTIC_PUSH \ + _Pragma("clang diagnostic ignored \"-Wgcc-compat\"") \ + __attribute__((__diagnose_if__(!(expr), msg, "error"))) \ + HEDLEY_DIAGNOSTIC_POP +# else +# define HEDLEY_REQUIRE_MSG(expr, msg) __attribute__((__diagnose_if__(!(expr), msg, "error"))) +# endif +#else +# define HEDLEY_REQUIRE_MSG(expr, msg) +#endif + +#if defined(HEDLEY_REQUIRE) + #undef HEDLEY_REQUIRE +#endif +#define HEDLEY_REQUIRE(expr) HEDLEY_REQUIRE_MSG(expr, #expr) + +#if defined(HEDLEY_FLAGS) + #undef HEDLEY_FLAGS +#endif +#if HEDLEY_HAS_ATTRIBUTE(flag_enum) + #define HEDLEY_FLAGS __attribute__((__flag_enum__)) +#endif + +#if defined(HEDLEY_FLAGS_CAST) + #undef HEDLEY_FLAGS_CAST +#endif +#if HEDLEY_INTEL_VERSION_CHECK(19,0,0) +# define HEDLEY_FLAGS_CAST(T, expr) (__extension__ ({ \ + HEDLEY_DIAGNOSTIC_PUSH \ + _Pragma("warning(disable:188)") \ + ((T) (expr)); \ + HEDLEY_DIAGNOSTIC_POP \ + })) +#else +# define HEDLEY_FLAGS_CAST(T, expr) HEDLEY_STATIC_CAST(T, expr) +#endif + +/* Remaining macros are deprecated. */ + +#if defined(HEDLEY_GCC_NOT_CLANG_VERSION_CHECK) + #undef HEDLEY_GCC_NOT_CLANG_VERSION_CHECK +#endif +#if defined(__clang__) + #define HEDLEY_GCC_NOT_CLANG_VERSION_CHECK(major,minor,patch) (0) +#else + #define HEDLEY_GCC_NOT_CLANG_VERSION_CHECK(major,minor,patch) HEDLEY_GCC_VERSION_CHECK(major,minor,patch) +#endif + +#if defined(HEDLEY_CLANG_HAS_ATTRIBUTE) + #undef HEDLEY_CLANG_HAS_ATTRIBUTE +#endif +#define HEDLEY_CLANG_HAS_ATTRIBUTE(attribute) HEDLEY_HAS_ATTRIBUTE(attribute) + +#if defined(HEDLEY_CLANG_HAS_CPP_ATTRIBUTE) + #undef HEDLEY_CLANG_HAS_CPP_ATTRIBUTE +#endif +#define HEDLEY_CLANG_HAS_CPP_ATTRIBUTE(attribute) HEDLEY_HAS_CPP_ATTRIBUTE(attribute) + +#if defined(HEDLEY_CLANG_HAS_BUILTIN) + #undef HEDLEY_CLANG_HAS_BUILTIN +#endif +#define HEDLEY_CLANG_HAS_BUILTIN(builtin) HEDLEY_HAS_BUILTIN(builtin) + +#if defined(HEDLEY_CLANG_HAS_FEATURE) + #undef HEDLEY_CLANG_HAS_FEATURE +#endif +#define HEDLEY_CLANG_HAS_FEATURE(feature) HEDLEY_HAS_FEATURE(feature) + +#if defined(HEDLEY_CLANG_HAS_EXTENSION) + #undef HEDLEY_CLANG_HAS_EXTENSION +#endif +#define HEDLEY_CLANG_HAS_EXTENSION(extension) HEDLEY_HAS_EXTENSION(extension) + +#if defined(HEDLEY_CLANG_HAS_DECLSPEC_DECLSPEC_ATTRIBUTE) + #undef HEDLEY_CLANG_HAS_DECLSPEC_DECLSPEC_ATTRIBUTE +#endif +#define HEDLEY_CLANG_HAS_DECLSPEC_ATTRIBUTE(attribute) HEDLEY_HAS_DECLSPEC_ATTRIBUTE(attribute) + +#if defined(HEDLEY_CLANG_HAS_WARNING) + #undef HEDLEY_CLANG_HAS_WARNING +#endif +#define HEDLEY_CLANG_HAS_WARNING(warning) HEDLEY_HAS_WARNING(warning) + +#endif /* !defined(HEDLEY_VERSION) || (HEDLEY_VERSION < X) */ diff --git a/single_include/nlohmann/json.hpp b/single_include/nlohmann/json.hpp index 08c4fc64..32ce6dff 100644 --- a/single_include/nlohmann/json.hpp +++ b/single_include/nlohmann/json.hpp @@ -105,6 +105,1635 @@ struct position_t } // namespace detail } // namespace nlohmann +// #include + + +#include // pair +// #include +/* Hedley - https://nemequ.github.io/hedley + * Created by Evan Nemerson + * + * To the extent possible under law, the author(s) have dedicated all + * copyright and related and neighboring rights to this software to + * the public domain worldwide. This software is distributed without + * any warranty. + * + * For details, see . + * SPDX-License-Identifier: CC0-1.0 + */ + +#if !defined(HEDLEY_VERSION) || (HEDLEY_VERSION < 9) +#if defined(HEDLEY_VERSION) + #undef HEDLEY_VERSION +#endif +#define HEDLEY_VERSION 9 + +#if defined(HEDLEY_STRINGIFY_EX) + #undef HEDLEY_STRINGIFY_EX +#endif +#define HEDLEY_STRINGIFY_EX(x) #x + +#if defined(HEDLEY_STRINGIFY) + #undef HEDLEY_STRINGIFY +#endif +#define HEDLEY_STRINGIFY(x) HEDLEY_STRINGIFY_EX(x) + +#if defined(HEDLEY_CONCAT_EX) + #undef HEDLEY_CONCAT_EX +#endif +#define HEDLEY_CONCAT_EX(a,b) a##b + +#if defined(HEDLEY_CONCAT) + #undef HEDLEY_CONCAT +#endif +#define HEDLEY_CONCAT(a,b) HEDLEY_CONCAT_EX(a,b) + +#if defined(HEDLEY_VERSION_ENCODE) + #undef HEDLEY_VERSION_ENCODE +#endif +#define HEDLEY_VERSION_ENCODE(major,minor,revision) (((major) * 1000000) + ((minor) * 1000) + (revision)) + +#if defined(HEDLEY_VERSION_DECODE_MAJOR) + #undef HEDLEY_VERSION_DECODE_MAJOR +#endif +#define HEDLEY_VERSION_DECODE_MAJOR(version) ((version) / 1000000) + +#if defined(HEDLEY_VERSION_DECODE_MINOR) + #undef HEDLEY_VERSION_DECODE_MINOR +#endif +#define HEDLEY_VERSION_DECODE_MINOR(version) (((version) % 1000000) / 1000) + +#if defined(HEDLEY_VERSION_DECODE_REVISION) + #undef HEDLEY_VERSION_DECODE_REVISION +#endif +#define HEDLEY_VERSION_DECODE_REVISION(version) ((version) % 1000) + +#if defined(HEDLEY_GNUC_VERSION) + #undef HEDLEY_GNUC_VERSION +#endif +#if defined(__GNUC__) && defined(__GNUC_PATCHLEVEL__) + #define HEDLEY_GNUC_VERSION HEDLEY_VERSION_ENCODE(__GNUC__, __GNUC_MINOR__, __GNUC_PATCHLEVEL__) +#elif defined(__GNUC__) + #define HEDLEY_GNUC_VERSION HEDLEY_VERSION_ENCODE(__GNUC__, __GNUC_MINOR__, 0) +#endif + +#if defined(HEDLEY_GNUC_VERSION_CHECK) + #undef HEDLEY_GNUC_VERSION_CHECK +#endif +#if defined(HEDLEY_GNUC_VERSION) + #define HEDLEY_GNUC_VERSION_CHECK(major,minor,patch) (HEDLEY_GNUC_VERSION >= HEDLEY_VERSION_ENCODE(major, minor, patch)) +#else + #define HEDLEY_GNUC_VERSION_CHECK(major,minor,patch) (0) +#endif + +#if defined(HEDLEY_MSVC_VERSION) + #undef HEDLEY_MSVC_VERSION +#endif +#if defined(_MSC_FULL_VER) && (_MSC_FULL_VER >= 140000000) + #define HEDLEY_MSVC_VERSION HEDLEY_VERSION_ENCODE(_MSC_FULL_VER / 10000000, (_MSC_FULL_VER % 10000000) / 100000, (_MSC_FULL_VER % 100000) / 100) +#elif defined(_MSC_FULL_VER) + #define HEDLEY_MSVC_VERSION HEDLEY_VERSION_ENCODE(_MSC_FULL_VER / 1000000, (_MSC_FULL_VER % 1000000) / 10000, (_MSC_FULL_VER % 10000) / 10) +#elif defined(_MSC_VER) + #define HEDLEY_MSVC_VERSION HEDLEY_VERSION_ENCODE(_MSC_VER / 100, _MSC_VER % 100, 0) +#endif + +#if defined(HEDLEY_MSVC_VERSION_CHECK) + #undef HEDLEY_MSVC_VERSION_CHECK +#endif +#if !defined(_MSC_VER) + #define HEDLEY_MSVC_VERSION_CHECK(major,minor,patch) (0) +#elif defined(_MSC_VER) && (_MSC_VER >= 1400) + #define HEDLEY_MSVC_VERSION_CHECK(major,minor,patch) (_MSC_FULL_VER >= ((major * 10000000) + (minor * 100000) + (patch))) +#elif defined(_MSC_VER) && (_MSC_VER >= 1200) + #define HEDLEY_MSVC_VERSION_CHECK(major,minor,patch) (_MSC_FULL_VER >= ((major * 1000000) + (minor * 10000) + (patch))) +#else + #define HEDLEY_MSVC_VERSION_CHECK(major,minor,patch) (_MSC_VER >= ((major * 100) + (minor))) +#endif + +#if defined(HEDLEY_INTEL_VERSION) + #undef HEDLEY_INTEL_VERSION +#endif +#if defined(__INTEL_COMPILER) && defined(__INTEL_COMPILER_UPDATE) + #define HEDLEY_INTEL_VERSION HEDLEY_VERSION_ENCODE(__INTEL_COMPILER / 100, __INTEL_COMPILER % 100, __INTEL_COMPILER_UPDATE) +#elif defined(__INTEL_COMPILER) + #define HEDLEY_INTEL_VERSION HEDLEY_VERSION_ENCODE(__INTEL_COMPILER / 100, __INTEL_COMPILER % 100, 0) +#endif + +#if defined(HEDLEY_INTEL_VERSION_CHECK) + #undef HEDLEY_INTEL_VERSION_CHECK +#endif +#if defined(HEDLEY_INTEL_VERSION) + #define HEDLEY_INTEL_VERSION_CHECK(major,minor,patch) (HEDLEY_INTEL_VERSION >= HEDLEY_VERSION_ENCODE(major, minor, patch)) +#else + #define HEDLEY_INTEL_VERSION_CHECK(major,minor,patch) (0) +#endif + +#if defined(HEDLEY_PGI_VERSION) + #undef HEDLEY_PGI_VERSION +#endif +#if defined(__PGI) && defined(__PGIC__) && defined(__PGIC_MINOR__) && defined(__PGIC_PATCHLEVEL__) + #define HEDLEY_PGI_VERSION HEDLEY_VERSION_ENCODE(__PGIC__, __PGIC_MINOR__, __PGIC_PATCHLEVEL__) +#endif + +#if defined(HEDLEY_PGI_VERSION_CHECK) + #undef HEDLEY_PGI_VERSION_CHECK +#endif +#if defined(HEDLEY_PGI_VERSION) + #define HEDLEY_PGI_VERSION_CHECK(major,minor,patch) (HEDLEY_PGI_VERSION >= HEDLEY_VERSION_ENCODE(major, minor, patch)) +#else + #define HEDLEY_PGI_VERSION_CHECK(major,minor,patch) (0) +#endif + +#if defined(HEDLEY_SUNPRO_VERSION) + #undef HEDLEY_SUNPRO_VERSION +#endif +#if defined(__SUNPRO_C) && (__SUNPRO_C > 0x1000) + #define HEDLEY_SUNPRO_VERSION HEDLEY_VERSION_ENCODE((((__SUNPRO_C >> 16) & 0xf) * 10) + ((__SUNPRO_C >> 12) & 0xf), (((__SUNPRO_C >> 8) & 0xf) * 10) + ((__SUNPRO_C >> 4) & 0xf), (__SUNPRO_C & 0xf) * 10) +#elif defined(__SUNPRO_C) + #define HEDLEY_SUNPRO_VERSION HEDLEY_VERSION_ENCODE((__SUNPRO_C >> 8) & 0xf, (__SUNPRO_C >> 4) & 0xf, (__SUNPRO_C) & 0xf) +#elif defined(__SUNPRO_CC) && (__SUNPRO_CC > 0x1000) + #define HEDLEY_SUNPRO_VERSION HEDLEY_VERSION_ENCODE((((__SUNPRO_CC >> 16) & 0xf) * 10) + ((__SUNPRO_CC >> 12) & 0xf), (((__SUNPRO_CC >> 8) & 0xf) * 10) + ((__SUNPRO_CC >> 4) & 0xf), (__SUNPRO_CC & 0xf) * 10) +#elif defined(__SUNPRO_CC) + #define HEDLEY_SUNPRO_VERSION HEDLEY_VERSION_ENCODE((__SUNPRO_CC >> 8) & 0xf, (__SUNPRO_CC >> 4) & 0xf, (__SUNPRO_CC) & 0xf) +#endif + +#if defined(HEDLEY_SUNPRO_VERSION_CHECK) + #undef HEDLEY_SUNPRO_VERSION_CHECK +#endif +#if defined(HEDLEY_SUNPRO_VERSION) + #define HEDLEY_SUNPRO_VERSION_CHECK(major,minor,patch) (HEDLEY_SUNPRO_VERSION >= HEDLEY_VERSION_ENCODE(major, minor, patch)) +#else + #define HEDLEY_SUNPRO_VERSION_CHECK(major,minor,patch) (0) +#endif + +#if defined(HEDLEY_EMSCRIPTEN_VERSION) + #undef HEDLEY_EMSCRIPTEN_VERSION +#endif +#if defined(__EMSCRIPTEN__) + #define HEDLEY_EMSCRIPTEN_VERSION HEDLEY_VERSION_ENCODE(__EMSCRIPTEN_major__, __EMSCRIPTEN_minor__, __EMSCRIPTEN_tiny__) +#endif + +#if defined(HEDLEY_EMSCRIPTEN_VERSION_CHECK) + #undef HEDLEY_EMSCRIPTEN_VERSION_CHECK +#endif +#if defined(HEDLEY_EMSCRIPTEN_VERSION) + #define HEDLEY_EMSCRIPTEN_VERSION_CHECK(major,minor,patch) (HEDLEY_EMSCRIPTEN_VERSION >= HEDLEY_VERSION_ENCODE(major, minor, patch)) +#else + #define HEDLEY_EMSCRIPTEN_VERSION_CHECK(major,minor,patch) (0) +#endif + +#if defined(HEDLEY_ARM_VERSION) + #undef HEDLEY_ARM_VERSION +#endif +#if defined(__CC_ARM) && defined(__ARMCOMPILER_VERSION) + #define HEDLEY_ARM_VERSION HEDLEY_VERSION_ENCODE(__ARMCOMPILER_VERSION / 1000000, (__ARMCOMPILER_VERSION % 1000000) / 10000, (__ARMCOMPILER_VERSION % 10000) / 100) +#elif defined(__CC_ARM) && defined(__ARMCC_VERSION) + #define HEDLEY_ARM_VERSION HEDLEY_VERSION_ENCODE(__ARMCC_VERSION / 1000000, (__ARMCC_VERSION % 1000000) / 10000, (__ARMCC_VERSION % 10000) / 100) +#endif + +#if defined(HEDLEY_ARM_VERSION_CHECK) + #undef HEDLEY_ARM_VERSION_CHECK +#endif +#if defined(HEDLEY_ARM_VERSION) + #define HEDLEY_ARM_VERSION_CHECK(major,minor,patch) (HEDLEY_ARM_VERSION >= HEDLEY_VERSION_ENCODE(major, minor, patch)) +#else + #define HEDLEY_ARM_VERSION_CHECK(major,minor,patch) (0) +#endif + +#if defined(HEDLEY_IBM_VERSION) + #undef HEDLEY_IBM_VERSION +#endif +#if defined(__ibmxl__) + #define HEDLEY_IBM_VERSION HEDLEY_VERSION_ENCODE(__ibmxl_version__, __ibmxl_release__, __ibmxl_modification__) +#elif defined(__xlC__) && defined(__xlC_ver__) + #define HEDLEY_IBM_VERSION HEDLEY_VERSION_ENCODE(__xlC__ >> 8, __xlC__ & 0xff, (__xlC_ver__ >> 8) & 0xff) +#elif defined(__xlC__) + #define HEDLEY_IBM_VERSION HEDLEY_VERSION_ENCODE(__xlC__ >> 8, __xlC__ & 0xff, 0) +#endif + +#if defined(HEDLEY_IBM_VERSION_CHECK) + #undef HEDLEY_IBM_VERSION_CHECK +#endif +#if defined(HEDLEY_IBM_VERSION) + #define HEDLEY_IBM_VERSION_CHECK(major,minor,patch) (HEDLEY_IBM_VERSION >= HEDLEY_VERSION_ENCODE(major, minor, patch)) +#else + #define HEDLEY_IBM_VERSION_CHECK(major,minor,patch) (0) +#endif + +#if defined(HEDLEY_TI_VERSION) + #undef HEDLEY_TI_VERSION +#endif +#if defined(__TI_COMPILER_VERSION__) + #define HEDLEY_TI_VERSION HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000)) +#endif + +#if defined(HEDLEY_TI_VERSION_CHECK) + #undef HEDLEY_TI_VERSION_CHECK +#endif +#if defined(HEDLEY_TI_VERSION) + #define HEDLEY_TI_VERSION_CHECK(major,minor,patch) (HEDLEY_TI_VERSION >= HEDLEY_VERSION_ENCODE(major, minor, patch)) +#else + #define HEDLEY_TI_VERSION_CHECK(major,minor,patch) (0) +#endif + +#if defined(HEDLEY_CRAY_VERSION) + #undef HEDLEY_CRAY_VERSION +#endif +#if defined(_CRAYC) + #if defined(_RELEASE_PATCHLEVEL) + #define HEDLEY_CRAY_VERSION HEDLEY_VERSION_ENCODE(_RELEASE_MAJOR, _RELEASE_MINOR, _RELEASE_PATCHLEVEL) + #else + #define HEDLEY_CRAY_VERSION HEDLEY_VERSION_ENCODE(_RELEASE_MAJOR, _RELEASE_MINOR, 0) + #endif +#endif + +#if defined(HEDLEY_CRAY_VERSION_CHECK) + #undef HEDLEY_CRAY_VERSION_CHECK +#endif +#if defined(HEDLEY_CRAY_VERSION) + #define HEDLEY_CRAY_VERSION_CHECK(major,minor,patch) (HEDLEY_CRAY_VERSION >= HEDLEY_VERSION_ENCODE(major, minor, patch)) +#else + #define HEDLEY_CRAY_VERSION_CHECK(major,minor,patch) (0) +#endif + +#if defined(HEDLEY_IAR_VERSION) + #undef HEDLEY_IAR_VERSION +#endif +#if defined(__IAR_SYSTEMS_ICC__) + #if __VER__ > 1000 + #define HEDLEY_IAR_VERSION HEDLEY_VERSION_ENCODE((__VER__ / 1000000), ((__VER__ / 1000) % 1000), (__VER__ % 1000)) + #else + #define HEDLEY_IAR_VERSION HEDLEY_VERSION_ENCODE(VER / 100, __VER__ % 100, 0) + #endif +#endif + +#if defined(HEDLEY_IAR_VERSION_CHECK) + #undef HEDLEY_IAR_VERSION_CHECK +#endif +#if defined(HEDLEY_IAR_VERSION) + #define HEDLEY_IAR_VERSION_CHECK(major,minor,patch) (HEDLEY_IAR_VERSION >= HEDLEY_VERSION_ENCODE(major, minor, patch)) +#else + #define HEDLEY_IAR_VERSION_CHECK(major,minor,patch) (0) +#endif + +#if defined(HEDLEY_TINYC_VERSION) + #undef HEDLEY_TINYC_VERSION +#endif +#if defined(__TINYC__) + #define HEDLEY_TINYC_VERSION HEDLEY_VERSION_ENCODE(__TINYC__ / 1000, (__TINYC__ / 100) % 10, __TINYC__ % 100) +#endif + +#if defined(HEDLEY_TINYC_VERSION_CHECK) + #undef HEDLEY_TINYC_VERSION_CHECK +#endif +#if defined(HEDLEY_TINYC_VERSION) + #define HEDLEY_TINYC_VERSION_CHECK(major,minor,patch) (HEDLEY_TINYC_VERSION >= HEDLEY_VERSION_ENCODE(major, minor, patch)) +#else + #define HEDLEY_TINYC_VERSION_CHECK(major,minor,patch) (0) +#endif + +#if defined(HEDLEY_DMC_VERSION) + #undef HEDLEY_DMC_VERSION +#endif +#if defined(__DMC__) + #define HEDLEY_DMC_VERSION HEDLEY_VERSION_ENCODE(__DMC__ >> 8, (__DMC__ >> 4) & 0xf, __DMC__ & 0xf) +#endif + +#if defined(HEDLEY_DMC_VERSION_CHECK) + #undef HEDLEY_DMC_VERSION_CHECK +#endif +#if defined(HEDLEY_DMC_VERSION) + #define HEDLEY_DMC_VERSION_CHECK(major,minor,patch) (HEDLEY_DMC_VERSION >= HEDLEY_VERSION_ENCODE(major, minor, patch)) +#else + #define HEDLEY_DMC_VERSION_CHECK(major,minor,patch) (0) +#endif + +#if defined(HEDLEY_COMPCERT_VERSION) + #undef HEDLEY_COMPCERT_VERSION +#endif +#if defined(__COMPCERT_VERSION__) + #define HEDLEY_COMPCERT_VERSION HEDLEY_VERSION_ENCODE(__COMPCERT_VERSION__ / 10000, (__COMPCERT_VERSION__ / 100) % 100, __COMPCERT_VERSION__ % 100) +#endif + +#if defined(HEDLEY_COMPCERT_VERSION_CHECK) + #undef HEDLEY_COMPCERT_VERSION_CHECK +#endif +#if defined(HEDLEY_COMPCERT_VERSION) + #define HEDLEY_COMPCERT_VERSION_CHECK(major,minor,patch) (HEDLEY_COMPCERT_VERSION >= HEDLEY_VERSION_ENCODE(major, minor, patch)) +#else + #define HEDLEY_COMPCERT_VERSION_CHECK(major,minor,patch) (0) +#endif + +#if defined(HEDLEY_PELLES_VERSION) + #undef HEDLEY_PELLES_VERSION +#endif +#if defined(__POCC__) + #define HEDLEY_PELLES_VERSION HEDLEY_VERSION_ENCODE(__POCC__ / 100, __POCC__ % 100, 0) +#endif + +#if defined(HEDLEY_PELLES_VERSION_CHECK) + #undef HEDLEY_PELLES_VERSION_CHECK +#endif +#if defined(HEDLEY_PELLES_VERSION) + #define HEDLEY_PELLES_VERSION_CHECK(major,minor,patch) (HEDLEY_PELLES_VERSION >= HEDLEY_VERSION_ENCODE(major, minor, patch)) +#else + #define HEDLEY_PELLES_VERSION_CHECK(major,minor,patch) (0) +#endif + +#if defined(HEDLEY_GCC_VERSION) + #undef HEDLEY_GCC_VERSION +#endif +#if \ + defined(HEDLEY_GNUC_VERSION) && \ + !defined(__clang__) && \ + !defined(HEDLEY_INTEL_VERSION) && \ + !defined(HEDLEY_PGI_VERSION) && \ + !defined(HEDLEY_ARM_VERSION) && \ + !defined(HEDLEY_TI_VERSION) && \ + !defined(__COMPCERT__) + #define HEDLEY_GCC_VERSION HEDLEY_GNUC_VERSION +#endif + +#if defined(HEDLEY_GCC_VERSION_CHECK) + #undef HEDLEY_GCC_VERSION_CHECK +#endif +#if defined(HEDLEY_GCC_VERSION) + #define HEDLEY_GCC_VERSION_CHECK(major,minor,patch) (HEDLEY_GCC_VERSION >= HEDLEY_VERSION_ENCODE(major, minor, patch)) +#else + #define HEDLEY_GCC_VERSION_CHECK(major,minor,patch) (0) +#endif + +#if defined(HEDLEY_HAS_ATTRIBUTE) + #undef HEDLEY_HAS_ATTRIBUTE +#endif +#if defined(__has_attribute) + #define HEDLEY_HAS_ATTRIBUTE(attribute) __has_attribute(attribute) +#else + #define HEDLEY_HAS_ATTRIBUTE(attribute) (0) +#endif + +#if defined(HEDLEY_GNUC_HAS_ATTRIBUTE) + #undef HEDLEY_GNUC_HAS_ATTRIBUTE +#endif +#if defined(__has_attribute) + #define HEDLEY_GNUC_HAS_ATTRIBUTE(attribute,major,minor,patch) __has_attribute(attribute) +#else + #define HEDLEY_GNUC_HAS_ATTRIBUTE(attribute,major,minor,patch) HEDLEY_GNUC_VERSION_CHECK(major,minor,patch) +#endif + +#if defined(HEDLEY_GCC_HAS_ATTRIBUTE) + #undef HEDLEY_GCC_HAS_ATTRIBUTE +#endif +#if defined(__has_attribute) + #define HEDLEY_GCC_HAS_ATTRIBUTE(attribute,major,minor,patch) __has_attribute(attribute) +#else + #define HEDLEY_GCC_HAS_ATTRIBUTE(attribute,major,minor,patch) HEDLEY_GCC_VERSION_CHECK(major,minor,patch) +#endif + +#if defined(HEDLEY_HAS_CPP_ATTRIBUTE) + #undef HEDLEY_HAS_CPP_ATTRIBUTE +#endif +#if defined(__has_cpp_attribute) && defined(__cplusplus) + #define HEDLEY_HAS_CPP_ATTRIBUTE(attribute) __has_cpp_attribute(attribute) +#else + #define HEDLEY_HAS_CPP_ATTRIBUTE(attribute) (0) +#endif + +#if defined(HEDLEY_GNUC_HAS_CPP_ATTRIBUTE) + #undef HEDLEY_GNUC_HAS_CPP_ATTRIBUTE +#endif +#if defined(__has_cpp_attribute) && defined(__cplusplus) + #define HEDLEY_GNUC_HAS_CPP_ATTRIBUTE(attribute,major,minor,patch) __has_cpp_attribute(attribute) +#else + #define HEDLEY_GNUC_HAS_CPP_ATTRIBUTE(attribute,major,minor,patch) HEDLEY_GNUC_VERSION_CHECK(major,minor,patch) +#endif + +#if defined(HEDLEY_GCC_HAS_CPP_ATTRIBUTE) + #undef HEDLEY_GCC_HAS_CPP_ATTRIBUTE +#endif +#if defined(__has_cpp_attribute) && defined(__cplusplus) + #define HEDLEY_GCC_HAS_CPP_ATTRIBUTE(attribute,major,minor,patch) __has_cpp_attribute(attribute) +#else + #define HEDLEY_GCC_HAS_CPP_ATTRIBUTE(attribute,major,minor,patch) HEDLEY_GCC_VERSION_CHECK(major,minor,patch) +#endif + +#if defined(HEDLEY_HAS_BUILTIN) + #undef HEDLEY_HAS_BUILTIN +#endif +#if defined(__has_builtin) + #define HEDLEY_HAS_BUILTIN(builtin) __has_builtin(builtin) +#else + #define HEDLEY_HAS_BUILTIN(builtin) (0) +#endif + +#if defined(HEDLEY_GNUC_HAS_BUILTIN) + #undef HEDLEY_GNUC_HAS_BUILTIN +#endif +#if defined(__has_builtin) + #define HEDLEY_GNUC_HAS_BUILTIN(builtin,major,minor,patch) __has_builtin(builtin) +#else + #define HEDLEY_GNUC_HAS_BUILTIN(builtin,major,minor,patch) HEDLEY_GNUC_VERSION_CHECK(major,minor,patch) +#endif + +#if defined(HEDLEY_GCC_HAS_BUILTIN) + #undef HEDLEY_GCC_HAS_BUILTIN +#endif +#if defined(__has_builtin) + #define HEDLEY_GCC_HAS_BUILTIN(builtin,major,minor,patch) __has_builtin(builtin) +#else + #define HEDLEY_GCC_HAS_BUILTIN(builtin,major,minor,patch) HEDLEY_GCC_VERSION_CHECK(major,minor,patch) +#endif + +#if defined(HEDLEY_HAS_FEATURE) + #undef HEDLEY_HAS_FEATURE +#endif +#if defined(__has_feature) + #define HEDLEY_HAS_FEATURE(feature) __has_feature(feature) +#else + #define HEDLEY_HAS_FEATURE(feature) (0) +#endif + +#if defined(HEDLEY_GNUC_HAS_FEATURE) + #undef HEDLEY_GNUC_HAS_FEATURE +#endif +#if defined(__has_feature) + #define HEDLEY_GNUC_HAS_FEATURE(feature,major,minor,patch) __has_feature(feature) +#else + #define HEDLEY_GNUC_HAS_FEATURE(feature,major,minor,patch) HEDLEY_GNUC_VERSION_CHECK(major,minor,patch) +#endif + +#if defined(HEDLEY_GCC_HAS_FEATURE) + #undef HEDLEY_GCC_HAS_FEATURE +#endif +#if defined(__has_feature) + #define HEDLEY_GCC_HAS_FEATURE(feature,major,minor,patch) __has_feature(feature) +#else + #define HEDLEY_GCC_HAS_FEATURE(feature,major,minor,patch) HEDLEY_GCC_VERSION_CHECK(major,minor,patch) +#endif + +#if defined(HEDLEY_HAS_EXTENSION) + #undef HEDLEY_HAS_EXTENSION +#endif +#if defined(__has_extension) + #define HEDLEY_HAS_EXTENSION(extension) __has_extension(extension) +#else + #define HEDLEY_HAS_EXTENSION(extension) (0) +#endif + +#if defined(HEDLEY_GNUC_HAS_EXTENSION) + #undef HEDLEY_GNUC_HAS_EXTENSION +#endif +#if defined(__has_extension) + #define HEDLEY_GNUC_HAS_EXTENSION(extension,major,minor,patch) __has_extension(extension) +#else + #define HEDLEY_GNUC_HAS_EXTENSION(extension,major,minor,patch) HEDLEY_GNUC_VERSION_CHECK(major,minor,patch) +#endif + +#if defined(HEDLEY_GCC_HAS_EXTENSION) + #undef HEDLEY_GCC_HAS_EXTENSION +#endif +#if defined(__has_extension) + #define HEDLEY_GCC_HAS_EXTENSION(extension,major,minor,patch) __has_extension(extension) +#else + #define HEDLEY_GCC_HAS_EXTENSION(extension,major,minor,patch) HEDLEY_GCC_VERSION_CHECK(major,minor,patch) +#endif + +#if defined(HEDLEY_HAS_DECLSPEC_ATTRIBUTE) + #undef HEDLEY_HAS_DECLSPEC_ATTRIBUTE +#endif +#if defined(__has_declspec_attribute) + #define HEDLEY_HAS_DECLSPEC_ATTRIBUTE(attribute) __has_declspec_attribute(attribute) +#else + #define HEDLEY_HAS_DECLSPEC_ATTRIBUTE(attribute) (0) +#endif + +#if defined(HEDLEY_GNUC_HAS_DECLSPEC_ATTRIBUTE) + #undef HEDLEY_GNUC_HAS_DECLSPEC_ATTRIBUTE +#endif +#if defined(__has_declspec_attribute) + #define HEDLEY_GNUC_HAS_DECLSPEC_ATTRIBUTE(attribute,major,minor,patch) __has_declspec_attribute(attribute) +#else + #define HEDLEY_GNUC_HAS_DECLSPEC_ATTRIBUTE(attribute,major,minor,patch) HEDLEY_GNUC_VERSION_CHECK(major,minor,patch) +#endif + +#if defined(HEDLEY_GCC_HAS_DECLSPEC_ATTRIBUTE) + #undef HEDLEY_GCC_HAS_DECLSPEC_ATTRIBUTE +#endif +#if defined(__has_declspec_attribute) + #define HEDLEY_GCC_HAS_DECLSPEC_ATTRIBUTE(attribute,major,minor,patch) __has_declspec_attribute(attribute) +#else + #define HEDLEY_GCC_HAS_DECLSPEC_ATTRIBUTE(attribute,major,minor,patch) HEDLEY_GCC_VERSION_CHECK(major,minor,patch) +#endif + +#if defined(HEDLEY_HAS_WARNING) + #undef HEDLEY_HAS_WARNING +#endif +#if defined(__has_warning) + #define HEDLEY_HAS_WARNING(warning) __has_warning(warning) +#else + #define HEDLEY_HAS_WARNING(warning) (0) +#endif + +#if defined(HEDLEY_GNUC_HAS_WARNING) + #undef HEDLEY_GNUC_HAS_WARNING +#endif +#if defined(__has_warning) + #define HEDLEY_GNUC_HAS_WARNING(warning,major,minor,patch) __has_warning(warning) +#else + #define HEDLEY_GNUC_HAS_WARNING(warning,major,minor,patch) HEDLEY_GNUC_VERSION_CHECK(major,minor,patch) +#endif + +#if defined(HEDLEY_GCC_HAS_WARNING) + #undef HEDLEY_GCC_HAS_WARNING +#endif +#if defined(__has_warning) + #define HEDLEY_GCC_HAS_WARNING(warning,major,minor,patch) __has_warning(warning) +#else + #define HEDLEY_GCC_HAS_WARNING(warning,major,minor,patch) HEDLEY_GCC_VERSION_CHECK(major,minor,patch) +#endif + +#if \ + (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)) || \ + defined(__clang__) || \ + HEDLEY_GCC_VERSION_CHECK(3,0,0) || \ + HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ + HEDLEY_IAR_VERSION_CHECK(8,0,0) || \ + HEDLEY_PGI_VERSION_CHECK(18,4,0) || \ + HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ + HEDLEY_TI_VERSION_CHECK(6,0,0) || \ + HEDLEY_CRAY_VERSION_CHECK(5,0,0) || \ + HEDLEY_TINYC_VERSION_CHECK(0,9,17) || \ + HEDLEY_SUNPRO_VERSION_CHECK(8,0,0) || \ + (HEDLEY_IBM_VERSION_CHECK(10,1,0) && defined(__C99_PRAGMA_OPERATOR)) + #define HEDLEY_PRAGMA(value) _Pragma(#value) +#elif HEDLEY_MSVC_VERSION_CHECK(15,0,0) + #define HEDLEY_PRAGMA(value) __pragma(value) +#else + #define HEDLEY_PRAGMA(value) +#endif + +#if defined(HEDLEY_DIAGNOSTIC_PUSH) + #undef HEDLEY_DIAGNOSTIC_PUSH +#endif +#if defined(HEDLEY_DIAGNOSTIC_POP) + #undef HEDLEY_DIAGNOSTIC_POP +#endif +#if defined(__clang__) + #define HEDLEY_DIAGNOSTIC_PUSH _Pragma("clang diagnostic push") + #define HEDLEY_DIAGNOSTIC_POP _Pragma("clang diagnostic pop") +#elif HEDLEY_INTEL_VERSION_CHECK(13,0,0) + #define HEDLEY_DIAGNOSTIC_PUSH _Pragma("warning(push)") + #define HEDLEY_DIAGNOSTIC_POP _Pragma("warning(pop)") +#elif HEDLEY_GCC_VERSION_CHECK(4,6,0) + #define HEDLEY_DIAGNOSTIC_PUSH _Pragma("GCC diagnostic push") + #define HEDLEY_DIAGNOSTIC_POP _Pragma("GCC diagnostic pop") +#elif HEDLEY_MSVC_VERSION_CHECK(15,0,0) + #define HEDLEY_DIAGNOSTIC_PUSH __pragma(warning(push)) + #define HEDLEY_DIAGNOSTIC_POP __pragma(warning(pop)) +#elif HEDLEY_ARM_VERSION_CHECK(5,6,0) + #define HEDLEY_DIAGNOSTIC_PUSH _Pragma("push") + #define HEDLEY_DIAGNOSTIC_POP _Pragma("pop") +#elif HEDLEY_TI_VERSION_CHECK(8,1,0) + #define HEDLEY_DIAGNOSTIC_PUSH _Pragma("diag_push") + #define HEDLEY_DIAGNOSTIC_POP _Pragma("diag_pop") +#elif HEDLEY_PELLES_VERSION_CHECK(2,90,0) + #define HEDLEY_DIAGNOSTIC_PUSH _Pragma("warning(push)") + #define HEDLEY_DIAGNOSTIC_POP _Pragma("warning(pop)") +#else + #define HEDLEY_DIAGNOSTIC_PUSH + #define HEDLEY_DIAGNOSTIC_POP +#endif + +#if defined(HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED) + #undef HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED +#endif +#if HEDLEY_HAS_WARNING("-Wdeprecated-declarations") + #define HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("clang diagnostic ignored \"-Wdeprecated-declarations\"") +#elif HEDLEY_INTEL_VERSION_CHECK(13,0,0) + #define HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("warning(disable:1478 1786)") +#elif HEDLEY_PGI_VERSION_CHECK(17,10,0) + #define HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("diag_suppress 1215,1444") +#elif HEDLEY_GCC_VERSION_CHECK(4,3,0) + #define HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"") +#elif HEDLEY_MSVC_VERSION_CHECK(15,0,0) + #define HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED __pragma(warning(disable:4996)) +#elif HEDLEY_TI_VERSION_CHECK(8,0,0) + #define HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("diag_suppress 1291,1718") +#elif HEDLEY_SUNPRO_VERSION_CHECK(5,13,0) && !defined(__cplusplus) + #define HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("error_messages(off,E_DEPRECATED_ATT,E_DEPRECATED_ATT_MESS)") +#elif HEDLEY_SUNPRO_VERSION_CHECK(5,13,0) && defined(__cplusplus) + #define HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("error_messages(off,symdeprecated,symdeprecated2)") +#elif HEDLEY_IAR_VERSION_CHECK(8,0,0) + #define HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("diag_suppress=Pe1444,Pe1215") +#elif HEDLEY_PELLES_VERSION_CHECK(2,90,0) + #define HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("warn(disable:2241)") +#else + #define HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED +#endif + +#if defined(HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS) + #undef HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS +#endif +#if HEDLEY_HAS_WARNING("-Wunknown-pragmas") + #define HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("clang diagnostic ignored \"-Wunknown-pragmas\"") +#elif HEDLEY_INTEL_VERSION_CHECK(13,0,0) + #define HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("warning(disable:161)") +#elif HEDLEY_PGI_VERSION_CHECK(17,10,0) + #define HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("diag_suppress 1675") +#elif HEDLEY_GCC_VERSION_CHECK(4,3,0) + #define HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("GCC diagnostic ignored \"-Wunknown-pragmas\"") +#elif HEDLEY_MSVC_VERSION_CHECK(15,0,0) + #define HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS __pragma(warning(disable:4068)) +#elif HEDLEY_TI_VERSION_CHECK(8,0,0) + #define HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("diag_suppress 163") +#elif HEDLEY_IAR_VERSION_CHECK(8,0,0) + #define HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("diag_suppress=Pe161") +#else + #define HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS +#endif + +#if defined(HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL) + #undef HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL +#endif +#if HEDLEY_HAS_WARNING("-Wcast-qual") + #define HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL _Pragma("clang diagnostic ignored \"-Wcast-qual\"") +#elif HEDLEY_INTEL_VERSION_CHECK(13,0,0) + #define HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL _Pragma("warning(disable:2203 2331)") +#elif HEDLEY_GCC_VERSION_CHECK(3,0,0) + #define HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL _Pragma("GCC diagnostic ignored \"-Wcast-qual\"") +#else + #define HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL +#endif + +#if defined(HEDLEY_DEPRECATED) + #undef HEDLEY_DEPRECATED +#endif +#if defined(HEDLEY_DEPRECATED_FOR) + #undef HEDLEY_DEPRECATED_FOR +#endif +#if defined(__cplusplus) && (__cplusplus >= 201402L) + #define HEDLEY_DEPRECATED(since) [[deprecated("Since " #since)]] + #define HEDLEY_DEPRECATED_FOR(since, replacement) [[deprecated("Since " #since "; use " #replacement)]] +#elif \ + HEDLEY_HAS_EXTENSION(attribute_deprecated_with_message) || \ + HEDLEY_GCC_VERSION_CHECK(4,5,0) || \ + HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ + HEDLEY_ARM_VERSION_CHECK(5,6,0) || \ + HEDLEY_SUNPRO_VERSION_CHECK(5,13,0) || \ + HEDLEY_PGI_VERSION_CHECK(17,10,0) || \ + HEDLEY_TI_VERSION_CHECK(8,3,0) + #define HEDLEY_DEPRECATED(since) __attribute__((__deprecated__("Since " #since))) + #define HEDLEY_DEPRECATED_FOR(since, replacement) __attribute__((__deprecated__("Since " #since "; use " #replacement))) +#elif \ + HEDLEY_HAS_ATTRIBUTE(deprecated) || \ + HEDLEY_GCC_VERSION_CHECK(3,1,0) || \ + HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ + HEDLEY_TI_VERSION_CHECK(8,0,0) || \ + (HEDLEY_TI_VERSION_CHECK(7,3,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) + #define HEDLEY_DEPRECATED(since) __attribute__((__deprecated__)) + #define HEDLEY_DEPRECATED_FOR(since, replacement) __attribute__((__deprecated__)) +#elif HEDLEY_MSVC_VERSION_CHECK(14,0,0) + #define HEDLEY_DEPRECATED(since) __declspec(deprecated("Since " # since)) + #define HEDLEY_DEPRECATED_FOR(since, replacement) __declspec(deprecated("Since " #since "; use " #replacement)) +#elif \ + HEDLEY_MSVC_VERSION_CHECK(13,10,0) || \ + HEDLEY_PELLES_VERSION_CHECK(6,50,0) + #define HEDLEY_DEPRECATED(since) _declspec(deprecated) + #define HEDLEY_DEPRECATED_FOR(since, replacement) __declspec(deprecated) +#elif HEDLEY_IAR_VERSION_CHECK(8,0,0) + #define HEDLEY_DEPRECATED(since) _Pragma("deprecated") + #define HEDLEY_DEPRECATED_FOR(since, replacement) _Pragma("deprecated") +#else + #define HEDLEY_DEPRECATED(since) + #define HEDLEY_DEPRECATED_FOR(since, replacement) +#endif + +#if defined(HEDLEY_UNAVAILABLE) + #undef HEDLEY_UNAVAILABLE +#endif +#if \ + HEDLEY_HAS_ATTRIBUTE(warning) || \ + HEDLEY_GCC_VERSION_CHECK(4,3,0) || \ + HEDLEY_INTEL_VERSION_CHECK(13,0,0) + #define HEDLEY_UNAVAILABLE(available_since) __attribute__((__warning__("Not available until " #available_since))) +#else + #define HEDLEY_UNAVAILABLE(available_since) +#endif + +#if defined(HEDLEY_WARN_UNUSED_RESULT) + #undef HEDLEY_WARN_UNUSED_RESULT +#endif +#if defined(__cplusplus) && (__cplusplus >= 201703L) + #define HEDLEY_WARN_UNUSED_RESULT [[nodiscard]] +#elif \ + HEDLEY_HAS_ATTRIBUTE(warn_unused_result) || \ + HEDLEY_GCC_VERSION_CHECK(3,4,0) || \ + HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ + HEDLEY_TI_VERSION_CHECK(8,0,0) || \ + (HEDLEY_TI_VERSION_CHECK(7,3,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ + (HEDLEY_SUNPRO_VERSION_CHECK(5,15,0) && defined(__cplusplus)) || \ + HEDLEY_PGI_VERSION_CHECK(17,10,0) + #define HEDLEY_WARN_UNUSED_RESULT __attribute__((__warn_unused_result__)) +#elif defined(_Check_return_) /* SAL */ + #define HEDLEY_WARN_UNUSED_RESULT _Check_return_ +#else + #define HEDLEY_WARN_UNUSED_RESULT +#endif + +#if defined(HEDLEY_SENTINEL) + #undef HEDLEY_SENTINEL +#endif +#if \ + HEDLEY_HAS_ATTRIBUTE(sentinel) || \ + HEDLEY_GCC_VERSION_CHECK(4,0,0) || \ + HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ + HEDLEY_ARM_VERSION_CHECK(5,4,0) + #define HEDLEY_SENTINEL(position) __attribute__((__sentinel__(position))) +#else + #define HEDLEY_SENTINEL(position) +#endif + +#if defined(HEDLEY_NO_RETURN) + #undef HEDLEY_NO_RETURN +#endif +#if HEDLEY_IAR_VERSION_CHECK(8,0,0) + #define HEDLEY_NO_RETURN __noreturn +#elif HEDLEY_INTEL_VERSION_CHECK(13,0,0) + #define HEDLEY_NO_RETURN __attribute__((__noreturn__)) +#elif defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L + #define HEDLEY_NO_RETURN _Noreturn +#elif defined(__cplusplus) && (__cplusplus >= 201103L) + #define HEDLEY_NO_RETURN [[noreturn]] +#elif \ + HEDLEY_HAS_ATTRIBUTE(noreturn) || \ + HEDLEY_GCC_VERSION_CHECK(3,2,0) || \ + HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \ + HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ + HEDLEY_IBM_VERSION_CHECK(10,1,0) || \ + HEDLEY_TI_VERSION_CHECK(18,0,0) || \ + (HEDLEY_TI_VERSION_CHECK(17,3,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) + #define HEDLEY_NO_RETURN __attribute__((__noreturn__)) +#elif HEDLEY_MSVC_VERSION_CHECK(13,10,0) + #define HEDLEY_NO_RETURN __declspec(noreturn) +#elif HEDLEY_TI_VERSION_CHECK(6,0,0) && defined(__cplusplus) + #define HEDLEY_NO_RETURN _Pragma("FUNC_NEVER_RETURNS;") +#elif HEDLEY_COMPCERT_VERSION_CHECK(3,2,0) + #define HEDLEY_NO_RETURN __attribute((noreturn)) +#elif HEDLEY_PELLES_VERSION_CHECK(9,0,0) + #define HEDLEY_NO_RETURN __declspec(noreturn) +#else + #define HEDLEY_NO_RETURN +#endif + +#if defined(HEDLEY_UNREACHABLE) + #undef HEDLEY_UNREACHABLE +#endif +#if defined(HEDLEY_UNREACHABLE_RETURN) + #undef HEDLEY_UNREACHABLE_RETURN +#endif +#if \ + (HEDLEY_HAS_BUILTIN(__builtin_unreachable) && (!defined(HEDLEY_ARM_VERSION))) || \ + HEDLEY_GCC_VERSION_CHECK(4,5,0) || \ + HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ + HEDLEY_IBM_VERSION_CHECK(13,1,5) + #define HEDLEY_UNREACHABLE() __builtin_unreachable() +#elif HEDLEY_MSVC_VERSION_CHECK(13,10,0) + #define HEDLEY_UNREACHABLE() __assume(0) +#elif HEDLEY_TI_VERSION_CHECK(6,0,0) + #if defined(__cplusplus) + #define HEDLEY_UNREACHABLE() std::_nassert(0) + #else + #define HEDLEY_UNREACHABLE() _nassert(0) + #endif + #define HEDLEY_UNREACHABLE_RETURN(value) return value +#elif defined(EXIT_FAILURE) + #define HEDLEY_UNREACHABLE() abort() +#else + #define HEDLEY_UNREACHABLE() + #define HEDLEY_UNREACHABLE_RETURN(value) return value +#endif +#if !defined(HEDLEY_UNREACHABLE_RETURN) + #define HEDLEY_UNREACHABLE_RETURN(value) HEDLEY_UNREACHABLE() +#endif + +#if defined(HEDLEY_ASSUME) + #undef HEDLEY_ASSUME +#endif +#if \ + HEDLEY_MSVC_VERSION_CHECK(13,10,0) || \ + HEDLEY_INTEL_VERSION_CHECK(13,0,0) + #define HEDLEY_ASSUME(expr) __assume(expr) +#elif HEDLEY_HAS_BUILTIN(__builtin_assume) + #define HEDLEY_ASSUME(expr) __builtin_assume(expr) +#elif HEDLEY_TI_VERSION_CHECK(6,0,0) + #if defined(__cplusplus) + #define HEDLEY_ASSUME(expr) std::_nassert(expr) + #else + #define HEDLEY_ASSUME(expr) _nassert(expr) + #endif +#elif \ + (HEDLEY_HAS_BUILTIN(__builtin_unreachable) && !defined(HEDLEY_ARM_VERSION)) || \ + HEDLEY_GCC_VERSION_CHECK(4,5,0) || \ + HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ + HEDLEY_IBM_VERSION_CHECK(13,1,5) + #define HEDLEY_ASSUME(expr) ((void) ((expr) ? 1 : (__builtin_unreachable(), 1))) +#else + #define HEDLEY_ASSUME(expr) ((void) (expr)) +#endif + + +HEDLEY_DIAGNOSTIC_PUSH +#if \ + HEDLEY_HAS_WARNING("-Wvariadic-macros") || \ + HEDLEY_GCC_VERSION_CHECK(4,0,0) + #if defined(__clang__) + #pragma clang diagnostic ignored "-Wvariadic-macros" + #elif defined(HEDLEY_GCC_VERSION) + #pragma GCC diagnostic ignored "-Wvariadic-macros" + #endif +#endif +#if defined(HEDLEY_NON_NULL) + #undef HEDLEY_NON_NULL +#endif +#if \ + HEDLEY_HAS_ATTRIBUTE(nonnull) || \ + HEDLEY_GCC_VERSION_CHECK(3,3,0) || \ + HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ + HEDLEY_ARM_VERSION_CHECK(4,1,0) + #define HEDLEY_NON_NULL(...) __attribute__((__nonnull__(__VA_ARGS__))) +#else + #define HEDLEY_NON_NULL(...) +#endif +HEDLEY_DIAGNOSTIC_POP + +#if defined(HEDLEY_PRINTF_FORMAT) + #undef HEDLEY_PRINTF_FORMAT +#endif +#if defined(__MINGW32__) && HEDLEY_GCC_HAS_ATTRIBUTE(format,4,4,0) && !defined(__USE_MINGW_ANSI_STDIO) + #define HEDLEY_PRINTF_FORMAT(string_idx,first_to_check) __attribute__((__format__(ms_printf, string_idx, first_to_check))) +#elif defined(__MINGW32__) && HEDLEY_GCC_HAS_ATTRIBUTE(format,4,4,0) && defined(__USE_MINGW_ANSI_STDIO) + #define HEDLEY_PRINTF_FORMAT(string_idx,first_to_check) __attribute__((__format__(gnu_printf, string_idx, first_to_check))) +#elif \ + HEDLEY_HAS_ATTRIBUTE(format) || \ + HEDLEY_GCC_VERSION_CHECK(3,1,0) || \ + HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ + HEDLEY_ARM_VERSION_CHECK(5,6,0) || \ + HEDLEY_IBM_VERSION_CHECK(10,1,0) || \ + HEDLEY_TI_VERSION_CHECK(8,0,0) || \ + (HEDLEY_TI_VERSION_CHECK(7,3,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) + #define HEDLEY_PRINTF_FORMAT(string_idx,first_to_check) __attribute__((__format__(__printf__, string_idx, first_to_check))) +#elif HEDLEY_PELLES_VERSION_CHECK(6,0,0) + #define HEDLEY_PRINTF_FORMAT(string_idx,first_to_check) __declspec(vaformat(printf,string_idx,first_to_check)) +#else + #define HEDLEY_PRINTF_FORMAT(string_idx,first_to_check) +#endif + +#if defined(HEDLEY_CONSTEXPR) + #undef HEDLEY_CONSTEXPR +#endif +#if defined(__cplusplus) + #if __cplusplus >= 201103L + #define HEDLEY_CONSTEXPR constexpr + #endif +#endif +#if !defined(HEDLEY_CONSTEXPR) + #define HEDLEY_CONSTEXPR +#endif + +#if defined(HEDLEY_PREDICT) + #undef HEDLEY_PREDICT +#endif +#if defined(HEDLEY_LIKELY) + #undef HEDLEY_LIKELY +#endif +#if defined(HEDLEY_UNLIKELY) + #undef HEDLEY_UNLIKELY +#endif +#if defined(HEDLEY_UNPREDICTABLE) + #undef HEDLEY_UNPREDICTABLE +#endif +#if HEDLEY_HAS_BUILTIN(__builtin_unpredictable) + #define HEDLEY_UNPREDICTABLE(expr) __builtin_unpredictable(!!(expr)) +#endif +#if \ + HEDLEY_HAS_BUILTIN(__builtin_expect_with_probability) || \ + HEDLEY_GCC_VERSION_CHECK(9,0,0) +# define HEDLEY_PREDICT(expr, value, probability) __builtin_expect_with_probability(expr, value, probability) +# define HEDLEY_PREDICT_TRUE(expr, probability) __builtin_expect_with_probability(!!(expr), 1, probability) +# define HEDLEY_PREDICT_FALSE(expr, probability) __builtin_expect_with_probability(!!(expr), 0, probability) +# define HEDLEY_LIKELY(expr) __builtin_expect(!!(expr), 1) +# define HEDLEY_UNLIKELY(expr) __builtin_expect(!!(expr), 0) +#if !defined(HEDLEY_BUILTIN_UNPREDICTABLE) + #define HEDLEY_BUILTIN_UNPREDICTABLE(expr) __builtin_expect_with_probability(!!(expr), 1, 0.5) +#endif +#elif \ + HEDLEY_HAS_BUILTIN(__builtin_expect) || \ + HEDLEY_GCC_VERSION_CHECK(3,0,0) || \ + HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ + (HEDLEY_SUNPRO_VERSION_CHECK(5,15,0) && defined(__cplusplus)) || \ + HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ + HEDLEY_IBM_VERSION_CHECK(10,1,0) || \ + HEDLEY_TI_VERSION_CHECK(6,1,0) || \ + HEDLEY_TINYC_VERSION_CHECK(0,9,27) +# define HEDLEY_PREDICT(expr, expected, probability) \ + (((probability) >= 0.9) ? __builtin_expect(!!(expr), (expected)) : (((void) (expected)), !!(expr))) +# define HEDLEY_PREDICT_TRUE(expr, probability) \ + (__extension__ ({ \ + HEDLEY_CONSTEXPR double hedley_probability_ = (probability); \ + ((hedley_probability_ >= 0.9) ? __builtin_expect(!!(expr), 1) : ((hedley_probability_ <= 0.1) ? __builtin_expect(!!(expr), 0) : !!(expr))); \ + })) +# define HEDLEY_PREDICT_FALSE(expr, probability) \ + (__extension__ ({ \ + HEDLEY_CONSTEXPR double hedley_probability_ = (probability); \ + ((hedley_probability_ >= 0.9) ? __builtin_expect(!!(expr), 0) : ((hedley_probability_ <= 0.1) ? __builtin_expect(!!(expr), 1) : !!(expr))); \ + })) +# define HEDLEY_LIKELY(expr) __builtin_expect(!!(expr), 1) +# define HEDLEY_UNLIKELY(expr) __builtin_expect(!!(expr), 0) +#else +# define HEDLEY_PREDICT(expr, expected, probability) (((void) (expected)), !!(expr)) +# define HEDLEY_PREDICT_TRUE(expr, probability) (!!(expr)) +# define HEDLEY_PREDICT_FALSE(expr, probability) (!!(expr)) +# define HEDLEY_LIKELY(expr) (!!(expr)) +# define HEDLEY_UNLIKELY(expr) (!!(expr)) +#endif +#if !defined(HEDLEY_UNPREDICTABLE) + #define HEDLEY_UNPREDICTABLE(expr) HEDLEY_PREDICT(expr, 1, 0.5) +#endif + +#if defined(HEDLEY_MALLOC) + #undef HEDLEY_MALLOC +#endif +#if \ + HEDLEY_HAS_ATTRIBUTE(malloc) || \ + HEDLEY_GCC_VERSION_CHECK(3,1,0) || \ + HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ + HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \ + HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ + HEDLEY_IBM_VERSION_CHECK(12,1,0) || \ + HEDLEY_TI_VERSION_CHECK(8,0,0) || \ + (HEDLEY_TI_VERSION_CHECK(7,3,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) + #define HEDLEY_MALLOC __attribute__((__malloc__)) +#elif HEDLEY_MSVC_VERSION_CHECK(14, 0, 0) + #define HEDLEY_MALLOC __declspec(restrict) +#else + #define HEDLEY_MALLOC +#endif + +#if defined(HEDLEY_PURE) + #undef HEDLEY_PURE +#endif +#if \ + HEDLEY_HAS_ATTRIBUTE(pure) || \ + HEDLEY_GCC_VERSION_CHECK(2,96,0) || \ + HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ + HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \ + HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ + HEDLEY_IBM_VERSION_CHECK(10,1,0) || \ + HEDLEY_TI_VERSION_CHECK(8,0,0) || \ + (HEDLEY_TI_VERSION_CHECK(7,3,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ + HEDLEY_PGI_VERSION_CHECK(17,10,0) + #define HEDLEY_PURE __attribute__((__pure__)) +#elif HEDLEY_TI_VERSION_CHECK(6,0,0) && defined(__cplusplus) + #define HEDLEY_PURE _Pragma("FUNC_IS_PURE;") +#else + #define HEDLEY_PURE +#endif + +#if defined(HEDLEY_CONST) + #undef HEDLEY_CONST +#endif +#if \ + HEDLEY_HAS_ATTRIBUTE(const) || \ + HEDLEY_GCC_VERSION_CHECK(2,5,0) || \ + HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ + HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \ + HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ + HEDLEY_IBM_VERSION_CHECK(10,1,0) || \ + HEDLEY_TI_VERSION_CHECK(8,0,0) || \ + (HEDLEY_TI_VERSION_CHECK(7,3,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ + HEDLEY_PGI_VERSION_CHECK(17,10,0) + #define HEDLEY_CONST __attribute__((__const__)) +#else + #define HEDLEY_CONST HEDLEY_PURE +#endif + +#if defined(HEDLEY_RESTRICT) + #undef HEDLEY_RESTRICT +#endif +#if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) && !defined(__cplusplus) + #define HEDLEY_RESTRICT restrict +#elif \ + HEDLEY_GCC_VERSION_CHECK(3,1,0) || \ + HEDLEY_MSVC_VERSION_CHECK(14,0,0) || \ + HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ + HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ + HEDLEY_IBM_VERSION_CHECK(10,1,0) || \ + HEDLEY_PGI_VERSION_CHECK(17,10,0) || \ + HEDLEY_TI_VERSION_CHECK(8,0,0) || \ + (HEDLEY_SUNPRO_VERSION_CHECK(5,14,0) && defined(__cplusplus)) || \ + HEDLEY_IAR_VERSION_CHECK(8,0,0) || \ + defined(__clang__) + #define HEDLEY_RESTRICT __restrict +#elif HEDLEY_SUNPRO_VERSION_CHECK(5,3,0) && !defined(__cplusplus) + #define HEDLEY_RESTRICT _Restrict +#else + #define HEDLEY_RESTRICT +#endif + +#if defined(HEDLEY_INLINE) + #undef HEDLEY_INLINE +#endif +#if \ + (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)) || \ + (defined(__cplusplus) && (__cplusplus >= 199711L)) + #define HEDLEY_INLINE inline +#elif \ + defined(HEDLEY_GCC_VERSION) || \ + HEDLEY_ARM_VERSION_CHECK(6,2,0) + #define HEDLEY_INLINE __inline__ +#elif \ + HEDLEY_MSVC_VERSION_CHECK(12,0,0) || \ + HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ + HEDLEY_TI_VERSION_CHECK(8,0,0) + #define HEDLEY_INLINE __inline +#else + #define HEDLEY_INLINE +#endif + +#if defined(HEDLEY_ALWAYS_INLINE) + #undef HEDLEY_ALWAYS_INLINE +#endif +#if \ + HEDLEY_HAS_ATTRIBUTE(always_inline) || \ + HEDLEY_GCC_VERSION_CHECK(4,0,0) || \ + HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ + HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \ + HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ + HEDLEY_IBM_VERSION_CHECK(10,1,0) || \ + HEDLEY_TI_VERSION_CHECK(8,0,0) || \ + (HEDLEY_TI_VERSION_CHECK(7,3,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) + #define HEDLEY_ALWAYS_INLINE __attribute__((__always_inline__)) HEDLEY_INLINE +#elif HEDLEY_MSVC_VERSION_CHECK(12,0,0) + #define HEDLEY_ALWAYS_INLINE __forceinline +#elif HEDLEY_TI_VERSION_CHECK(7,0,0) && defined(__cplusplus) + #define HEDLEY_ALWAYS_INLINE _Pragma("FUNC_ALWAYS_INLINE;") +#elif HEDLEY_IAR_VERSION_CHECK(8,0,0) + #define HEDLEY_ALWAYS_INLINE _Pragma("inline=forced") +#else + #define HEDLEY_ALWAYS_INLINE HEDLEY_INLINE +#endif + +#if defined(HEDLEY_NEVER_INLINE) + #undef HEDLEY_NEVER_INLINE +#endif +#if \ + HEDLEY_HAS_ATTRIBUTE(noinline) || \ + HEDLEY_GCC_VERSION_CHECK(4,0,0) || \ + HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ + HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \ + HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ + HEDLEY_IBM_VERSION_CHECK(10,1,0) || \ + HEDLEY_TI_VERSION_CHECK(8,0,0) || \ + (HEDLEY_TI_VERSION_CHECK(7,3,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) + #define HEDLEY_NEVER_INLINE __attribute__((__noinline__)) +#elif HEDLEY_MSVC_VERSION_CHECK(13,10,0) + #define HEDLEY_NEVER_INLINE __declspec(noinline) +#elif HEDLEY_PGI_VERSION_CHECK(10,2,0) + #define HEDLEY_NEVER_INLINE _Pragma("noinline") +#elif HEDLEY_TI_VERSION_CHECK(6,0,0) && defined(__cplusplus) + #define HEDLEY_NEVER_INLINE _Pragma("FUNC_CANNOT_INLINE;") +#elif HEDLEY_IAR_VERSION_CHECK(8,0,0) + #define HEDLEY_NEVER_INLINE _Pragma("inline=never") +#elif HEDLEY_COMPCERT_VERSION_CHECK(3,2,0) + #define HEDLEY_NEVER_INLINE __attribute((noinline)) +#elif HEDLEY_PELLES_VERSION_CHECK(9,0,0) + #define HEDLEY_NEVER_INLINE __declspec(noinline) +#else + #define HEDLEY_NEVER_INLINE +#endif + +#if defined(HEDLEY_PRIVATE) + #undef HEDLEY_PRIVATE +#endif +#if defined(HEDLEY_PUBLIC) + #undef HEDLEY_PUBLIC +#endif +#if defined(HEDLEY_IMPORT) + #undef HEDLEY_IMPORT +#endif +#if defined(_WIN32) || defined(__CYGWIN__) + #define HEDLEY_PRIVATE + #define HEDLEY_PUBLIC __declspec(dllexport) + #define HEDLEY_IMPORT __declspec(dllimport) +#else + #if \ + HEDLEY_HAS_ATTRIBUTE(visibility) || \ + HEDLEY_GCC_VERSION_CHECK(3,3,0) || \ + HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \ + HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ + HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ + HEDLEY_IBM_VERSION_CHECK(13,1,0) || \ + HEDLEY_TI_VERSION_CHECK(8,0,0) || \ + (HEDLEY_TI_VERSION_CHECK(7,3,0) && defined(__TI_EABI__) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) + #define HEDLEY_PRIVATE __attribute__((__visibility__("hidden"))) + #define HEDLEY_PUBLIC __attribute__((__visibility__("default"))) + #else + #define HEDLEY_PRIVATE + #define HEDLEY_PUBLIC + #endif + #define HEDLEY_IMPORT extern +#endif + +#if defined(HEDLEY_NO_THROW) + #undef HEDLEY_NO_THROW +#endif +#if \ + HEDLEY_HAS_ATTRIBUTE(nothrow) || \ + HEDLEY_GCC_VERSION_CHECK(3,3,0) || \ + HEDLEY_INTEL_VERSION_CHECK(13,0,0) + #define HEDLEY_NO_THROW __attribute__((__nothrow__)) +#elif \ + HEDLEY_MSVC_VERSION_CHECK(13,1,0) || \ + HEDLEY_ARM_VERSION_CHECK(4,1,0) + #define HEDLEY_NO_THROW __declspec(nothrow) +#else + #define HEDLEY_NO_THROW +#endif + +#if defined(HEDLEY_FALL_THROUGH) + #undef HEDLEY_FALL_THROUGH +#endif +#if \ + defined(__cplusplus) && \ + (!defined(HEDLEY_SUNPRO_VERSION) || HEDLEY_SUNPRO_VERSION_CHECK(5,15,0)) && \ + !defined(HEDLEY_PGI_VERSION) + #if \ + (__cplusplus >= 201703L) || \ + ((__cplusplus >= 201103L) && HEDLEY_HAS_CPP_ATTRIBUTE(fallthrough)) + #define HEDLEY_FALL_THROUGH [[fallthrough]] + #elif (__cplusplus >= 201103L) && HEDLEY_HAS_CPP_ATTRIBUTE(clang::fallthrough) + #define HEDLEY_FALL_THROUGH [[clang::fallthrough]] + #elif (__cplusplus >= 201103L) && HEDLEY_GCC_VERSION_CHECK(7,0,0) + #define HEDLEY_FALL_THROUGH [[gnu::fallthrough]] + #endif +#endif +#if !defined(HEDLEY_FALL_THROUGH) + #if HEDLEY_GNUC_HAS_ATTRIBUTE(fallthrough,7,0,0) && !defined(HEDLEY_PGI_VERSION) + #define HEDLEY_FALL_THROUGH __attribute__((__fallthrough__)) + #elif defined(__fallthrough) /* SAL */ + #define HEDLEY_FALL_THROUGH __fallthrough + #else + #define HEDLEY_FALL_THROUGH + #endif +#endif + +#if defined(HEDLEY_RETURNS_NON_NULL) + #undef HEDLEY_RETURNS_NON_NULL +#endif +#if \ + HEDLEY_HAS_ATTRIBUTE(returns_nonnull) || \ + HEDLEY_GCC_VERSION_CHECK(4,9,0) + #define HEDLEY_RETURNS_NON_NULL __attribute__((__returns_nonnull__)) +#elif defined(_Ret_notnull_) /* SAL */ + #define HEDLEY_RETURNS_NON_NULL _Ret_notnull_ +#else + #define HEDLEY_RETURNS_NON_NULL +#endif + +#if defined(HEDLEY_ARRAY_PARAM) + #undef HEDLEY_ARRAY_PARAM +#endif +#if \ + defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) && \ + !defined(__STDC_NO_VLA__) && \ + !defined(__cplusplus) && \ + !defined(HEDLEY_PGI_VERSION) && \ + !defined(HEDLEY_TINYC_VERSION) + #define HEDLEY_ARRAY_PARAM(name) (name) +#else + #define HEDLEY_ARRAY_PARAM(name) +#endif + +#if defined(HEDLEY_IS_CONSTANT) + #undef HEDLEY_IS_CONSTANT +#endif +#if defined(HEDLEY_REQUIRE_CONSTEXPR) + #undef HEDLEY_REQUIRE_CONSTEXPR +#endif +/* Note the double-underscore. For internal use only; no API + * guarantees! */ +#if defined(HEDLEY__IS_CONSTEXPR) + #undef HEDLEY__IS_CONSTEXPR +#endif + +#if \ + HEDLEY_HAS_BUILTIN(__builtin_constant_p) || \ + HEDLEY_GCC_VERSION_CHECK(3,4,0) || \ + HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ + HEDLEY_TINYC_VERSION_CHECK(0,9,19) || \ + HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ + HEDLEY_IBM_VERSION_CHECK(13,1,0) || \ + HEDLEY_TI_VERSION_CHECK(6,1,0) || \ + HEDLEY_SUNPRO_VERSION_CHECK(5,10,0) || \ + HEDLEY_CRAY_VERSION_CHECK(8,1,0) + #define HEDLEY_IS_CONSTANT(expr) __builtin_constant_p(expr) +#endif +#if !defined(__cplusplus) +# if \ + HEDLEY_HAS_BUILTIN(__builtin_types_compatible_p) || \ + HEDLEY_GCC_VERSION_CHECK(3,4,0) || \ + HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ + HEDLEY_IBM_VERSION_CHECK(13,1,0) || \ + HEDLEY_CRAY_VERSION_CHECK(8,1,0) || \ + HEDLEY_ARM_VERSION_CHECK(5,4,0) || \ + HEDLEY_TINYC_VERSION_CHECK(0,9,24) +#if defined(__INTPTR_TYPE__) + #define HEDLEY__IS_CONSTEXPR(expr) __builtin_types_compatible_p(__typeof__((1 ? (void*) ((__INTPTR_TYPE__) ((expr) * 0)) : (int*) 0)), int*) +#else + #include + #define HEDLEY__IS_CONSTEXPR(expr) __builtin_types_compatible_p(__typeof__((1 ? (void*) ((intptr_t) ((expr) * 0)) : (int*) 0)), int*) +#endif +# elif \ + (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 201112L) && !defined(HEDLEY_SUNPRO_VERSION) && !defined(HEDLEY_PGI_VERSION)) || \ + HEDLEY_HAS_EXTENSION(c_generic_selections) || \ + HEDLEY_GCC_VERSION_CHECK(4,9,0) || \ + HEDLEY_INTEL_VERSION_CHECK(17,0,0) || \ + HEDLEY_IBM_VERSION_CHECK(12,1,0) || \ + HEDLEY_ARM_VERSION_CHECK(5,3,0) +#if defined(__INTPTR_TYPE__) + #define HEDLEY__IS_CONSTEXPR(expr) _Generic((1 ? (void*) ((__INTPTR_TYPE__) ((expr) * 0)) : (int*) 0), int*: 1, void*: 0) +#else + #include + #define HEDLEY__IS_CONSTEXPR(expr) _Generic((1 ? (void*) ((intptr_t) * 0) : (int*) 0), int*: 1, void*: 0) +#endif +# elif \ + defined(HEDLEY_GCC_VERSION) || \ + defined(HEDLEY_INTEL_VERSION) || \ + defined(HEDLEY_TINYC_VERSION) || \ + defined(HEDLEY_TI_VERSION) || \ + defined(__clang__) +# define HEDLEY__IS_CONSTEXPR(expr) ( \ + sizeof(void) != \ + sizeof(*( \ + 1 ? \ + ((void*) ((expr) * 0L) ) : \ +((struct { char v[sizeof(void) * 2]; } *) 1) \ + ) \ + ) \ + ) +# endif +#endif +#if defined(HEDLEY__IS_CONSTEXPR) + #if !defined(HEDLEY_IS_CONSTANT) + #define HEDLEY_IS_CONSTANT(expr) HEDLEY__IS_CONSTEXPR(expr) + #endif + #define HEDLEY_REQUIRE_CONSTEXPR(expr) (HEDLEY__IS_CONSTEXPR(expr) ? (expr) : (-1)) +#else + #if !defined(HEDLEY_IS_CONSTANT) + #define HEDLEY_IS_CONSTANT(expr) (0) + #endif + #define HEDLEY_REQUIRE_CONSTEXPR(expr) (expr) +#endif + +#if defined(HEDLEY_BEGIN_C_DECLS) + #undef HEDLEY_BEGIN_C_DECLS +#endif +#if defined(HEDLEY_END_C_DECLS) + #undef HEDLEY_END_C_DECLS +#endif +#if defined(HEDLEY_C_DECL) + #undef HEDLEY_C_DECL +#endif +#if defined(__cplusplus) + #define HEDLEY_BEGIN_C_DECLS extern "C" { + #define HEDLEY_END_C_DECLS } + #define HEDLEY_C_DECL extern "C" +#else + #define HEDLEY_BEGIN_C_DECLS + #define HEDLEY_END_C_DECLS + #define HEDLEY_C_DECL +#endif + +#if defined(HEDLEY_STATIC_ASSERT) + #undef HEDLEY_STATIC_ASSERT +#endif +#if \ + !defined(__cplusplus) && ( \ + (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 201112L)) || \ + HEDLEY_HAS_FEATURE(c_static_assert) || \ + HEDLEY_GCC_VERSION_CHECK(6,0,0) || \ + HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ + defined(_Static_assert) \ + ) +# define HEDLEY_STATIC_ASSERT(expr, message) _Static_assert(expr, message) +#elif \ + (defined(__cplusplus) && (__cplusplus >= 201703L)) || \ + HEDLEY_MSVC_VERSION_CHECK(16,0,0) || \ + (defined(__cplusplus) && HEDLEY_TI_VERSION_CHECK(8,3,0)) +# define HEDLEY_STATIC_ASSERT(expr, message) static_assert(expr, message) +#elif defined(__cplusplus) && (__cplusplus >= 201103L) +# define HEDLEY_STATIC_ASSERT(expr, message) static_assert(expr) +#else +# define HEDLEY_STATIC_ASSERT(expr, message) +#endif + +#if defined(HEDLEY_CONST_CAST) + #undef HEDLEY_CONST_CAST +#endif +#if defined(__cplusplus) +# define HEDLEY_CONST_CAST(T, expr) (const_cast(expr)) +#elif \ + HEDLEY_HAS_WARNING("-Wcast-qual") || \ + HEDLEY_GCC_VERSION_CHECK(4,6,0) || \ + HEDLEY_INTEL_VERSION_CHECK(13,0,0) +# define HEDLEY_CONST_CAST(T, expr) (__extension__ ({ \ + HEDLEY_DIAGNOSTIC_PUSH \ + HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL \ + ((T) (expr)); \ + HEDLEY_DIAGNOSTIC_POP \ + })) +#else +# define HEDLEY_CONST_CAST(T, expr) ((T) (expr)) +#endif + +#if defined(HEDLEY_REINTERPRET_CAST) + #undef HEDLEY_REINTERPRET_CAST +#endif +#if defined(__cplusplus) + #define HEDLEY_REINTERPRET_CAST(T, expr) (reinterpret_cast(expr)) +#else + #define HEDLEY_REINTERPRET_CAST(T, expr) (*((T*) &(expr))) +#endif + +#if defined(HEDLEY_STATIC_CAST) + #undef HEDLEY_STATIC_CAST +#endif +#if defined(__cplusplus) + #define HEDLEY_STATIC_CAST(T, expr) (static_cast(expr)) +#else + #define HEDLEY_STATIC_CAST(T, expr) ((T) (expr)) +#endif + +#if defined(HEDLEY_CPP_CAST) + #undef HEDLEY_CPP_CAST +#endif +#if defined(__cplusplus) + #define HEDLEY_CPP_CAST(T, expr) static_cast(expr) +#else + #define HEDLEY_CPP_CAST(T, expr) (expr) +#endif + +#if defined(HEDLEY_MESSAGE) + #undef HEDLEY_MESSAGE +#endif +#if HEDLEY_HAS_WARNING("-Wunknown-pragmas") +# define HEDLEY_MESSAGE(msg) \ + HEDLEY_DIAGNOSTIC_PUSH \ + HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS \ + HEDLEY_PRAGMA(message msg) \ + HEDLEY_DIAGNOSTIC_POP +#elif \ + HEDLEY_GCC_VERSION_CHECK(4,4,0) || \ + HEDLEY_INTEL_VERSION_CHECK(13,0,0) +# define HEDLEY_MESSAGE(msg) HEDLEY_PRAGMA(message msg) +#elif HEDLEY_CRAY_VERSION_CHECK(5,0,0) +# define HEDLEY_MESSAGE(msg) HEDLEY_PRAGMA(_CRI message msg) +#elif HEDLEY_IAR_VERSION_CHECK(8,0,0) +# define HEDLEY_MESSAGE(msg) HEDLEY_PRAGMA(message(msg)) +#elif HEDLEY_PELLES_VERSION_CHECK(2,0,0) +# define HEDLEY_MESSAGE(msg) HEDLEY_PRAGMA(message(msg)) +#else +# define HEDLEY_MESSAGE(msg) +#endif + +#if defined(HEDLEY_WARNING) + #undef HEDLEY_WARNING +#endif +#if HEDLEY_HAS_WARNING("-Wunknown-pragmas") +# define HEDLEY_WARNING(msg) \ + HEDLEY_DIAGNOSTIC_PUSH \ + HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS \ + HEDLEY_PRAGMA(clang warning msg) \ + HEDLEY_DIAGNOSTIC_POP +#elif \ + HEDLEY_GCC_VERSION_CHECK(4,8,0) || \ + HEDLEY_PGI_VERSION_CHECK(18,4,0) +# define HEDLEY_WARNING(msg) HEDLEY_PRAGMA(GCC warning msg) +#elif HEDLEY_MSVC_VERSION_CHECK(15,0,0) +# define HEDLEY_WARNING(msg) HEDLEY_PRAGMA(message(msg)) +#else +# define HEDLEY_WARNING(msg) HEDLEY_MESSAGE(msg) +#endif + +#if defined(HEDLEY_REQUIRE_MSG) + #undef HEDLEY_REQUIRE_MSG +#endif +#if HEDLEY_HAS_ATTRIBUTE(diagnose_if) +# if HEDLEY_HAS_WARNING("-Wgcc-compat") +# define HEDLEY_REQUIRE_MSG(expr, msg) \ + HEDLEY_DIAGNOSTIC_PUSH \ + _Pragma("clang diagnostic ignored \"-Wgcc-compat\"") \ + __attribute__((__diagnose_if__(!(expr), msg, "error"))) \ + HEDLEY_DIAGNOSTIC_POP +# else +# define HEDLEY_REQUIRE_MSG(expr, msg) __attribute__((__diagnose_if__(!(expr), msg, "error"))) +# endif +#else +# define HEDLEY_REQUIRE_MSG(expr, msg) +#endif + +#if defined(HEDLEY_REQUIRE) + #undef HEDLEY_REQUIRE +#endif +#define HEDLEY_REQUIRE(expr) HEDLEY_REQUIRE_MSG(expr, #expr) + +#if defined(HEDLEY_FLAGS) + #undef HEDLEY_FLAGS +#endif +#if HEDLEY_HAS_ATTRIBUTE(flag_enum) + #define HEDLEY_FLAGS __attribute__((__flag_enum__)) +#endif + +#if defined(HEDLEY_FLAGS_CAST) + #undef HEDLEY_FLAGS_CAST +#endif +#if HEDLEY_INTEL_VERSION_CHECK(19,0,0) +# define HEDLEY_FLAGS_CAST(T, expr) (__extension__ ({ \ + HEDLEY_DIAGNOSTIC_PUSH \ + _Pragma("warning(disable:188)") \ + ((T) (expr)); \ + HEDLEY_DIAGNOSTIC_POP \ + })) +#else +# define HEDLEY_FLAGS_CAST(T, expr) HEDLEY_STATIC_CAST(T, expr) +#endif + +/* Remaining macros are deprecated. */ + +#if defined(HEDLEY_GCC_NOT_CLANG_VERSION_CHECK) + #undef HEDLEY_GCC_NOT_CLANG_VERSION_CHECK +#endif +#if defined(__clang__) + #define HEDLEY_GCC_NOT_CLANG_VERSION_CHECK(major,minor,patch) (0) +#else + #define HEDLEY_GCC_NOT_CLANG_VERSION_CHECK(major,minor,patch) HEDLEY_GCC_VERSION_CHECK(major,minor,patch) +#endif + +#if defined(HEDLEY_CLANG_HAS_ATTRIBUTE) + #undef HEDLEY_CLANG_HAS_ATTRIBUTE +#endif +#define HEDLEY_CLANG_HAS_ATTRIBUTE(attribute) HEDLEY_HAS_ATTRIBUTE(attribute) + +#if defined(HEDLEY_CLANG_HAS_CPP_ATTRIBUTE) + #undef HEDLEY_CLANG_HAS_CPP_ATTRIBUTE +#endif +#define HEDLEY_CLANG_HAS_CPP_ATTRIBUTE(attribute) HEDLEY_HAS_CPP_ATTRIBUTE(attribute) + +#if defined(HEDLEY_CLANG_HAS_BUILTIN) + #undef HEDLEY_CLANG_HAS_BUILTIN +#endif +#define HEDLEY_CLANG_HAS_BUILTIN(builtin) HEDLEY_HAS_BUILTIN(builtin) + +#if defined(HEDLEY_CLANG_HAS_FEATURE) + #undef HEDLEY_CLANG_HAS_FEATURE +#endif +#define HEDLEY_CLANG_HAS_FEATURE(feature) HEDLEY_HAS_FEATURE(feature) + +#if defined(HEDLEY_CLANG_HAS_EXTENSION) + #undef HEDLEY_CLANG_HAS_EXTENSION +#endif +#define HEDLEY_CLANG_HAS_EXTENSION(extension) HEDLEY_HAS_EXTENSION(extension) + +#if defined(HEDLEY_CLANG_HAS_DECLSPEC_DECLSPEC_ATTRIBUTE) + #undef HEDLEY_CLANG_HAS_DECLSPEC_DECLSPEC_ATTRIBUTE +#endif +#define HEDLEY_CLANG_HAS_DECLSPEC_ATTRIBUTE(attribute) HEDLEY_HAS_DECLSPEC_ATTRIBUTE(attribute) + +#if defined(HEDLEY_CLANG_HAS_WARNING) + #undef HEDLEY_CLANG_HAS_WARNING +#endif +#define HEDLEY_CLANG_HAS_WARNING(warning) HEDLEY_HAS_WARNING(warning) + +#endif /* !defined(HEDLEY_VERSION) || (HEDLEY_VERSION < X) */ + + +// This file contains all internal macro definitions +// You MUST include macro_unscope.hpp at the end of json.hpp to undef all of them + +// exclude unsupported compilers +#if !defined(JSON_SKIP_UNSUPPORTED_COMPILER_CHECK) + #if defined(__clang__) + #if (__clang_major__ * 10000 + __clang_minor__ * 100 + __clang_patchlevel__) < 30400 + #error "unsupported Clang version - see https://github.com/nlohmann/json#supported-compilers" + #endif + #elif defined(__GNUC__) && !(defined(__ICC) || defined(__INTEL_COMPILER)) + #if (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__) < 40800 + #error "unsupported GCC version - see https://github.com/nlohmann/json#supported-compilers" + #endif + #endif +#endif + +// C++ language standard detection +#if (defined(__cplusplus) && __cplusplus >= 201703L) || (defined(_HAS_CXX17) && _HAS_CXX17 == 1) // fix for issue #464 + #define JSON_HAS_CPP_17 + #define JSON_HAS_CPP_14 +#elif (defined(__cplusplus) && __cplusplus >= 201402L) || (defined(_HAS_CXX14) && _HAS_CXX14 == 1) + #define JSON_HAS_CPP_14 +#endif + +// disable float-equal warnings on GCC/clang +#if defined(__clang__) || defined(__GNUC__) || defined(__GNUG__) + #pragma GCC diagnostic push + #pragma GCC diagnostic ignored "-Wfloat-equal" +#endif + +// disable documentation warnings on clang +#if defined(__clang__) + #pragma GCC diagnostic push + #pragma GCC diagnostic ignored "-Wdocumentation" +#endif + +// allow to disable exceptions +#if (defined(__cpp_exceptions) || defined(__EXCEPTIONS) || defined(_CPPUNWIND)) && !defined(JSON_NOEXCEPTION) + #define JSON_THROW(exception) throw exception + #define JSON_TRY try + #define JSON_CATCH(exception) catch(exception) + #define JSON_INTERNAL_CATCH(exception) catch(exception) +#else + #include + #define JSON_THROW(exception) std::abort() + #define JSON_TRY if(true) + #define JSON_CATCH(exception) if(false) + #define JSON_INTERNAL_CATCH(exception) if(false) +#endif + +// override exception macros +#if defined(JSON_THROW_USER) + #undef JSON_THROW + #define JSON_THROW JSON_THROW_USER +#endif +#if defined(JSON_TRY_USER) + #undef JSON_TRY + #define JSON_TRY JSON_TRY_USER +#endif +#if defined(JSON_CATCH_USER) + #undef JSON_CATCH + #define JSON_CATCH JSON_CATCH_USER + #undef JSON_INTERNAL_CATCH + #define JSON_INTERNAL_CATCH JSON_CATCH_USER +#endif +#if defined(JSON_INTERNAL_CATCH_USER) + #undef JSON_INTERNAL_CATCH + #define JSON_INTERNAL_CATCH JSON_INTERNAL_CATCH_USER +#endif + +/*! +@brief macro to briefly define a mapping between an enum and JSON +@def NLOHMANN_JSON_SERIALIZE_ENUM +@since version 3.4.0 +*/ +#define NLOHMANN_JSON_SERIALIZE_ENUM(ENUM_TYPE, ...) \ + template \ + inline void to_json(BasicJsonType& j, const ENUM_TYPE& e) \ + { \ + static_assert(std::is_enum::value, #ENUM_TYPE " must be an enum!"); \ + static const std::pair m[] = __VA_ARGS__; \ + auto it = std::find_if(std::begin(m), std::end(m), \ + [e](const std::pair& ej_pair) -> bool \ + { \ + return ej_pair.first == e; \ + }); \ + j = ((it != std::end(m)) ? it : std::begin(m))->second; \ + } \ + template \ + inline void from_json(const BasicJsonType& j, ENUM_TYPE& e) \ + { \ + static_assert(std::is_enum::value, #ENUM_TYPE " must be an enum!"); \ + static const std::pair m[] = __VA_ARGS__; \ + auto it = std::find_if(std::begin(m), std::end(m), \ + [j](const std::pair& ej_pair) -> bool \ + { \ + return ej_pair.second == j; \ + }); \ + e = ((it != std::end(m)) ? it : std::begin(m))->first; \ + } + +// Ugly macros to avoid uglier copy-paste when specializing basic_json. They +// may be removed in the future once the class is split. + +#define NLOHMANN_BASIC_JSON_TPL_DECLARATION \ + template class ObjectType, \ + template class ArrayType, \ + class StringType, class BooleanType, class NumberIntegerType, \ + class NumberUnsignedType, class NumberFloatType, \ + template class AllocatorType, \ + template class JSONSerializer> + +#define NLOHMANN_BASIC_JSON_TPL \ + basic_json + namespace nlohmann { @@ -146,6 +1775,7 @@ class exception : public std::exception { public: /// returns the explanatory string + HEDLEY_RETURNS_NON_NULL const char* what() const noexcept override { return m.what(); @@ -155,6 +1785,7 @@ class exception : public std::exception const int id; protected: + HEDLEY_NON_NULL(3) exception(int id_, const char* what_arg) : id(id_), m(what_arg) {} static std::string name(const std::string& ename, int id_) @@ -307,6 +1938,7 @@ class invalid_iterator : public exception } private: + HEDLEY_NON_NULL(3) invalid_iterator(int id_, const char* what_arg) : exception(id_, what_arg) {} }; @@ -360,6 +1992,7 @@ class type_error : public exception } private: + HEDLEY_NON_NULL(3) type_error(int id_, const char* what_arg) : exception(id_, what_arg) {} }; @@ -406,6 +2039,7 @@ class out_of_range : public exception } private: + HEDLEY_NON_NULL(3) out_of_range(int id_, const char* what_arg) : exception(id_, what_arg) {} }; @@ -443,6 +2077,7 @@ class other_error : public exception } private: + HEDLEY_NON_NULL(3) other_error(int id_, const char* what_arg) : exception(id_, what_arg) {} }; } // namespace detail @@ -450,161 +2085,6 @@ class other_error : public exception // #include - -#include // pair - -// This file contains all internal macro definitions -// You MUST include macro_unscope.hpp at the end of json.hpp to undef all of them - -// exclude unsupported compilers -#if !defined(JSON_SKIP_UNSUPPORTED_COMPILER_CHECK) - #if defined(__clang__) - #if (__clang_major__ * 10000 + __clang_minor__ * 100 + __clang_patchlevel__) < 30400 - #error "unsupported Clang version - see https://github.com/nlohmann/json#supported-compilers" - #endif - #elif defined(__GNUC__) && !(defined(__ICC) || defined(__INTEL_COMPILER)) - #if (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__) < 40800 - #error "unsupported GCC version - see https://github.com/nlohmann/json#supported-compilers" - #endif - #endif -#endif - -// C++ language standard detection -#if (defined(__cplusplus) && __cplusplus >= 201703L) || (defined(_HAS_CXX17) && _HAS_CXX17 == 1) // fix for issue #464 - #define JSON_HAS_CPP_17 - #define JSON_HAS_CPP_14 -#elif (defined(__cplusplus) && __cplusplus >= 201402L) || (defined(_HAS_CXX14) && _HAS_CXX14 == 1) - #define JSON_HAS_CPP_14 -#endif - -// disable float-equal warnings on GCC/clang -#if defined(__clang__) || defined(__GNUC__) || defined(__GNUG__) - #pragma GCC diagnostic push - #pragma GCC diagnostic ignored "-Wfloat-equal" -#endif - -// disable documentation warnings on clang -#if defined(__clang__) - #pragma GCC diagnostic push - #pragma GCC diagnostic ignored "-Wdocumentation" -#endif - -// allow for portable deprecation warnings -#if defined(__clang__) || defined(__GNUC__) || defined(__GNUG__) - #define JSON_DEPRECATED __attribute__((deprecated)) -#elif defined(_MSC_VER) - #define JSON_DEPRECATED __declspec(deprecated) -#else - #define JSON_DEPRECATED -#endif - -// allow for portable nodiscard warnings -#if defined(__has_cpp_attribute) - #if __has_cpp_attribute(nodiscard) - #if defined(__clang__) && !defined(JSON_HAS_CPP_17) // issue #1535 - #define JSON_NODISCARD - #else - #define JSON_NODISCARD [[nodiscard]] - #endif - #elif __has_cpp_attribute(gnu::warn_unused_result) - #define JSON_NODISCARD [[gnu::warn_unused_result]] - #else - #define JSON_NODISCARD - #endif -#else - #define JSON_NODISCARD -#endif - -// allow to disable exceptions -#if (defined(__cpp_exceptions) || defined(__EXCEPTIONS) || defined(_CPPUNWIND)) && !defined(JSON_NOEXCEPTION) - #define JSON_THROW(exception) throw exception - #define JSON_TRY try - #define JSON_CATCH(exception) catch(exception) - #define JSON_INTERNAL_CATCH(exception) catch(exception) -#else - #include - #define JSON_THROW(exception) std::abort() - #define JSON_TRY if(true) - #define JSON_CATCH(exception) if(false) - #define JSON_INTERNAL_CATCH(exception) if(false) -#endif - -// override exception macros -#if defined(JSON_THROW_USER) - #undef JSON_THROW - #define JSON_THROW JSON_THROW_USER -#endif -#if defined(JSON_TRY_USER) - #undef JSON_TRY - #define JSON_TRY JSON_TRY_USER -#endif -#if defined(JSON_CATCH_USER) - #undef JSON_CATCH - #define JSON_CATCH JSON_CATCH_USER - #undef JSON_INTERNAL_CATCH - #define JSON_INTERNAL_CATCH JSON_CATCH_USER -#endif -#if defined(JSON_INTERNAL_CATCH_USER) - #undef JSON_INTERNAL_CATCH - #define JSON_INTERNAL_CATCH JSON_INTERNAL_CATCH_USER -#endif - -// manual branch prediction -#if defined(__clang__) || defined(__GNUC__) || defined(__GNUG__) - #define JSON_LIKELY(x) __builtin_expect(x, 1) - #define JSON_UNLIKELY(x) __builtin_expect(x, 0) -#else - #define JSON_LIKELY(x) x - #define JSON_UNLIKELY(x) x -#endif - -/*! -@brief macro to briefly define a mapping between an enum and JSON -@def NLOHMANN_JSON_SERIALIZE_ENUM -@since version 3.4.0 -*/ -#define NLOHMANN_JSON_SERIALIZE_ENUM(ENUM_TYPE, ...) \ - template \ - inline void to_json(BasicJsonType& j, const ENUM_TYPE& e) \ - { \ - static_assert(std::is_enum::value, #ENUM_TYPE " must be an enum!"); \ - static const std::pair m[] = __VA_ARGS__; \ - auto it = std::find_if(std::begin(m), std::end(m), \ - [e](const std::pair& ej_pair) -> bool \ - { \ - return ej_pair.first == e; \ - }); \ - j = ((it != std::end(m)) ? it : std::begin(m))->second; \ - } \ - template \ - inline void from_json(const BasicJsonType& j, ENUM_TYPE& e) \ - { \ - static_assert(std::is_enum::value, #ENUM_TYPE " must be an enum!"); \ - static const std::pair m[] = __VA_ARGS__; \ - auto it = std::find_if(std::begin(m), std::end(m), \ - [j](const std::pair& ej_pair) -> bool \ - { \ - return ej_pair.second == j; \ - }); \ - e = ((it != std::end(m)) ? it : std::begin(m))->first; \ - } - -// Ugly macros to avoid uglier copy-paste when specializing basic_json. They -// may be removed in the future once the class is split. - -#define NLOHMANN_BASIC_JSON_TPL_DECLARATION \ - template class ObjectType, \ - template class ArrayType, \ - class StringType, class BooleanType, class NumberIntegerType, \ - class NumberUnsignedType, class NumberFloatType, \ - template class AllocatorType, \ - template class JSONSerializer> - -#define NLOHMANN_BASIC_JSON_TPL \ - basic_json - // #include @@ -1314,7 +2794,7 @@ namespace detail template void from_json(const BasicJsonType& j, typename std::nullptr_t& n) { - if (JSON_UNLIKELY(not j.is_null())) + if (HEDLEY_UNLIKELY(not j.is_null())) { JSON_THROW(type_error::create(302, "type must be null, but is " + std::string(j.type_name()))); } @@ -1354,7 +2834,7 @@ void get_arithmetic_value(const BasicJsonType& j, ArithmeticType& val) template void from_json(const BasicJsonType& j, typename BasicJsonType::boolean_t& b) { - if (JSON_UNLIKELY(not j.is_boolean())) + if (HEDLEY_UNLIKELY(not j.is_boolean())) { JSON_THROW(type_error::create(302, "type must be boolean, but is " + std::string(j.type_name()))); } @@ -1364,7 +2844,7 @@ void from_json(const BasicJsonType& j, typename BasicJsonType::boolean_t& b) template void from_json(const BasicJsonType& j, typename BasicJsonType::string_t& s) { - if (JSON_UNLIKELY(not j.is_string())) + if (HEDLEY_UNLIKELY(not j.is_string())) { JSON_THROW(type_error::create(302, "type must be string, but is " + std::string(j.type_name()))); } @@ -1380,7 +2860,7 @@ template < int > = 0 > void from_json(const BasicJsonType& j, ConstructibleStringType& s) { - if (JSON_UNLIKELY(not j.is_string())) + if (HEDLEY_UNLIKELY(not j.is_string())) { JSON_THROW(type_error::create(302, "type must be string, but is " + std::string(j.type_name()))); } @@ -1420,7 +2900,7 @@ template::value, int> = 0> void from_json(const BasicJsonType& j, std::forward_list& l) { - if (JSON_UNLIKELY(not j.is_array())) + if (HEDLEY_UNLIKELY(not j.is_array())) { JSON_THROW(type_error::create(302, "type must be array, but is " + std::string(j.type_name()))); } @@ -1437,7 +2917,7 @@ template::value, int> = 0> void from_json(const BasicJsonType& j, std::valarray& l) { - if (JSON_UNLIKELY(not j.is_array())) + if (HEDLEY_UNLIKELY(not j.is_array())) { JSON_THROW(type_error::create(302, "type must be array, but is " + std::string(j.type_name()))); } @@ -1524,7 +3004,7 @@ auto from_json(const BasicJsonType& j, ConstructibleArrayType& arr) j.template get(), void()) { - if (JSON_UNLIKELY(not j.is_array())) + if (HEDLEY_UNLIKELY(not j.is_array())) { JSON_THROW(type_error::create(302, "type must be array, but is " + std::string(j.type_name()))); @@ -1537,7 +3017,7 @@ template::value, int> = 0> void from_json(const BasicJsonType& j, ConstructibleObjectType& obj) { - if (JSON_UNLIKELY(not j.is_object())) + if (HEDLEY_UNLIKELY(not j.is_object())) { JSON_THROW(type_error::create(302, "type must be object, but is " + std::string(j.type_name()))); } @@ -1620,14 +3100,14 @@ template ::value>> void from_json(const BasicJsonType& j, std::map& m) { - if (JSON_UNLIKELY(not j.is_array())) + if (HEDLEY_UNLIKELY(not j.is_array())) { JSON_THROW(type_error::create(302, "type must be array, but is " + std::string(j.type_name()))); } m.clear(); for (const auto& p : j) { - if (JSON_UNLIKELY(not p.is_array())) + if (HEDLEY_UNLIKELY(not p.is_array())) { JSON_THROW(type_error::create(302, "type must be array, but is " + std::string(p.type_name()))); } @@ -1640,14 +3120,14 @@ template ::value>> void from_json(const BasicJsonType& j, std::unordered_map& m) { - if (JSON_UNLIKELY(not j.is_array())) + if (HEDLEY_UNLIKELY(not j.is_array())) { JSON_THROW(type_error::create(302, "type must be array, but is " + std::string(j.type_name()))); } m.clear(); for (const auto& p : j) { - if (JSON_UNLIKELY(not p.is_array())) + if (HEDLEY_UNLIKELY(not p.is_array())) { JSON_THROW(type_error::create(302, "type must be array, but is " + std::string(p.type_name()))); } @@ -1674,7 +3154,7 @@ namespace { constexpr const auto& from_json = detail::static_const::value; } // namespace -} // namespace nlohmann +} // namespace nlohmann // #include @@ -2196,7 +3676,7 @@ namespace { constexpr const auto& to_json = detail::static_const::value; } // namespace -} // namespace nlohmann +} // namespace nlohmann namespace nlohmann @@ -2326,6 +3806,7 @@ Input adapter for stdio file access. This adapter read only 1 byte and do not us class file_input_adapter : public input_adapter_protocol { public: + HEDLEY_NON_NULL(2) explicit file_input_adapter(std::FILE* f) noexcept : m_file(f) {} @@ -2401,6 +3882,7 @@ class input_stream_adapter : public input_adapter_protocol class input_buffer_adapter : public input_adapter_protocol { public: + HEDLEY_NON_NULL(2) input_buffer_adapter(const char* b, const std::size_t l) noexcept : cursor(b), limit(b + l) {} @@ -2414,7 +3896,7 @@ class input_buffer_adapter : public input_adapter_protocol std::char_traits::int_type get_character() noexcept override { - if (JSON_LIKELY(cursor < limit)) + if (HEDLEY_LIKELY(cursor < limit)) { return std::char_traits::to_int_type(*(cursor++)); } @@ -2604,6 +4086,7 @@ class input_adapter { public: // native support + HEDLEY_NON_NULL(2) input_adapter(std::FILE* file) : ia(std::make_shared(file)) {} /// input adapter for input stream @@ -2672,7 +4155,7 @@ class input_adapter "each element in the iterator range must have the size of 1 byte"); const auto len = static_cast(std::distance(first, last)); - if (JSON_LIKELY(len > 0)) + if (HEDLEY_LIKELY(len > 0)) { // there is at least one element: use the address of first ia = std::make_shared(reinterpret_cast(&(*first)), len); @@ -2920,7 +4403,7 @@ class json_sax_dom_parser { ref_stack.push_back(handle_value(BasicJsonType::value_t::object)); - if (JSON_UNLIKELY(len != std::size_t(-1) and len > ref_stack.back()->max_size())) + if (HEDLEY_UNLIKELY(len != std::size_t(-1) and len > ref_stack.back()->max_size())) { JSON_THROW(out_of_range::create(408, "excessive object size: " + std::to_string(len))); @@ -2946,7 +4429,7 @@ class json_sax_dom_parser { ref_stack.push_back(handle_value(BasicJsonType::value_t::array)); - if (JSON_UNLIKELY(len != std::size_t(-1) and len > ref_stack.back()->max_size())) + if (HEDLEY_UNLIKELY(len != std::size_t(-1) and len > ref_stack.back()->max_size())) { JSON_THROW(out_of_range::create(408, "excessive array size: " + std::to_string(len))); @@ -3002,6 +4485,7 @@ class json_sax_dom_parser object to which we can add elements */ template + HEDLEY_RETURNS_NON_NULL BasicJsonType* handle_value(Value&& v) { if (ref_stack.empty()) @@ -3108,7 +4592,7 @@ class json_sax_dom_callback_parser ref_stack.push_back(val.second); // check object limit - if (ref_stack.back() and JSON_UNLIKELY(len != std::size_t(-1) and len > ref_stack.back()->max_size())) + if (ref_stack.back() and HEDLEY_UNLIKELY(len != std::size_t(-1) and len > ref_stack.back()->max_size())) { JSON_THROW(out_of_range::create(408, "excessive object size: " + std::to_string(len))); } @@ -3171,7 +4655,7 @@ class json_sax_dom_callback_parser ref_stack.push_back(val.second); // check array limit - if (ref_stack.back() and JSON_UNLIKELY(len != std::size_t(-1) and len > ref_stack.back()->max_size())) + if (ref_stack.back() and HEDLEY_UNLIKELY(len != std::size_t(-1) and len > ref_stack.back()->max_size())) { JSON_THROW(out_of_range::create(408, "excessive array size: " + std::to_string(len))); } @@ -3610,6 +5094,7 @@ class binary_reader @return */ + HEDLEY_NON_NULL(3) bool sax_parse(const input_format_t format, json_sax_t* sax_, const bool strict = true) @@ -3651,7 +5136,7 @@ class binary_reader get(); } - if (JSON_UNLIKELY(current != std::char_traits::eof())) + if (HEDLEY_UNLIKELY(current != std::char_traits::eof())) { return sax->parse_error(chars_read, get_token_string(), parse_error::create(110, chars_read, exception_message(format, "expected end of input; last byte: 0x" + get_token_string(), "value"))); @@ -3687,12 +5172,12 @@ class binary_reader std::int32_t document_size; get_number(input_format_t::bson, document_size); - if (JSON_UNLIKELY(not sax->start_object(std::size_t(-1)))) + if (HEDLEY_UNLIKELY(not sax->start_object(std::size_t(-1)))) { return false; } - if (JSON_UNLIKELY(not parse_bson_element_list(/*is_array*/false))) + if (HEDLEY_UNLIKELY(not parse_bson_element_list(/*is_array*/false))) { return false; } @@ -3713,7 +5198,7 @@ class binary_reader while (true) { get(); - if (JSON_UNLIKELY(not unexpect_eof(input_format_t::bson, "cstring"))) + if (HEDLEY_UNLIKELY(not unexpect_eof(input_format_t::bson, "cstring"))) { return false; } @@ -3741,7 +5226,7 @@ class binary_reader template bool get_bson_string(const NumberType len, string_t& result) { - if (JSON_UNLIKELY(len < 1)) + if (HEDLEY_UNLIKELY(len < 1)) { auto last_token = get_token_string(); return sax->parse_error(chars_read, last_token, parse_error::create(112, chars_read, exception_message(input_format_t::bson, "string length must be at least 1, is " + std::to_string(len), "string"))); @@ -3836,13 +5321,13 @@ class binary_reader string_t key; while (int element_type = get()) { - if (JSON_UNLIKELY(not unexpect_eof(input_format_t::bson, "element list"))) + if (HEDLEY_UNLIKELY(not unexpect_eof(input_format_t::bson, "element list"))) { return false; } const std::size_t element_type_parse_position = chars_read; - if (JSON_UNLIKELY(not get_bson_cstr(key))) + if (HEDLEY_UNLIKELY(not get_bson_cstr(key))) { return false; } @@ -3852,7 +5337,7 @@ class binary_reader return false; } - if (JSON_UNLIKELY(not parse_bson_element_internal(element_type, element_type_parse_position))) + if (HEDLEY_UNLIKELY(not parse_bson_element_internal(element_type, element_type_parse_position))) { return false; } @@ -3873,12 +5358,12 @@ class binary_reader std::int32_t document_size; get_number(input_format_t::bson, document_size); - if (JSON_UNLIKELY(not sax->start_array(std::size_t(-1)))) + if (HEDLEY_UNLIKELY(not sax->start_array(std::size_t(-1)))) { return false; } - if (JSON_UNLIKELY(not parse_bson_element_list(/*is_array*/true))) + if (HEDLEY_UNLIKELY(not parse_bson_element_list(/*is_array*/true))) { return false; } @@ -4163,12 +5648,12 @@ class binary_reader case 0xF9: // Half-Precision Float (two-byte IEEE 754) { const int byte1_raw = get(); - if (JSON_UNLIKELY(not unexpect_eof(input_format_t::cbor, "number"))) + if (HEDLEY_UNLIKELY(not unexpect_eof(input_format_t::cbor, "number"))) { return false; } const int byte2_raw = get(); - if (JSON_UNLIKELY(not unexpect_eof(input_format_t::cbor, "number"))) + if (HEDLEY_UNLIKELY(not unexpect_eof(input_format_t::cbor, "number"))) { return false; } @@ -4241,7 +5726,7 @@ class binary_reader */ bool get_cbor_string(string_t& result) { - if (JSON_UNLIKELY(not unexpect_eof(input_format_t::cbor, "string"))) + if (HEDLEY_UNLIKELY(not unexpect_eof(input_format_t::cbor, "string"))) { return false; } @@ -4330,7 +5815,7 @@ class binary_reader */ bool get_cbor_array(const std::size_t len) { - if (JSON_UNLIKELY(not sax->start_array(len))) + if (HEDLEY_UNLIKELY(not sax->start_array(len))) { return false; } @@ -4339,7 +5824,7 @@ class binary_reader { for (std::size_t i = 0; i < len; ++i) { - if (JSON_UNLIKELY(not parse_cbor_internal())) + if (HEDLEY_UNLIKELY(not parse_cbor_internal())) { return false; } @@ -4349,7 +5834,7 @@ class binary_reader { while (get() != 0xFF) { - if (JSON_UNLIKELY(not parse_cbor_internal(false))) + if (HEDLEY_UNLIKELY(not parse_cbor_internal(false))) { return false; } @@ -4366,7 +5851,7 @@ class binary_reader */ bool get_cbor_object(const std::size_t len) { - if (JSON_UNLIKELY(not sax->start_object(len))) + if (HEDLEY_UNLIKELY(not sax->start_object(len))) { return false; } @@ -4377,12 +5862,12 @@ class binary_reader for (std::size_t i = 0; i < len; ++i) { get(); - if (JSON_UNLIKELY(not get_cbor_string(key) or not sax->key(key))) + if (HEDLEY_UNLIKELY(not get_cbor_string(key) or not sax->key(key))) { return false; } - if (JSON_UNLIKELY(not parse_cbor_internal())) + if (HEDLEY_UNLIKELY(not parse_cbor_internal())) { return false; } @@ -4393,12 +5878,12 @@ class binary_reader { while (get() != 0xFF) { - if (JSON_UNLIKELY(not get_cbor_string(key) or not sax->key(key))) + if (HEDLEY_UNLIKELY(not get_cbor_string(key) or not sax->key(key))) { return false; } - if (JSON_UNLIKELY(not parse_cbor_internal())) + if (HEDLEY_UNLIKELY(not parse_cbor_internal())) { return false; } @@ -4787,7 +6272,7 @@ class binary_reader */ bool get_msgpack_string(string_t& result) { - if (JSON_UNLIKELY(not unexpect_eof(input_format_t::msgpack, "string"))) + if (HEDLEY_UNLIKELY(not unexpect_eof(input_format_t::msgpack, "string"))) { return false; } @@ -4863,14 +6348,14 @@ class binary_reader */ bool get_msgpack_array(const std::size_t len) { - if (JSON_UNLIKELY(not sax->start_array(len))) + if (HEDLEY_UNLIKELY(not sax->start_array(len))) { return false; } for (std::size_t i = 0; i < len; ++i) { - if (JSON_UNLIKELY(not parse_msgpack_internal())) + if (HEDLEY_UNLIKELY(not parse_msgpack_internal())) { return false; } @@ -4885,7 +6370,7 @@ class binary_reader */ bool get_msgpack_object(const std::size_t len) { - if (JSON_UNLIKELY(not sax->start_object(len))) + if (HEDLEY_UNLIKELY(not sax->start_object(len))) { return false; } @@ -4894,12 +6379,12 @@ class binary_reader for (std::size_t i = 0; i < len; ++i) { get(); - if (JSON_UNLIKELY(not get_msgpack_string(key) or not sax->key(key))) + if (HEDLEY_UNLIKELY(not get_msgpack_string(key) or not sax->key(key))) { return false; } - if (JSON_UNLIKELY(not parse_msgpack_internal())) + if (HEDLEY_UNLIKELY(not parse_msgpack_internal())) { return false; } @@ -4946,7 +6431,7 @@ class binary_reader get(); // TODO(niels): may we ignore N here? } - if (JSON_UNLIKELY(not unexpect_eof(input_format_t::ubjson, "value"))) + if (HEDLEY_UNLIKELY(not unexpect_eof(input_format_t::ubjson, "value"))) { return false; } @@ -5000,7 +6485,7 @@ class binary_reader case 'U': { std::uint8_t number; - if (JSON_UNLIKELY(not get_number(input_format_t::ubjson, number))) + if (HEDLEY_UNLIKELY(not get_number(input_format_t::ubjson, number))) { return false; } @@ -5011,7 +6496,7 @@ class binary_reader case 'i': { std::int8_t number; - if (JSON_UNLIKELY(not get_number(input_format_t::ubjson, number))) + if (HEDLEY_UNLIKELY(not get_number(input_format_t::ubjson, number))) { return false; } @@ -5022,7 +6507,7 @@ class binary_reader case 'I': { std::int16_t number; - if (JSON_UNLIKELY(not get_number(input_format_t::ubjson, number))) + if (HEDLEY_UNLIKELY(not get_number(input_format_t::ubjson, number))) { return false; } @@ -5033,7 +6518,7 @@ class binary_reader case 'l': { std::int32_t number; - if (JSON_UNLIKELY(not get_number(input_format_t::ubjson, number))) + if (HEDLEY_UNLIKELY(not get_number(input_format_t::ubjson, number))) { return false; } @@ -5044,7 +6529,7 @@ class binary_reader case 'L': { std::int64_t number; - if (JSON_UNLIKELY(not get_number(input_format_t::ubjson, number))) + if (HEDLEY_UNLIKELY(not get_number(input_format_t::ubjson, number))) { return false; } @@ -5080,15 +6565,15 @@ class binary_reader if (current == '$') { result.second = get(); // must not ignore 'N', because 'N' maybe the type - if (JSON_UNLIKELY(not unexpect_eof(input_format_t::ubjson, "type"))) + if (HEDLEY_UNLIKELY(not unexpect_eof(input_format_t::ubjson, "type"))) { return false; } get_ignore_noop(); - if (JSON_UNLIKELY(current != '#')) + if (HEDLEY_UNLIKELY(current != '#')) { - if (JSON_UNLIKELY(not unexpect_eof(input_format_t::ubjson, "value"))) + if (HEDLEY_UNLIKELY(not unexpect_eof(input_format_t::ubjson, "value"))) { return false; } @@ -5171,11 +6656,11 @@ class binary_reader case 'C': // char { get(); - if (JSON_UNLIKELY(not unexpect_eof(input_format_t::ubjson, "char"))) + if (HEDLEY_UNLIKELY(not unexpect_eof(input_format_t::ubjson, "char"))) { return false; } - if (JSON_UNLIKELY(current > 127)) + if (HEDLEY_UNLIKELY(current > 127)) { auto last_token = get_token_string(); return sax->parse_error(chars_read, last_token, parse_error::create(113, chars_read, exception_message(input_format_t::ubjson, "byte after 'C' must be in range 0x00..0x7F; last byte: 0x" + last_token, "char"))); @@ -5210,14 +6695,14 @@ class binary_reader bool get_ubjson_array() { std::pair size_and_type; - if (JSON_UNLIKELY(not get_ubjson_size_type(size_and_type))) + if (HEDLEY_UNLIKELY(not get_ubjson_size_type(size_and_type))) { return false; } if (size_and_type.first != string_t::npos) { - if (JSON_UNLIKELY(not sax->start_array(size_and_type.first))) + if (HEDLEY_UNLIKELY(not sax->start_array(size_and_type.first))) { return false; } @@ -5228,7 +6713,7 @@ class binary_reader { for (std::size_t i = 0; i < size_and_type.first; ++i) { - if (JSON_UNLIKELY(not get_ubjson_value(size_and_type.second))) + if (HEDLEY_UNLIKELY(not get_ubjson_value(size_and_type.second))) { return false; } @@ -5239,7 +6724,7 @@ class binary_reader { for (std::size_t i = 0; i < size_and_type.first; ++i) { - if (JSON_UNLIKELY(not parse_ubjson_internal())) + if (HEDLEY_UNLIKELY(not parse_ubjson_internal())) { return false; } @@ -5248,14 +6733,14 @@ class binary_reader } else { - if (JSON_UNLIKELY(not sax->start_array(std::size_t(-1)))) + if (HEDLEY_UNLIKELY(not sax->start_array(std::size_t(-1)))) { return false; } while (current != ']') { - if (JSON_UNLIKELY(not parse_ubjson_internal(false))) + if (HEDLEY_UNLIKELY(not parse_ubjson_internal(false))) { return false; } @@ -5272,7 +6757,7 @@ class binary_reader bool get_ubjson_object() { std::pair size_and_type; - if (JSON_UNLIKELY(not get_ubjson_size_type(size_and_type))) + if (HEDLEY_UNLIKELY(not get_ubjson_size_type(size_and_type))) { return false; } @@ -5280,7 +6765,7 @@ class binary_reader string_t key; if (size_and_type.first != string_t::npos) { - if (JSON_UNLIKELY(not sax->start_object(size_and_type.first))) + if (HEDLEY_UNLIKELY(not sax->start_object(size_and_type.first))) { return false; } @@ -5289,11 +6774,11 @@ class binary_reader { for (std::size_t i = 0; i < size_and_type.first; ++i) { - if (JSON_UNLIKELY(not get_ubjson_string(key) or not sax->key(key))) + if (HEDLEY_UNLIKELY(not get_ubjson_string(key) or not sax->key(key))) { return false; } - if (JSON_UNLIKELY(not get_ubjson_value(size_and_type.second))) + if (HEDLEY_UNLIKELY(not get_ubjson_value(size_and_type.second))) { return false; } @@ -5304,11 +6789,11 @@ class binary_reader { for (std::size_t i = 0; i < size_and_type.first; ++i) { - if (JSON_UNLIKELY(not get_ubjson_string(key) or not sax->key(key))) + if (HEDLEY_UNLIKELY(not get_ubjson_string(key) or not sax->key(key))) { return false; } - if (JSON_UNLIKELY(not parse_ubjson_internal())) + if (HEDLEY_UNLIKELY(not parse_ubjson_internal())) { return false; } @@ -5318,18 +6803,18 @@ class binary_reader } else { - if (JSON_UNLIKELY(not sax->start_object(std::size_t(-1)))) + if (HEDLEY_UNLIKELY(not sax->start_object(std::size_t(-1)))) { return false; } while (current != '}') { - if (JSON_UNLIKELY(not get_ubjson_string(key, false) or not sax->key(key))) + if (HEDLEY_UNLIKELY(not get_ubjson_string(key, false) or not sax->key(key))) { return false; } - if (JSON_UNLIKELY(not parse_ubjson_internal())) + if (HEDLEY_UNLIKELY(not parse_ubjson_internal())) { return false; } @@ -5395,7 +6880,7 @@ class binary_reader for (std::size_t i = 0; i < sizeof(NumberType); ++i) { get(); - if (JSON_UNLIKELY(not unexpect_eof(format, "number"))) + if (HEDLEY_UNLIKELY(not unexpect_eof(format, "number"))) { return false; } @@ -5439,7 +6924,7 @@ class binary_reader std::generate_n(std::back_inserter(result), len, [this, &success, &format]() { get(); - if (JSON_UNLIKELY(not unexpect_eof(format, "string"))) + if (HEDLEY_UNLIKELY(not unexpect_eof(format, "string"))) { success = false; } @@ -5453,9 +6938,10 @@ class binary_reader @param[in] context further context information (for diagnostics) @return whether the last read character is not EOF */ + HEDLEY_NON_NULL(3) bool unexpect_eof(const input_format_t format, const char* context) const { - if (JSON_UNLIKELY(current == std::char_traits::eof())) + if (HEDLEY_UNLIKELY(current == std::char_traits::eof())) { return sax->parse_error(chars_read, "", parse_error::create(110, chars_read, exception_message(format, "unexpected end of input", context))); @@ -5596,6 +7082,7 @@ class lexer }; /// return name of values of type token_type (only used for errors) + HEDLEY_RETURNS_NON_NULL static const char* token_type_name(const token_type t) noexcept { switch (t) @@ -5737,7 +7224,7 @@ class lexer for (auto range = ranges.begin(); range != ranges.end(); ++range) { get(); - if (JSON_LIKELY(*range <= current and current <= *(++range))) + if (HEDLEY_LIKELY(*range <= current and current <= *(++range))) { add(current); } @@ -5836,7 +7323,7 @@ class lexer const int codepoint1 = get_codepoint(); int codepoint = codepoint1; // start with codepoint1 - if (JSON_UNLIKELY(codepoint1 == -1)) + if (HEDLEY_UNLIKELY(codepoint1 == -1)) { error_message = "invalid string: '\\u' must be followed by 4 hex digits"; return token_type::parse_error; @@ -5846,18 +7333,18 @@ class lexer if (0xD800 <= codepoint1 and codepoint1 <= 0xDBFF) { // expect next \uxxxx entry - if (JSON_LIKELY(get() == '\\' and get() == 'u')) + if (HEDLEY_LIKELY(get() == '\\' and get() == 'u')) { const int codepoint2 = get_codepoint(); - if (JSON_UNLIKELY(codepoint2 == -1)) + if (HEDLEY_UNLIKELY(codepoint2 == -1)) { error_message = "invalid string: '\\u' must be followed by 4 hex digits"; return token_type::parse_error; } // check if codepoint2 is a low surrogate - if (JSON_LIKELY(0xDC00 <= codepoint2 and codepoint2 <= 0xDFFF)) + if (HEDLEY_LIKELY(0xDC00 <= codepoint2 and codepoint2 <= 0xDFFF)) { // overwrite codepoint codepoint = static_cast( @@ -5884,7 +7371,7 @@ class lexer } else { - if (JSON_UNLIKELY(0xDC00 <= codepoint1 and codepoint1 <= 0xDFFF)) + if (HEDLEY_UNLIKELY(0xDC00 <= codepoint1 and codepoint1 <= 0xDFFF)) { error_message = "invalid string: surrogate U+DC00..U+DFFF must follow U+D800..U+DBFF"; return token_type::parse_error; @@ -6259,7 +7746,7 @@ class lexer case 0xDE: case 0xDF: { - if (JSON_UNLIKELY(not next_byte_in_range({0x80, 0xBF}))) + if (HEDLEY_UNLIKELY(not next_byte_in_range({0x80, 0xBF}))) { return token_type::parse_error; } @@ -6269,7 +7756,7 @@ class lexer // U+0800..U+0FFF: bytes E0 A0..BF 80..BF case 0xE0: { - if (JSON_UNLIKELY(not (next_byte_in_range({0xA0, 0xBF, 0x80, 0xBF})))) + if (HEDLEY_UNLIKELY(not (next_byte_in_range({0xA0, 0xBF, 0x80, 0xBF})))) { return token_type::parse_error; } @@ -6293,7 +7780,7 @@ class lexer case 0xEE: case 0xEF: { - if (JSON_UNLIKELY(not (next_byte_in_range({0x80, 0xBF, 0x80, 0xBF})))) + if (HEDLEY_UNLIKELY(not (next_byte_in_range({0x80, 0xBF, 0x80, 0xBF})))) { return token_type::parse_error; } @@ -6303,7 +7790,7 @@ class lexer // U+D000..U+D7FF: bytes ED 80..9F 80..BF case 0xED: { - if (JSON_UNLIKELY(not (next_byte_in_range({0x80, 0x9F, 0x80, 0xBF})))) + if (HEDLEY_UNLIKELY(not (next_byte_in_range({0x80, 0x9F, 0x80, 0xBF})))) { return token_type::parse_error; } @@ -6313,7 +7800,7 @@ class lexer // U+10000..U+3FFFF F0 90..BF 80..BF 80..BF case 0xF0: { - if (JSON_UNLIKELY(not (next_byte_in_range({0x90, 0xBF, 0x80, 0xBF, 0x80, 0xBF})))) + if (HEDLEY_UNLIKELY(not (next_byte_in_range({0x90, 0xBF, 0x80, 0xBF, 0x80, 0xBF})))) { return token_type::parse_error; } @@ -6325,7 +7812,7 @@ class lexer case 0xF2: case 0xF3: { - if (JSON_UNLIKELY(not (next_byte_in_range({0x80, 0xBF, 0x80, 0xBF, 0x80, 0xBF})))) + if (HEDLEY_UNLIKELY(not (next_byte_in_range({0x80, 0xBF, 0x80, 0xBF, 0x80, 0xBF})))) { return token_type::parse_error; } @@ -6335,7 +7822,7 @@ class lexer // U+100000..U+10FFFF F4 80..8F 80..BF 80..BF case 0xF4: { - if (JSON_UNLIKELY(not (next_byte_in_range({0x80, 0x8F, 0x80, 0xBF, 0x80, 0xBF})))) + if (HEDLEY_UNLIKELY(not (next_byte_in_range({0x80, 0x8F, 0x80, 0xBF, 0x80, 0xBF})))) { return token_type::parse_error; } @@ -6352,16 +7839,19 @@ class lexer } } + HEDLEY_NON_NULL(2) static void strtof(float& f, const char* str, char** endptr) noexcept { f = std::strtof(str, endptr); } + HEDLEY_NON_NULL(2) static void strtof(double& f, const char* str, char** endptr) noexcept { f = std::strtod(str, endptr); } + HEDLEY_NON_NULL(2) static void strtof(long double& f, const char* str, char** endptr) noexcept { f = std::strtold(str, endptr); @@ -6737,13 +8227,14 @@ scan_number_done: @param[in] length the length of the passed literal text @param[in] return_type the token type to return on success */ + HEDLEY_NON_NULL(2) token_type scan_literal(const char* literal_text, const std::size_t length, token_type return_type) { assert(current == literal_text[0]); for (std::size_t i = 1; i < length; ++i) { - if (JSON_UNLIKELY(get() != literal_text[i])) + if (HEDLEY_UNLIKELY(get() != literal_text[i])) { error_message = "invalid literal"; return token_type::parse_error; @@ -6789,7 +8280,7 @@ scan_number_done: current = ia->get_character(); } - if (JSON_LIKELY(current != std::char_traits::eof())) + if (HEDLEY_LIKELY(current != std::char_traits::eof())) { token_string.push_back(std::char_traits::to_char_type(current)); } @@ -6830,7 +8321,7 @@ scan_number_done: --position.chars_read_current_line; } - if (JSON_LIKELY(current != std::char_traits::eof())) + if (HEDLEY_LIKELY(current != std::char_traits::eof())) { assert(not token_string.empty()); token_string.pop_back(); @@ -6909,6 +8400,7 @@ scan_number_done: } /// return syntax error message + HEDLEY_RETURNS_NON_NULL constexpr const char* get_error_message() const noexcept { return error_message; @@ -7197,6 +8689,7 @@ class parser } template + HEDLEY_NON_NULL(2) bool sax_parse(SAX* sax, const bool strict = true) { (void)detail::is_sax_static_asserts {}; @@ -7216,6 +8709,7 @@ class parser private: template + HEDLEY_NON_NULL(2) bool sax_parse_internal(SAX* sax) { // stack to remember the hierarchy of structured values we are parsing @@ -7233,7 +8727,7 @@ class parser { case token_type::begin_object: { - if (JSON_UNLIKELY(not sax->start_object(std::size_t(-1)))) + if (HEDLEY_UNLIKELY(not sax->start_object(std::size_t(-1)))) { return false; } @@ -7241,7 +8735,7 @@ class parser // closing } -> we are done if (get_token() == token_type::end_object) { - if (JSON_UNLIKELY(not sax->end_object())) + if (HEDLEY_UNLIKELY(not sax->end_object())) { return false; } @@ -7249,20 +8743,20 @@ class parser } // parse key - if (JSON_UNLIKELY(last_token != token_type::value_string)) + if (HEDLEY_UNLIKELY(last_token != token_type::value_string)) { return sax->parse_error(m_lexer.get_position(), m_lexer.get_token_string(), parse_error::create(101, m_lexer.get_position(), exception_message(token_type::value_string, "object key"))); } - if (JSON_UNLIKELY(not sax->key(m_lexer.get_string()))) + if (HEDLEY_UNLIKELY(not sax->key(m_lexer.get_string()))) { return false; } // parse separator (:) - if (JSON_UNLIKELY(get_token() != token_type::name_separator)) + if (HEDLEY_UNLIKELY(get_token() != token_type::name_separator)) { return sax->parse_error(m_lexer.get_position(), m_lexer.get_token_string(), @@ -7280,7 +8774,7 @@ class parser case token_type::begin_array: { - if (JSON_UNLIKELY(not sax->start_array(std::size_t(-1)))) + if (HEDLEY_UNLIKELY(not sax->start_array(std::size_t(-1)))) { return false; } @@ -7288,7 +8782,7 @@ class parser // closing ] -> we are done if (get_token() == token_type::end_array) { - if (JSON_UNLIKELY(not sax->end_array())) + if (HEDLEY_UNLIKELY(not sax->end_array())) { return false; } @@ -7306,14 +8800,14 @@ class parser { const auto res = m_lexer.get_number_float(); - if (JSON_UNLIKELY(not std::isfinite(res))) + if (HEDLEY_UNLIKELY(not std::isfinite(res))) { return sax->parse_error(m_lexer.get_position(), m_lexer.get_token_string(), out_of_range::create(406, "number overflow parsing '" + m_lexer.get_token_string() + "'")); } - if (JSON_UNLIKELY(not sax->number_float(res, m_lexer.get_string()))) + if (HEDLEY_UNLIKELY(not sax->number_float(res, m_lexer.get_string()))) { return false; } @@ -7323,7 +8817,7 @@ class parser case token_type::literal_false: { - if (JSON_UNLIKELY(not sax->boolean(false))) + if (HEDLEY_UNLIKELY(not sax->boolean(false))) { return false; } @@ -7332,7 +8826,7 @@ class parser case token_type::literal_null: { - if (JSON_UNLIKELY(not sax->null())) + if (HEDLEY_UNLIKELY(not sax->null())) { return false; } @@ -7341,7 +8835,7 @@ class parser case token_type::literal_true: { - if (JSON_UNLIKELY(not sax->boolean(true))) + if (HEDLEY_UNLIKELY(not sax->boolean(true))) { return false; } @@ -7350,7 +8844,7 @@ class parser case token_type::value_integer: { - if (JSON_UNLIKELY(not sax->number_integer(m_lexer.get_number_integer()))) + if (HEDLEY_UNLIKELY(not sax->number_integer(m_lexer.get_number_integer()))) { return false; } @@ -7359,7 +8853,7 @@ class parser case token_type::value_string: { - if (JSON_UNLIKELY(not sax->string(m_lexer.get_string()))) + if (HEDLEY_UNLIKELY(not sax->string(m_lexer.get_string()))) { return false; } @@ -7368,7 +8862,7 @@ class parser case token_type::value_unsigned: { - if (JSON_UNLIKELY(not sax->number_unsigned(m_lexer.get_number_unsigned()))) + if (HEDLEY_UNLIKELY(not sax->number_unsigned(m_lexer.get_number_unsigned()))) { return false; } @@ -7416,9 +8910,9 @@ class parser } // closing ] - if (JSON_LIKELY(last_token == token_type::end_array)) + if (HEDLEY_LIKELY(last_token == token_type::end_array)) { - if (JSON_UNLIKELY(not sax->end_array())) + if (HEDLEY_UNLIKELY(not sax->end_array())) { return false; } @@ -7444,7 +8938,7 @@ class parser if (get_token() == token_type::value_separator) { // parse key - if (JSON_UNLIKELY(get_token() != token_type::value_string)) + if (HEDLEY_UNLIKELY(get_token() != token_type::value_string)) { return sax->parse_error(m_lexer.get_position(), m_lexer.get_token_string(), @@ -7452,13 +8946,13 @@ class parser exception_message(token_type::value_string, "object key"))); } - if (JSON_UNLIKELY(not sax->key(m_lexer.get_string()))) + if (HEDLEY_UNLIKELY(not sax->key(m_lexer.get_string()))) { return false; } // parse separator (:) - if (JSON_UNLIKELY(get_token() != token_type::name_separator)) + if (HEDLEY_UNLIKELY(get_token() != token_type::name_separator)) { return sax->parse_error(m_lexer.get_position(), m_lexer.get_token_string(), @@ -7472,9 +8966,9 @@ class parser } // closing } - if (JSON_LIKELY(last_token == token_type::end_object)) + if (HEDLEY_LIKELY(last_token == token_type::end_object)) { - if (JSON_UNLIKELY(not sax->end_object())) + if (HEDLEY_UNLIKELY(not sax->end_object())) { return false; } @@ -7829,7 +9323,8 @@ class iter_impl information refer to: https://github.com/nlohmann/json/issues/1608 */ iter_impl(const iter_impl& other) noexcept - : m_object(other.m_object), m_it(other.m_it) {} + : m_object(other.m_object), m_it(other.m_it) + {} /*! @brief converting constructor @@ -7837,7 +9332,8 @@ class iter_impl @note It is not checked whether @a other is initialized. */ iter_impl(const iter_impl::type>& other) noexcept - : m_object(other.m_object), m_it(other.m_it) {} + : m_object(other.m_object), m_it(other.m_it) + {} /*! @brief converting assignment @@ -7852,6 +9348,14 @@ class iter_impl return *this; } + /// @copydoc operator=(const iter_impl::type>&) + iter_impl& operator=(const iter_impl& other) noexcept + { + m_object = other.m_object; + m_it = other.m_it; + return *this; + } + private: /*! @brief set the iterator to the first value @@ -7948,7 +9452,7 @@ class iter_impl default: { - if (JSON_LIKELY(m_it.primitive_iterator.is_begin())) + if (HEDLEY_LIKELY(m_it.primitive_iterator.is_begin())) { return *m_object; } @@ -7982,7 +9486,7 @@ class iter_impl default: { - if (JSON_LIKELY(m_it.primitive_iterator.is_begin())) + if (HEDLEY_LIKELY(m_it.primitive_iterator.is_begin())) { return m_object; } @@ -8085,7 +9589,7 @@ class iter_impl bool operator==(const iter_impl& other) const { // if objects are not the same, the comparison is undefined - if (JSON_UNLIKELY(m_object != other.m_object)) + if (HEDLEY_UNLIKELY(m_object != other.m_object)) { JSON_THROW(invalid_iterator::create(212, "cannot compare iterators of different containers")); } @@ -8121,7 +9625,7 @@ class iter_impl bool operator<(const iter_impl& other) const { // if objects are not the same, the comparison is undefined - if (JSON_UNLIKELY(m_object != other.m_object)) + if (HEDLEY_UNLIKELY(m_object != other.m_object)) { JSON_THROW(invalid_iterator::create(212, "cannot compare iterators of different containers")); } @@ -8281,7 +9785,7 @@ class iter_impl default: { - if (JSON_LIKELY(m_it.primitive_iterator.get_value() == -n)) + if (HEDLEY_LIKELY(m_it.primitive_iterator.get_value() == -n)) { return *m_object; } @@ -8299,7 +9803,7 @@ class iter_impl { assert(m_object != nullptr); - if (JSON_LIKELY(m_object->is_object())) + if (HEDLEY_LIKELY(m_object->is_object())) { return m_it.object_iterator->first; } @@ -8322,7 +9826,7 @@ class iter_impl /// the actual iterator of the associated instance internal_iterator::type> m_it {}; }; -} // namespace detail +} // namespace detail } // namespace nlohmann // #include @@ -8700,7 +10204,7 @@ class json_pointer */ void pop_back() { - if (JSON_UNLIKELY(empty())) + if (HEDLEY_UNLIKELY(empty())) { JSON_THROW(detail::out_of_range::create(405, "JSON pointer has no parent")); } @@ -8724,7 +10228,7 @@ class json_pointer */ const std::string& back() { - if (JSON_UNLIKELY(empty())) + if (HEDLEY_UNLIKELY(empty())) { JSON_THROW(detail::out_of_range::create(405, "JSON pointer has no parent")); } @@ -8788,7 +10292,7 @@ class json_pointer const int res = std::stoi(s, &processed_chars); // check if the string was completely read - if (JSON_UNLIKELY(processed_chars != s.size())) + if (HEDLEY_UNLIKELY(processed_chars != s.size())) { JSON_THROW(detail::out_of_range::create(404, "unresolved reference token '" + s + "'")); } @@ -8798,7 +10302,7 @@ class json_pointer json_pointer top() const { - if (JSON_UNLIKELY(empty())) + if (HEDLEY_UNLIKELY(empty())) { JSON_THROW(detail::out_of_range::create(405, "JSON pointer has no parent")); } @@ -8930,7 +10434,7 @@ class json_pointer case detail::value_t::array: { // error condition (cf. RFC 6901, Sect. 4) - if (JSON_UNLIKELY(reference_token.size() > 1 and reference_token[0] == '0')) + if (HEDLEY_UNLIKELY(reference_token.size() > 1 and reference_token[0] == '0')) { JSON_THROW(detail::parse_error::create(106, 0, "array index '" + reference_token + @@ -8988,7 +10492,7 @@ class json_pointer case detail::value_t::array: { - if (JSON_UNLIKELY(reference_token == "-")) + if (HEDLEY_UNLIKELY(reference_token == "-")) { // "-" always fails the range check JSON_THROW(detail::out_of_range::create(402, @@ -8997,7 +10501,7 @@ class json_pointer } // error condition (cf. RFC 6901, Sect. 4) - if (JSON_UNLIKELY(reference_token.size() > 1 and reference_token[0] == '0')) + if (HEDLEY_UNLIKELY(reference_token.size() > 1 and reference_token[0] == '0')) { JSON_THROW(detail::parse_error::create(106, 0, "array index '" + reference_token + @@ -9053,7 +10557,7 @@ class json_pointer case detail::value_t::array: { - if (JSON_UNLIKELY(reference_token == "-")) + if (HEDLEY_UNLIKELY(reference_token == "-")) { // "-" cannot be used for const access JSON_THROW(detail::out_of_range::create(402, @@ -9062,7 +10566,7 @@ class json_pointer } // error condition (cf. RFC 6901, Sect. 4) - if (JSON_UNLIKELY(reference_token.size() > 1 and reference_token[0] == '0')) + if (HEDLEY_UNLIKELY(reference_token.size() > 1 and reference_token[0] == '0')) { JSON_THROW(detail::parse_error::create(106, 0, "array index '" + reference_token + @@ -9112,7 +10616,7 @@ class json_pointer case detail::value_t::array: { - if (JSON_UNLIKELY(reference_token == "-")) + if (HEDLEY_UNLIKELY(reference_token == "-")) { // "-" always fails the range check JSON_THROW(detail::out_of_range::create(402, @@ -9121,7 +10625,7 @@ class json_pointer } // error condition (cf. RFC 6901, Sect. 4) - if (JSON_UNLIKELY(reference_token.size() > 1 and reference_token[0] == '0')) + if (HEDLEY_UNLIKELY(reference_token.size() > 1 and reference_token[0] == '0')) { JSON_THROW(detail::parse_error::create(106, 0, "array index '" + reference_token + @@ -9168,7 +10672,7 @@ class json_pointer } // check if nonempty reference string begins with slash - if (JSON_UNLIKELY(reference_string[0] != '/')) + if (HEDLEY_UNLIKELY(reference_string[0] != '/')) { JSON_THROW(detail::parse_error::create(107, 1, "JSON pointer must be empty or begin with '/' - was: '" + @@ -9203,9 +10707,9 @@ class json_pointer assert(reference_token[pos] == '~'); // ~ must be followed by 0 or 1 - if (JSON_UNLIKELY(pos == reference_token.size() - 1 or - (reference_token[pos + 1] != '0' and - reference_token[pos + 1] != '1'))) + if (HEDLEY_UNLIKELY(pos == reference_token.size() - 1 or + (reference_token[pos + 1] != '0' and + reference_token[pos + 1] != '1'))) { JSON_THROW(detail::parse_error::create(108, 0, "escape character '~' must be followed with '0' or '1'")); } @@ -9330,7 +10834,7 @@ class json_pointer static BasicJsonType unflatten(const BasicJsonType& value) { - if (JSON_UNLIKELY(not value.is_object())) + if (HEDLEY_UNLIKELY(not value.is_object())) { JSON_THROW(detail::type_error::create(314, "only objects can be unflattened")); } @@ -9340,7 +10844,7 @@ class json_pointer // iterate the JSON object values for (const auto& element : *value.m_value.object) { - if (JSON_UNLIKELY(not element.second.is_primitive())) + if (HEDLEY_UNLIKELY(not element.second.is_primitive())) { JSON_THROW(detail::type_error::create(315, "values in object must be primitive")); } @@ -9484,6 +10988,8 @@ class json_ref // #include +// #include + // #include @@ -9495,6 +11001,8 @@ class json_ref #include // basic_ostream #include // basic_string #include // vector +// #include + namespace nlohmann { @@ -9526,6 +11034,7 @@ class output_vector_adapter : public output_adapter_protocol v.push_back(c); } + HEDLEY_NON_NULL(2) void write_characters(const CharType* s, std::size_t length) override { std::copy(s, s + length, std::back_inserter(v)); @@ -9549,6 +11058,7 @@ class output_stream_adapter : public output_adapter_protocol stream.put(c); } + HEDLEY_NON_NULL(2) void write_characters(const CharType* s, std::size_t length) override { stream.write(s, static_cast(length)); @@ -9572,6 +11082,7 @@ class output_string_adapter : public output_adapter_protocol str.push_back(c); } + HEDLEY_NON_NULL(2) void write_characters(const CharType* s, std::size_t length) override { str.append(s, length); @@ -10310,7 +11821,7 @@ class binary_writer static std::size_t calc_bson_entry_header_size(const string_t& name) { const auto it = name.find(static_cast(0)); - if (JSON_UNLIKELY(it != BasicJsonType::string_t::npos)) + if (HEDLEY_UNLIKELY(it != BasicJsonType::string_t::npos)) { JSON_THROW(out_of_range::create(409, "BSON key cannot contain code point U+0000 (at byte " + std::to_string(it) + ")")); @@ -10960,6 +12471,8 @@ class binary_writer #include // memcpy, memmove #include // numeric_limits #include // conditional +// #include + namespace nlohmann { @@ -11770,6 +13283,7 @@ v = buf * 10^decimal_exponent len is the length of the buffer (number of decimal digits) The buffer must be large enough, i.e. >= max_digits10. */ +HEDLEY_NON_NULL(1) inline void grisu2(char* buf, int& len, int& decimal_exponent, diyfp m_minus, diyfp v, diyfp m_plus) { @@ -11829,6 +13343,7 @@ len is the length of the buffer (number of decimal digits) The buffer must be large enough, i.e. >= max_digits10. */ template +HEDLEY_NON_NULL(1) void grisu2(char* buf, int& len, int& decimal_exponent, FloatType value) { static_assert(diyfp::kPrecision >= std::numeric_limits::digits + 3, @@ -11867,6 +13382,8 @@ void grisu2(char* buf, int& len, int& decimal_exponent, FloatType value) @return a pointer to the element following the exponent. @pre -1000 < e < 1000 */ +HEDLEY_NON_NULL(1) +HEDLEY_RETURNS_NON_NULL inline char* append_exponent(char* buf, int e) { assert(e > -1000); @@ -11917,6 +13434,8 @@ notation. Otherwise it will be printed in exponential notation. @pre min_exp < 0 @pre max_exp > 0 */ +HEDLEY_NON_NULL(1) +HEDLEY_RETURNS_NON_NULL inline char* format_buffer(char* buf, int len, int decimal_exponent, int min_exp, int max_exp) { @@ -12000,6 +13519,8 @@ format. Returns an iterator pointing past-the-end of the decimal representation. @note The result is NOT null-terminated. */ template +HEDLEY_NON_NULL(1, 2) +HEDLEY_RETURNS_NON_NULL char* to_chars(char* first, const char* last, FloatType value) { static_cast(last); // maybe unused - fix warning @@ -12149,7 +13670,7 @@ class serializer // variable to hold indentation for recursive calls const auto new_indent = current_indent + indent_step; - if (JSON_UNLIKELY(indent_string.size() < new_indent)) + if (HEDLEY_UNLIKELY(indent_string.size() < new_indent)) { indent_string.resize(indent_string.size() * 2, ' '); } @@ -12222,7 +13743,7 @@ class serializer // variable to hold indentation for recursive calls const auto new_indent = current_indent + indent_step; - if (JSON_UNLIKELY(indent_string.size() < new_indent)) + if (HEDLEY_UNLIKELY(indent_string.size() < new_indent)) { indent_string.resize(indent_string.size() * 2, ' '); } @@ -12537,7 +14058,7 @@ class serializer } // we finished processing the string - if (JSON_LIKELY(state == UTF8_ACCEPT)) + if (HEDLEY_LIKELY(state == UTF8_ACCEPT)) { // write buffer if (bytes > 0) @@ -13130,7 +14651,7 @@ class basic_json @since 2.1.0 */ - JSON_NODISCARD + HEDLEY_WARN_UNUSED_RESULT static basic_json meta() { basic_json result; @@ -13635,6 +15156,7 @@ class basic_json /// helper for exception-safe object creation template + HEDLEY_RETURNS_NON_NULL static T* create(Args&& ... args) { AllocatorType alloc; @@ -13761,7 +15283,7 @@ class basic_json default: { object = nullptr; // silence warning, see #821 - if (JSON_UNLIKELY(t == value_t::null)) + if (HEDLEY_UNLIKELY(t == value_t::null)) { JSON_THROW(other_error::create(500, "961c151d2e87f2686a955a9be24d316f1362bf21 3.6.1")); // LCOV_EXCL_LINE } @@ -14238,7 +15760,7 @@ class basic_json } // if object is wanted but impossible, throw an exception - if (JSON_UNLIKELY(manual_type == value_t::object and not is_an_object)) + if (HEDLEY_UNLIKELY(manual_type == value_t::object and not is_an_object)) { JSON_THROW(type_error::create(301, "cannot create object from initializer list")); } @@ -14305,7 +15827,7 @@ class basic_json @since version 1.0.0 */ - JSON_NODISCARD + HEDLEY_WARN_UNUSED_RESULT static basic_json array(initializer_list_t init = {}) { return basic_json(init, false, value_t::array); @@ -14349,7 +15871,7 @@ class basic_json @since version 1.0.0 */ - JSON_NODISCARD + HEDLEY_WARN_UNUSED_RESULT static basic_json object(initializer_list_t init = {}) { return basic_json(init, false, value_t::object); @@ -14448,7 +15970,7 @@ class basic_json assert(last.m_object != nullptr); // make sure iterator fits the current value - if (JSON_UNLIKELY(first.m_object != last.m_object)) + if (HEDLEY_UNLIKELY(first.m_object != last.m_object)) { JSON_THROW(invalid_iterator::create(201, "iterators are not compatible")); } @@ -14465,8 +15987,8 @@ class basic_json case value_t::number_unsigned: case value_t::string: { - if (JSON_UNLIKELY(not first.m_it.primitive_iterator.is_begin() - or not last.m_it.primitive_iterator.is_end())) + if (HEDLEY_UNLIKELY(not first.m_it.primitive_iterator.is_begin() + or not last.m_it.primitive_iterator.is_end())) { JSON_THROW(invalid_iterator::create(204, "iterators out of range")); } @@ -15179,7 +16701,7 @@ class basic_json /// get a boolean (explicit) boolean_t get_impl(boolean_t* /*unused*/) const { - if (JSON_LIKELY(is_boolean())) + if (HEDLEY_LIKELY(is_boolean())) { return m_value.boolean; } @@ -15288,7 +16810,7 @@ class basic_json // delegate the call to get_ptr<>() auto ptr = obj.template get_ptr::type>(); - if (JSON_LIKELY(ptr != nullptr)) + if (HEDLEY_LIKELY(ptr != nullptr)) { return *ptr; } @@ -15739,7 +17261,7 @@ class basic_json reference at(size_type idx) { // at only works for arrays - if (JSON_LIKELY(is_array())) + if (HEDLEY_LIKELY(is_array())) { JSON_TRY { @@ -15786,7 +17308,7 @@ class basic_json const_reference at(size_type idx) const { // at only works for arrays - if (JSON_LIKELY(is_array())) + if (HEDLEY_LIKELY(is_array())) { JSON_TRY { @@ -15837,7 +17359,7 @@ class basic_json reference at(const typename object_t::key_type& key) { // at only works for objects - if (JSON_LIKELY(is_object())) + if (HEDLEY_LIKELY(is_object())) { JSON_TRY { @@ -15888,7 +17410,7 @@ class basic_json const_reference at(const typename object_t::key_type& key) const { // at only works for objects - if (JSON_LIKELY(is_object())) + if (HEDLEY_LIKELY(is_object())) { JSON_TRY { @@ -15942,7 +17464,7 @@ class basic_json } // operator[] only works for arrays - if (JSON_LIKELY(is_array())) + if (HEDLEY_LIKELY(is_array())) { // fill up array with null values if given idx is outside range if (idx >= m_value.array->size()) @@ -15980,7 +17502,7 @@ class basic_json const_reference operator[](size_type idx) const { // const operator[] only works for arrays - if (JSON_LIKELY(is_array())) + if (HEDLEY_LIKELY(is_array())) { return m_value.array->operator[](idx); } @@ -16026,7 +17548,7 @@ class basic_json } // operator[] only works for objects - if (JSON_LIKELY(is_object())) + if (HEDLEY_LIKELY(is_object())) { return m_value.object->operator[](key); } @@ -16067,7 +17589,7 @@ class basic_json const_reference operator[](const typename object_t::key_type& key) const { // const operator[] only works for objects - if (JSON_LIKELY(is_object())) + if (HEDLEY_LIKELY(is_object())) { assert(m_value.object->find(key) != m_value.object->end()); return m_value.object->find(key)->second; @@ -16104,6 +17626,7 @@ class basic_json @since version 1.1.0 */ template + HEDLEY_NON_NULL(2) reference operator[](T* key) { // implicitly convert null to object @@ -16115,7 +17638,7 @@ class basic_json } // at only works for objects - if (JSON_LIKELY(is_object())) + if (HEDLEY_LIKELY(is_object())) { return m_value.object->operator[](key); } @@ -16154,10 +17677,11 @@ class basic_json @since version 1.1.0 */ template + HEDLEY_NON_NULL(2) const_reference operator[](T* key) const { // at only works for objects - if (JSON_LIKELY(is_object())) + if (HEDLEY_LIKELY(is_object())) { assert(m_value.object->find(key) != m_value.object->end()); return m_value.object->find(key)->second; @@ -16221,7 +17745,7 @@ class basic_json ValueType value(const typename object_t::key_type& key, const ValueType& default_value) const { // at only works for objects - if (JSON_LIKELY(is_object())) + if (HEDLEY_LIKELY(is_object())) { // if key is found, return value and given default value otherwise const auto it = find(key); @@ -16293,7 +17817,7 @@ class basic_json ValueType value(const json_pointer& ptr, const ValueType& default_value) const { // at only works for objects - if (JSON_LIKELY(is_object())) + if (HEDLEY_LIKELY(is_object())) { // if pointer resolves a value, return it or use default value JSON_TRY @@ -16313,6 +17837,7 @@ class basic_json @brief overload for a default value of type const char* @copydoc basic_json::value(const json_pointer&, ValueType) const */ + HEDLEY_NON_NULL(3) string_t value(const json_pointer& ptr, const char* default_value) const { return value(ptr, string_t(default_value)); @@ -16457,7 +17982,7 @@ class basic_json IteratorType erase(IteratorType pos) { // make sure iterator fits the current value - if (JSON_UNLIKELY(this != pos.m_object)) + if (HEDLEY_UNLIKELY(this != pos.m_object)) { JSON_THROW(invalid_iterator::create(202, "iterator does not fit current value")); } @@ -16472,7 +17997,7 @@ class basic_json case value_t::number_unsigned: case value_t::string: { - if (JSON_UNLIKELY(not pos.m_it.primitive_iterator.is_begin())) + if (HEDLEY_UNLIKELY(not pos.m_it.primitive_iterator.is_begin())) { JSON_THROW(invalid_iterator::create(205, "iterator out of range")); } @@ -16562,7 +18087,7 @@ class basic_json IteratorType erase(IteratorType first, IteratorType last) { // make sure iterator fits the current value - if (JSON_UNLIKELY(this != first.m_object or this != last.m_object)) + if (HEDLEY_UNLIKELY(this != first.m_object or this != last.m_object)) { JSON_THROW(invalid_iterator::create(203, "iterators do not fit current value")); } @@ -16577,8 +18102,8 @@ class basic_json case value_t::number_unsigned: case value_t::string: { - if (JSON_LIKELY(not first.m_it.primitive_iterator.is_begin() - or not last.m_it.primitive_iterator.is_end())) + if (HEDLEY_LIKELY(not first.m_it.primitive_iterator.is_begin() + or not last.m_it.primitive_iterator.is_end())) { JSON_THROW(invalid_iterator::create(204, "iterators out of range")); } @@ -16649,7 +18174,7 @@ class basic_json size_type erase(const typename object_t::key_type& key) { // this erase only works for objects - if (JSON_LIKELY(is_object())) + if (HEDLEY_LIKELY(is_object())) { return m_value.object->erase(key); } @@ -16684,9 +18209,9 @@ class basic_json void erase(const size_type idx) { // this erase only works for arrays - if (JSON_LIKELY(is_array())) + if (HEDLEY_LIKELY(is_array())) { - if (JSON_UNLIKELY(idx >= size())) + if (HEDLEY_UNLIKELY(idx >= size())) { JSON_THROW(out_of_range::create(401, "array index " + std::to_string(idx) + " is out of range")); } @@ -17162,7 +18687,7 @@ class basic_json future 4.0.0 of the library. Please use @ref items() instead; that is, replace `json::iterator_wrapper(j)` with `j.items()`. */ - JSON_DEPRECATED + HEDLEY_DEPRECATED(3.1.0) static iteration_proxy iterator_wrapper(reference ref) noexcept { return ref.items(); @@ -17171,7 +18696,7 @@ class basic_json /*! @copydoc iterator_wrapper(reference) */ - JSON_DEPRECATED + HEDLEY_DEPRECATED(3.1.0) static iteration_proxy iterator_wrapper(const_reference ref) noexcept { return ref.items(); @@ -17590,7 +19115,7 @@ class basic_json void push_back(basic_json&& val) { // push_back only works for null objects or arrays - if (JSON_UNLIKELY(not(is_null() or is_array()))) + if (HEDLEY_UNLIKELY(not(is_null() or is_array()))) { JSON_THROW(type_error::create(308, "cannot use push_back() with " + std::string(type_name()))); } @@ -17627,7 +19152,7 @@ class basic_json void push_back(const basic_json& val) { // push_back only works for null objects or arrays - if (JSON_UNLIKELY(not(is_null() or is_array()))) + if (HEDLEY_UNLIKELY(not(is_null() or is_array()))) { JSON_THROW(type_error::create(308, "cannot use push_back() with " + std::string(type_name()))); } @@ -17677,7 +19202,7 @@ class basic_json void push_back(const typename object_t::value_type& val) { // push_back only works for null objects or objects - if (JSON_UNLIKELY(not(is_null() or is_object()))) + if (HEDLEY_UNLIKELY(not(is_null() or is_object()))) { JSON_THROW(type_error::create(308, "cannot use push_back() with " + std::string(type_name()))); } @@ -17778,7 +19303,7 @@ class basic_json void emplace_back(Args&& ... args) { // emplace_back only works for null objects or arrays - if (JSON_UNLIKELY(not(is_null() or is_array()))) + if (HEDLEY_UNLIKELY(not(is_null() or is_array()))) { JSON_THROW(type_error::create(311, "cannot use emplace_back() with " + std::string(type_name()))); } @@ -17826,7 +19351,7 @@ class basic_json std::pair emplace(Args&& ... args) { // emplace only works for null objects or arrays - if (JSON_UNLIKELY(not(is_null() or is_object()))) + if (HEDLEY_UNLIKELY(not(is_null() or is_object()))) { JSON_THROW(type_error::create(311, "cannot use emplace() with " + std::string(type_name()))); } @@ -17894,10 +19419,10 @@ class basic_json iterator insert(const_iterator pos, const basic_json& val) { // insert only works for arrays - if (JSON_LIKELY(is_array())) + if (HEDLEY_LIKELY(is_array())) { // check if iterator pos fits to this JSON value - if (JSON_UNLIKELY(pos.m_object != this)) + if (HEDLEY_UNLIKELY(pos.m_object != this)) { JSON_THROW(invalid_iterator::create(202, "iterator does not fit current value")); } @@ -17945,10 +19470,10 @@ class basic_json iterator insert(const_iterator pos, size_type cnt, const basic_json& val) { // insert only works for arrays - if (JSON_LIKELY(is_array())) + if (HEDLEY_LIKELY(is_array())) { // check if iterator pos fits to this JSON value - if (JSON_UNLIKELY(pos.m_object != this)) + if (HEDLEY_UNLIKELY(pos.m_object != this)) { JSON_THROW(invalid_iterator::create(202, "iterator does not fit current value")); } @@ -17993,24 +19518,24 @@ class basic_json iterator insert(const_iterator pos, const_iterator first, const_iterator last) { // insert only works for arrays - if (JSON_UNLIKELY(not is_array())) + if (HEDLEY_UNLIKELY(not is_array())) { JSON_THROW(type_error::create(309, "cannot use insert() with " + std::string(type_name()))); } // check if iterator pos fits to this JSON value - if (JSON_UNLIKELY(pos.m_object != this)) + if (HEDLEY_UNLIKELY(pos.m_object != this)) { JSON_THROW(invalid_iterator::create(202, "iterator does not fit current value")); } // check if range iterators belong to the same JSON object - if (JSON_UNLIKELY(first.m_object != last.m_object)) + if (HEDLEY_UNLIKELY(first.m_object != last.m_object)) { JSON_THROW(invalid_iterator::create(210, "iterators do not fit")); } - if (JSON_UNLIKELY(first.m_object == this)) + if (HEDLEY_UNLIKELY(first.m_object == this)) { JSON_THROW(invalid_iterator::create(211, "passed iterators may not belong to container")); } @@ -18046,13 +19571,13 @@ class basic_json iterator insert(const_iterator pos, initializer_list_t ilist) { // insert only works for arrays - if (JSON_UNLIKELY(not is_array())) + if (HEDLEY_UNLIKELY(not is_array())) { JSON_THROW(type_error::create(309, "cannot use insert() with " + std::string(type_name()))); } // check if iterator pos fits to this JSON value - if (JSON_UNLIKELY(pos.m_object != this)) + if (HEDLEY_UNLIKELY(pos.m_object != this)) { JSON_THROW(invalid_iterator::create(202, "iterator does not fit current value")); } @@ -18087,19 +19612,19 @@ class basic_json void insert(const_iterator first, const_iterator last) { // insert only works for objects - if (JSON_UNLIKELY(not is_object())) + if (HEDLEY_UNLIKELY(not is_object())) { JSON_THROW(type_error::create(309, "cannot use insert() with " + std::string(type_name()))); } // check if range iterators belong to the same JSON object - if (JSON_UNLIKELY(first.m_object != last.m_object)) + if (HEDLEY_UNLIKELY(first.m_object != last.m_object)) { JSON_THROW(invalid_iterator::create(210, "iterators do not fit")); } // passed iterators must belong to objects - if (JSON_UNLIKELY(not first.m_object->is_object())) + if (HEDLEY_UNLIKELY(not first.m_object->is_object())) { JSON_THROW(invalid_iterator::create(202, "iterators first and last must point to objects")); } @@ -18136,11 +19661,11 @@ class basic_json assert_invariant(); } - if (JSON_UNLIKELY(not is_object())) + if (HEDLEY_UNLIKELY(not is_object())) { JSON_THROW(type_error::create(312, "cannot use update() with " + std::string(type_name()))); } - if (JSON_UNLIKELY(not j.is_object())) + if (HEDLEY_UNLIKELY(not j.is_object())) { JSON_THROW(type_error::create(312, "cannot use update() with " + std::string(j.type_name()))); } @@ -18187,20 +19712,20 @@ class basic_json assert_invariant(); } - if (JSON_UNLIKELY(not is_object())) + if (HEDLEY_UNLIKELY(not is_object())) { JSON_THROW(type_error::create(312, "cannot use update() with " + std::string(type_name()))); } // check if range iterators belong to the same JSON object - if (JSON_UNLIKELY(first.m_object != last.m_object)) + if (HEDLEY_UNLIKELY(first.m_object != last.m_object)) { JSON_THROW(invalid_iterator::create(210, "iterators do not fit")); } // passed iterators must belong to objects - if (JSON_UNLIKELY(not first.m_object->is_object() - or not last.m_object->is_object())) + if (HEDLEY_UNLIKELY(not first.m_object->is_object() + or not last.m_object->is_object())) { JSON_THROW(invalid_iterator::create(202, "iterators first and last must point to objects")); } @@ -18263,7 +19788,7 @@ class basic_json void swap(array_t& other) { // swap only works for arrays - if (JSON_LIKELY(is_array())) + if (HEDLEY_LIKELY(is_array())) { std::swap(*(m_value.array), other); } @@ -18296,7 +19821,7 @@ class basic_json void swap(object_t& other) { // swap only works for objects - if (JSON_LIKELY(is_object())) + if (HEDLEY_LIKELY(is_object())) { std::swap(*(m_value.object), other); } @@ -18329,7 +19854,7 @@ class basic_json void swap(string_t& other) { // swap only works for strings - if (JSON_LIKELY(is_string())) + if (HEDLEY_LIKELY(is_string())) { std::swap(*(m_value.string), other); } @@ -18839,7 +20364,7 @@ class basic_json instead; that is, replace calls like `j >> o;` with `o << j;`. @since version 1.0.0; deprecated since version 3.0.0 */ - JSON_DEPRECATED + HEDLEY_DEPRECATED(3.0.0) friend std::ostream& operator>>(const basic_json& j, std::ostream& o) { return o << j; @@ -18918,7 +20443,7 @@ class basic_json @since version 2.0.3 (contiguous containers) */ - JSON_NODISCARD + HEDLEY_WARN_UNUSED_RESULT static basic_json parse(detail::input_adapter&& i, const parser_callback_t cb = nullptr, const bool allow_exceptions = true) @@ -18987,6 +20512,7 @@ class basic_json @since version 3.2.0 */ template + HEDLEY_NON_NULL(2) static bool sax_parse(detail::input_adapter&& i, SAX* sax, input_format_t format = input_format_t::json, const bool strict = true) @@ -19072,6 +20598,7 @@ class basic_json std::is_base_of< std::random_access_iterator_tag, typename std::iterator_traits::iterator_category>::value, int>::type = 0> + HEDLEY_NON_NULL(3) static bool sax_parse(IteratorType first, IteratorType last, SAX* sax) { return parser(detail::input_adapter(first, last)).sax_parse(sax); @@ -19085,7 +20612,7 @@ class basic_json instead; that is, replace calls like `j << i;` with `i >> j;`. @since version 1.0.0; deprecated since version 3.0.0 */ - JSON_DEPRECATED + HEDLEY_DEPRECATED(3.0.0) friend std::istream& operator<<(basic_json& j, std::istream& i) { return operator>>(i, j); @@ -19158,6 +20685,7 @@ class basic_json @since version 1.0.0, public since 2.1.0, `const char*` and `noexcept` since 3.0.0 */ + HEDLEY_RETURNS_NON_NULL const char* type_name() const noexcept { { @@ -19687,7 +21215,7 @@ class basic_json @a strict parameter since 3.0.0; added @a allow_exceptions parameter since 3.2.0 */ - JSON_NODISCARD + HEDLEY_WARN_UNUSED_RESULT static basic_json from_cbor(detail::input_adapter&& i, const bool strict = true, const bool allow_exceptions = true) @@ -19703,7 +21231,7 @@ class basic_json */ template::value, int> = 0> - JSON_NODISCARD + HEDLEY_WARN_UNUSED_RESULT static basic_json from_cbor(A1 && a1, A2 && a2, const bool strict = true, const bool allow_exceptions = true) @@ -19796,7 +21324,7 @@ class basic_json @a strict parameter since 3.0.0; added @a allow_exceptions parameter since 3.2.0 */ - JSON_NODISCARD + HEDLEY_WARN_UNUSED_RESULT static basic_json from_msgpack(detail::input_adapter&& i, const bool strict = true, const bool allow_exceptions = true) @@ -19812,7 +21340,7 @@ class basic_json */ template::value, int> = 0> - JSON_NODISCARD + HEDLEY_WARN_UNUSED_RESULT static basic_json from_msgpack(A1 && a1, A2 && a2, const bool strict = true, const bool allow_exceptions = true) @@ -19884,7 +21412,7 @@ class basic_json @since version 3.1.0; added @a allow_exceptions parameter since 3.2.0 */ - JSON_NODISCARD + HEDLEY_WARN_UNUSED_RESULT static basic_json from_ubjson(detail::input_adapter&& i, const bool strict = true, const bool allow_exceptions = true) @@ -19900,7 +21428,7 @@ class basic_json */ template::value, int> = 0> - JSON_NODISCARD + HEDLEY_WARN_UNUSED_RESULT static basic_json from_ubjson(A1 && a1, A2 && a2, const bool strict = true, const bool allow_exceptions = true) @@ -19971,7 +21499,7 @@ class basic_json @sa @ref from_ubjson(detail::input_adapter&&, const bool, const bool) for the related UBJSON format */ - JSON_NODISCARD + HEDLEY_WARN_UNUSED_RESULT static basic_json from_bson(detail::input_adapter&& i, const bool strict = true, const bool allow_exceptions = true) @@ -19987,7 +21515,7 @@ class basic_json */ template::value, int> = 0> - JSON_NODISCARD + HEDLEY_WARN_UNUSED_RESULT static basic_json from_bson(A1 && a1, A2 && a2, const bool strict = true, const bool allow_exceptions = true) @@ -20361,7 +21889,7 @@ class basic_json else { const auto idx = json_pointer::array_index(last_path); - if (JSON_UNLIKELY(static_cast(idx) > parent.size())) + if (HEDLEY_UNLIKELY(static_cast(idx) > parent.size())) { // avoid undefined behavior JSON_THROW(out_of_range::create(401, "array index " + std::to_string(idx) + " is out of range")); @@ -20392,7 +21920,7 @@ class basic_json { // perform range check auto it = parent.find(last_path); - if (JSON_LIKELY(it != parent.end())) + if (HEDLEY_LIKELY(it != parent.end())) { parent.erase(it); } @@ -20409,7 +21937,7 @@ class basic_json }; // type check: top level value must be an array - if (JSON_UNLIKELY(not json_patch.is_array())) + if (HEDLEY_UNLIKELY(not json_patch.is_array())) { JSON_THROW(parse_error::create(104, 0, "JSON patch must be an array of objects")); } @@ -20429,13 +21957,13 @@ class basic_json const auto error_msg = (op == "op") ? "operation" : "operation '" + op + "'"; // check if desired value is present - if (JSON_UNLIKELY(it == val.m_value.object->end())) + if (HEDLEY_UNLIKELY(it == val.m_value.object->end())) { JSON_THROW(parse_error::create(105, 0, error_msg + " must have member '" + member + "'")); } // check if result is of type string - if (JSON_UNLIKELY(string_type and not it->second.is_string())) + if (HEDLEY_UNLIKELY(string_type and not it->second.is_string())) { JSON_THROW(parse_error::create(105, 0, error_msg + " must have string member '" + member + "'")); } @@ -20445,7 +21973,7 @@ class basic_json }; // type check: every element of the array must be an object - if (JSON_UNLIKELY(not val.is_object())) + if (HEDLEY_UNLIKELY(not val.is_object())) { JSON_THROW(parse_error::create(104, 0, "JSON patch must be an array of objects")); } @@ -20523,7 +22051,7 @@ class basic_json } // throw an exception if test fails - if (JSON_UNLIKELY(not success)) + if (HEDLEY_UNLIKELY(not success)) { JSON_THROW(other_error::create(501, "unsuccessful: " + val.dump())); } @@ -20576,7 +22104,7 @@ class basic_json @since version 2.0.0 */ - JSON_NODISCARD + HEDLEY_WARN_UNUSED_RESULT static basic_json diff(const basic_json& source, const basic_json& target, const std::string& path = "") { @@ -20868,6 +22396,7 @@ if no parse error occurred. @since version 1.0.0 */ +HEDLEY_NON_NULL(1) inline nlohmann::json operator "" _json(const char* s, std::size_t n) { return nlohmann::json::parse(s, s + n); @@ -20886,6 +22415,7 @@ object if no parse error occurred. @since version 2.0.0 */ +HEDLEY_NON_NULL(1) inline nlohmann::json::json_pointer operator "" _json_pointer(const char* s, std::size_t n) { return nlohmann::json::json_pointer(std::string(s, n)); @@ -20907,10 +22437,6 @@ inline nlohmann::json::json_pointer operator "" _json_pointer(const char* s, std #undef JSON_CATCH #undef JSON_THROW #undef JSON_TRY -#undef JSON_LIKELY -#undef JSON_UNLIKELY -#undef JSON_DEPRECATED -#undef JSON_NODISCARD #undef JSON_HAS_CPP_14 #undef JSON_HAS_CPP_17 #undef NLOHMANN_BASIC_JSON_TPL_DECLARATION From 897362191d7618d2210c4395ff7984d4932672f5 Mon Sep 17 00:00:00 2001 From: Niels Lohmann Date: Mon, 1 Jul 2019 22:24:39 +0200 Subject: [PATCH 088/106] :hammer: add NLOHMANN_JSON prefix and undef macros --- Makefile | 7 + hedley.h | 1505 ++++++++++ .../nlohmann/detail/conversions/from_json.hpp | 24 +- .../nlohmann/detail/conversions/to_chars.hpp | 16 +- include/nlohmann/detail/exceptions.hpp | 12 +- .../nlohmann/detail/input/binary_reader.hpp | 116 +- .../nlohmann/detail/input/input_adapters.hpp | 10 +- include/nlohmann/detail/input/json_sax.hpp | 10 +- include/nlohmann/detail/input/lexer.hpp | 44 +- include/nlohmann/detail/input/parser.hpp | 48 +- .../nlohmann/detail/iterators/iter_impl.hpp | 12 +- include/nlohmann/detail/json_pointer.hpp | 34 +- include/nlohmann/detail/macro_unscope.hpp | 2 + .../nlohmann/detail/output/binary_writer.hpp | 2 +- .../detail/output/output_adapters.hpp | 6 +- include/nlohmann/detail/output/serializer.hpp | 6 +- include/nlohmann/json.hpp | 174 +- include/nlohmann/thirdparty/hedley/hedley.hpp | 1780 ++++++------ .../thirdparty/hedley/hedley_undef.hpp | 122 + single_include/nlohmann/json.hpp | 2419 +++++++++-------- 20 files changed, 4055 insertions(+), 2294 deletions(-) create mode 100644 hedley.h create mode 100644 include/nlohmann/thirdparty/hedley/hedley_undef.hpp diff --git a/Makefile b/Makefile index 3afca525..141e1c78 100644 --- a/Makefile +++ b/Makefile @@ -616,3 +616,10 @@ clean: rm -fr build_coverage build_benchmarks fuzz-testing clang_analyze_build pvs_studio_build infer_build clang_sanitize_build cmake_build $(MAKE) clean -Cdoc $(MAKE) clean -Ctest + +update_hedley: + rm -f include/nlohmann/thirdparty/hedley/hedley.hpp include/nlohmann/thirdparty/hedley/hedley_undef.hpp + curl https://raw.githubusercontent.com/nemequ/hedley/master/hedley.h -o include/nlohmann/thirdparty/hedley/hedley.hpp + gsed -i 's/HEDLEY_/NLOHMANN_JSON_HEDLEY_/g' include/nlohmann/thirdparty/hedley/hedley.hpp + grep "[[:blank:]]*#[[:blank:]]*undef" include/nlohmann/thirdparty/hedley/hedley.hpp | sort | uniq | gsed 's/ //g' | gsed 's/undef/undef /g' > include/nlohmann/thirdparty/hedley/hedley_undef.hpp + $(MAKE) amalgamate diff --git a/hedley.h b/hedley.h new file mode 100644 index 00000000..d20c2297 --- /dev/null +++ b/hedley.h @@ -0,0 +1,1505 @@ +/* Hedley - https://nemequ.github.io/hedley + * Created by Evan Nemerson + * + * To the extent possible under law, the author(s) have dedicated all + * copyright and related and neighboring rights to this software to + * the public domain worldwide. This software is distributed without + * any warranty. + * + * For details, see . + * SPDX-License-Identifier: CC0-1.0 + */ + +#if !defined(HEDLEY_VERSION) || (HEDLEY_VERSION < 9) +#if defined(HEDLEY_VERSION) +# undef HEDLEY_VERSION +#endif +#define HEDLEY_VERSION 9 + +#if defined(HEDLEY_STRINGIFY_EX) +# undef HEDLEY_STRINGIFY_EX +#endif +#define HEDLEY_STRINGIFY_EX(x) #x + +#if defined(HEDLEY_STRINGIFY) +# undef HEDLEY_STRINGIFY +#endif +#define HEDLEY_STRINGIFY(x) HEDLEY_STRINGIFY_EX(x) + +#if defined(HEDLEY_CONCAT_EX) +# undef HEDLEY_CONCAT_EX +#endif +#define HEDLEY_CONCAT_EX(a,b) a##b + +#if defined(HEDLEY_CONCAT) +# undef HEDLEY_CONCAT +#endif +#define HEDLEY_CONCAT(a,b) HEDLEY_CONCAT_EX(a,b) + +#if defined(HEDLEY_VERSION_ENCODE) +# undef HEDLEY_VERSION_ENCODE +#endif +#define HEDLEY_VERSION_ENCODE(major,minor,revision) (((major) * 1000000) + ((minor) * 1000) + (revision)) + +#if defined(HEDLEY_VERSION_DECODE_MAJOR) +# undef HEDLEY_VERSION_DECODE_MAJOR +#endif +#define HEDLEY_VERSION_DECODE_MAJOR(version) ((version) / 1000000) + +#if defined(HEDLEY_VERSION_DECODE_MINOR) +# undef HEDLEY_VERSION_DECODE_MINOR +#endif +#define HEDLEY_VERSION_DECODE_MINOR(version) (((version) % 1000000) / 1000) + +#if defined(HEDLEY_VERSION_DECODE_REVISION) +# undef HEDLEY_VERSION_DECODE_REVISION +#endif +#define HEDLEY_VERSION_DECODE_REVISION(version) ((version) % 1000) + +#if defined(HEDLEY_GNUC_VERSION) +# undef HEDLEY_GNUC_VERSION +#endif +#if defined(__GNUC__) && defined(__GNUC_PATCHLEVEL__) +# define HEDLEY_GNUC_VERSION HEDLEY_VERSION_ENCODE(__GNUC__, __GNUC_MINOR__, __GNUC_PATCHLEVEL__) +#elif defined(__GNUC__) +# define HEDLEY_GNUC_VERSION HEDLEY_VERSION_ENCODE(__GNUC__, __GNUC_MINOR__, 0) +#endif + +#if defined(HEDLEY_GNUC_VERSION_CHECK) +# undef HEDLEY_GNUC_VERSION_CHECK +#endif +#if defined(HEDLEY_GNUC_VERSION) +# define HEDLEY_GNUC_VERSION_CHECK(major,minor,patch) (HEDLEY_GNUC_VERSION >= HEDLEY_VERSION_ENCODE(major, minor, patch)) +#else +# define HEDLEY_GNUC_VERSION_CHECK(major,minor,patch) (0) +#endif + +#if defined(HEDLEY_MSVC_VERSION) +# undef HEDLEY_MSVC_VERSION +#endif +#if defined(_MSC_FULL_VER) && (_MSC_FULL_VER >= 140000000) +# define HEDLEY_MSVC_VERSION HEDLEY_VERSION_ENCODE(_MSC_FULL_VER / 10000000, (_MSC_FULL_VER % 10000000) / 100000, (_MSC_FULL_VER % 100000) / 100) +#elif defined(_MSC_FULL_VER) +# define HEDLEY_MSVC_VERSION HEDLEY_VERSION_ENCODE(_MSC_FULL_VER / 1000000, (_MSC_FULL_VER % 1000000) / 10000, (_MSC_FULL_VER % 10000) / 10) +#elif defined(_MSC_VER) +# define HEDLEY_MSVC_VERSION HEDLEY_VERSION_ENCODE(_MSC_VER / 100, _MSC_VER % 100, 0) +#endif + +#if defined(HEDLEY_MSVC_VERSION_CHECK) +# undef HEDLEY_MSVC_VERSION_CHECK +#endif +#if !defined(_MSC_VER) +# define HEDLEY_MSVC_VERSION_CHECK(major,minor,patch) (0) +#elif defined(_MSC_VER) && (_MSC_VER >= 1400) +# define HEDLEY_MSVC_VERSION_CHECK(major,minor,patch) (_MSC_FULL_VER >= ((major * 10000000) + (minor * 100000) + (patch))) +#elif defined(_MSC_VER) && (_MSC_VER >= 1200) +# define HEDLEY_MSVC_VERSION_CHECK(major,minor,patch) (_MSC_FULL_VER >= ((major * 1000000) + (minor * 10000) + (patch))) +#else +# define HEDLEY_MSVC_VERSION_CHECK(major,minor,patch) (_MSC_VER >= ((major * 100) + (minor))) +#endif + +#if defined(HEDLEY_INTEL_VERSION) +# undef HEDLEY_INTEL_VERSION +#endif +#if defined(__INTEL_COMPILER) && defined(__INTEL_COMPILER_UPDATE) +# define HEDLEY_INTEL_VERSION HEDLEY_VERSION_ENCODE(__INTEL_COMPILER / 100, __INTEL_COMPILER % 100, __INTEL_COMPILER_UPDATE) +#elif defined(__INTEL_COMPILER) +# define HEDLEY_INTEL_VERSION HEDLEY_VERSION_ENCODE(__INTEL_COMPILER / 100, __INTEL_COMPILER % 100, 0) +#endif + +#if defined(HEDLEY_INTEL_VERSION_CHECK) +# undef HEDLEY_INTEL_VERSION_CHECK +#endif +#if defined(HEDLEY_INTEL_VERSION) +# define HEDLEY_INTEL_VERSION_CHECK(major,minor,patch) (HEDLEY_INTEL_VERSION >= HEDLEY_VERSION_ENCODE(major, minor, patch)) +#else +# define HEDLEY_INTEL_VERSION_CHECK(major,minor,patch) (0) +#endif + +#if defined(HEDLEY_PGI_VERSION) +# undef HEDLEY_PGI_VERSION +#endif +#if defined(__PGI) && defined(__PGIC__) && defined(__PGIC_MINOR__) && defined(__PGIC_PATCHLEVEL__) +# define HEDLEY_PGI_VERSION HEDLEY_VERSION_ENCODE(__PGIC__, __PGIC_MINOR__, __PGIC_PATCHLEVEL__) +#endif + +#if defined(HEDLEY_PGI_VERSION_CHECK) +# undef HEDLEY_PGI_VERSION_CHECK +#endif +#if defined(HEDLEY_PGI_VERSION) +# define HEDLEY_PGI_VERSION_CHECK(major,minor,patch) (HEDLEY_PGI_VERSION >= HEDLEY_VERSION_ENCODE(major, minor, patch)) +#else +# define HEDLEY_PGI_VERSION_CHECK(major,minor,patch) (0) +#endif + +#if defined(HEDLEY_SUNPRO_VERSION) +# undef HEDLEY_SUNPRO_VERSION +#endif +#if defined(__SUNPRO_C) && (__SUNPRO_C > 0x1000) +# define HEDLEY_SUNPRO_VERSION HEDLEY_VERSION_ENCODE((((__SUNPRO_C >> 16) & 0xf) * 10) + ((__SUNPRO_C >> 12) & 0xf), (((__SUNPRO_C >> 8) & 0xf) * 10) + ((__SUNPRO_C >> 4) & 0xf), (__SUNPRO_C & 0xf) * 10) +#elif defined(__SUNPRO_C) +# define HEDLEY_SUNPRO_VERSION HEDLEY_VERSION_ENCODE((__SUNPRO_C >> 8) & 0xf, (__SUNPRO_C >> 4) & 0xf, (__SUNPRO_C) & 0xf) +#elif defined(__SUNPRO_CC) && (__SUNPRO_CC > 0x1000) +# define HEDLEY_SUNPRO_VERSION HEDLEY_VERSION_ENCODE((((__SUNPRO_CC >> 16) & 0xf) * 10) + ((__SUNPRO_CC >> 12) & 0xf), (((__SUNPRO_CC >> 8) & 0xf) * 10) + ((__SUNPRO_CC >> 4) & 0xf), (__SUNPRO_CC & 0xf) * 10) +#elif defined(__SUNPRO_CC) +# define HEDLEY_SUNPRO_VERSION HEDLEY_VERSION_ENCODE((__SUNPRO_CC >> 8) & 0xf, (__SUNPRO_CC >> 4) & 0xf, (__SUNPRO_CC) & 0xf) +#endif + +#if defined(HEDLEY_SUNPRO_VERSION_CHECK) +# undef HEDLEY_SUNPRO_VERSION_CHECK +#endif +#if defined(HEDLEY_SUNPRO_VERSION) +# define HEDLEY_SUNPRO_VERSION_CHECK(major,minor,patch) (HEDLEY_SUNPRO_VERSION >= HEDLEY_VERSION_ENCODE(major, minor, patch)) +#else +# define HEDLEY_SUNPRO_VERSION_CHECK(major,minor,patch) (0) +#endif + +#if defined(HEDLEY_EMSCRIPTEN_VERSION) +# undef HEDLEY_EMSCRIPTEN_VERSION +#endif +#if defined(__EMSCRIPTEN__) +# define HEDLEY_EMSCRIPTEN_VERSION HEDLEY_VERSION_ENCODE(__EMSCRIPTEN_major__, __EMSCRIPTEN_minor__, __EMSCRIPTEN_tiny__) +#endif + +#if defined(HEDLEY_EMSCRIPTEN_VERSION_CHECK) +# undef HEDLEY_EMSCRIPTEN_VERSION_CHECK +#endif +#if defined(HEDLEY_EMSCRIPTEN_VERSION) +# define HEDLEY_EMSCRIPTEN_VERSION_CHECK(major,minor,patch) (HEDLEY_EMSCRIPTEN_VERSION >= HEDLEY_VERSION_ENCODE(major, minor, patch)) +#else +# define HEDLEY_EMSCRIPTEN_VERSION_CHECK(major,minor,patch) (0) +#endif + +#if defined(HEDLEY_ARM_VERSION) +# undef HEDLEY_ARM_VERSION +#endif +#if defined(__CC_ARM) && defined(__ARMCOMPILER_VERSION) +# define HEDLEY_ARM_VERSION HEDLEY_VERSION_ENCODE(__ARMCOMPILER_VERSION / 1000000, (__ARMCOMPILER_VERSION % 1000000) / 10000, (__ARMCOMPILER_VERSION % 10000) / 100) +#elif defined(__CC_ARM) && defined(__ARMCC_VERSION) +# define HEDLEY_ARM_VERSION HEDLEY_VERSION_ENCODE(__ARMCC_VERSION / 1000000, (__ARMCC_VERSION % 1000000) / 10000, (__ARMCC_VERSION % 10000) / 100) +#endif + +#if defined(HEDLEY_ARM_VERSION_CHECK) +# undef HEDLEY_ARM_VERSION_CHECK +#endif +#if defined(HEDLEY_ARM_VERSION) +# define HEDLEY_ARM_VERSION_CHECK(major,minor,patch) (HEDLEY_ARM_VERSION >= HEDLEY_VERSION_ENCODE(major, minor, patch)) +#else +# define HEDLEY_ARM_VERSION_CHECK(major,minor,patch) (0) +#endif + +#if defined(HEDLEY_IBM_VERSION) +# undef HEDLEY_IBM_VERSION +#endif +#if defined(__ibmxl__) +# define HEDLEY_IBM_VERSION HEDLEY_VERSION_ENCODE(__ibmxl_version__, __ibmxl_release__, __ibmxl_modification__) +#elif defined(__xlC__) && defined(__xlC_ver__) +# define HEDLEY_IBM_VERSION HEDLEY_VERSION_ENCODE(__xlC__ >> 8, __xlC__ & 0xff, (__xlC_ver__ >> 8) & 0xff) +#elif defined(__xlC__) +# define HEDLEY_IBM_VERSION HEDLEY_VERSION_ENCODE(__xlC__ >> 8, __xlC__ & 0xff, 0) +#endif + +#if defined(HEDLEY_IBM_VERSION_CHECK) +# undef HEDLEY_IBM_VERSION_CHECK +#endif +#if defined(HEDLEY_IBM_VERSION) +# define HEDLEY_IBM_VERSION_CHECK(major,minor,patch) (HEDLEY_IBM_VERSION >= HEDLEY_VERSION_ENCODE(major, minor, patch)) +#else +# define HEDLEY_IBM_VERSION_CHECK(major,minor,patch) (0) +#endif + +#if defined(HEDLEY_TI_VERSION) +# undef HEDLEY_TI_VERSION +#endif +#if defined(__TI_COMPILER_VERSION__) +# define HEDLEY_TI_VERSION HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000)) +#endif + +#if defined(HEDLEY_TI_VERSION_CHECK) +# undef HEDLEY_TI_VERSION_CHECK +#endif +#if defined(HEDLEY_TI_VERSION) +# define HEDLEY_TI_VERSION_CHECK(major,minor,patch) (HEDLEY_TI_VERSION >= HEDLEY_VERSION_ENCODE(major, minor, patch)) +#else +# define HEDLEY_TI_VERSION_CHECK(major,minor,patch) (0) +#endif + +#if defined(HEDLEY_CRAY_VERSION) +# undef HEDLEY_CRAY_VERSION +#endif +#if defined(_CRAYC) +# if defined(_RELEASE_PATCHLEVEL) +# define HEDLEY_CRAY_VERSION HEDLEY_VERSION_ENCODE(_RELEASE_MAJOR, _RELEASE_MINOR, _RELEASE_PATCHLEVEL) +# else +# define HEDLEY_CRAY_VERSION HEDLEY_VERSION_ENCODE(_RELEASE_MAJOR, _RELEASE_MINOR, 0) +# endif +#endif + +#if defined(HEDLEY_CRAY_VERSION_CHECK) +# undef HEDLEY_CRAY_VERSION_CHECK +#endif +#if defined(HEDLEY_CRAY_VERSION) +# define HEDLEY_CRAY_VERSION_CHECK(major,minor,patch) (HEDLEY_CRAY_VERSION >= HEDLEY_VERSION_ENCODE(major, minor, patch)) +#else +# define HEDLEY_CRAY_VERSION_CHECK(major,minor,patch) (0) +#endif + +#if defined(HEDLEY_IAR_VERSION) +# undef HEDLEY_IAR_VERSION +#endif +#if defined(__IAR_SYSTEMS_ICC__) +# if __VER__ > 1000 +# define HEDLEY_IAR_VERSION HEDLEY_VERSION_ENCODE((__VER__ / 1000000), ((__VER__ / 1000) % 1000), (__VER__ % 1000)) +# else +# define HEDLEY_IAR_VERSION HEDLEY_VERSION_ENCODE(VER / 100, __VER__ % 100, 0) +# endif +#endif + +#if defined(HEDLEY_IAR_VERSION_CHECK) +# undef HEDLEY_IAR_VERSION_CHECK +#endif +#if defined(HEDLEY_IAR_VERSION) +# define HEDLEY_IAR_VERSION_CHECK(major,minor,patch) (HEDLEY_IAR_VERSION >= HEDLEY_VERSION_ENCODE(major, minor, patch)) +#else +# define HEDLEY_IAR_VERSION_CHECK(major,minor,patch) (0) +#endif + +#if defined(HEDLEY_TINYC_VERSION) +# undef HEDLEY_TINYC_VERSION +#endif +#if defined(__TINYC__) +# define HEDLEY_TINYC_VERSION HEDLEY_VERSION_ENCODE(__TINYC__ / 1000, (__TINYC__ / 100) % 10, __TINYC__ % 100) +#endif + +#if defined(HEDLEY_TINYC_VERSION_CHECK) +# undef HEDLEY_TINYC_VERSION_CHECK +#endif +#if defined(HEDLEY_TINYC_VERSION) +# define HEDLEY_TINYC_VERSION_CHECK(major,minor,patch) (HEDLEY_TINYC_VERSION >= HEDLEY_VERSION_ENCODE(major, minor, patch)) +#else +# define HEDLEY_TINYC_VERSION_CHECK(major,minor,patch) (0) +#endif + +#if defined(HEDLEY_DMC_VERSION) +# undef HEDLEY_DMC_VERSION +#endif +#if defined(__DMC__) +# define HEDLEY_DMC_VERSION HEDLEY_VERSION_ENCODE(__DMC__ >> 8, (__DMC__ >> 4) & 0xf, __DMC__ & 0xf) +#endif + +#if defined(HEDLEY_DMC_VERSION_CHECK) +# undef HEDLEY_DMC_VERSION_CHECK +#endif +#if defined(HEDLEY_DMC_VERSION) +# define HEDLEY_DMC_VERSION_CHECK(major,minor,patch) (HEDLEY_DMC_VERSION >= HEDLEY_VERSION_ENCODE(major, minor, patch)) +#else +# define HEDLEY_DMC_VERSION_CHECK(major,minor,patch) (0) +#endif + +#if defined(HEDLEY_COMPCERT_VERSION) +# undef HEDLEY_COMPCERT_VERSION +#endif +#if defined(__COMPCERT_VERSION__) +# define HEDLEY_COMPCERT_VERSION HEDLEY_VERSION_ENCODE(__COMPCERT_VERSION__ / 10000, (__COMPCERT_VERSION__ / 100) % 100, __COMPCERT_VERSION__ % 100) +#endif + +#if defined(HEDLEY_COMPCERT_VERSION_CHECK) +# undef HEDLEY_COMPCERT_VERSION_CHECK +#endif +#if defined(HEDLEY_COMPCERT_VERSION) +# define HEDLEY_COMPCERT_VERSION_CHECK(major,minor,patch) (HEDLEY_COMPCERT_VERSION >= HEDLEY_VERSION_ENCODE(major, minor, patch)) +#else +# define HEDLEY_COMPCERT_VERSION_CHECK(major,minor,patch) (0) +#endif + +#if defined(HEDLEY_PELLES_VERSION) +# undef HEDLEY_PELLES_VERSION +#endif +#if defined(__POCC__) +# define HEDLEY_PELLES_VERSION HEDLEY_VERSION_ENCODE(__POCC__ / 100, __POCC__ % 100, 0) +#endif + +#if defined(HEDLEY_PELLES_VERSION_CHECK) +# undef HEDLEY_PELLES_VERSION_CHECK +#endif +#if defined(HEDLEY_PELLES_VERSION) +# define HEDLEY_PELLES_VERSION_CHECK(major,minor,patch) (HEDLEY_PELLES_VERSION >= HEDLEY_VERSION_ENCODE(major, minor, patch)) +#else +# define HEDLEY_PELLES_VERSION_CHECK(major,minor,patch) (0) +#endif + +#if defined(HEDLEY_GCC_VERSION) +# undef HEDLEY_GCC_VERSION +#endif +#if \ + defined(HEDLEY_GNUC_VERSION) && \ + !defined(__clang__) && \ + !defined(HEDLEY_INTEL_VERSION) && \ + !defined(HEDLEY_PGI_VERSION) && \ + !defined(HEDLEY_ARM_VERSION) && \ + !defined(HEDLEY_TI_VERSION) && \ + !defined(__COMPCERT__) +# define HEDLEY_GCC_VERSION HEDLEY_GNUC_VERSION +#endif + +#if defined(HEDLEY_GCC_VERSION_CHECK) +# undef HEDLEY_GCC_VERSION_CHECK +#endif +#if defined(HEDLEY_GCC_VERSION) +# define HEDLEY_GCC_VERSION_CHECK(major,minor,patch) (HEDLEY_GCC_VERSION >= HEDLEY_VERSION_ENCODE(major, minor, patch)) +#else +# define HEDLEY_GCC_VERSION_CHECK(major,minor,patch) (0) +#endif + +#if defined(HEDLEY_HAS_ATTRIBUTE) +# undef HEDLEY_HAS_ATTRIBUTE +#endif +#if defined(__has_attribute) +# define HEDLEY_HAS_ATTRIBUTE(attribute) __has_attribute(attribute) +#else +# define HEDLEY_HAS_ATTRIBUTE(attribute) (0) +#endif + +#if defined(HEDLEY_GNUC_HAS_ATTRIBUTE) +# undef HEDLEY_GNUC_HAS_ATTRIBUTE +#endif +#if defined(__has_attribute) +# define HEDLEY_GNUC_HAS_ATTRIBUTE(attribute,major,minor,patch) __has_attribute(attribute) +#else +# define HEDLEY_GNUC_HAS_ATTRIBUTE(attribute,major,minor,patch) HEDLEY_GNUC_VERSION_CHECK(major,minor,patch) +#endif + +#if defined(HEDLEY_GCC_HAS_ATTRIBUTE) +# undef HEDLEY_GCC_HAS_ATTRIBUTE +#endif +#if defined(__has_attribute) +# define HEDLEY_GCC_HAS_ATTRIBUTE(attribute,major,minor,patch) __has_attribute(attribute) +#else +# define HEDLEY_GCC_HAS_ATTRIBUTE(attribute,major,minor,patch) HEDLEY_GCC_VERSION_CHECK(major,minor,patch) +#endif + +#if defined(HEDLEY_HAS_CPP_ATTRIBUTE) +# undef HEDLEY_HAS_CPP_ATTRIBUTE +#endif +#if defined(__has_cpp_attribute) && defined(__cplusplus) +# define HEDLEY_HAS_CPP_ATTRIBUTE(attribute) __has_cpp_attribute(attribute) +#else +# define HEDLEY_HAS_CPP_ATTRIBUTE(attribute) (0) +#endif + +#if defined(HEDLEY_GNUC_HAS_CPP_ATTRIBUTE) +# undef HEDLEY_GNUC_HAS_CPP_ATTRIBUTE +#endif +#if defined(__has_cpp_attribute) && defined(__cplusplus) +# define HEDLEY_GNUC_HAS_CPP_ATTRIBUTE(attribute,major,minor,patch) __has_cpp_attribute(attribute) +#else +# define HEDLEY_GNUC_HAS_CPP_ATTRIBUTE(attribute,major,minor,patch) HEDLEY_GNUC_VERSION_CHECK(major,minor,patch) +#endif + +#if defined(HEDLEY_GCC_HAS_CPP_ATTRIBUTE) +# undef HEDLEY_GCC_HAS_CPP_ATTRIBUTE +#endif +#if defined(__has_cpp_attribute) && defined(__cplusplus) +# define HEDLEY_GCC_HAS_CPP_ATTRIBUTE(attribute,major,minor,patch) __has_cpp_attribute(attribute) +#else +# define HEDLEY_GCC_HAS_CPP_ATTRIBUTE(attribute,major,minor,patch) HEDLEY_GCC_VERSION_CHECK(major,minor,patch) +#endif + +#if defined(HEDLEY_HAS_BUILTIN) +# undef HEDLEY_HAS_BUILTIN +#endif +#if defined(__has_builtin) +# define HEDLEY_HAS_BUILTIN(builtin) __has_builtin(builtin) +#else +# define HEDLEY_HAS_BUILTIN(builtin) (0) +#endif + +#if defined(HEDLEY_GNUC_HAS_BUILTIN) +# undef HEDLEY_GNUC_HAS_BUILTIN +#endif +#if defined(__has_builtin) +# define HEDLEY_GNUC_HAS_BUILTIN(builtin,major,minor,patch) __has_builtin(builtin) +#else +# define HEDLEY_GNUC_HAS_BUILTIN(builtin,major,minor,patch) HEDLEY_GNUC_VERSION_CHECK(major,minor,patch) +#endif + +#if defined(HEDLEY_GCC_HAS_BUILTIN) +# undef HEDLEY_GCC_HAS_BUILTIN +#endif +#if defined(__has_builtin) +# define HEDLEY_GCC_HAS_BUILTIN(builtin,major,minor,patch) __has_builtin(builtin) +#else +# define HEDLEY_GCC_HAS_BUILTIN(builtin,major,minor,patch) HEDLEY_GCC_VERSION_CHECK(major,minor,patch) +#endif + +#if defined(HEDLEY_HAS_FEATURE) +# undef HEDLEY_HAS_FEATURE +#endif +#if defined(__has_feature) +# define HEDLEY_HAS_FEATURE(feature) __has_feature(feature) +#else +# define HEDLEY_HAS_FEATURE(feature) (0) +#endif + +#if defined(HEDLEY_GNUC_HAS_FEATURE) +# undef HEDLEY_GNUC_HAS_FEATURE +#endif +#if defined(__has_feature) +# define HEDLEY_GNUC_HAS_FEATURE(feature,major,minor,patch) __has_feature(feature) +#else +# define HEDLEY_GNUC_HAS_FEATURE(feature,major,minor,patch) HEDLEY_GNUC_VERSION_CHECK(major,minor,patch) +#endif + +#if defined(HEDLEY_GCC_HAS_FEATURE) +# undef HEDLEY_GCC_HAS_FEATURE +#endif +#if defined(__has_feature) +# define HEDLEY_GCC_HAS_FEATURE(feature,major,minor,patch) __has_feature(feature) +#else +# define HEDLEY_GCC_HAS_FEATURE(feature,major,minor,patch) HEDLEY_GCC_VERSION_CHECK(major,minor,patch) +#endif + +#if defined(HEDLEY_HAS_EXTENSION) +# undef HEDLEY_HAS_EXTENSION +#endif +#if defined(__has_extension) +# define HEDLEY_HAS_EXTENSION(extension) __has_extension(extension) +#else +# define HEDLEY_HAS_EXTENSION(extension) (0) +#endif + +#if defined(HEDLEY_GNUC_HAS_EXTENSION) +# undef HEDLEY_GNUC_HAS_EXTENSION +#endif +#if defined(__has_extension) +# define HEDLEY_GNUC_HAS_EXTENSION(extension,major,minor,patch) __has_extension(extension) +#else +# define HEDLEY_GNUC_HAS_EXTENSION(extension,major,minor,patch) HEDLEY_GNUC_VERSION_CHECK(major,minor,patch) +#endif + +#if defined(HEDLEY_GCC_HAS_EXTENSION) +# undef HEDLEY_GCC_HAS_EXTENSION +#endif +#if defined(__has_extension) +# define HEDLEY_GCC_HAS_EXTENSION(extension,major,minor,patch) __has_extension(extension) +#else +# define HEDLEY_GCC_HAS_EXTENSION(extension,major,minor,patch) HEDLEY_GCC_VERSION_CHECK(major,minor,patch) +#endif + +#if defined(HEDLEY_HAS_DECLSPEC_ATTRIBUTE) +# undef HEDLEY_HAS_DECLSPEC_ATTRIBUTE +#endif +#if defined(__has_declspec_attribute) +# define HEDLEY_HAS_DECLSPEC_ATTRIBUTE(attribute) __has_declspec_attribute(attribute) +#else +# define HEDLEY_HAS_DECLSPEC_ATTRIBUTE(attribute) (0) +#endif + +#if defined(HEDLEY_GNUC_HAS_DECLSPEC_ATTRIBUTE) +# undef HEDLEY_GNUC_HAS_DECLSPEC_ATTRIBUTE +#endif +#if defined(__has_declspec_attribute) +# define HEDLEY_GNUC_HAS_DECLSPEC_ATTRIBUTE(attribute,major,minor,patch) __has_declspec_attribute(attribute) +#else +# define HEDLEY_GNUC_HAS_DECLSPEC_ATTRIBUTE(attribute,major,minor,patch) HEDLEY_GNUC_VERSION_CHECK(major,minor,patch) +#endif + +#if defined(HEDLEY_GCC_HAS_DECLSPEC_ATTRIBUTE) +# undef HEDLEY_GCC_HAS_DECLSPEC_ATTRIBUTE +#endif +#if defined(__has_declspec_attribute) +# define HEDLEY_GCC_HAS_DECLSPEC_ATTRIBUTE(attribute,major,minor,patch) __has_declspec_attribute(attribute) +#else +# define HEDLEY_GCC_HAS_DECLSPEC_ATTRIBUTE(attribute,major,minor,patch) HEDLEY_GCC_VERSION_CHECK(major,minor,patch) +#endif + +#if defined(HEDLEY_HAS_WARNING) +# undef HEDLEY_HAS_WARNING +#endif +#if defined(__has_warning) +# define HEDLEY_HAS_WARNING(warning) __has_warning(warning) +#else +# define HEDLEY_HAS_WARNING(warning) (0) +#endif + +#if defined(HEDLEY_GNUC_HAS_WARNING) +# undef HEDLEY_GNUC_HAS_WARNING +#endif +#if defined(__has_warning) +# define HEDLEY_GNUC_HAS_WARNING(warning,major,minor,patch) __has_warning(warning) +#else +# define HEDLEY_GNUC_HAS_WARNING(warning,major,minor,patch) HEDLEY_GNUC_VERSION_CHECK(major,minor,patch) +#endif + +#if defined(HEDLEY_GCC_HAS_WARNING) +# undef HEDLEY_GCC_HAS_WARNING +#endif +#if defined(__has_warning) +# define HEDLEY_GCC_HAS_WARNING(warning,major,minor,patch) __has_warning(warning) +#else +# define HEDLEY_GCC_HAS_WARNING(warning,major,minor,patch) HEDLEY_GCC_VERSION_CHECK(major,minor,patch) +#endif + +#if \ + (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)) || \ + defined(__clang__) || \ + HEDLEY_GCC_VERSION_CHECK(3,0,0) || \ + HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ + HEDLEY_IAR_VERSION_CHECK(8,0,0) || \ + HEDLEY_PGI_VERSION_CHECK(18,4,0) || \ + HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ + HEDLEY_TI_VERSION_CHECK(6,0,0) || \ + HEDLEY_CRAY_VERSION_CHECK(5,0,0) || \ + HEDLEY_TINYC_VERSION_CHECK(0,9,17) || \ + HEDLEY_SUNPRO_VERSION_CHECK(8,0,0) || \ + (HEDLEY_IBM_VERSION_CHECK(10,1,0) && defined(__C99_PRAGMA_OPERATOR)) +# define HEDLEY_PRAGMA(value) _Pragma(#value) +#elif HEDLEY_MSVC_VERSION_CHECK(15,0,0) +# define HEDLEY_PRAGMA(value) __pragma(value) +#else +# define HEDLEY_PRAGMA(value) +#endif + +#if defined(HEDLEY_DIAGNOSTIC_PUSH) +# undef HEDLEY_DIAGNOSTIC_PUSH +#endif +#if defined(HEDLEY_DIAGNOSTIC_POP) +# undef HEDLEY_DIAGNOSTIC_POP +#endif +#if defined(__clang__) +# define HEDLEY_DIAGNOSTIC_PUSH _Pragma("clang diagnostic push") +# define HEDLEY_DIAGNOSTIC_POP _Pragma("clang diagnostic pop") +#elif HEDLEY_INTEL_VERSION_CHECK(13,0,0) +# define HEDLEY_DIAGNOSTIC_PUSH _Pragma("warning(push)") +# define HEDLEY_DIAGNOSTIC_POP _Pragma("warning(pop)") +#elif HEDLEY_GCC_VERSION_CHECK(4,6,0) +# define HEDLEY_DIAGNOSTIC_PUSH _Pragma("GCC diagnostic push") +# define HEDLEY_DIAGNOSTIC_POP _Pragma("GCC diagnostic pop") +#elif HEDLEY_MSVC_VERSION_CHECK(15,0,0) +# define HEDLEY_DIAGNOSTIC_PUSH __pragma(warning(push)) +# define HEDLEY_DIAGNOSTIC_POP __pragma(warning(pop)) +#elif HEDLEY_ARM_VERSION_CHECK(5,6,0) +# define HEDLEY_DIAGNOSTIC_PUSH _Pragma("push") +# define HEDLEY_DIAGNOSTIC_POP _Pragma("pop") +#elif HEDLEY_TI_VERSION_CHECK(8,1,0) +# define HEDLEY_DIAGNOSTIC_PUSH _Pragma("diag_push") +# define HEDLEY_DIAGNOSTIC_POP _Pragma("diag_pop") +#elif HEDLEY_PELLES_VERSION_CHECK(2,90,0) +# define HEDLEY_DIAGNOSTIC_PUSH _Pragma("warning(push)") +# define HEDLEY_DIAGNOSTIC_POP _Pragma("warning(pop)") +#else +# define HEDLEY_DIAGNOSTIC_PUSH +# define HEDLEY_DIAGNOSTIC_POP +#endif + +#if defined(HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED) +# undef HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED +#endif +#if HEDLEY_HAS_WARNING("-Wdeprecated-declarations") +# define HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("clang diagnostic ignored \"-Wdeprecated-declarations\"") +#elif HEDLEY_INTEL_VERSION_CHECK(13,0,0) +# define HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("warning(disable:1478 1786)") +#elif HEDLEY_PGI_VERSION_CHECK(17,10,0) +# define HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("diag_suppress 1215,1444") +#elif HEDLEY_GCC_VERSION_CHECK(4,3,0) +# define HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"") +#elif HEDLEY_MSVC_VERSION_CHECK(15,0,0) +# define HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED __pragma(warning(disable:4996)) +#elif HEDLEY_TI_VERSION_CHECK(8,0,0) +# define HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("diag_suppress 1291,1718") +#elif HEDLEY_SUNPRO_VERSION_CHECK(5,13,0) && !defined(__cplusplus) +# define HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("error_messages(off,E_DEPRECATED_ATT,E_DEPRECATED_ATT_MESS)") +#elif HEDLEY_SUNPRO_VERSION_CHECK(5,13,0) && defined(__cplusplus) +# define HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("error_messages(off,symdeprecated,symdeprecated2)") +#elif HEDLEY_IAR_VERSION_CHECK(8,0,0) +# define HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("diag_suppress=Pe1444,Pe1215") +#elif HEDLEY_PELLES_VERSION_CHECK(2,90,0) +# define HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("warn(disable:2241)") +#else +# define HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED +#endif + +#if defined(HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS) +# undef HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS +#endif +#if HEDLEY_HAS_WARNING("-Wunknown-pragmas") +# define HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("clang diagnostic ignored \"-Wunknown-pragmas\"") +#elif HEDLEY_INTEL_VERSION_CHECK(13,0,0) +# define HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("warning(disable:161)") +#elif HEDLEY_PGI_VERSION_CHECK(17,10,0) +# define HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("diag_suppress 1675") +#elif HEDLEY_GCC_VERSION_CHECK(4,3,0) +# define HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("GCC diagnostic ignored \"-Wunknown-pragmas\"") +#elif HEDLEY_MSVC_VERSION_CHECK(15,0,0) +# define HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS __pragma(warning(disable:4068)) +#elif HEDLEY_TI_VERSION_CHECK(8,0,0) +# define HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("diag_suppress 163") +#elif HEDLEY_IAR_VERSION_CHECK(8,0,0) +# define HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("diag_suppress=Pe161") +#else +# define HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS +#endif + +#if defined(HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL) +# undef HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL +#endif +#if HEDLEY_HAS_WARNING("-Wcast-qual") +# define HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL _Pragma("clang diagnostic ignored \"-Wcast-qual\"") +#elif HEDLEY_INTEL_VERSION_CHECK(13,0,0) +# define HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL _Pragma("warning(disable:2203 2331)") +#elif HEDLEY_GCC_VERSION_CHECK(3,0,0) +# define HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL _Pragma("GCC diagnostic ignored \"-Wcast-qual\"") +#else +# define HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL +#endif + +#if defined(HEDLEY_DEPRECATED) +# undef HEDLEY_DEPRECATED +#endif +#if defined(HEDLEY_DEPRECATED_FOR) +# undef HEDLEY_DEPRECATED_FOR +#endif +#if defined(__cplusplus) && (__cplusplus >= 201402L) +# define HEDLEY_DEPRECATED(since) [[deprecated("Since " #since)]] +# define HEDLEY_DEPRECATED_FOR(since, replacement) [[deprecated("Since " #since "; use " #replacement)]] +#elif \ + HEDLEY_HAS_EXTENSION(attribute_deprecated_with_message) || \ + HEDLEY_GCC_VERSION_CHECK(4,5,0) || \ + HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ + HEDLEY_ARM_VERSION_CHECK(5,6,0) || \ + HEDLEY_SUNPRO_VERSION_CHECK(5,13,0) || \ + HEDLEY_PGI_VERSION_CHECK(17,10,0) || \ + HEDLEY_TI_VERSION_CHECK(8,3,0) +# define HEDLEY_DEPRECATED(since) __attribute__((__deprecated__("Since " #since))) +# define HEDLEY_DEPRECATED_FOR(since, replacement) __attribute__((__deprecated__("Since " #since "; use " #replacement))) +#elif \ + HEDLEY_HAS_ATTRIBUTE(deprecated) || \ + HEDLEY_GCC_VERSION_CHECK(3,1,0) || \ + HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ + HEDLEY_TI_VERSION_CHECK(8,0,0) || \ + (HEDLEY_TI_VERSION_CHECK(7,3,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) +# define HEDLEY_DEPRECATED(since) __attribute__((__deprecated__)) +# define HEDLEY_DEPRECATED_FOR(since, replacement) __attribute__((__deprecated__)) +#elif HEDLEY_MSVC_VERSION_CHECK(14,0,0) +# define HEDLEY_DEPRECATED(since) __declspec(deprecated("Since " # since)) +# define HEDLEY_DEPRECATED_FOR(since, replacement) __declspec(deprecated("Since " #since "; use " #replacement)) +#elif \ + HEDLEY_MSVC_VERSION_CHECK(13,10,0) || \ + HEDLEY_PELLES_VERSION_CHECK(6,50,0) +# define HEDLEY_DEPRECATED(since) _declspec(deprecated) +# define HEDLEY_DEPRECATED_FOR(since, replacement) __declspec(deprecated) +#elif HEDLEY_IAR_VERSION_CHECK(8,0,0) +# define HEDLEY_DEPRECATED(since) _Pragma("deprecated") +# define HEDLEY_DEPRECATED_FOR(since, replacement) _Pragma("deprecated") +#else +# define HEDLEY_DEPRECATED(since) +# define HEDLEY_DEPRECATED_FOR(since, replacement) +#endif + +#if defined(HEDLEY_UNAVAILABLE) +# undef HEDLEY_UNAVAILABLE +#endif +#if \ + HEDLEY_HAS_ATTRIBUTE(warning) || \ + HEDLEY_GCC_VERSION_CHECK(4,3,0) || \ + HEDLEY_INTEL_VERSION_CHECK(13,0,0) +# define HEDLEY_UNAVAILABLE(available_since) __attribute__((__warning__("Not available until " #available_since))) +#else +# define HEDLEY_UNAVAILABLE(available_since) +#endif + +#if defined(HEDLEY_WARN_UNUSED_RESULT) +# undef HEDLEY_WARN_UNUSED_RESULT +#endif +#if defined(__cplusplus) && (__cplusplus >= 201703L) +# define HEDLEY_WARN_UNUSED_RESULT [[nodiscard]] +#elif \ + HEDLEY_HAS_ATTRIBUTE(warn_unused_result) || \ + HEDLEY_GCC_VERSION_CHECK(3,4,0) || \ + HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ + HEDLEY_TI_VERSION_CHECK(8,0,0) || \ + (HEDLEY_TI_VERSION_CHECK(7,3,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ + (HEDLEY_SUNPRO_VERSION_CHECK(5,15,0) && defined(__cplusplus)) || \ + HEDLEY_PGI_VERSION_CHECK(17,10,0) +# define HEDLEY_WARN_UNUSED_RESULT __attribute__((__warn_unused_result__)) +#elif defined(_Check_return_) /* SAL */ +# define HEDLEY_WARN_UNUSED_RESULT _Check_return_ +#else +# define HEDLEY_WARN_UNUSED_RESULT +#endif + +#if defined(HEDLEY_SENTINEL) +# undef HEDLEY_SENTINEL +#endif +#if \ + HEDLEY_HAS_ATTRIBUTE(sentinel) || \ + HEDLEY_GCC_VERSION_CHECK(4,0,0) || \ + HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ + HEDLEY_ARM_VERSION_CHECK(5,4,0) +# define HEDLEY_SENTINEL(position) __attribute__((__sentinel__(position))) +#else +# define HEDLEY_SENTINEL(position) +#endif + +#if defined(HEDLEY_NO_RETURN) +# undef HEDLEY_NO_RETURN +#endif +#if HEDLEY_IAR_VERSION_CHECK(8,0,0) +# define HEDLEY_NO_RETURN __noreturn +#elif HEDLEY_INTEL_VERSION_CHECK(13,0,0) +# define HEDLEY_NO_RETURN __attribute__((__noreturn__)) +#elif defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L +# define HEDLEY_NO_RETURN _Noreturn +#elif defined(__cplusplus) && (__cplusplus >= 201103L) +# define HEDLEY_NO_RETURN [[noreturn]] +#elif \ + HEDLEY_HAS_ATTRIBUTE(noreturn) || \ + HEDLEY_GCC_VERSION_CHECK(3,2,0) || \ + HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \ + HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ + HEDLEY_IBM_VERSION_CHECK(10,1,0) || \ + HEDLEY_TI_VERSION_CHECK(18,0,0) || \ + (HEDLEY_TI_VERSION_CHECK(17,3,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) +# define HEDLEY_NO_RETURN __attribute__((__noreturn__)) +#elif HEDLEY_MSVC_VERSION_CHECK(13,10,0) +# define HEDLEY_NO_RETURN __declspec(noreturn) +#elif HEDLEY_TI_VERSION_CHECK(6,0,0) && defined(__cplusplus) +# define HEDLEY_NO_RETURN _Pragma("FUNC_NEVER_RETURNS;") +#elif HEDLEY_COMPCERT_VERSION_CHECK(3,2,0) +# define HEDLEY_NO_RETURN __attribute((noreturn)) +#elif HEDLEY_PELLES_VERSION_CHECK(9,0,0) +# define HEDLEY_NO_RETURN __declspec(noreturn) +#else +# define HEDLEY_NO_RETURN +#endif + +#if defined(HEDLEY_UNREACHABLE) +# undef HEDLEY_UNREACHABLE +#endif +#if defined(HEDLEY_UNREACHABLE_RETURN) +# undef HEDLEY_UNREACHABLE_RETURN +#endif +#if \ + (HEDLEY_HAS_BUILTIN(__builtin_unreachable) && (!defined(HEDLEY_ARM_VERSION))) || \ + HEDLEY_GCC_VERSION_CHECK(4,5,0) || \ + HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ + HEDLEY_IBM_VERSION_CHECK(13,1,5) +# define HEDLEY_UNREACHABLE() __builtin_unreachable() +#elif HEDLEY_MSVC_VERSION_CHECK(13,10,0) +# define HEDLEY_UNREACHABLE() __assume(0) +#elif HEDLEY_TI_VERSION_CHECK(6,0,0) +# if defined(__cplusplus) +# define HEDLEY_UNREACHABLE() std::_nassert(0) +# else +# define HEDLEY_UNREACHABLE() _nassert(0) +# endif +# define HEDLEY_UNREACHABLE_RETURN(value) return value +#elif defined(EXIT_FAILURE) +# define HEDLEY_UNREACHABLE() abort() +#else +# define HEDLEY_UNREACHABLE() +# define HEDLEY_UNREACHABLE_RETURN(value) return value +#endif +#if !defined(HEDLEY_UNREACHABLE_RETURN) +# define HEDLEY_UNREACHABLE_RETURN(value) HEDLEY_UNREACHABLE() +#endif + +#if defined(HEDLEY_ASSUME) +# undef HEDLEY_ASSUME +#endif +#if \ + HEDLEY_MSVC_VERSION_CHECK(13,10,0) || \ + HEDLEY_INTEL_VERSION_CHECK(13,0,0) +# define HEDLEY_ASSUME(expr) __assume(expr) +#elif HEDLEY_HAS_BUILTIN(__builtin_assume) +# define HEDLEY_ASSUME(expr) __builtin_assume(expr) +#elif HEDLEY_TI_VERSION_CHECK(6,0,0) +# if defined(__cplusplus) +# define HEDLEY_ASSUME(expr) std::_nassert(expr) +# else +# define HEDLEY_ASSUME(expr) _nassert(expr) +# endif +#elif \ + (HEDLEY_HAS_BUILTIN(__builtin_unreachable) && !defined(HEDLEY_ARM_VERSION)) || \ + HEDLEY_GCC_VERSION_CHECK(4,5,0) || \ + HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ + HEDLEY_IBM_VERSION_CHECK(13,1,5) +# define HEDLEY_ASSUME(expr) ((void) ((expr) ? 1 : (__builtin_unreachable(), 1))) +#else +# define HEDLEY_ASSUME(expr) ((void) (expr)) +#endif + + +HEDLEY_DIAGNOSTIC_PUSH +#if \ + HEDLEY_HAS_WARNING("-Wvariadic-macros") || \ + HEDLEY_GCC_VERSION_CHECK(4,0,0) +# if defined(__clang__) +# pragma clang diagnostic ignored "-Wvariadic-macros" +# elif defined(HEDLEY_GCC_VERSION) +# pragma GCC diagnostic ignored "-Wvariadic-macros" +# endif +#endif +#if defined(HEDLEY_NON_NULL) +# undef HEDLEY_NON_NULL +#endif +#if \ + HEDLEY_HAS_ATTRIBUTE(nonnull) || \ + HEDLEY_GCC_VERSION_CHECK(3,3,0) || \ + HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ + HEDLEY_ARM_VERSION_CHECK(4,1,0) +# define HEDLEY_NON_NULL(...) __attribute__((__nonnull__(__VA_ARGS__))) +#else +# define HEDLEY_NON_NULL(...) +#endif +HEDLEY_DIAGNOSTIC_POP + +#if defined(HEDLEY_PRINTF_FORMAT) +# undef HEDLEY_PRINTF_FORMAT +#endif +#if defined(__MINGW32__) && HEDLEY_GCC_HAS_ATTRIBUTE(format,4,4,0) && !defined(__USE_MINGW_ANSI_STDIO) +# define HEDLEY_PRINTF_FORMAT(string_idx,first_to_check) __attribute__((__format__(ms_printf, string_idx, first_to_check))) +#elif defined(__MINGW32__) && HEDLEY_GCC_HAS_ATTRIBUTE(format,4,4,0) && defined(__USE_MINGW_ANSI_STDIO) +# define HEDLEY_PRINTF_FORMAT(string_idx,first_to_check) __attribute__((__format__(gnu_printf, string_idx, first_to_check))) +#elif \ + HEDLEY_HAS_ATTRIBUTE(format) || \ + HEDLEY_GCC_VERSION_CHECK(3,1,0) || \ + HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ + HEDLEY_ARM_VERSION_CHECK(5,6,0) || \ + HEDLEY_IBM_VERSION_CHECK(10,1,0) || \ + HEDLEY_TI_VERSION_CHECK(8,0,0) || \ + (HEDLEY_TI_VERSION_CHECK(7,3,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) +# define HEDLEY_PRINTF_FORMAT(string_idx,first_to_check) __attribute__((__format__(__printf__, string_idx, first_to_check))) +#elif HEDLEY_PELLES_VERSION_CHECK(6,0,0) +# define HEDLEY_PRINTF_FORMAT(string_idx,first_to_check) __declspec(vaformat(printf,string_idx,first_to_check)) +#else +# define HEDLEY_PRINTF_FORMAT(string_idx,first_to_check) +#endif + +#if defined(HEDLEY_CONSTEXPR) +# undef HEDLEY_CONSTEXPR +#endif +#if defined(__cplusplus) +# if __cplusplus >= 201103L +# define HEDLEY_CONSTEXPR constexpr +# endif +#endif +#if !defined(HEDLEY_CONSTEXPR) +# define HEDLEY_CONSTEXPR +#endif + +#if defined(HEDLEY_PREDICT) +# undef HEDLEY_PREDICT +#endif +#if defined(HEDLEY_LIKELY) +# undef HEDLEY_LIKELY +#endif +#if defined(HEDLEY_UNLIKELY) +# undef HEDLEY_UNLIKELY +#endif +#if defined(HEDLEY_UNPREDICTABLE) +# undef HEDLEY_UNPREDICTABLE +#endif +#if HEDLEY_HAS_BUILTIN(__builtin_unpredictable) +# define HEDLEY_UNPREDICTABLE(expr) __builtin_unpredictable(!!(expr)) +#endif +#if \ + HEDLEY_HAS_BUILTIN(__builtin_expect_with_probability) || \ + HEDLEY_GCC_VERSION_CHECK(9,0,0) +# define HEDLEY_PREDICT(expr, value, probability) __builtin_expect_with_probability(expr, value, probability) +# define HEDLEY_PREDICT_TRUE(expr, probability) __builtin_expect_with_probability(!!(expr), 1, probability) +# define HEDLEY_PREDICT_FALSE(expr, probability) __builtin_expect_with_probability(!!(expr), 0, probability) +# define HEDLEY_LIKELY(expr) __builtin_expect(!!(expr), 1) +# define HEDLEY_UNLIKELY(expr) __builtin_expect(!!(expr), 0) +# if !defined(HEDLEY_BUILTIN_UNPREDICTABLE) +# define HEDLEY_BUILTIN_UNPREDICTABLE(expr) __builtin_expect_with_probability(!!(expr), 1, 0.5) +# endif +#elif \ + HEDLEY_HAS_BUILTIN(__builtin_expect) || \ + HEDLEY_GCC_VERSION_CHECK(3,0,0) || \ + HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ + (HEDLEY_SUNPRO_VERSION_CHECK(5,15,0) && defined(__cplusplus)) || \ + HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ + HEDLEY_IBM_VERSION_CHECK(10,1,0) || \ + HEDLEY_TI_VERSION_CHECK(6,1,0) || \ + HEDLEY_TINYC_VERSION_CHECK(0,9,27) +# define HEDLEY_PREDICT(expr, expected, probability) \ + (((probability) >= 0.9) ? __builtin_expect(!!(expr), (expected)) : (((void) (expected)), !!(expr))) +# define HEDLEY_PREDICT_TRUE(expr, probability) \ + (__extension__ ({ \ + HEDLEY_CONSTEXPR double hedley_probability_ = (probability); \ + ((hedley_probability_ >= 0.9) ? __builtin_expect(!!(expr), 1) : ((hedley_probability_ <= 0.1) ? __builtin_expect(!!(expr), 0) : !!(expr))); \ + })) +# define HEDLEY_PREDICT_FALSE(expr, probability) \ + (__extension__ ({ \ + HEDLEY_CONSTEXPR double hedley_probability_ = (probability); \ + ((hedley_probability_ >= 0.9) ? __builtin_expect(!!(expr), 0) : ((hedley_probability_ <= 0.1) ? __builtin_expect(!!(expr), 1) : !!(expr))); \ + })) +# define HEDLEY_LIKELY(expr) __builtin_expect(!!(expr), 1) +# define HEDLEY_UNLIKELY(expr) __builtin_expect(!!(expr), 0) +#else +# define HEDLEY_PREDICT(expr, expected, probability) (((void) (expected)), !!(expr)) +# define HEDLEY_PREDICT_TRUE(expr, probability) (!!(expr)) +# define HEDLEY_PREDICT_FALSE(expr, probability) (!!(expr)) +# define HEDLEY_LIKELY(expr) (!!(expr)) +# define HEDLEY_UNLIKELY(expr) (!!(expr)) +#endif +#if !defined(HEDLEY_UNPREDICTABLE) +# define HEDLEY_UNPREDICTABLE(expr) HEDLEY_PREDICT(expr, 1, 0.5) +#endif + +#if defined(HEDLEY_MALLOC) +# undef HEDLEY_MALLOC +#endif +#if \ + HEDLEY_HAS_ATTRIBUTE(malloc) || \ + HEDLEY_GCC_VERSION_CHECK(3,1,0) || \ + HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ + HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \ + HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ + HEDLEY_IBM_VERSION_CHECK(12,1,0) || \ + HEDLEY_TI_VERSION_CHECK(8,0,0) || \ + (HEDLEY_TI_VERSION_CHECK(7,3,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) +# define HEDLEY_MALLOC __attribute__((__malloc__)) +#elif HEDLEY_MSVC_VERSION_CHECK(14, 0, 0) +# define HEDLEY_MALLOC __declspec(restrict) +#else +# define HEDLEY_MALLOC +#endif + +#if defined(HEDLEY_PURE) +# undef HEDLEY_PURE +#endif +#if \ + HEDLEY_HAS_ATTRIBUTE(pure) || \ + HEDLEY_GCC_VERSION_CHECK(2,96,0) || \ + HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ + HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \ + HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ + HEDLEY_IBM_VERSION_CHECK(10,1,0) || \ + HEDLEY_TI_VERSION_CHECK(8,0,0) || \ + (HEDLEY_TI_VERSION_CHECK(7,3,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ + HEDLEY_PGI_VERSION_CHECK(17,10,0) +# define HEDLEY_PURE __attribute__((__pure__)) +#elif HEDLEY_TI_VERSION_CHECK(6,0,0) && defined(__cplusplus) +# define HEDLEY_PURE _Pragma("FUNC_IS_PURE;") +#else +# define HEDLEY_PURE +#endif + +#if defined(HEDLEY_CONST) +# undef HEDLEY_CONST +#endif +#if \ + HEDLEY_HAS_ATTRIBUTE(const) || \ + HEDLEY_GCC_VERSION_CHECK(2,5,0) || \ + HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ + HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \ + HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ + HEDLEY_IBM_VERSION_CHECK(10,1,0) || \ + HEDLEY_TI_VERSION_CHECK(8,0,0) || \ + (HEDLEY_TI_VERSION_CHECK(7,3,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ + HEDLEY_PGI_VERSION_CHECK(17,10,0) +# define HEDLEY_CONST __attribute__((__const__)) +#else +# define HEDLEY_CONST HEDLEY_PURE +#endif + +#if defined(HEDLEY_RESTRICT) +# undef HEDLEY_RESTRICT +#endif +#if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) && !defined(__cplusplus) +# define HEDLEY_RESTRICT restrict +#elif \ + HEDLEY_GCC_VERSION_CHECK(3,1,0) || \ + HEDLEY_MSVC_VERSION_CHECK(14,0,0) || \ + HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ + HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ + HEDLEY_IBM_VERSION_CHECK(10,1,0) || \ + HEDLEY_PGI_VERSION_CHECK(17,10,0) || \ + HEDLEY_TI_VERSION_CHECK(8,0,0) || \ + (HEDLEY_SUNPRO_VERSION_CHECK(5,14,0) && defined(__cplusplus)) || \ + HEDLEY_IAR_VERSION_CHECK(8,0,0) || \ + defined(__clang__) +# define HEDLEY_RESTRICT __restrict +#elif HEDLEY_SUNPRO_VERSION_CHECK(5,3,0) && !defined(__cplusplus) +# define HEDLEY_RESTRICT _Restrict +#else +# define HEDLEY_RESTRICT +#endif + +#if defined(HEDLEY_INLINE) +# undef HEDLEY_INLINE +#endif +#if \ + (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)) || \ + (defined(__cplusplus) && (__cplusplus >= 199711L)) +# define HEDLEY_INLINE inline +#elif \ + defined(HEDLEY_GCC_VERSION) || \ + HEDLEY_ARM_VERSION_CHECK(6,2,0) +# define HEDLEY_INLINE __inline__ +#elif \ + HEDLEY_MSVC_VERSION_CHECK(12,0,0) || \ + HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ + HEDLEY_TI_VERSION_CHECK(8,0,0) +# define HEDLEY_INLINE __inline +#else +# define HEDLEY_INLINE +#endif + +#if defined(HEDLEY_ALWAYS_INLINE) +# undef HEDLEY_ALWAYS_INLINE +#endif +#if \ + HEDLEY_HAS_ATTRIBUTE(always_inline) || \ + HEDLEY_GCC_VERSION_CHECK(4,0,0) || \ + HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ + HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \ + HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ + HEDLEY_IBM_VERSION_CHECK(10,1,0) || \ + HEDLEY_TI_VERSION_CHECK(8,0,0) || \ + (HEDLEY_TI_VERSION_CHECK(7,3,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) +# define HEDLEY_ALWAYS_INLINE __attribute__((__always_inline__)) HEDLEY_INLINE +#elif HEDLEY_MSVC_VERSION_CHECK(12,0,0) +# define HEDLEY_ALWAYS_INLINE __forceinline +#elif HEDLEY_TI_VERSION_CHECK(7,0,0) && defined(__cplusplus) +# define HEDLEY_ALWAYS_INLINE _Pragma("FUNC_ALWAYS_INLINE;") +#elif HEDLEY_IAR_VERSION_CHECK(8,0,0) +# define HEDLEY_ALWAYS_INLINE _Pragma("inline=forced") +#else +# define HEDLEY_ALWAYS_INLINE HEDLEY_INLINE +#endif + +#if defined(HEDLEY_NEVER_INLINE) +# undef HEDLEY_NEVER_INLINE +#endif +#if \ + HEDLEY_HAS_ATTRIBUTE(noinline) || \ + HEDLEY_GCC_VERSION_CHECK(4,0,0) || \ + HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ + HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \ + HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ + HEDLEY_IBM_VERSION_CHECK(10,1,0) || \ + HEDLEY_TI_VERSION_CHECK(8,0,0) || \ + (HEDLEY_TI_VERSION_CHECK(7,3,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) +# define HEDLEY_NEVER_INLINE __attribute__((__noinline__)) +#elif HEDLEY_MSVC_VERSION_CHECK(13,10,0) +# define HEDLEY_NEVER_INLINE __declspec(noinline) +#elif HEDLEY_PGI_VERSION_CHECK(10,2,0) +# define HEDLEY_NEVER_INLINE _Pragma("noinline") +#elif HEDLEY_TI_VERSION_CHECK(6,0,0) && defined(__cplusplus) +# define HEDLEY_NEVER_INLINE _Pragma("FUNC_CANNOT_INLINE;") +#elif HEDLEY_IAR_VERSION_CHECK(8,0,0) +# define HEDLEY_NEVER_INLINE _Pragma("inline=never") +#elif HEDLEY_COMPCERT_VERSION_CHECK(3,2,0) +# define HEDLEY_NEVER_INLINE __attribute((noinline)) +#elif HEDLEY_PELLES_VERSION_CHECK(9,0,0) +# define HEDLEY_NEVER_INLINE __declspec(noinline) +#else +# define HEDLEY_NEVER_INLINE +#endif + +#if defined(HEDLEY_PRIVATE) +# undef HEDLEY_PRIVATE +#endif +#if defined(HEDLEY_PUBLIC) +# undef HEDLEY_PUBLIC +#endif +#if defined(HEDLEY_IMPORT) +# undef HEDLEY_IMPORT +#endif +#if defined(_WIN32) || defined(__CYGWIN__) +# define HEDLEY_PRIVATE +# define HEDLEY_PUBLIC __declspec(dllexport) +# define HEDLEY_IMPORT __declspec(dllimport) +#else +# if \ + HEDLEY_HAS_ATTRIBUTE(visibility) || \ + HEDLEY_GCC_VERSION_CHECK(3,3,0) || \ + HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \ + HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ + HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ + HEDLEY_IBM_VERSION_CHECK(13,1,0) || \ + HEDLEY_TI_VERSION_CHECK(8,0,0) || \ + (HEDLEY_TI_VERSION_CHECK(7,3,0) && defined(__TI_EABI__) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) +# define HEDLEY_PRIVATE __attribute__((__visibility__("hidden"))) +# define HEDLEY_PUBLIC __attribute__((__visibility__("default"))) +# else +# define HEDLEY_PRIVATE +# define HEDLEY_PUBLIC +# endif +# define HEDLEY_IMPORT extern +#endif + +#if defined(HEDLEY_NO_THROW) +# undef HEDLEY_NO_THROW +#endif +#if \ + HEDLEY_HAS_ATTRIBUTE(nothrow) || \ + HEDLEY_GCC_VERSION_CHECK(3,3,0) || \ + HEDLEY_INTEL_VERSION_CHECK(13,0,0) +# define HEDLEY_NO_THROW __attribute__((__nothrow__)) +#elif \ + HEDLEY_MSVC_VERSION_CHECK(13,1,0) || \ + HEDLEY_ARM_VERSION_CHECK(4,1,0) +# define HEDLEY_NO_THROW __declspec(nothrow) +#else +# define HEDLEY_NO_THROW +#endif + +#if defined(HEDLEY_FALL_THROUGH) +# undef HEDLEY_FALL_THROUGH +#endif +#if \ + defined(__cplusplus) && \ + (!defined(HEDLEY_SUNPRO_VERSION) || HEDLEY_SUNPRO_VERSION_CHECK(5,15,0)) && \ + !defined(HEDLEY_PGI_VERSION) +# if \ + (__cplusplus >= 201703L) || \ + ((__cplusplus >= 201103L) && HEDLEY_HAS_CPP_ATTRIBUTE(fallthrough)) +# define HEDLEY_FALL_THROUGH [[fallthrough]] +# elif (__cplusplus >= 201103L) && HEDLEY_HAS_CPP_ATTRIBUTE(clang::fallthrough) +# define HEDLEY_FALL_THROUGH [[clang::fallthrough]] +# elif (__cplusplus >= 201103L) && HEDLEY_GCC_VERSION_CHECK(7,0,0) +# define HEDLEY_FALL_THROUGH [[gnu::fallthrough]] +# endif +#endif +#if !defined(HEDLEY_FALL_THROUGH) +# if HEDLEY_GNUC_HAS_ATTRIBUTE(fallthrough,7,0,0) && !defined(HEDLEY_PGI_VERSION) +# define HEDLEY_FALL_THROUGH __attribute__((__fallthrough__)) +# elif defined(__fallthrough) /* SAL */ +# define HEDLEY_FALL_THROUGH __fallthrough +# else +# define HEDLEY_FALL_THROUGH +# endif +#endif + +#if defined(HEDLEY_RETURNS_NON_NULL) +# undef HEDLEY_RETURNS_NON_NULL +#endif +#if \ + HEDLEY_HAS_ATTRIBUTE(returns_nonnull) || \ + HEDLEY_GCC_VERSION_CHECK(4,9,0) +# define HEDLEY_RETURNS_NON_NULL __attribute__((__returns_nonnull__)) +#elif defined(_Ret_notnull_) /* SAL */ +# define HEDLEY_RETURNS_NON_NULL _Ret_notnull_ +#else +# define HEDLEY_RETURNS_NON_NULL +#endif + +#if defined(HEDLEY_ARRAY_PARAM) +# undef HEDLEY_ARRAY_PARAM +#endif +#if \ + defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) && \ + !defined(__STDC_NO_VLA__) && \ + !defined(__cplusplus) && \ + !defined(HEDLEY_PGI_VERSION) && \ + !defined(HEDLEY_TINYC_VERSION) +# define HEDLEY_ARRAY_PARAM(name) (name) +#else +# define HEDLEY_ARRAY_PARAM(name) +#endif + +#if defined(HEDLEY_IS_CONSTANT) +# undef HEDLEY_IS_CONSTANT +#endif +#if defined(HEDLEY_REQUIRE_CONSTEXPR) +# undef HEDLEY_REQUIRE_CONSTEXPR +#endif +/* Note the double-underscore. For internal use only; no API + * guarantees! */ +#if defined(HEDLEY__IS_CONSTEXPR) +# undef HEDLEY__IS_CONSTEXPR +#endif + +#if \ + HEDLEY_HAS_BUILTIN(__builtin_constant_p) || \ + HEDLEY_GCC_VERSION_CHECK(3,4,0) || \ + HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ + HEDLEY_TINYC_VERSION_CHECK(0,9,19) || \ + HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ + HEDLEY_IBM_VERSION_CHECK(13,1,0) || \ + HEDLEY_TI_VERSION_CHECK(6,1,0) || \ + HEDLEY_SUNPRO_VERSION_CHECK(5,10,0) || \ + HEDLEY_CRAY_VERSION_CHECK(8,1,0) +# define HEDLEY_IS_CONSTANT(expr) __builtin_constant_p(expr) +#endif +#if !defined(__cplusplus) +# if \ + HEDLEY_HAS_BUILTIN(__builtin_types_compatible_p) || \ + HEDLEY_GCC_VERSION_CHECK(3,4,0) || \ + HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ + HEDLEY_IBM_VERSION_CHECK(13,1,0) || \ + HEDLEY_CRAY_VERSION_CHECK(8,1,0) || \ + HEDLEY_ARM_VERSION_CHECK(5,4,0) || \ + HEDLEY_TINYC_VERSION_CHECK(0,9,24) +# if defined(__INTPTR_TYPE__) +# define HEDLEY__IS_CONSTEXPR(expr) __builtin_types_compatible_p(__typeof__((1 ? (void*) ((__INTPTR_TYPE__) ((expr) * 0)) : (int*) 0)), int*) +# else +# include +# define HEDLEY__IS_CONSTEXPR(expr) __builtin_types_compatible_p(__typeof__((1 ? (void*) ((intptr_t) ((expr) * 0)) : (int*) 0)), int*) +# endif +# elif \ + (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 201112L) && !defined(HEDLEY_SUNPRO_VERSION) && !defined(HEDLEY_PGI_VERSION)) || \ + HEDLEY_HAS_EXTENSION(c_generic_selections) || \ + HEDLEY_GCC_VERSION_CHECK(4,9,0) || \ + HEDLEY_INTEL_VERSION_CHECK(17,0,0) || \ + HEDLEY_IBM_VERSION_CHECK(12,1,0) || \ + HEDLEY_ARM_VERSION_CHECK(5,3,0) +# if defined(__INTPTR_TYPE__) +# define HEDLEY__IS_CONSTEXPR(expr) _Generic((1 ? (void*) ((__INTPTR_TYPE__) ((expr) * 0)) : (int*) 0), int*: 1, void*: 0) +# else +# include +# define HEDLEY__IS_CONSTEXPR(expr) _Generic((1 ? (void*) ((intptr_t) * 0) : (int*) 0), int*: 1, void*: 0) +# endif +# elif \ + defined(HEDLEY_GCC_VERSION) || \ + defined(HEDLEY_INTEL_VERSION) || \ + defined(HEDLEY_TINYC_VERSION) || \ + defined(HEDLEY_TI_VERSION) || \ + defined(__clang__) +# define HEDLEY__IS_CONSTEXPR(expr) ( \ + sizeof(void) != \ + sizeof(*( \ + 1 ? \ + ((void*) ((expr) * 0L) ) : \ + ((struct { char v[sizeof(void) * 2]; } *) 1) \ + ) \ + ) \ + ) +# endif +#endif +#if defined(HEDLEY__IS_CONSTEXPR) +# if !defined(HEDLEY_IS_CONSTANT) +# define HEDLEY_IS_CONSTANT(expr) HEDLEY__IS_CONSTEXPR(expr) +# endif +# define HEDLEY_REQUIRE_CONSTEXPR(expr) (HEDLEY__IS_CONSTEXPR(expr) ? (expr) : (-1)) +#else +# if !defined(HEDLEY_IS_CONSTANT) +# define HEDLEY_IS_CONSTANT(expr) (0) +# endif +# define HEDLEY_REQUIRE_CONSTEXPR(expr) (expr) +#endif + +#if defined(HEDLEY_BEGIN_C_DECLS) +# undef HEDLEY_BEGIN_C_DECLS +#endif +#if defined(HEDLEY_END_C_DECLS) +# undef HEDLEY_END_C_DECLS +#endif +#if defined(HEDLEY_C_DECL) +# undef HEDLEY_C_DECL +#endif +#if defined(__cplusplus) +# define HEDLEY_BEGIN_C_DECLS extern "C" { +# define HEDLEY_END_C_DECLS } +# define HEDLEY_C_DECL extern "C" +#else +# define HEDLEY_BEGIN_C_DECLS +# define HEDLEY_END_C_DECLS +# define HEDLEY_C_DECL +#endif + +#if defined(HEDLEY_STATIC_ASSERT) +# undef HEDLEY_STATIC_ASSERT +#endif +#if \ + !defined(__cplusplus) && ( \ + (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 201112L)) || \ + HEDLEY_HAS_FEATURE(c_static_assert) || \ + HEDLEY_GCC_VERSION_CHECK(6,0,0) || \ + HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ + defined(_Static_assert) \ + ) +# define HEDLEY_STATIC_ASSERT(expr, message) _Static_assert(expr, message) +#elif \ + (defined(__cplusplus) && (__cplusplus >= 201703L)) || \ + HEDLEY_MSVC_VERSION_CHECK(16,0,0) || \ + (defined(__cplusplus) && HEDLEY_TI_VERSION_CHECK(8,3,0)) +# define HEDLEY_STATIC_ASSERT(expr, message) static_assert(expr, message) +#elif defined(__cplusplus) && (__cplusplus >= 201103L) +# define HEDLEY_STATIC_ASSERT(expr, message) static_assert(expr) +#else +# define HEDLEY_STATIC_ASSERT(expr, message) +#endif + +#if defined(HEDLEY_CONST_CAST) +# undef HEDLEY_CONST_CAST +#endif +#if defined(__cplusplus) +# define HEDLEY_CONST_CAST(T, expr) (const_cast(expr)) +#elif \ + HEDLEY_HAS_WARNING("-Wcast-qual") || \ + HEDLEY_GCC_VERSION_CHECK(4,6,0) || \ + HEDLEY_INTEL_VERSION_CHECK(13,0,0) +# define HEDLEY_CONST_CAST(T, expr) (__extension__ ({ \ + HEDLEY_DIAGNOSTIC_PUSH \ + HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL \ + ((T) (expr)); \ + HEDLEY_DIAGNOSTIC_POP \ + })) +#else +# define HEDLEY_CONST_CAST(T, expr) ((T) (expr)) +#endif + +#if defined(HEDLEY_REINTERPRET_CAST) +# undef HEDLEY_REINTERPRET_CAST +#endif +#if defined(__cplusplus) +# define HEDLEY_REINTERPRET_CAST(T, expr) (reinterpret_cast(expr)) +#else +# define HEDLEY_REINTERPRET_CAST(T, expr) (*((T*) &(expr))) +#endif + +#if defined(HEDLEY_STATIC_CAST) +# undef HEDLEY_STATIC_CAST +#endif +#if defined(__cplusplus) +# define HEDLEY_STATIC_CAST(T, expr) (static_cast(expr)) +#else +# define HEDLEY_STATIC_CAST(T, expr) ((T) (expr)) +#endif + +#if defined(HEDLEY_CPP_CAST) +# undef HEDLEY_CPP_CAST +#endif +#if defined(__cplusplus) +# define HEDLEY_CPP_CAST(T, expr) static_cast(expr) +#else +# define HEDLEY_CPP_CAST(T, expr) (expr) +#endif + +#if defined(HEDLEY_MESSAGE) +# undef HEDLEY_MESSAGE +#endif +#if HEDLEY_HAS_WARNING("-Wunknown-pragmas") +# define HEDLEY_MESSAGE(msg) \ + HEDLEY_DIAGNOSTIC_PUSH \ + HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS \ + HEDLEY_PRAGMA(message msg) \ + HEDLEY_DIAGNOSTIC_POP +#elif \ + HEDLEY_GCC_VERSION_CHECK(4,4,0) || \ + HEDLEY_INTEL_VERSION_CHECK(13,0,0) +# define HEDLEY_MESSAGE(msg) HEDLEY_PRAGMA(message msg) +#elif HEDLEY_CRAY_VERSION_CHECK(5,0,0) +# define HEDLEY_MESSAGE(msg) HEDLEY_PRAGMA(_CRI message msg) +#elif HEDLEY_IAR_VERSION_CHECK(8,0,0) +# define HEDLEY_MESSAGE(msg) HEDLEY_PRAGMA(message(msg)) +#elif HEDLEY_PELLES_VERSION_CHECK(2,0,0) +# define HEDLEY_MESSAGE(msg) HEDLEY_PRAGMA(message(msg)) +#else +# define HEDLEY_MESSAGE(msg) +#endif + +#if defined(HEDLEY_WARNING) +# undef HEDLEY_WARNING +#endif +#if HEDLEY_HAS_WARNING("-Wunknown-pragmas") +# define HEDLEY_WARNING(msg) \ + HEDLEY_DIAGNOSTIC_PUSH \ + HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS \ + HEDLEY_PRAGMA(clang warning msg) \ + HEDLEY_DIAGNOSTIC_POP +#elif \ + HEDLEY_GCC_VERSION_CHECK(4,8,0) || \ + HEDLEY_PGI_VERSION_CHECK(18,4,0) +# define HEDLEY_WARNING(msg) HEDLEY_PRAGMA(GCC warning msg) +#elif HEDLEY_MSVC_VERSION_CHECK(15,0,0) +# define HEDLEY_WARNING(msg) HEDLEY_PRAGMA(message(msg)) +#else +# define HEDLEY_WARNING(msg) HEDLEY_MESSAGE(msg) +#endif + +#if defined(HEDLEY_REQUIRE_MSG) +# undef HEDLEY_REQUIRE_MSG +#endif +#if HEDLEY_HAS_ATTRIBUTE(diagnose_if) +# if HEDLEY_HAS_WARNING("-Wgcc-compat") +# define HEDLEY_REQUIRE_MSG(expr, msg) \ + HEDLEY_DIAGNOSTIC_PUSH \ + _Pragma("clang diagnostic ignored \"-Wgcc-compat\"") \ + __attribute__((__diagnose_if__(!(expr), msg, "error"))) \ + HEDLEY_DIAGNOSTIC_POP +# else +# define HEDLEY_REQUIRE_MSG(expr, msg) __attribute__((__diagnose_if__(!(expr), msg, "error"))) +# endif +#else +# define HEDLEY_REQUIRE_MSG(expr, msg) +#endif + +#if defined(HEDLEY_REQUIRE) +# undef HEDLEY_REQUIRE +#endif +#define HEDLEY_REQUIRE(expr) HEDLEY_REQUIRE_MSG(expr, #expr) + +#if defined(HEDLEY_FLAGS) +# undef HEDLEY_FLAGS +#endif +#if HEDLEY_HAS_ATTRIBUTE(flag_enum) +# define HEDLEY_FLAGS __attribute__((__flag_enum__)) +#endif + +#if defined(HEDLEY_FLAGS_CAST) +# undef HEDLEY_FLAGS_CAST +#endif +#if HEDLEY_INTEL_VERSION_CHECK(19,0,0) +# define HEDLEY_FLAGS_CAST(T, expr) (__extension__ ({ \ + HEDLEY_DIAGNOSTIC_PUSH \ + _Pragma("warning(disable:188)") \ + ((T) (expr)); \ + HEDLEY_DIAGNOSTIC_POP \ + })) +#else +# define HEDLEY_FLAGS_CAST(T, expr) HEDLEY_STATIC_CAST(T, expr) +#endif + +/* Remaining macros are deprecated. */ + +#if defined(HEDLEY_GCC_NOT_CLANG_VERSION_CHECK) +# undef HEDLEY_GCC_NOT_CLANG_VERSION_CHECK +#endif +#if defined(__clang__) +# define HEDLEY_GCC_NOT_CLANG_VERSION_CHECK(major,minor,patch) (0) +#else +# define HEDLEY_GCC_NOT_CLANG_VERSION_CHECK(major,minor,patch) HEDLEY_GCC_VERSION_CHECK(major,minor,patch) +#endif + +#if defined(HEDLEY_CLANG_HAS_ATTRIBUTE) +# undef HEDLEY_CLANG_HAS_ATTRIBUTE +#endif +#define HEDLEY_CLANG_HAS_ATTRIBUTE(attribute) HEDLEY_HAS_ATTRIBUTE(attribute) + +#if defined(HEDLEY_CLANG_HAS_CPP_ATTRIBUTE) +# undef HEDLEY_CLANG_HAS_CPP_ATTRIBUTE +#endif +#define HEDLEY_CLANG_HAS_CPP_ATTRIBUTE(attribute) HEDLEY_HAS_CPP_ATTRIBUTE(attribute) + +#if defined(HEDLEY_CLANG_HAS_BUILTIN) +# undef HEDLEY_CLANG_HAS_BUILTIN +#endif +#define HEDLEY_CLANG_HAS_BUILTIN(builtin) HEDLEY_HAS_BUILTIN(builtin) + +#if defined(HEDLEY_CLANG_HAS_FEATURE) +# undef HEDLEY_CLANG_HAS_FEATURE +#endif +#define HEDLEY_CLANG_HAS_FEATURE(feature) HEDLEY_HAS_FEATURE(feature) + +#if defined(HEDLEY_CLANG_HAS_EXTENSION) +# undef HEDLEY_CLANG_HAS_EXTENSION +#endif +#define HEDLEY_CLANG_HAS_EXTENSION(extension) HEDLEY_HAS_EXTENSION(extension) + +#if defined(HEDLEY_CLANG_HAS_DECLSPEC_DECLSPEC_ATTRIBUTE) +# undef HEDLEY_CLANG_HAS_DECLSPEC_DECLSPEC_ATTRIBUTE +#endif +#define HEDLEY_CLANG_HAS_DECLSPEC_ATTRIBUTE(attribute) HEDLEY_HAS_DECLSPEC_ATTRIBUTE(attribute) + +#if defined(HEDLEY_CLANG_HAS_WARNING) +# undef HEDLEY_CLANG_HAS_WARNING +#endif +#define HEDLEY_CLANG_HAS_WARNING(warning) HEDLEY_HAS_WARNING(warning) + +#endif /* !defined(HEDLEY_VERSION) || (HEDLEY_VERSION < X) */ diff --git a/include/nlohmann/detail/conversions/from_json.hpp b/include/nlohmann/detail/conversions/from_json.hpp index b7848c9e..4520041e 100644 --- a/include/nlohmann/detail/conversions/from_json.hpp +++ b/include/nlohmann/detail/conversions/from_json.hpp @@ -26,7 +26,7 @@ namespace detail template void from_json(const BasicJsonType& j, typename std::nullptr_t& n) { - if (HEDLEY_UNLIKELY(not j.is_null())) + if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not j.is_null())) { JSON_THROW(type_error::create(302, "type must be null, but is " + std::string(j.type_name()))); } @@ -66,7 +66,7 @@ void get_arithmetic_value(const BasicJsonType& j, ArithmeticType& val) template void from_json(const BasicJsonType& j, typename BasicJsonType::boolean_t& b) { - if (HEDLEY_UNLIKELY(not j.is_boolean())) + if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not j.is_boolean())) { JSON_THROW(type_error::create(302, "type must be boolean, but is " + std::string(j.type_name()))); } @@ -76,7 +76,7 @@ void from_json(const BasicJsonType& j, typename BasicJsonType::boolean_t& b) template void from_json(const BasicJsonType& j, typename BasicJsonType::string_t& s) { - if (HEDLEY_UNLIKELY(not j.is_string())) + if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not j.is_string())) { JSON_THROW(type_error::create(302, "type must be string, but is " + std::string(j.type_name()))); } @@ -92,7 +92,7 @@ template < int > = 0 > void from_json(const BasicJsonType& j, ConstructibleStringType& s) { - if (HEDLEY_UNLIKELY(not j.is_string())) + if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not j.is_string())) { JSON_THROW(type_error::create(302, "type must be string, but is " + std::string(j.type_name()))); } @@ -132,7 +132,7 @@ template::value, int> = 0> void from_json(const BasicJsonType& j, std::forward_list& l) { - if (HEDLEY_UNLIKELY(not j.is_array())) + if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not j.is_array())) { JSON_THROW(type_error::create(302, "type must be array, but is " + std::string(j.type_name()))); } @@ -149,7 +149,7 @@ template::value, int> = 0> void from_json(const BasicJsonType& j, std::valarray& l) { - if (HEDLEY_UNLIKELY(not j.is_array())) + if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not j.is_array())) { JSON_THROW(type_error::create(302, "type must be array, but is " + std::string(j.type_name()))); } @@ -236,7 +236,7 @@ auto from_json(const BasicJsonType& j, ConstructibleArrayType& arr) j.template get(), void()) { - if (HEDLEY_UNLIKELY(not j.is_array())) + if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not j.is_array())) { JSON_THROW(type_error::create(302, "type must be array, but is " + std::string(j.type_name()))); @@ -249,7 +249,7 @@ template::value, int> = 0> void from_json(const BasicJsonType& j, ConstructibleObjectType& obj) { - if (HEDLEY_UNLIKELY(not j.is_object())) + if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not j.is_object())) { JSON_THROW(type_error::create(302, "type must be object, but is " + std::string(j.type_name()))); } @@ -332,14 +332,14 @@ template ::value>> void from_json(const BasicJsonType& j, std::map& m) { - if (HEDLEY_UNLIKELY(not j.is_array())) + if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not j.is_array())) { JSON_THROW(type_error::create(302, "type must be array, but is " + std::string(j.type_name()))); } m.clear(); for (const auto& p : j) { - if (HEDLEY_UNLIKELY(not p.is_array())) + if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not p.is_array())) { JSON_THROW(type_error::create(302, "type must be array, but is " + std::string(p.type_name()))); } @@ -352,14 +352,14 @@ template ::value>> void from_json(const BasicJsonType& j, std::unordered_map& m) { - if (HEDLEY_UNLIKELY(not j.is_array())) + if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not j.is_array())) { JSON_THROW(type_error::create(302, "type must be array, but is " + std::string(j.type_name()))); } m.clear(); for (const auto& p : j) { - if (HEDLEY_UNLIKELY(not p.is_array())) + if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not p.is_array())) { JSON_THROW(type_error::create(302, "type must be array, but is " + std::string(p.type_name()))); } diff --git a/include/nlohmann/detail/conversions/to_chars.hpp b/include/nlohmann/detail/conversions/to_chars.hpp index 6edc57ff..9a88937e 100644 --- a/include/nlohmann/detail/conversions/to_chars.hpp +++ b/include/nlohmann/detail/conversions/to_chars.hpp @@ -819,7 +819,7 @@ v = buf * 10^decimal_exponent len is the length of the buffer (number of decimal digits) The buffer must be large enough, i.e. >= max_digits10. */ -HEDLEY_NON_NULL(1) +NLOHMANN_JSON_HEDLEY_NON_NULL(1) inline void grisu2(char* buf, int& len, int& decimal_exponent, diyfp m_minus, diyfp v, diyfp m_plus) { @@ -879,7 +879,7 @@ len is the length of the buffer (number of decimal digits) The buffer must be large enough, i.e. >= max_digits10. */ template -HEDLEY_NON_NULL(1) +NLOHMANN_JSON_HEDLEY_NON_NULL(1) void grisu2(char* buf, int& len, int& decimal_exponent, FloatType value) { static_assert(diyfp::kPrecision >= std::numeric_limits::digits + 3, @@ -918,8 +918,8 @@ void grisu2(char* buf, int& len, int& decimal_exponent, FloatType value) @return a pointer to the element following the exponent. @pre -1000 < e < 1000 */ -HEDLEY_NON_NULL(1) -HEDLEY_RETURNS_NON_NULL +NLOHMANN_JSON_HEDLEY_NON_NULL(1) +NLOHMANN_JSON_HEDLEY_RETURNS_NON_NULL inline char* append_exponent(char* buf, int e) { assert(e > -1000); @@ -970,8 +970,8 @@ notation. Otherwise it will be printed in exponential notation. @pre min_exp < 0 @pre max_exp > 0 */ -HEDLEY_NON_NULL(1) -HEDLEY_RETURNS_NON_NULL +NLOHMANN_JSON_HEDLEY_NON_NULL(1) +NLOHMANN_JSON_HEDLEY_RETURNS_NON_NULL inline char* format_buffer(char* buf, int len, int decimal_exponent, int min_exp, int max_exp) { @@ -1055,8 +1055,8 @@ format. Returns an iterator pointing past-the-end of the decimal representation. @note The result is NOT null-terminated. */ template -HEDLEY_NON_NULL(1, 2) -HEDLEY_RETURNS_NON_NULL +NLOHMANN_JSON_HEDLEY_NON_NULL(1, 2) +NLOHMANN_JSON_HEDLEY_RETURNS_NON_NULL char* to_chars(char* first, const char* last, FloatType value) { static_cast(last); // maybe unused - fix warning diff --git a/include/nlohmann/detail/exceptions.hpp b/include/nlohmann/detail/exceptions.hpp index bff13194..ad9673b6 100644 --- a/include/nlohmann/detail/exceptions.hpp +++ b/include/nlohmann/detail/exceptions.hpp @@ -47,7 +47,7 @@ class exception : public std::exception { public: /// returns the explanatory string - HEDLEY_RETURNS_NON_NULL + NLOHMANN_JSON_HEDLEY_RETURNS_NON_NULL const char* what() const noexcept override { return m.what(); @@ -57,7 +57,7 @@ class exception : public std::exception const int id; protected: - HEDLEY_NON_NULL(3) + NLOHMANN_JSON_HEDLEY_NON_NULL(3) exception(int id_, const char* what_arg) : id(id_), m(what_arg) {} static std::string name(const std::string& ename, int id_) @@ -210,7 +210,7 @@ class invalid_iterator : public exception } private: - HEDLEY_NON_NULL(3) + NLOHMANN_JSON_HEDLEY_NON_NULL(3) invalid_iterator(int id_, const char* what_arg) : exception(id_, what_arg) {} }; @@ -264,7 +264,7 @@ class type_error : public exception } private: - HEDLEY_NON_NULL(3) + NLOHMANN_JSON_HEDLEY_NON_NULL(3) type_error(int id_, const char* what_arg) : exception(id_, what_arg) {} }; @@ -311,7 +311,7 @@ class out_of_range : public exception } private: - HEDLEY_NON_NULL(3) + NLOHMANN_JSON_HEDLEY_NON_NULL(3) out_of_range(int id_, const char* what_arg) : exception(id_, what_arg) {} }; @@ -349,7 +349,7 @@ class other_error : public exception } private: - HEDLEY_NON_NULL(3) + NLOHMANN_JSON_HEDLEY_NON_NULL(3) other_error(int id_, const char* what_arg) : exception(id_, what_arg) {} }; } // namespace detail diff --git a/include/nlohmann/detail/input/binary_reader.hpp b/include/nlohmann/detail/input/binary_reader.hpp index 33af9c36..48ad8c00 100644 --- a/include/nlohmann/detail/input/binary_reader.hpp +++ b/include/nlohmann/detail/input/binary_reader.hpp @@ -66,7 +66,7 @@ class binary_reader @return */ - HEDLEY_NON_NULL(3) + NLOHMANN_JSON_HEDLEY_NON_NULL(3) bool sax_parse(const input_format_t format, json_sax_t* sax_, const bool strict = true) @@ -108,7 +108,7 @@ class binary_reader get(); } - if (HEDLEY_UNLIKELY(current != std::char_traits::eof())) + if (NLOHMANN_JSON_HEDLEY_UNLIKELY(current != std::char_traits::eof())) { return sax->parse_error(chars_read, get_token_string(), parse_error::create(110, chars_read, exception_message(format, "expected end of input; last byte: 0x" + get_token_string(), "value"))); @@ -144,12 +144,12 @@ class binary_reader std::int32_t document_size; get_number(input_format_t::bson, document_size); - if (HEDLEY_UNLIKELY(not sax->start_object(std::size_t(-1)))) + if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not sax->start_object(std::size_t(-1)))) { return false; } - if (HEDLEY_UNLIKELY(not parse_bson_element_list(/*is_array*/false))) + if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not parse_bson_element_list(/*is_array*/false))) { return false; } @@ -170,7 +170,7 @@ class binary_reader while (true) { get(); - if (HEDLEY_UNLIKELY(not unexpect_eof(input_format_t::bson, "cstring"))) + if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not unexpect_eof(input_format_t::bson, "cstring"))) { return false; } @@ -198,7 +198,7 @@ class binary_reader template bool get_bson_string(const NumberType len, string_t& result) { - if (HEDLEY_UNLIKELY(len < 1)) + if (NLOHMANN_JSON_HEDLEY_UNLIKELY(len < 1)) { auto last_token = get_token_string(); return sax->parse_error(chars_read, last_token, parse_error::create(112, chars_read, exception_message(input_format_t::bson, "string length must be at least 1, is " + std::to_string(len), "string"))); @@ -293,13 +293,13 @@ class binary_reader string_t key; while (int element_type = get()) { - if (HEDLEY_UNLIKELY(not unexpect_eof(input_format_t::bson, "element list"))) + if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not unexpect_eof(input_format_t::bson, "element list"))) { return false; } const std::size_t element_type_parse_position = chars_read; - if (HEDLEY_UNLIKELY(not get_bson_cstr(key))) + if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not get_bson_cstr(key))) { return false; } @@ -309,7 +309,7 @@ class binary_reader return false; } - if (HEDLEY_UNLIKELY(not parse_bson_element_internal(element_type, element_type_parse_position))) + if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not parse_bson_element_internal(element_type, element_type_parse_position))) { return false; } @@ -330,12 +330,12 @@ class binary_reader std::int32_t document_size; get_number(input_format_t::bson, document_size); - if (HEDLEY_UNLIKELY(not sax->start_array(std::size_t(-1)))) + if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not sax->start_array(std::size_t(-1)))) { return false; } - if (HEDLEY_UNLIKELY(not parse_bson_element_list(/*is_array*/true))) + if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not parse_bson_element_list(/*is_array*/true))) { return false; } @@ -620,12 +620,12 @@ class binary_reader case 0xF9: // Half-Precision Float (two-byte IEEE 754) { const int byte1_raw = get(); - if (HEDLEY_UNLIKELY(not unexpect_eof(input_format_t::cbor, "number"))) + if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not unexpect_eof(input_format_t::cbor, "number"))) { return false; } const int byte2_raw = get(); - if (HEDLEY_UNLIKELY(not unexpect_eof(input_format_t::cbor, "number"))) + if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not unexpect_eof(input_format_t::cbor, "number"))) { return false; } @@ -698,7 +698,7 @@ class binary_reader */ bool get_cbor_string(string_t& result) { - if (HEDLEY_UNLIKELY(not unexpect_eof(input_format_t::cbor, "string"))) + if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not unexpect_eof(input_format_t::cbor, "string"))) { return false; } @@ -787,7 +787,7 @@ class binary_reader */ bool get_cbor_array(const std::size_t len) { - if (HEDLEY_UNLIKELY(not sax->start_array(len))) + if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not sax->start_array(len))) { return false; } @@ -796,7 +796,7 @@ class binary_reader { for (std::size_t i = 0; i < len; ++i) { - if (HEDLEY_UNLIKELY(not parse_cbor_internal())) + if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not parse_cbor_internal())) { return false; } @@ -806,7 +806,7 @@ class binary_reader { while (get() != 0xFF) { - if (HEDLEY_UNLIKELY(not parse_cbor_internal(false))) + if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not parse_cbor_internal(false))) { return false; } @@ -823,7 +823,7 @@ class binary_reader */ bool get_cbor_object(const std::size_t len) { - if (HEDLEY_UNLIKELY(not sax->start_object(len))) + if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not sax->start_object(len))) { return false; } @@ -834,12 +834,12 @@ class binary_reader for (std::size_t i = 0; i < len; ++i) { get(); - if (HEDLEY_UNLIKELY(not get_cbor_string(key) or not sax->key(key))) + if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not get_cbor_string(key) or not sax->key(key))) { return false; } - if (HEDLEY_UNLIKELY(not parse_cbor_internal())) + if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not parse_cbor_internal())) { return false; } @@ -850,12 +850,12 @@ class binary_reader { while (get() != 0xFF) { - if (HEDLEY_UNLIKELY(not get_cbor_string(key) or not sax->key(key))) + if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not get_cbor_string(key) or not sax->key(key))) { return false; } - if (HEDLEY_UNLIKELY(not parse_cbor_internal())) + if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not parse_cbor_internal())) { return false; } @@ -1244,7 +1244,7 @@ class binary_reader */ bool get_msgpack_string(string_t& result) { - if (HEDLEY_UNLIKELY(not unexpect_eof(input_format_t::msgpack, "string"))) + if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not unexpect_eof(input_format_t::msgpack, "string"))) { return false; } @@ -1320,14 +1320,14 @@ class binary_reader */ bool get_msgpack_array(const std::size_t len) { - if (HEDLEY_UNLIKELY(not sax->start_array(len))) + if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not sax->start_array(len))) { return false; } for (std::size_t i = 0; i < len; ++i) { - if (HEDLEY_UNLIKELY(not parse_msgpack_internal())) + if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not parse_msgpack_internal())) { return false; } @@ -1342,7 +1342,7 @@ class binary_reader */ bool get_msgpack_object(const std::size_t len) { - if (HEDLEY_UNLIKELY(not sax->start_object(len))) + if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not sax->start_object(len))) { return false; } @@ -1351,12 +1351,12 @@ class binary_reader for (std::size_t i = 0; i < len; ++i) { get(); - if (HEDLEY_UNLIKELY(not get_msgpack_string(key) or not sax->key(key))) + if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not get_msgpack_string(key) or not sax->key(key))) { return false; } - if (HEDLEY_UNLIKELY(not parse_msgpack_internal())) + if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not parse_msgpack_internal())) { return false; } @@ -1403,7 +1403,7 @@ class binary_reader get(); // TODO(niels): may we ignore N here? } - if (HEDLEY_UNLIKELY(not unexpect_eof(input_format_t::ubjson, "value"))) + if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not unexpect_eof(input_format_t::ubjson, "value"))) { return false; } @@ -1457,7 +1457,7 @@ class binary_reader case 'U': { std::uint8_t number; - if (HEDLEY_UNLIKELY(not get_number(input_format_t::ubjson, number))) + if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not get_number(input_format_t::ubjson, number))) { return false; } @@ -1468,7 +1468,7 @@ class binary_reader case 'i': { std::int8_t number; - if (HEDLEY_UNLIKELY(not get_number(input_format_t::ubjson, number))) + if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not get_number(input_format_t::ubjson, number))) { return false; } @@ -1479,7 +1479,7 @@ class binary_reader case 'I': { std::int16_t number; - if (HEDLEY_UNLIKELY(not get_number(input_format_t::ubjson, number))) + if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not get_number(input_format_t::ubjson, number))) { return false; } @@ -1490,7 +1490,7 @@ class binary_reader case 'l': { std::int32_t number; - if (HEDLEY_UNLIKELY(not get_number(input_format_t::ubjson, number))) + if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not get_number(input_format_t::ubjson, number))) { return false; } @@ -1501,7 +1501,7 @@ class binary_reader case 'L': { std::int64_t number; - if (HEDLEY_UNLIKELY(not get_number(input_format_t::ubjson, number))) + if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not get_number(input_format_t::ubjson, number))) { return false; } @@ -1537,15 +1537,15 @@ class binary_reader if (current == '$') { result.second = get(); // must not ignore 'N', because 'N' maybe the type - if (HEDLEY_UNLIKELY(not unexpect_eof(input_format_t::ubjson, "type"))) + if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not unexpect_eof(input_format_t::ubjson, "type"))) { return false; } get_ignore_noop(); - if (HEDLEY_UNLIKELY(current != '#')) + if (NLOHMANN_JSON_HEDLEY_UNLIKELY(current != '#')) { - if (HEDLEY_UNLIKELY(not unexpect_eof(input_format_t::ubjson, "value"))) + if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not unexpect_eof(input_format_t::ubjson, "value"))) { return false; } @@ -1628,11 +1628,11 @@ class binary_reader case 'C': // char { get(); - if (HEDLEY_UNLIKELY(not unexpect_eof(input_format_t::ubjson, "char"))) + if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not unexpect_eof(input_format_t::ubjson, "char"))) { return false; } - if (HEDLEY_UNLIKELY(current > 127)) + if (NLOHMANN_JSON_HEDLEY_UNLIKELY(current > 127)) { auto last_token = get_token_string(); return sax->parse_error(chars_read, last_token, parse_error::create(113, chars_read, exception_message(input_format_t::ubjson, "byte after 'C' must be in range 0x00..0x7F; last byte: 0x" + last_token, "char"))); @@ -1667,14 +1667,14 @@ class binary_reader bool get_ubjson_array() { std::pair size_and_type; - if (HEDLEY_UNLIKELY(not get_ubjson_size_type(size_and_type))) + if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not get_ubjson_size_type(size_and_type))) { return false; } if (size_and_type.first != string_t::npos) { - if (HEDLEY_UNLIKELY(not sax->start_array(size_and_type.first))) + if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not sax->start_array(size_and_type.first))) { return false; } @@ -1685,7 +1685,7 @@ class binary_reader { for (std::size_t i = 0; i < size_and_type.first; ++i) { - if (HEDLEY_UNLIKELY(not get_ubjson_value(size_and_type.second))) + if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not get_ubjson_value(size_and_type.second))) { return false; } @@ -1696,7 +1696,7 @@ class binary_reader { for (std::size_t i = 0; i < size_and_type.first; ++i) { - if (HEDLEY_UNLIKELY(not parse_ubjson_internal())) + if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not parse_ubjson_internal())) { return false; } @@ -1705,14 +1705,14 @@ class binary_reader } else { - if (HEDLEY_UNLIKELY(not sax->start_array(std::size_t(-1)))) + if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not sax->start_array(std::size_t(-1)))) { return false; } while (current != ']') { - if (HEDLEY_UNLIKELY(not parse_ubjson_internal(false))) + if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not parse_ubjson_internal(false))) { return false; } @@ -1729,7 +1729,7 @@ class binary_reader bool get_ubjson_object() { std::pair size_and_type; - if (HEDLEY_UNLIKELY(not get_ubjson_size_type(size_and_type))) + if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not get_ubjson_size_type(size_and_type))) { return false; } @@ -1737,7 +1737,7 @@ class binary_reader string_t key; if (size_and_type.first != string_t::npos) { - if (HEDLEY_UNLIKELY(not sax->start_object(size_and_type.first))) + if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not sax->start_object(size_and_type.first))) { return false; } @@ -1746,11 +1746,11 @@ class binary_reader { for (std::size_t i = 0; i < size_and_type.first; ++i) { - if (HEDLEY_UNLIKELY(not get_ubjson_string(key) or not sax->key(key))) + if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not get_ubjson_string(key) or not sax->key(key))) { return false; } - if (HEDLEY_UNLIKELY(not get_ubjson_value(size_and_type.second))) + if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not get_ubjson_value(size_and_type.second))) { return false; } @@ -1761,11 +1761,11 @@ class binary_reader { for (std::size_t i = 0; i < size_and_type.first; ++i) { - if (HEDLEY_UNLIKELY(not get_ubjson_string(key) or not sax->key(key))) + if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not get_ubjson_string(key) or not sax->key(key))) { return false; } - if (HEDLEY_UNLIKELY(not parse_ubjson_internal())) + if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not parse_ubjson_internal())) { return false; } @@ -1775,18 +1775,18 @@ class binary_reader } else { - if (HEDLEY_UNLIKELY(not sax->start_object(std::size_t(-1)))) + if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not sax->start_object(std::size_t(-1)))) { return false; } while (current != '}') { - if (HEDLEY_UNLIKELY(not get_ubjson_string(key, false) or not sax->key(key))) + if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not get_ubjson_string(key, false) or not sax->key(key))) { return false; } - if (HEDLEY_UNLIKELY(not parse_ubjson_internal())) + if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not parse_ubjson_internal())) { return false; } @@ -1852,7 +1852,7 @@ class binary_reader for (std::size_t i = 0; i < sizeof(NumberType); ++i) { get(); - if (HEDLEY_UNLIKELY(not unexpect_eof(format, "number"))) + if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not unexpect_eof(format, "number"))) { return false; } @@ -1896,7 +1896,7 @@ class binary_reader std::generate_n(std::back_inserter(result), len, [this, &success, &format]() { get(); - if (HEDLEY_UNLIKELY(not unexpect_eof(format, "string"))) + if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not unexpect_eof(format, "string"))) { success = false; } @@ -1910,10 +1910,10 @@ class binary_reader @param[in] context further context information (for diagnostics) @return whether the last read character is not EOF */ - HEDLEY_NON_NULL(3) + NLOHMANN_JSON_HEDLEY_NON_NULL(3) bool unexpect_eof(const input_format_t format, const char* context) const { - if (HEDLEY_UNLIKELY(current == std::char_traits::eof())) + if (NLOHMANN_JSON_HEDLEY_UNLIKELY(current == std::char_traits::eof())) { return sax->parse_error(chars_read, "", parse_error::create(110, chars_read, exception_message(format, "unexpected end of input", context))); diff --git a/include/nlohmann/detail/input/input_adapters.hpp b/include/nlohmann/detail/input/input_adapters.hpp index 487cb525..55b2931c 100644 --- a/include/nlohmann/detail/input/input_adapters.hpp +++ b/include/nlohmann/detail/input/input_adapters.hpp @@ -55,7 +55,7 @@ Input adapter for stdio file access. This adapter read only 1 byte and do not us class file_input_adapter : public input_adapter_protocol { public: - HEDLEY_NON_NULL(2) + NLOHMANN_JSON_HEDLEY_NON_NULL(2) explicit file_input_adapter(std::FILE* f) noexcept : m_file(f) {} @@ -131,7 +131,7 @@ class input_stream_adapter : public input_adapter_protocol class input_buffer_adapter : public input_adapter_protocol { public: - HEDLEY_NON_NULL(2) + NLOHMANN_JSON_HEDLEY_NON_NULL(2) input_buffer_adapter(const char* b, const std::size_t l) noexcept : cursor(b), limit(b + l) {} @@ -145,7 +145,7 @@ class input_buffer_adapter : public input_adapter_protocol std::char_traits::int_type get_character() noexcept override { - if (HEDLEY_LIKELY(cursor < limit)) + if (NLOHMANN_JSON_HEDLEY_LIKELY(cursor < limit)) { return std::char_traits::to_int_type(*(cursor++)); } @@ -335,7 +335,7 @@ class input_adapter { public: // native support - HEDLEY_NON_NULL(2) + NLOHMANN_JSON_HEDLEY_NON_NULL(2) input_adapter(std::FILE* file) : ia(std::make_shared(file)) {} /// input adapter for input stream @@ -404,7 +404,7 @@ class input_adapter "each element in the iterator range must have the size of 1 byte"); const auto len = static_cast(std::distance(first, last)); - if (HEDLEY_LIKELY(len > 0)) + if (NLOHMANN_JSON_HEDLEY_LIKELY(len > 0)) { // there is at least one element: use the address of first ia = std::make_shared(reinterpret_cast(&(*first)), len); diff --git a/include/nlohmann/detail/input/json_sax.hpp b/include/nlohmann/detail/input/json_sax.hpp index b4cd1c9b..65e48b31 100644 --- a/include/nlohmann/detail/input/json_sax.hpp +++ b/include/nlohmann/detail/input/json_sax.hpp @@ -206,7 +206,7 @@ class json_sax_dom_parser { ref_stack.push_back(handle_value(BasicJsonType::value_t::object)); - if (HEDLEY_UNLIKELY(len != std::size_t(-1) and len > ref_stack.back()->max_size())) + if (NLOHMANN_JSON_HEDLEY_UNLIKELY(len != std::size_t(-1) and len > ref_stack.back()->max_size())) { JSON_THROW(out_of_range::create(408, "excessive object size: " + std::to_string(len))); @@ -232,7 +232,7 @@ class json_sax_dom_parser { ref_stack.push_back(handle_value(BasicJsonType::value_t::array)); - if (HEDLEY_UNLIKELY(len != std::size_t(-1) and len > ref_stack.back()->max_size())) + if (NLOHMANN_JSON_HEDLEY_UNLIKELY(len != std::size_t(-1) and len > ref_stack.back()->max_size())) { JSON_THROW(out_of_range::create(408, "excessive array size: " + std::to_string(len))); @@ -288,7 +288,7 @@ class json_sax_dom_parser object to which we can add elements */ template - HEDLEY_RETURNS_NON_NULL + NLOHMANN_JSON_HEDLEY_RETURNS_NON_NULL BasicJsonType* handle_value(Value&& v) { if (ref_stack.empty()) @@ -395,7 +395,7 @@ class json_sax_dom_callback_parser ref_stack.push_back(val.second); // check object limit - if (ref_stack.back() and HEDLEY_UNLIKELY(len != std::size_t(-1) and len > ref_stack.back()->max_size())) + if (ref_stack.back() and NLOHMANN_JSON_HEDLEY_UNLIKELY(len != std::size_t(-1) and len > ref_stack.back()->max_size())) { JSON_THROW(out_of_range::create(408, "excessive object size: " + std::to_string(len))); } @@ -458,7 +458,7 @@ class json_sax_dom_callback_parser ref_stack.push_back(val.second); // check array limit - if (ref_stack.back() and HEDLEY_UNLIKELY(len != std::size_t(-1) and len > ref_stack.back()->max_size())) + if (ref_stack.back() and NLOHMANN_JSON_HEDLEY_UNLIKELY(len != std::size_t(-1) and len > ref_stack.back()->max_size())) { JSON_THROW(out_of_range::create(408, "excessive array size: " + std::to_string(len))); } diff --git a/include/nlohmann/detail/input/lexer.hpp b/include/nlohmann/detail/input/lexer.hpp index 04b9a31e..21e37d4b 100644 --- a/include/nlohmann/detail/input/lexer.hpp +++ b/include/nlohmann/detail/input/lexer.hpp @@ -59,7 +59,7 @@ class lexer }; /// return name of values of type token_type (only used for errors) - HEDLEY_RETURNS_NON_NULL + NLOHMANN_JSON_HEDLEY_RETURNS_NON_NULL static const char* token_type_name(const token_type t) noexcept { switch (t) @@ -201,7 +201,7 @@ class lexer for (auto range = ranges.begin(); range != ranges.end(); ++range) { get(); - if (HEDLEY_LIKELY(*range <= current and current <= *(++range))) + if (NLOHMANN_JSON_HEDLEY_LIKELY(*range <= current and current <= *(++range))) { add(current); } @@ -300,7 +300,7 @@ class lexer const int codepoint1 = get_codepoint(); int codepoint = codepoint1; // start with codepoint1 - if (HEDLEY_UNLIKELY(codepoint1 == -1)) + if (NLOHMANN_JSON_HEDLEY_UNLIKELY(codepoint1 == -1)) { error_message = "invalid string: '\\u' must be followed by 4 hex digits"; return token_type::parse_error; @@ -310,18 +310,18 @@ class lexer if (0xD800 <= codepoint1 and codepoint1 <= 0xDBFF) { // expect next \uxxxx entry - if (HEDLEY_LIKELY(get() == '\\' and get() == 'u')) + if (NLOHMANN_JSON_HEDLEY_LIKELY(get() == '\\' and get() == 'u')) { const int codepoint2 = get_codepoint(); - if (HEDLEY_UNLIKELY(codepoint2 == -1)) + if (NLOHMANN_JSON_HEDLEY_UNLIKELY(codepoint2 == -1)) { error_message = "invalid string: '\\u' must be followed by 4 hex digits"; return token_type::parse_error; } // check if codepoint2 is a low surrogate - if (HEDLEY_LIKELY(0xDC00 <= codepoint2 and codepoint2 <= 0xDFFF)) + if (NLOHMANN_JSON_HEDLEY_LIKELY(0xDC00 <= codepoint2 and codepoint2 <= 0xDFFF)) { // overwrite codepoint codepoint = static_cast( @@ -348,7 +348,7 @@ class lexer } else { - if (HEDLEY_UNLIKELY(0xDC00 <= codepoint1 and codepoint1 <= 0xDFFF)) + if (NLOHMANN_JSON_HEDLEY_UNLIKELY(0xDC00 <= codepoint1 and codepoint1 <= 0xDFFF)) { error_message = "invalid string: surrogate U+DC00..U+DFFF must follow U+D800..U+DBFF"; return token_type::parse_error; @@ -723,7 +723,7 @@ class lexer case 0xDE: case 0xDF: { - if (HEDLEY_UNLIKELY(not next_byte_in_range({0x80, 0xBF}))) + if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not next_byte_in_range({0x80, 0xBF}))) { return token_type::parse_error; } @@ -733,7 +733,7 @@ class lexer // U+0800..U+0FFF: bytes E0 A0..BF 80..BF case 0xE0: { - if (HEDLEY_UNLIKELY(not (next_byte_in_range({0xA0, 0xBF, 0x80, 0xBF})))) + if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not (next_byte_in_range({0xA0, 0xBF, 0x80, 0xBF})))) { return token_type::parse_error; } @@ -757,7 +757,7 @@ class lexer case 0xEE: case 0xEF: { - if (HEDLEY_UNLIKELY(not (next_byte_in_range({0x80, 0xBF, 0x80, 0xBF})))) + if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not (next_byte_in_range({0x80, 0xBF, 0x80, 0xBF})))) { return token_type::parse_error; } @@ -767,7 +767,7 @@ class lexer // U+D000..U+D7FF: bytes ED 80..9F 80..BF case 0xED: { - if (HEDLEY_UNLIKELY(not (next_byte_in_range({0x80, 0x9F, 0x80, 0xBF})))) + if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not (next_byte_in_range({0x80, 0x9F, 0x80, 0xBF})))) { return token_type::parse_error; } @@ -777,7 +777,7 @@ class lexer // U+10000..U+3FFFF F0 90..BF 80..BF 80..BF case 0xF0: { - if (HEDLEY_UNLIKELY(not (next_byte_in_range({0x90, 0xBF, 0x80, 0xBF, 0x80, 0xBF})))) + if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not (next_byte_in_range({0x90, 0xBF, 0x80, 0xBF, 0x80, 0xBF})))) { return token_type::parse_error; } @@ -789,7 +789,7 @@ class lexer case 0xF2: case 0xF3: { - if (HEDLEY_UNLIKELY(not (next_byte_in_range({0x80, 0xBF, 0x80, 0xBF, 0x80, 0xBF})))) + if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not (next_byte_in_range({0x80, 0xBF, 0x80, 0xBF, 0x80, 0xBF})))) { return token_type::parse_error; } @@ -799,7 +799,7 @@ class lexer // U+100000..U+10FFFF F4 80..8F 80..BF 80..BF case 0xF4: { - if (HEDLEY_UNLIKELY(not (next_byte_in_range({0x80, 0x8F, 0x80, 0xBF, 0x80, 0xBF})))) + if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not (next_byte_in_range({0x80, 0x8F, 0x80, 0xBF, 0x80, 0xBF})))) { return token_type::parse_error; } @@ -816,19 +816,19 @@ class lexer } } - HEDLEY_NON_NULL(2) + NLOHMANN_JSON_HEDLEY_NON_NULL(2) static void strtof(float& f, const char* str, char** endptr) noexcept { f = std::strtof(str, endptr); } - HEDLEY_NON_NULL(2) + NLOHMANN_JSON_HEDLEY_NON_NULL(2) static void strtof(double& f, const char* str, char** endptr) noexcept { f = std::strtod(str, endptr); } - HEDLEY_NON_NULL(2) + NLOHMANN_JSON_HEDLEY_NON_NULL(2) static void strtof(long double& f, const char* str, char** endptr) noexcept { f = std::strtold(str, endptr); @@ -1204,14 +1204,14 @@ scan_number_done: @param[in] length the length of the passed literal text @param[in] return_type the token type to return on success */ - HEDLEY_NON_NULL(2) + NLOHMANN_JSON_HEDLEY_NON_NULL(2) token_type scan_literal(const char* literal_text, const std::size_t length, token_type return_type) { assert(current == literal_text[0]); for (std::size_t i = 1; i < length; ++i) { - if (HEDLEY_UNLIKELY(get() != literal_text[i])) + if (NLOHMANN_JSON_HEDLEY_UNLIKELY(get() != literal_text[i])) { error_message = "invalid literal"; return token_type::parse_error; @@ -1257,7 +1257,7 @@ scan_number_done: current = ia->get_character(); } - if (HEDLEY_LIKELY(current != std::char_traits::eof())) + if (NLOHMANN_JSON_HEDLEY_LIKELY(current != std::char_traits::eof())) { token_string.push_back(std::char_traits::to_char_type(current)); } @@ -1298,7 +1298,7 @@ scan_number_done: --position.chars_read_current_line; } - if (HEDLEY_LIKELY(current != std::char_traits::eof())) + if (NLOHMANN_JSON_HEDLEY_LIKELY(current != std::char_traits::eof())) { assert(not token_string.empty()); token_string.pop_back(); @@ -1377,7 +1377,7 @@ scan_number_done: } /// return syntax error message - HEDLEY_RETURNS_NON_NULL + NLOHMANN_JSON_HEDLEY_RETURNS_NON_NULL constexpr const char* get_error_message() const noexcept { return error_message; diff --git a/include/nlohmann/detail/input/parser.hpp b/include/nlohmann/detail/input/parser.hpp index 55a972e3..2e3f3b62 100644 --- a/include/nlohmann/detail/input/parser.hpp +++ b/include/nlohmann/detail/input/parser.hpp @@ -147,7 +147,7 @@ class parser } template - HEDLEY_NON_NULL(2) + NLOHMANN_JSON_HEDLEY_NON_NULL(2) bool sax_parse(SAX* sax, const bool strict = true) { (void)detail::is_sax_static_asserts {}; @@ -167,7 +167,7 @@ class parser private: template - HEDLEY_NON_NULL(2) + NLOHMANN_JSON_HEDLEY_NON_NULL(2) bool sax_parse_internal(SAX* sax) { // stack to remember the hierarchy of structured values we are parsing @@ -185,7 +185,7 @@ class parser { case token_type::begin_object: { - if (HEDLEY_UNLIKELY(not sax->start_object(std::size_t(-1)))) + if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not sax->start_object(std::size_t(-1)))) { return false; } @@ -193,7 +193,7 @@ class parser // closing } -> we are done if (get_token() == token_type::end_object) { - if (HEDLEY_UNLIKELY(not sax->end_object())) + if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not sax->end_object())) { return false; } @@ -201,20 +201,20 @@ class parser } // parse key - if (HEDLEY_UNLIKELY(last_token != token_type::value_string)) + if (NLOHMANN_JSON_HEDLEY_UNLIKELY(last_token != token_type::value_string)) { return sax->parse_error(m_lexer.get_position(), m_lexer.get_token_string(), parse_error::create(101, m_lexer.get_position(), exception_message(token_type::value_string, "object key"))); } - if (HEDLEY_UNLIKELY(not sax->key(m_lexer.get_string()))) + if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not sax->key(m_lexer.get_string()))) { return false; } // parse separator (:) - if (HEDLEY_UNLIKELY(get_token() != token_type::name_separator)) + if (NLOHMANN_JSON_HEDLEY_UNLIKELY(get_token() != token_type::name_separator)) { return sax->parse_error(m_lexer.get_position(), m_lexer.get_token_string(), @@ -232,7 +232,7 @@ class parser case token_type::begin_array: { - if (HEDLEY_UNLIKELY(not sax->start_array(std::size_t(-1)))) + if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not sax->start_array(std::size_t(-1)))) { return false; } @@ -240,7 +240,7 @@ class parser // closing ] -> we are done if (get_token() == token_type::end_array) { - if (HEDLEY_UNLIKELY(not sax->end_array())) + if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not sax->end_array())) { return false; } @@ -258,14 +258,14 @@ class parser { const auto res = m_lexer.get_number_float(); - if (HEDLEY_UNLIKELY(not std::isfinite(res))) + if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not std::isfinite(res))) { return sax->parse_error(m_lexer.get_position(), m_lexer.get_token_string(), out_of_range::create(406, "number overflow parsing '" + m_lexer.get_token_string() + "'")); } - if (HEDLEY_UNLIKELY(not sax->number_float(res, m_lexer.get_string()))) + if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not sax->number_float(res, m_lexer.get_string()))) { return false; } @@ -275,7 +275,7 @@ class parser case token_type::literal_false: { - if (HEDLEY_UNLIKELY(not sax->boolean(false))) + if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not sax->boolean(false))) { return false; } @@ -284,7 +284,7 @@ class parser case token_type::literal_null: { - if (HEDLEY_UNLIKELY(not sax->null())) + if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not sax->null())) { return false; } @@ -293,7 +293,7 @@ class parser case token_type::literal_true: { - if (HEDLEY_UNLIKELY(not sax->boolean(true))) + if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not sax->boolean(true))) { return false; } @@ -302,7 +302,7 @@ class parser case token_type::value_integer: { - if (HEDLEY_UNLIKELY(not sax->number_integer(m_lexer.get_number_integer()))) + if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not sax->number_integer(m_lexer.get_number_integer()))) { return false; } @@ -311,7 +311,7 @@ class parser case token_type::value_string: { - if (HEDLEY_UNLIKELY(not sax->string(m_lexer.get_string()))) + if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not sax->string(m_lexer.get_string()))) { return false; } @@ -320,7 +320,7 @@ class parser case token_type::value_unsigned: { - if (HEDLEY_UNLIKELY(not sax->number_unsigned(m_lexer.get_number_unsigned()))) + if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not sax->number_unsigned(m_lexer.get_number_unsigned()))) { return false; } @@ -368,9 +368,9 @@ class parser } // closing ] - if (HEDLEY_LIKELY(last_token == token_type::end_array)) + if (NLOHMANN_JSON_HEDLEY_LIKELY(last_token == token_type::end_array)) { - if (HEDLEY_UNLIKELY(not sax->end_array())) + if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not sax->end_array())) { return false; } @@ -396,7 +396,7 @@ class parser if (get_token() == token_type::value_separator) { // parse key - if (HEDLEY_UNLIKELY(get_token() != token_type::value_string)) + if (NLOHMANN_JSON_HEDLEY_UNLIKELY(get_token() != token_type::value_string)) { return sax->parse_error(m_lexer.get_position(), m_lexer.get_token_string(), @@ -404,13 +404,13 @@ class parser exception_message(token_type::value_string, "object key"))); } - if (HEDLEY_UNLIKELY(not sax->key(m_lexer.get_string()))) + if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not sax->key(m_lexer.get_string()))) { return false; } // parse separator (:) - if (HEDLEY_UNLIKELY(get_token() != token_type::name_separator)) + if (NLOHMANN_JSON_HEDLEY_UNLIKELY(get_token() != token_type::name_separator)) { return sax->parse_error(m_lexer.get_position(), m_lexer.get_token_string(), @@ -424,9 +424,9 @@ class parser } // closing } - if (HEDLEY_LIKELY(last_token == token_type::end_object)) + if (NLOHMANN_JSON_HEDLEY_LIKELY(last_token == token_type::end_object)) { - if (HEDLEY_UNLIKELY(not sax->end_object())) + if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not sax->end_object())) { return false; } diff --git a/include/nlohmann/detail/iterators/iter_impl.hpp b/include/nlohmann/detail/iterators/iter_impl.hpp index af03cb60..887bcce4 100644 --- a/include/nlohmann/detail/iterators/iter_impl.hpp +++ b/include/nlohmann/detail/iterators/iter_impl.hpp @@ -255,7 +255,7 @@ class iter_impl default: { - if (HEDLEY_LIKELY(m_it.primitive_iterator.is_begin())) + if (NLOHMANN_JSON_HEDLEY_LIKELY(m_it.primitive_iterator.is_begin())) { return *m_object; } @@ -289,7 +289,7 @@ class iter_impl default: { - if (HEDLEY_LIKELY(m_it.primitive_iterator.is_begin())) + if (NLOHMANN_JSON_HEDLEY_LIKELY(m_it.primitive_iterator.is_begin())) { return m_object; } @@ -392,7 +392,7 @@ class iter_impl bool operator==(const iter_impl& other) const { // if objects are not the same, the comparison is undefined - if (HEDLEY_UNLIKELY(m_object != other.m_object)) + if (NLOHMANN_JSON_HEDLEY_UNLIKELY(m_object != other.m_object)) { JSON_THROW(invalid_iterator::create(212, "cannot compare iterators of different containers")); } @@ -428,7 +428,7 @@ class iter_impl bool operator<(const iter_impl& other) const { // if objects are not the same, the comparison is undefined - if (HEDLEY_UNLIKELY(m_object != other.m_object)) + if (NLOHMANN_JSON_HEDLEY_UNLIKELY(m_object != other.m_object)) { JSON_THROW(invalid_iterator::create(212, "cannot compare iterators of different containers")); } @@ -588,7 +588,7 @@ class iter_impl default: { - if (HEDLEY_LIKELY(m_it.primitive_iterator.get_value() == -n)) + if (NLOHMANN_JSON_HEDLEY_LIKELY(m_it.primitive_iterator.get_value() == -n)) { return *m_object; } @@ -606,7 +606,7 @@ class iter_impl { assert(m_object != nullptr); - if (HEDLEY_LIKELY(m_object->is_object())) + if (NLOHMANN_JSON_HEDLEY_LIKELY(m_object->is_object())) { return m_it.object_iterator->first; } diff --git a/include/nlohmann/detail/json_pointer.hpp b/include/nlohmann/detail/json_pointer.hpp index 644504b4..609b433f 100644 --- a/include/nlohmann/detail/json_pointer.hpp +++ b/include/nlohmann/detail/json_pointer.hpp @@ -244,7 +244,7 @@ class json_pointer */ void pop_back() { - if (HEDLEY_UNLIKELY(empty())) + if (NLOHMANN_JSON_HEDLEY_UNLIKELY(empty())) { JSON_THROW(detail::out_of_range::create(405, "JSON pointer has no parent")); } @@ -268,7 +268,7 @@ class json_pointer */ const std::string& back() { - if (HEDLEY_UNLIKELY(empty())) + if (NLOHMANN_JSON_HEDLEY_UNLIKELY(empty())) { JSON_THROW(detail::out_of_range::create(405, "JSON pointer has no parent")); } @@ -332,7 +332,7 @@ class json_pointer const int res = std::stoi(s, &processed_chars); // check if the string was completely read - if (HEDLEY_UNLIKELY(processed_chars != s.size())) + if (NLOHMANN_JSON_HEDLEY_UNLIKELY(processed_chars != s.size())) { JSON_THROW(detail::out_of_range::create(404, "unresolved reference token '" + s + "'")); } @@ -342,7 +342,7 @@ class json_pointer json_pointer top() const { - if (HEDLEY_UNLIKELY(empty())) + if (NLOHMANN_JSON_HEDLEY_UNLIKELY(empty())) { JSON_THROW(detail::out_of_range::create(405, "JSON pointer has no parent")); } @@ -474,7 +474,7 @@ class json_pointer case detail::value_t::array: { // error condition (cf. RFC 6901, Sect. 4) - if (HEDLEY_UNLIKELY(reference_token.size() > 1 and reference_token[0] == '0')) + if (NLOHMANN_JSON_HEDLEY_UNLIKELY(reference_token.size() > 1 and reference_token[0] == '0')) { JSON_THROW(detail::parse_error::create(106, 0, "array index '" + reference_token + @@ -532,7 +532,7 @@ class json_pointer case detail::value_t::array: { - if (HEDLEY_UNLIKELY(reference_token == "-")) + if (NLOHMANN_JSON_HEDLEY_UNLIKELY(reference_token == "-")) { // "-" always fails the range check JSON_THROW(detail::out_of_range::create(402, @@ -541,7 +541,7 @@ class json_pointer } // error condition (cf. RFC 6901, Sect. 4) - if (HEDLEY_UNLIKELY(reference_token.size() > 1 and reference_token[0] == '0')) + if (NLOHMANN_JSON_HEDLEY_UNLIKELY(reference_token.size() > 1 and reference_token[0] == '0')) { JSON_THROW(detail::parse_error::create(106, 0, "array index '" + reference_token + @@ -597,7 +597,7 @@ class json_pointer case detail::value_t::array: { - if (HEDLEY_UNLIKELY(reference_token == "-")) + if (NLOHMANN_JSON_HEDLEY_UNLIKELY(reference_token == "-")) { // "-" cannot be used for const access JSON_THROW(detail::out_of_range::create(402, @@ -606,7 +606,7 @@ class json_pointer } // error condition (cf. RFC 6901, Sect. 4) - if (HEDLEY_UNLIKELY(reference_token.size() > 1 and reference_token[0] == '0')) + if (NLOHMANN_JSON_HEDLEY_UNLIKELY(reference_token.size() > 1 and reference_token[0] == '0')) { JSON_THROW(detail::parse_error::create(106, 0, "array index '" + reference_token + @@ -656,7 +656,7 @@ class json_pointer case detail::value_t::array: { - if (HEDLEY_UNLIKELY(reference_token == "-")) + if (NLOHMANN_JSON_HEDLEY_UNLIKELY(reference_token == "-")) { // "-" always fails the range check JSON_THROW(detail::out_of_range::create(402, @@ -665,7 +665,7 @@ class json_pointer } // error condition (cf. RFC 6901, Sect. 4) - if (HEDLEY_UNLIKELY(reference_token.size() > 1 and reference_token[0] == '0')) + if (NLOHMANN_JSON_HEDLEY_UNLIKELY(reference_token.size() > 1 and reference_token[0] == '0')) { JSON_THROW(detail::parse_error::create(106, 0, "array index '" + reference_token + @@ -712,7 +712,7 @@ class json_pointer } // check if nonempty reference string begins with slash - if (HEDLEY_UNLIKELY(reference_string[0] != '/')) + if (NLOHMANN_JSON_HEDLEY_UNLIKELY(reference_string[0] != '/')) { JSON_THROW(detail::parse_error::create(107, 1, "JSON pointer must be empty or begin with '/' - was: '" + @@ -747,9 +747,9 @@ class json_pointer assert(reference_token[pos] == '~'); // ~ must be followed by 0 or 1 - if (HEDLEY_UNLIKELY(pos == reference_token.size() - 1 or - (reference_token[pos + 1] != '0' and - reference_token[pos + 1] != '1'))) + if (NLOHMANN_JSON_HEDLEY_UNLIKELY(pos == reference_token.size() - 1 or + (reference_token[pos + 1] != '0' and + reference_token[pos + 1] != '1'))) { JSON_THROW(detail::parse_error::create(108, 0, "escape character '~' must be followed with '0' or '1'")); } @@ -874,7 +874,7 @@ class json_pointer static BasicJsonType unflatten(const BasicJsonType& value) { - if (HEDLEY_UNLIKELY(not value.is_object())) + if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not value.is_object())) { JSON_THROW(detail::type_error::create(314, "only objects can be unflattened")); } @@ -884,7 +884,7 @@ class json_pointer // iterate the JSON object values for (const auto& element : *value.m_value.object) { - if (HEDLEY_UNLIKELY(not element.second.is_primitive())) + if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not element.second.is_primitive())) { JSON_THROW(detail::type_error::create(315, "values in object must be primitive")); } diff --git a/include/nlohmann/detail/macro_unscope.hpp b/include/nlohmann/detail/macro_unscope.hpp index 8ad57a57..80b293e7 100644 --- a/include/nlohmann/detail/macro_unscope.hpp +++ b/include/nlohmann/detail/macro_unscope.hpp @@ -17,3 +17,5 @@ #undef JSON_HAS_CPP_17 #undef NLOHMANN_BASIC_JSON_TPL_DECLARATION #undef NLOHMANN_BASIC_JSON_TPL + +#include diff --git a/include/nlohmann/detail/output/binary_writer.hpp b/include/nlohmann/detail/output/binary_writer.hpp index 54206fd4..f09d151e 100644 --- a/include/nlohmann/detail/output/binary_writer.hpp +++ b/include/nlohmann/detail/output/binary_writer.hpp @@ -715,7 +715,7 @@ class binary_writer static std::size_t calc_bson_entry_header_size(const string_t& name) { const auto it = name.find(static_cast(0)); - if (HEDLEY_UNLIKELY(it != BasicJsonType::string_t::npos)) + if (NLOHMANN_JSON_HEDLEY_UNLIKELY(it != BasicJsonType::string_t::npos)) { JSON_THROW(out_of_range::create(409, "BSON key cannot contain code point U+0000 (at byte " + std::to_string(it) + ")")); diff --git a/include/nlohmann/detail/output/output_adapters.hpp b/include/nlohmann/detail/output/output_adapters.hpp index 65090221..1354a814 100644 --- a/include/nlohmann/detail/output/output_adapters.hpp +++ b/include/nlohmann/detail/output/output_adapters.hpp @@ -40,7 +40,7 @@ class output_vector_adapter : public output_adapter_protocol v.push_back(c); } - HEDLEY_NON_NULL(2) + NLOHMANN_JSON_HEDLEY_NON_NULL(2) void write_characters(const CharType* s, std::size_t length) override { std::copy(s, s + length, std::back_inserter(v)); @@ -64,7 +64,7 @@ class output_stream_adapter : public output_adapter_protocol stream.put(c); } - HEDLEY_NON_NULL(2) + NLOHMANN_JSON_HEDLEY_NON_NULL(2) void write_characters(const CharType* s, std::size_t length) override { stream.write(s, static_cast(length)); @@ -88,7 +88,7 @@ class output_string_adapter : public output_adapter_protocol str.push_back(c); } - HEDLEY_NON_NULL(2) + NLOHMANN_JSON_HEDLEY_NON_NULL(2) void write_characters(const CharType* s, std::size_t length) override { str.append(s, length); diff --git a/include/nlohmann/detail/output/serializer.hpp b/include/nlohmann/detail/output/serializer.hpp index d17f54d4..7c0a681c 100644 --- a/include/nlohmann/detail/output/serializer.hpp +++ b/include/nlohmann/detail/output/serializer.hpp @@ -110,7 +110,7 @@ class serializer // variable to hold indentation for recursive calls const auto new_indent = current_indent + indent_step; - if (HEDLEY_UNLIKELY(indent_string.size() < new_indent)) + if (NLOHMANN_JSON_HEDLEY_UNLIKELY(indent_string.size() < new_indent)) { indent_string.resize(indent_string.size() * 2, ' '); } @@ -183,7 +183,7 @@ class serializer // variable to hold indentation for recursive calls const auto new_indent = current_indent + indent_step; - if (HEDLEY_UNLIKELY(indent_string.size() < new_indent)) + if (NLOHMANN_JSON_HEDLEY_UNLIKELY(indent_string.size() < new_indent)) { indent_string.resize(indent_string.size() * 2, ' '); } @@ -498,7 +498,7 @@ class serializer } // we finished processing the string - if (HEDLEY_LIKELY(state == UTF8_ACCEPT)) + if (NLOHMANN_JSON_HEDLEY_LIKELY(state == UTF8_ACCEPT)) { // write buffer if (bytes > 0) diff --git a/include/nlohmann/json.hpp b/include/nlohmann/json.hpp index 2443f319..ab8dd2e9 100644 --- a/include/nlohmann/json.hpp +++ b/include/nlohmann/json.hpp @@ -319,7 +319,7 @@ class basic_json @since 2.1.0 */ - HEDLEY_WARN_UNUSED_RESULT + NLOHMANN_JSON_HEDLEY_WARN_UNUSED_RESULT static basic_json meta() { basic_json result; @@ -824,7 +824,7 @@ class basic_json /// helper for exception-safe object creation template - HEDLEY_RETURNS_NON_NULL + NLOHMANN_JSON_HEDLEY_RETURNS_NON_NULL static T* create(Args&& ... args) { AllocatorType alloc; @@ -951,7 +951,7 @@ class basic_json default: { object = nullptr; // silence warning, see #821 - if (HEDLEY_UNLIKELY(t == value_t::null)) + if (NLOHMANN_JSON_HEDLEY_UNLIKELY(t == value_t::null)) { JSON_THROW(other_error::create(500, "961c151d2e87f2686a955a9be24d316f1362bf21 3.6.1")); // LCOV_EXCL_LINE } @@ -1428,7 +1428,7 @@ class basic_json } // if object is wanted but impossible, throw an exception - if (HEDLEY_UNLIKELY(manual_type == value_t::object and not is_an_object)) + if (NLOHMANN_JSON_HEDLEY_UNLIKELY(manual_type == value_t::object and not is_an_object)) { JSON_THROW(type_error::create(301, "cannot create object from initializer list")); } @@ -1495,7 +1495,7 @@ class basic_json @since version 1.0.0 */ - HEDLEY_WARN_UNUSED_RESULT + NLOHMANN_JSON_HEDLEY_WARN_UNUSED_RESULT static basic_json array(initializer_list_t init = {}) { return basic_json(init, false, value_t::array); @@ -1539,7 +1539,7 @@ class basic_json @since version 1.0.0 */ - HEDLEY_WARN_UNUSED_RESULT + NLOHMANN_JSON_HEDLEY_WARN_UNUSED_RESULT static basic_json object(initializer_list_t init = {}) { return basic_json(init, false, value_t::object); @@ -1638,7 +1638,7 @@ class basic_json assert(last.m_object != nullptr); // make sure iterator fits the current value - if (HEDLEY_UNLIKELY(first.m_object != last.m_object)) + if (NLOHMANN_JSON_HEDLEY_UNLIKELY(first.m_object != last.m_object)) { JSON_THROW(invalid_iterator::create(201, "iterators are not compatible")); } @@ -1655,8 +1655,8 @@ class basic_json case value_t::number_unsigned: case value_t::string: { - if (HEDLEY_UNLIKELY(not first.m_it.primitive_iterator.is_begin() - or not last.m_it.primitive_iterator.is_end())) + if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not first.m_it.primitive_iterator.is_begin() + or not last.m_it.primitive_iterator.is_end())) { JSON_THROW(invalid_iterator::create(204, "iterators out of range")); } @@ -2369,7 +2369,7 @@ class basic_json /// get a boolean (explicit) boolean_t get_impl(boolean_t* /*unused*/) const { - if (HEDLEY_LIKELY(is_boolean())) + if (NLOHMANN_JSON_HEDLEY_LIKELY(is_boolean())) { return m_value.boolean; } @@ -2478,7 +2478,7 @@ class basic_json // delegate the call to get_ptr<>() auto ptr = obj.template get_ptr::type>(); - if (HEDLEY_LIKELY(ptr != nullptr)) + if (NLOHMANN_JSON_HEDLEY_LIKELY(ptr != nullptr)) { return *ptr; } @@ -2929,7 +2929,7 @@ class basic_json reference at(size_type idx) { // at only works for arrays - if (HEDLEY_LIKELY(is_array())) + if (NLOHMANN_JSON_HEDLEY_LIKELY(is_array())) { JSON_TRY { @@ -2976,7 +2976,7 @@ class basic_json const_reference at(size_type idx) const { // at only works for arrays - if (HEDLEY_LIKELY(is_array())) + if (NLOHMANN_JSON_HEDLEY_LIKELY(is_array())) { JSON_TRY { @@ -3027,7 +3027,7 @@ class basic_json reference at(const typename object_t::key_type& key) { // at only works for objects - if (HEDLEY_LIKELY(is_object())) + if (NLOHMANN_JSON_HEDLEY_LIKELY(is_object())) { JSON_TRY { @@ -3078,7 +3078,7 @@ class basic_json const_reference at(const typename object_t::key_type& key) const { // at only works for objects - if (HEDLEY_LIKELY(is_object())) + if (NLOHMANN_JSON_HEDLEY_LIKELY(is_object())) { JSON_TRY { @@ -3132,7 +3132,7 @@ class basic_json } // operator[] only works for arrays - if (HEDLEY_LIKELY(is_array())) + if (NLOHMANN_JSON_HEDLEY_LIKELY(is_array())) { // fill up array with null values if given idx is outside range if (idx >= m_value.array->size()) @@ -3170,7 +3170,7 @@ class basic_json const_reference operator[](size_type idx) const { // const operator[] only works for arrays - if (HEDLEY_LIKELY(is_array())) + if (NLOHMANN_JSON_HEDLEY_LIKELY(is_array())) { return m_value.array->operator[](idx); } @@ -3216,7 +3216,7 @@ class basic_json } // operator[] only works for objects - if (HEDLEY_LIKELY(is_object())) + if (NLOHMANN_JSON_HEDLEY_LIKELY(is_object())) { return m_value.object->operator[](key); } @@ -3257,7 +3257,7 @@ class basic_json const_reference operator[](const typename object_t::key_type& key) const { // const operator[] only works for objects - if (HEDLEY_LIKELY(is_object())) + if (NLOHMANN_JSON_HEDLEY_LIKELY(is_object())) { assert(m_value.object->find(key) != m_value.object->end()); return m_value.object->find(key)->second; @@ -3294,7 +3294,7 @@ class basic_json @since version 1.1.0 */ template - HEDLEY_NON_NULL(2) + NLOHMANN_JSON_HEDLEY_NON_NULL(2) reference operator[](T* key) { // implicitly convert null to object @@ -3306,7 +3306,7 @@ class basic_json } // at only works for objects - if (HEDLEY_LIKELY(is_object())) + if (NLOHMANN_JSON_HEDLEY_LIKELY(is_object())) { return m_value.object->operator[](key); } @@ -3345,11 +3345,11 @@ class basic_json @since version 1.1.0 */ template - HEDLEY_NON_NULL(2) + NLOHMANN_JSON_HEDLEY_NON_NULL(2) const_reference operator[](T* key) const { // at only works for objects - if (HEDLEY_LIKELY(is_object())) + if (NLOHMANN_JSON_HEDLEY_LIKELY(is_object())) { assert(m_value.object->find(key) != m_value.object->end()); return m_value.object->find(key)->second; @@ -3413,7 +3413,7 @@ class basic_json ValueType value(const typename object_t::key_type& key, const ValueType& default_value) const { // at only works for objects - if (HEDLEY_LIKELY(is_object())) + if (NLOHMANN_JSON_HEDLEY_LIKELY(is_object())) { // if key is found, return value and given default value otherwise const auto it = find(key); @@ -3485,7 +3485,7 @@ class basic_json ValueType value(const json_pointer& ptr, const ValueType& default_value) const { // at only works for objects - if (HEDLEY_LIKELY(is_object())) + if (NLOHMANN_JSON_HEDLEY_LIKELY(is_object())) { // if pointer resolves a value, return it or use default value JSON_TRY @@ -3505,7 +3505,7 @@ class basic_json @brief overload for a default value of type const char* @copydoc basic_json::value(const json_pointer&, ValueType) const */ - HEDLEY_NON_NULL(3) + NLOHMANN_JSON_HEDLEY_NON_NULL(3) string_t value(const json_pointer& ptr, const char* default_value) const { return value(ptr, string_t(default_value)); @@ -3650,7 +3650,7 @@ class basic_json IteratorType erase(IteratorType pos) { // make sure iterator fits the current value - if (HEDLEY_UNLIKELY(this != pos.m_object)) + if (NLOHMANN_JSON_HEDLEY_UNLIKELY(this != pos.m_object)) { JSON_THROW(invalid_iterator::create(202, "iterator does not fit current value")); } @@ -3665,7 +3665,7 @@ class basic_json case value_t::number_unsigned: case value_t::string: { - if (HEDLEY_UNLIKELY(not pos.m_it.primitive_iterator.is_begin())) + if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not pos.m_it.primitive_iterator.is_begin())) { JSON_THROW(invalid_iterator::create(205, "iterator out of range")); } @@ -3755,7 +3755,7 @@ class basic_json IteratorType erase(IteratorType first, IteratorType last) { // make sure iterator fits the current value - if (HEDLEY_UNLIKELY(this != first.m_object or this != last.m_object)) + if (NLOHMANN_JSON_HEDLEY_UNLIKELY(this != first.m_object or this != last.m_object)) { JSON_THROW(invalid_iterator::create(203, "iterators do not fit current value")); } @@ -3770,8 +3770,8 @@ class basic_json case value_t::number_unsigned: case value_t::string: { - if (HEDLEY_LIKELY(not first.m_it.primitive_iterator.is_begin() - or not last.m_it.primitive_iterator.is_end())) + if (NLOHMANN_JSON_HEDLEY_LIKELY(not first.m_it.primitive_iterator.is_begin() + or not last.m_it.primitive_iterator.is_end())) { JSON_THROW(invalid_iterator::create(204, "iterators out of range")); } @@ -3842,7 +3842,7 @@ class basic_json size_type erase(const typename object_t::key_type& key) { // this erase only works for objects - if (HEDLEY_LIKELY(is_object())) + if (NLOHMANN_JSON_HEDLEY_LIKELY(is_object())) { return m_value.object->erase(key); } @@ -3877,9 +3877,9 @@ class basic_json void erase(const size_type idx) { // this erase only works for arrays - if (HEDLEY_LIKELY(is_array())) + if (NLOHMANN_JSON_HEDLEY_LIKELY(is_array())) { - if (HEDLEY_UNLIKELY(idx >= size())) + if (NLOHMANN_JSON_HEDLEY_UNLIKELY(idx >= size())) { JSON_THROW(out_of_range::create(401, "array index " + std::to_string(idx) + " is out of range")); } @@ -4355,7 +4355,7 @@ class basic_json future 4.0.0 of the library. Please use @ref items() instead; that is, replace `json::iterator_wrapper(j)` with `j.items()`. */ - HEDLEY_DEPRECATED(3.1.0) + NLOHMANN_JSON_HEDLEY_DEPRECATED(3.1.0) static iteration_proxy iterator_wrapper(reference ref) noexcept { return ref.items(); @@ -4364,7 +4364,7 @@ class basic_json /*! @copydoc iterator_wrapper(reference) */ - HEDLEY_DEPRECATED(3.1.0) + NLOHMANN_JSON_HEDLEY_DEPRECATED(3.1.0) static iteration_proxy iterator_wrapper(const_reference ref) noexcept { return ref.items(); @@ -4783,7 +4783,7 @@ class basic_json void push_back(basic_json&& val) { // push_back only works for null objects or arrays - if (HEDLEY_UNLIKELY(not(is_null() or is_array()))) + if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not(is_null() or is_array()))) { JSON_THROW(type_error::create(308, "cannot use push_back() with " + std::string(type_name()))); } @@ -4820,7 +4820,7 @@ class basic_json void push_back(const basic_json& val) { // push_back only works for null objects or arrays - if (HEDLEY_UNLIKELY(not(is_null() or is_array()))) + if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not(is_null() or is_array()))) { JSON_THROW(type_error::create(308, "cannot use push_back() with " + std::string(type_name()))); } @@ -4870,7 +4870,7 @@ class basic_json void push_back(const typename object_t::value_type& val) { // push_back only works for null objects or objects - if (HEDLEY_UNLIKELY(not(is_null() or is_object()))) + if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not(is_null() or is_object()))) { JSON_THROW(type_error::create(308, "cannot use push_back() with " + std::string(type_name()))); } @@ -4971,7 +4971,7 @@ class basic_json void emplace_back(Args&& ... args) { // emplace_back only works for null objects or arrays - if (HEDLEY_UNLIKELY(not(is_null() or is_array()))) + if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not(is_null() or is_array()))) { JSON_THROW(type_error::create(311, "cannot use emplace_back() with " + std::string(type_name()))); } @@ -5019,7 +5019,7 @@ class basic_json std::pair emplace(Args&& ... args) { // emplace only works for null objects or arrays - if (HEDLEY_UNLIKELY(not(is_null() or is_object()))) + if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not(is_null() or is_object()))) { JSON_THROW(type_error::create(311, "cannot use emplace() with " + std::string(type_name()))); } @@ -5087,10 +5087,10 @@ class basic_json iterator insert(const_iterator pos, const basic_json& val) { // insert only works for arrays - if (HEDLEY_LIKELY(is_array())) + if (NLOHMANN_JSON_HEDLEY_LIKELY(is_array())) { // check if iterator pos fits to this JSON value - if (HEDLEY_UNLIKELY(pos.m_object != this)) + if (NLOHMANN_JSON_HEDLEY_UNLIKELY(pos.m_object != this)) { JSON_THROW(invalid_iterator::create(202, "iterator does not fit current value")); } @@ -5138,10 +5138,10 @@ class basic_json iterator insert(const_iterator pos, size_type cnt, const basic_json& val) { // insert only works for arrays - if (HEDLEY_LIKELY(is_array())) + if (NLOHMANN_JSON_HEDLEY_LIKELY(is_array())) { // check if iterator pos fits to this JSON value - if (HEDLEY_UNLIKELY(pos.m_object != this)) + if (NLOHMANN_JSON_HEDLEY_UNLIKELY(pos.m_object != this)) { JSON_THROW(invalid_iterator::create(202, "iterator does not fit current value")); } @@ -5186,24 +5186,24 @@ class basic_json iterator insert(const_iterator pos, const_iterator first, const_iterator last) { // insert only works for arrays - if (HEDLEY_UNLIKELY(not is_array())) + if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not is_array())) { JSON_THROW(type_error::create(309, "cannot use insert() with " + std::string(type_name()))); } // check if iterator pos fits to this JSON value - if (HEDLEY_UNLIKELY(pos.m_object != this)) + if (NLOHMANN_JSON_HEDLEY_UNLIKELY(pos.m_object != this)) { JSON_THROW(invalid_iterator::create(202, "iterator does not fit current value")); } // check if range iterators belong to the same JSON object - if (HEDLEY_UNLIKELY(first.m_object != last.m_object)) + if (NLOHMANN_JSON_HEDLEY_UNLIKELY(first.m_object != last.m_object)) { JSON_THROW(invalid_iterator::create(210, "iterators do not fit")); } - if (HEDLEY_UNLIKELY(first.m_object == this)) + if (NLOHMANN_JSON_HEDLEY_UNLIKELY(first.m_object == this)) { JSON_THROW(invalid_iterator::create(211, "passed iterators may not belong to container")); } @@ -5239,13 +5239,13 @@ class basic_json iterator insert(const_iterator pos, initializer_list_t ilist) { // insert only works for arrays - if (HEDLEY_UNLIKELY(not is_array())) + if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not is_array())) { JSON_THROW(type_error::create(309, "cannot use insert() with " + std::string(type_name()))); } // check if iterator pos fits to this JSON value - if (HEDLEY_UNLIKELY(pos.m_object != this)) + if (NLOHMANN_JSON_HEDLEY_UNLIKELY(pos.m_object != this)) { JSON_THROW(invalid_iterator::create(202, "iterator does not fit current value")); } @@ -5280,19 +5280,19 @@ class basic_json void insert(const_iterator first, const_iterator last) { // insert only works for objects - if (HEDLEY_UNLIKELY(not is_object())) + if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not is_object())) { JSON_THROW(type_error::create(309, "cannot use insert() with " + std::string(type_name()))); } // check if range iterators belong to the same JSON object - if (HEDLEY_UNLIKELY(first.m_object != last.m_object)) + if (NLOHMANN_JSON_HEDLEY_UNLIKELY(first.m_object != last.m_object)) { JSON_THROW(invalid_iterator::create(210, "iterators do not fit")); } // passed iterators must belong to objects - if (HEDLEY_UNLIKELY(not first.m_object->is_object())) + if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not first.m_object->is_object())) { JSON_THROW(invalid_iterator::create(202, "iterators first and last must point to objects")); } @@ -5329,11 +5329,11 @@ class basic_json assert_invariant(); } - if (HEDLEY_UNLIKELY(not is_object())) + if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not is_object())) { JSON_THROW(type_error::create(312, "cannot use update() with " + std::string(type_name()))); } - if (HEDLEY_UNLIKELY(not j.is_object())) + if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not j.is_object())) { JSON_THROW(type_error::create(312, "cannot use update() with " + std::string(j.type_name()))); } @@ -5380,20 +5380,20 @@ class basic_json assert_invariant(); } - if (HEDLEY_UNLIKELY(not is_object())) + if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not is_object())) { JSON_THROW(type_error::create(312, "cannot use update() with " + std::string(type_name()))); } // check if range iterators belong to the same JSON object - if (HEDLEY_UNLIKELY(first.m_object != last.m_object)) + if (NLOHMANN_JSON_HEDLEY_UNLIKELY(first.m_object != last.m_object)) { JSON_THROW(invalid_iterator::create(210, "iterators do not fit")); } // passed iterators must belong to objects - if (HEDLEY_UNLIKELY(not first.m_object->is_object() - or not last.m_object->is_object())) + if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not first.m_object->is_object() + or not last.m_object->is_object())) { JSON_THROW(invalid_iterator::create(202, "iterators first and last must point to objects")); } @@ -5456,7 +5456,7 @@ class basic_json void swap(array_t& other) { // swap only works for arrays - if (HEDLEY_LIKELY(is_array())) + if (NLOHMANN_JSON_HEDLEY_LIKELY(is_array())) { std::swap(*(m_value.array), other); } @@ -5489,7 +5489,7 @@ class basic_json void swap(object_t& other) { // swap only works for objects - if (HEDLEY_LIKELY(is_object())) + if (NLOHMANN_JSON_HEDLEY_LIKELY(is_object())) { std::swap(*(m_value.object), other); } @@ -5522,7 +5522,7 @@ class basic_json void swap(string_t& other) { // swap only works for strings - if (HEDLEY_LIKELY(is_string())) + if (NLOHMANN_JSON_HEDLEY_LIKELY(is_string())) { std::swap(*(m_value.string), other); } @@ -6032,7 +6032,7 @@ class basic_json instead; that is, replace calls like `j >> o;` with `o << j;`. @since version 1.0.0; deprecated since version 3.0.0 */ - HEDLEY_DEPRECATED(3.0.0) + NLOHMANN_JSON_HEDLEY_DEPRECATED(3.0.0) friend std::ostream& operator>>(const basic_json& j, std::ostream& o) { return o << j; @@ -6111,7 +6111,7 @@ class basic_json @since version 2.0.3 (contiguous containers) */ - HEDLEY_WARN_UNUSED_RESULT + NLOHMANN_JSON_HEDLEY_WARN_UNUSED_RESULT static basic_json parse(detail::input_adapter&& i, const parser_callback_t cb = nullptr, const bool allow_exceptions = true) @@ -6180,7 +6180,7 @@ class basic_json @since version 3.2.0 */ template - HEDLEY_NON_NULL(2) + NLOHMANN_JSON_HEDLEY_NON_NULL(2) static bool sax_parse(detail::input_adapter&& i, SAX* sax, input_format_t format = input_format_t::json, const bool strict = true) @@ -6266,7 +6266,7 @@ class basic_json std::is_base_of< std::random_access_iterator_tag, typename std::iterator_traits::iterator_category>::value, int>::type = 0> - HEDLEY_NON_NULL(3) + NLOHMANN_JSON_HEDLEY_NON_NULL(3) static bool sax_parse(IteratorType first, IteratorType last, SAX* sax) { return parser(detail::input_adapter(first, last)).sax_parse(sax); @@ -6280,7 +6280,7 @@ class basic_json instead; that is, replace calls like `j << i;` with `i >> j;`. @since version 1.0.0; deprecated since version 3.0.0 */ - HEDLEY_DEPRECATED(3.0.0) + NLOHMANN_JSON_HEDLEY_DEPRECATED(3.0.0) friend std::istream& operator<<(basic_json& j, std::istream& i) { return operator>>(i, j); @@ -6353,7 +6353,7 @@ class basic_json @since version 1.0.0, public since 2.1.0, `const char*` and `noexcept` since 3.0.0 */ - HEDLEY_RETURNS_NON_NULL + NLOHMANN_JSON_HEDLEY_RETURNS_NON_NULL const char* type_name() const noexcept { { @@ -6883,7 +6883,7 @@ class basic_json @a strict parameter since 3.0.0; added @a allow_exceptions parameter since 3.2.0 */ - HEDLEY_WARN_UNUSED_RESULT + NLOHMANN_JSON_HEDLEY_WARN_UNUSED_RESULT static basic_json from_cbor(detail::input_adapter&& i, const bool strict = true, const bool allow_exceptions = true) @@ -6899,7 +6899,7 @@ class basic_json */ template::value, int> = 0> - HEDLEY_WARN_UNUSED_RESULT + NLOHMANN_JSON_HEDLEY_WARN_UNUSED_RESULT static basic_json from_cbor(A1 && a1, A2 && a2, const bool strict = true, const bool allow_exceptions = true) @@ -6992,7 +6992,7 @@ class basic_json @a strict parameter since 3.0.0; added @a allow_exceptions parameter since 3.2.0 */ - HEDLEY_WARN_UNUSED_RESULT + NLOHMANN_JSON_HEDLEY_WARN_UNUSED_RESULT static basic_json from_msgpack(detail::input_adapter&& i, const bool strict = true, const bool allow_exceptions = true) @@ -7008,7 +7008,7 @@ class basic_json */ template::value, int> = 0> - HEDLEY_WARN_UNUSED_RESULT + NLOHMANN_JSON_HEDLEY_WARN_UNUSED_RESULT static basic_json from_msgpack(A1 && a1, A2 && a2, const bool strict = true, const bool allow_exceptions = true) @@ -7080,7 +7080,7 @@ class basic_json @since version 3.1.0; added @a allow_exceptions parameter since 3.2.0 */ - HEDLEY_WARN_UNUSED_RESULT + NLOHMANN_JSON_HEDLEY_WARN_UNUSED_RESULT static basic_json from_ubjson(detail::input_adapter&& i, const bool strict = true, const bool allow_exceptions = true) @@ -7096,7 +7096,7 @@ class basic_json */ template::value, int> = 0> - HEDLEY_WARN_UNUSED_RESULT + NLOHMANN_JSON_HEDLEY_WARN_UNUSED_RESULT static basic_json from_ubjson(A1 && a1, A2 && a2, const bool strict = true, const bool allow_exceptions = true) @@ -7167,7 +7167,7 @@ class basic_json @sa @ref from_ubjson(detail::input_adapter&&, const bool, const bool) for the related UBJSON format */ - HEDLEY_WARN_UNUSED_RESULT + NLOHMANN_JSON_HEDLEY_WARN_UNUSED_RESULT static basic_json from_bson(detail::input_adapter&& i, const bool strict = true, const bool allow_exceptions = true) @@ -7183,7 +7183,7 @@ class basic_json */ template::value, int> = 0> - HEDLEY_WARN_UNUSED_RESULT + NLOHMANN_JSON_HEDLEY_WARN_UNUSED_RESULT static basic_json from_bson(A1 && a1, A2 && a2, const bool strict = true, const bool allow_exceptions = true) @@ -7557,7 +7557,7 @@ class basic_json else { const auto idx = json_pointer::array_index(last_path); - if (HEDLEY_UNLIKELY(static_cast(idx) > parent.size())) + if (NLOHMANN_JSON_HEDLEY_UNLIKELY(static_cast(idx) > parent.size())) { // avoid undefined behavior JSON_THROW(out_of_range::create(401, "array index " + std::to_string(idx) + " is out of range")); @@ -7588,7 +7588,7 @@ class basic_json { // perform range check auto it = parent.find(last_path); - if (HEDLEY_LIKELY(it != parent.end())) + if (NLOHMANN_JSON_HEDLEY_LIKELY(it != parent.end())) { parent.erase(it); } @@ -7605,7 +7605,7 @@ class basic_json }; // type check: top level value must be an array - if (HEDLEY_UNLIKELY(not json_patch.is_array())) + if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not json_patch.is_array())) { JSON_THROW(parse_error::create(104, 0, "JSON patch must be an array of objects")); } @@ -7625,13 +7625,13 @@ class basic_json const auto error_msg = (op == "op") ? "operation" : "operation '" + op + "'"; // check if desired value is present - if (HEDLEY_UNLIKELY(it == val.m_value.object->end())) + if (NLOHMANN_JSON_HEDLEY_UNLIKELY(it == val.m_value.object->end())) { JSON_THROW(parse_error::create(105, 0, error_msg + " must have member '" + member + "'")); } // check if result is of type string - if (HEDLEY_UNLIKELY(string_type and not it->second.is_string())) + if (NLOHMANN_JSON_HEDLEY_UNLIKELY(string_type and not it->second.is_string())) { JSON_THROW(parse_error::create(105, 0, error_msg + " must have string member '" + member + "'")); } @@ -7641,7 +7641,7 @@ class basic_json }; // type check: every element of the array must be an object - if (HEDLEY_UNLIKELY(not val.is_object())) + if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not val.is_object())) { JSON_THROW(parse_error::create(104, 0, "JSON patch must be an array of objects")); } @@ -7719,7 +7719,7 @@ class basic_json } // throw an exception if test fails - if (HEDLEY_UNLIKELY(not success)) + if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not success)) { JSON_THROW(other_error::create(501, "unsuccessful: " + val.dump())); } @@ -7772,7 +7772,7 @@ class basic_json @since version 2.0.0 */ - HEDLEY_WARN_UNUSED_RESULT + NLOHMANN_JSON_HEDLEY_WARN_UNUSED_RESULT static basic_json diff(const basic_json& source, const basic_json& target, const std::string& path = "") { @@ -8064,7 +8064,7 @@ if no parse error occurred. @since version 1.0.0 */ -HEDLEY_NON_NULL(1) +NLOHMANN_JSON_HEDLEY_NON_NULL(1) inline nlohmann::json operator "" _json(const char* s, std::size_t n) { return nlohmann::json::parse(s, s + n); @@ -8083,7 +8083,7 @@ object if no parse error occurred. @since version 2.0.0 */ -HEDLEY_NON_NULL(1) +NLOHMANN_JSON_HEDLEY_NON_NULL(1) inline nlohmann::json::json_pointer operator "" _json_pointer(const char* s, std::size_t n) { return nlohmann::json::json_pointer(std::string(s, n)); diff --git a/include/nlohmann/thirdparty/hedley/hedley.hpp b/include/nlohmann/thirdparty/hedley/hedley.hpp index eb4c2018..31d63a6b 100644 --- a/include/nlohmann/thirdparty/hedley/hedley.hpp +++ b/include/nlohmann/thirdparty/hedley/hedley.hpp @@ -10,1257 +10,1257 @@ * SPDX-License-Identifier: CC0-1.0 */ -#if !defined(HEDLEY_VERSION) || (HEDLEY_VERSION < 9) -#if defined(HEDLEY_VERSION) - #undef HEDLEY_VERSION +#if !defined(NLOHMANN_JSON_HEDLEY_VERSION) || (NLOHMANN_JSON_HEDLEY_VERSION < 9) +#if defined(NLOHMANN_JSON_HEDLEY_VERSION) + #undef NLOHMANN_JSON_HEDLEY_VERSION #endif -#define HEDLEY_VERSION 9 +#define NLOHMANN_JSON_HEDLEY_VERSION 9 -#if defined(HEDLEY_STRINGIFY_EX) - #undef HEDLEY_STRINGIFY_EX +#if defined(NLOHMANN_JSON_HEDLEY_STRINGIFY_EX) + #undef NLOHMANN_JSON_HEDLEY_STRINGIFY_EX #endif -#define HEDLEY_STRINGIFY_EX(x) #x +#define NLOHMANN_JSON_HEDLEY_STRINGIFY_EX(x) #x -#if defined(HEDLEY_STRINGIFY) - #undef HEDLEY_STRINGIFY +#if defined(NLOHMANN_JSON_HEDLEY_STRINGIFY) + #undef NLOHMANN_JSON_HEDLEY_STRINGIFY #endif -#define HEDLEY_STRINGIFY(x) HEDLEY_STRINGIFY_EX(x) +#define NLOHMANN_JSON_HEDLEY_STRINGIFY(x) NLOHMANN_JSON_HEDLEY_STRINGIFY_EX(x) -#if defined(HEDLEY_CONCAT_EX) - #undef HEDLEY_CONCAT_EX +#if defined(NLOHMANN_JSON_HEDLEY_CONCAT_EX) + #undef NLOHMANN_JSON_HEDLEY_CONCAT_EX #endif -#define HEDLEY_CONCAT_EX(a,b) a##b +#define NLOHMANN_JSON_HEDLEY_CONCAT_EX(a,b) a##b -#if defined(HEDLEY_CONCAT) - #undef HEDLEY_CONCAT +#if defined(NLOHMANN_JSON_HEDLEY_CONCAT) + #undef NLOHMANN_JSON_HEDLEY_CONCAT #endif -#define HEDLEY_CONCAT(a,b) HEDLEY_CONCAT_EX(a,b) +#define NLOHMANN_JSON_HEDLEY_CONCAT(a,b) NLOHMANN_JSON_HEDLEY_CONCAT_EX(a,b) -#if defined(HEDLEY_VERSION_ENCODE) - #undef HEDLEY_VERSION_ENCODE +#if defined(NLOHMANN_JSON_HEDLEY_VERSION_ENCODE) + #undef NLOHMANN_JSON_HEDLEY_VERSION_ENCODE #endif -#define HEDLEY_VERSION_ENCODE(major,minor,revision) (((major) * 1000000) + ((minor) * 1000) + (revision)) +#define NLOHMANN_JSON_HEDLEY_VERSION_ENCODE(major,minor,revision) (((major) * 1000000) + ((minor) * 1000) + (revision)) -#if defined(HEDLEY_VERSION_DECODE_MAJOR) - #undef HEDLEY_VERSION_DECODE_MAJOR +#if defined(NLOHMANN_JSON_HEDLEY_VERSION_DECODE_MAJOR) + #undef NLOHMANN_JSON_HEDLEY_VERSION_DECODE_MAJOR #endif -#define HEDLEY_VERSION_DECODE_MAJOR(version) ((version) / 1000000) +#define NLOHMANN_JSON_HEDLEY_VERSION_DECODE_MAJOR(version) ((version) / 1000000) -#if defined(HEDLEY_VERSION_DECODE_MINOR) - #undef HEDLEY_VERSION_DECODE_MINOR +#if defined(NLOHMANN_JSON_HEDLEY_VERSION_DECODE_MINOR) + #undef NLOHMANN_JSON_HEDLEY_VERSION_DECODE_MINOR #endif -#define HEDLEY_VERSION_DECODE_MINOR(version) (((version) % 1000000) / 1000) +#define NLOHMANN_JSON_HEDLEY_VERSION_DECODE_MINOR(version) (((version) % 1000000) / 1000) -#if defined(HEDLEY_VERSION_DECODE_REVISION) - #undef HEDLEY_VERSION_DECODE_REVISION +#if defined(NLOHMANN_JSON_HEDLEY_VERSION_DECODE_REVISION) + #undef NLOHMANN_JSON_HEDLEY_VERSION_DECODE_REVISION #endif -#define HEDLEY_VERSION_DECODE_REVISION(version) ((version) % 1000) +#define NLOHMANN_JSON_HEDLEY_VERSION_DECODE_REVISION(version) ((version) % 1000) -#if defined(HEDLEY_GNUC_VERSION) - #undef HEDLEY_GNUC_VERSION +#if defined(NLOHMANN_JSON_HEDLEY_GNUC_VERSION) + #undef NLOHMANN_JSON_HEDLEY_GNUC_VERSION #endif #if defined(__GNUC__) && defined(__GNUC_PATCHLEVEL__) - #define HEDLEY_GNUC_VERSION HEDLEY_VERSION_ENCODE(__GNUC__, __GNUC_MINOR__, __GNUC_PATCHLEVEL__) + #define NLOHMANN_JSON_HEDLEY_GNUC_VERSION NLOHMANN_JSON_HEDLEY_VERSION_ENCODE(__GNUC__, __GNUC_MINOR__, __GNUC_PATCHLEVEL__) #elif defined(__GNUC__) - #define HEDLEY_GNUC_VERSION HEDLEY_VERSION_ENCODE(__GNUC__, __GNUC_MINOR__, 0) + #define NLOHMANN_JSON_HEDLEY_GNUC_VERSION NLOHMANN_JSON_HEDLEY_VERSION_ENCODE(__GNUC__, __GNUC_MINOR__, 0) #endif -#if defined(HEDLEY_GNUC_VERSION_CHECK) - #undef HEDLEY_GNUC_VERSION_CHECK +#if defined(NLOHMANN_JSON_HEDLEY_GNUC_VERSION_CHECK) + #undef NLOHMANN_JSON_HEDLEY_GNUC_VERSION_CHECK #endif -#if defined(HEDLEY_GNUC_VERSION) - #define HEDLEY_GNUC_VERSION_CHECK(major,minor,patch) (HEDLEY_GNUC_VERSION >= HEDLEY_VERSION_ENCODE(major, minor, patch)) +#if defined(NLOHMANN_JSON_HEDLEY_GNUC_VERSION) + #define NLOHMANN_JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch) (NLOHMANN_JSON_HEDLEY_GNUC_VERSION >= NLOHMANN_JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) #else - #define HEDLEY_GNUC_VERSION_CHECK(major,minor,patch) (0) + #define NLOHMANN_JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch) (0) #endif -#if defined(HEDLEY_MSVC_VERSION) - #undef HEDLEY_MSVC_VERSION +#if defined(NLOHMANN_JSON_HEDLEY_MSVC_VERSION) + #undef NLOHMANN_JSON_HEDLEY_MSVC_VERSION #endif #if defined(_MSC_FULL_VER) && (_MSC_FULL_VER >= 140000000) - #define HEDLEY_MSVC_VERSION HEDLEY_VERSION_ENCODE(_MSC_FULL_VER / 10000000, (_MSC_FULL_VER % 10000000) / 100000, (_MSC_FULL_VER % 100000) / 100) + #define NLOHMANN_JSON_HEDLEY_MSVC_VERSION NLOHMANN_JSON_HEDLEY_VERSION_ENCODE(_MSC_FULL_VER / 10000000, (_MSC_FULL_VER % 10000000) / 100000, (_MSC_FULL_VER % 100000) / 100) #elif defined(_MSC_FULL_VER) - #define HEDLEY_MSVC_VERSION HEDLEY_VERSION_ENCODE(_MSC_FULL_VER / 1000000, (_MSC_FULL_VER % 1000000) / 10000, (_MSC_FULL_VER % 10000) / 10) + #define NLOHMANN_JSON_HEDLEY_MSVC_VERSION NLOHMANN_JSON_HEDLEY_VERSION_ENCODE(_MSC_FULL_VER / 1000000, (_MSC_FULL_VER % 1000000) / 10000, (_MSC_FULL_VER % 10000) / 10) #elif defined(_MSC_VER) - #define HEDLEY_MSVC_VERSION HEDLEY_VERSION_ENCODE(_MSC_VER / 100, _MSC_VER % 100, 0) + #define NLOHMANN_JSON_HEDLEY_MSVC_VERSION NLOHMANN_JSON_HEDLEY_VERSION_ENCODE(_MSC_VER / 100, _MSC_VER % 100, 0) #endif -#if defined(HEDLEY_MSVC_VERSION_CHECK) - #undef HEDLEY_MSVC_VERSION_CHECK +#if defined(NLOHMANN_JSON_HEDLEY_MSVC_VERSION_CHECK) + #undef NLOHMANN_JSON_HEDLEY_MSVC_VERSION_CHECK #endif #if !defined(_MSC_VER) - #define HEDLEY_MSVC_VERSION_CHECK(major,minor,patch) (0) + #define NLOHMANN_JSON_HEDLEY_MSVC_VERSION_CHECK(major,minor,patch) (0) #elif defined(_MSC_VER) && (_MSC_VER >= 1400) - #define HEDLEY_MSVC_VERSION_CHECK(major,minor,patch) (_MSC_FULL_VER >= ((major * 10000000) + (minor * 100000) + (patch))) + #define NLOHMANN_JSON_HEDLEY_MSVC_VERSION_CHECK(major,minor,patch) (_MSC_FULL_VER >= ((major * 10000000) + (minor * 100000) + (patch))) #elif defined(_MSC_VER) && (_MSC_VER >= 1200) - #define HEDLEY_MSVC_VERSION_CHECK(major,minor,patch) (_MSC_FULL_VER >= ((major * 1000000) + (minor * 10000) + (patch))) + #define NLOHMANN_JSON_HEDLEY_MSVC_VERSION_CHECK(major,minor,patch) (_MSC_FULL_VER >= ((major * 1000000) + (minor * 10000) + (patch))) #else - #define HEDLEY_MSVC_VERSION_CHECK(major,minor,patch) (_MSC_VER >= ((major * 100) + (minor))) + #define NLOHMANN_JSON_HEDLEY_MSVC_VERSION_CHECK(major,minor,patch) (_MSC_VER >= ((major * 100) + (minor))) #endif -#if defined(HEDLEY_INTEL_VERSION) - #undef HEDLEY_INTEL_VERSION +#if defined(NLOHMANN_JSON_HEDLEY_INTEL_VERSION) + #undef NLOHMANN_JSON_HEDLEY_INTEL_VERSION #endif #if defined(__INTEL_COMPILER) && defined(__INTEL_COMPILER_UPDATE) - #define HEDLEY_INTEL_VERSION HEDLEY_VERSION_ENCODE(__INTEL_COMPILER / 100, __INTEL_COMPILER % 100, __INTEL_COMPILER_UPDATE) + #define NLOHMANN_JSON_HEDLEY_INTEL_VERSION NLOHMANN_JSON_HEDLEY_VERSION_ENCODE(__INTEL_COMPILER / 100, __INTEL_COMPILER % 100, __INTEL_COMPILER_UPDATE) #elif defined(__INTEL_COMPILER) - #define HEDLEY_INTEL_VERSION HEDLEY_VERSION_ENCODE(__INTEL_COMPILER / 100, __INTEL_COMPILER % 100, 0) + #define NLOHMANN_JSON_HEDLEY_INTEL_VERSION NLOHMANN_JSON_HEDLEY_VERSION_ENCODE(__INTEL_COMPILER / 100, __INTEL_COMPILER % 100, 0) #endif -#if defined(HEDLEY_INTEL_VERSION_CHECK) - #undef HEDLEY_INTEL_VERSION_CHECK +#if defined(NLOHMANN_JSON_HEDLEY_INTEL_VERSION_CHECK) + #undef NLOHMANN_JSON_HEDLEY_INTEL_VERSION_CHECK #endif -#if defined(HEDLEY_INTEL_VERSION) - #define HEDLEY_INTEL_VERSION_CHECK(major,minor,patch) (HEDLEY_INTEL_VERSION >= HEDLEY_VERSION_ENCODE(major, minor, patch)) +#if defined(NLOHMANN_JSON_HEDLEY_INTEL_VERSION) + #define NLOHMANN_JSON_HEDLEY_INTEL_VERSION_CHECK(major,minor,patch) (NLOHMANN_JSON_HEDLEY_INTEL_VERSION >= NLOHMANN_JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) #else - #define HEDLEY_INTEL_VERSION_CHECK(major,minor,patch) (0) + #define NLOHMANN_JSON_HEDLEY_INTEL_VERSION_CHECK(major,minor,patch) (0) #endif -#if defined(HEDLEY_PGI_VERSION) - #undef HEDLEY_PGI_VERSION +#if defined(NLOHMANN_JSON_HEDLEY_PGI_VERSION) + #undef NLOHMANN_JSON_HEDLEY_PGI_VERSION #endif #if defined(__PGI) && defined(__PGIC__) && defined(__PGIC_MINOR__) && defined(__PGIC_PATCHLEVEL__) - #define HEDLEY_PGI_VERSION HEDLEY_VERSION_ENCODE(__PGIC__, __PGIC_MINOR__, __PGIC_PATCHLEVEL__) + #define NLOHMANN_JSON_HEDLEY_PGI_VERSION NLOHMANN_JSON_HEDLEY_VERSION_ENCODE(__PGIC__, __PGIC_MINOR__, __PGIC_PATCHLEVEL__) #endif -#if defined(HEDLEY_PGI_VERSION_CHECK) - #undef HEDLEY_PGI_VERSION_CHECK +#if defined(NLOHMANN_JSON_HEDLEY_PGI_VERSION_CHECK) + #undef NLOHMANN_JSON_HEDLEY_PGI_VERSION_CHECK #endif -#if defined(HEDLEY_PGI_VERSION) - #define HEDLEY_PGI_VERSION_CHECK(major,minor,patch) (HEDLEY_PGI_VERSION >= HEDLEY_VERSION_ENCODE(major, minor, patch)) +#if defined(NLOHMANN_JSON_HEDLEY_PGI_VERSION) + #define NLOHMANN_JSON_HEDLEY_PGI_VERSION_CHECK(major,minor,patch) (NLOHMANN_JSON_HEDLEY_PGI_VERSION >= NLOHMANN_JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) #else - #define HEDLEY_PGI_VERSION_CHECK(major,minor,patch) (0) + #define NLOHMANN_JSON_HEDLEY_PGI_VERSION_CHECK(major,minor,patch) (0) #endif -#if defined(HEDLEY_SUNPRO_VERSION) - #undef HEDLEY_SUNPRO_VERSION +#if defined(NLOHMANN_JSON_HEDLEY_SUNPRO_VERSION) + #undef NLOHMANN_JSON_HEDLEY_SUNPRO_VERSION #endif #if defined(__SUNPRO_C) && (__SUNPRO_C > 0x1000) - #define HEDLEY_SUNPRO_VERSION HEDLEY_VERSION_ENCODE((((__SUNPRO_C >> 16) & 0xf) * 10) + ((__SUNPRO_C >> 12) & 0xf), (((__SUNPRO_C >> 8) & 0xf) * 10) + ((__SUNPRO_C >> 4) & 0xf), (__SUNPRO_C & 0xf) * 10) + #define NLOHMANN_JSON_HEDLEY_SUNPRO_VERSION NLOHMANN_JSON_HEDLEY_VERSION_ENCODE((((__SUNPRO_C >> 16) & 0xf) * 10) + ((__SUNPRO_C >> 12) & 0xf), (((__SUNPRO_C >> 8) & 0xf) * 10) + ((__SUNPRO_C >> 4) & 0xf), (__SUNPRO_C & 0xf) * 10) #elif defined(__SUNPRO_C) - #define HEDLEY_SUNPRO_VERSION HEDLEY_VERSION_ENCODE((__SUNPRO_C >> 8) & 0xf, (__SUNPRO_C >> 4) & 0xf, (__SUNPRO_C) & 0xf) + #define NLOHMANN_JSON_HEDLEY_SUNPRO_VERSION NLOHMANN_JSON_HEDLEY_VERSION_ENCODE((__SUNPRO_C >> 8) & 0xf, (__SUNPRO_C >> 4) & 0xf, (__SUNPRO_C) & 0xf) #elif defined(__SUNPRO_CC) && (__SUNPRO_CC > 0x1000) - #define HEDLEY_SUNPRO_VERSION HEDLEY_VERSION_ENCODE((((__SUNPRO_CC >> 16) & 0xf) * 10) + ((__SUNPRO_CC >> 12) & 0xf), (((__SUNPRO_CC >> 8) & 0xf) * 10) + ((__SUNPRO_CC >> 4) & 0xf), (__SUNPRO_CC & 0xf) * 10) + #define NLOHMANN_JSON_HEDLEY_SUNPRO_VERSION NLOHMANN_JSON_HEDLEY_VERSION_ENCODE((((__SUNPRO_CC >> 16) & 0xf) * 10) + ((__SUNPRO_CC >> 12) & 0xf), (((__SUNPRO_CC >> 8) & 0xf) * 10) + ((__SUNPRO_CC >> 4) & 0xf), (__SUNPRO_CC & 0xf) * 10) #elif defined(__SUNPRO_CC) - #define HEDLEY_SUNPRO_VERSION HEDLEY_VERSION_ENCODE((__SUNPRO_CC >> 8) & 0xf, (__SUNPRO_CC >> 4) & 0xf, (__SUNPRO_CC) & 0xf) + #define NLOHMANN_JSON_HEDLEY_SUNPRO_VERSION NLOHMANN_JSON_HEDLEY_VERSION_ENCODE((__SUNPRO_CC >> 8) & 0xf, (__SUNPRO_CC >> 4) & 0xf, (__SUNPRO_CC) & 0xf) #endif -#if defined(HEDLEY_SUNPRO_VERSION_CHECK) - #undef HEDLEY_SUNPRO_VERSION_CHECK +#if defined(NLOHMANN_JSON_HEDLEY_SUNPRO_VERSION_CHECK) + #undef NLOHMANN_JSON_HEDLEY_SUNPRO_VERSION_CHECK #endif -#if defined(HEDLEY_SUNPRO_VERSION) - #define HEDLEY_SUNPRO_VERSION_CHECK(major,minor,patch) (HEDLEY_SUNPRO_VERSION >= HEDLEY_VERSION_ENCODE(major, minor, patch)) +#if defined(NLOHMANN_JSON_HEDLEY_SUNPRO_VERSION) + #define NLOHMANN_JSON_HEDLEY_SUNPRO_VERSION_CHECK(major,minor,patch) (NLOHMANN_JSON_HEDLEY_SUNPRO_VERSION >= NLOHMANN_JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) #else - #define HEDLEY_SUNPRO_VERSION_CHECK(major,minor,patch) (0) + #define NLOHMANN_JSON_HEDLEY_SUNPRO_VERSION_CHECK(major,minor,patch) (0) #endif -#if defined(HEDLEY_EMSCRIPTEN_VERSION) - #undef HEDLEY_EMSCRIPTEN_VERSION +#if defined(NLOHMANN_JSON_HEDLEY_EMSCRIPTEN_VERSION) + #undef NLOHMANN_JSON_HEDLEY_EMSCRIPTEN_VERSION #endif #if defined(__EMSCRIPTEN__) - #define HEDLEY_EMSCRIPTEN_VERSION HEDLEY_VERSION_ENCODE(__EMSCRIPTEN_major__, __EMSCRIPTEN_minor__, __EMSCRIPTEN_tiny__) + #define NLOHMANN_JSON_HEDLEY_EMSCRIPTEN_VERSION NLOHMANN_JSON_HEDLEY_VERSION_ENCODE(__EMSCRIPTEN_major__, __EMSCRIPTEN_minor__, __EMSCRIPTEN_tiny__) #endif -#if defined(HEDLEY_EMSCRIPTEN_VERSION_CHECK) - #undef HEDLEY_EMSCRIPTEN_VERSION_CHECK +#if defined(NLOHMANN_JSON_HEDLEY_EMSCRIPTEN_VERSION_CHECK) + #undef NLOHMANN_JSON_HEDLEY_EMSCRIPTEN_VERSION_CHECK #endif -#if defined(HEDLEY_EMSCRIPTEN_VERSION) - #define HEDLEY_EMSCRIPTEN_VERSION_CHECK(major,minor,patch) (HEDLEY_EMSCRIPTEN_VERSION >= HEDLEY_VERSION_ENCODE(major, minor, patch)) +#if defined(NLOHMANN_JSON_HEDLEY_EMSCRIPTEN_VERSION) + #define NLOHMANN_JSON_HEDLEY_EMSCRIPTEN_VERSION_CHECK(major,minor,patch) (NLOHMANN_JSON_HEDLEY_EMSCRIPTEN_VERSION >= NLOHMANN_JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) #else - #define HEDLEY_EMSCRIPTEN_VERSION_CHECK(major,minor,patch) (0) + #define NLOHMANN_JSON_HEDLEY_EMSCRIPTEN_VERSION_CHECK(major,minor,patch) (0) #endif -#if defined(HEDLEY_ARM_VERSION) - #undef HEDLEY_ARM_VERSION +#if defined(NLOHMANN_JSON_HEDLEY_ARM_VERSION) + #undef NLOHMANN_JSON_HEDLEY_ARM_VERSION #endif #if defined(__CC_ARM) && defined(__ARMCOMPILER_VERSION) - #define HEDLEY_ARM_VERSION HEDLEY_VERSION_ENCODE(__ARMCOMPILER_VERSION / 1000000, (__ARMCOMPILER_VERSION % 1000000) / 10000, (__ARMCOMPILER_VERSION % 10000) / 100) + #define NLOHMANN_JSON_HEDLEY_ARM_VERSION NLOHMANN_JSON_HEDLEY_VERSION_ENCODE(__ARMCOMPILER_VERSION / 1000000, (__ARMCOMPILER_VERSION % 1000000) / 10000, (__ARMCOMPILER_VERSION % 10000) / 100) #elif defined(__CC_ARM) && defined(__ARMCC_VERSION) - #define HEDLEY_ARM_VERSION HEDLEY_VERSION_ENCODE(__ARMCC_VERSION / 1000000, (__ARMCC_VERSION % 1000000) / 10000, (__ARMCC_VERSION % 10000) / 100) + #define NLOHMANN_JSON_HEDLEY_ARM_VERSION NLOHMANN_JSON_HEDLEY_VERSION_ENCODE(__ARMCC_VERSION / 1000000, (__ARMCC_VERSION % 1000000) / 10000, (__ARMCC_VERSION % 10000) / 100) #endif -#if defined(HEDLEY_ARM_VERSION_CHECK) - #undef HEDLEY_ARM_VERSION_CHECK +#if defined(NLOHMANN_JSON_HEDLEY_ARM_VERSION_CHECK) + #undef NLOHMANN_JSON_HEDLEY_ARM_VERSION_CHECK #endif -#if defined(HEDLEY_ARM_VERSION) - #define HEDLEY_ARM_VERSION_CHECK(major,minor,patch) (HEDLEY_ARM_VERSION >= HEDLEY_VERSION_ENCODE(major, minor, patch)) +#if defined(NLOHMANN_JSON_HEDLEY_ARM_VERSION) + #define NLOHMANN_JSON_HEDLEY_ARM_VERSION_CHECK(major,minor,patch) (NLOHMANN_JSON_HEDLEY_ARM_VERSION >= NLOHMANN_JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) #else - #define HEDLEY_ARM_VERSION_CHECK(major,minor,patch) (0) + #define NLOHMANN_JSON_HEDLEY_ARM_VERSION_CHECK(major,minor,patch) (0) #endif -#if defined(HEDLEY_IBM_VERSION) - #undef HEDLEY_IBM_VERSION +#if defined(NLOHMANN_JSON_HEDLEY_IBM_VERSION) + #undef NLOHMANN_JSON_HEDLEY_IBM_VERSION #endif #if defined(__ibmxl__) - #define HEDLEY_IBM_VERSION HEDLEY_VERSION_ENCODE(__ibmxl_version__, __ibmxl_release__, __ibmxl_modification__) + #define NLOHMANN_JSON_HEDLEY_IBM_VERSION NLOHMANN_JSON_HEDLEY_VERSION_ENCODE(__ibmxl_version__, __ibmxl_release__, __ibmxl_modification__) #elif defined(__xlC__) && defined(__xlC_ver__) - #define HEDLEY_IBM_VERSION HEDLEY_VERSION_ENCODE(__xlC__ >> 8, __xlC__ & 0xff, (__xlC_ver__ >> 8) & 0xff) + #define NLOHMANN_JSON_HEDLEY_IBM_VERSION NLOHMANN_JSON_HEDLEY_VERSION_ENCODE(__xlC__ >> 8, __xlC__ & 0xff, (__xlC_ver__ >> 8) & 0xff) #elif defined(__xlC__) - #define HEDLEY_IBM_VERSION HEDLEY_VERSION_ENCODE(__xlC__ >> 8, __xlC__ & 0xff, 0) + #define NLOHMANN_JSON_HEDLEY_IBM_VERSION NLOHMANN_JSON_HEDLEY_VERSION_ENCODE(__xlC__ >> 8, __xlC__ & 0xff, 0) #endif -#if defined(HEDLEY_IBM_VERSION_CHECK) - #undef HEDLEY_IBM_VERSION_CHECK +#if defined(NLOHMANN_JSON_HEDLEY_IBM_VERSION_CHECK) + #undef NLOHMANN_JSON_HEDLEY_IBM_VERSION_CHECK #endif -#if defined(HEDLEY_IBM_VERSION) - #define HEDLEY_IBM_VERSION_CHECK(major,minor,patch) (HEDLEY_IBM_VERSION >= HEDLEY_VERSION_ENCODE(major, minor, patch)) +#if defined(NLOHMANN_JSON_HEDLEY_IBM_VERSION) + #define NLOHMANN_JSON_HEDLEY_IBM_VERSION_CHECK(major,minor,patch) (NLOHMANN_JSON_HEDLEY_IBM_VERSION >= NLOHMANN_JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) #else - #define HEDLEY_IBM_VERSION_CHECK(major,minor,patch) (0) + #define NLOHMANN_JSON_HEDLEY_IBM_VERSION_CHECK(major,minor,patch) (0) #endif -#if defined(HEDLEY_TI_VERSION) - #undef HEDLEY_TI_VERSION +#if defined(NLOHMANN_JSON_HEDLEY_TI_VERSION) + #undef NLOHMANN_JSON_HEDLEY_TI_VERSION #endif #if defined(__TI_COMPILER_VERSION__) - #define HEDLEY_TI_VERSION HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000)) + #define NLOHMANN_JSON_HEDLEY_TI_VERSION NLOHMANN_JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000)) #endif -#if defined(HEDLEY_TI_VERSION_CHECK) - #undef HEDLEY_TI_VERSION_CHECK +#if defined(NLOHMANN_JSON_HEDLEY_TI_VERSION_CHECK) + #undef NLOHMANN_JSON_HEDLEY_TI_VERSION_CHECK #endif -#if defined(HEDLEY_TI_VERSION) - #define HEDLEY_TI_VERSION_CHECK(major,minor,patch) (HEDLEY_TI_VERSION >= HEDLEY_VERSION_ENCODE(major, minor, patch)) +#if defined(NLOHMANN_JSON_HEDLEY_TI_VERSION) + #define NLOHMANN_JSON_HEDLEY_TI_VERSION_CHECK(major,minor,patch) (NLOHMANN_JSON_HEDLEY_TI_VERSION >= NLOHMANN_JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) #else - #define HEDLEY_TI_VERSION_CHECK(major,minor,patch) (0) + #define NLOHMANN_JSON_HEDLEY_TI_VERSION_CHECK(major,minor,patch) (0) #endif -#if defined(HEDLEY_CRAY_VERSION) - #undef HEDLEY_CRAY_VERSION +#if defined(NLOHMANN_JSON_HEDLEY_CRAY_VERSION) + #undef NLOHMANN_JSON_HEDLEY_CRAY_VERSION #endif #if defined(_CRAYC) #if defined(_RELEASE_PATCHLEVEL) - #define HEDLEY_CRAY_VERSION HEDLEY_VERSION_ENCODE(_RELEASE_MAJOR, _RELEASE_MINOR, _RELEASE_PATCHLEVEL) + #define NLOHMANN_JSON_HEDLEY_CRAY_VERSION NLOHMANN_JSON_HEDLEY_VERSION_ENCODE(_RELEASE_MAJOR, _RELEASE_MINOR, _RELEASE_PATCHLEVEL) #else - #define HEDLEY_CRAY_VERSION HEDLEY_VERSION_ENCODE(_RELEASE_MAJOR, _RELEASE_MINOR, 0) + #define NLOHMANN_JSON_HEDLEY_CRAY_VERSION NLOHMANN_JSON_HEDLEY_VERSION_ENCODE(_RELEASE_MAJOR, _RELEASE_MINOR, 0) #endif #endif -#if defined(HEDLEY_CRAY_VERSION_CHECK) - #undef HEDLEY_CRAY_VERSION_CHECK +#if defined(NLOHMANN_JSON_HEDLEY_CRAY_VERSION_CHECK) + #undef NLOHMANN_JSON_HEDLEY_CRAY_VERSION_CHECK #endif -#if defined(HEDLEY_CRAY_VERSION) - #define HEDLEY_CRAY_VERSION_CHECK(major,minor,patch) (HEDLEY_CRAY_VERSION >= HEDLEY_VERSION_ENCODE(major, minor, patch)) +#if defined(NLOHMANN_JSON_HEDLEY_CRAY_VERSION) + #define NLOHMANN_JSON_HEDLEY_CRAY_VERSION_CHECK(major,minor,patch) (NLOHMANN_JSON_HEDLEY_CRAY_VERSION >= NLOHMANN_JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) #else - #define HEDLEY_CRAY_VERSION_CHECK(major,minor,patch) (0) + #define NLOHMANN_JSON_HEDLEY_CRAY_VERSION_CHECK(major,minor,patch) (0) #endif -#if defined(HEDLEY_IAR_VERSION) - #undef HEDLEY_IAR_VERSION +#if defined(NLOHMANN_JSON_HEDLEY_IAR_VERSION) + #undef NLOHMANN_JSON_HEDLEY_IAR_VERSION #endif #if defined(__IAR_SYSTEMS_ICC__) #if __VER__ > 1000 - #define HEDLEY_IAR_VERSION HEDLEY_VERSION_ENCODE((__VER__ / 1000000), ((__VER__ / 1000) % 1000), (__VER__ % 1000)) + #define NLOHMANN_JSON_HEDLEY_IAR_VERSION NLOHMANN_JSON_HEDLEY_VERSION_ENCODE((__VER__ / 1000000), ((__VER__ / 1000) % 1000), (__VER__ % 1000)) #else - #define HEDLEY_IAR_VERSION HEDLEY_VERSION_ENCODE(VER / 100, __VER__ % 100, 0) + #define NLOHMANN_JSON_HEDLEY_IAR_VERSION NLOHMANN_JSON_HEDLEY_VERSION_ENCODE(VER / 100, __VER__ % 100, 0) #endif #endif -#if defined(HEDLEY_IAR_VERSION_CHECK) - #undef HEDLEY_IAR_VERSION_CHECK +#if defined(NLOHMANN_JSON_HEDLEY_IAR_VERSION_CHECK) + #undef NLOHMANN_JSON_HEDLEY_IAR_VERSION_CHECK #endif -#if defined(HEDLEY_IAR_VERSION) - #define HEDLEY_IAR_VERSION_CHECK(major,minor,patch) (HEDLEY_IAR_VERSION >= HEDLEY_VERSION_ENCODE(major, minor, patch)) +#if defined(NLOHMANN_JSON_HEDLEY_IAR_VERSION) + #define NLOHMANN_JSON_HEDLEY_IAR_VERSION_CHECK(major,minor,patch) (NLOHMANN_JSON_HEDLEY_IAR_VERSION >= NLOHMANN_JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) #else - #define HEDLEY_IAR_VERSION_CHECK(major,minor,patch) (0) + #define NLOHMANN_JSON_HEDLEY_IAR_VERSION_CHECK(major,minor,patch) (0) #endif -#if defined(HEDLEY_TINYC_VERSION) - #undef HEDLEY_TINYC_VERSION +#if defined(NLOHMANN_JSON_HEDLEY_TINYC_VERSION) + #undef NLOHMANN_JSON_HEDLEY_TINYC_VERSION #endif #if defined(__TINYC__) - #define HEDLEY_TINYC_VERSION HEDLEY_VERSION_ENCODE(__TINYC__ / 1000, (__TINYC__ / 100) % 10, __TINYC__ % 100) + #define NLOHMANN_JSON_HEDLEY_TINYC_VERSION NLOHMANN_JSON_HEDLEY_VERSION_ENCODE(__TINYC__ / 1000, (__TINYC__ / 100) % 10, __TINYC__ % 100) #endif -#if defined(HEDLEY_TINYC_VERSION_CHECK) - #undef HEDLEY_TINYC_VERSION_CHECK +#if defined(NLOHMANN_JSON_HEDLEY_TINYC_VERSION_CHECK) + #undef NLOHMANN_JSON_HEDLEY_TINYC_VERSION_CHECK #endif -#if defined(HEDLEY_TINYC_VERSION) - #define HEDLEY_TINYC_VERSION_CHECK(major,minor,patch) (HEDLEY_TINYC_VERSION >= HEDLEY_VERSION_ENCODE(major, minor, patch)) +#if defined(NLOHMANN_JSON_HEDLEY_TINYC_VERSION) + #define NLOHMANN_JSON_HEDLEY_TINYC_VERSION_CHECK(major,minor,patch) (NLOHMANN_JSON_HEDLEY_TINYC_VERSION >= NLOHMANN_JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) #else - #define HEDLEY_TINYC_VERSION_CHECK(major,minor,patch) (0) + #define NLOHMANN_JSON_HEDLEY_TINYC_VERSION_CHECK(major,minor,patch) (0) #endif -#if defined(HEDLEY_DMC_VERSION) - #undef HEDLEY_DMC_VERSION +#if defined(NLOHMANN_JSON_HEDLEY_DMC_VERSION) + #undef NLOHMANN_JSON_HEDLEY_DMC_VERSION #endif #if defined(__DMC__) - #define HEDLEY_DMC_VERSION HEDLEY_VERSION_ENCODE(__DMC__ >> 8, (__DMC__ >> 4) & 0xf, __DMC__ & 0xf) + #define NLOHMANN_JSON_HEDLEY_DMC_VERSION NLOHMANN_JSON_HEDLEY_VERSION_ENCODE(__DMC__ >> 8, (__DMC__ >> 4) & 0xf, __DMC__ & 0xf) #endif -#if defined(HEDLEY_DMC_VERSION_CHECK) - #undef HEDLEY_DMC_VERSION_CHECK +#if defined(NLOHMANN_JSON_HEDLEY_DMC_VERSION_CHECK) + #undef NLOHMANN_JSON_HEDLEY_DMC_VERSION_CHECK #endif -#if defined(HEDLEY_DMC_VERSION) - #define HEDLEY_DMC_VERSION_CHECK(major,minor,patch) (HEDLEY_DMC_VERSION >= HEDLEY_VERSION_ENCODE(major, minor, patch)) +#if defined(NLOHMANN_JSON_HEDLEY_DMC_VERSION) + #define NLOHMANN_JSON_HEDLEY_DMC_VERSION_CHECK(major,minor,patch) (NLOHMANN_JSON_HEDLEY_DMC_VERSION >= NLOHMANN_JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) #else - #define HEDLEY_DMC_VERSION_CHECK(major,minor,patch) (0) + #define NLOHMANN_JSON_HEDLEY_DMC_VERSION_CHECK(major,minor,patch) (0) #endif -#if defined(HEDLEY_COMPCERT_VERSION) - #undef HEDLEY_COMPCERT_VERSION +#if defined(NLOHMANN_JSON_HEDLEY_COMPCERT_VERSION) + #undef NLOHMANN_JSON_HEDLEY_COMPCERT_VERSION #endif #if defined(__COMPCERT_VERSION__) - #define HEDLEY_COMPCERT_VERSION HEDLEY_VERSION_ENCODE(__COMPCERT_VERSION__ / 10000, (__COMPCERT_VERSION__ / 100) % 100, __COMPCERT_VERSION__ % 100) + #define NLOHMANN_JSON_HEDLEY_COMPCERT_VERSION NLOHMANN_JSON_HEDLEY_VERSION_ENCODE(__COMPCERT_VERSION__ / 10000, (__COMPCERT_VERSION__ / 100) % 100, __COMPCERT_VERSION__ % 100) #endif -#if defined(HEDLEY_COMPCERT_VERSION_CHECK) - #undef HEDLEY_COMPCERT_VERSION_CHECK +#if defined(NLOHMANN_JSON_HEDLEY_COMPCERT_VERSION_CHECK) + #undef NLOHMANN_JSON_HEDLEY_COMPCERT_VERSION_CHECK #endif -#if defined(HEDLEY_COMPCERT_VERSION) - #define HEDLEY_COMPCERT_VERSION_CHECK(major,minor,patch) (HEDLEY_COMPCERT_VERSION >= HEDLEY_VERSION_ENCODE(major, minor, patch)) +#if defined(NLOHMANN_JSON_HEDLEY_COMPCERT_VERSION) + #define NLOHMANN_JSON_HEDLEY_COMPCERT_VERSION_CHECK(major,minor,patch) (NLOHMANN_JSON_HEDLEY_COMPCERT_VERSION >= NLOHMANN_JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) #else - #define HEDLEY_COMPCERT_VERSION_CHECK(major,minor,patch) (0) + #define NLOHMANN_JSON_HEDLEY_COMPCERT_VERSION_CHECK(major,minor,patch) (0) #endif -#if defined(HEDLEY_PELLES_VERSION) - #undef HEDLEY_PELLES_VERSION +#if defined(NLOHMANN_JSON_HEDLEY_PELLES_VERSION) + #undef NLOHMANN_JSON_HEDLEY_PELLES_VERSION #endif #if defined(__POCC__) - #define HEDLEY_PELLES_VERSION HEDLEY_VERSION_ENCODE(__POCC__ / 100, __POCC__ % 100, 0) + #define NLOHMANN_JSON_HEDLEY_PELLES_VERSION NLOHMANN_JSON_HEDLEY_VERSION_ENCODE(__POCC__ / 100, __POCC__ % 100, 0) #endif -#if defined(HEDLEY_PELLES_VERSION_CHECK) - #undef HEDLEY_PELLES_VERSION_CHECK +#if defined(NLOHMANN_JSON_HEDLEY_PELLES_VERSION_CHECK) + #undef NLOHMANN_JSON_HEDLEY_PELLES_VERSION_CHECK #endif -#if defined(HEDLEY_PELLES_VERSION) - #define HEDLEY_PELLES_VERSION_CHECK(major,minor,patch) (HEDLEY_PELLES_VERSION >= HEDLEY_VERSION_ENCODE(major, minor, patch)) +#if defined(NLOHMANN_JSON_HEDLEY_PELLES_VERSION) + #define NLOHMANN_JSON_HEDLEY_PELLES_VERSION_CHECK(major,minor,patch) (NLOHMANN_JSON_HEDLEY_PELLES_VERSION >= NLOHMANN_JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) #else - #define HEDLEY_PELLES_VERSION_CHECK(major,minor,patch) (0) + #define NLOHMANN_JSON_HEDLEY_PELLES_VERSION_CHECK(major,minor,patch) (0) #endif -#if defined(HEDLEY_GCC_VERSION) - #undef HEDLEY_GCC_VERSION +#if defined(NLOHMANN_JSON_HEDLEY_GCC_VERSION) + #undef NLOHMANN_JSON_HEDLEY_GCC_VERSION #endif #if \ - defined(HEDLEY_GNUC_VERSION) && \ + defined(NLOHMANN_JSON_HEDLEY_GNUC_VERSION) && \ !defined(__clang__) && \ - !defined(HEDLEY_INTEL_VERSION) && \ - !defined(HEDLEY_PGI_VERSION) && \ - !defined(HEDLEY_ARM_VERSION) && \ - !defined(HEDLEY_TI_VERSION) && \ + !defined(NLOHMANN_JSON_HEDLEY_INTEL_VERSION) && \ + !defined(NLOHMANN_JSON_HEDLEY_PGI_VERSION) && \ + !defined(NLOHMANN_JSON_HEDLEY_ARM_VERSION) && \ + !defined(NLOHMANN_JSON_HEDLEY_TI_VERSION) && \ !defined(__COMPCERT__) - #define HEDLEY_GCC_VERSION HEDLEY_GNUC_VERSION + #define NLOHMANN_JSON_HEDLEY_GCC_VERSION NLOHMANN_JSON_HEDLEY_GNUC_VERSION #endif -#if defined(HEDLEY_GCC_VERSION_CHECK) - #undef HEDLEY_GCC_VERSION_CHECK +#if defined(NLOHMANN_JSON_HEDLEY_GCC_VERSION_CHECK) + #undef NLOHMANN_JSON_HEDLEY_GCC_VERSION_CHECK #endif -#if defined(HEDLEY_GCC_VERSION) - #define HEDLEY_GCC_VERSION_CHECK(major,minor,patch) (HEDLEY_GCC_VERSION >= HEDLEY_VERSION_ENCODE(major, minor, patch)) +#if defined(NLOHMANN_JSON_HEDLEY_GCC_VERSION) + #define NLOHMANN_JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch) (NLOHMANN_JSON_HEDLEY_GCC_VERSION >= NLOHMANN_JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) #else - #define HEDLEY_GCC_VERSION_CHECK(major,minor,patch) (0) + #define NLOHMANN_JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch) (0) #endif -#if defined(HEDLEY_HAS_ATTRIBUTE) - #undef HEDLEY_HAS_ATTRIBUTE +#if defined(NLOHMANN_JSON_HEDLEY_HAS_ATTRIBUTE) + #undef NLOHMANN_JSON_HEDLEY_HAS_ATTRIBUTE #endif #if defined(__has_attribute) - #define HEDLEY_HAS_ATTRIBUTE(attribute) __has_attribute(attribute) + #define NLOHMANN_JSON_HEDLEY_HAS_ATTRIBUTE(attribute) __has_attribute(attribute) #else - #define HEDLEY_HAS_ATTRIBUTE(attribute) (0) + #define NLOHMANN_JSON_HEDLEY_HAS_ATTRIBUTE(attribute) (0) #endif -#if defined(HEDLEY_GNUC_HAS_ATTRIBUTE) - #undef HEDLEY_GNUC_HAS_ATTRIBUTE +#if defined(NLOHMANN_JSON_HEDLEY_GNUC_HAS_ATTRIBUTE) + #undef NLOHMANN_JSON_HEDLEY_GNUC_HAS_ATTRIBUTE #endif #if defined(__has_attribute) - #define HEDLEY_GNUC_HAS_ATTRIBUTE(attribute,major,minor,patch) __has_attribute(attribute) + #define NLOHMANN_JSON_HEDLEY_GNUC_HAS_ATTRIBUTE(attribute,major,minor,patch) __has_attribute(attribute) #else - #define HEDLEY_GNUC_HAS_ATTRIBUTE(attribute,major,minor,patch) HEDLEY_GNUC_VERSION_CHECK(major,minor,patch) + #define NLOHMANN_JSON_HEDLEY_GNUC_HAS_ATTRIBUTE(attribute,major,minor,patch) NLOHMANN_JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch) #endif -#if defined(HEDLEY_GCC_HAS_ATTRIBUTE) - #undef HEDLEY_GCC_HAS_ATTRIBUTE +#if defined(NLOHMANN_JSON_HEDLEY_GCC_HAS_ATTRIBUTE) + #undef NLOHMANN_JSON_HEDLEY_GCC_HAS_ATTRIBUTE #endif #if defined(__has_attribute) - #define HEDLEY_GCC_HAS_ATTRIBUTE(attribute,major,minor,patch) __has_attribute(attribute) + #define NLOHMANN_JSON_HEDLEY_GCC_HAS_ATTRIBUTE(attribute,major,minor,patch) __has_attribute(attribute) #else - #define HEDLEY_GCC_HAS_ATTRIBUTE(attribute,major,minor,patch) HEDLEY_GCC_VERSION_CHECK(major,minor,patch) + #define NLOHMANN_JSON_HEDLEY_GCC_HAS_ATTRIBUTE(attribute,major,minor,patch) NLOHMANN_JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch) #endif -#if defined(HEDLEY_HAS_CPP_ATTRIBUTE) - #undef HEDLEY_HAS_CPP_ATTRIBUTE +#if defined(NLOHMANN_JSON_HEDLEY_HAS_CPP_ATTRIBUTE) + #undef NLOHMANN_JSON_HEDLEY_HAS_CPP_ATTRIBUTE #endif #if defined(__has_cpp_attribute) && defined(__cplusplus) - #define HEDLEY_HAS_CPP_ATTRIBUTE(attribute) __has_cpp_attribute(attribute) + #define NLOHMANN_JSON_HEDLEY_HAS_CPP_ATTRIBUTE(attribute) __has_cpp_attribute(attribute) #else - #define HEDLEY_HAS_CPP_ATTRIBUTE(attribute) (0) + #define NLOHMANN_JSON_HEDLEY_HAS_CPP_ATTRIBUTE(attribute) (0) #endif -#if defined(HEDLEY_GNUC_HAS_CPP_ATTRIBUTE) - #undef HEDLEY_GNUC_HAS_CPP_ATTRIBUTE +#if defined(NLOHMANN_JSON_HEDLEY_GNUC_HAS_CPP_ATTRIBUTE) + #undef NLOHMANN_JSON_HEDLEY_GNUC_HAS_CPP_ATTRIBUTE #endif #if defined(__has_cpp_attribute) && defined(__cplusplus) - #define HEDLEY_GNUC_HAS_CPP_ATTRIBUTE(attribute,major,minor,patch) __has_cpp_attribute(attribute) + #define NLOHMANN_JSON_HEDLEY_GNUC_HAS_CPP_ATTRIBUTE(attribute,major,minor,patch) __has_cpp_attribute(attribute) #else - #define HEDLEY_GNUC_HAS_CPP_ATTRIBUTE(attribute,major,minor,patch) HEDLEY_GNUC_VERSION_CHECK(major,minor,patch) + #define NLOHMANN_JSON_HEDLEY_GNUC_HAS_CPP_ATTRIBUTE(attribute,major,minor,patch) NLOHMANN_JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch) #endif -#if defined(HEDLEY_GCC_HAS_CPP_ATTRIBUTE) - #undef HEDLEY_GCC_HAS_CPP_ATTRIBUTE +#if defined(NLOHMANN_JSON_HEDLEY_GCC_HAS_CPP_ATTRIBUTE) + #undef NLOHMANN_JSON_HEDLEY_GCC_HAS_CPP_ATTRIBUTE #endif #if defined(__has_cpp_attribute) && defined(__cplusplus) - #define HEDLEY_GCC_HAS_CPP_ATTRIBUTE(attribute,major,minor,patch) __has_cpp_attribute(attribute) + #define NLOHMANN_JSON_HEDLEY_GCC_HAS_CPP_ATTRIBUTE(attribute,major,minor,patch) __has_cpp_attribute(attribute) #else - #define HEDLEY_GCC_HAS_CPP_ATTRIBUTE(attribute,major,minor,patch) HEDLEY_GCC_VERSION_CHECK(major,minor,patch) + #define NLOHMANN_JSON_HEDLEY_GCC_HAS_CPP_ATTRIBUTE(attribute,major,minor,patch) NLOHMANN_JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch) #endif -#if defined(HEDLEY_HAS_BUILTIN) - #undef HEDLEY_HAS_BUILTIN +#if defined(NLOHMANN_JSON_HEDLEY_HAS_BUILTIN) + #undef NLOHMANN_JSON_HEDLEY_HAS_BUILTIN #endif #if defined(__has_builtin) - #define HEDLEY_HAS_BUILTIN(builtin) __has_builtin(builtin) + #define NLOHMANN_JSON_HEDLEY_HAS_BUILTIN(builtin) __has_builtin(builtin) #else - #define HEDLEY_HAS_BUILTIN(builtin) (0) + #define NLOHMANN_JSON_HEDLEY_HAS_BUILTIN(builtin) (0) #endif -#if defined(HEDLEY_GNUC_HAS_BUILTIN) - #undef HEDLEY_GNUC_HAS_BUILTIN +#if defined(NLOHMANN_JSON_HEDLEY_GNUC_HAS_BUILTIN) + #undef NLOHMANN_JSON_HEDLEY_GNUC_HAS_BUILTIN #endif #if defined(__has_builtin) - #define HEDLEY_GNUC_HAS_BUILTIN(builtin,major,minor,patch) __has_builtin(builtin) + #define NLOHMANN_JSON_HEDLEY_GNUC_HAS_BUILTIN(builtin,major,minor,patch) __has_builtin(builtin) #else - #define HEDLEY_GNUC_HAS_BUILTIN(builtin,major,minor,patch) HEDLEY_GNUC_VERSION_CHECK(major,minor,patch) + #define NLOHMANN_JSON_HEDLEY_GNUC_HAS_BUILTIN(builtin,major,minor,patch) NLOHMANN_JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch) #endif -#if defined(HEDLEY_GCC_HAS_BUILTIN) - #undef HEDLEY_GCC_HAS_BUILTIN +#if defined(NLOHMANN_JSON_HEDLEY_GCC_HAS_BUILTIN) + #undef NLOHMANN_JSON_HEDLEY_GCC_HAS_BUILTIN #endif #if defined(__has_builtin) - #define HEDLEY_GCC_HAS_BUILTIN(builtin,major,minor,patch) __has_builtin(builtin) + #define NLOHMANN_JSON_HEDLEY_GCC_HAS_BUILTIN(builtin,major,minor,patch) __has_builtin(builtin) #else - #define HEDLEY_GCC_HAS_BUILTIN(builtin,major,minor,patch) HEDLEY_GCC_VERSION_CHECK(major,minor,patch) + #define NLOHMANN_JSON_HEDLEY_GCC_HAS_BUILTIN(builtin,major,minor,patch) NLOHMANN_JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch) #endif -#if defined(HEDLEY_HAS_FEATURE) - #undef HEDLEY_HAS_FEATURE +#if defined(NLOHMANN_JSON_HEDLEY_HAS_FEATURE) + #undef NLOHMANN_JSON_HEDLEY_HAS_FEATURE #endif #if defined(__has_feature) - #define HEDLEY_HAS_FEATURE(feature) __has_feature(feature) + #define NLOHMANN_JSON_HEDLEY_HAS_FEATURE(feature) __has_feature(feature) #else - #define HEDLEY_HAS_FEATURE(feature) (0) + #define NLOHMANN_JSON_HEDLEY_HAS_FEATURE(feature) (0) #endif -#if defined(HEDLEY_GNUC_HAS_FEATURE) - #undef HEDLEY_GNUC_HAS_FEATURE +#if defined(NLOHMANN_JSON_HEDLEY_GNUC_HAS_FEATURE) + #undef NLOHMANN_JSON_HEDLEY_GNUC_HAS_FEATURE #endif #if defined(__has_feature) - #define HEDLEY_GNUC_HAS_FEATURE(feature,major,minor,patch) __has_feature(feature) + #define NLOHMANN_JSON_HEDLEY_GNUC_HAS_FEATURE(feature,major,minor,patch) __has_feature(feature) #else - #define HEDLEY_GNUC_HAS_FEATURE(feature,major,minor,patch) HEDLEY_GNUC_VERSION_CHECK(major,minor,patch) + #define NLOHMANN_JSON_HEDLEY_GNUC_HAS_FEATURE(feature,major,minor,patch) NLOHMANN_JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch) #endif -#if defined(HEDLEY_GCC_HAS_FEATURE) - #undef HEDLEY_GCC_HAS_FEATURE +#if defined(NLOHMANN_JSON_HEDLEY_GCC_HAS_FEATURE) + #undef NLOHMANN_JSON_HEDLEY_GCC_HAS_FEATURE #endif #if defined(__has_feature) - #define HEDLEY_GCC_HAS_FEATURE(feature,major,minor,patch) __has_feature(feature) + #define NLOHMANN_JSON_HEDLEY_GCC_HAS_FEATURE(feature,major,minor,patch) __has_feature(feature) #else - #define HEDLEY_GCC_HAS_FEATURE(feature,major,minor,patch) HEDLEY_GCC_VERSION_CHECK(major,minor,patch) + #define NLOHMANN_JSON_HEDLEY_GCC_HAS_FEATURE(feature,major,minor,patch) NLOHMANN_JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch) #endif -#if defined(HEDLEY_HAS_EXTENSION) - #undef HEDLEY_HAS_EXTENSION +#if defined(NLOHMANN_JSON_HEDLEY_HAS_EXTENSION) + #undef NLOHMANN_JSON_HEDLEY_HAS_EXTENSION #endif #if defined(__has_extension) - #define HEDLEY_HAS_EXTENSION(extension) __has_extension(extension) + #define NLOHMANN_JSON_HEDLEY_HAS_EXTENSION(extension) __has_extension(extension) #else - #define HEDLEY_HAS_EXTENSION(extension) (0) + #define NLOHMANN_JSON_HEDLEY_HAS_EXTENSION(extension) (0) #endif -#if defined(HEDLEY_GNUC_HAS_EXTENSION) - #undef HEDLEY_GNUC_HAS_EXTENSION +#if defined(NLOHMANN_JSON_HEDLEY_GNUC_HAS_EXTENSION) + #undef NLOHMANN_JSON_HEDLEY_GNUC_HAS_EXTENSION #endif #if defined(__has_extension) - #define HEDLEY_GNUC_HAS_EXTENSION(extension,major,minor,patch) __has_extension(extension) + #define NLOHMANN_JSON_HEDLEY_GNUC_HAS_EXTENSION(extension,major,minor,patch) __has_extension(extension) #else - #define HEDLEY_GNUC_HAS_EXTENSION(extension,major,minor,patch) HEDLEY_GNUC_VERSION_CHECK(major,minor,patch) + #define NLOHMANN_JSON_HEDLEY_GNUC_HAS_EXTENSION(extension,major,minor,patch) NLOHMANN_JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch) #endif -#if defined(HEDLEY_GCC_HAS_EXTENSION) - #undef HEDLEY_GCC_HAS_EXTENSION +#if defined(NLOHMANN_JSON_HEDLEY_GCC_HAS_EXTENSION) + #undef NLOHMANN_JSON_HEDLEY_GCC_HAS_EXTENSION #endif #if defined(__has_extension) - #define HEDLEY_GCC_HAS_EXTENSION(extension,major,minor,patch) __has_extension(extension) + #define NLOHMANN_JSON_HEDLEY_GCC_HAS_EXTENSION(extension,major,minor,patch) __has_extension(extension) #else - #define HEDLEY_GCC_HAS_EXTENSION(extension,major,minor,patch) HEDLEY_GCC_VERSION_CHECK(major,minor,patch) + #define NLOHMANN_JSON_HEDLEY_GCC_HAS_EXTENSION(extension,major,minor,patch) NLOHMANN_JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch) #endif -#if defined(HEDLEY_HAS_DECLSPEC_ATTRIBUTE) - #undef HEDLEY_HAS_DECLSPEC_ATTRIBUTE +#if defined(NLOHMANN_JSON_HEDLEY_HAS_DECLSPEC_ATTRIBUTE) + #undef NLOHMANN_JSON_HEDLEY_HAS_DECLSPEC_ATTRIBUTE #endif #if defined(__has_declspec_attribute) - #define HEDLEY_HAS_DECLSPEC_ATTRIBUTE(attribute) __has_declspec_attribute(attribute) + #define NLOHMANN_JSON_HEDLEY_HAS_DECLSPEC_ATTRIBUTE(attribute) __has_declspec_attribute(attribute) #else - #define HEDLEY_HAS_DECLSPEC_ATTRIBUTE(attribute) (0) + #define NLOHMANN_JSON_HEDLEY_HAS_DECLSPEC_ATTRIBUTE(attribute) (0) #endif -#if defined(HEDLEY_GNUC_HAS_DECLSPEC_ATTRIBUTE) - #undef HEDLEY_GNUC_HAS_DECLSPEC_ATTRIBUTE +#if defined(NLOHMANN_JSON_HEDLEY_GNUC_HAS_DECLSPEC_ATTRIBUTE) + #undef NLOHMANN_JSON_HEDLEY_GNUC_HAS_DECLSPEC_ATTRIBUTE #endif #if defined(__has_declspec_attribute) - #define HEDLEY_GNUC_HAS_DECLSPEC_ATTRIBUTE(attribute,major,minor,patch) __has_declspec_attribute(attribute) + #define NLOHMANN_JSON_HEDLEY_GNUC_HAS_DECLSPEC_ATTRIBUTE(attribute,major,minor,patch) __has_declspec_attribute(attribute) #else - #define HEDLEY_GNUC_HAS_DECLSPEC_ATTRIBUTE(attribute,major,minor,patch) HEDLEY_GNUC_VERSION_CHECK(major,minor,patch) + #define NLOHMANN_JSON_HEDLEY_GNUC_HAS_DECLSPEC_ATTRIBUTE(attribute,major,minor,patch) NLOHMANN_JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch) #endif -#if defined(HEDLEY_GCC_HAS_DECLSPEC_ATTRIBUTE) - #undef HEDLEY_GCC_HAS_DECLSPEC_ATTRIBUTE +#if defined(NLOHMANN_JSON_HEDLEY_GCC_HAS_DECLSPEC_ATTRIBUTE) + #undef NLOHMANN_JSON_HEDLEY_GCC_HAS_DECLSPEC_ATTRIBUTE #endif #if defined(__has_declspec_attribute) - #define HEDLEY_GCC_HAS_DECLSPEC_ATTRIBUTE(attribute,major,minor,patch) __has_declspec_attribute(attribute) + #define NLOHMANN_JSON_HEDLEY_GCC_HAS_DECLSPEC_ATTRIBUTE(attribute,major,minor,patch) __has_declspec_attribute(attribute) #else - #define HEDLEY_GCC_HAS_DECLSPEC_ATTRIBUTE(attribute,major,minor,patch) HEDLEY_GCC_VERSION_CHECK(major,minor,patch) + #define NLOHMANN_JSON_HEDLEY_GCC_HAS_DECLSPEC_ATTRIBUTE(attribute,major,minor,patch) NLOHMANN_JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch) #endif -#if defined(HEDLEY_HAS_WARNING) - #undef HEDLEY_HAS_WARNING +#if defined(NLOHMANN_JSON_HEDLEY_HAS_WARNING) + #undef NLOHMANN_JSON_HEDLEY_HAS_WARNING #endif #if defined(__has_warning) - #define HEDLEY_HAS_WARNING(warning) __has_warning(warning) + #define NLOHMANN_JSON_HEDLEY_HAS_WARNING(warning) __has_warning(warning) #else - #define HEDLEY_HAS_WARNING(warning) (0) + #define NLOHMANN_JSON_HEDLEY_HAS_WARNING(warning) (0) #endif -#if defined(HEDLEY_GNUC_HAS_WARNING) - #undef HEDLEY_GNUC_HAS_WARNING +#if defined(NLOHMANN_JSON_HEDLEY_GNUC_HAS_WARNING) + #undef NLOHMANN_JSON_HEDLEY_GNUC_HAS_WARNING #endif #if defined(__has_warning) - #define HEDLEY_GNUC_HAS_WARNING(warning,major,minor,patch) __has_warning(warning) + #define NLOHMANN_JSON_HEDLEY_GNUC_HAS_WARNING(warning,major,minor,patch) __has_warning(warning) #else - #define HEDLEY_GNUC_HAS_WARNING(warning,major,minor,patch) HEDLEY_GNUC_VERSION_CHECK(major,minor,patch) + #define NLOHMANN_JSON_HEDLEY_GNUC_HAS_WARNING(warning,major,minor,patch) NLOHMANN_JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch) #endif -#if defined(HEDLEY_GCC_HAS_WARNING) - #undef HEDLEY_GCC_HAS_WARNING +#if defined(NLOHMANN_JSON_HEDLEY_GCC_HAS_WARNING) + #undef NLOHMANN_JSON_HEDLEY_GCC_HAS_WARNING #endif #if defined(__has_warning) - #define HEDLEY_GCC_HAS_WARNING(warning,major,minor,patch) __has_warning(warning) + #define NLOHMANN_JSON_HEDLEY_GCC_HAS_WARNING(warning,major,minor,patch) __has_warning(warning) #else - #define HEDLEY_GCC_HAS_WARNING(warning,major,minor,patch) HEDLEY_GCC_VERSION_CHECK(major,minor,patch) + #define NLOHMANN_JSON_HEDLEY_GCC_HAS_WARNING(warning,major,minor,patch) NLOHMANN_JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch) #endif #if \ (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)) || \ defined(__clang__) || \ - HEDLEY_GCC_VERSION_CHECK(3,0,0) || \ - HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ - HEDLEY_IAR_VERSION_CHECK(8,0,0) || \ - HEDLEY_PGI_VERSION_CHECK(18,4,0) || \ - HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ - HEDLEY_TI_VERSION_CHECK(6,0,0) || \ - HEDLEY_CRAY_VERSION_CHECK(5,0,0) || \ - HEDLEY_TINYC_VERSION_CHECK(0,9,17) || \ - HEDLEY_SUNPRO_VERSION_CHECK(8,0,0) || \ - (HEDLEY_IBM_VERSION_CHECK(10,1,0) && defined(__C99_PRAGMA_OPERATOR)) - #define HEDLEY_PRAGMA(value) _Pragma(#value) -#elif HEDLEY_MSVC_VERSION_CHECK(15,0,0) - #define HEDLEY_PRAGMA(value) __pragma(value) + NLOHMANN_JSON_HEDLEY_GCC_VERSION_CHECK(3,0,0) || \ + NLOHMANN_JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ + NLOHMANN_JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0) || \ + NLOHMANN_JSON_HEDLEY_PGI_VERSION_CHECK(18,4,0) || \ + NLOHMANN_JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ + NLOHMANN_JSON_HEDLEY_TI_VERSION_CHECK(6,0,0) || \ + NLOHMANN_JSON_HEDLEY_CRAY_VERSION_CHECK(5,0,0) || \ + NLOHMANN_JSON_HEDLEY_TINYC_VERSION_CHECK(0,9,17) || \ + NLOHMANN_JSON_HEDLEY_SUNPRO_VERSION_CHECK(8,0,0) || \ + (NLOHMANN_JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) && defined(__C99_PRAGMA_OPERATOR)) + #define NLOHMANN_JSON_HEDLEY_PRAGMA(value) _Pragma(#value) +#elif NLOHMANN_JSON_HEDLEY_MSVC_VERSION_CHECK(15,0,0) + #define NLOHMANN_JSON_HEDLEY_PRAGMA(value) __pragma(value) #else - #define HEDLEY_PRAGMA(value) + #define NLOHMANN_JSON_HEDLEY_PRAGMA(value) #endif -#if defined(HEDLEY_DIAGNOSTIC_PUSH) - #undef HEDLEY_DIAGNOSTIC_PUSH +#if defined(NLOHMANN_JSON_HEDLEY_DIAGNOSTIC_PUSH) + #undef NLOHMANN_JSON_HEDLEY_DIAGNOSTIC_PUSH #endif -#if defined(HEDLEY_DIAGNOSTIC_POP) - #undef HEDLEY_DIAGNOSTIC_POP +#if defined(NLOHMANN_JSON_HEDLEY_DIAGNOSTIC_POP) + #undef NLOHMANN_JSON_HEDLEY_DIAGNOSTIC_POP #endif #if defined(__clang__) - #define HEDLEY_DIAGNOSTIC_PUSH _Pragma("clang diagnostic push") - #define HEDLEY_DIAGNOSTIC_POP _Pragma("clang diagnostic pop") -#elif HEDLEY_INTEL_VERSION_CHECK(13,0,0) - #define HEDLEY_DIAGNOSTIC_PUSH _Pragma("warning(push)") - #define HEDLEY_DIAGNOSTIC_POP _Pragma("warning(pop)") -#elif HEDLEY_GCC_VERSION_CHECK(4,6,0) - #define HEDLEY_DIAGNOSTIC_PUSH _Pragma("GCC diagnostic push") - #define HEDLEY_DIAGNOSTIC_POP _Pragma("GCC diagnostic pop") -#elif HEDLEY_MSVC_VERSION_CHECK(15,0,0) - #define HEDLEY_DIAGNOSTIC_PUSH __pragma(warning(push)) - #define HEDLEY_DIAGNOSTIC_POP __pragma(warning(pop)) -#elif HEDLEY_ARM_VERSION_CHECK(5,6,0) - #define HEDLEY_DIAGNOSTIC_PUSH _Pragma("push") - #define HEDLEY_DIAGNOSTIC_POP _Pragma("pop") -#elif HEDLEY_TI_VERSION_CHECK(8,1,0) - #define HEDLEY_DIAGNOSTIC_PUSH _Pragma("diag_push") - #define HEDLEY_DIAGNOSTIC_POP _Pragma("diag_pop") -#elif HEDLEY_PELLES_VERSION_CHECK(2,90,0) - #define HEDLEY_DIAGNOSTIC_PUSH _Pragma("warning(push)") - #define HEDLEY_DIAGNOSTIC_POP _Pragma("warning(pop)") + #define NLOHMANN_JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("clang diagnostic push") + #define NLOHMANN_JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("clang diagnostic pop") +#elif NLOHMANN_JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) + #define NLOHMANN_JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("warning(push)") + #define NLOHMANN_JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("warning(pop)") +#elif NLOHMANN_JSON_HEDLEY_GCC_VERSION_CHECK(4,6,0) + #define NLOHMANN_JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("GCC diagnostic push") + #define NLOHMANN_JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("GCC diagnostic pop") +#elif NLOHMANN_JSON_HEDLEY_MSVC_VERSION_CHECK(15,0,0) + #define NLOHMANN_JSON_HEDLEY_DIAGNOSTIC_PUSH __pragma(warning(push)) + #define NLOHMANN_JSON_HEDLEY_DIAGNOSTIC_POP __pragma(warning(pop)) +#elif NLOHMANN_JSON_HEDLEY_ARM_VERSION_CHECK(5,6,0) + #define NLOHMANN_JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("push") + #define NLOHMANN_JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("pop") +#elif NLOHMANN_JSON_HEDLEY_TI_VERSION_CHECK(8,1,0) + #define NLOHMANN_JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("diag_push") + #define NLOHMANN_JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("diag_pop") +#elif NLOHMANN_JSON_HEDLEY_PELLES_VERSION_CHECK(2,90,0) + #define NLOHMANN_JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("warning(push)") + #define NLOHMANN_JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("warning(pop)") #else - #define HEDLEY_DIAGNOSTIC_PUSH - #define HEDLEY_DIAGNOSTIC_POP + #define NLOHMANN_JSON_HEDLEY_DIAGNOSTIC_PUSH + #define NLOHMANN_JSON_HEDLEY_DIAGNOSTIC_POP #endif -#if defined(HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED) - #undef HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED +#if defined(NLOHMANN_JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED) + #undef NLOHMANN_JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED #endif -#if HEDLEY_HAS_WARNING("-Wdeprecated-declarations") - #define HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("clang diagnostic ignored \"-Wdeprecated-declarations\"") -#elif HEDLEY_INTEL_VERSION_CHECK(13,0,0) - #define HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("warning(disable:1478 1786)") -#elif HEDLEY_PGI_VERSION_CHECK(17,10,0) - #define HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("diag_suppress 1215,1444") -#elif HEDLEY_GCC_VERSION_CHECK(4,3,0) - #define HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"") -#elif HEDLEY_MSVC_VERSION_CHECK(15,0,0) - #define HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED __pragma(warning(disable:4996)) -#elif HEDLEY_TI_VERSION_CHECK(8,0,0) - #define HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("diag_suppress 1291,1718") -#elif HEDLEY_SUNPRO_VERSION_CHECK(5,13,0) && !defined(__cplusplus) - #define HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("error_messages(off,E_DEPRECATED_ATT,E_DEPRECATED_ATT_MESS)") -#elif HEDLEY_SUNPRO_VERSION_CHECK(5,13,0) && defined(__cplusplus) - #define HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("error_messages(off,symdeprecated,symdeprecated2)") -#elif HEDLEY_IAR_VERSION_CHECK(8,0,0) - #define HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("diag_suppress=Pe1444,Pe1215") -#elif HEDLEY_PELLES_VERSION_CHECK(2,90,0) - #define HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("warn(disable:2241)") +#if NLOHMANN_JSON_HEDLEY_HAS_WARNING("-Wdeprecated-declarations") + #define NLOHMANN_JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("clang diagnostic ignored \"-Wdeprecated-declarations\"") +#elif NLOHMANN_JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) + #define NLOHMANN_JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("warning(disable:1478 1786)") +#elif NLOHMANN_JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) + #define NLOHMANN_JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("diag_suppress 1215,1444") +#elif NLOHMANN_JSON_HEDLEY_GCC_VERSION_CHECK(4,3,0) + #define NLOHMANN_JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"") +#elif NLOHMANN_JSON_HEDLEY_MSVC_VERSION_CHECK(15,0,0) + #define NLOHMANN_JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED __pragma(warning(disable:4996)) +#elif NLOHMANN_JSON_HEDLEY_TI_VERSION_CHECK(8,0,0) + #define NLOHMANN_JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("diag_suppress 1291,1718") +#elif NLOHMANN_JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,13,0) && !defined(__cplusplus) + #define NLOHMANN_JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("error_messages(off,E_DEPRECATED_ATT,E_DEPRECATED_ATT_MESS)") +#elif NLOHMANN_JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,13,0) && defined(__cplusplus) + #define NLOHMANN_JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("error_messages(off,symdeprecated,symdeprecated2)") +#elif NLOHMANN_JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0) + #define NLOHMANN_JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("diag_suppress=Pe1444,Pe1215") +#elif NLOHMANN_JSON_HEDLEY_PELLES_VERSION_CHECK(2,90,0) + #define NLOHMANN_JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("warn(disable:2241)") #else - #define HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED + #define NLOHMANN_JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED #endif -#if defined(HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS) - #undef HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS +#if defined(NLOHMANN_JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS) + #undef NLOHMANN_JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS #endif -#if HEDLEY_HAS_WARNING("-Wunknown-pragmas") - #define HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("clang diagnostic ignored \"-Wunknown-pragmas\"") -#elif HEDLEY_INTEL_VERSION_CHECK(13,0,0) - #define HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("warning(disable:161)") -#elif HEDLEY_PGI_VERSION_CHECK(17,10,0) - #define HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("diag_suppress 1675") -#elif HEDLEY_GCC_VERSION_CHECK(4,3,0) - #define HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("GCC diagnostic ignored \"-Wunknown-pragmas\"") -#elif HEDLEY_MSVC_VERSION_CHECK(15,0,0) - #define HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS __pragma(warning(disable:4068)) -#elif HEDLEY_TI_VERSION_CHECK(8,0,0) - #define HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("diag_suppress 163") -#elif HEDLEY_IAR_VERSION_CHECK(8,0,0) - #define HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("diag_suppress=Pe161") +#if NLOHMANN_JSON_HEDLEY_HAS_WARNING("-Wunknown-pragmas") + #define NLOHMANN_JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("clang diagnostic ignored \"-Wunknown-pragmas\"") +#elif NLOHMANN_JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) + #define NLOHMANN_JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("warning(disable:161)") +#elif NLOHMANN_JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) + #define NLOHMANN_JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("diag_suppress 1675") +#elif NLOHMANN_JSON_HEDLEY_GCC_VERSION_CHECK(4,3,0) + #define NLOHMANN_JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("GCC diagnostic ignored \"-Wunknown-pragmas\"") +#elif NLOHMANN_JSON_HEDLEY_MSVC_VERSION_CHECK(15,0,0) + #define NLOHMANN_JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS __pragma(warning(disable:4068)) +#elif NLOHMANN_JSON_HEDLEY_TI_VERSION_CHECK(8,0,0) + #define NLOHMANN_JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("diag_suppress 163") +#elif NLOHMANN_JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0) + #define NLOHMANN_JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("diag_suppress=Pe161") #else - #define HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS + #define NLOHMANN_JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS #endif -#if defined(HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL) - #undef HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL +#if defined(NLOHMANN_JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL) + #undef NLOHMANN_JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL #endif -#if HEDLEY_HAS_WARNING("-Wcast-qual") - #define HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL _Pragma("clang diagnostic ignored \"-Wcast-qual\"") -#elif HEDLEY_INTEL_VERSION_CHECK(13,0,0) - #define HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL _Pragma("warning(disable:2203 2331)") -#elif HEDLEY_GCC_VERSION_CHECK(3,0,0) - #define HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL _Pragma("GCC diagnostic ignored \"-Wcast-qual\"") +#if NLOHMANN_JSON_HEDLEY_HAS_WARNING("-Wcast-qual") + #define NLOHMANN_JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL _Pragma("clang diagnostic ignored \"-Wcast-qual\"") +#elif NLOHMANN_JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) + #define NLOHMANN_JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL _Pragma("warning(disable:2203 2331)") +#elif NLOHMANN_JSON_HEDLEY_GCC_VERSION_CHECK(3,0,0) + #define NLOHMANN_JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL _Pragma("GCC diagnostic ignored \"-Wcast-qual\"") #else - #define HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL + #define NLOHMANN_JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL #endif -#if defined(HEDLEY_DEPRECATED) - #undef HEDLEY_DEPRECATED +#if defined(NLOHMANN_JSON_HEDLEY_DEPRECATED) + #undef NLOHMANN_JSON_HEDLEY_DEPRECATED #endif -#if defined(HEDLEY_DEPRECATED_FOR) - #undef HEDLEY_DEPRECATED_FOR +#if defined(NLOHMANN_JSON_HEDLEY_DEPRECATED_FOR) + #undef NLOHMANN_JSON_HEDLEY_DEPRECATED_FOR #endif #if defined(__cplusplus) && (__cplusplus >= 201402L) - #define HEDLEY_DEPRECATED(since) [[deprecated("Since " #since)]] - #define HEDLEY_DEPRECATED_FOR(since, replacement) [[deprecated("Since " #since "; use " #replacement)]] + #define NLOHMANN_JSON_HEDLEY_DEPRECATED(since) [[deprecated("Since " #since)]] + #define NLOHMANN_JSON_HEDLEY_DEPRECATED_FOR(since, replacement) [[deprecated("Since " #since "; use " #replacement)]] #elif \ - HEDLEY_HAS_EXTENSION(attribute_deprecated_with_message) || \ - HEDLEY_GCC_VERSION_CHECK(4,5,0) || \ - HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ - HEDLEY_ARM_VERSION_CHECK(5,6,0) || \ - HEDLEY_SUNPRO_VERSION_CHECK(5,13,0) || \ - HEDLEY_PGI_VERSION_CHECK(17,10,0) || \ - HEDLEY_TI_VERSION_CHECK(8,3,0) - #define HEDLEY_DEPRECATED(since) __attribute__((__deprecated__("Since " #since))) - #define HEDLEY_DEPRECATED_FOR(since, replacement) __attribute__((__deprecated__("Since " #since "; use " #replacement))) + NLOHMANN_JSON_HEDLEY_HAS_EXTENSION(attribute_deprecated_with_message) || \ + NLOHMANN_JSON_HEDLEY_GCC_VERSION_CHECK(4,5,0) || \ + NLOHMANN_JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ + NLOHMANN_JSON_HEDLEY_ARM_VERSION_CHECK(5,6,0) || \ + NLOHMANN_JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,13,0) || \ + NLOHMANN_JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) || \ + NLOHMANN_JSON_HEDLEY_TI_VERSION_CHECK(8,3,0) + #define NLOHMANN_JSON_HEDLEY_DEPRECATED(since) __attribute__((__deprecated__("Since " #since))) + #define NLOHMANN_JSON_HEDLEY_DEPRECATED_FOR(since, replacement) __attribute__((__deprecated__("Since " #since "; use " #replacement))) #elif \ - HEDLEY_HAS_ATTRIBUTE(deprecated) || \ - HEDLEY_GCC_VERSION_CHECK(3,1,0) || \ - HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ - HEDLEY_TI_VERSION_CHECK(8,0,0) || \ - (HEDLEY_TI_VERSION_CHECK(7,3,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) - #define HEDLEY_DEPRECATED(since) __attribute__((__deprecated__)) - #define HEDLEY_DEPRECATED_FOR(since, replacement) __attribute__((__deprecated__)) -#elif HEDLEY_MSVC_VERSION_CHECK(14,0,0) - #define HEDLEY_DEPRECATED(since) __declspec(deprecated("Since " # since)) - #define HEDLEY_DEPRECATED_FOR(since, replacement) __declspec(deprecated("Since " #since "; use " #replacement)) + NLOHMANN_JSON_HEDLEY_HAS_ATTRIBUTE(deprecated) || \ + NLOHMANN_JSON_HEDLEY_GCC_VERSION_CHECK(3,1,0) || \ + NLOHMANN_JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ + NLOHMANN_JSON_HEDLEY_TI_VERSION_CHECK(8,0,0) || \ + (NLOHMANN_JSON_HEDLEY_TI_VERSION_CHECK(7,3,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) + #define NLOHMANN_JSON_HEDLEY_DEPRECATED(since) __attribute__((__deprecated__)) + #define NLOHMANN_JSON_HEDLEY_DEPRECATED_FOR(since, replacement) __attribute__((__deprecated__)) +#elif NLOHMANN_JSON_HEDLEY_MSVC_VERSION_CHECK(14,0,0) + #define NLOHMANN_JSON_HEDLEY_DEPRECATED(since) __declspec(deprecated("Since " # since)) + #define NLOHMANN_JSON_HEDLEY_DEPRECATED_FOR(since, replacement) __declspec(deprecated("Since " #since "; use " #replacement)) #elif \ - HEDLEY_MSVC_VERSION_CHECK(13,10,0) || \ - HEDLEY_PELLES_VERSION_CHECK(6,50,0) - #define HEDLEY_DEPRECATED(since) _declspec(deprecated) - #define HEDLEY_DEPRECATED_FOR(since, replacement) __declspec(deprecated) -#elif HEDLEY_IAR_VERSION_CHECK(8,0,0) - #define HEDLEY_DEPRECATED(since) _Pragma("deprecated") - #define HEDLEY_DEPRECATED_FOR(since, replacement) _Pragma("deprecated") + NLOHMANN_JSON_HEDLEY_MSVC_VERSION_CHECK(13,10,0) || \ + NLOHMANN_JSON_HEDLEY_PELLES_VERSION_CHECK(6,50,0) + #define NLOHMANN_JSON_HEDLEY_DEPRECATED(since) _declspec(deprecated) + #define NLOHMANN_JSON_HEDLEY_DEPRECATED_FOR(since, replacement) __declspec(deprecated) +#elif NLOHMANN_JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0) + #define NLOHMANN_JSON_HEDLEY_DEPRECATED(since) _Pragma("deprecated") + #define NLOHMANN_JSON_HEDLEY_DEPRECATED_FOR(since, replacement) _Pragma("deprecated") #else - #define HEDLEY_DEPRECATED(since) - #define HEDLEY_DEPRECATED_FOR(since, replacement) + #define NLOHMANN_JSON_HEDLEY_DEPRECATED(since) + #define NLOHMANN_JSON_HEDLEY_DEPRECATED_FOR(since, replacement) #endif -#if defined(HEDLEY_UNAVAILABLE) - #undef HEDLEY_UNAVAILABLE +#if defined(NLOHMANN_JSON_HEDLEY_UNAVAILABLE) + #undef NLOHMANN_JSON_HEDLEY_UNAVAILABLE #endif #if \ - HEDLEY_HAS_ATTRIBUTE(warning) || \ - HEDLEY_GCC_VERSION_CHECK(4,3,0) || \ - HEDLEY_INTEL_VERSION_CHECK(13,0,0) - #define HEDLEY_UNAVAILABLE(available_since) __attribute__((__warning__("Not available until " #available_since))) + NLOHMANN_JSON_HEDLEY_HAS_ATTRIBUTE(warning) || \ + NLOHMANN_JSON_HEDLEY_GCC_VERSION_CHECK(4,3,0) || \ + NLOHMANN_JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) + #define NLOHMANN_JSON_HEDLEY_UNAVAILABLE(available_since) __attribute__((__warning__("Not available until " #available_since))) #else - #define HEDLEY_UNAVAILABLE(available_since) + #define NLOHMANN_JSON_HEDLEY_UNAVAILABLE(available_since) #endif -#if defined(HEDLEY_WARN_UNUSED_RESULT) - #undef HEDLEY_WARN_UNUSED_RESULT +#if defined(NLOHMANN_JSON_HEDLEY_WARN_UNUSED_RESULT) + #undef NLOHMANN_JSON_HEDLEY_WARN_UNUSED_RESULT #endif #if defined(__cplusplus) && (__cplusplus >= 201703L) - #define HEDLEY_WARN_UNUSED_RESULT [[nodiscard]] + #define NLOHMANN_JSON_HEDLEY_WARN_UNUSED_RESULT [[nodiscard]] #elif \ - HEDLEY_HAS_ATTRIBUTE(warn_unused_result) || \ - HEDLEY_GCC_VERSION_CHECK(3,4,0) || \ - HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ - HEDLEY_TI_VERSION_CHECK(8,0,0) || \ - (HEDLEY_TI_VERSION_CHECK(7,3,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ - (HEDLEY_SUNPRO_VERSION_CHECK(5,15,0) && defined(__cplusplus)) || \ - HEDLEY_PGI_VERSION_CHECK(17,10,0) - #define HEDLEY_WARN_UNUSED_RESULT __attribute__((__warn_unused_result__)) + NLOHMANN_JSON_HEDLEY_HAS_ATTRIBUTE(warn_unused_result) || \ + NLOHMANN_JSON_HEDLEY_GCC_VERSION_CHECK(3,4,0) || \ + NLOHMANN_JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ + NLOHMANN_JSON_HEDLEY_TI_VERSION_CHECK(8,0,0) || \ + (NLOHMANN_JSON_HEDLEY_TI_VERSION_CHECK(7,3,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ + (NLOHMANN_JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,15,0) && defined(__cplusplus)) || \ + NLOHMANN_JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) + #define NLOHMANN_JSON_HEDLEY_WARN_UNUSED_RESULT __attribute__((__warn_unused_result__)) #elif defined(_Check_return_) /* SAL */ - #define HEDLEY_WARN_UNUSED_RESULT _Check_return_ + #define NLOHMANN_JSON_HEDLEY_WARN_UNUSED_RESULT _Check_return_ #else - #define HEDLEY_WARN_UNUSED_RESULT + #define NLOHMANN_JSON_HEDLEY_WARN_UNUSED_RESULT #endif -#if defined(HEDLEY_SENTINEL) - #undef HEDLEY_SENTINEL +#if defined(NLOHMANN_JSON_HEDLEY_SENTINEL) + #undef NLOHMANN_JSON_HEDLEY_SENTINEL #endif #if \ - HEDLEY_HAS_ATTRIBUTE(sentinel) || \ - HEDLEY_GCC_VERSION_CHECK(4,0,0) || \ - HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ - HEDLEY_ARM_VERSION_CHECK(5,4,0) - #define HEDLEY_SENTINEL(position) __attribute__((__sentinel__(position))) + NLOHMANN_JSON_HEDLEY_HAS_ATTRIBUTE(sentinel) || \ + NLOHMANN_JSON_HEDLEY_GCC_VERSION_CHECK(4,0,0) || \ + NLOHMANN_JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ + NLOHMANN_JSON_HEDLEY_ARM_VERSION_CHECK(5,4,0) + #define NLOHMANN_JSON_HEDLEY_SENTINEL(position) __attribute__((__sentinel__(position))) #else - #define HEDLEY_SENTINEL(position) + #define NLOHMANN_JSON_HEDLEY_SENTINEL(position) #endif -#if defined(HEDLEY_NO_RETURN) - #undef HEDLEY_NO_RETURN +#if defined(NLOHMANN_JSON_HEDLEY_NO_RETURN) + #undef NLOHMANN_JSON_HEDLEY_NO_RETURN #endif -#if HEDLEY_IAR_VERSION_CHECK(8,0,0) - #define HEDLEY_NO_RETURN __noreturn -#elif HEDLEY_INTEL_VERSION_CHECK(13,0,0) - #define HEDLEY_NO_RETURN __attribute__((__noreturn__)) +#if NLOHMANN_JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0) + #define NLOHMANN_JSON_HEDLEY_NO_RETURN __noreturn +#elif NLOHMANN_JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) + #define NLOHMANN_JSON_HEDLEY_NO_RETURN __attribute__((__noreturn__)) #elif defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L - #define HEDLEY_NO_RETURN _Noreturn + #define NLOHMANN_JSON_HEDLEY_NO_RETURN _Noreturn #elif defined(__cplusplus) && (__cplusplus >= 201103L) - #define HEDLEY_NO_RETURN [[noreturn]] + #define NLOHMANN_JSON_HEDLEY_NO_RETURN [[noreturn]] #elif \ - HEDLEY_HAS_ATTRIBUTE(noreturn) || \ - HEDLEY_GCC_VERSION_CHECK(3,2,0) || \ - HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \ - HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ - HEDLEY_IBM_VERSION_CHECK(10,1,0) || \ - HEDLEY_TI_VERSION_CHECK(18,0,0) || \ - (HEDLEY_TI_VERSION_CHECK(17,3,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) - #define HEDLEY_NO_RETURN __attribute__((__noreturn__)) -#elif HEDLEY_MSVC_VERSION_CHECK(13,10,0) - #define HEDLEY_NO_RETURN __declspec(noreturn) -#elif HEDLEY_TI_VERSION_CHECK(6,0,0) && defined(__cplusplus) - #define HEDLEY_NO_RETURN _Pragma("FUNC_NEVER_RETURNS;") -#elif HEDLEY_COMPCERT_VERSION_CHECK(3,2,0) - #define HEDLEY_NO_RETURN __attribute((noreturn)) -#elif HEDLEY_PELLES_VERSION_CHECK(9,0,0) - #define HEDLEY_NO_RETURN __declspec(noreturn) + NLOHMANN_JSON_HEDLEY_HAS_ATTRIBUTE(noreturn) || \ + NLOHMANN_JSON_HEDLEY_GCC_VERSION_CHECK(3,2,0) || \ + NLOHMANN_JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \ + NLOHMANN_JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ + NLOHMANN_JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \ + NLOHMANN_JSON_HEDLEY_TI_VERSION_CHECK(18,0,0) || \ + (NLOHMANN_JSON_HEDLEY_TI_VERSION_CHECK(17,3,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) + #define NLOHMANN_JSON_HEDLEY_NO_RETURN __attribute__((__noreturn__)) +#elif NLOHMANN_JSON_HEDLEY_MSVC_VERSION_CHECK(13,10,0) + #define NLOHMANN_JSON_HEDLEY_NO_RETURN __declspec(noreturn) +#elif NLOHMANN_JSON_HEDLEY_TI_VERSION_CHECK(6,0,0) && defined(__cplusplus) + #define NLOHMANN_JSON_HEDLEY_NO_RETURN _Pragma("FUNC_NEVER_RETURNS;") +#elif NLOHMANN_JSON_HEDLEY_COMPCERT_VERSION_CHECK(3,2,0) + #define NLOHMANN_JSON_HEDLEY_NO_RETURN __attribute((noreturn)) +#elif NLOHMANN_JSON_HEDLEY_PELLES_VERSION_CHECK(9,0,0) + #define NLOHMANN_JSON_HEDLEY_NO_RETURN __declspec(noreturn) #else - #define HEDLEY_NO_RETURN + #define NLOHMANN_JSON_HEDLEY_NO_RETURN #endif -#if defined(HEDLEY_UNREACHABLE) - #undef HEDLEY_UNREACHABLE +#if defined(NLOHMANN_JSON_HEDLEY_UNREACHABLE) + #undef NLOHMANN_JSON_HEDLEY_UNREACHABLE #endif -#if defined(HEDLEY_UNREACHABLE_RETURN) - #undef HEDLEY_UNREACHABLE_RETURN +#if defined(NLOHMANN_JSON_HEDLEY_UNREACHABLE_RETURN) + #undef NLOHMANN_JSON_HEDLEY_UNREACHABLE_RETURN #endif #if \ - (HEDLEY_HAS_BUILTIN(__builtin_unreachable) && (!defined(HEDLEY_ARM_VERSION))) || \ - HEDLEY_GCC_VERSION_CHECK(4,5,0) || \ - HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ - HEDLEY_IBM_VERSION_CHECK(13,1,5) - #define HEDLEY_UNREACHABLE() __builtin_unreachable() -#elif HEDLEY_MSVC_VERSION_CHECK(13,10,0) - #define HEDLEY_UNREACHABLE() __assume(0) -#elif HEDLEY_TI_VERSION_CHECK(6,0,0) + (NLOHMANN_JSON_HEDLEY_HAS_BUILTIN(__builtin_unreachable) && (!defined(NLOHMANN_JSON_HEDLEY_ARM_VERSION))) || \ + NLOHMANN_JSON_HEDLEY_GCC_VERSION_CHECK(4,5,0) || \ + NLOHMANN_JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ + NLOHMANN_JSON_HEDLEY_IBM_VERSION_CHECK(13,1,5) + #define NLOHMANN_JSON_HEDLEY_UNREACHABLE() __builtin_unreachable() +#elif NLOHMANN_JSON_HEDLEY_MSVC_VERSION_CHECK(13,10,0) + #define NLOHMANN_JSON_HEDLEY_UNREACHABLE() __assume(0) +#elif NLOHMANN_JSON_HEDLEY_TI_VERSION_CHECK(6,0,0) #if defined(__cplusplus) - #define HEDLEY_UNREACHABLE() std::_nassert(0) + #define NLOHMANN_JSON_HEDLEY_UNREACHABLE() std::_nassert(0) #else - #define HEDLEY_UNREACHABLE() _nassert(0) + #define NLOHMANN_JSON_HEDLEY_UNREACHABLE() _nassert(0) #endif - #define HEDLEY_UNREACHABLE_RETURN(value) return value + #define NLOHMANN_JSON_HEDLEY_UNREACHABLE_RETURN(value) return value #elif defined(EXIT_FAILURE) - #define HEDLEY_UNREACHABLE() abort() + #define NLOHMANN_JSON_HEDLEY_UNREACHABLE() abort() #else - #define HEDLEY_UNREACHABLE() - #define HEDLEY_UNREACHABLE_RETURN(value) return value + #define NLOHMANN_JSON_HEDLEY_UNREACHABLE() + #define NLOHMANN_JSON_HEDLEY_UNREACHABLE_RETURN(value) return value #endif -#if !defined(HEDLEY_UNREACHABLE_RETURN) - #define HEDLEY_UNREACHABLE_RETURN(value) HEDLEY_UNREACHABLE() +#if !defined(NLOHMANN_JSON_HEDLEY_UNREACHABLE_RETURN) + #define NLOHMANN_JSON_HEDLEY_UNREACHABLE_RETURN(value) NLOHMANN_JSON_HEDLEY_UNREACHABLE() #endif -#if defined(HEDLEY_ASSUME) - #undef HEDLEY_ASSUME +#if defined(NLOHMANN_JSON_HEDLEY_ASSUME) + #undef NLOHMANN_JSON_HEDLEY_ASSUME #endif #if \ - HEDLEY_MSVC_VERSION_CHECK(13,10,0) || \ - HEDLEY_INTEL_VERSION_CHECK(13,0,0) - #define HEDLEY_ASSUME(expr) __assume(expr) -#elif HEDLEY_HAS_BUILTIN(__builtin_assume) - #define HEDLEY_ASSUME(expr) __builtin_assume(expr) -#elif HEDLEY_TI_VERSION_CHECK(6,0,0) + NLOHMANN_JSON_HEDLEY_MSVC_VERSION_CHECK(13,10,0) || \ + NLOHMANN_JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) + #define NLOHMANN_JSON_HEDLEY_ASSUME(expr) __assume(expr) +#elif NLOHMANN_JSON_HEDLEY_HAS_BUILTIN(__builtin_assume) + #define NLOHMANN_JSON_HEDLEY_ASSUME(expr) __builtin_assume(expr) +#elif NLOHMANN_JSON_HEDLEY_TI_VERSION_CHECK(6,0,0) #if defined(__cplusplus) - #define HEDLEY_ASSUME(expr) std::_nassert(expr) + #define NLOHMANN_JSON_HEDLEY_ASSUME(expr) std::_nassert(expr) #else - #define HEDLEY_ASSUME(expr) _nassert(expr) + #define NLOHMANN_JSON_HEDLEY_ASSUME(expr) _nassert(expr) #endif #elif \ - (HEDLEY_HAS_BUILTIN(__builtin_unreachable) && !defined(HEDLEY_ARM_VERSION)) || \ - HEDLEY_GCC_VERSION_CHECK(4,5,0) || \ - HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ - HEDLEY_IBM_VERSION_CHECK(13,1,5) - #define HEDLEY_ASSUME(expr) ((void) ((expr) ? 1 : (__builtin_unreachable(), 1))) + (NLOHMANN_JSON_HEDLEY_HAS_BUILTIN(__builtin_unreachable) && !defined(NLOHMANN_JSON_HEDLEY_ARM_VERSION)) || \ + NLOHMANN_JSON_HEDLEY_GCC_VERSION_CHECK(4,5,0) || \ + NLOHMANN_JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ + NLOHMANN_JSON_HEDLEY_IBM_VERSION_CHECK(13,1,5) + #define NLOHMANN_JSON_HEDLEY_ASSUME(expr) ((void) ((expr) ? 1 : (__builtin_unreachable(), 1))) #else - #define HEDLEY_ASSUME(expr) ((void) (expr)) + #define NLOHMANN_JSON_HEDLEY_ASSUME(expr) ((void) (expr)) #endif -HEDLEY_DIAGNOSTIC_PUSH +NLOHMANN_JSON_HEDLEY_DIAGNOSTIC_PUSH #if \ - HEDLEY_HAS_WARNING("-Wvariadic-macros") || \ - HEDLEY_GCC_VERSION_CHECK(4,0,0) + NLOHMANN_JSON_HEDLEY_HAS_WARNING("-Wvariadic-macros") || \ + NLOHMANN_JSON_HEDLEY_GCC_VERSION_CHECK(4,0,0) #if defined(__clang__) #pragma clang diagnostic ignored "-Wvariadic-macros" - #elif defined(HEDLEY_GCC_VERSION) + #elif defined(NLOHMANN_JSON_HEDLEY_GCC_VERSION) #pragma GCC diagnostic ignored "-Wvariadic-macros" #endif #endif -#if defined(HEDLEY_NON_NULL) - #undef HEDLEY_NON_NULL +#if defined(NLOHMANN_JSON_HEDLEY_NON_NULL) + #undef NLOHMANN_JSON_HEDLEY_NON_NULL #endif #if \ - HEDLEY_HAS_ATTRIBUTE(nonnull) || \ - HEDLEY_GCC_VERSION_CHECK(3,3,0) || \ - HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ - HEDLEY_ARM_VERSION_CHECK(4,1,0) - #define HEDLEY_NON_NULL(...) __attribute__((__nonnull__(__VA_ARGS__))) + NLOHMANN_JSON_HEDLEY_HAS_ATTRIBUTE(nonnull) || \ + NLOHMANN_JSON_HEDLEY_GCC_VERSION_CHECK(3,3,0) || \ + NLOHMANN_JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ + NLOHMANN_JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) + #define NLOHMANN_JSON_HEDLEY_NON_NULL(...) __attribute__((__nonnull__(__VA_ARGS__))) #else - #define HEDLEY_NON_NULL(...) + #define NLOHMANN_JSON_HEDLEY_NON_NULL(...) #endif -HEDLEY_DIAGNOSTIC_POP +NLOHMANN_JSON_HEDLEY_DIAGNOSTIC_POP -#if defined(HEDLEY_PRINTF_FORMAT) - #undef HEDLEY_PRINTF_FORMAT +#if defined(NLOHMANN_JSON_HEDLEY_PRINTF_FORMAT) + #undef NLOHMANN_JSON_HEDLEY_PRINTF_FORMAT #endif -#if defined(__MINGW32__) && HEDLEY_GCC_HAS_ATTRIBUTE(format,4,4,0) && !defined(__USE_MINGW_ANSI_STDIO) - #define HEDLEY_PRINTF_FORMAT(string_idx,first_to_check) __attribute__((__format__(ms_printf, string_idx, first_to_check))) -#elif defined(__MINGW32__) && HEDLEY_GCC_HAS_ATTRIBUTE(format,4,4,0) && defined(__USE_MINGW_ANSI_STDIO) - #define HEDLEY_PRINTF_FORMAT(string_idx,first_to_check) __attribute__((__format__(gnu_printf, string_idx, first_to_check))) +#if defined(__MINGW32__) && NLOHMANN_JSON_HEDLEY_GCC_HAS_ATTRIBUTE(format,4,4,0) && !defined(__USE_MINGW_ANSI_STDIO) + #define NLOHMANN_JSON_HEDLEY_PRINTF_FORMAT(string_idx,first_to_check) __attribute__((__format__(ms_printf, string_idx, first_to_check))) +#elif defined(__MINGW32__) && NLOHMANN_JSON_HEDLEY_GCC_HAS_ATTRIBUTE(format,4,4,0) && defined(__USE_MINGW_ANSI_STDIO) + #define NLOHMANN_JSON_HEDLEY_PRINTF_FORMAT(string_idx,first_to_check) __attribute__((__format__(gnu_printf, string_idx, first_to_check))) #elif \ - HEDLEY_HAS_ATTRIBUTE(format) || \ - HEDLEY_GCC_VERSION_CHECK(3,1,0) || \ - HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ - HEDLEY_ARM_VERSION_CHECK(5,6,0) || \ - HEDLEY_IBM_VERSION_CHECK(10,1,0) || \ - HEDLEY_TI_VERSION_CHECK(8,0,0) || \ - (HEDLEY_TI_VERSION_CHECK(7,3,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) - #define HEDLEY_PRINTF_FORMAT(string_idx,first_to_check) __attribute__((__format__(__printf__, string_idx, first_to_check))) -#elif HEDLEY_PELLES_VERSION_CHECK(6,0,0) - #define HEDLEY_PRINTF_FORMAT(string_idx,first_to_check) __declspec(vaformat(printf,string_idx,first_to_check)) + NLOHMANN_JSON_HEDLEY_HAS_ATTRIBUTE(format) || \ + NLOHMANN_JSON_HEDLEY_GCC_VERSION_CHECK(3,1,0) || \ + NLOHMANN_JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ + NLOHMANN_JSON_HEDLEY_ARM_VERSION_CHECK(5,6,0) || \ + NLOHMANN_JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \ + NLOHMANN_JSON_HEDLEY_TI_VERSION_CHECK(8,0,0) || \ + (NLOHMANN_JSON_HEDLEY_TI_VERSION_CHECK(7,3,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) + #define NLOHMANN_JSON_HEDLEY_PRINTF_FORMAT(string_idx,first_to_check) __attribute__((__format__(__printf__, string_idx, first_to_check))) +#elif NLOHMANN_JSON_HEDLEY_PELLES_VERSION_CHECK(6,0,0) + #define NLOHMANN_JSON_HEDLEY_PRINTF_FORMAT(string_idx,first_to_check) __declspec(vaformat(printf,string_idx,first_to_check)) #else - #define HEDLEY_PRINTF_FORMAT(string_idx,first_to_check) + #define NLOHMANN_JSON_HEDLEY_PRINTF_FORMAT(string_idx,first_to_check) #endif -#if defined(HEDLEY_CONSTEXPR) - #undef HEDLEY_CONSTEXPR +#if defined(NLOHMANN_JSON_HEDLEY_CONSTEXPR) + #undef NLOHMANN_JSON_HEDLEY_CONSTEXPR #endif #if defined(__cplusplus) #if __cplusplus >= 201103L - #define HEDLEY_CONSTEXPR constexpr + #define NLOHMANN_JSON_HEDLEY_CONSTEXPR constexpr #endif #endif -#if !defined(HEDLEY_CONSTEXPR) - #define HEDLEY_CONSTEXPR +#if !defined(NLOHMANN_JSON_HEDLEY_CONSTEXPR) + #define NLOHMANN_JSON_HEDLEY_CONSTEXPR #endif -#if defined(HEDLEY_PREDICT) - #undef HEDLEY_PREDICT +#if defined(NLOHMANN_JSON_HEDLEY_PREDICT) + #undef NLOHMANN_JSON_HEDLEY_PREDICT #endif -#if defined(HEDLEY_LIKELY) - #undef HEDLEY_LIKELY +#if defined(NLOHMANN_JSON_HEDLEY_LIKELY) + #undef NLOHMANN_JSON_HEDLEY_LIKELY #endif -#if defined(HEDLEY_UNLIKELY) - #undef HEDLEY_UNLIKELY +#if defined(NLOHMANN_JSON_HEDLEY_UNLIKELY) + #undef NLOHMANN_JSON_HEDLEY_UNLIKELY #endif -#if defined(HEDLEY_UNPREDICTABLE) - #undef HEDLEY_UNPREDICTABLE +#if defined(NLOHMANN_JSON_HEDLEY_UNPREDICTABLE) + #undef NLOHMANN_JSON_HEDLEY_UNPREDICTABLE #endif -#if HEDLEY_HAS_BUILTIN(__builtin_unpredictable) - #define HEDLEY_UNPREDICTABLE(expr) __builtin_unpredictable(!!(expr)) +#if NLOHMANN_JSON_HEDLEY_HAS_BUILTIN(__builtin_unpredictable) + #define NLOHMANN_JSON_HEDLEY_UNPREDICTABLE(expr) __builtin_unpredictable(!!(expr)) #endif #if \ - HEDLEY_HAS_BUILTIN(__builtin_expect_with_probability) || \ - HEDLEY_GCC_VERSION_CHECK(9,0,0) -# define HEDLEY_PREDICT(expr, value, probability) __builtin_expect_with_probability(expr, value, probability) -# define HEDLEY_PREDICT_TRUE(expr, probability) __builtin_expect_with_probability(!!(expr), 1, probability) -# define HEDLEY_PREDICT_FALSE(expr, probability) __builtin_expect_with_probability(!!(expr), 0, probability) -# define HEDLEY_LIKELY(expr) __builtin_expect(!!(expr), 1) -# define HEDLEY_UNLIKELY(expr) __builtin_expect(!!(expr), 0) -#if !defined(HEDLEY_BUILTIN_UNPREDICTABLE) - #define HEDLEY_BUILTIN_UNPREDICTABLE(expr) __builtin_expect_with_probability(!!(expr), 1, 0.5) + NLOHMANN_JSON_HEDLEY_HAS_BUILTIN(__builtin_expect_with_probability) || \ + NLOHMANN_JSON_HEDLEY_GCC_VERSION_CHECK(9,0,0) +# define NLOHMANN_JSON_HEDLEY_PREDICT(expr, value, probability) __builtin_expect_with_probability(expr, value, probability) +# define NLOHMANN_JSON_HEDLEY_PREDICT_TRUE(expr, probability) __builtin_expect_with_probability(!!(expr), 1, probability) +# define NLOHMANN_JSON_HEDLEY_PREDICT_FALSE(expr, probability) __builtin_expect_with_probability(!!(expr), 0, probability) +# define NLOHMANN_JSON_HEDLEY_LIKELY(expr) __builtin_expect(!!(expr), 1) +# define NLOHMANN_JSON_HEDLEY_UNLIKELY(expr) __builtin_expect(!!(expr), 0) +#if !defined(NLOHMANN_JSON_HEDLEY_BUILTIN_UNPREDICTABLE) + #define NLOHMANN_JSON_HEDLEY_BUILTIN_UNPREDICTABLE(expr) __builtin_expect_with_probability(!!(expr), 1, 0.5) #endif #elif \ - HEDLEY_HAS_BUILTIN(__builtin_expect) || \ - HEDLEY_GCC_VERSION_CHECK(3,0,0) || \ - HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ - (HEDLEY_SUNPRO_VERSION_CHECK(5,15,0) && defined(__cplusplus)) || \ - HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ - HEDLEY_IBM_VERSION_CHECK(10,1,0) || \ - HEDLEY_TI_VERSION_CHECK(6,1,0) || \ - HEDLEY_TINYC_VERSION_CHECK(0,9,27) -# define HEDLEY_PREDICT(expr, expected, probability) \ + NLOHMANN_JSON_HEDLEY_HAS_BUILTIN(__builtin_expect) || \ + NLOHMANN_JSON_HEDLEY_GCC_VERSION_CHECK(3,0,0) || \ + NLOHMANN_JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ + (NLOHMANN_JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,15,0) && defined(__cplusplus)) || \ + NLOHMANN_JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ + NLOHMANN_JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \ + NLOHMANN_JSON_HEDLEY_TI_VERSION_CHECK(6,1,0) || \ + NLOHMANN_JSON_HEDLEY_TINYC_VERSION_CHECK(0,9,27) +# define NLOHMANN_JSON_HEDLEY_PREDICT(expr, expected, probability) \ (((probability) >= 0.9) ? __builtin_expect(!!(expr), (expected)) : (((void) (expected)), !!(expr))) -# define HEDLEY_PREDICT_TRUE(expr, probability) \ +# define NLOHMANN_JSON_HEDLEY_PREDICT_TRUE(expr, probability) \ (__extension__ ({ \ - HEDLEY_CONSTEXPR double hedley_probability_ = (probability); \ + NLOHMANN_JSON_HEDLEY_CONSTEXPR double hedley_probability_ = (probability); \ ((hedley_probability_ >= 0.9) ? __builtin_expect(!!(expr), 1) : ((hedley_probability_ <= 0.1) ? __builtin_expect(!!(expr), 0) : !!(expr))); \ })) -# define HEDLEY_PREDICT_FALSE(expr, probability) \ +# define NLOHMANN_JSON_HEDLEY_PREDICT_FALSE(expr, probability) \ (__extension__ ({ \ - HEDLEY_CONSTEXPR double hedley_probability_ = (probability); \ + NLOHMANN_JSON_HEDLEY_CONSTEXPR double hedley_probability_ = (probability); \ ((hedley_probability_ >= 0.9) ? __builtin_expect(!!(expr), 0) : ((hedley_probability_ <= 0.1) ? __builtin_expect(!!(expr), 1) : !!(expr))); \ })) -# define HEDLEY_LIKELY(expr) __builtin_expect(!!(expr), 1) -# define HEDLEY_UNLIKELY(expr) __builtin_expect(!!(expr), 0) +# define NLOHMANN_JSON_HEDLEY_LIKELY(expr) __builtin_expect(!!(expr), 1) +# define NLOHMANN_JSON_HEDLEY_UNLIKELY(expr) __builtin_expect(!!(expr), 0) #else -# define HEDLEY_PREDICT(expr, expected, probability) (((void) (expected)), !!(expr)) -# define HEDLEY_PREDICT_TRUE(expr, probability) (!!(expr)) -# define HEDLEY_PREDICT_FALSE(expr, probability) (!!(expr)) -# define HEDLEY_LIKELY(expr) (!!(expr)) -# define HEDLEY_UNLIKELY(expr) (!!(expr)) +# define NLOHMANN_JSON_HEDLEY_PREDICT(expr, expected, probability) (((void) (expected)), !!(expr)) +# define NLOHMANN_JSON_HEDLEY_PREDICT_TRUE(expr, probability) (!!(expr)) +# define NLOHMANN_JSON_HEDLEY_PREDICT_FALSE(expr, probability) (!!(expr)) +# define NLOHMANN_JSON_HEDLEY_LIKELY(expr) (!!(expr)) +# define NLOHMANN_JSON_HEDLEY_UNLIKELY(expr) (!!(expr)) #endif -#if !defined(HEDLEY_UNPREDICTABLE) - #define HEDLEY_UNPREDICTABLE(expr) HEDLEY_PREDICT(expr, 1, 0.5) +#if !defined(NLOHMANN_JSON_HEDLEY_UNPREDICTABLE) + #define NLOHMANN_JSON_HEDLEY_UNPREDICTABLE(expr) NLOHMANN_JSON_HEDLEY_PREDICT(expr, 1, 0.5) #endif -#if defined(HEDLEY_MALLOC) - #undef HEDLEY_MALLOC +#if defined(NLOHMANN_JSON_HEDLEY_MALLOC) + #undef NLOHMANN_JSON_HEDLEY_MALLOC #endif #if \ - HEDLEY_HAS_ATTRIBUTE(malloc) || \ - HEDLEY_GCC_VERSION_CHECK(3,1,0) || \ - HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ - HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \ - HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ - HEDLEY_IBM_VERSION_CHECK(12,1,0) || \ - HEDLEY_TI_VERSION_CHECK(8,0,0) || \ - (HEDLEY_TI_VERSION_CHECK(7,3,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) - #define HEDLEY_MALLOC __attribute__((__malloc__)) -#elif HEDLEY_MSVC_VERSION_CHECK(14, 0, 0) - #define HEDLEY_MALLOC __declspec(restrict) + NLOHMANN_JSON_HEDLEY_HAS_ATTRIBUTE(malloc) || \ + NLOHMANN_JSON_HEDLEY_GCC_VERSION_CHECK(3,1,0) || \ + NLOHMANN_JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ + NLOHMANN_JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \ + NLOHMANN_JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ + NLOHMANN_JSON_HEDLEY_IBM_VERSION_CHECK(12,1,0) || \ + NLOHMANN_JSON_HEDLEY_TI_VERSION_CHECK(8,0,0) || \ + (NLOHMANN_JSON_HEDLEY_TI_VERSION_CHECK(7,3,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) + #define NLOHMANN_JSON_HEDLEY_MALLOC __attribute__((__malloc__)) +#elif NLOHMANN_JSON_HEDLEY_MSVC_VERSION_CHECK(14, 0, 0) + #define NLOHMANN_JSON_HEDLEY_MALLOC __declspec(restrict) #else - #define HEDLEY_MALLOC + #define NLOHMANN_JSON_HEDLEY_MALLOC #endif -#if defined(HEDLEY_PURE) - #undef HEDLEY_PURE +#if defined(NLOHMANN_JSON_HEDLEY_PURE) + #undef NLOHMANN_JSON_HEDLEY_PURE #endif #if \ - HEDLEY_HAS_ATTRIBUTE(pure) || \ - HEDLEY_GCC_VERSION_CHECK(2,96,0) || \ - HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ - HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \ - HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ - HEDLEY_IBM_VERSION_CHECK(10,1,0) || \ - HEDLEY_TI_VERSION_CHECK(8,0,0) || \ - (HEDLEY_TI_VERSION_CHECK(7,3,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ - HEDLEY_PGI_VERSION_CHECK(17,10,0) - #define HEDLEY_PURE __attribute__((__pure__)) -#elif HEDLEY_TI_VERSION_CHECK(6,0,0) && defined(__cplusplus) - #define HEDLEY_PURE _Pragma("FUNC_IS_PURE;") + NLOHMANN_JSON_HEDLEY_HAS_ATTRIBUTE(pure) || \ + NLOHMANN_JSON_HEDLEY_GCC_VERSION_CHECK(2,96,0) || \ + NLOHMANN_JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ + NLOHMANN_JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \ + NLOHMANN_JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ + NLOHMANN_JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \ + NLOHMANN_JSON_HEDLEY_TI_VERSION_CHECK(8,0,0) || \ + (NLOHMANN_JSON_HEDLEY_TI_VERSION_CHECK(7,3,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ + NLOHMANN_JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) + #define NLOHMANN_JSON_HEDLEY_PURE __attribute__((__pure__)) +#elif NLOHMANN_JSON_HEDLEY_TI_VERSION_CHECK(6,0,0) && defined(__cplusplus) + #define NLOHMANN_JSON_HEDLEY_PURE _Pragma("FUNC_IS_PURE;") #else - #define HEDLEY_PURE + #define NLOHMANN_JSON_HEDLEY_PURE #endif -#if defined(HEDLEY_CONST) - #undef HEDLEY_CONST +#if defined(NLOHMANN_JSON_HEDLEY_CONST) + #undef NLOHMANN_JSON_HEDLEY_CONST #endif #if \ - HEDLEY_HAS_ATTRIBUTE(const) || \ - HEDLEY_GCC_VERSION_CHECK(2,5,0) || \ - HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ - HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \ - HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ - HEDLEY_IBM_VERSION_CHECK(10,1,0) || \ - HEDLEY_TI_VERSION_CHECK(8,0,0) || \ - (HEDLEY_TI_VERSION_CHECK(7,3,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ - HEDLEY_PGI_VERSION_CHECK(17,10,0) - #define HEDLEY_CONST __attribute__((__const__)) + NLOHMANN_JSON_HEDLEY_HAS_ATTRIBUTE(const) || \ + NLOHMANN_JSON_HEDLEY_GCC_VERSION_CHECK(2,5,0) || \ + NLOHMANN_JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ + NLOHMANN_JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \ + NLOHMANN_JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ + NLOHMANN_JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \ + NLOHMANN_JSON_HEDLEY_TI_VERSION_CHECK(8,0,0) || \ + (NLOHMANN_JSON_HEDLEY_TI_VERSION_CHECK(7,3,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ + NLOHMANN_JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) + #define NLOHMANN_JSON_HEDLEY_CONST __attribute__((__const__)) #else - #define HEDLEY_CONST HEDLEY_PURE + #define NLOHMANN_JSON_HEDLEY_CONST NLOHMANN_JSON_HEDLEY_PURE #endif -#if defined(HEDLEY_RESTRICT) - #undef HEDLEY_RESTRICT +#if defined(NLOHMANN_JSON_HEDLEY_RESTRICT) + #undef NLOHMANN_JSON_HEDLEY_RESTRICT #endif #if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) && !defined(__cplusplus) - #define HEDLEY_RESTRICT restrict + #define NLOHMANN_JSON_HEDLEY_RESTRICT restrict #elif \ - HEDLEY_GCC_VERSION_CHECK(3,1,0) || \ - HEDLEY_MSVC_VERSION_CHECK(14,0,0) || \ - HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ - HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ - HEDLEY_IBM_VERSION_CHECK(10,1,0) || \ - HEDLEY_PGI_VERSION_CHECK(17,10,0) || \ - HEDLEY_TI_VERSION_CHECK(8,0,0) || \ - (HEDLEY_SUNPRO_VERSION_CHECK(5,14,0) && defined(__cplusplus)) || \ - HEDLEY_IAR_VERSION_CHECK(8,0,0) || \ + NLOHMANN_JSON_HEDLEY_GCC_VERSION_CHECK(3,1,0) || \ + NLOHMANN_JSON_HEDLEY_MSVC_VERSION_CHECK(14,0,0) || \ + NLOHMANN_JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ + NLOHMANN_JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ + NLOHMANN_JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \ + NLOHMANN_JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) || \ + NLOHMANN_JSON_HEDLEY_TI_VERSION_CHECK(8,0,0) || \ + (NLOHMANN_JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,14,0) && defined(__cplusplus)) || \ + NLOHMANN_JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0) || \ defined(__clang__) - #define HEDLEY_RESTRICT __restrict -#elif HEDLEY_SUNPRO_VERSION_CHECK(5,3,0) && !defined(__cplusplus) - #define HEDLEY_RESTRICT _Restrict + #define NLOHMANN_JSON_HEDLEY_RESTRICT __restrict +#elif NLOHMANN_JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,3,0) && !defined(__cplusplus) + #define NLOHMANN_JSON_HEDLEY_RESTRICT _Restrict #else - #define HEDLEY_RESTRICT + #define NLOHMANN_JSON_HEDLEY_RESTRICT #endif -#if defined(HEDLEY_INLINE) - #undef HEDLEY_INLINE +#if defined(NLOHMANN_JSON_HEDLEY_INLINE) + #undef NLOHMANN_JSON_HEDLEY_INLINE #endif #if \ (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)) || \ (defined(__cplusplus) && (__cplusplus >= 199711L)) - #define HEDLEY_INLINE inline + #define NLOHMANN_JSON_HEDLEY_INLINE inline #elif \ - defined(HEDLEY_GCC_VERSION) || \ - HEDLEY_ARM_VERSION_CHECK(6,2,0) - #define HEDLEY_INLINE __inline__ + defined(NLOHMANN_JSON_HEDLEY_GCC_VERSION) || \ + NLOHMANN_JSON_HEDLEY_ARM_VERSION_CHECK(6,2,0) + #define NLOHMANN_JSON_HEDLEY_INLINE __inline__ #elif \ - HEDLEY_MSVC_VERSION_CHECK(12,0,0) || \ - HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ - HEDLEY_TI_VERSION_CHECK(8,0,0) - #define HEDLEY_INLINE __inline + NLOHMANN_JSON_HEDLEY_MSVC_VERSION_CHECK(12,0,0) || \ + NLOHMANN_JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ + NLOHMANN_JSON_HEDLEY_TI_VERSION_CHECK(8,0,0) + #define NLOHMANN_JSON_HEDLEY_INLINE __inline #else - #define HEDLEY_INLINE + #define NLOHMANN_JSON_HEDLEY_INLINE #endif -#if defined(HEDLEY_ALWAYS_INLINE) - #undef HEDLEY_ALWAYS_INLINE +#if defined(NLOHMANN_JSON_HEDLEY_ALWAYS_INLINE) + #undef NLOHMANN_JSON_HEDLEY_ALWAYS_INLINE #endif #if \ - HEDLEY_HAS_ATTRIBUTE(always_inline) || \ - HEDLEY_GCC_VERSION_CHECK(4,0,0) || \ - HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ - HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \ - HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ - HEDLEY_IBM_VERSION_CHECK(10,1,0) || \ - HEDLEY_TI_VERSION_CHECK(8,0,0) || \ - (HEDLEY_TI_VERSION_CHECK(7,3,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) - #define HEDLEY_ALWAYS_INLINE __attribute__((__always_inline__)) HEDLEY_INLINE -#elif HEDLEY_MSVC_VERSION_CHECK(12,0,0) - #define HEDLEY_ALWAYS_INLINE __forceinline -#elif HEDLEY_TI_VERSION_CHECK(7,0,0) && defined(__cplusplus) - #define HEDLEY_ALWAYS_INLINE _Pragma("FUNC_ALWAYS_INLINE;") -#elif HEDLEY_IAR_VERSION_CHECK(8,0,0) - #define HEDLEY_ALWAYS_INLINE _Pragma("inline=forced") + NLOHMANN_JSON_HEDLEY_HAS_ATTRIBUTE(always_inline) || \ + NLOHMANN_JSON_HEDLEY_GCC_VERSION_CHECK(4,0,0) || \ + NLOHMANN_JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ + NLOHMANN_JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \ + NLOHMANN_JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ + NLOHMANN_JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \ + NLOHMANN_JSON_HEDLEY_TI_VERSION_CHECK(8,0,0) || \ + (NLOHMANN_JSON_HEDLEY_TI_VERSION_CHECK(7,3,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) + #define NLOHMANN_JSON_HEDLEY_ALWAYS_INLINE __attribute__((__always_inline__)) NLOHMANN_JSON_HEDLEY_INLINE +#elif NLOHMANN_JSON_HEDLEY_MSVC_VERSION_CHECK(12,0,0) + #define NLOHMANN_JSON_HEDLEY_ALWAYS_INLINE __forceinline +#elif NLOHMANN_JSON_HEDLEY_TI_VERSION_CHECK(7,0,0) && defined(__cplusplus) + #define NLOHMANN_JSON_HEDLEY_ALWAYS_INLINE _Pragma("FUNC_ALWAYS_INLINE;") +#elif NLOHMANN_JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0) + #define NLOHMANN_JSON_HEDLEY_ALWAYS_INLINE _Pragma("inline=forced") #else - #define HEDLEY_ALWAYS_INLINE HEDLEY_INLINE + #define NLOHMANN_JSON_HEDLEY_ALWAYS_INLINE NLOHMANN_JSON_HEDLEY_INLINE #endif -#if defined(HEDLEY_NEVER_INLINE) - #undef HEDLEY_NEVER_INLINE +#if defined(NLOHMANN_JSON_HEDLEY_NEVER_INLINE) + #undef NLOHMANN_JSON_HEDLEY_NEVER_INLINE #endif #if \ - HEDLEY_HAS_ATTRIBUTE(noinline) || \ - HEDLEY_GCC_VERSION_CHECK(4,0,0) || \ - HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ - HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \ - HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ - HEDLEY_IBM_VERSION_CHECK(10,1,0) || \ - HEDLEY_TI_VERSION_CHECK(8,0,0) || \ - (HEDLEY_TI_VERSION_CHECK(7,3,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) - #define HEDLEY_NEVER_INLINE __attribute__((__noinline__)) -#elif HEDLEY_MSVC_VERSION_CHECK(13,10,0) - #define HEDLEY_NEVER_INLINE __declspec(noinline) -#elif HEDLEY_PGI_VERSION_CHECK(10,2,0) - #define HEDLEY_NEVER_INLINE _Pragma("noinline") -#elif HEDLEY_TI_VERSION_CHECK(6,0,0) && defined(__cplusplus) - #define HEDLEY_NEVER_INLINE _Pragma("FUNC_CANNOT_INLINE;") -#elif HEDLEY_IAR_VERSION_CHECK(8,0,0) - #define HEDLEY_NEVER_INLINE _Pragma("inline=never") -#elif HEDLEY_COMPCERT_VERSION_CHECK(3,2,0) - #define HEDLEY_NEVER_INLINE __attribute((noinline)) -#elif HEDLEY_PELLES_VERSION_CHECK(9,0,0) - #define HEDLEY_NEVER_INLINE __declspec(noinline) + NLOHMANN_JSON_HEDLEY_HAS_ATTRIBUTE(noinline) || \ + NLOHMANN_JSON_HEDLEY_GCC_VERSION_CHECK(4,0,0) || \ + NLOHMANN_JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ + NLOHMANN_JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \ + NLOHMANN_JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ + NLOHMANN_JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \ + NLOHMANN_JSON_HEDLEY_TI_VERSION_CHECK(8,0,0) || \ + (NLOHMANN_JSON_HEDLEY_TI_VERSION_CHECK(7,3,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) + #define NLOHMANN_JSON_HEDLEY_NEVER_INLINE __attribute__((__noinline__)) +#elif NLOHMANN_JSON_HEDLEY_MSVC_VERSION_CHECK(13,10,0) + #define NLOHMANN_JSON_HEDLEY_NEVER_INLINE __declspec(noinline) +#elif NLOHMANN_JSON_HEDLEY_PGI_VERSION_CHECK(10,2,0) + #define NLOHMANN_JSON_HEDLEY_NEVER_INLINE _Pragma("noinline") +#elif NLOHMANN_JSON_HEDLEY_TI_VERSION_CHECK(6,0,0) && defined(__cplusplus) + #define NLOHMANN_JSON_HEDLEY_NEVER_INLINE _Pragma("FUNC_CANNOT_INLINE;") +#elif NLOHMANN_JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0) + #define NLOHMANN_JSON_HEDLEY_NEVER_INLINE _Pragma("inline=never") +#elif NLOHMANN_JSON_HEDLEY_COMPCERT_VERSION_CHECK(3,2,0) + #define NLOHMANN_JSON_HEDLEY_NEVER_INLINE __attribute((noinline)) +#elif NLOHMANN_JSON_HEDLEY_PELLES_VERSION_CHECK(9,0,0) + #define NLOHMANN_JSON_HEDLEY_NEVER_INLINE __declspec(noinline) #else - #define HEDLEY_NEVER_INLINE + #define NLOHMANN_JSON_HEDLEY_NEVER_INLINE #endif -#if defined(HEDLEY_PRIVATE) - #undef HEDLEY_PRIVATE +#if defined(NLOHMANN_JSON_HEDLEY_PRIVATE) + #undef NLOHMANN_JSON_HEDLEY_PRIVATE #endif -#if defined(HEDLEY_PUBLIC) - #undef HEDLEY_PUBLIC +#if defined(NLOHMANN_JSON_HEDLEY_PUBLIC) + #undef NLOHMANN_JSON_HEDLEY_PUBLIC #endif -#if defined(HEDLEY_IMPORT) - #undef HEDLEY_IMPORT +#if defined(NLOHMANN_JSON_HEDLEY_IMPORT) + #undef NLOHMANN_JSON_HEDLEY_IMPORT #endif #if defined(_WIN32) || defined(__CYGWIN__) - #define HEDLEY_PRIVATE - #define HEDLEY_PUBLIC __declspec(dllexport) - #define HEDLEY_IMPORT __declspec(dllimport) + #define NLOHMANN_JSON_HEDLEY_PRIVATE + #define NLOHMANN_JSON_HEDLEY_PUBLIC __declspec(dllexport) + #define NLOHMANN_JSON_HEDLEY_IMPORT __declspec(dllimport) #else #if \ - HEDLEY_HAS_ATTRIBUTE(visibility) || \ - HEDLEY_GCC_VERSION_CHECK(3,3,0) || \ - HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \ - HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ - HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ - HEDLEY_IBM_VERSION_CHECK(13,1,0) || \ - HEDLEY_TI_VERSION_CHECK(8,0,0) || \ - (HEDLEY_TI_VERSION_CHECK(7,3,0) && defined(__TI_EABI__) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) - #define HEDLEY_PRIVATE __attribute__((__visibility__("hidden"))) - #define HEDLEY_PUBLIC __attribute__((__visibility__("default"))) + NLOHMANN_JSON_HEDLEY_HAS_ATTRIBUTE(visibility) || \ + NLOHMANN_JSON_HEDLEY_GCC_VERSION_CHECK(3,3,0) || \ + NLOHMANN_JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \ + NLOHMANN_JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ + NLOHMANN_JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ + NLOHMANN_JSON_HEDLEY_IBM_VERSION_CHECK(13,1,0) || \ + NLOHMANN_JSON_HEDLEY_TI_VERSION_CHECK(8,0,0) || \ + (NLOHMANN_JSON_HEDLEY_TI_VERSION_CHECK(7,3,0) && defined(__TI_EABI__) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) + #define NLOHMANN_JSON_HEDLEY_PRIVATE __attribute__((__visibility__("hidden"))) + #define NLOHMANN_JSON_HEDLEY_PUBLIC __attribute__((__visibility__("default"))) #else - #define HEDLEY_PRIVATE - #define HEDLEY_PUBLIC + #define NLOHMANN_JSON_HEDLEY_PRIVATE + #define NLOHMANN_JSON_HEDLEY_PUBLIC #endif - #define HEDLEY_IMPORT extern + #define NLOHMANN_JSON_HEDLEY_IMPORT extern #endif -#if defined(HEDLEY_NO_THROW) - #undef HEDLEY_NO_THROW +#if defined(NLOHMANN_JSON_HEDLEY_NO_THROW) + #undef NLOHMANN_JSON_HEDLEY_NO_THROW #endif #if \ - HEDLEY_HAS_ATTRIBUTE(nothrow) || \ - HEDLEY_GCC_VERSION_CHECK(3,3,0) || \ - HEDLEY_INTEL_VERSION_CHECK(13,0,0) - #define HEDLEY_NO_THROW __attribute__((__nothrow__)) + NLOHMANN_JSON_HEDLEY_HAS_ATTRIBUTE(nothrow) || \ + NLOHMANN_JSON_HEDLEY_GCC_VERSION_CHECK(3,3,0) || \ + NLOHMANN_JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) + #define NLOHMANN_JSON_HEDLEY_NO_THROW __attribute__((__nothrow__)) #elif \ - HEDLEY_MSVC_VERSION_CHECK(13,1,0) || \ - HEDLEY_ARM_VERSION_CHECK(4,1,0) - #define HEDLEY_NO_THROW __declspec(nothrow) + NLOHMANN_JSON_HEDLEY_MSVC_VERSION_CHECK(13,1,0) || \ + NLOHMANN_JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) + #define NLOHMANN_JSON_HEDLEY_NO_THROW __declspec(nothrow) #else - #define HEDLEY_NO_THROW + #define NLOHMANN_JSON_HEDLEY_NO_THROW #endif -#if defined(HEDLEY_FALL_THROUGH) - #undef HEDLEY_FALL_THROUGH +#if defined(NLOHMANN_JSON_HEDLEY_FALL_THROUGH) + #undef NLOHMANN_JSON_HEDLEY_FALL_THROUGH #endif #if \ defined(__cplusplus) && \ - (!defined(HEDLEY_SUNPRO_VERSION) || HEDLEY_SUNPRO_VERSION_CHECK(5,15,0)) && \ - !defined(HEDLEY_PGI_VERSION) + (!defined(NLOHMANN_JSON_HEDLEY_SUNPRO_VERSION) || NLOHMANN_JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,15,0)) && \ + !defined(NLOHMANN_JSON_HEDLEY_PGI_VERSION) #if \ (__cplusplus >= 201703L) || \ - ((__cplusplus >= 201103L) && HEDLEY_HAS_CPP_ATTRIBUTE(fallthrough)) - #define HEDLEY_FALL_THROUGH [[fallthrough]] - #elif (__cplusplus >= 201103L) && HEDLEY_HAS_CPP_ATTRIBUTE(clang::fallthrough) - #define HEDLEY_FALL_THROUGH [[clang::fallthrough]] - #elif (__cplusplus >= 201103L) && HEDLEY_GCC_VERSION_CHECK(7,0,0) - #define HEDLEY_FALL_THROUGH [[gnu::fallthrough]] + ((__cplusplus >= 201103L) && NLOHMANN_JSON_HEDLEY_HAS_CPP_ATTRIBUTE(fallthrough)) + #define NLOHMANN_JSON_HEDLEY_FALL_THROUGH [[fallthrough]] + #elif (__cplusplus >= 201103L) && NLOHMANN_JSON_HEDLEY_HAS_CPP_ATTRIBUTE(clang::fallthrough) + #define NLOHMANN_JSON_HEDLEY_FALL_THROUGH [[clang::fallthrough]] + #elif (__cplusplus >= 201103L) && NLOHMANN_JSON_HEDLEY_GCC_VERSION_CHECK(7,0,0) + #define NLOHMANN_JSON_HEDLEY_FALL_THROUGH [[gnu::fallthrough]] #endif #endif -#if !defined(HEDLEY_FALL_THROUGH) - #if HEDLEY_GNUC_HAS_ATTRIBUTE(fallthrough,7,0,0) && !defined(HEDLEY_PGI_VERSION) - #define HEDLEY_FALL_THROUGH __attribute__((__fallthrough__)) +#if !defined(NLOHMANN_JSON_HEDLEY_FALL_THROUGH) + #if NLOHMANN_JSON_HEDLEY_GNUC_HAS_ATTRIBUTE(fallthrough,7,0,0) && !defined(NLOHMANN_JSON_HEDLEY_PGI_VERSION) + #define NLOHMANN_JSON_HEDLEY_FALL_THROUGH __attribute__((__fallthrough__)) #elif defined(__fallthrough) /* SAL */ - #define HEDLEY_FALL_THROUGH __fallthrough + #define NLOHMANN_JSON_HEDLEY_FALL_THROUGH __fallthrough #else - #define HEDLEY_FALL_THROUGH + #define NLOHMANN_JSON_HEDLEY_FALL_THROUGH #endif #endif -#if defined(HEDLEY_RETURNS_NON_NULL) - #undef HEDLEY_RETURNS_NON_NULL +#if defined(NLOHMANN_JSON_HEDLEY_RETURNS_NON_NULL) + #undef NLOHMANN_JSON_HEDLEY_RETURNS_NON_NULL #endif #if \ - HEDLEY_HAS_ATTRIBUTE(returns_nonnull) || \ - HEDLEY_GCC_VERSION_CHECK(4,9,0) - #define HEDLEY_RETURNS_NON_NULL __attribute__((__returns_nonnull__)) + NLOHMANN_JSON_HEDLEY_HAS_ATTRIBUTE(returns_nonnull) || \ + NLOHMANN_JSON_HEDLEY_GCC_VERSION_CHECK(4,9,0) + #define NLOHMANN_JSON_HEDLEY_RETURNS_NON_NULL __attribute__((__returns_nonnull__)) #elif defined(_Ret_notnull_) /* SAL */ - #define HEDLEY_RETURNS_NON_NULL _Ret_notnull_ + #define NLOHMANN_JSON_HEDLEY_RETURNS_NON_NULL _Ret_notnull_ #else - #define HEDLEY_RETURNS_NON_NULL + #define NLOHMANN_JSON_HEDLEY_RETURNS_NON_NULL #endif -#if defined(HEDLEY_ARRAY_PARAM) - #undef HEDLEY_ARRAY_PARAM +#if defined(NLOHMANN_JSON_HEDLEY_ARRAY_PARAM) + #undef NLOHMANN_JSON_HEDLEY_ARRAY_PARAM #endif #if \ defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) && \ !defined(__STDC_NO_VLA__) && \ !defined(__cplusplus) && \ - !defined(HEDLEY_PGI_VERSION) && \ - !defined(HEDLEY_TINYC_VERSION) - #define HEDLEY_ARRAY_PARAM(name) (name) + !defined(NLOHMANN_JSON_HEDLEY_PGI_VERSION) && \ + !defined(NLOHMANN_JSON_HEDLEY_TINYC_VERSION) + #define NLOHMANN_JSON_HEDLEY_ARRAY_PARAM(name) (name) #else - #define HEDLEY_ARRAY_PARAM(name) + #define NLOHMANN_JSON_HEDLEY_ARRAY_PARAM(name) #endif -#if defined(HEDLEY_IS_CONSTANT) - #undef HEDLEY_IS_CONSTANT +#if defined(NLOHMANN_JSON_HEDLEY_IS_CONSTANT) + #undef NLOHMANN_JSON_HEDLEY_IS_CONSTANT #endif -#if defined(HEDLEY_REQUIRE_CONSTEXPR) - #undef HEDLEY_REQUIRE_CONSTEXPR +#if defined(NLOHMANN_JSON_HEDLEY_REQUIRE_CONSTEXPR) + #undef NLOHMANN_JSON_HEDLEY_REQUIRE_CONSTEXPR #endif /* Note the double-underscore. For internal use only; no API * guarantees! */ -#if defined(HEDLEY__IS_CONSTEXPR) - #undef HEDLEY__IS_CONSTEXPR +#if defined(NLOHMANN_JSON_HEDLEY__IS_CONSTEXPR) + #undef NLOHMANN_JSON_HEDLEY__IS_CONSTEXPR #endif #if \ - HEDLEY_HAS_BUILTIN(__builtin_constant_p) || \ - HEDLEY_GCC_VERSION_CHECK(3,4,0) || \ - HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ - HEDLEY_TINYC_VERSION_CHECK(0,9,19) || \ - HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ - HEDLEY_IBM_VERSION_CHECK(13,1,0) || \ - HEDLEY_TI_VERSION_CHECK(6,1,0) || \ - HEDLEY_SUNPRO_VERSION_CHECK(5,10,0) || \ - HEDLEY_CRAY_VERSION_CHECK(8,1,0) - #define HEDLEY_IS_CONSTANT(expr) __builtin_constant_p(expr) + NLOHMANN_JSON_HEDLEY_HAS_BUILTIN(__builtin_constant_p) || \ + NLOHMANN_JSON_HEDLEY_GCC_VERSION_CHECK(3,4,0) || \ + NLOHMANN_JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ + NLOHMANN_JSON_HEDLEY_TINYC_VERSION_CHECK(0,9,19) || \ + NLOHMANN_JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ + NLOHMANN_JSON_HEDLEY_IBM_VERSION_CHECK(13,1,0) || \ + NLOHMANN_JSON_HEDLEY_TI_VERSION_CHECK(6,1,0) || \ + NLOHMANN_JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,10,0) || \ + NLOHMANN_JSON_HEDLEY_CRAY_VERSION_CHECK(8,1,0) + #define NLOHMANN_JSON_HEDLEY_IS_CONSTANT(expr) __builtin_constant_p(expr) #endif #if !defined(__cplusplus) # if \ - HEDLEY_HAS_BUILTIN(__builtin_types_compatible_p) || \ - HEDLEY_GCC_VERSION_CHECK(3,4,0) || \ - HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ - HEDLEY_IBM_VERSION_CHECK(13,1,0) || \ - HEDLEY_CRAY_VERSION_CHECK(8,1,0) || \ - HEDLEY_ARM_VERSION_CHECK(5,4,0) || \ - HEDLEY_TINYC_VERSION_CHECK(0,9,24) + NLOHMANN_JSON_HEDLEY_HAS_BUILTIN(__builtin_types_compatible_p) || \ + NLOHMANN_JSON_HEDLEY_GCC_VERSION_CHECK(3,4,0) || \ + NLOHMANN_JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ + NLOHMANN_JSON_HEDLEY_IBM_VERSION_CHECK(13,1,0) || \ + NLOHMANN_JSON_HEDLEY_CRAY_VERSION_CHECK(8,1,0) || \ + NLOHMANN_JSON_HEDLEY_ARM_VERSION_CHECK(5,4,0) || \ + NLOHMANN_JSON_HEDLEY_TINYC_VERSION_CHECK(0,9,24) #if defined(__INTPTR_TYPE__) - #define HEDLEY__IS_CONSTEXPR(expr) __builtin_types_compatible_p(__typeof__((1 ? (void*) ((__INTPTR_TYPE__) ((expr) * 0)) : (int*) 0)), int*) + #define NLOHMANN_JSON_HEDLEY__IS_CONSTEXPR(expr) __builtin_types_compatible_p(__typeof__((1 ? (void*) ((__INTPTR_TYPE__) ((expr) * 0)) : (int*) 0)), int*) #else #include - #define HEDLEY__IS_CONSTEXPR(expr) __builtin_types_compatible_p(__typeof__((1 ? (void*) ((intptr_t) ((expr) * 0)) : (int*) 0)), int*) + #define NLOHMANN_JSON_HEDLEY__IS_CONSTEXPR(expr) __builtin_types_compatible_p(__typeof__((1 ? (void*) ((intptr_t) ((expr) * 0)) : (int*) 0)), int*) #endif # elif \ - (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 201112L) && !defined(HEDLEY_SUNPRO_VERSION) && !defined(HEDLEY_PGI_VERSION)) || \ - HEDLEY_HAS_EXTENSION(c_generic_selections) || \ - HEDLEY_GCC_VERSION_CHECK(4,9,0) || \ - HEDLEY_INTEL_VERSION_CHECK(17,0,0) || \ - HEDLEY_IBM_VERSION_CHECK(12,1,0) || \ - HEDLEY_ARM_VERSION_CHECK(5,3,0) + (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 201112L) && !defined(NLOHMANN_JSON_HEDLEY_SUNPRO_VERSION) && !defined(NLOHMANN_JSON_HEDLEY_PGI_VERSION)) || \ + NLOHMANN_JSON_HEDLEY_HAS_EXTENSION(c_generic_selections) || \ + NLOHMANN_JSON_HEDLEY_GCC_VERSION_CHECK(4,9,0) || \ + NLOHMANN_JSON_HEDLEY_INTEL_VERSION_CHECK(17,0,0) || \ + NLOHMANN_JSON_HEDLEY_IBM_VERSION_CHECK(12,1,0) || \ + NLOHMANN_JSON_HEDLEY_ARM_VERSION_CHECK(5,3,0) #if defined(__INTPTR_TYPE__) - #define HEDLEY__IS_CONSTEXPR(expr) _Generic((1 ? (void*) ((__INTPTR_TYPE__) ((expr) * 0)) : (int*) 0), int*: 1, void*: 0) + #define NLOHMANN_JSON_HEDLEY__IS_CONSTEXPR(expr) _Generic((1 ? (void*) ((__INTPTR_TYPE__) ((expr) * 0)) : (int*) 0), int*: 1, void*: 0) #else #include - #define HEDLEY__IS_CONSTEXPR(expr) _Generic((1 ? (void*) ((intptr_t) * 0) : (int*) 0), int*: 1, void*: 0) + #define NLOHMANN_JSON_HEDLEY__IS_CONSTEXPR(expr) _Generic((1 ? (void*) ((intptr_t) * 0) : (int*) 0), int*: 1, void*: 0) #endif # elif \ - defined(HEDLEY_GCC_VERSION) || \ - defined(HEDLEY_INTEL_VERSION) || \ - defined(HEDLEY_TINYC_VERSION) || \ - defined(HEDLEY_TI_VERSION) || \ + defined(NLOHMANN_JSON_HEDLEY_GCC_VERSION) || \ + defined(NLOHMANN_JSON_HEDLEY_INTEL_VERSION) || \ + defined(NLOHMANN_JSON_HEDLEY_TINYC_VERSION) || \ + defined(NLOHMANN_JSON_HEDLEY_TI_VERSION) || \ defined(__clang__) -# define HEDLEY__IS_CONSTEXPR(expr) ( \ +# define NLOHMANN_JSON_HEDLEY__IS_CONSTEXPR(expr) ( \ sizeof(void) != \ sizeof(*( \ 1 ? \ @@ -1268,238 +1268,238 @@ HEDLEY_DIAGNOSTIC_POP ((struct { char v[sizeof(void) * 2]; } *) 1) \ ) \ ) \ - ) + ) # endif #endif -#if defined(HEDLEY__IS_CONSTEXPR) - #if !defined(HEDLEY_IS_CONSTANT) - #define HEDLEY_IS_CONSTANT(expr) HEDLEY__IS_CONSTEXPR(expr) +#if defined(NLOHMANN_JSON_HEDLEY__IS_CONSTEXPR) + #if !defined(NLOHMANN_JSON_HEDLEY_IS_CONSTANT) + #define NLOHMANN_JSON_HEDLEY_IS_CONSTANT(expr) NLOHMANN_JSON_HEDLEY__IS_CONSTEXPR(expr) #endif - #define HEDLEY_REQUIRE_CONSTEXPR(expr) (HEDLEY__IS_CONSTEXPR(expr) ? (expr) : (-1)) + #define NLOHMANN_JSON_HEDLEY_REQUIRE_CONSTEXPR(expr) (NLOHMANN_JSON_HEDLEY__IS_CONSTEXPR(expr) ? (expr) : (-1)) #else - #if !defined(HEDLEY_IS_CONSTANT) - #define HEDLEY_IS_CONSTANT(expr) (0) + #if !defined(NLOHMANN_JSON_HEDLEY_IS_CONSTANT) + #define NLOHMANN_JSON_HEDLEY_IS_CONSTANT(expr) (0) #endif - #define HEDLEY_REQUIRE_CONSTEXPR(expr) (expr) + #define NLOHMANN_JSON_HEDLEY_REQUIRE_CONSTEXPR(expr) (expr) #endif -#if defined(HEDLEY_BEGIN_C_DECLS) - #undef HEDLEY_BEGIN_C_DECLS +#if defined(NLOHMANN_JSON_HEDLEY_BEGIN_C_DECLS) + #undef NLOHMANN_JSON_HEDLEY_BEGIN_C_DECLS #endif -#if defined(HEDLEY_END_C_DECLS) - #undef HEDLEY_END_C_DECLS +#if defined(NLOHMANN_JSON_HEDLEY_END_C_DECLS) + #undef NLOHMANN_JSON_HEDLEY_END_C_DECLS #endif -#if defined(HEDLEY_C_DECL) - #undef HEDLEY_C_DECL +#if defined(NLOHMANN_JSON_HEDLEY_C_DECL) + #undef NLOHMANN_JSON_HEDLEY_C_DECL #endif #if defined(__cplusplus) - #define HEDLEY_BEGIN_C_DECLS extern "C" { - #define HEDLEY_END_C_DECLS } - #define HEDLEY_C_DECL extern "C" + #define NLOHMANN_JSON_HEDLEY_BEGIN_C_DECLS extern "C" { + #define NLOHMANN_JSON_HEDLEY_END_C_DECLS } + #define NLOHMANN_JSON_HEDLEY_C_DECL extern "C" #else - #define HEDLEY_BEGIN_C_DECLS - #define HEDLEY_END_C_DECLS - #define HEDLEY_C_DECL + #define NLOHMANN_JSON_HEDLEY_BEGIN_C_DECLS + #define NLOHMANN_JSON_HEDLEY_END_C_DECLS + #define NLOHMANN_JSON_HEDLEY_C_DECL #endif -#if defined(HEDLEY_STATIC_ASSERT) - #undef HEDLEY_STATIC_ASSERT +#if defined(NLOHMANN_JSON_HEDLEY_STATIC_ASSERT) + #undef NLOHMANN_JSON_HEDLEY_STATIC_ASSERT #endif #if \ !defined(__cplusplus) && ( \ (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 201112L)) || \ - HEDLEY_HAS_FEATURE(c_static_assert) || \ - HEDLEY_GCC_VERSION_CHECK(6,0,0) || \ - HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ + NLOHMANN_JSON_HEDLEY_HAS_FEATURE(c_static_assert) || \ + NLOHMANN_JSON_HEDLEY_GCC_VERSION_CHECK(6,0,0) || \ + NLOHMANN_JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ defined(_Static_assert) \ ) -# define HEDLEY_STATIC_ASSERT(expr, message) _Static_assert(expr, message) +# define NLOHMANN_JSON_HEDLEY_STATIC_ASSERT(expr, message) _Static_assert(expr, message) #elif \ (defined(__cplusplus) && (__cplusplus >= 201703L)) || \ - HEDLEY_MSVC_VERSION_CHECK(16,0,0) || \ - (defined(__cplusplus) && HEDLEY_TI_VERSION_CHECK(8,3,0)) -# define HEDLEY_STATIC_ASSERT(expr, message) static_assert(expr, message) + NLOHMANN_JSON_HEDLEY_MSVC_VERSION_CHECK(16,0,0) || \ + (defined(__cplusplus) && NLOHMANN_JSON_HEDLEY_TI_VERSION_CHECK(8,3,0)) +# define NLOHMANN_JSON_HEDLEY_STATIC_ASSERT(expr, message) static_assert(expr, message) #elif defined(__cplusplus) && (__cplusplus >= 201103L) -# define HEDLEY_STATIC_ASSERT(expr, message) static_assert(expr) +# define NLOHMANN_JSON_HEDLEY_STATIC_ASSERT(expr, message) static_assert(expr) #else -# define HEDLEY_STATIC_ASSERT(expr, message) +# define NLOHMANN_JSON_HEDLEY_STATIC_ASSERT(expr, message) #endif -#if defined(HEDLEY_CONST_CAST) - #undef HEDLEY_CONST_CAST +#if defined(NLOHMANN_JSON_HEDLEY_CONST_CAST) + #undef NLOHMANN_JSON_HEDLEY_CONST_CAST #endif #if defined(__cplusplus) -# define HEDLEY_CONST_CAST(T, expr) (const_cast(expr)) +# define NLOHMANN_JSON_HEDLEY_CONST_CAST(T, expr) (const_cast(expr)) #elif \ - HEDLEY_HAS_WARNING("-Wcast-qual") || \ - HEDLEY_GCC_VERSION_CHECK(4,6,0) || \ - HEDLEY_INTEL_VERSION_CHECK(13,0,0) -# define HEDLEY_CONST_CAST(T, expr) (__extension__ ({ \ - HEDLEY_DIAGNOSTIC_PUSH \ - HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL \ + NLOHMANN_JSON_HEDLEY_HAS_WARNING("-Wcast-qual") || \ + NLOHMANN_JSON_HEDLEY_GCC_VERSION_CHECK(4,6,0) || \ + NLOHMANN_JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) +# define NLOHMANN_JSON_HEDLEY_CONST_CAST(T, expr) (__extension__ ({ \ + NLOHMANN_JSON_HEDLEY_DIAGNOSTIC_PUSH \ + NLOHMANN_JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL \ ((T) (expr)); \ - HEDLEY_DIAGNOSTIC_POP \ + NLOHMANN_JSON_HEDLEY_DIAGNOSTIC_POP \ })) #else -# define HEDLEY_CONST_CAST(T, expr) ((T) (expr)) +# define NLOHMANN_JSON_HEDLEY_CONST_CAST(T, expr) ((T) (expr)) #endif -#if defined(HEDLEY_REINTERPRET_CAST) - #undef HEDLEY_REINTERPRET_CAST +#if defined(NLOHMANN_JSON_HEDLEY_REINTERPRET_CAST) + #undef NLOHMANN_JSON_HEDLEY_REINTERPRET_CAST #endif #if defined(__cplusplus) - #define HEDLEY_REINTERPRET_CAST(T, expr) (reinterpret_cast(expr)) + #define NLOHMANN_JSON_HEDLEY_REINTERPRET_CAST(T, expr) (reinterpret_cast(expr)) #else - #define HEDLEY_REINTERPRET_CAST(T, expr) (*((T*) &(expr))) + #define NLOHMANN_JSON_HEDLEY_REINTERPRET_CAST(T, expr) (*((T*) &(expr))) #endif -#if defined(HEDLEY_STATIC_CAST) - #undef HEDLEY_STATIC_CAST +#if defined(NLOHMANN_JSON_HEDLEY_STATIC_CAST) + #undef NLOHMANN_JSON_HEDLEY_STATIC_CAST #endif #if defined(__cplusplus) - #define HEDLEY_STATIC_CAST(T, expr) (static_cast(expr)) + #define NLOHMANN_JSON_HEDLEY_STATIC_CAST(T, expr) (static_cast(expr)) #else - #define HEDLEY_STATIC_CAST(T, expr) ((T) (expr)) + #define NLOHMANN_JSON_HEDLEY_STATIC_CAST(T, expr) ((T) (expr)) #endif -#if defined(HEDLEY_CPP_CAST) - #undef HEDLEY_CPP_CAST +#if defined(NLOHMANN_JSON_HEDLEY_CPP_CAST) + #undef NLOHMANN_JSON_HEDLEY_CPP_CAST #endif #if defined(__cplusplus) - #define HEDLEY_CPP_CAST(T, expr) static_cast(expr) + #define NLOHMANN_JSON_HEDLEY_CPP_CAST(T, expr) static_cast(expr) #else - #define HEDLEY_CPP_CAST(T, expr) (expr) + #define NLOHMANN_JSON_HEDLEY_CPP_CAST(T, expr) (expr) #endif -#if defined(HEDLEY_MESSAGE) - #undef HEDLEY_MESSAGE +#if defined(NLOHMANN_JSON_HEDLEY_MESSAGE) + #undef NLOHMANN_JSON_HEDLEY_MESSAGE #endif -#if HEDLEY_HAS_WARNING("-Wunknown-pragmas") -# define HEDLEY_MESSAGE(msg) \ - HEDLEY_DIAGNOSTIC_PUSH \ - HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS \ - HEDLEY_PRAGMA(message msg) \ - HEDLEY_DIAGNOSTIC_POP +#if NLOHMANN_JSON_HEDLEY_HAS_WARNING("-Wunknown-pragmas") +# define NLOHMANN_JSON_HEDLEY_MESSAGE(msg) \ + NLOHMANN_JSON_HEDLEY_DIAGNOSTIC_PUSH \ + NLOHMANN_JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS \ + NLOHMANN_JSON_HEDLEY_PRAGMA(message msg) \ + NLOHMANN_JSON_HEDLEY_DIAGNOSTIC_POP #elif \ - HEDLEY_GCC_VERSION_CHECK(4,4,0) || \ - HEDLEY_INTEL_VERSION_CHECK(13,0,0) -# define HEDLEY_MESSAGE(msg) HEDLEY_PRAGMA(message msg) -#elif HEDLEY_CRAY_VERSION_CHECK(5,0,0) -# define HEDLEY_MESSAGE(msg) HEDLEY_PRAGMA(_CRI message msg) -#elif HEDLEY_IAR_VERSION_CHECK(8,0,0) -# define HEDLEY_MESSAGE(msg) HEDLEY_PRAGMA(message(msg)) -#elif HEDLEY_PELLES_VERSION_CHECK(2,0,0) -# define HEDLEY_MESSAGE(msg) HEDLEY_PRAGMA(message(msg)) + NLOHMANN_JSON_HEDLEY_GCC_VERSION_CHECK(4,4,0) || \ + NLOHMANN_JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) +# define NLOHMANN_JSON_HEDLEY_MESSAGE(msg) NLOHMANN_JSON_HEDLEY_PRAGMA(message msg) +#elif NLOHMANN_JSON_HEDLEY_CRAY_VERSION_CHECK(5,0,0) +# define NLOHMANN_JSON_HEDLEY_MESSAGE(msg) NLOHMANN_JSON_HEDLEY_PRAGMA(_CRI message msg) +#elif NLOHMANN_JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0) +# define NLOHMANN_JSON_HEDLEY_MESSAGE(msg) NLOHMANN_JSON_HEDLEY_PRAGMA(message(msg)) +#elif NLOHMANN_JSON_HEDLEY_PELLES_VERSION_CHECK(2,0,0) +# define NLOHMANN_JSON_HEDLEY_MESSAGE(msg) NLOHMANN_JSON_HEDLEY_PRAGMA(message(msg)) #else -# define HEDLEY_MESSAGE(msg) +# define NLOHMANN_JSON_HEDLEY_MESSAGE(msg) #endif -#if defined(HEDLEY_WARNING) - #undef HEDLEY_WARNING +#if defined(NLOHMANN_JSON_HEDLEY_WARNING) + #undef NLOHMANN_JSON_HEDLEY_WARNING #endif -#if HEDLEY_HAS_WARNING("-Wunknown-pragmas") -# define HEDLEY_WARNING(msg) \ - HEDLEY_DIAGNOSTIC_PUSH \ - HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS \ - HEDLEY_PRAGMA(clang warning msg) \ - HEDLEY_DIAGNOSTIC_POP +#if NLOHMANN_JSON_HEDLEY_HAS_WARNING("-Wunknown-pragmas") +# define NLOHMANN_JSON_HEDLEY_WARNING(msg) \ + NLOHMANN_JSON_HEDLEY_DIAGNOSTIC_PUSH \ + NLOHMANN_JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS \ + NLOHMANN_JSON_HEDLEY_PRAGMA(clang warning msg) \ + NLOHMANN_JSON_HEDLEY_DIAGNOSTIC_POP #elif \ - HEDLEY_GCC_VERSION_CHECK(4,8,0) || \ - HEDLEY_PGI_VERSION_CHECK(18,4,0) -# define HEDLEY_WARNING(msg) HEDLEY_PRAGMA(GCC warning msg) -#elif HEDLEY_MSVC_VERSION_CHECK(15,0,0) -# define HEDLEY_WARNING(msg) HEDLEY_PRAGMA(message(msg)) + NLOHMANN_JSON_HEDLEY_GCC_VERSION_CHECK(4,8,0) || \ + NLOHMANN_JSON_HEDLEY_PGI_VERSION_CHECK(18,4,0) +# define NLOHMANN_JSON_HEDLEY_WARNING(msg) NLOHMANN_JSON_HEDLEY_PRAGMA(GCC warning msg) +#elif NLOHMANN_JSON_HEDLEY_MSVC_VERSION_CHECK(15,0,0) +# define NLOHMANN_JSON_HEDLEY_WARNING(msg) NLOHMANN_JSON_HEDLEY_PRAGMA(message(msg)) #else -# define HEDLEY_WARNING(msg) HEDLEY_MESSAGE(msg) +# define NLOHMANN_JSON_HEDLEY_WARNING(msg) NLOHMANN_JSON_HEDLEY_MESSAGE(msg) #endif -#if defined(HEDLEY_REQUIRE_MSG) - #undef HEDLEY_REQUIRE_MSG +#if defined(NLOHMANN_JSON_HEDLEY_REQUIRE_MSG) + #undef NLOHMANN_JSON_HEDLEY_REQUIRE_MSG #endif -#if HEDLEY_HAS_ATTRIBUTE(diagnose_if) -# if HEDLEY_HAS_WARNING("-Wgcc-compat") -# define HEDLEY_REQUIRE_MSG(expr, msg) \ - HEDLEY_DIAGNOSTIC_PUSH \ +#if NLOHMANN_JSON_HEDLEY_HAS_ATTRIBUTE(diagnose_if) +# if NLOHMANN_JSON_HEDLEY_HAS_WARNING("-Wgcc-compat") +# define NLOHMANN_JSON_HEDLEY_REQUIRE_MSG(expr, msg) \ + NLOHMANN_JSON_HEDLEY_DIAGNOSTIC_PUSH \ _Pragma("clang diagnostic ignored \"-Wgcc-compat\"") \ __attribute__((__diagnose_if__(!(expr), msg, "error"))) \ - HEDLEY_DIAGNOSTIC_POP + NLOHMANN_JSON_HEDLEY_DIAGNOSTIC_POP # else -# define HEDLEY_REQUIRE_MSG(expr, msg) __attribute__((__diagnose_if__(!(expr), msg, "error"))) +# define NLOHMANN_JSON_HEDLEY_REQUIRE_MSG(expr, msg) __attribute__((__diagnose_if__(!(expr), msg, "error"))) # endif #else -# define HEDLEY_REQUIRE_MSG(expr, msg) +# define NLOHMANN_JSON_HEDLEY_REQUIRE_MSG(expr, msg) #endif -#if defined(HEDLEY_REQUIRE) - #undef HEDLEY_REQUIRE +#if defined(NLOHMANN_JSON_HEDLEY_REQUIRE) + #undef NLOHMANN_JSON_HEDLEY_REQUIRE #endif -#define HEDLEY_REQUIRE(expr) HEDLEY_REQUIRE_MSG(expr, #expr) +#define NLOHMANN_JSON_HEDLEY_REQUIRE(expr) NLOHMANN_JSON_HEDLEY_REQUIRE_MSG(expr, #expr) -#if defined(HEDLEY_FLAGS) - #undef HEDLEY_FLAGS +#if defined(NLOHMANN_JSON_HEDLEY_FLAGS) + #undef NLOHMANN_JSON_HEDLEY_FLAGS #endif -#if HEDLEY_HAS_ATTRIBUTE(flag_enum) - #define HEDLEY_FLAGS __attribute__((__flag_enum__)) +#if NLOHMANN_JSON_HEDLEY_HAS_ATTRIBUTE(flag_enum) + #define NLOHMANN_JSON_HEDLEY_FLAGS __attribute__((__flag_enum__)) #endif -#if defined(HEDLEY_FLAGS_CAST) - #undef HEDLEY_FLAGS_CAST +#if defined(NLOHMANN_JSON_HEDLEY_FLAGS_CAST) + #undef NLOHMANN_JSON_HEDLEY_FLAGS_CAST #endif -#if HEDLEY_INTEL_VERSION_CHECK(19,0,0) -# define HEDLEY_FLAGS_CAST(T, expr) (__extension__ ({ \ - HEDLEY_DIAGNOSTIC_PUSH \ +#if NLOHMANN_JSON_HEDLEY_INTEL_VERSION_CHECK(19,0,0) +# define NLOHMANN_JSON_HEDLEY_FLAGS_CAST(T, expr) (__extension__ ({ \ + NLOHMANN_JSON_HEDLEY_DIAGNOSTIC_PUSH \ _Pragma("warning(disable:188)") \ ((T) (expr)); \ - HEDLEY_DIAGNOSTIC_POP \ + NLOHMANN_JSON_HEDLEY_DIAGNOSTIC_POP \ })) #else -# define HEDLEY_FLAGS_CAST(T, expr) HEDLEY_STATIC_CAST(T, expr) +# define NLOHMANN_JSON_HEDLEY_FLAGS_CAST(T, expr) NLOHMANN_JSON_HEDLEY_STATIC_CAST(T, expr) #endif /* Remaining macros are deprecated. */ -#if defined(HEDLEY_GCC_NOT_CLANG_VERSION_CHECK) - #undef HEDLEY_GCC_NOT_CLANG_VERSION_CHECK +#if defined(NLOHMANN_JSON_HEDLEY_GCC_NOT_CLANG_VERSION_CHECK) + #undef NLOHMANN_JSON_HEDLEY_GCC_NOT_CLANG_VERSION_CHECK #endif #if defined(__clang__) - #define HEDLEY_GCC_NOT_CLANG_VERSION_CHECK(major,minor,patch) (0) + #define NLOHMANN_JSON_HEDLEY_GCC_NOT_CLANG_VERSION_CHECK(major,minor,patch) (0) #else - #define HEDLEY_GCC_NOT_CLANG_VERSION_CHECK(major,minor,patch) HEDLEY_GCC_VERSION_CHECK(major,minor,patch) + #define NLOHMANN_JSON_HEDLEY_GCC_NOT_CLANG_VERSION_CHECK(major,minor,patch) NLOHMANN_JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch) #endif -#if defined(HEDLEY_CLANG_HAS_ATTRIBUTE) - #undef HEDLEY_CLANG_HAS_ATTRIBUTE +#if defined(NLOHMANN_JSON_HEDLEY_CLANG_HAS_ATTRIBUTE) + #undef NLOHMANN_JSON_HEDLEY_CLANG_HAS_ATTRIBUTE #endif -#define HEDLEY_CLANG_HAS_ATTRIBUTE(attribute) HEDLEY_HAS_ATTRIBUTE(attribute) +#define NLOHMANN_JSON_HEDLEY_CLANG_HAS_ATTRIBUTE(attribute) NLOHMANN_JSON_HEDLEY_HAS_ATTRIBUTE(attribute) -#if defined(HEDLEY_CLANG_HAS_CPP_ATTRIBUTE) - #undef HEDLEY_CLANG_HAS_CPP_ATTRIBUTE +#if defined(NLOHMANN_JSON_HEDLEY_CLANG_HAS_CPP_ATTRIBUTE) + #undef NLOHMANN_JSON_HEDLEY_CLANG_HAS_CPP_ATTRIBUTE #endif -#define HEDLEY_CLANG_HAS_CPP_ATTRIBUTE(attribute) HEDLEY_HAS_CPP_ATTRIBUTE(attribute) +#define NLOHMANN_JSON_HEDLEY_CLANG_HAS_CPP_ATTRIBUTE(attribute) NLOHMANN_JSON_HEDLEY_HAS_CPP_ATTRIBUTE(attribute) -#if defined(HEDLEY_CLANG_HAS_BUILTIN) - #undef HEDLEY_CLANG_HAS_BUILTIN +#if defined(NLOHMANN_JSON_HEDLEY_CLANG_HAS_BUILTIN) + #undef NLOHMANN_JSON_HEDLEY_CLANG_HAS_BUILTIN #endif -#define HEDLEY_CLANG_HAS_BUILTIN(builtin) HEDLEY_HAS_BUILTIN(builtin) +#define NLOHMANN_JSON_HEDLEY_CLANG_HAS_BUILTIN(builtin) NLOHMANN_JSON_HEDLEY_HAS_BUILTIN(builtin) -#if defined(HEDLEY_CLANG_HAS_FEATURE) - #undef HEDLEY_CLANG_HAS_FEATURE +#if defined(NLOHMANN_JSON_HEDLEY_CLANG_HAS_FEATURE) + #undef NLOHMANN_JSON_HEDLEY_CLANG_HAS_FEATURE #endif -#define HEDLEY_CLANG_HAS_FEATURE(feature) HEDLEY_HAS_FEATURE(feature) +#define NLOHMANN_JSON_HEDLEY_CLANG_HAS_FEATURE(feature) NLOHMANN_JSON_HEDLEY_HAS_FEATURE(feature) -#if defined(HEDLEY_CLANG_HAS_EXTENSION) - #undef HEDLEY_CLANG_HAS_EXTENSION +#if defined(NLOHMANN_JSON_HEDLEY_CLANG_HAS_EXTENSION) + #undef NLOHMANN_JSON_HEDLEY_CLANG_HAS_EXTENSION #endif -#define HEDLEY_CLANG_HAS_EXTENSION(extension) HEDLEY_HAS_EXTENSION(extension) +#define NLOHMANN_JSON_HEDLEY_CLANG_HAS_EXTENSION(extension) NLOHMANN_JSON_HEDLEY_HAS_EXTENSION(extension) -#if defined(HEDLEY_CLANG_HAS_DECLSPEC_DECLSPEC_ATTRIBUTE) - #undef HEDLEY_CLANG_HAS_DECLSPEC_DECLSPEC_ATTRIBUTE +#if defined(NLOHMANN_JSON_HEDLEY_CLANG_HAS_DECLSPEC_DECLSPEC_ATTRIBUTE) + #undef NLOHMANN_JSON_HEDLEY_CLANG_HAS_DECLSPEC_DECLSPEC_ATTRIBUTE #endif -#define HEDLEY_CLANG_HAS_DECLSPEC_ATTRIBUTE(attribute) HEDLEY_HAS_DECLSPEC_ATTRIBUTE(attribute) +#define NLOHMANN_JSON_HEDLEY_CLANG_HAS_DECLSPEC_ATTRIBUTE(attribute) NLOHMANN_JSON_HEDLEY_HAS_DECLSPEC_ATTRIBUTE(attribute) -#if defined(HEDLEY_CLANG_HAS_WARNING) - #undef HEDLEY_CLANG_HAS_WARNING +#if defined(NLOHMANN_JSON_HEDLEY_CLANG_HAS_WARNING) + #undef NLOHMANN_JSON_HEDLEY_CLANG_HAS_WARNING #endif -#define HEDLEY_CLANG_HAS_WARNING(warning) HEDLEY_HAS_WARNING(warning) +#define NLOHMANN_JSON_HEDLEY_CLANG_HAS_WARNING(warning) NLOHMANN_JSON_HEDLEY_HAS_WARNING(warning) -#endif /* !defined(HEDLEY_VERSION) || (HEDLEY_VERSION < X) */ +#endif /* !defined(NLOHMANN_JSON_HEDLEY_VERSION) || (NLOHMANN_JSON_HEDLEY_VERSION < X) */ diff --git a/include/nlohmann/thirdparty/hedley/hedley_undef.hpp b/include/nlohmann/thirdparty/hedley/hedley_undef.hpp new file mode 100644 index 00000000..5458f064 --- /dev/null +++ b/include/nlohmann/thirdparty/hedley/hedley_undef.hpp @@ -0,0 +1,122 @@ +#undef NLOHMANN_JSON_HEDLEY_ALWAYS_INLINE +#undef NLOHMANN_JSON_HEDLEY_ARM_VERSION +#undef NLOHMANN_JSON_HEDLEY_ARM_VERSION_CHECK +#undef NLOHMANN_JSON_HEDLEY_ARRAY_PARAM +#undef NLOHMANN_JSON_HEDLEY_ASSUME +#undef NLOHMANN_JSON_HEDLEY_BEGIN_C_DECLS +#undef NLOHMANN_JSON_HEDLEY_CLANG_HAS_ATTRIBUTE +#undef NLOHMANN_JSON_HEDLEY_CLANG_HAS_BUILTIN +#undef NLOHMANN_JSON_HEDLEY_CLANG_HAS_CPP_ATTRIBUTE +#undef NLOHMANN_JSON_HEDLEY_CLANG_HAS_DECLSPEC_DECLSPEC_ATTRIBUTE +#undef NLOHMANN_JSON_HEDLEY_CLANG_HAS_EXTENSION +#undef NLOHMANN_JSON_HEDLEY_CLANG_HAS_FEATURE +#undef NLOHMANN_JSON_HEDLEY_CLANG_HAS_WARNING +#undef NLOHMANN_JSON_HEDLEY_COMPCERT_VERSION +#undef NLOHMANN_JSON_HEDLEY_COMPCERT_VERSION_CHECK +#undef NLOHMANN_JSON_HEDLEY_CONCAT +#undef NLOHMANN_JSON_HEDLEY_CONCAT_EX +#undef NLOHMANN_JSON_HEDLEY_CONST +#undef NLOHMANN_JSON_HEDLEY_CONSTEXPR +#undef NLOHMANN_JSON_HEDLEY_CONST_CAST +#undef NLOHMANN_JSON_HEDLEY_CPP_CAST +#undef NLOHMANN_JSON_HEDLEY_CRAY_VERSION +#undef NLOHMANN_JSON_HEDLEY_CRAY_VERSION_CHECK +#undef NLOHMANN_JSON_HEDLEY_C_DECL +#undef NLOHMANN_JSON_HEDLEY_DEPRECATED +#undef NLOHMANN_JSON_HEDLEY_DEPRECATED_FOR +#undef NLOHMANN_JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL +#undef NLOHMANN_JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED +#undef NLOHMANN_JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS +#undef NLOHMANN_JSON_HEDLEY_DIAGNOSTIC_POP +#undef NLOHMANN_JSON_HEDLEY_DIAGNOSTIC_PUSH +#undef NLOHMANN_JSON_HEDLEY_DMC_VERSION +#undef NLOHMANN_JSON_HEDLEY_DMC_VERSION_CHECK +#undef NLOHMANN_JSON_HEDLEY_EMSCRIPTEN_VERSION +#undef NLOHMANN_JSON_HEDLEY_EMSCRIPTEN_VERSION_CHECK +#undef NLOHMANN_JSON_HEDLEY_END_C_DECLS +#undef NLOHMANN_JSON_HEDLEY_FALL_THROUGH +#undef NLOHMANN_JSON_HEDLEY_FLAGS +#undef NLOHMANN_JSON_HEDLEY_FLAGS_CAST +#undef NLOHMANN_JSON_HEDLEY_GCC_HAS_ATTRIBUTE +#undef NLOHMANN_JSON_HEDLEY_GCC_HAS_BUILTIN +#undef NLOHMANN_JSON_HEDLEY_GCC_HAS_CPP_ATTRIBUTE +#undef NLOHMANN_JSON_HEDLEY_GCC_HAS_DECLSPEC_ATTRIBUTE +#undef NLOHMANN_JSON_HEDLEY_GCC_HAS_EXTENSION +#undef NLOHMANN_JSON_HEDLEY_GCC_HAS_FEATURE +#undef NLOHMANN_JSON_HEDLEY_GCC_HAS_WARNING +#undef NLOHMANN_JSON_HEDLEY_GCC_NOT_CLANG_VERSION_CHECK +#undef NLOHMANN_JSON_HEDLEY_GCC_VERSION +#undef NLOHMANN_JSON_HEDLEY_GCC_VERSION_CHECK +#undef NLOHMANN_JSON_HEDLEY_GNUC_HAS_ATTRIBUTE +#undef NLOHMANN_JSON_HEDLEY_GNUC_HAS_BUILTIN +#undef NLOHMANN_JSON_HEDLEY_GNUC_HAS_CPP_ATTRIBUTE +#undef NLOHMANN_JSON_HEDLEY_GNUC_HAS_DECLSPEC_ATTRIBUTE +#undef NLOHMANN_JSON_HEDLEY_GNUC_HAS_EXTENSION +#undef NLOHMANN_JSON_HEDLEY_GNUC_HAS_FEATURE +#undef NLOHMANN_JSON_HEDLEY_GNUC_HAS_WARNING +#undef NLOHMANN_JSON_HEDLEY_GNUC_VERSION +#undef NLOHMANN_JSON_HEDLEY_GNUC_VERSION_CHECK +#undef NLOHMANN_JSON_HEDLEY_HAS_ATTRIBUTE +#undef NLOHMANN_JSON_HEDLEY_HAS_BUILTIN +#undef NLOHMANN_JSON_HEDLEY_HAS_CPP_ATTRIBUTE +#undef NLOHMANN_JSON_HEDLEY_HAS_DECLSPEC_ATTRIBUTE +#undef NLOHMANN_JSON_HEDLEY_HAS_EXTENSION +#undef NLOHMANN_JSON_HEDLEY_HAS_FEATURE +#undef NLOHMANN_JSON_HEDLEY_HAS_WARNING +#undef NLOHMANN_JSON_HEDLEY_IAR_VERSION +#undef NLOHMANN_JSON_HEDLEY_IAR_VERSION_CHECK +#undef NLOHMANN_JSON_HEDLEY_IBM_VERSION +#undef NLOHMANN_JSON_HEDLEY_IBM_VERSION_CHECK +#undef NLOHMANN_JSON_HEDLEY_IMPORT +#undef NLOHMANN_JSON_HEDLEY_INLINE +#undef NLOHMANN_JSON_HEDLEY_INTEL_VERSION +#undef NLOHMANN_JSON_HEDLEY_INTEL_VERSION_CHECK +#undef NLOHMANN_JSON_HEDLEY_IS_CONSTANT +#undef NLOHMANN_JSON_HEDLEY_LIKELY +#undef NLOHMANN_JSON_HEDLEY_MALLOC +#undef NLOHMANN_JSON_HEDLEY_MESSAGE +#undef NLOHMANN_JSON_HEDLEY_MSVC_VERSION +#undef NLOHMANN_JSON_HEDLEY_MSVC_VERSION_CHECK +#undef NLOHMANN_JSON_HEDLEY_NEVER_INLINE +#undef NLOHMANN_JSON_HEDLEY_NON_NULL +#undef NLOHMANN_JSON_HEDLEY_NO_RETURN +#undef NLOHMANN_JSON_HEDLEY_NO_THROW +#undef NLOHMANN_JSON_HEDLEY_PELLES_VERSION +#undef NLOHMANN_JSON_HEDLEY_PELLES_VERSION_CHECK +#undef NLOHMANN_JSON_HEDLEY_PGI_VERSION +#undef NLOHMANN_JSON_HEDLEY_PGI_VERSION_CHECK +#undef NLOHMANN_JSON_HEDLEY_PREDICT +#undef NLOHMANN_JSON_HEDLEY_PRINTF_FORMAT +#undef NLOHMANN_JSON_HEDLEY_PRIVATE +#undef NLOHMANN_JSON_HEDLEY_PUBLIC +#undef NLOHMANN_JSON_HEDLEY_PURE +#undef NLOHMANN_JSON_HEDLEY_REINTERPRET_CAST +#undef NLOHMANN_JSON_HEDLEY_REQUIRE +#undef NLOHMANN_JSON_HEDLEY_REQUIRE_CONSTEXPR +#undef NLOHMANN_JSON_HEDLEY_REQUIRE_MSG +#undef NLOHMANN_JSON_HEDLEY_RESTRICT +#undef NLOHMANN_JSON_HEDLEY_RETURNS_NON_NULL +#undef NLOHMANN_JSON_HEDLEY_SENTINEL +#undef NLOHMANN_JSON_HEDLEY_STATIC_ASSERT +#undef NLOHMANN_JSON_HEDLEY_STATIC_CAST +#undef NLOHMANN_JSON_HEDLEY_STRINGIFY +#undef NLOHMANN_JSON_HEDLEY_STRINGIFY_EX +#undef NLOHMANN_JSON_HEDLEY_SUNPRO_VERSION +#undef NLOHMANN_JSON_HEDLEY_SUNPRO_VERSION_CHECK +#undef NLOHMANN_JSON_HEDLEY_TINYC_VERSION +#undef NLOHMANN_JSON_HEDLEY_TINYC_VERSION_CHECK +#undef NLOHMANN_JSON_HEDLEY_TI_VERSION +#undef NLOHMANN_JSON_HEDLEY_TI_VERSION_CHECK +#undef NLOHMANN_JSON_HEDLEY_UNAVAILABLE +#undef NLOHMANN_JSON_HEDLEY_UNLIKELY +#undef NLOHMANN_JSON_HEDLEY_UNPREDICTABLE +#undef NLOHMANN_JSON_HEDLEY_UNREACHABLE +#undef NLOHMANN_JSON_HEDLEY_UNREACHABLE_RETURN +#undef NLOHMANN_JSON_HEDLEY_VERSION +#undef NLOHMANN_JSON_HEDLEY_VERSION_DECODE_MAJOR +#undef NLOHMANN_JSON_HEDLEY_VERSION_DECODE_MINOR +#undef NLOHMANN_JSON_HEDLEY_VERSION_DECODE_REVISION +#undef NLOHMANN_JSON_HEDLEY_VERSION_ENCODE +#undef NLOHMANN_JSON_HEDLEY_WARNING +#undef NLOHMANN_JSON_HEDLEY_WARN_UNUSED_RESULT +#undef NLOHMANN_JSON_HEDLEY__IS_CONSTEXPR diff --git a/single_include/nlohmann/json.hpp b/single_include/nlohmann/json.hpp index 32ce6dff..73a53ffb 100644 --- a/single_include/nlohmann/json.hpp +++ b/single_include/nlohmann/json.hpp @@ -122,1257 +122,1257 @@ struct position_t * SPDX-License-Identifier: CC0-1.0 */ -#if !defined(HEDLEY_VERSION) || (HEDLEY_VERSION < 9) -#if defined(HEDLEY_VERSION) - #undef HEDLEY_VERSION +#if !defined(NLOHMANN_JSON_HEDLEY_VERSION) || (NLOHMANN_JSON_HEDLEY_VERSION < 9) +#if defined(NLOHMANN_JSON_HEDLEY_VERSION) + #undef NLOHMANN_JSON_HEDLEY_VERSION #endif -#define HEDLEY_VERSION 9 +#define NLOHMANN_JSON_HEDLEY_VERSION 9 -#if defined(HEDLEY_STRINGIFY_EX) - #undef HEDLEY_STRINGIFY_EX +#if defined(NLOHMANN_JSON_HEDLEY_STRINGIFY_EX) + #undef NLOHMANN_JSON_HEDLEY_STRINGIFY_EX #endif -#define HEDLEY_STRINGIFY_EX(x) #x +#define NLOHMANN_JSON_HEDLEY_STRINGIFY_EX(x) #x -#if defined(HEDLEY_STRINGIFY) - #undef HEDLEY_STRINGIFY +#if defined(NLOHMANN_JSON_HEDLEY_STRINGIFY) + #undef NLOHMANN_JSON_HEDLEY_STRINGIFY #endif -#define HEDLEY_STRINGIFY(x) HEDLEY_STRINGIFY_EX(x) +#define NLOHMANN_JSON_HEDLEY_STRINGIFY(x) NLOHMANN_JSON_HEDLEY_STRINGIFY_EX(x) -#if defined(HEDLEY_CONCAT_EX) - #undef HEDLEY_CONCAT_EX +#if defined(NLOHMANN_JSON_HEDLEY_CONCAT_EX) + #undef NLOHMANN_JSON_HEDLEY_CONCAT_EX #endif -#define HEDLEY_CONCAT_EX(a,b) a##b +#define NLOHMANN_JSON_HEDLEY_CONCAT_EX(a,b) a##b -#if defined(HEDLEY_CONCAT) - #undef HEDLEY_CONCAT +#if defined(NLOHMANN_JSON_HEDLEY_CONCAT) + #undef NLOHMANN_JSON_HEDLEY_CONCAT #endif -#define HEDLEY_CONCAT(a,b) HEDLEY_CONCAT_EX(a,b) +#define NLOHMANN_JSON_HEDLEY_CONCAT(a,b) NLOHMANN_JSON_HEDLEY_CONCAT_EX(a,b) -#if defined(HEDLEY_VERSION_ENCODE) - #undef HEDLEY_VERSION_ENCODE +#if defined(NLOHMANN_JSON_HEDLEY_VERSION_ENCODE) + #undef NLOHMANN_JSON_HEDLEY_VERSION_ENCODE #endif -#define HEDLEY_VERSION_ENCODE(major,minor,revision) (((major) * 1000000) + ((minor) * 1000) + (revision)) +#define NLOHMANN_JSON_HEDLEY_VERSION_ENCODE(major,minor,revision) (((major) * 1000000) + ((minor) * 1000) + (revision)) -#if defined(HEDLEY_VERSION_DECODE_MAJOR) - #undef HEDLEY_VERSION_DECODE_MAJOR +#if defined(NLOHMANN_JSON_HEDLEY_VERSION_DECODE_MAJOR) + #undef NLOHMANN_JSON_HEDLEY_VERSION_DECODE_MAJOR #endif -#define HEDLEY_VERSION_DECODE_MAJOR(version) ((version) / 1000000) +#define NLOHMANN_JSON_HEDLEY_VERSION_DECODE_MAJOR(version) ((version) / 1000000) -#if defined(HEDLEY_VERSION_DECODE_MINOR) - #undef HEDLEY_VERSION_DECODE_MINOR +#if defined(NLOHMANN_JSON_HEDLEY_VERSION_DECODE_MINOR) + #undef NLOHMANN_JSON_HEDLEY_VERSION_DECODE_MINOR #endif -#define HEDLEY_VERSION_DECODE_MINOR(version) (((version) % 1000000) / 1000) +#define NLOHMANN_JSON_HEDLEY_VERSION_DECODE_MINOR(version) (((version) % 1000000) / 1000) -#if defined(HEDLEY_VERSION_DECODE_REVISION) - #undef HEDLEY_VERSION_DECODE_REVISION +#if defined(NLOHMANN_JSON_HEDLEY_VERSION_DECODE_REVISION) + #undef NLOHMANN_JSON_HEDLEY_VERSION_DECODE_REVISION #endif -#define HEDLEY_VERSION_DECODE_REVISION(version) ((version) % 1000) +#define NLOHMANN_JSON_HEDLEY_VERSION_DECODE_REVISION(version) ((version) % 1000) -#if defined(HEDLEY_GNUC_VERSION) - #undef HEDLEY_GNUC_VERSION +#if defined(NLOHMANN_JSON_HEDLEY_GNUC_VERSION) + #undef NLOHMANN_JSON_HEDLEY_GNUC_VERSION #endif #if defined(__GNUC__) && defined(__GNUC_PATCHLEVEL__) - #define HEDLEY_GNUC_VERSION HEDLEY_VERSION_ENCODE(__GNUC__, __GNUC_MINOR__, __GNUC_PATCHLEVEL__) + #define NLOHMANN_JSON_HEDLEY_GNUC_VERSION NLOHMANN_JSON_HEDLEY_VERSION_ENCODE(__GNUC__, __GNUC_MINOR__, __GNUC_PATCHLEVEL__) #elif defined(__GNUC__) - #define HEDLEY_GNUC_VERSION HEDLEY_VERSION_ENCODE(__GNUC__, __GNUC_MINOR__, 0) + #define NLOHMANN_JSON_HEDLEY_GNUC_VERSION NLOHMANN_JSON_HEDLEY_VERSION_ENCODE(__GNUC__, __GNUC_MINOR__, 0) #endif -#if defined(HEDLEY_GNUC_VERSION_CHECK) - #undef HEDLEY_GNUC_VERSION_CHECK +#if defined(NLOHMANN_JSON_HEDLEY_GNUC_VERSION_CHECK) + #undef NLOHMANN_JSON_HEDLEY_GNUC_VERSION_CHECK #endif -#if defined(HEDLEY_GNUC_VERSION) - #define HEDLEY_GNUC_VERSION_CHECK(major,minor,patch) (HEDLEY_GNUC_VERSION >= HEDLEY_VERSION_ENCODE(major, minor, patch)) +#if defined(NLOHMANN_JSON_HEDLEY_GNUC_VERSION) + #define NLOHMANN_JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch) (NLOHMANN_JSON_HEDLEY_GNUC_VERSION >= NLOHMANN_JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) #else - #define HEDLEY_GNUC_VERSION_CHECK(major,minor,patch) (0) + #define NLOHMANN_JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch) (0) #endif -#if defined(HEDLEY_MSVC_VERSION) - #undef HEDLEY_MSVC_VERSION +#if defined(NLOHMANN_JSON_HEDLEY_MSVC_VERSION) + #undef NLOHMANN_JSON_HEDLEY_MSVC_VERSION #endif #if defined(_MSC_FULL_VER) && (_MSC_FULL_VER >= 140000000) - #define HEDLEY_MSVC_VERSION HEDLEY_VERSION_ENCODE(_MSC_FULL_VER / 10000000, (_MSC_FULL_VER % 10000000) / 100000, (_MSC_FULL_VER % 100000) / 100) + #define NLOHMANN_JSON_HEDLEY_MSVC_VERSION NLOHMANN_JSON_HEDLEY_VERSION_ENCODE(_MSC_FULL_VER / 10000000, (_MSC_FULL_VER % 10000000) / 100000, (_MSC_FULL_VER % 100000) / 100) #elif defined(_MSC_FULL_VER) - #define HEDLEY_MSVC_VERSION HEDLEY_VERSION_ENCODE(_MSC_FULL_VER / 1000000, (_MSC_FULL_VER % 1000000) / 10000, (_MSC_FULL_VER % 10000) / 10) + #define NLOHMANN_JSON_HEDLEY_MSVC_VERSION NLOHMANN_JSON_HEDLEY_VERSION_ENCODE(_MSC_FULL_VER / 1000000, (_MSC_FULL_VER % 1000000) / 10000, (_MSC_FULL_VER % 10000) / 10) #elif defined(_MSC_VER) - #define HEDLEY_MSVC_VERSION HEDLEY_VERSION_ENCODE(_MSC_VER / 100, _MSC_VER % 100, 0) + #define NLOHMANN_JSON_HEDLEY_MSVC_VERSION NLOHMANN_JSON_HEDLEY_VERSION_ENCODE(_MSC_VER / 100, _MSC_VER % 100, 0) #endif -#if defined(HEDLEY_MSVC_VERSION_CHECK) - #undef HEDLEY_MSVC_VERSION_CHECK +#if defined(NLOHMANN_JSON_HEDLEY_MSVC_VERSION_CHECK) + #undef NLOHMANN_JSON_HEDLEY_MSVC_VERSION_CHECK #endif #if !defined(_MSC_VER) - #define HEDLEY_MSVC_VERSION_CHECK(major,minor,patch) (0) + #define NLOHMANN_JSON_HEDLEY_MSVC_VERSION_CHECK(major,minor,patch) (0) #elif defined(_MSC_VER) && (_MSC_VER >= 1400) - #define HEDLEY_MSVC_VERSION_CHECK(major,minor,patch) (_MSC_FULL_VER >= ((major * 10000000) + (minor * 100000) + (patch))) + #define NLOHMANN_JSON_HEDLEY_MSVC_VERSION_CHECK(major,minor,patch) (_MSC_FULL_VER >= ((major * 10000000) + (minor * 100000) + (patch))) #elif defined(_MSC_VER) && (_MSC_VER >= 1200) - #define HEDLEY_MSVC_VERSION_CHECK(major,minor,patch) (_MSC_FULL_VER >= ((major * 1000000) + (minor * 10000) + (patch))) + #define NLOHMANN_JSON_HEDLEY_MSVC_VERSION_CHECK(major,minor,patch) (_MSC_FULL_VER >= ((major * 1000000) + (minor * 10000) + (patch))) #else - #define HEDLEY_MSVC_VERSION_CHECK(major,minor,patch) (_MSC_VER >= ((major * 100) + (minor))) + #define NLOHMANN_JSON_HEDLEY_MSVC_VERSION_CHECK(major,minor,patch) (_MSC_VER >= ((major * 100) + (minor))) #endif -#if defined(HEDLEY_INTEL_VERSION) - #undef HEDLEY_INTEL_VERSION +#if defined(NLOHMANN_JSON_HEDLEY_INTEL_VERSION) + #undef NLOHMANN_JSON_HEDLEY_INTEL_VERSION #endif #if defined(__INTEL_COMPILER) && defined(__INTEL_COMPILER_UPDATE) - #define HEDLEY_INTEL_VERSION HEDLEY_VERSION_ENCODE(__INTEL_COMPILER / 100, __INTEL_COMPILER % 100, __INTEL_COMPILER_UPDATE) + #define NLOHMANN_JSON_HEDLEY_INTEL_VERSION NLOHMANN_JSON_HEDLEY_VERSION_ENCODE(__INTEL_COMPILER / 100, __INTEL_COMPILER % 100, __INTEL_COMPILER_UPDATE) #elif defined(__INTEL_COMPILER) - #define HEDLEY_INTEL_VERSION HEDLEY_VERSION_ENCODE(__INTEL_COMPILER / 100, __INTEL_COMPILER % 100, 0) + #define NLOHMANN_JSON_HEDLEY_INTEL_VERSION NLOHMANN_JSON_HEDLEY_VERSION_ENCODE(__INTEL_COMPILER / 100, __INTEL_COMPILER % 100, 0) #endif -#if defined(HEDLEY_INTEL_VERSION_CHECK) - #undef HEDLEY_INTEL_VERSION_CHECK +#if defined(NLOHMANN_JSON_HEDLEY_INTEL_VERSION_CHECK) + #undef NLOHMANN_JSON_HEDLEY_INTEL_VERSION_CHECK #endif -#if defined(HEDLEY_INTEL_VERSION) - #define HEDLEY_INTEL_VERSION_CHECK(major,minor,patch) (HEDLEY_INTEL_VERSION >= HEDLEY_VERSION_ENCODE(major, minor, patch)) +#if defined(NLOHMANN_JSON_HEDLEY_INTEL_VERSION) + #define NLOHMANN_JSON_HEDLEY_INTEL_VERSION_CHECK(major,minor,patch) (NLOHMANN_JSON_HEDLEY_INTEL_VERSION >= NLOHMANN_JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) #else - #define HEDLEY_INTEL_VERSION_CHECK(major,minor,patch) (0) + #define NLOHMANN_JSON_HEDLEY_INTEL_VERSION_CHECK(major,minor,patch) (0) #endif -#if defined(HEDLEY_PGI_VERSION) - #undef HEDLEY_PGI_VERSION +#if defined(NLOHMANN_JSON_HEDLEY_PGI_VERSION) + #undef NLOHMANN_JSON_HEDLEY_PGI_VERSION #endif #if defined(__PGI) && defined(__PGIC__) && defined(__PGIC_MINOR__) && defined(__PGIC_PATCHLEVEL__) - #define HEDLEY_PGI_VERSION HEDLEY_VERSION_ENCODE(__PGIC__, __PGIC_MINOR__, __PGIC_PATCHLEVEL__) + #define NLOHMANN_JSON_HEDLEY_PGI_VERSION NLOHMANN_JSON_HEDLEY_VERSION_ENCODE(__PGIC__, __PGIC_MINOR__, __PGIC_PATCHLEVEL__) #endif -#if defined(HEDLEY_PGI_VERSION_CHECK) - #undef HEDLEY_PGI_VERSION_CHECK +#if defined(NLOHMANN_JSON_HEDLEY_PGI_VERSION_CHECK) + #undef NLOHMANN_JSON_HEDLEY_PGI_VERSION_CHECK #endif -#if defined(HEDLEY_PGI_VERSION) - #define HEDLEY_PGI_VERSION_CHECK(major,minor,patch) (HEDLEY_PGI_VERSION >= HEDLEY_VERSION_ENCODE(major, minor, patch)) +#if defined(NLOHMANN_JSON_HEDLEY_PGI_VERSION) + #define NLOHMANN_JSON_HEDLEY_PGI_VERSION_CHECK(major,minor,patch) (NLOHMANN_JSON_HEDLEY_PGI_VERSION >= NLOHMANN_JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) #else - #define HEDLEY_PGI_VERSION_CHECK(major,minor,patch) (0) + #define NLOHMANN_JSON_HEDLEY_PGI_VERSION_CHECK(major,minor,patch) (0) #endif -#if defined(HEDLEY_SUNPRO_VERSION) - #undef HEDLEY_SUNPRO_VERSION +#if defined(NLOHMANN_JSON_HEDLEY_SUNPRO_VERSION) + #undef NLOHMANN_JSON_HEDLEY_SUNPRO_VERSION #endif #if defined(__SUNPRO_C) && (__SUNPRO_C > 0x1000) - #define HEDLEY_SUNPRO_VERSION HEDLEY_VERSION_ENCODE((((__SUNPRO_C >> 16) & 0xf) * 10) + ((__SUNPRO_C >> 12) & 0xf), (((__SUNPRO_C >> 8) & 0xf) * 10) + ((__SUNPRO_C >> 4) & 0xf), (__SUNPRO_C & 0xf) * 10) + #define NLOHMANN_JSON_HEDLEY_SUNPRO_VERSION NLOHMANN_JSON_HEDLEY_VERSION_ENCODE((((__SUNPRO_C >> 16) & 0xf) * 10) + ((__SUNPRO_C >> 12) & 0xf), (((__SUNPRO_C >> 8) & 0xf) * 10) + ((__SUNPRO_C >> 4) & 0xf), (__SUNPRO_C & 0xf) * 10) #elif defined(__SUNPRO_C) - #define HEDLEY_SUNPRO_VERSION HEDLEY_VERSION_ENCODE((__SUNPRO_C >> 8) & 0xf, (__SUNPRO_C >> 4) & 0xf, (__SUNPRO_C) & 0xf) + #define NLOHMANN_JSON_HEDLEY_SUNPRO_VERSION NLOHMANN_JSON_HEDLEY_VERSION_ENCODE((__SUNPRO_C >> 8) & 0xf, (__SUNPRO_C >> 4) & 0xf, (__SUNPRO_C) & 0xf) #elif defined(__SUNPRO_CC) && (__SUNPRO_CC > 0x1000) - #define HEDLEY_SUNPRO_VERSION HEDLEY_VERSION_ENCODE((((__SUNPRO_CC >> 16) & 0xf) * 10) + ((__SUNPRO_CC >> 12) & 0xf), (((__SUNPRO_CC >> 8) & 0xf) * 10) + ((__SUNPRO_CC >> 4) & 0xf), (__SUNPRO_CC & 0xf) * 10) + #define NLOHMANN_JSON_HEDLEY_SUNPRO_VERSION NLOHMANN_JSON_HEDLEY_VERSION_ENCODE((((__SUNPRO_CC >> 16) & 0xf) * 10) + ((__SUNPRO_CC >> 12) & 0xf), (((__SUNPRO_CC >> 8) & 0xf) * 10) + ((__SUNPRO_CC >> 4) & 0xf), (__SUNPRO_CC & 0xf) * 10) #elif defined(__SUNPRO_CC) - #define HEDLEY_SUNPRO_VERSION HEDLEY_VERSION_ENCODE((__SUNPRO_CC >> 8) & 0xf, (__SUNPRO_CC >> 4) & 0xf, (__SUNPRO_CC) & 0xf) + #define NLOHMANN_JSON_HEDLEY_SUNPRO_VERSION NLOHMANN_JSON_HEDLEY_VERSION_ENCODE((__SUNPRO_CC >> 8) & 0xf, (__SUNPRO_CC >> 4) & 0xf, (__SUNPRO_CC) & 0xf) #endif -#if defined(HEDLEY_SUNPRO_VERSION_CHECK) - #undef HEDLEY_SUNPRO_VERSION_CHECK +#if defined(NLOHMANN_JSON_HEDLEY_SUNPRO_VERSION_CHECK) + #undef NLOHMANN_JSON_HEDLEY_SUNPRO_VERSION_CHECK #endif -#if defined(HEDLEY_SUNPRO_VERSION) - #define HEDLEY_SUNPRO_VERSION_CHECK(major,minor,patch) (HEDLEY_SUNPRO_VERSION >= HEDLEY_VERSION_ENCODE(major, minor, patch)) +#if defined(NLOHMANN_JSON_HEDLEY_SUNPRO_VERSION) + #define NLOHMANN_JSON_HEDLEY_SUNPRO_VERSION_CHECK(major,minor,patch) (NLOHMANN_JSON_HEDLEY_SUNPRO_VERSION >= NLOHMANN_JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) #else - #define HEDLEY_SUNPRO_VERSION_CHECK(major,minor,patch) (0) + #define NLOHMANN_JSON_HEDLEY_SUNPRO_VERSION_CHECK(major,minor,patch) (0) #endif -#if defined(HEDLEY_EMSCRIPTEN_VERSION) - #undef HEDLEY_EMSCRIPTEN_VERSION +#if defined(NLOHMANN_JSON_HEDLEY_EMSCRIPTEN_VERSION) + #undef NLOHMANN_JSON_HEDLEY_EMSCRIPTEN_VERSION #endif #if defined(__EMSCRIPTEN__) - #define HEDLEY_EMSCRIPTEN_VERSION HEDLEY_VERSION_ENCODE(__EMSCRIPTEN_major__, __EMSCRIPTEN_minor__, __EMSCRIPTEN_tiny__) + #define NLOHMANN_JSON_HEDLEY_EMSCRIPTEN_VERSION NLOHMANN_JSON_HEDLEY_VERSION_ENCODE(__EMSCRIPTEN_major__, __EMSCRIPTEN_minor__, __EMSCRIPTEN_tiny__) #endif -#if defined(HEDLEY_EMSCRIPTEN_VERSION_CHECK) - #undef HEDLEY_EMSCRIPTEN_VERSION_CHECK +#if defined(NLOHMANN_JSON_HEDLEY_EMSCRIPTEN_VERSION_CHECK) + #undef NLOHMANN_JSON_HEDLEY_EMSCRIPTEN_VERSION_CHECK #endif -#if defined(HEDLEY_EMSCRIPTEN_VERSION) - #define HEDLEY_EMSCRIPTEN_VERSION_CHECK(major,minor,patch) (HEDLEY_EMSCRIPTEN_VERSION >= HEDLEY_VERSION_ENCODE(major, minor, patch)) +#if defined(NLOHMANN_JSON_HEDLEY_EMSCRIPTEN_VERSION) + #define NLOHMANN_JSON_HEDLEY_EMSCRIPTEN_VERSION_CHECK(major,minor,patch) (NLOHMANN_JSON_HEDLEY_EMSCRIPTEN_VERSION >= NLOHMANN_JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) #else - #define HEDLEY_EMSCRIPTEN_VERSION_CHECK(major,minor,patch) (0) + #define NLOHMANN_JSON_HEDLEY_EMSCRIPTEN_VERSION_CHECK(major,minor,patch) (0) #endif -#if defined(HEDLEY_ARM_VERSION) - #undef HEDLEY_ARM_VERSION +#if defined(NLOHMANN_JSON_HEDLEY_ARM_VERSION) + #undef NLOHMANN_JSON_HEDLEY_ARM_VERSION #endif #if defined(__CC_ARM) && defined(__ARMCOMPILER_VERSION) - #define HEDLEY_ARM_VERSION HEDLEY_VERSION_ENCODE(__ARMCOMPILER_VERSION / 1000000, (__ARMCOMPILER_VERSION % 1000000) / 10000, (__ARMCOMPILER_VERSION % 10000) / 100) + #define NLOHMANN_JSON_HEDLEY_ARM_VERSION NLOHMANN_JSON_HEDLEY_VERSION_ENCODE(__ARMCOMPILER_VERSION / 1000000, (__ARMCOMPILER_VERSION % 1000000) / 10000, (__ARMCOMPILER_VERSION % 10000) / 100) #elif defined(__CC_ARM) && defined(__ARMCC_VERSION) - #define HEDLEY_ARM_VERSION HEDLEY_VERSION_ENCODE(__ARMCC_VERSION / 1000000, (__ARMCC_VERSION % 1000000) / 10000, (__ARMCC_VERSION % 10000) / 100) + #define NLOHMANN_JSON_HEDLEY_ARM_VERSION NLOHMANN_JSON_HEDLEY_VERSION_ENCODE(__ARMCC_VERSION / 1000000, (__ARMCC_VERSION % 1000000) / 10000, (__ARMCC_VERSION % 10000) / 100) #endif -#if defined(HEDLEY_ARM_VERSION_CHECK) - #undef HEDLEY_ARM_VERSION_CHECK +#if defined(NLOHMANN_JSON_HEDLEY_ARM_VERSION_CHECK) + #undef NLOHMANN_JSON_HEDLEY_ARM_VERSION_CHECK #endif -#if defined(HEDLEY_ARM_VERSION) - #define HEDLEY_ARM_VERSION_CHECK(major,minor,patch) (HEDLEY_ARM_VERSION >= HEDLEY_VERSION_ENCODE(major, minor, patch)) +#if defined(NLOHMANN_JSON_HEDLEY_ARM_VERSION) + #define NLOHMANN_JSON_HEDLEY_ARM_VERSION_CHECK(major,minor,patch) (NLOHMANN_JSON_HEDLEY_ARM_VERSION >= NLOHMANN_JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) #else - #define HEDLEY_ARM_VERSION_CHECK(major,minor,patch) (0) + #define NLOHMANN_JSON_HEDLEY_ARM_VERSION_CHECK(major,minor,patch) (0) #endif -#if defined(HEDLEY_IBM_VERSION) - #undef HEDLEY_IBM_VERSION +#if defined(NLOHMANN_JSON_HEDLEY_IBM_VERSION) + #undef NLOHMANN_JSON_HEDLEY_IBM_VERSION #endif #if defined(__ibmxl__) - #define HEDLEY_IBM_VERSION HEDLEY_VERSION_ENCODE(__ibmxl_version__, __ibmxl_release__, __ibmxl_modification__) + #define NLOHMANN_JSON_HEDLEY_IBM_VERSION NLOHMANN_JSON_HEDLEY_VERSION_ENCODE(__ibmxl_version__, __ibmxl_release__, __ibmxl_modification__) #elif defined(__xlC__) && defined(__xlC_ver__) - #define HEDLEY_IBM_VERSION HEDLEY_VERSION_ENCODE(__xlC__ >> 8, __xlC__ & 0xff, (__xlC_ver__ >> 8) & 0xff) + #define NLOHMANN_JSON_HEDLEY_IBM_VERSION NLOHMANN_JSON_HEDLEY_VERSION_ENCODE(__xlC__ >> 8, __xlC__ & 0xff, (__xlC_ver__ >> 8) & 0xff) #elif defined(__xlC__) - #define HEDLEY_IBM_VERSION HEDLEY_VERSION_ENCODE(__xlC__ >> 8, __xlC__ & 0xff, 0) + #define NLOHMANN_JSON_HEDLEY_IBM_VERSION NLOHMANN_JSON_HEDLEY_VERSION_ENCODE(__xlC__ >> 8, __xlC__ & 0xff, 0) #endif -#if defined(HEDLEY_IBM_VERSION_CHECK) - #undef HEDLEY_IBM_VERSION_CHECK +#if defined(NLOHMANN_JSON_HEDLEY_IBM_VERSION_CHECK) + #undef NLOHMANN_JSON_HEDLEY_IBM_VERSION_CHECK #endif -#if defined(HEDLEY_IBM_VERSION) - #define HEDLEY_IBM_VERSION_CHECK(major,minor,patch) (HEDLEY_IBM_VERSION >= HEDLEY_VERSION_ENCODE(major, minor, patch)) +#if defined(NLOHMANN_JSON_HEDLEY_IBM_VERSION) + #define NLOHMANN_JSON_HEDLEY_IBM_VERSION_CHECK(major,minor,patch) (NLOHMANN_JSON_HEDLEY_IBM_VERSION >= NLOHMANN_JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) #else - #define HEDLEY_IBM_VERSION_CHECK(major,minor,patch) (0) + #define NLOHMANN_JSON_HEDLEY_IBM_VERSION_CHECK(major,minor,patch) (0) #endif -#if defined(HEDLEY_TI_VERSION) - #undef HEDLEY_TI_VERSION +#if defined(NLOHMANN_JSON_HEDLEY_TI_VERSION) + #undef NLOHMANN_JSON_HEDLEY_TI_VERSION #endif #if defined(__TI_COMPILER_VERSION__) - #define HEDLEY_TI_VERSION HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000)) + #define NLOHMANN_JSON_HEDLEY_TI_VERSION NLOHMANN_JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000)) #endif -#if defined(HEDLEY_TI_VERSION_CHECK) - #undef HEDLEY_TI_VERSION_CHECK +#if defined(NLOHMANN_JSON_HEDLEY_TI_VERSION_CHECK) + #undef NLOHMANN_JSON_HEDLEY_TI_VERSION_CHECK #endif -#if defined(HEDLEY_TI_VERSION) - #define HEDLEY_TI_VERSION_CHECK(major,minor,patch) (HEDLEY_TI_VERSION >= HEDLEY_VERSION_ENCODE(major, minor, patch)) +#if defined(NLOHMANN_JSON_HEDLEY_TI_VERSION) + #define NLOHMANN_JSON_HEDLEY_TI_VERSION_CHECK(major,minor,patch) (NLOHMANN_JSON_HEDLEY_TI_VERSION >= NLOHMANN_JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) #else - #define HEDLEY_TI_VERSION_CHECK(major,minor,patch) (0) + #define NLOHMANN_JSON_HEDLEY_TI_VERSION_CHECK(major,minor,patch) (0) #endif -#if defined(HEDLEY_CRAY_VERSION) - #undef HEDLEY_CRAY_VERSION +#if defined(NLOHMANN_JSON_HEDLEY_CRAY_VERSION) + #undef NLOHMANN_JSON_HEDLEY_CRAY_VERSION #endif #if defined(_CRAYC) #if defined(_RELEASE_PATCHLEVEL) - #define HEDLEY_CRAY_VERSION HEDLEY_VERSION_ENCODE(_RELEASE_MAJOR, _RELEASE_MINOR, _RELEASE_PATCHLEVEL) + #define NLOHMANN_JSON_HEDLEY_CRAY_VERSION NLOHMANN_JSON_HEDLEY_VERSION_ENCODE(_RELEASE_MAJOR, _RELEASE_MINOR, _RELEASE_PATCHLEVEL) #else - #define HEDLEY_CRAY_VERSION HEDLEY_VERSION_ENCODE(_RELEASE_MAJOR, _RELEASE_MINOR, 0) + #define NLOHMANN_JSON_HEDLEY_CRAY_VERSION NLOHMANN_JSON_HEDLEY_VERSION_ENCODE(_RELEASE_MAJOR, _RELEASE_MINOR, 0) #endif #endif -#if defined(HEDLEY_CRAY_VERSION_CHECK) - #undef HEDLEY_CRAY_VERSION_CHECK +#if defined(NLOHMANN_JSON_HEDLEY_CRAY_VERSION_CHECK) + #undef NLOHMANN_JSON_HEDLEY_CRAY_VERSION_CHECK #endif -#if defined(HEDLEY_CRAY_VERSION) - #define HEDLEY_CRAY_VERSION_CHECK(major,minor,patch) (HEDLEY_CRAY_VERSION >= HEDLEY_VERSION_ENCODE(major, minor, patch)) +#if defined(NLOHMANN_JSON_HEDLEY_CRAY_VERSION) + #define NLOHMANN_JSON_HEDLEY_CRAY_VERSION_CHECK(major,minor,patch) (NLOHMANN_JSON_HEDLEY_CRAY_VERSION >= NLOHMANN_JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) #else - #define HEDLEY_CRAY_VERSION_CHECK(major,minor,patch) (0) + #define NLOHMANN_JSON_HEDLEY_CRAY_VERSION_CHECK(major,minor,patch) (0) #endif -#if defined(HEDLEY_IAR_VERSION) - #undef HEDLEY_IAR_VERSION +#if defined(NLOHMANN_JSON_HEDLEY_IAR_VERSION) + #undef NLOHMANN_JSON_HEDLEY_IAR_VERSION #endif #if defined(__IAR_SYSTEMS_ICC__) #if __VER__ > 1000 - #define HEDLEY_IAR_VERSION HEDLEY_VERSION_ENCODE((__VER__ / 1000000), ((__VER__ / 1000) % 1000), (__VER__ % 1000)) + #define NLOHMANN_JSON_HEDLEY_IAR_VERSION NLOHMANN_JSON_HEDLEY_VERSION_ENCODE((__VER__ / 1000000), ((__VER__ / 1000) % 1000), (__VER__ % 1000)) #else - #define HEDLEY_IAR_VERSION HEDLEY_VERSION_ENCODE(VER / 100, __VER__ % 100, 0) + #define NLOHMANN_JSON_HEDLEY_IAR_VERSION NLOHMANN_JSON_HEDLEY_VERSION_ENCODE(VER / 100, __VER__ % 100, 0) #endif #endif -#if defined(HEDLEY_IAR_VERSION_CHECK) - #undef HEDLEY_IAR_VERSION_CHECK +#if defined(NLOHMANN_JSON_HEDLEY_IAR_VERSION_CHECK) + #undef NLOHMANN_JSON_HEDLEY_IAR_VERSION_CHECK #endif -#if defined(HEDLEY_IAR_VERSION) - #define HEDLEY_IAR_VERSION_CHECK(major,minor,patch) (HEDLEY_IAR_VERSION >= HEDLEY_VERSION_ENCODE(major, minor, patch)) +#if defined(NLOHMANN_JSON_HEDLEY_IAR_VERSION) + #define NLOHMANN_JSON_HEDLEY_IAR_VERSION_CHECK(major,minor,patch) (NLOHMANN_JSON_HEDLEY_IAR_VERSION >= NLOHMANN_JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) #else - #define HEDLEY_IAR_VERSION_CHECK(major,minor,patch) (0) + #define NLOHMANN_JSON_HEDLEY_IAR_VERSION_CHECK(major,minor,patch) (0) #endif -#if defined(HEDLEY_TINYC_VERSION) - #undef HEDLEY_TINYC_VERSION +#if defined(NLOHMANN_JSON_HEDLEY_TINYC_VERSION) + #undef NLOHMANN_JSON_HEDLEY_TINYC_VERSION #endif #if defined(__TINYC__) - #define HEDLEY_TINYC_VERSION HEDLEY_VERSION_ENCODE(__TINYC__ / 1000, (__TINYC__ / 100) % 10, __TINYC__ % 100) + #define NLOHMANN_JSON_HEDLEY_TINYC_VERSION NLOHMANN_JSON_HEDLEY_VERSION_ENCODE(__TINYC__ / 1000, (__TINYC__ / 100) % 10, __TINYC__ % 100) #endif -#if defined(HEDLEY_TINYC_VERSION_CHECK) - #undef HEDLEY_TINYC_VERSION_CHECK +#if defined(NLOHMANN_JSON_HEDLEY_TINYC_VERSION_CHECK) + #undef NLOHMANN_JSON_HEDLEY_TINYC_VERSION_CHECK #endif -#if defined(HEDLEY_TINYC_VERSION) - #define HEDLEY_TINYC_VERSION_CHECK(major,minor,patch) (HEDLEY_TINYC_VERSION >= HEDLEY_VERSION_ENCODE(major, minor, patch)) +#if defined(NLOHMANN_JSON_HEDLEY_TINYC_VERSION) + #define NLOHMANN_JSON_HEDLEY_TINYC_VERSION_CHECK(major,minor,patch) (NLOHMANN_JSON_HEDLEY_TINYC_VERSION >= NLOHMANN_JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) #else - #define HEDLEY_TINYC_VERSION_CHECK(major,minor,patch) (0) + #define NLOHMANN_JSON_HEDLEY_TINYC_VERSION_CHECK(major,minor,patch) (0) #endif -#if defined(HEDLEY_DMC_VERSION) - #undef HEDLEY_DMC_VERSION +#if defined(NLOHMANN_JSON_HEDLEY_DMC_VERSION) + #undef NLOHMANN_JSON_HEDLEY_DMC_VERSION #endif #if defined(__DMC__) - #define HEDLEY_DMC_VERSION HEDLEY_VERSION_ENCODE(__DMC__ >> 8, (__DMC__ >> 4) & 0xf, __DMC__ & 0xf) + #define NLOHMANN_JSON_HEDLEY_DMC_VERSION NLOHMANN_JSON_HEDLEY_VERSION_ENCODE(__DMC__ >> 8, (__DMC__ >> 4) & 0xf, __DMC__ & 0xf) #endif -#if defined(HEDLEY_DMC_VERSION_CHECK) - #undef HEDLEY_DMC_VERSION_CHECK +#if defined(NLOHMANN_JSON_HEDLEY_DMC_VERSION_CHECK) + #undef NLOHMANN_JSON_HEDLEY_DMC_VERSION_CHECK #endif -#if defined(HEDLEY_DMC_VERSION) - #define HEDLEY_DMC_VERSION_CHECK(major,minor,patch) (HEDLEY_DMC_VERSION >= HEDLEY_VERSION_ENCODE(major, minor, patch)) +#if defined(NLOHMANN_JSON_HEDLEY_DMC_VERSION) + #define NLOHMANN_JSON_HEDLEY_DMC_VERSION_CHECK(major,minor,patch) (NLOHMANN_JSON_HEDLEY_DMC_VERSION >= NLOHMANN_JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) #else - #define HEDLEY_DMC_VERSION_CHECK(major,minor,patch) (0) + #define NLOHMANN_JSON_HEDLEY_DMC_VERSION_CHECK(major,minor,patch) (0) #endif -#if defined(HEDLEY_COMPCERT_VERSION) - #undef HEDLEY_COMPCERT_VERSION +#if defined(NLOHMANN_JSON_HEDLEY_COMPCERT_VERSION) + #undef NLOHMANN_JSON_HEDLEY_COMPCERT_VERSION #endif #if defined(__COMPCERT_VERSION__) - #define HEDLEY_COMPCERT_VERSION HEDLEY_VERSION_ENCODE(__COMPCERT_VERSION__ / 10000, (__COMPCERT_VERSION__ / 100) % 100, __COMPCERT_VERSION__ % 100) + #define NLOHMANN_JSON_HEDLEY_COMPCERT_VERSION NLOHMANN_JSON_HEDLEY_VERSION_ENCODE(__COMPCERT_VERSION__ / 10000, (__COMPCERT_VERSION__ / 100) % 100, __COMPCERT_VERSION__ % 100) #endif -#if defined(HEDLEY_COMPCERT_VERSION_CHECK) - #undef HEDLEY_COMPCERT_VERSION_CHECK +#if defined(NLOHMANN_JSON_HEDLEY_COMPCERT_VERSION_CHECK) + #undef NLOHMANN_JSON_HEDLEY_COMPCERT_VERSION_CHECK #endif -#if defined(HEDLEY_COMPCERT_VERSION) - #define HEDLEY_COMPCERT_VERSION_CHECK(major,minor,patch) (HEDLEY_COMPCERT_VERSION >= HEDLEY_VERSION_ENCODE(major, minor, patch)) +#if defined(NLOHMANN_JSON_HEDLEY_COMPCERT_VERSION) + #define NLOHMANN_JSON_HEDLEY_COMPCERT_VERSION_CHECK(major,minor,patch) (NLOHMANN_JSON_HEDLEY_COMPCERT_VERSION >= NLOHMANN_JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) #else - #define HEDLEY_COMPCERT_VERSION_CHECK(major,minor,patch) (0) + #define NLOHMANN_JSON_HEDLEY_COMPCERT_VERSION_CHECK(major,minor,patch) (0) #endif -#if defined(HEDLEY_PELLES_VERSION) - #undef HEDLEY_PELLES_VERSION +#if defined(NLOHMANN_JSON_HEDLEY_PELLES_VERSION) + #undef NLOHMANN_JSON_HEDLEY_PELLES_VERSION #endif #if defined(__POCC__) - #define HEDLEY_PELLES_VERSION HEDLEY_VERSION_ENCODE(__POCC__ / 100, __POCC__ % 100, 0) + #define NLOHMANN_JSON_HEDLEY_PELLES_VERSION NLOHMANN_JSON_HEDLEY_VERSION_ENCODE(__POCC__ / 100, __POCC__ % 100, 0) #endif -#if defined(HEDLEY_PELLES_VERSION_CHECK) - #undef HEDLEY_PELLES_VERSION_CHECK +#if defined(NLOHMANN_JSON_HEDLEY_PELLES_VERSION_CHECK) + #undef NLOHMANN_JSON_HEDLEY_PELLES_VERSION_CHECK #endif -#if defined(HEDLEY_PELLES_VERSION) - #define HEDLEY_PELLES_VERSION_CHECK(major,minor,patch) (HEDLEY_PELLES_VERSION >= HEDLEY_VERSION_ENCODE(major, minor, patch)) +#if defined(NLOHMANN_JSON_HEDLEY_PELLES_VERSION) + #define NLOHMANN_JSON_HEDLEY_PELLES_VERSION_CHECK(major,minor,patch) (NLOHMANN_JSON_HEDLEY_PELLES_VERSION >= NLOHMANN_JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) #else - #define HEDLEY_PELLES_VERSION_CHECK(major,minor,patch) (0) + #define NLOHMANN_JSON_HEDLEY_PELLES_VERSION_CHECK(major,minor,patch) (0) #endif -#if defined(HEDLEY_GCC_VERSION) - #undef HEDLEY_GCC_VERSION +#if defined(NLOHMANN_JSON_HEDLEY_GCC_VERSION) + #undef NLOHMANN_JSON_HEDLEY_GCC_VERSION #endif #if \ - defined(HEDLEY_GNUC_VERSION) && \ + defined(NLOHMANN_JSON_HEDLEY_GNUC_VERSION) && \ !defined(__clang__) && \ - !defined(HEDLEY_INTEL_VERSION) && \ - !defined(HEDLEY_PGI_VERSION) && \ - !defined(HEDLEY_ARM_VERSION) && \ - !defined(HEDLEY_TI_VERSION) && \ + !defined(NLOHMANN_JSON_HEDLEY_INTEL_VERSION) && \ + !defined(NLOHMANN_JSON_HEDLEY_PGI_VERSION) && \ + !defined(NLOHMANN_JSON_HEDLEY_ARM_VERSION) && \ + !defined(NLOHMANN_JSON_HEDLEY_TI_VERSION) && \ !defined(__COMPCERT__) - #define HEDLEY_GCC_VERSION HEDLEY_GNUC_VERSION + #define NLOHMANN_JSON_HEDLEY_GCC_VERSION NLOHMANN_JSON_HEDLEY_GNUC_VERSION #endif -#if defined(HEDLEY_GCC_VERSION_CHECK) - #undef HEDLEY_GCC_VERSION_CHECK +#if defined(NLOHMANN_JSON_HEDLEY_GCC_VERSION_CHECK) + #undef NLOHMANN_JSON_HEDLEY_GCC_VERSION_CHECK #endif -#if defined(HEDLEY_GCC_VERSION) - #define HEDLEY_GCC_VERSION_CHECK(major,minor,patch) (HEDLEY_GCC_VERSION >= HEDLEY_VERSION_ENCODE(major, minor, patch)) +#if defined(NLOHMANN_JSON_HEDLEY_GCC_VERSION) + #define NLOHMANN_JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch) (NLOHMANN_JSON_HEDLEY_GCC_VERSION >= NLOHMANN_JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) #else - #define HEDLEY_GCC_VERSION_CHECK(major,minor,patch) (0) + #define NLOHMANN_JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch) (0) #endif -#if defined(HEDLEY_HAS_ATTRIBUTE) - #undef HEDLEY_HAS_ATTRIBUTE +#if defined(NLOHMANN_JSON_HEDLEY_HAS_ATTRIBUTE) + #undef NLOHMANN_JSON_HEDLEY_HAS_ATTRIBUTE #endif #if defined(__has_attribute) - #define HEDLEY_HAS_ATTRIBUTE(attribute) __has_attribute(attribute) + #define NLOHMANN_JSON_HEDLEY_HAS_ATTRIBUTE(attribute) __has_attribute(attribute) #else - #define HEDLEY_HAS_ATTRIBUTE(attribute) (0) + #define NLOHMANN_JSON_HEDLEY_HAS_ATTRIBUTE(attribute) (0) #endif -#if defined(HEDLEY_GNUC_HAS_ATTRIBUTE) - #undef HEDLEY_GNUC_HAS_ATTRIBUTE +#if defined(NLOHMANN_JSON_HEDLEY_GNUC_HAS_ATTRIBUTE) + #undef NLOHMANN_JSON_HEDLEY_GNUC_HAS_ATTRIBUTE #endif #if defined(__has_attribute) - #define HEDLEY_GNUC_HAS_ATTRIBUTE(attribute,major,minor,patch) __has_attribute(attribute) + #define NLOHMANN_JSON_HEDLEY_GNUC_HAS_ATTRIBUTE(attribute,major,minor,patch) __has_attribute(attribute) #else - #define HEDLEY_GNUC_HAS_ATTRIBUTE(attribute,major,minor,patch) HEDLEY_GNUC_VERSION_CHECK(major,minor,patch) + #define NLOHMANN_JSON_HEDLEY_GNUC_HAS_ATTRIBUTE(attribute,major,minor,patch) NLOHMANN_JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch) #endif -#if defined(HEDLEY_GCC_HAS_ATTRIBUTE) - #undef HEDLEY_GCC_HAS_ATTRIBUTE +#if defined(NLOHMANN_JSON_HEDLEY_GCC_HAS_ATTRIBUTE) + #undef NLOHMANN_JSON_HEDLEY_GCC_HAS_ATTRIBUTE #endif #if defined(__has_attribute) - #define HEDLEY_GCC_HAS_ATTRIBUTE(attribute,major,minor,patch) __has_attribute(attribute) + #define NLOHMANN_JSON_HEDLEY_GCC_HAS_ATTRIBUTE(attribute,major,minor,patch) __has_attribute(attribute) #else - #define HEDLEY_GCC_HAS_ATTRIBUTE(attribute,major,minor,patch) HEDLEY_GCC_VERSION_CHECK(major,minor,patch) + #define NLOHMANN_JSON_HEDLEY_GCC_HAS_ATTRIBUTE(attribute,major,minor,patch) NLOHMANN_JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch) #endif -#if defined(HEDLEY_HAS_CPP_ATTRIBUTE) - #undef HEDLEY_HAS_CPP_ATTRIBUTE +#if defined(NLOHMANN_JSON_HEDLEY_HAS_CPP_ATTRIBUTE) + #undef NLOHMANN_JSON_HEDLEY_HAS_CPP_ATTRIBUTE #endif #if defined(__has_cpp_attribute) && defined(__cplusplus) - #define HEDLEY_HAS_CPP_ATTRIBUTE(attribute) __has_cpp_attribute(attribute) + #define NLOHMANN_JSON_HEDLEY_HAS_CPP_ATTRIBUTE(attribute) __has_cpp_attribute(attribute) #else - #define HEDLEY_HAS_CPP_ATTRIBUTE(attribute) (0) + #define NLOHMANN_JSON_HEDLEY_HAS_CPP_ATTRIBUTE(attribute) (0) #endif -#if defined(HEDLEY_GNUC_HAS_CPP_ATTRIBUTE) - #undef HEDLEY_GNUC_HAS_CPP_ATTRIBUTE +#if defined(NLOHMANN_JSON_HEDLEY_GNUC_HAS_CPP_ATTRIBUTE) + #undef NLOHMANN_JSON_HEDLEY_GNUC_HAS_CPP_ATTRIBUTE #endif #if defined(__has_cpp_attribute) && defined(__cplusplus) - #define HEDLEY_GNUC_HAS_CPP_ATTRIBUTE(attribute,major,minor,patch) __has_cpp_attribute(attribute) + #define NLOHMANN_JSON_HEDLEY_GNUC_HAS_CPP_ATTRIBUTE(attribute,major,minor,patch) __has_cpp_attribute(attribute) #else - #define HEDLEY_GNUC_HAS_CPP_ATTRIBUTE(attribute,major,minor,patch) HEDLEY_GNUC_VERSION_CHECK(major,minor,patch) + #define NLOHMANN_JSON_HEDLEY_GNUC_HAS_CPP_ATTRIBUTE(attribute,major,minor,patch) NLOHMANN_JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch) #endif -#if defined(HEDLEY_GCC_HAS_CPP_ATTRIBUTE) - #undef HEDLEY_GCC_HAS_CPP_ATTRIBUTE +#if defined(NLOHMANN_JSON_HEDLEY_GCC_HAS_CPP_ATTRIBUTE) + #undef NLOHMANN_JSON_HEDLEY_GCC_HAS_CPP_ATTRIBUTE #endif #if defined(__has_cpp_attribute) && defined(__cplusplus) - #define HEDLEY_GCC_HAS_CPP_ATTRIBUTE(attribute,major,minor,patch) __has_cpp_attribute(attribute) + #define NLOHMANN_JSON_HEDLEY_GCC_HAS_CPP_ATTRIBUTE(attribute,major,minor,patch) __has_cpp_attribute(attribute) #else - #define HEDLEY_GCC_HAS_CPP_ATTRIBUTE(attribute,major,minor,patch) HEDLEY_GCC_VERSION_CHECK(major,minor,patch) + #define NLOHMANN_JSON_HEDLEY_GCC_HAS_CPP_ATTRIBUTE(attribute,major,minor,patch) NLOHMANN_JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch) #endif -#if defined(HEDLEY_HAS_BUILTIN) - #undef HEDLEY_HAS_BUILTIN +#if defined(NLOHMANN_JSON_HEDLEY_HAS_BUILTIN) + #undef NLOHMANN_JSON_HEDLEY_HAS_BUILTIN #endif #if defined(__has_builtin) - #define HEDLEY_HAS_BUILTIN(builtin) __has_builtin(builtin) + #define NLOHMANN_JSON_HEDLEY_HAS_BUILTIN(builtin) __has_builtin(builtin) #else - #define HEDLEY_HAS_BUILTIN(builtin) (0) + #define NLOHMANN_JSON_HEDLEY_HAS_BUILTIN(builtin) (0) #endif -#if defined(HEDLEY_GNUC_HAS_BUILTIN) - #undef HEDLEY_GNUC_HAS_BUILTIN +#if defined(NLOHMANN_JSON_HEDLEY_GNUC_HAS_BUILTIN) + #undef NLOHMANN_JSON_HEDLEY_GNUC_HAS_BUILTIN #endif #if defined(__has_builtin) - #define HEDLEY_GNUC_HAS_BUILTIN(builtin,major,minor,patch) __has_builtin(builtin) + #define NLOHMANN_JSON_HEDLEY_GNUC_HAS_BUILTIN(builtin,major,minor,patch) __has_builtin(builtin) #else - #define HEDLEY_GNUC_HAS_BUILTIN(builtin,major,minor,patch) HEDLEY_GNUC_VERSION_CHECK(major,minor,patch) + #define NLOHMANN_JSON_HEDLEY_GNUC_HAS_BUILTIN(builtin,major,minor,patch) NLOHMANN_JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch) #endif -#if defined(HEDLEY_GCC_HAS_BUILTIN) - #undef HEDLEY_GCC_HAS_BUILTIN +#if defined(NLOHMANN_JSON_HEDLEY_GCC_HAS_BUILTIN) + #undef NLOHMANN_JSON_HEDLEY_GCC_HAS_BUILTIN #endif #if defined(__has_builtin) - #define HEDLEY_GCC_HAS_BUILTIN(builtin,major,minor,patch) __has_builtin(builtin) + #define NLOHMANN_JSON_HEDLEY_GCC_HAS_BUILTIN(builtin,major,minor,patch) __has_builtin(builtin) #else - #define HEDLEY_GCC_HAS_BUILTIN(builtin,major,minor,patch) HEDLEY_GCC_VERSION_CHECK(major,minor,patch) + #define NLOHMANN_JSON_HEDLEY_GCC_HAS_BUILTIN(builtin,major,minor,patch) NLOHMANN_JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch) #endif -#if defined(HEDLEY_HAS_FEATURE) - #undef HEDLEY_HAS_FEATURE +#if defined(NLOHMANN_JSON_HEDLEY_HAS_FEATURE) + #undef NLOHMANN_JSON_HEDLEY_HAS_FEATURE #endif #if defined(__has_feature) - #define HEDLEY_HAS_FEATURE(feature) __has_feature(feature) + #define NLOHMANN_JSON_HEDLEY_HAS_FEATURE(feature) __has_feature(feature) #else - #define HEDLEY_HAS_FEATURE(feature) (0) + #define NLOHMANN_JSON_HEDLEY_HAS_FEATURE(feature) (0) #endif -#if defined(HEDLEY_GNUC_HAS_FEATURE) - #undef HEDLEY_GNUC_HAS_FEATURE +#if defined(NLOHMANN_JSON_HEDLEY_GNUC_HAS_FEATURE) + #undef NLOHMANN_JSON_HEDLEY_GNUC_HAS_FEATURE #endif #if defined(__has_feature) - #define HEDLEY_GNUC_HAS_FEATURE(feature,major,minor,patch) __has_feature(feature) + #define NLOHMANN_JSON_HEDLEY_GNUC_HAS_FEATURE(feature,major,minor,patch) __has_feature(feature) #else - #define HEDLEY_GNUC_HAS_FEATURE(feature,major,minor,patch) HEDLEY_GNUC_VERSION_CHECK(major,minor,patch) + #define NLOHMANN_JSON_HEDLEY_GNUC_HAS_FEATURE(feature,major,minor,patch) NLOHMANN_JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch) #endif -#if defined(HEDLEY_GCC_HAS_FEATURE) - #undef HEDLEY_GCC_HAS_FEATURE +#if defined(NLOHMANN_JSON_HEDLEY_GCC_HAS_FEATURE) + #undef NLOHMANN_JSON_HEDLEY_GCC_HAS_FEATURE #endif #if defined(__has_feature) - #define HEDLEY_GCC_HAS_FEATURE(feature,major,minor,patch) __has_feature(feature) + #define NLOHMANN_JSON_HEDLEY_GCC_HAS_FEATURE(feature,major,minor,patch) __has_feature(feature) #else - #define HEDLEY_GCC_HAS_FEATURE(feature,major,minor,patch) HEDLEY_GCC_VERSION_CHECK(major,minor,patch) + #define NLOHMANN_JSON_HEDLEY_GCC_HAS_FEATURE(feature,major,minor,patch) NLOHMANN_JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch) #endif -#if defined(HEDLEY_HAS_EXTENSION) - #undef HEDLEY_HAS_EXTENSION +#if defined(NLOHMANN_JSON_HEDLEY_HAS_EXTENSION) + #undef NLOHMANN_JSON_HEDLEY_HAS_EXTENSION #endif #if defined(__has_extension) - #define HEDLEY_HAS_EXTENSION(extension) __has_extension(extension) + #define NLOHMANN_JSON_HEDLEY_HAS_EXTENSION(extension) __has_extension(extension) #else - #define HEDLEY_HAS_EXTENSION(extension) (0) + #define NLOHMANN_JSON_HEDLEY_HAS_EXTENSION(extension) (0) #endif -#if defined(HEDLEY_GNUC_HAS_EXTENSION) - #undef HEDLEY_GNUC_HAS_EXTENSION +#if defined(NLOHMANN_JSON_HEDLEY_GNUC_HAS_EXTENSION) + #undef NLOHMANN_JSON_HEDLEY_GNUC_HAS_EXTENSION #endif #if defined(__has_extension) - #define HEDLEY_GNUC_HAS_EXTENSION(extension,major,minor,patch) __has_extension(extension) + #define NLOHMANN_JSON_HEDLEY_GNUC_HAS_EXTENSION(extension,major,minor,patch) __has_extension(extension) #else - #define HEDLEY_GNUC_HAS_EXTENSION(extension,major,minor,patch) HEDLEY_GNUC_VERSION_CHECK(major,minor,patch) + #define NLOHMANN_JSON_HEDLEY_GNUC_HAS_EXTENSION(extension,major,minor,patch) NLOHMANN_JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch) #endif -#if defined(HEDLEY_GCC_HAS_EXTENSION) - #undef HEDLEY_GCC_HAS_EXTENSION +#if defined(NLOHMANN_JSON_HEDLEY_GCC_HAS_EXTENSION) + #undef NLOHMANN_JSON_HEDLEY_GCC_HAS_EXTENSION #endif #if defined(__has_extension) - #define HEDLEY_GCC_HAS_EXTENSION(extension,major,minor,patch) __has_extension(extension) + #define NLOHMANN_JSON_HEDLEY_GCC_HAS_EXTENSION(extension,major,minor,patch) __has_extension(extension) #else - #define HEDLEY_GCC_HAS_EXTENSION(extension,major,minor,patch) HEDLEY_GCC_VERSION_CHECK(major,minor,patch) + #define NLOHMANN_JSON_HEDLEY_GCC_HAS_EXTENSION(extension,major,minor,patch) NLOHMANN_JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch) #endif -#if defined(HEDLEY_HAS_DECLSPEC_ATTRIBUTE) - #undef HEDLEY_HAS_DECLSPEC_ATTRIBUTE +#if defined(NLOHMANN_JSON_HEDLEY_HAS_DECLSPEC_ATTRIBUTE) + #undef NLOHMANN_JSON_HEDLEY_HAS_DECLSPEC_ATTRIBUTE #endif #if defined(__has_declspec_attribute) - #define HEDLEY_HAS_DECLSPEC_ATTRIBUTE(attribute) __has_declspec_attribute(attribute) + #define NLOHMANN_JSON_HEDLEY_HAS_DECLSPEC_ATTRIBUTE(attribute) __has_declspec_attribute(attribute) #else - #define HEDLEY_HAS_DECLSPEC_ATTRIBUTE(attribute) (0) + #define NLOHMANN_JSON_HEDLEY_HAS_DECLSPEC_ATTRIBUTE(attribute) (0) #endif -#if defined(HEDLEY_GNUC_HAS_DECLSPEC_ATTRIBUTE) - #undef HEDLEY_GNUC_HAS_DECLSPEC_ATTRIBUTE +#if defined(NLOHMANN_JSON_HEDLEY_GNUC_HAS_DECLSPEC_ATTRIBUTE) + #undef NLOHMANN_JSON_HEDLEY_GNUC_HAS_DECLSPEC_ATTRIBUTE #endif #if defined(__has_declspec_attribute) - #define HEDLEY_GNUC_HAS_DECLSPEC_ATTRIBUTE(attribute,major,minor,patch) __has_declspec_attribute(attribute) + #define NLOHMANN_JSON_HEDLEY_GNUC_HAS_DECLSPEC_ATTRIBUTE(attribute,major,minor,patch) __has_declspec_attribute(attribute) #else - #define HEDLEY_GNUC_HAS_DECLSPEC_ATTRIBUTE(attribute,major,minor,patch) HEDLEY_GNUC_VERSION_CHECK(major,minor,patch) + #define NLOHMANN_JSON_HEDLEY_GNUC_HAS_DECLSPEC_ATTRIBUTE(attribute,major,minor,patch) NLOHMANN_JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch) #endif -#if defined(HEDLEY_GCC_HAS_DECLSPEC_ATTRIBUTE) - #undef HEDLEY_GCC_HAS_DECLSPEC_ATTRIBUTE +#if defined(NLOHMANN_JSON_HEDLEY_GCC_HAS_DECLSPEC_ATTRIBUTE) + #undef NLOHMANN_JSON_HEDLEY_GCC_HAS_DECLSPEC_ATTRIBUTE #endif #if defined(__has_declspec_attribute) - #define HEDLEY_GCC_HAS_DECLSPEC_ATTRIBUTE(attribute,major,minor,patch) __has_declspec_attribute(attribute) + #define NLOHMANN_JSON_HEDLEY_GCC_HAS_DECLSPEC_ATTRIBUTE(attribute,major,minor,patch) __has_declspec_attribute(attribute) #else - #define HEDLEY_GCC_HAS_DECLSPEC_ATTRIBUTE(attribute,major,minor,patch) HEDLEY_GCC_VERSION_CHECK(major,minor,patch) + #define NLOHMANN_JSON_HEDLEY_GCC_HAS_DECLSPEC_ATTRIBUTE(attribute,major,minor,patch) NLOHMANN_JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch) #endif -#if defined(HEDLEY_HAS_WARNING) - #undef HEDLEY_HAS_WARNING +#if defined(NLOHMANN_JSON_HEDLEY_HAS_WARNING) + #undef NLOHMANN_JSON_HEDLEY_HAS_WARNING #endif #if defined(__has_warning) - #define HEDLEY_HAS_WARNING(warning) __has_warning(warning) + #define NLOHMANN_JSON_HEDLEY_HAS_WARNING(warning) __has_warning(warning) #else - #define HEDLEY_HAS_WARNING(warning) (0) + #define NLOHMANN_JSON_HEDLEY_HAS_WARNING(warning) (0) #endif -#if defined(HEDLEY_GNUC_HAS_WARNING) - #undef HEDLEY_GNUC_HAS_WARNING +#if defined(NLOHMANN_JSON_HEDLEY_GNUC_HAS_WARNING) + #undef NLOHMANN_JSON_HEDLEY_GNUC_HAS_WARNING #endif #if defined(__has_warning) - #define HEDLEY_GNUC_HAS_WARNING(warning,major,minor,patch) __has_warning(warning) + #define NLOHMANN_JSON_HEDLEY_GNUC_HAS_WARNING(warning,major,minor,patch) __has_warning(warning) #else - #define HEDLEY_GNUC_HAS_WARNING(warning,major,minor,patch) HEDLEY_GNUC_VERSION_CHECK(major,minor,patch) + #define NLOHMANN_JSON_HEDLEY_GNUC_HAS_WARNING(warning,major,minor,patch) NLOHMANN_JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch) #endif -#if defined(HEDLEY_GCC_HAS_WARNING) - #undef HEDLEY_GCC_HAS_WARNING +#if defined(NLOHMANN_JSON_HEDLEY_GCC_HAS_WARNING) + #undef NLOHMANN_JSON_HEDLEY_GCC_HAS_WARNING #endif #if defined(__has_warning) - #define HEDLEY_GCC_HAS_WARNING(warning,major,minor,patch) __has_warning(warning) + #define NLOHMANN_JSON_HEDLEY_GCC_HAS_WARNING(warning,major,minor,patch) __has_warning(warning) #else - #define HEDLEY_GCC_HAS_WARNING(warning,major,minor,patch) HEDLEY_GCC_VERSION_CHECK(major,minor,patch) + #define NLOHMANN_JSON_HEDLEY_GCC_HAS_WARNING(warning,major,minor,patch) NLOHMANN_JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch) #endif #if \ (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)) || \ defined(__clang__) || \ - HEDLEY_GCC_VERSION_CHECK(3,0,0) || \ - HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ - HEDLEY_IAR_VERSION_CHECK(8,0,0) || \ - HEDLEY_PGI_VERSION_CHECK(18,4,0) || \ - HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ - HEDLEY_TI_VERSION_CHECK(6,0,0) || \ - HEDLEY_CRAY_VERSION_CHECK(5,0,0) || \ - HEDLEY_TINYC_VERSION_CHECK(0,9,17) || \ - HEDLEY_SUNPRO_VERSION_CHECK(8,0,0) || \ - (HEDLEY_IBM_VERSION_CHECK(10,1,0) && defined(__C99_PRAGMA_OPERATOR)) - #define HEDLEY_PRAGMA(value) _Pragma(#value) -#elif HEDLEY_MSVC_VERSION_CHECK(15,0,0) - #define HEDLEY_PRAGMA(value) __pragma(value) + NLOHMANN_JSON_HEDLEY_GCC_VERSION_CHECK(3,0,0) || \ + NLOHMANN_JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ + NLOHMANN_JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0) || \ + NLOHMANN_JSON_HEDLEY_PGI_VERSION_CHECK(18,4,0) || \ + NLOHMANN_JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ + NLOHMANN_JSON_HEDLEY_TI_VERSION_CHECK(6,0,0) || \ + NLOHMANN_JSON_HEDLEY_CRAY_VERSION_CHECK(5,0,0) || \ + NLOHMANN_JSON_HEDLEY_TINYC_VERSION_CHECK(0,9,17) || \ + NLOHMANN_JSON_HEDLEY_SUNPRO_VERSION_CHECK(8,0,0) || \ + (NLOHMANN_JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) && defined(__C99_PRAGMA_OPERATOR)) + #define NLOHMANN_JSON_HEDLEY_PRAGMA(value) _Pragma(#value) +#elif NLOHMANN_JSON_HEDLEY_MSVC_VERSION_CHECK(15,0,0) + #define NLOHMANN_JSON_HEDLEY_PRAGMA(value) __pragma(value) #else - #define HEDLEY_PRAGMA(value) + #define NLOHMANN_JSON_HEDLEY_PRAGMA(value) #endif -#if defined(HEDLEY_DIAGNOSTIC_PUSH) - #undef HEDLEY_DIAGNOSTIC_PUSH +#if defined(NLOHMANN_JSON_HEDLEY_DIAGNOSTIC_PUSH) + #undef NLOHMANN_JSON_HEDLEY_DIAGNOSTIC_PUSH #endif -#if defined(HEDLEY_DIAGNOSTIC_POP) - #undef HEDLEY_DIAGNOSTIC_POP +#if defined(NLOHMANN_JSON_HEDLEY_DIAGNOSTIC_POP) + #undef NLOHMANN_JSON_HEDLEY_DIAGNOSTIC_POP #endif #if defined(__clang__) - #define HEDLEY_DIAGNOSTIC_PUSH _Pragma("clang diagnostic push") - #define HEDLEY_DIAGNOSTIC_POP _Pragma("clang diagnostic pop") -#elif HEDLEY_INTEL_VERSION_CHECK(13,0,0) - #define HEDLEY_DIAGNOSTIC_PUSH _Pragma("warning(push)") - #define HEDLEY_DIAGNOSTIC_POP _Pragma("warning(pop)") -#elif HEDLEY_GCC_VERSION_CHECK(4,6,0) - #define HEDLEY_DIAGNOSTIC_PUSH _Pragma("GCC diagnostic push") - #define HEDLEY_DIAGNOSTIC_POP _Pragma("GCC diagnostic pop") -#elif HEDLEY_MSVC_VERSION_CHECK(15,0,0) - #define HEDLEY_DIAGNOSTIC_PUSH __pragma(warning(push)) - #define HEDLEY_DIAGNOSTIC_POP __pragma(warning(pop)) -#elif HEDLEY_ARM_VERSION_CHECK(5,6,0) - #define HEDLEY_DIAGNOSTIC_PUSH _Pragma("push") - #define HEDLEY_DIAGNOSTIC_POP _Pragma("pop") -#elif HEDLEY_TI_VERSION_CHECK(8,1,0) - #define HEDLEY_DIAGNOSTIC_PUSH _Pragma("diag_push") - #define HEDLEY_DIAGNOSTIC_POP _Pragma("diag_pop") -#elif HEDLEY_PELLES_VERSION_CHECK(2,90,0) - #define HEDLEY_DIAGNOSTIC_PUSH _Pragma("warning(push)") - #define HEDLEY_DIAGNOSTIC_POP _Pragma("warning(pop)") + #define NLOHMANN_JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("clang diagnostic push") + #define NLOHMANN_JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("clang diagnostic pop") +#elif NLOHMANN_JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) + #define NLOHMANN_JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("warning(push)") + #define NLOHMANN_JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("warning(pop)") +#elif NLOHMANN_JSON_HEDLEY_GCC_VERSION_CHECK(4,6,0) + #define NLOHMANN_JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("GCC diagnostic push") + #define NLOHMANN_JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("GCC diagnostic pop") +#elif NLOHMANN_JSON_HEDLEY_MSVC_VERSION_CHECK(15,0,0) + #define NLOHMANN_JSON_HEDLEY_DIAGNOSTIC_PUSH __pragma(warning(push)) + #define NLOHMANN_JSON_HEDLEY_DIAGNOSTIC_POP __pragma(warning(pop)) +#elif NLOHMANN_JSON_HEDLEY_ARM_VERSION_CHECK(5,6,0) + #define NLOHMANN_JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("push") + #define NLOHMANN_JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("pop") +#elif NLOHMANN_JSON_HEDLEY_TI_VERSION_CHECK(8,1,0) + #define NLOHMANN_JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("diag_push") + #define NLOHMANN_JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("diag_pop") +#elif NLOHMANN_JSON_HEDLEY_PELLES_VERSION_CHECK(2,90,0) + #define NLOHMANN_JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("warning(push)") + #define NLOHMANN_JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("warning(pop)") #else - #define HEDLEY_DIAGNOSTIC_PUSH - #define HEDLEY_DIAGNOSTIC_POP + #define NLOHMANN_JSON_HEDLEY_DIAGNOSTIC_PUSH + #define NLOHMANN_JSON_HEDLEY_DIAGNOSTIC_POP #endif -#if defined(HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED) - #undef HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED +#if defined(NLOHMANN_JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED) + #undef NLOHMANN_JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED #endif -#if HEDLEY_HAS_WARNING("-Wdeprecated-declarations") - #define HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("clang diagnostic ignored \"-Wdeprecated-declarations\"") -#elif HEDLEY_INTEL_VERSION_CHECK(13,0,0) - #define HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("warning(disable:1478 1786)") -#elif HEDLEY_PGI_VERSION_CHECK(17,10,0) - #define HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("diag_suppress 1215,1444") -#elif HEDLEY_GCC_VERSION_CHECK(4,3,0) - #define HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"") -#elif HEDLEY_MSVC_VERSION_CHECK(15,0,0) - #define HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED __pragma(warning(disable:4996)) -#elif HEDLEY_TI_VERSION_CHECK(8,0,0) - #define HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("diag_suppress 1291,1718") -#elif HEDLEY_SUNPRO_VERSION_CHECK(5,13,0) && !defined(__cplusplus) - #define HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("error_messages(off,E_DEPRECATED_ATT,E_DEPRECATED_ATT_MESS)") -#elif HEDLEY_SUNPRO_VERSION_CHECK(5,13,0) && defined(__cplusplus) - #define HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("error_messages(off,symdeprecated,symdeprecated2)") -#elif HEDLEY_IAR_VERSION_CHECK(8,0,0) - #define HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("diag_suppress=Pe1444,Pe1215") -#elif HEDLEY_PELLES_VERSION_CHECK(2,90,0) - #define HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("warn(disable:2241)") +#if NLOHMANN_JSON_HEDLEY_HAS_WARNING("-Wdeprecated-declarations") + #define NLOHMANN_JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("clang diagnostic ignored \"-Wdeprecated-declarations\"") +#elif NLOHMANN_JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) + #define NLOHMANN_JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("warning(disable:1478 1786)") +#elif NLOHMANN_JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) + #define NLOHMANN_JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("diag_suppress 1215,1444") +#elif NLOHMANN_JSON_HEDLEY_GCC_VERSION_CHECK(4,3,0) + #define NLOHMANN_JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"") +#elif NLOHMANN_JSON_HEDLEY_MSVC_VERSION_CHECK(15,0,0) + #define NLOHMANN_JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED __pragma(warning(disable:4996)) +#elif NLOHMANN_JSON_HEDLEY_TI_VERSION_CHECK(8,0,0) + #define NLOHMANN_JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("diag_suppress 1291,1718") +#elif NLOHMANN_JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,13,0) && !defined(__cplusplus) + #define NLOHMANN_JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("error_messages(off,E_DEPRECATED_ATT,E_DEPRECATED_ATT_MESS)") +#elif NLOHMANN_JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,13,0) && defined(__cplusplus) + #define NLOHMANN_JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("error_messages(off,symdeprecated,symdeprecated2)") +#elif NLOHMANN_JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0) + #define NLOHMANN_JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("diag_suppress=Pe1444,Pe1215") +#elif NLOHMANN_JSON_HEDLEY_PELLES_VERSION_CHECK(2,90,0) + #define NLOHMANN_JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("warn(disable:2241)") #else - #define HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED + #define NLOHMANN_JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED #endif -#if defined(HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS) - #undef HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS +#if defined(NLOHMANN_JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS) + #undef NLOHMANN_JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS #endif -#if HEDLEY_HAS_WARNING("-Wunknown-pragmas") - #define HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("clang diagnostic ignored \"-Wunknown-pragmas\"") -#elif HEDLEY_INTEL_VERSION_CHECK(13,0,0) - #define HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("warning(disable:161)") -#elif HEDLEY_PGI_VERSION_CHECK(17,10,0) - #define HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("diag_suppress 1675") -#elif HEDLEY_GCC_VERSION_CHECK(4,3,0) - #define HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("GCC diagnostic ignored \"-Wunknown-pragmas\"") -#elif HEDLEY_MSVC_VERSION_CHECK(15,0,0) - #define HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS __pragma(warning(disable:4068)) -#elif HEDLEY_TI_VERSION_CHECK(8,0,0) - #define HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("diag_suppress 163") -#elif HEDLEY_IAR_VERSION_CHECK(8,0,0) - #define HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("diag_suppress=Pe161") +#if NLOHMANN_JSON_HEDLEY_HAS_WARNING("-Wunknown-pragmas") + #define NLOHMANN_JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("clang diagnostic ignored \"-Wunknown-pragmas\"") +#elif NLOHMANN_JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) + #define NLOHMANN_JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("warning(disable:161)") +#elif NLOHMANN_JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) + #define NLOHMANN_JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("diag_suppress 1675") +#elif NLOHMANN_JSON_HEDLEY_GCC_VERSION_CHECK(4,3,0) + #define NLOHMANN_JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("GCC diagnostic ignored \"-Wunknown-pragmas\"") +#elif NLOHMANN_JSON_HEDLEY_MSVC_VERSION_CHECK(15,0,0) + #define NLOHMANN_JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS __pragma(warning(disable:4068)) +#elif NLOHMANN_JSON_HEDLEY_TI_VERSION_CHECK(8,0,0) + #define NLOHMANN_JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("diag_suppress 163") +#elif NLOHMANN_JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0) + #define NLOHMANN_JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("diag_suppress=Pe161") #else - #define HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS + #define NLOHMANN_JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS #endif -#if defined(HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL) - #undef HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL +#if defined(NLOHMANN_JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL) + #undef NLOHMANN_JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL #endif -#if HEDLEY_HAS_WARNING("-Wcast-qual") - #define HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL _Pragma("clang diagnostic ignored \"-Wcast-qual\"") -#elif HEDLEY_INTEL_VERSION_CHECK(13,0,0) - #define HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL _Pragma("warning(disable:2203 2331)") -#elif HEDLEY_GCC_VERSION_CHECK(3,0,0) - #define HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL _Pragma("GCC diagnostic ignored \"-Wcast-qual\"") +#if NLOHMANN_JSON_HEDLEY_HAS_WARNING("-Wcast-qual") + #define NLOHMANN_JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL _Pragma("clang diagnostic ignored \"-Wcast-qual\"") +#elif NLOHMANN_JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) + #define NLOHMANN_JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL _Pragma("warning(disable:2203 2331)") +#elif NLOHMANN_JSON_HEDLEY_GCC_VERSION_CHECK(3,0,0) + #define NLOHMANN_JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL _Pragma("GCC diagnostic ignored \"-Wcast-qual\"") #else - #define HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL + #define NLOHMANN_JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL #endif -#if defined(HEDLEY_DEPRECATED) - #undef HEDLEY_DEPRECATED +#if defined(NLOHMANN_JSON_HEDLEY_DEPRECATED) + #undef NLOHMANN_JSON_HEDLEY_DEPRECATED #endif -#if defined(HEDLEY_DEPRECATED_FOR) - #undef HEDLEY_DEPRECATED_FOR +#if defined(NLOHMANN_JSON_HEDLEY_DEPRECATED_FOR) + #undef NLOHMANN_JSON_HEDLEY_DEPRECATED_FOR #endif #if defined(__cplusplus) && (__cplusplus >= 201402L) - #define HEDLEY_DEPRECATED(since) [[deprecated("Since " #since)]] - #define HEDLEY_DEPRECATED_FOR(since, replacement) [[deprecated("Since " #since "; use " #replacement)]] + #define NLOHMANN_JSON_HEDLEY_DEPRECATED(since) [[deprecated("Since " #since)]] + #define NLOHMANN_JSON_HEDLEY_DEPRECATED_FOR(since, replacement) [[deprecated("Since " #since "; use " #replacement)]] #elif \ - HEDLEY_HAS_EXTENSION(attribute_deprecated_with_message) || \ - HEDLEY_GCC_VERSION_CHECK(4,5,0) || \ - HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ - HEDLEY_ARM_VERSION_CHECK(5,6,0) || \ - HEDLEY_SUNPRO_VERSION_CHECK(5,13,0) || \ - HEDLEY_PGI_VERSION_CHECK(17,10,0) || \ - HEDLEY_TI_VERSION_CHECK(8,3,0) - #define HEDLEY_DEPRECATED(since) __attribute__((__deprecated__("Since " #since))) - #define HEDLEY_DEPRECATED_FOR(since, replacement) __attribute__((__deprecated__("Since " #since "; use " #replacement))) + NLOHMANN_JSON_HEDLEY_HAS_EXTENSION(attribute_deprecated_with_message) || \ + NLOHMANN_JSON_HEDLEY_GCC_VERSION_CHECK(4,5,0) || \ + NLOHMANN_JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ + NLOHMANN_JSON_HEDLEY_ARM_VERSION_CHECK(5,6,0) || \ + NLOHMANN_JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,13,0) || \ + NLOHMANN_JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) || \ + NLOHMANN_JSON_HEDLEY_TI_VERSION_CHECK(8,3,0) + #define NLOHMANN_JSON_HEDLEY_DEPRECATED(since) __attribute__((__deprecated__("Since " #since))) + #define NLOHMANN_JSON_HEDLEY_DEPRECATED_FOR(since, replacement) __attribute__((__deprecated__("Since " #since "; use " #replacement))) #elif \ - HEDLEY_HAS_ATTRIBUTE(deprecated) || \ - HEDLEY_GCC_VERSION_CHECK(3,1,0) || \ - HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ - HEDLEY_TI_VERSION_CHECK(8,0,0) || \ - (HEDLEY_TI_VERSION_CHECK(7,3,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) - #define HEDLEY_DEPRECATED(since) __attribute__((__deprecated__)) - #define HEDLEY_DEPRECATED_FOR(since, replacement) __attribute__((__deprecated__)) -#elif HEDLEY_MSVC_VERSION_CHECK(14,0,0) - #define HEDLEY_DEPRECATED(since) __declspec(deprecated("Since " # since)) - #define HEDLEY_DEPRECATED_FOR(since, replacement) __declspec(deprecated("Since " #since "; use " #replacement)) + NLOHMANN_JSON_HEDLEY_HAS_ATTRIBUTE(deprecated) || \ + NLOHMANN_JSON_HEDLEY_GCC_VERSION_CHECK(3,1,0) || \ + NLOHMANN_JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ + NLOHMANN_JSON_HEDLEY_TI_VERSION_CHECK(8,0,0) || \ + (NLOHMANN_JSON_HEDLEY_TI_VERSION_CHECK(7,3,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) + #define NLOHMANN_JSON_HEDLEY_DEPRECATED(since) __attribute__((__deprecated__)) + #define NLOHMANN_JSON_HEDLEY_DEPRECATED_FOR(since, replacement) __attribute__((__deprecated__)) +#elif NLOHMANN_JSON_HEDLEY_MSVC_VERSION_CHECK(14,0,0) + #define NLOHMANN_JSON_HEDLEY_DEPRECATED(since) __declspec(deprecated("Since " # since)) + #define NLOHMANN_JSON_HEDLEY_DEPRECATED_FOR(since, replacement) __declspec(deprecated("Since " #since "; use " #replacement)) #elif \ - HEDLEY_MSVC_VERSION_CHECK(13,10,0) || \ - HEDLEY_PELLES_VERSION_CHECK(6,50,0) - #define HEDLEY_DEPRECATED(since) _declspec(deprecated) - #define HEDLEY_DEPRECATED_FOR(since, replacement) __declspec(deprecated) -#elif HEDLEY_IAR_VERSION_CHECK(8,0,0) - #define HEDLEY_DEPRECATED(since) _Pragma("deprecated") - #define HEDLEY_DEPRECATED_FOR(since, replacement) _Pragma("deprecated") + NLOHMANN_JSON_HEDLEY_MSVC_VERSION_CHECK(13,10,0) || \ + NLOHMANN_JSON_HEDLEY_PELLES_VERSION_CHECK(6,50,0) + #define NLOHMANN_JSON_HEDLEY_DEPRECATED(since) _declspec(deprecated) + #define NLOHMANN_JSON_HEDLEY_DEPRECATED_FOR(since, replacement) __declspec(deprecated) +#elif NLOHMANN_JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0) + #define NLOHMANN_JSON_HEDLEY_DEPRECATED(since) _Pragma("deprecated") + #define NLOHMANN_JSON_HEDLEY_DEPRECATED_FOR(since, replacement) _Pragma("deprecated") #else - #define HEDLEY_DEPRECATED(since) - #define HEDLEY_DEPRECATED_FOR(since, replacement) + #define NLOHMANN_JSON_HEDLEY_DEPRECATED(since) + #define NLOHMANN_JSON_HEDLEY_DEPRECATED_FOR(since, replacement) #endif -#if defined(HEDLEY_UNAVAILABLE) - #undef HEDLEY_UNAVAILABLE +#if defined(NLOHMANN_JSON_HEDLEY_UNAVAILABLE) + #undef NLOHMANN_JSON_HEDLEY_UNAVAILABLE #endif #if \ - HEDLEY_HAS_ATTRIBUTE(warning) || \ - HEDLEY_GCC_VERSION_CHECK(4,3,0) || \ - HEDLEY_INTEL_VERSION_CHECK(13,0,0) - #define HEDLEY_UNAVAILABLE(available_since) __attribute__((__warning__("Not available until " #available_since))) + NLOHMANN_JSON_HEDLEY_HAS_ATTRIBUTE(warning) || \ + NLOHMANN_JSON_HEDLEY_GCC_VERSION_CHECK(4,3,0) || \ + NLOHMANN_JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) + #define NLOHMANN_JSON_HEDLEY_UNAVAILABLE(available_since) __attribute__((__warning__("Not available until " #available_since))) #else - #define HEDLEY_UNAVAILABLE(available_since) + #define NLOHMANN_JSON_HEDLEY_UNAVAILABLE(available_since) #endif -#if defined(HEDLEY_WARN_UNUSED_RESULT) - #undef HEDLEY_WARN_UNUSED_RESULT +#if defined(NLOHMANN_JSON_HEDLEY_WARN_UNUSED_RESULT) + #undef NLOHMANN_JSON_HEDLEY_WARN_UNUSED_RESULT #endif #if defined(__cplusplus) && (__cplusplus >= 201703L) - #define HEDLEY_WARN_UNUSED_RESULT [[nodiscard]] + #define NLOHMANN_JSON_HEDLEY_WARN_UNUSED_RESULT [[nodiscard]] #elif \ - HEDLEY_HAS_ATTRIBUTE(warn_unused_result) || \ - HEDLEY_GCC_VERSION_CHECK(3,4,0) || \ - HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ - HEDLEY_TI_VERSION_CHECK(8,0,0) || \ - (HEDLEY_TI_VERSION_CHECK(7,3,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ - (HEDLEY_SUNPRO_VERSION_CHECK(5,15,0) && defined(__cplusplus)) || \ - HEDLEY_PGI_VERSION_CHECK(17,10,0) - #define HEDLEY_WARN_UNUSED_RESULT __attribute__((__warn_unused_result__)) + NLOHMANN_JSON_HEDLEY_HAS_ATTRIBUTE(warn_unused_result) || \ + NLOHMANN_JSON_HEDLEY_GCC_VERSION_CHECK(3,4,0) || \ + NLOHMANN_JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ + NLOHMANN_JSON_HEDLEY_TI_VERSION_CHECK(8,0,0) || \ + (NLOHMANN_JSON_HEDLEY_TI_VERSION_CHECK(7,3,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ + (NLOHMANN_JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,15,0) && defined(__cplusplus)) || \ + NLOHMANN_JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) + #define NLOHMANN_JSON_HEDLEY_WARN_UNUSED_RESULT __attribute__((__warn_unused_result__)) #elif defined(_Check_return_) /* SAL */ - #define HEDLEY_WARN_UNUSED_RESULT _Check_return_ + #define NLOHMANN_JSON_HEDLEY_WARN_UNUSED_RESULT _Check_return_ #else - #define HEDLEY_WARN_UNUSED_RESULT + #define NLOHMANN_JSON_HEDLEY_WARN_UNUSED_RESULT #endif -#if defined(HEDLEY_SENTINEL) - #undef HEDLEY_SENTINEL +#if defined(NLOHMANN_JSON_HEDLEY_SENTINEL) + #undef NLOHMANN_JSON_HEDLEY_SENTINEL #endif #if \ - HEDLEY_HAS_ATTRIBUTE(sentinel) || \ - HEDLEY_GCC_VERSION_CHECK(4,0,0) || \ - HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ - HEDLEY_ARM_VERSION_CHECK(5,4,0) - #define HEDLEY_SENTINEL(position) __attribute__((__sentinel__(position))) + NLOHMANN_JSON_HEDLEY_HAS_ATTRIBUTE(sentinel) || \ + NLOHMANN_JSON_HEDLEY_GCC_VERSION_CHECK(4,0,0) || \ + NLOHMANN_JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ + NLOHMANN_JSON_HEDLEY_ARM_VERSION_CHECK(5,4,0) + #define NLOHMANN_JSON_HEDLEY_SENTINEL(position) __attribute__((__sentinel__(position))) #else - #define HEDLEY_SENTINEL(position) + #define NLOHMANN_JSON_HEDLEY_SENTINEL(position) #endif -#if defined(HEDLEY_NO_RETURN) - #undef HEDLEY_NO_RETURN +#if defined(NLOHMANN_JSON_HEDLEY_NO_RETURN) + #undef NLOHMANN_JSON_HEDLEY_NO_RETURN #endif -#if HEDLEY_IAR_VERSION_CHECK(8,0,0) - #define HEDLEY_NO_RETURN __noreturn -#elif HEDLEY_INTEL_VERSION_CHECK(13,0,0) - #define HEDLEY_NO_RETURN __attribute__((__noreturn__)) +#if NLOHMANN_JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0) + #define NLOHMANN_JSON_HEDLEY_NO_RETURN __noreturn +#elif NLOHMANN_JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) + #define NLOHMANN_JSON_HEDLEY_NO_RETURN __attribute__((__noreturn__)) #elif defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L - #define HEDLEY_NO_RETURN _Noreturn + #define NLOHMANN_JSON_HEDLEY_NO_RETURN _Noreturn #elif defined(__cplusplus) && (__cplusplus >= 201103L) - #define HEDLEY_NO_RETURN [[noreturn]] + #define NLOHMANN_JSON_HEDLEY_NO_RETURN [[noreturn]] #elif \ - HEDLEY_HAS_ATTRIBUTE(noreturn) || \ - HEDLEY_GCC_VERSION_CHECK(3,2,0) || \ - HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \ - HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ - HEDLEY_IBM_VERSION_CHECK(10,1,0) || \ - HEDLEY_TI_VERSION_CHECK(18,0,0) || \ - (HEDLEY_TI_VERSION_CHECK(17,3,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) - #define HEDLEY_NO_RETURN __attribute__((__noreturn__)) -#elif HEDLEY_MSVC_VERSION_CHECK(13,10,0) - #define HEDLEY_NO_RETURN __declspec(noreturn) -#elif HEDLEY_TI_VERSION_CHECK(6,0,0) && defined(__cplusplus) - #define HEDLEY_NO_RETURN _Pragma("FUNC_NEVER_RETURNS;") -#elif HEDLEY_COMPCERT_VERSION_CHECK(3,2,0) - #define HEDLEY_NO_RETURN __attribute((noreturn)) -#elif HEDLEY_PELLES_VERSION_CHECK(9,0,0) - #define HEDLEY_NO_RETURN __declspec(noreturn) + NLOHMANN_JSON_HEDLEY_HAS_ATTRIBUTE(noreturn) || \ + NLOHMANN_JSON_HEDLEY_GCC_VERSION_CHECK(3,2,0) || \ + NLOHMANN_JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \ + NLOHMANN_JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ + NLOHMANN_JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \ + NLOHMANN_JSON_HEDLEY_TI_VERSION_CHECK(18,0,0) || \ + (NLOHMANN_JSON_HEDLEY_TI_VERSION_CHECK(17,3,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) + #define NLOHMANN_JSON_HEDLEY_NO_RETURN __attribute__((__noreturn__)) +#elif NLOHMANN_JSON_HEDLEY_MSVC_VERSION_CHECK(13,10,0) + #define NLOHMANN_JSON_HEDLEY_NO_RETURN __declspec(noreturn) +#elif NLOHMANN_JSON_HEDLEY_TI_VERSION_CHECK(6,0,0) && defined(__cplusplus) + #define NLOHMANN_JSON_HEDLEY_NO_RETURN _Pragma("FUNC_NEVER_RETURNS;") +#elif NLOHMANN_JSON_HEDLEY_COMPCERT_VERSION_CHECK(3,2,0) + #define NLOHMANN_JSON_HEDLEY_NO_RETURN __attribute((noreturn)) +#elif NLOHMANN_JSON_HEDLEY_PELLES_VERSION_CHECK(9,0,0) + #define NLOHMANN_JSON_HEDLEY_NO_RETURN __declspec(noreturn) #else - #define HEDLEY_NO_RETURN + #define NLOHMANN_JSON_HEDLEY_NO_RETURN #endif -#if defined(HEDLEY_UNREACHABLE) - #undef HEDLEY_UNREACHABLE +#if defined(NLOHMANN_JSON_HEDLEY_UNREACHABLE) + #undef NLOHMANN_JSON_HEDLEY_UNREACHABLE #endif -#if defined(HEDLEY_UNREACHABLE_RETURN) - #undef HEDLEY_UNREACHABLE_RETURN +#if defined(NLOHMANN_JSON_HEDLEY_UNREACHABLE_RETURN) + #undef NLOHMANN_JSON_HEDLEY_UNREACHABLE_RETURN #endif #if \ - (HEDLEY_HAS_BUILTIN(__builtin_unreachable) && (!defined(HEDLEY_ARM_VERSION))) || \ - HEDLEY_GCC_VERSION_CHECK(4,5,0) || \ - HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ - HEDLEY_IBM_VERSION_CHECK(13,1,5) - #define HEDLEY_UNREACHABLE() __builtin_unreachable() -#elif HEDLEY_MSVC_VERSION_CHECK(13,10,0) - #define HEDLEY_UNREACHABLE() __assume(0) -#elif HEDLEY_TI_VERSION_CHECK(6,0,0) + (NLOHMANN_JSON_HEDLEY_HAS_BUILTIN(__builtin_unreachable) && (!defined(NLOHMANN_JSON_HEDLEY_ARM_VERSION))) || \ + NLOHMANN_JSON_HEDLEY_GCC_VERSION_CHECK(4,5,0) || \ + NLOHMANN_JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ + NLOHMANN_JSON_HEDLEY_IBM_VERSION_CHECK(13,1,5) + #define NLOHMANN_JSON_HEDLEY_UNREACHABLE() __builtin_unreachable() +#elif NLOHMANN_JSON_HEDLEY_MSVC_VERSION_CHECK(13,10,0) + #define NLOHMANN_JSON_HEDLEY_UNREACHABLE() __assume(0) +#elif NLOHMANN_JSON_HEDLEY_TI_VERSION_CHECK(6,0,0) #if defined(__cplusplus) - #define HEDLEY_UNREACHABLE() std::_nassert(0) + #define NLOHMANN_JSON_HEDLEY_UNREACHABLE() std::_nassert(0) #else - #define HEDLEY_UNREACHABLE() _nassert(0) + #define NLOHMANN_JSON_HEDLEY_UNREACHABLE() _nassert(0) #endif - #define HEDLEY_UNREACHABLE_RETURN(value) return value + #define NLOHMANN_JSON_HEDLEY_UNREACHABLE_RETURN(value) return value #elif defined(EXIT_FAILURE) - #define HEDLEY_UNREACHABLE() abort() + #define NLOHMANN_JSON_HEDLEY_UNREACHABLE() abort() #else - #define HEDLEY_UNREACHABLE() - #define HEDLEY_UNREACHABLE_RETURN(value) return value + #define NLOHMANN_JSON_HEDLEY_UNREACHABLE() + #define NLOHMANN_JSON_HEDLEY_UNREACHABLE_RETURN(value) return value #endif -#if !defined(HEDLEY_UNREACHABLE_RETURN) - #define HEDLEY_UNREACHABLE_RETURN(value) HEDLEY_UNREACHABLE() +#if !defined(NLOHMANN_JSON_HEDLEY_UNREACHABLE_RETURN) + #define NLOHMANN_JSON_HEDLEY_UNREACHABLE_RETURN(value) NLOHMANN_JSON_HEDLEY_UNREACHABLE() #endif -#if defined(HEDLEY_ASSUME) - #undef HEDLEY_ASSUME +#if defined(NLOHMANN_JSON_HEDLEY_ASSUME) + #undef NLOHMANN_JSON_HEDLEY_ASSUME #endif #if \ - HEDLEY_MSVC_VERSION_CHECK(13,10,0) || \ - HEDLEY_INTEL_VERSION_CHECK(13,0,0) - #define HEDLEY_ASSUME(expr) __assume(expr) -#elif HEDLEY_HAS_BUILTIN(__builtin_assume) - #define HEDLEY_ASSUME(expr) __builtin_assume(expr) -#elif HEDLEY_TI_VERSION_CHECK(6,0,0) + NLOHMANN_JSON_HEDLEY_MSVC_VERSION_CHECK(13,10,0) || \ + NLOHMANN_JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) + #define NLOHMANN_JSON_HEDLEY_ASSUME(expr) __assume(expr) +#elif NLOHMANN_JSON_HEDLEY_HAS_BUILTIN(__builtin_assume) + #define NLOHMANN_JSON_HEDLEY_ASSUME(expr) __builtin_assume(expr) +#elif NLOHMANN_JSON_HEDLEY_TI_VERSION_CHECK(6,0,0) #if defined(__cplusplus) - #define HEDLEY_ASSUME(expr) std::_nassert(expr) + #define NLOHMANN_JSON_HEDLEY_ASSUME(expr) std::_nassert(expr) #else - #define HEDLEY_ASSUME(expr) _nassert(expr) + #define NLOHMANN_JSON_HEDLEY_ASSUME(expr) _nassert(expr) #endif #elif \ - (HEDLEY_HAS_BUILTIN(__builtin_unreachable) && !defined(HEDLEY_ARM_VERSION)) || \ - HEDLEY_GCC_VERSION_CHECK(4,5,0) || \ - HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ - HEDLEY_IBM_VERSION_CHECK(13,1,5) - #define HEDLEY_ASSUME(expr) ((void) ((expr) ? 1 : (__builtin_unreachable(), 1))) + (NLOHMANN_JSON_HEDLEY_HAS_BUILTIN(__builtin_unreachable) && !defined(NLOHMANN_JSON_HEDLEY_ARM_VERSION)) || \ + NLOHMANN_JSON_HEDLEY_GCC_VERSION_CHECK(4,5,0) || \ + NLOHMANN_JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ + NLOHMANN_JSON_HEDLEY_IBM_VERSION_CHECK(13,1,5) + #define NLOHMANN_JSON_HEDLEY_ASSUME(expr) ((void) ((expr) ? 1 : (__builtin_unreachable(), 1))) #else - #define HEDLEY_ASSUME(expr) ((void) (expr)) + #define NLOHMANN_JSON_HEDLEY_ASSUME(expr) ((void) (expr)) #endif -HEDLEY_DIAGNOSTIC_PUSH +NLOHMANN_JSON_HEDLEY_DIAGNOSTIC_PUSH #if \ - HEDLEY_HAS_WARNING("-Wvariadic-macros") || \ - HEDLEY_GCC_VERSION_CHECK(4,0,0) + NLOHMANN_JSON_HEDLEY_HAS_WARNING("-Wvariadic-macros") || \ + NLOHMANN_JSON_HEDLEY_GCC_VERSION_CHECK(4,0,0) #if defined(__clang__) #pragma clang diagnostic ignored "-Wvariadic-macros" - #elif defined(HEDLEY_GCC_VERSION) + #elif defined(NLOHMANN_JSON_HEDLEY_GCC_VERSION) #pragma GCC diagnostic ignored "-Wvariadic-macros" #endif #endif -#if defined(HEDLEY_NON_NULL) - #undef HEDLEY_NON_NULL +#if defined(NLOHMANN_JSON_HEDLEY_NON_NULL) + #undef NLOHMANN_JSON_HEDLEY_NON_NULL #endif #if \ - HEDLEY_HAS_ATTRIBUTE(nonnull) || \ - HEDLEY_GCC_VERSION_CHECK(3,3,0) || \ - HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ - HEDLEY_ARM_VERSION_CHECK(4,1,0) - #define HEDLEY_NON_NULL(...) __attribute__((__nonnull__(__VA_ARGS__))) + NLOHMANN_JSON_HEDLEY_HAS_ATTRIBUTE(nonnull) || \ + NLOHMANN_JSON_HEDLEY_GCC_VERSION_CHECK(3,3,0) || \ + NLOHMANN_JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ + NLOHMANN_JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) + #define NLOHMANN_JSON_HEDLEY_NON_NULL(...) __attribute__((__nonnull__(__VA_ARGS__))) #else - #define HEDLEY_NON_NULL(...) + #define NLOHMANN_JSON_HEDLEY_NON_NULL(...) #endif -HEDLEY_DIAGNOSTIC_POP +NLOHMANN_JSON_HEDLEY_DIAGNOSTIC_POP -#if defined(HEDLEY_PRINTF_FORMAT) - #undef HEDLEY_PRINTF_FORMAT +#if defined(NLOHMANN_JSON_HEDLEY_PRINTF_FORMAT) + #undef NLOHMANN_JSON_HEDLEY_PRINTF_FORMAT #endif -#if defined(__MINGW32__) && HEDLEY_GCC_HAS_ATTRIBUTE(format,4,4,0) && !defined(__USE_MINGW_ANSI_STDIO) - #define HEDLEY_PRINTF_FORMAT(string_idx,first_to_check) __attribute__((__format__(ms_printf, string_idx, first_to_check))) -#elif defined(__MINGW32__) && HEDLEY_GCC_HAS_ATTRIBUTE(format,4,4,0) && defined(__USE_MINGW_ANSI_STDIO) - #define HEDLEY_PRINTF_FORMAT(string_idx,first_to_check) __attribute__((__format__(gnu_printf, string_idx, first_to_check))) +#if defined(__MINGW32__) && NLOHMANN_JSON_HEDLEY_GCC_HAS_ATTRIBUTE(format,4,4,0) && !defined(__USE_MINGW_ANSI_STDIO) + #define NLOHMANN_JSON_HEDLEY_PRINTF_FORMAT(string_idx,first_to_check) __attribute__((__format__(ms_printf, string_idx, first_to_check))) +#elif defined(__MINGW32__) && NLOHMANN_JSON_HEDLEY_GCC_HAS_ATTRIBUTE(format,4,4,0) && defined(__USE_MINGW_ANSI_STDIO) + #define NLOHMANN_JSON_HEDLEY_PRINTF_FORMAT(string_idx,first_to_check) __attribute__((__format__(gnu_printf, string_idx, first_to_check))) #elif \ - HEDLEY_HAS_ATTRIBUTE(format) || \ - HEDLEY_GCC_VERSION_CHECK(3,1,0) || \ - HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ - HEDLEY_ARM_VERSION_CHECK(5,6,0) || \ - HEDLEY_IBM_VERSION_CHECK(10,1,0) || \ - HEDLEY_TI_VERSION_CHECK(8,0,0) || \ - (HEDLEY_TI_VERSION_CHECK(7,3,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) - #define HEDLEY_PRINTF_FORMAT(string_idx,first_to_check) __attribute__((__format__(__printf__, string_idx, first_to_check))) -#elif HEDLEY_PELLES_VERSION_CHECK(6,0,0) - #define HEDLEY_PRINTF_FORMAT(string_idx,first_to_check) __declspec(vaformat(printf,string_idx,first_to_check)) + NLOHMANN_JSON_HEDLEY_HAS_ATTRIBUTE(format) || \ + NLOHMANN_JSON_HEDLEY_GCC_VERSION_CHECK(3,1,0) || \ + NLOHMANN_JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ + NLOHMANN_JSON_HEDLEY_ARM_VERSION_CHECK(5,6,0) || \ + NLOHMANN_JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \ + NLOHMANN_JSON_HEDLEY_TI_VERSION_CHECK(8,0,0) || \ + (NLOHMANN_JSON_HEDLEY_TI_VERSION_CHECK(7,3,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) + #define NLOHMANN_JSON_HEDLEY_PRINTF_FORMAT(string_idx,first_to_check) __attribute__((__format__(__printf__, string_idx, first_to_check))) +#elif NLOHMANN_JSON_HEDLEY_PELLES_VERSION_CHECK(6,0,0) + #define NLOHMANN_JSON_HEDLEY_PRINTF_FORMAT(string_idx,first_to_check) __declspec(vaformat(printf,string_idx,first_to_check)) #else - #define HEDLEY_PRINTF_FORMAT(string_idx,first_to_check) + #define NLOHMANN_JSON_HEDLEY_PRINTF_FORMAT(string_idx,first_to_check) #endif -#if defined(HEDLEY_CONSTEXPR) - #undef HEDLEY_CONSTEXPR +#if defined(NLOHMANN_JSON_HEDLEY_CONSTEXPR) + #undef NLOHMANN_JSON_HEDLEY_CONSTEXPR #endif #if defined(__cplusplus) #if __cplusplus >= 201103L - #define HEDLEY_CONSTEXPR constexpr + #define NLOHMANN_JSON_HEDLEY_CONSTEXPR constexpr #endif #endif -#if !defined(HEDLEY_CONSTEXPR) - #define HEDLEY_CONSTEXPR +#if !defined(NLOHMANN_JSON_HEDLEY_CONSTEXPR) + #define NLOHMANN_JSON_HEDLEY_CONSTEXPR #endif -#if defined(HEDLEY_PREDICT) - #undef HEDLEY_PREDICT +#if defined(NLOHMANN_JSON_HEDLEY_PREDICT) + #undef NLOHMANN_JSON_HEDLEY_PREDICT #endif -#if defined(HEDLEY_LIKELY) - #undef HEDLEY_LIKELY +#if defined(NLOHMANN_JSON_HEDLEY_LIKELY) + #undef NLOHMANN_JSON_HEDLEY_LIKELY #endif -#if defined(HEDLEY_UNLIKELY) - #undef HEDLEY_UNLIKELY +#if defined(NLOHMANN_JSON_HEDLEY_UNLIKELY) + #undef NLOHMANN_JSON_HEDLEY_UNLIKELY #endif -#if defined(HEDLEY_UNPREDICTABLE) - #undef HEDLEY_UNPREDICTABLE +#if defined(NLOHMANN_JSON_HEDLEY_UNPREDICTABLE) + #undef NLOHMANN_JSON_HEDLEY_UNPREDICTABLE #endif -#if HEDLEY_HAS_BUILTIN(__builtin_unpredictable) - #define HEDLEY_UNPREDICTABLE(expr) __builtin_unpredictable(!!(expr)) +#if NLOHMANN_JSON_HEDLEY_HAS_BUILTIN(__builtin_unpredictable) + #define NLOHMANN_JSON_HEDLEY_UNPREDICTABLE(expr) __builtin_unpredictable(!!(expr)) #endif #if \ - HEDLEY_HAS_BUILTIN(__builtin_expect_with_probability) || \ - HEDLEY_GCC_VERSION_CHECK(9,0,0) -# define HEDLEY_PREDICT(expr, value, probability) __builtin_expect_with_probability(expr, value, probability) -# define HEDLEY_PREDICT_TRUE(expr, probability) __builtin_expect_with_probability(!!(expr), 1, probability) -# define HEDLEY_PREDICT_FALSE(expr, probability) __builtin_expect_with_probability(!!(expr), 0, probability) -# define HEDLEY_LIKELY(expr) __builtin_expect(!!(expr), 1) -# define HEDLEY_UNLIKELY(expr) __builtin_expect(!!(expr), 0) -#if !defined(HEDLEY_BUILTIN_UNPREDICTABLE) - #define HEDLEY_BUILTIN_UNPREDICTABLE(expr) __builtin_expect_with_probability(!!(expr), 1, 0.5) + NLOHMANN_JSON_HEDLEY_HAS_BUILTIN(__builtin_expect_with_probability) || \ + NLOHMANN_JSON_HEDLEY_GCC_VERSION_CHECK(9,0,0) +# define NLOHMANN_JSON_HEDLEY_PREDICT(expr, value, probability) __builtin_expect_with_probability(expr, value, probability) +# define NLOHMANN_JSON_HEDLEY_PREDICT_TRUE(expr, probability) __builtin_expect_with_probability(!!(expr), 1, probability) +# define NLOHMANN_JSON_HEDLEY_PREDICT_FALSE(expr, probability) __builtin_expect_with_probability(!!(expr), 0, probability) +# define NLOHMANN_JSON_HEDLEY_LIKELY(expr) __builtin_expect(!!(expr), 1) +# define NLOHMANN_JSON_HEDLEY_UNLIKELY(expr) __builtin_expect(!!(expr), 0) +#if !defined(NLOHMANN_JSON_HEDLEY_BUILTIN_UNPREDICTABLE) + #define NLOHMANN_JSON_HEDLEY_BUILTIN_UNPREDICTABLE(expr) __builtin_expect_with_probability(!!(expr), 1, 0.5) #endif #elif \ - HEDLEY_HAS_BUILTIN(__builtin_expect) || \ - HEDLEY_GCC_VERSION_CHECK(3,0,0) || \ - HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ - (HEDLEY_SUNPRO_VERSION_CHECK(5,15,0) && defined(__cplusplus)) || \ - HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ - HEDLEY_IBM_VERSION_CHECK(10,1,0) || \ - HEDLEY_TI_VERSION_CHECK(6,1,0) || \ - HEDLEY_TINYC_VERSION_CHECK(0,9,27) -# define HEDLEY_PREDICT(expr, expected, probability) \ + NLOHMANN_JSON_HEDLEY_HAS_BUILTIN(__builtin_expect) || \ + NLOHMANN_JSON_HEDLEY_GCC_VERSION_CHECK(3,0,0) || \ + NLOHMANN_JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ + (NLOHMANN_JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,15,0) && defined(__cplusplus)) || \ + NLOHMANN_JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ + NLOHMANN_JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \ + NLOHMANN_JSON_HEDLEY_TI_VERSION_CHECK(6,1,0) || \ + NLOHMANN_JSON_HEDLEY_TINYC_VERSION_CHECK(0,9,27) +# define NLOHMANN_JSON_HEDLEY_PREDICT(expr, expected, probability) \ (((probability) >= 0.9) ? __builtin_expect(!!(expr), (expected)) : (((void) (expected)), !!(expr))) -# define HEDLEY_PREDICT_TRUE(expr, probability) \ +# define NLOHMANN_JSON_HEDLEY_PREDICT_TRUE(expr, probability) \ (__extension__ ({ \ - HEDLEY_CONSTEXPR double hedley_probability_ = (probability); \ + NLOHMANN_JSON_HEDLEY_CONSTEXPR double hedley_probability_ = (probability); \ ((hedley_probability_ >= 0.9) ? __builtin_expect(!!(expr), 1) : ((hedley_probability_ <= 0.1) ? __builtin_expect(!!(expr), 0) : !!(expr))); \ })) -# define HEDLEY_PREDICT_FALSE(expr, probability) \ +# define NLOHMANN_JSON_HEDLEY_PREDICT_FALSE(expr, probability) \ (__extension__ ({ \ - HEDLEY_CONSTEXPR double hedley_probability_ = (probability); \ + NLOHMANN_JSON_HEDLEY_CONSTEXPR double hedley_probability_ = (probability); \ ((hedley_probability_ >= 0.9) ? __builtin_expect(!!(expr), 0) : ((hedley_probability_ <= 0.1) ? __builtin_expect(!!(expr), 1) : !!(expr))); \ })) -# define HEDLEY_LIKELY(expr) __builtin_expect(!!(expr), 1) -# define HEDLEY_UNLIKELY(expr) __builtin_expect(!!(expr), 0) +# define NLOHMANN_JSON_HEDLEY_LIKELY(expr) __builtin_expect(!!(expr), 1) +# define NLOHMANN_JSON_HEDLEY_UNLIKELY(expr) __builtin_expect(!!(expr), 0) #else -# define HEDLEY_PREDICT(expr, expected, probability) (((void) (expected)), !!(expr)) -# define HEDLEY_PREDICT_TRUE(expr, probability) (!!(expr)) -# define HEDLEY_PREDICT_FALSE(expr, probability) (!!(expr)) -# define HEDLEY_LIKELY(expr) (!!(expr)) -# define HEDLEY_UNLIKELY(expr) (!!(expr)) +# define NLOHMANN_JSON_HEDLEY_PREDICT(expr, expected, probability) (((void) (expected)), !!(expr)) +# define NLOHMANN_JSON_HEDLEY_PREDICT_TRUE(expr, probability) (!!(expr)) +# define NLOHMANN_JSON_HEDLEY_PREDICT_FALSE(expr, probability) (!!(expr)) +# define NLOHMANN_JSON_HEDLEY_LIKELY(expr) (!!(expr)) +# define NLOHMANN_JSON_HEDLEY_UNLIKELY(expr) (!!(expr)) #endif -#if !defined(HEDLEY_UNPREDICTABLE) - #define HEDLEY_UNPREDICTABLE(expr) HEDLEY_PREDICT(expr, 1, 0.5) +#if !defined(NLOHMANN_JSON_HEDLEY_UNPREDICTABLE) + #define NLOHMANN_JSON_HEDLEY_UNPREDICTABLE(expr) NLOHMANN_JSON_HEDLEY_PREDICT(expr, 1, 0.5) #endif -#if defined(HEDLEY_MALLOC) - #undef HEDLEY_MALLOC +#if defined(NLOHMANN_JSON_HEDLEY_MALLOC) + #undef NLOHMANN_JSON_HEDLEY_MALLOC #endif #if \ - HEDLEY_HAS_ATTRIBUTE(malloc) || \ - HEDLEY_GCC_VERSION_CHECK(3,1,0) || \ - HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ - HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \ - HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ - HEDLEY_IBM_VERSION_CHECK(12,1,0) || \ - HEDLEY_TI_VERSION_CHECK(8,0,0) || \ - (HEDLEY_TI_VERSION_CHECK(7,3,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) - #define HEDLEY_MALLOC __attribute__((__malloc__)) -#elif HEDLEY_MSVC_VERSION_CHECK(14, 0, 0) - #define HEDLEY_MALLOC __declspec(restrict) + NLOHMANN_JSON_HEDLEY_HAS_ATTRIBUTE(malloc) || \ + NLOHMANN_JSON_HEDLEY_GCC_VERSION_CHECK(3,1,0) || \ + NLOHMANN_JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ + NLOHMANN_JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \ + NLOHMANN_JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ + NLOHMANN_JSON_HEDLEY_IBM_VERSION_CHECK(12,1,0) || \ + NLOHMANN_JSON_HEDLEY_TI_VERSION_CHECK(8,0,0) || \ + (NLOHMANN_JSON_HEDLEY_TI_VERSION_CHECK(7,3,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) + #define NLOHMANN_JSON_HEDLEY_MALLOC __attribute__((__malloc__)) +#elif NLOHMANN_JSON_HEDLEY_MSVC_VERSION_CHECK(14, 0, 0) + #define NLOHMANN_JSON_HEDLEY_MALLOC __declspec(restrict) #else - #define HEDLEY_MALLOC + #define NLOHMANN_JSON_HEDLEY_MALLOC #endif -#if defined(HEDLEY_PURE) - #undef HEDLEY_PURE +#if defined(NLOHMANN_JSON_HEDLEY_PURE) + #undef NLOHMANN_JSON_HEDLEY_PURE #endif #if \ - HEDLEY_HAS_ATTRIBUTE(pure) || \ - HEDLEY_GCC_VERSION_CHECK(2,96,0) || \ - HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ - HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \ - HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ - HEDLEY_IBM_VERSION_CHECK(10,1,0) || \ - HEDLEY_TI_VERSION_CHECK(8,0,0) || \ - (HEDLEY_TI_VERSION_CHECK(7,3,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ - HEDLEY_PGI_VERSION_CHECK(17,10,0) - #define HEDLEY_PURE __attribute__((__pure__)) -#elif HEDLEY_TI_VERSION_CHECK(6,0,0) && defined(__cplusplus) - #define HEDLEY_PURE _Pragma("FUNC_IS_PURE;") + NLOHMANN_JSON_HEDLEY_HAS_ATTRIBUTE(pure) || \ + NLOHMANN_JSON_HEDLEY_GCC_VERSION_CHECK(2,96,0) || \ + NLOHMANN_JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ + NLOHMANN_JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \ + NLOHMANN_JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ + NLOHMANN_JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \ + NLOHMANN_JSON_HEDLEY_TI_VERSION_CHECK(8,0,0) || \ + (NLOHMANN_JSON_HEDLEY_TI_VERSION_CHECK(7,3,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ + NLOHMANN_JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) + #define NLOHMANN_JSON_HEDLEY_PURE __attribute__((__pure__)) +#elif NLOHMANN_JSON_HEDLEY_TI_VERSION_CHECK(6,0,0) && defined(__cplusplus) + #define NLOHMANN_JSON_HEDLEY_PURE _Pragma("FUNC_IS_PURE;") #else - #define HEDLEY_PURE + #define NLOHMANN_JSON_HEDLEY_PURE #endif -#if defined(HEDLEY_CONST) - #undef HEDLEY_CONST +#if defined(NLOHMANN_JSON_HEDLEY_CONST) + #undef NLOHMANN_JSON_HEDLEY_CONST #endif #if \ - HEDLEY_HAS_ATTRIBUTE(const) || \ - HEDLEY_GCC_VERSION_CHECK(2,5,0) || \ - HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ - HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \ - HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ - HEDLEY_IBM_VERSION_CHECK(10,1,0) || \ - HEDLEY_TI_VERSION_CHECK(8,0,0) || \ - (HEDLEY_TI_VERSION_CHECK(7,3,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ - HEDLEY_PGI_VERSION_CHECK(17,10,0) - #define HEDLEY_CONST __attribute__((__const__)) + NLOHMANN_JSON_HEDLEY_HAS_ATTRIBUTE(const) || \ + NLOHMANN_JSON_HEDLEY_GCC_VERSION_CHECK(2,5,0) || \ + NLOHMANN_JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ + NLOHMANN_JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \ + NLOHMANN_JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ + NLOHMANN_JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \ + NLOHMANN_JSON_HEDLEY_TI_VERSION_CHECK(8,0,0) || \ + (NLOHMANN_JSON_HEDLEY_TI_VERSION_CHECK(7,3,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ + NLOHMANN_JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) + #define NLOHMANN_JSON_HEDLEY_CONST __attribute__((__const__)) #else - #define HEDLEY_CONST HEDLEY_PURE + #define NLOHMANN_JSON_HEDLEY_CONST NLOHMANN_JSON_HEDLEY_PURE #endif -#if defined(HEDLEY_RESTRICT) - #undef HEDLEY_RESTRICT +#if defined(NLOHMANN_JSON_HEDLEY_RESTRICT) + #undef NLOHMANN_JSON_HEDLEY_RESTRICT #endif #if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) && !defined(__cplusplus) - #define HEDLEY_RESTRICT restrict + #define NLOHMANN_JSON_HEDLEY_RESTRICT restrict #elif \ - HEDLEY_GCC_VERSION_CHECK(3,1,0) || \ - HEDLEY_MSVC_VERSION_CHECK(14,0,0) || \ - HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ - HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ - HEDLEY_IBM_VERSION_CHECK(10,1,0) || \ - HEDLEY_PGI_VERSION_CHECK(17,10,0) || \ - HEDLEY_TI_VERSION_CHECK(8,0,0) || \ - (HEDLEY_SUNPRO_VERSION_CHECK(5,14,0) && defined(__cplusplus)) || \ - HEDLEY_IAR_VERSION_CHECK(8,0,0) || \ + NLOHMANN_JSON_HEDLEY_GCC_VERSION_CHECK(3,1,0) || \ + NLOHMANN_JSON_HEDLEY_MSVC_VERSION_CHECK(14,0,0) || \ + NLOHMANN_JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ + NLOHMANN_JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ + NLOHMANN_JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \ + NLOHMANN_JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) || \ + NLOHMANN_JSON_HEDLEY_TI_VERSION_CHECK(8,0,0) || \ + (NLOHMANN_JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,14,0) && defined(__cplusplus)) || \ + NLOHMANN_JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0) || \ defined(__clang__) - #define HEDLEY_RESTRICT __restrict -#elif HEDLEY_SUNPRO_VERSION_CHECK(5,3,0) && !defined(__cplusplus) - #define HEDLEY_RESTRICT _Restrict + #define NLOHMANN_JSON_HEDLEY_RESTRICT __restrict +#elif NLOHMANN_JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,3,0) && !defined(__cplusplus) + #define NLOHMANN_JSON_HEDLEY_RESTRICT _Restrict #else - #define HEDLEY_RESTRICT + #define NLOHMANN_JSON_HEDLEY_RESTRICT #endif -#if defined(HEDLEY_INLINE) - #undef HEDLEY_INLINE +#if defined(NLOHMANN_JSON_HEDLEY_INLINE) + #undef NLOHMANN_JSON_HEDLEY_INLINE #endif #if \ (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)) || \ (defined(__cplusplus) && (__cplusplus >= 199711L)) - #define HEDLEY_INLINE inline + #define NLOHMANN_JSON_HEDLEY_INLINE inline #elif \ - defined(HEDLEY_GCC_VERSION) || \ - HEDLEY_ARM_VERSION_CHECK(6,2,0) - #define HEDLEY_INLINE __inline__ + defined(NLOHMANN_JSON_HEDLEY_GCC_VERSION) || \ + NLOHMANN_JSON_HEDLEY_ARM_VERSION_CHECK(6,2,0) + #define NLOHMANN_JSON_HEDLEY_INLINE __inline__ #elif \ - HEDLEY_MSVC_VERSION_CHECK(12,0,0) || \ - HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ - HEDLEY_TI_VERSION_CHECK(8,0,0) - #define HEDLEY_INLINE __inline + NLOHMANN_JSON_HEDLEY_MSVC_VERSION_CHECK(12,0,0) || \ + NLOHMANN_JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ + NLOHMANN_JSON_HEDLEY_TI_VERSION_CHECK(8,0,0) + #define NLOHMANN_JSON_HEDLEY_INLINE __inline #else - #define HEDLEY_INLINE + #define NLOHMANN_JSON_HEDLEY_INLINE #endif -#if defined(HEDLEY_ALWAYS_INLINE) - #undef HEDLEY_ALWAYS_INLINE +#if defined(NLOHMANN_JSON_HEDLEY_ALWAYS_INLINE) + #undef NLOHMANN_JSON_HEDLEY_ALWAYS_INLINE #endif #if \ - HEDLEY_HAS_ATTRIBUTE(always_inline) || \ - HEDLEY_GCC_VERSION_CHECK(4,0,0) || \ - HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ - HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \ - HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ - HEDLEY_IBM_VERSION_CHECK(10,1,0) || \ - HEDLEY_TI_VERSION_CHECK(8,0,0) || \ - (HEDLEY_TI_VERSION_CHECK(7,3,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) - #define HEDLEY_ALWAYS_INLINE __attribute__((__always_inline__)) HEDLEY_INLINE -#elif HEDLEY_MSVC_VERSION_CHECK(12,0,0) - #define HEDLEY_ALWAYS_INLINE __forceinline -#elif HEDLEY_TI_VERSION_CHECK(7,0,0) && defined(__cplusplus) - #define HEDLEY_ALWAYS_INLINE _Pragma("FUNC_ALWAYS_INLINE;") -#elif HEDLEY_IAR_VERSION_CHECK(8,0,0) - #define HEDLEY_ALWAYS_INLINE _Pragma("inline=forced") + NLOHMANN_JSON_HEDLEY_HAS_ATTRIBUTE(always_inline) || \ + NLOHMANN_JSON_HEDLEY_GCC_VERSION_CHECK(4,0,0) || \ + NLOHMANN_JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ + NLOHMANN_JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \ + NLOHMANN_JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ + NLOHMANN_JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \ + NLOHMANN_JSON_HEDLEY_TI_VERSION_CHECK(8,0,0) || \ + (NLOHMANN_JSON_HEDLEY_TI_VERSION_CHECK(7,3,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) + #define NLOHMANN_JSON_HEDLEY_ALWAYS_INLINE __attribute__((__always_inline__)) NLOHMANN_JSON_HEDLEY_INLINE +#elif NLOHMANN_JSON_HEDLEY_MSVC_VERSION_CHECK(12,0,0) + #define NLOHMANN_JSON_HEDLEY_ALWAYS_INLINE __forceinline +#elif NLOHMANN_JSON_HEDLEY_TI_VERSION_CHECK(7,0,0) && defined(__cplusplus) + #define NLOHMANN_JSON_HEDLEY_ALWAYS_INLINE _Pragma("FUNC_ALWAYS_INLINE;") +#elif NLOHMANN_JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0) + #define NLOHMANN_JSON_HEDLEY_ALWAYS_INLINE _Pragma("inline=forced") #else - #define HEDLEY_ALWAYS_INLINE HEDLEY_INLINE + #define NLOHMANN_JSON_HEDLEY_ALWAYS_INLINE NLOHMANN_JSON_HEDLEY_INLINE #endif -#if defined(HEDLEY_NEVER_INLINE) - #undef HEDLEY_NEVER_INLINE +#if defined(NLOHMANN_JSON_HEDLEY_NEVER_INLINE) + #undef NLOHMANN_JSON_HEDLEY_NEVER_INLINE #endif #if \ - HEDLEY_HAS_ATTRIBUTE(noinline) || \ - HEDLEY_GCC_VERSION_CHECK(4,0,0) || \ - HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ - HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \ - HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ - HEDLEY_IBM_VERSION_CHECK(10,1,0) || \ - HEDLEY_TI_VERSION_CHECK(8,0,0) || \ - (HEDLEY_TI_VERSION_CHECK(7,3,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) - #define HEDLEY_NEVER_INLINE __attribute__((__noinline__)) -#elif HEDLEY_MSVC_VERSION_CHECK(13,10,0) - #define HEDLEY_NEVER_INLINE __declspec(noinline) -#elif HEDLEY_PGI_VERSION_CHECK(10,2,0) - #define HEDLEY_NEVER_INLINE _Pragma("noinline") -#elif HEDLEY_TI_VERSION_CHECK(6,0,0) && defined(__cplusplus) - #define HEDLEY_NEVER_INLINE _Pragma("FUNC_CANNOT_INLINE;") -#elif HEDLEY_IAR_VERSION_CHECK(8,0,0) - #define HEDLEY_NEVER_INLINE _Pragma("inline=never") -#elif HEDLEY_COMPCERT_VERSION_CHECK(3,2,0) - #define HEDLEY_NEVER_INLINE __attribute((noinline)) -#elif HEDLEY_PELLES_VERSION_CHECK(9,0,0) - #define HEDLEY_NEVER_INLINE __declspec(noinline) + NLOHMANN_JSON_HEDLEY_HAS_ATTRIBUTE(noinline) || \ + NLOHMANN_JSON_HEDLEY_GCC_VERSION_CHECK(4,0,0) || \ + NLOHMANN_JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ + NLOHMANN_JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \ + NLOHMANN_JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ + NLOHMANN_JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \ + NLOHMANN_JSON_HEDLEY_TI_VERSION_CHECK(8,0,0) || \ + (NLOHMANN_JSON_HEDLEY_TI_VERSION_CHECK(7,3,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) + #define NLOHMANN_JSON_HEDLEY_NEVER_INLINE __attribute__((__noinline__)) +#elif NLOHMANN_JSON_HEDLEY_MSVC_VERSION_CHECK(13,10,0) + #define NLOHMANN_JSON_HEDLEY_NEVER_INLINE __declspec(noinline) +#elif NLOHMANN_JSON_HEDLEY_PGI_VERSION_CHECK(10,2,0) + #define NLOHMANN_JSON_HEDLEY_NEVER_INLINE _Pragma("noinline") +#elif NLOHMANN_JSON_HEDLEY_TI_VERSION_CHECK(6,0,0) && defined(__cplusplus) + #define NLOHMANN_JSON_HEDLEY_NEVER_INLINE _Pragma("FUNC_CANNOT_INLINE;") +#elif NLOHMANN_JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0) + #define NLOHMANN_JSON_HEDLEY_NEVER_INLINE _Pragma("inline=never") +#elif NLOHMANN_JSON_HEDLEY_COMPCERT_VERSION_CHECK(3,2,0) + #define NLOHMANN_JSON_HEDLEY_NEVER_INLINE __attribute((noinline)) +#elif NLOHMANN_JSON_HEDLEY_PELLES_VERSION_CHECK(9,0,0) + #define NLOHMANN_JSON_HEDLEY_NEVER_INLINE __declspec(noinline) #else - #define HEDLEY_NEVER_INLINE + #define NLOHMANN_JSON_HEDLEY_NEVER_INLINE #endif -#if defined(HEDLEY_PRIVATE) - #undef HEDLEY_PRIVATE +#if defined(NLOHMANN_JSON_HEDLEY_PRIVATE) + #undef NLOHMANN_JSON_HEDLEY_PRIVATE #endif -#if defined(HEDLEY_PUBLIC) - #undef HEDLEY_PUBLIC +#if defined(NLOHMANN_JSON_HEDLEY_PUBLIC) + #undef NLOHMANN_JSON_HEDLEY_PUBLIC #endif -#if defined(HEDLEY_IMPORT) - #undef HEDLEY_IMPORT +#if defined(NLOHMANN_JSON_HEDLEY_IMPORT) + #undef NLOHMANN_JSON_HEDLEY_IMPORT #endif #if defined(_WIN32) || defined(__CYGWIN__) - #define HEDLEY_PRIVATE - #define HEDLEY_PUBLIC __declspec(dllexport) - #define HEDLEY_IMPORT __declspec(dllimport) + #define NLOHMANN_JSON_HEDLEY_PRIVATE + #define NLOHMANN_JSON_HEDLEY_PUBLIC __declspec(dllexport) + #define NLOHMANN_JSON_HEDLEY_IMPORT __declspec(dllimport) #else #if \ - HEDLEY_HAS_ATTRIBUTE(visibility) || \ - HEDLEY_GCC_VERSION_CHECK(3,3,0) || \ - HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \ - HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ - HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ - HEDLEY_IBM_VERSION_CHECK(13,1,0) || \ - HEDLEY_TI_VERSION_CHECK(8,0,0) || \ - (HEDLEY_TI_VERSION_CHECK(7,3,0) && defined(__TI_EABI__) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) - #define HEDLEY_PRIVATE __attribute__((__visibility__("hidden"))) - #define HEDLEY_PUBLIC __attribute__((__visibility__("default"))) + NLOHMANN_JSON_HEDLEY_HAS_ATTRIBUTE(visibility) || \ + NLOHMANN_JSON_HEDLEY_GCC_VERSION_CHECK(3,3,0) || \ + NLOHMANN_JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \ + NLOHMANN_JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ + NLOHMANN_JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ + NLOHMANN_JSON_HEDLEY_IBM_VERSION_CHECK(13,1,0) || \ + NLOHMANN_JSON_HEDLEY_TI_VERSION_CHECK(8,0,0) || \ + (NLOHMANN_JSON_HEDLEY_TI_VERSION_CHECK(7,3,0) && defined(__TI_EABI__) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) + #define NLOHMANN_JSON_HEDLEY_PRIVATE __attribute__((__visibility__("hidden"))) + #define NLOHMANN_JSON_HEDLEY_PUBLIC __attribute__((__visibility__("default"))) #else - #define HEDLEY_PRIVATE - #define HEDLEY_PUBLIC + #define NLOHMANN_JSON_HEDLEY_PRIVATE + #define NLOHMANN_JSON_HEDLEY_PUBLIC #endif - #define HEDLEY_IMPORT extern + #define NLOHMANN_JSON_HEDLEY_IMPORT extern #endif -#if defined(HEDLEY_NO_THROW) - #undef HEDLEY_NO_THROW +#if defined(NLOHMANN_JSON_HEDLEY_NO_THROW) + #undef NLOHMANN_JSON_HEDLEY_NO_THROW #endif #if \ - HEDLEY_HAS_ATTRIBUTE(nothrow) || \ - HEDLEY_GCC_VERSION_CHECK(3,3,0) || \ - HEDLEY_INTEL_VERSION_CHECK(13,0,0) - #define HEDLEY_NO_THROW __attribute__((__nothrow__)) + NLOHMANN_JSON_HEDLEY_HAS_ATTRIBUTE(nothrow) || \ + NLOHMANN_JSON_HEDLEY_GCC_VERSION_CHECK(3,3,0) || \ + NLOHMANN_JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) + #define NLOHMANN_JSON_HEDLEY_NO_THROW __attribute__((__nothrow__)) #elif \ - HEDLEY_MSVC_VERSION_CHECK(13,1,0) || \ - HEDLEY_ARM_VERSION_CHECK(4,1,0) - #define HEDLEY_NO_THROW __declspec(nothrow) + NLOHMANN_JSON_HEDLEY_MSVC_VERSION_CHECK(13,1,0) || \ + NLOHMANN_JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) + #define NLOHMANN_JSON_HEDLEY_NO_THROW __declspec(nothrow) #else - #define HEDLEY_NO_THROW + #define NLOHMANN_JSON_HEDLEY_NO_THROW #endif -#if defined(HEDLEY_FALL_THROUGH) - #undef HEDLEY_FALL_THROUGH +#if defined(NLOHMANN_JSON_HEDLEY_FALL_THROUGH) + #undef NLOHMANN_JSON_HEDLEY_FALL_THROUGH #endif #if \ defined(__cplusplus) && \ - (!defined(HEDLEY_SUNPRO_VERSION) || HEDLEY_SUNPRO_VERSION_CHECK(5,15,0)) && \ - !defined(HEDLEY_PGI_VERSION) + (!defined(NLOHMANN_JSON_HEDLEY_SUNPRO_VERSION) || NLOHMANN_JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,15,0)) && \ + !defined(NLOHMANN_JSON_HEDLEY_PGI_VERSION) #if \ (__cplusplus >= 201703L) || \ - ((__cplusplus >= 201103L) && HEDLEY_HAS_CPP_ATTRIBUTE(fallthrough)) - #define HEDLEY_FALL_THROUGH [[fallthrough]] - #elif (__cplusplus >= 201103L) && HEDLEY_HAS_CPP_ATTRIBUTE(clang::fallthrough) - #define HEDLEY_FALL_THROUGH [[clang::fallthrough]] - #elif (__cplusplus >= 201103L) && HEDLEY_GCC_VERSION_CHECK(7,0,0) - #define HEDLEY_FALL_THROUGH [[gnu::fallthrough]] + ((__cplusplus >= 201103L) && NLOHMANN_JSON_HEDLEY_HAS_CPP_ATTRIBUTE(fallthrough)) + #define NLOHMANN_JSON_HEDLEY_FALL_THROUGH [[fallthrough]] + #elif (__cplusplus >= 201103L) && NLOHMANN_JSON_HEDLEY_HAS_CPP_ATTRIBUTE(clang::fallthrough) + #define NLOHMANN_JSON_HEDLEY_FALL_THROUGH [[clang::fallthrough]] + #elif (__cplusplus >= 201103L) && NLOHMANN_JSON_HEDLEY_GCC_VERSION_CHECK(7,0,0) + #define NLOHMANN_JSON_HEDLEY_FALL_THROUGH [[gnu::fallthrough]] #endif #endif -#if !defined(HEDLEY_FALL_THROUGH) - #if HEDLEY_GNUC_HAS_ATTRIBUTE(fallthrough,7,0,0) && !defined(HEDLEY_PGI_VERSION) - #define HEDLEY_FALL_THROUGH __attribute__((__fallthrough__)) +#if !defined(NLOHMANN_JSON_HEDLEY_FALL_THROUGH) + #if NLOHMANN_JSON_HEDLEY_GNUC_HAS_ATTRIBUTE(fallthrough,7,0,0) && !defined(NLOHMANN_JSON_HEDLEY_PGI_VERSION) + #define NLOHMANN_JSON_HEDLEY_FALL_THROUGH __attribute__((__fallthrough__)) #elif defined(__fallthrough) /* SAL */ - #define HEDLEY_FALL_THROUGH __fallthrough + #define NLOHMANN_JSON_HEDLEY_FALL_THROUGH __fallthrough #else - #define HEDLEY_FALL_THROUGH + #define NLOHMANN_JSON_HEDLEY_FALL_THROUGH #endif #endif -#if defined(HEDLEY_RETURNS_NON_NULL) - #undef HEDLEY_RETURNS_NON_NULL +#if defined(NLOHMANN_JSON_HEDLEY_RETURNS_NON_NULL) + #undef NLOHMANN_JSON_HEDLEY_RETURNS_NON_NULL #endif #if \ - HEDLEY_HAS_ATTRIBUTE(returns_nonnull) || \ - HEDLEY_GCC_VERSION_CHECK(4,9,0) - #define HEDLEY_RETURNS_NON_NULL __attribute__((__returns_nonnull__)) + NLOHMANN_JSON_HEDLEY_HAS_ATTRIBUTE(returns_nonnull) || \ + NLOHMANN_JSON_HEDLEY_GCC_VERSION_CHECK(4,9,0) + #define NLOHMANN_JSON_HEDLEY_RETURNS_NON_NULL __attribute__((__returns_nonnull__)) #elif defined(_Ret_notnull_) /* SAL */ - #define HEDLEY_RETURNS_NON_NULL _Ret_notnull_ + #define NLOHMANN_JSON_HEDLEY_RETURNS_NON_NULL _Ret_notnull_ #else - #define HEDLEY_RETURNS_NON_NULL + #define NLOHMANN_JSON_HEDLEY_RETURNS_NON_NULL #endif -#if defined(HEDLEY_ARRAY_PARAM) - #undef HEDLEY_ARRAY_PARAM +#if defined(NLOHMANN_JSON_HEDLEY_ARRAY_PARAM) + #undef NLOHMANN_JSON_HEDLEY_ARRAY_PARAM #endif #if \ defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) && \ !defined(__STDC_NO_VLA__) && \ !defined(__cplusplus) && \ - !defined(HEDLEY_PGI_VERSION) && \ - !defined(HEDLEY_TINYC_VERSION) - #define HEDLEY_ARRAY_PARAM(name) (name) + !defined(NLOHMANN_JSON_HEDLEY_PGI_VERSION) && \ + !defined(NLOHMANN_JSON_HEDLEY_TINYC_VERSION) + #define NLOHMANN_JSON_HEDLEY_ARRAY_PARAM(name) (name) #else - #define HEDLEY_ARRAY_PARAM(name) + #define NLOHMANN_JSON_HEDLEY_ARRAY_PARAM(name) #endif -#if defined(HEDLEY_IS_CONSTANT) - #undef HEDLEY_IS_CONSTANT +#if defined(NLOHMANN_JSON_HEDLEY_IS_CONSTANT) + #undef NLOHMANN_JSON_HEDLEY_IS_CONSTANT #endif -#if defined(HEDLEY_REQUIRE_CONSTEXPR) - #undef HEDLEY_REQUIRE_CONSTEXPR +#if defined(NLOHMANN_JSON_HEDLEY_REQUIRE_CONSTEXPR) + #undef NLOHMANN_JSON_HEDLEY_REQUIRE_CONSTEXPR #endif /* Note the double-underscore. For internal use only; no API * guarantees! */ -#if defined(HEDLEY__IS_CONSTEXPR) - #undef HEDLEY__IS_CONSTEXPR +#if defined(NLOHMANN_JSON_HEDLEY__IS_CONSTEXPR) + #undef NLOHMANN_JSON_HEDLEY__IS_CONSTEXPR #endif #if \ - HEDLEY_HAS_BUILTIN(__builtin_constant_p) || \ - HEDLEY_GCC_VERSION_CHECK(3,4,0) || \ - HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ - HEDLEY_TINYC_VERSION_CHECK(0,9,19) || \ - HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ - HEDLEY_IBM_VERSION_CHECK(13,1,0) || \ - HEDLEY_TI_VERSION_CHECK(6,1,0) || \ - HEDLEY_SUNPRO_VERSION_CHECK(5,10,0) || \ - HEDLEY_CRAY_VERSION_CHECK(8,1,0) - #define HEDLEY_IS_CONSTANT(expr) __builtin_constant_p(expr) + NLOHMANN_JSON_HEDLEY_HAS_BUILTIN(__builtin_constant_p) || \ + NLOHMANN_JSON_HEDLEY_GCC_VERSION_CHECK(3,4,0) || \ + NLOHMANN_JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ + NLOHMANN_JSON_HEDLEY_TINYC_VERSION_CHECK(0,9,19) || \ + NLOHMANN_JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ + NLOHMANN_JSON_HEDLEY_IBM_VERSION_CHECK(13,1,0) || \ + NLOHMANN_JSON_HEDLEY_TI_VERSION_CHECK(6,1,0) || \ + NLOHMANN_JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,10,0) || \ + NLOHMANN_JSON_HEDLEY_CRAY_VERSION_CHECK(8,1,0) + #define NLOHMANN_JSON_HEDLEY_IS_CONSTANT(expr) __builtin_constant_p(expr) #endif #if !defined(__cplusplus) # if \ - HEDLEY_HAS_BUILTIN(__builtin_types_compatible_p) || \ - HEDLEY_GCC_VERSION_CHECK(3,4,0) || \ - HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ - HEDLEY_IBM_VERSION_CHECK(13,1,0) || \ - HEDLEY_CRAY_VERSION_CHECK(8,1,0) || \ - HEDLEY_ARM_VERSION_CHECK(5,4,0) || \ - HEDLEY_TINYC_VERSION_CHECK(0,9,24) + NLOHMANN_JSON_HEDLEY_HAS_BUILTIN(__builtin_types_compatible_p) || \ + NLOHMANN_JSON_HEDLEY_GCC_VERSION_CHECK(3,4,0) || \ + NLOHMANN_JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ + NLOHMANN_JSON_HEDLEY_IBM_VERSION_CHECK(13,1,0) || \ + NLOHMANN_JSON_HEDLEY_CRAY_VERSION_CHECK(8,1,0) || \ + NLOHMANN_JSON_HEDLEY_ARM_VERSION_CHECK(5,4,0) || \ + NLOHMANN_JSON_HEDLEY_TINYC_VERSION_CHECK(0,9,24) #if defined(__INTPTR_TYPE__) - #define HEDLEY__IS_CONSTEXPR(expr) __builtin_types_compatible_p(__typeof__((1 ? (void*) ((__INTPTR_TYPE__) ((expr) * 0)) : (int*) 0)), int*) + #define NLOHMANN_JSON_HEDLEY__IS_CONSTEXPR(expr) __builtin_types_compatible_p(__typeof__((1 ? (void*) ((__INTPTR_TYPE__) ((expr) * 0)) : (int*) 0)), int*) #else #include - #define HEDLEY__IS_CONSTEXPR(expr) __builtin_types_compatible_p(__typeof__((1 ? (void*) ((intptr_t) ((expr) * 0)) : (int*) 0)), int*) + #define NLOHMANN_JSON_HEDLEY__IS_CONSTEXPR(expr) __builtin_types_compatible_p(__typeof__((1 ? (void*) ((intptr_t) ((expr) * 0)) : (int*) 0)), int*) #endif # elif \ - (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 201112L) && !defined(HEDLEY_SUNPRO_VERSION) && !defined(HEDLEY_PGI_VERSION)) || \ - HEDLEY_HAS_EXTENSION(c_generic_selections) || \ - HEDLEY_GCC_VERSION_CHECK(4,9,0) || \ - HEDLEY_INTEL_VERSION_CHECK(17,0,0) || \ - HEDLEY_IBM_VERSION_CHECK(12,1,0) || \ - HEDLEY_ARM_VERSION_CHECK(5,3,0) + (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 201112L) && !defined(NLOHMANN_JSON_HEDLEY_SUNPRO_VERSION) && !defined(NLOHMANN_JSON_HEDLEY_PGI_VERSION)) || \ + NLOHMANN_JSON_HEDLEY_HAS_EXTENSION(c_generic_selections) || \ + NLOHMANN_JSON_HEDLEY_GCC_VERSION_CHECK(4,9,0) || \ + NLOHMANN_JSON_HEDLEY_INTEL_VERSION_CHECK(17,0,0) || \ + NLOHMANN_JSON_HEDLEY_IBM_VERSION_CHECK(12,1,0) || \ + NLOHMANN_JSON_HEDLEY_ARM_VERSION_CHECK(5,3,0) #if defined(__INTPTR_TYPE__) - #define HEDLEY__IS_CONSTEXPR(expr) _Generic((1 ? (void*) ((__INTPTR_TYPE__) ((expr) * 0)) : (int*) 0), int*: 1, void*: 0) + #define NLOHMANN_JSON_HEDLEY__IS_CONSTEXPR(expr) _Generic((1 ? (void*) ((__INTPTR_TYPE__) ((expr) * 0)) : (int*) 0), int*: 1, void*: 0) #else #include - #define HEDLEY__IS_CONSTEXPR(expr) _Generic((1 ? (void*) ((intptr_t) * 0) : (int*) 0), int*: 1, void*: 0) + #define NLOHMANN_JSON_HEDLEY__IS_CONSTEXPR(expr) _Generic((1 ? (void*) ((intptr_t) * 0) : (int*) 0), int*: 1, void*: 0) #endif # elif \ - defined(HEDLEY_GCC_VERSION) || \ - defined(HEDLEY_INTEL_VERSION) || \ - defined(HEDLEY_TINYC_VERSION) || \ - defined(HEDLEY_TI_VERSION) || \ + defined(NLOHMANN_JSON_HEDLEY_GCC_VERSION) || \ + defined(NLOHMANN_JSON_HEDLEY_INTEL_VERSION) || \ + defined(NLOHMANN_JSON_HEDLEY_TINYC_VERSION) || \ + defined(NLOHMANN_JSON_HEDLEY_TI_VERSION) || \ defined(__clang__) -# define HEDLEY__IS_CONSTEXPR(expr) ( \ +# define NLOHMANN_JSON_HEDLEY__IS_CONSTEXPR(expr) ( \ sizeof(void) != \ sizeof(*( \ 1 ? \ @@ -1380,241 +1380,241 @@ HEDLEY_DIAGNOSTIC_POP ((struct { char v[sizeof(void) * 2]; } *) 1) \ ) \ ) \ - ) + ) # endif #endif -#if defined(HEDLEY__IS_CONSTEXPR) - #if !defined(HEDLEY_IS_CONSTANT) - #define HEDLEY_IS_CONSTANT(expr) HEDLEY__IS_CONSTEXPR(expr) +#if defined(NLOHMANN_JSON_HEDLEY__IS_CONSTEXPR) + #if !defined(NLOHMANN_JSON_HEDLEY_IS_CONSTANT) + #define NLOHMANN_JSON_HEDLEY_IS_CONSTANT(expr) NLOHMANN_JSON_HEDLEY__IS_CONSTEXPR(expr) #endif - #define HEDLEY_REQUIRE_CONSTEXPR(expr) (HEDLEY__IS_CONSTEXPR(expr) ? (expr) : (-1)) + #define NLOHMANN_JSON_HEDLEY_REQUIRE_CONSTEXPR(expr) (NLOHMANN_JSON_HEDLEY__IS_CONSTEXPR(expr) ? (expr) : (-1)) #else - #if !defined(HEDLEY_IS_CONSTANT) - #define HEDLEY_IS_CONSTANT(expr) (0) + #if !defined(NLOHMANN_JSON_HEDLEY_IS_CONSTANT) + #define NLOHMANN_JSON_HEDLEY_IS_CONSTANT(expr) (0) #endif - #define HEDLEY_REQUIRE_CONSTEXPR(expr) (expr) + #define NLOHMANN_JSON_HEDLEY_REQUIRE_CONSTEXPR(expr) (expr) #endif -#if defined(HEDLEY_BEGIN_C_DECLS) - #undef HEDLEY_BEGIN_C_DECLS +#if defined(NLOHMANN_JSON_HEDLEY_BEGIN_C_DECLS) + #undef NLOHMANN_JSON_HEDLEY_BEGIN_C_DECLS #endif -#if defined(HEDLEY_END_C_DECLS) - #undef HEDLEY_END_C_DECLS +#if defined(NLOHMANN_JSON_HEDLEY_END_C_DECLS) + #undef NLOHMANN_JSON_HEDLEY_END_C_DECLS #endif -#if defined(HEDLEY_C_DECL) - #undef HEDLEY_C_DECL +#if defined(NLOHMANN_JSON_HEDLEY_C_DECL) + #undef NLOHMANN_JSON_HEDLEY_C_DECL #endif #if defined(__cplusplus) - #define HEDLEY_BEGIN_C_DECLS extern "C" { - #define HEDLEY_END_C_DECLS } - #define HEDLEY_C_DECL extern "C" + #define NLOHMANN_JSON_HEDLEY_BEGIN_C_DECLS extern "C" { + #define NLOHMANN_JSON_HEDLEY_END_C_DECLS } + #define NLOHMANN_JSON_HEDLEY_C_DECL extern "C" #else - #define HEDLEY_BEGIN_C_DECLS - #define HEDLEY_END_C_DECLS - #define HEDLEY_C_DECL + #define NLOHMANN_JSON_HEDLEY_BEGIN_C_DECLS + #define NLOHMANN_JSON_HEDLEY_END_C_DECLS + #define NLOHMANN_JSON_HEDLEY_C_DECL #endif -#if defined(HEDLEY_STATIC_ASSERT) - #undef HEDLEY_STATIC_ASSERT +#if defined(NLOHMANN_JSON_HEDLEY_STATIC_ASSERT) + #undef NLOHMANN_JSON_HEDLEY_STATIC_ASSERT #endif #if \ !defined(__cplusplus) && ( \ (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 201112L)) || \ - HEDLEY_HAS_FEATURE(c_static_assert) || \ - HEDLEY_GCC_VERSION_CHECK(6,0,0) || \ - HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ + NLOHMANN_JSON_HEDLEY_HAS_FEATURE(c_static_assert) || \ + NLOHMANN_JSON_HEDLEY_GCC_VERSION_CHECK(6,0,0) || \ + NLOHMANN_JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ defined(_Static_assert) \ ) -# define HEDLEY_STATIC_ASSERT(expr, message) _Static_assert(expr, message) +# define NLOHMANN_JSON_HEDLEY_STATIC_ASSERT(expr, message) _Static_assert(expr, message) #elif \ (defined(__cplusplus) && (__cplusplus >= 201703L)) || \ - HEDLEY_MSVC_VERSION_CHECK(16,0,0) || \ - (defined(__cplusplus) && HEDLEY_TI_VERSION_CHECK(8,3,0)) -# define HEDLEY_STATIC_ASSERT(expr, message) static_assert(expr, message) + NLOHMANN_JSON_HEDLEY_MSVC_VERSION_CHECK(16,0,0) || \ + (defined(__cplusplus) && NLOHMANN_JSON_HEDLEY_TI_VERSION_CHECK(8,3,0)) +# define NLOHMANN_JSON_HEDLEY_STATIC_ASSERT(expr, message) static_assert(expr, message) #elif defined(__cplusplus) && (__cplusplus >= 201103L) -# define HEDLEY_STATIC_ASSERT(expr, message) static_assert(expr) +# define NLOHMANN_JSON_HEDLEY_STATIC_ASSERT(expr, message) static_assert(expr) #else -# define HEDLEY_STATIC_ASSERT(expr, message) +# define NLOHMANN_JSON_HEDLEY_STATIC_ASSERT(expr, message) #endif -#if defined(HEDLEY_CONST_CAST) - #undef HEDLEY_CONST_CAST +#if defined(NLOHMANN_JSON_HEDLEY_CONST_CAST) + #undef NLOHMANN_JSON_HEDLEY_CONST_CAST #endif #if defined(__cplusplus) -# define HEDLEY_CONST_CAST(T, expr) (const_cast(expr)) +# define NLOHMANN_JSON_HEDLEY_CONST_CAST(T, expr) (const_cast(expr)) #elif \ - HEDLEY_HAS_WARNING("-Wcast-qual") || \ - HEDLEY_GCC_VERSION_CHECK(4,6,0) || \ - HEDLEY_INTEL_VERSION_CHECK(13,0,0) -# define HEDLEY_CONST_CAST(T, expr) (__extension__ ({ \ - HEDLEY_DIAGNOSTIC_PUSH \ - HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL \ + NLOHMANN_JSON_HEDLEY_HAS_WARNING("-Wcast-qual") || \ + NLOHMANN_JSON_HEDLEY_GCC_VERSION_CHECK(4,6,0) || \ + NLOHMANN_JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) +# define NLOHMANN_JSON_HEDLEY_CONST_CAST(T, expr) (__extension__ ({ \ + NLOHMANN_JSON_HEDLEY_DIAGNOSTIC_PUSH \ + NLOHMANN_JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL \ ((T) (expr)); \ - HEDLEY_DIAGNOSTIC_POP \ + NLOHMANN_JSON_HEDLEY_DIAGNOSTIC_POP \ })) #else -# define HEDLEY_CONST_CAST(T, expr) ((T) (expr)) +# define NLOHMANN_JSON_HEDLEY_CONST_CAST(T, expr) ((T) (expr)) #endif -#if defined(HEDLEY_REINTERPRET_CAST) - #undef HEDLEY_REINTERPRET_CAST +#if defined(NLOHMANN_JSON_HEDLEY_REINTERPRET_CAST) + #undef NLOHMANN_JSON_HEDLEY_REINTERPRET_CAST #endif #if defined(__cplusplus) - #define HEDLEY_REINTERPRET_CAST(T, expr) (reinterpret_cast(expr)) + #define NLOHMANN_JSON_HEDLEY_REINTERPRET_CAST(T, expr) (reinterpret_cast(expr)) #else - #define HEDLEY_REINTERPRET_CAST(T, expr) (*((T*) &(expr))) + #define NLOHMANN_JSON_HEDLEY_REINTERPRET_CAST(T, expr) (*((T*) &(expr))) #endif -#if defined(HEDLEY_STATIC_CAST) - #undef HEDLEY_STATIC_CAST +#if defined(NLOHMANN_JSON_HEDLEY_STATIC_CAST) + #undef NLOHMANN_JSON_HEDLEY_STATIC_CAST #endif #if defined(__cplusplus) - #define HEDLEY_STATIC_CAST(T, expr) (static_cast(expr)) + #define NLOHMANN_JSON_HEDLEY_STATIC_CAST(T, expr) (static_cast(expr)) #else - #define HEDLEY_STATIC_CAST(T, expr) ((T) (expr)) + #define NLOHMANN_JSON_HEDLEY_STATIC_CAST(T, expr) ((T) (expr)) #endif -#if defined(HEDLEY_CPP_CAST) - #undef HEDLEY_CPP_CAST +#if defined(NLOHMANN_JSON_HEDLEY_CPP_CAST) + #undef NLOHMANN_JSON_HEDLEY_CPP_CAST #endif #if defined(__cplusplus) - #define HEDLEY_CPP_CAST(T, expr) static_cast(expr) + #define NLOHMANN_JSON_HEDLEY_CPP_CAST(T, expr) static_cast(expr) #else - #define HEDLEY_CPP_CAST(T, expr) (expr) + #define NLOHMANN_JSON_HEDLEY_CPP_CAST(T, expr) (expr) #endif -#if defined(HEDLEY_MESSAGE) - #undef HEDLEY_MESSAGE +#if defined(NLOHMANN_JSON_HEDLEY_MESSAGE) + #undef NLOHMANN_JSON_HEDLEY_MESSAGE #endif -#if HEDLEY_HAS_WARNING("-Wunknown-pragmas") -# define HEDLEY_MESSAGE(msg) \ - HEDLEY_DIAGNOSTIC_PUSH \ - HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS \ - HEDLEY_PRAGMA(message msg) \ - HEDLEY_DIAGNOSTIC_POP +#if NLOHMANN_JSON_HEDLEY_HAS_WARNING("-Wunknown-pragmas") +# define NLOHMANN_JSON_HEDLEY_MESSAGE(msg) \ + NLOHMANN_JSON_HEDLEY_DIAGNOSTIC_PUSH \ + NLOHMANN_JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS \ + NLOHMANN_JSON_HEDLEY_PRAGMA(message msg) \ + NLOHMANN_JSON_HEDLEY_DIAGNOSTIC_POP #elif \ - HEDLEY_GCC_VERSION_CHECK(4,4,0) || \ - HEDLEY_INTEL_VERSION_CHECK(13,0,0) -# define HEDLEY_MESSAGE(msg) HEDLEY_PRAGMA(message msg) -#elif HEDLEY_CRAY_VERSION_CHECK(5,0,0) -# define HEDLEY_MESSAGE(msg) HEDLEY_PRAGMA(_CRI message msg) -#elif HEDLEY_IAR_VERSION_CHECK(8,0,0) -# define HEDLEY_MESSAGE(msg) HEDLEY_PRAGMA(message(msg)) -#elif HEDLEY_PELLES_VERSION_CHECK(2,0,0) -# define HEDLEY_MESSAGE(msg) HEDLEY_PRAGMA(message(msg)) + NLOHMANN_JSON_HEDLEY_GCC_VERSION_CHECK(4,4,0) || \ + NLOHMANN_JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) +# define NLOHMANN_JSON_HEDLEY_MESSAGE(msg) NLOHMANN_JSON_HEDLEY_PRAGMA(message msg) +#elif NLOHMANN_JSON_HEDLEY_CRAY_VERSION_CHECK(5,0,0) +# define NLOHMANN_JSON_HEDLEY_MESSAGE(msg) NLOHMANN_JSON_HEDLEY_PRAGMA(_CRI message msg) +#elif NLOHMANN_JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0) +# define NLOHMANN_JSON_HEDLEY_MESSAGE(msg) NLOHMANN_JSON_HEDLEY_PRAGMA(message(msg)) +#elif NLOHMANN_JSON_HEDLEY_PELLES_VERSION_CHECK(2,0,0) +# define NLOHMANN_JSON_HEDLEY_MESSAGE(msg) NLOHMANN_JSON_HEDLEY_PRAGMA(message(msg)) #else -# define HEDLEY_MESSAGE(msg) +# define NLOHMANN_JSON_HEDLEY_MESSAGE(msg) #endif -#if defined(HEDLEY_WARNING) - #undef HEDLEY_WARNING +#if defined(NLOHMANN_JSON_HEDLEY_WARNING) + #undef NLOHMANN_JSON_HEDLEY_WARNING #endif -#if HEDLEY_HAS_WARNING("-Wunknown-pragmas") -# define HEDLEY_WARNING(msg) \ - HEDLEY_DIAGNOSTIC_PUSH \ - HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS \ - HEDLEY_PRAGMA(clang warning msg) \ - HEDLEY_DIAGNOSTIC_POP +#if NLOHMANN_JSON_HEDLEY_HAS_WARNING("-Wunknown-pragmas") +# define NLOHMANN_JSON_HEDLEY_WARNING(msg) \ + NLOHMANN_JSON_HEDLEY_DIAGNOSTIC_PUSH \ + NLOHMANN_JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS \ + NLOHMANN_JSON_HEDLEY_PRAGMA(clang warning msg) \ + NLOHMANN_JSON_HEDLEY_DIAGNOSTIC_POP #elif \ - HEDLEY_GCC_VERSION_CHECK(4,8,0) || \ - HEDLEY_PGI_VERSION_CHECK(18,4,0) -# define HEDLEY_WARNING(msg) HEDLEY_PRAGMA(GCC warning msg) -#elif HEDLEY_MSVC_VERSION_CHECK(15,0,0) -# define HEDLEY_WARNING(msg) HEDLEY_PRAGMA(message(msg)) + NLOHMANN_JSON_HEDLEY_GCC_VERSION_CHECK(4,8,0) || \ + NLOHMANN_JSON_HEDLEY_PGI_VERSION_CHECK(18,4,0) +# define NLOHMANN_JSON_HEDLEY_WARNING(msg) NLOHMANN_JSON_HEDLEY_PRAGMA(GCC warning msg) +#elif NLOHMANN_JSON_HEDLEY_MSVC_VERSION_CHECK(15,0,0) +# define NLOHMANN_JSON_HEDLEY_WARNING(msg) NLOHMANN_JSON_HEDLEY_PRAGMA(message(msg)) #else -# define HEDLEY_WARNING(msg) HEDLEY_MESSAGE(msg) +# define NLOHMANN_JSON_HEDLEY_WARNING(msg) NLOHMANN_JSON_HEDLEY_MESSAGE(msg) #endif -#if defined(HEDLEY_REQUIRE_MSG) - #undef HEDLEY_REQUIRE_MSG +#if defined(NLOHMANN_JSON_HEDLEY_REQUIRE_MSG) + #undef NLOHMANN_JSON_HEDLEY_REQUIRE_MSG #endif -#if HEDLEY_HAS_ATTRIBUTE(diagnose_if) -# if HEDLEY_HAS_WARNING("-Wgcc-compat") -# define HEDLEY_REQUIRE_MSG(expr, msg) \ - HEDLEY_DIAGNOSTIC_PUSH \ +#if NLOHMANN_JSON_HEDLEY_HAS_ATTRIBUTE(diagnose_if) +# if NLOHMANN_JSON_HEDLEY_HAS_WARNING("-Wgcc-compat") +# define NLOHMANN_JSON_HEDLEY_REQUIRE_MSG(expr, msg) \ + NLOHMANN_JSON_HEDLEY_DIAGNOSTIC_PUSH \ _Pragma("clang diagnostic ignored \"-Wgcc-compat\"") \ __attribute__((__diagnose_if__(!(expr), msg, "error"))) \ - HEDLEY_DIAGNOSTIC_POP + NLOHMANN_JSON_HEDLEY_DIAGNOSTIC_POP # else -# define HEDLEY_REQUIRE_MSG(expr, msg) __attribute__((__diagnose_if__(!(expr), msg, "error"))) +# define NLOHMANN_JSON_HEDLEY_REQUIRE_MSG(expr, msg) __attribute__((__diagnose_if__(!(expr), msg, "error"))) # endif #else -# define HEDLEY_REQUIRE_MSG(expr, msg) +# define NLOHMANN_JSON_HEDLEY_REQUIRE_MSG(expr, msg) #endif -#if defined(HEDLEY_REQUIRE) - #undef HEDLEY_REQUIRE +#if defined(NLOHMANN_JSON_HEDLEY_REQUIRE) + #undef NLOHMANN_JSON_HEDLEY_REQUIRE #endif -#define HEDLEY_REQUIRE(expr) HEDLEY_REQUIRE_MSG(expr, #expr) +#define NLOHMANN_JSON_HEDLEY_REQUIRE(expr) NLOHMANN_JSON_HEDLEY_REQUIRE_MSG(expr, #expr) -#if defined(HEDLEY_FLAGS) - #undef HEDLEY_FLAGS +#if defined(NLOHMANN_JSON_HEDLEY_FLAGS) + #undef NLOHMANN_JSON_HEDLEY_FLAGS #endif -#if HEDLEY_HAS_ATTRIBUTE(flag_enum) - #define HEDLEY_FLAGS __attribute__((__flag_enum__)) +#if NLOHMANN_JSON_HEDLEY_HAS_ATTRIBUTE(flag_enum) + #define NLOHMANN_JSON_HEDLEY_FLAGS __attribute__((__flag_enum__)) #endif -#if defined(HEDLEY_FLAGS_CAST) - #undef HEDLEY_FLAGS_CAST +#if defined(NLOHMANN_JSON_HEDLEY_FLAGS_CAST) + #undef NLOHMANN_JSON_HEDLEY_FLAGS_CAST #endif -#if HEDLEY_INTEL_VERSION_CHECK(19,0,0) -# define HEDLEY_FLAGS_CAST(T, expr) (__extension__ ({ \ - HEDLEY_DIAGNOSTIC_PUSH \ +#if NLOHMANN_JSON_HEDLEY_INTEL_VERSION_CHECK(19,0,0) +# define NLOHMANN_JSON_HEDLEY_FLAGS_CAST(T, expr) (__extension__ ({ \ + NLOHMANN_JSON_HEDLEY_DIAGNOSTIC_PUSH \ _Pragma("warning(disable:188)") \ ((T) (expr)); \ - HEDLEY_DIAGNOSTIC_POP \ + NLOHMANN_JSON_HEDLEY_DIAGNOSTIC_POP \ })) #else -# define HEDLEY_FLAGS_CAST(T, expr) HEDLEY_STATIC_CAST(T, expr) +# define NLOHMANN_JSON_HEDLEY_FLAGS_CAST(T, expr) NLOHMANN_JSON_HEDLEY_STATIC_CAST(T, expr) #endif /* Remaining macros are deprecated. */ -#if defined(HEDLEY_GCC_NOT_CLANG_VERSION_CHECK) - #undef HEDLEY_GCC_NOT_CLANG_VERSION_CHECK +#if defined(NLOHMANN_JSON_HEDLEY_GCC_NOT_CLANG_VERSION_CHECK) + #undef NLOHMANN_JSON_HEDLEY_GCC_NOT_CLANG_VERSION_CHECK #endif #if defined(__clang__) - #define HEDLEY_GCC_NOT_CLANG_VERSION_CHECK(major,minor,patch) (0) + #define NLOHMANN_JSON_HEDLEY_GCC_NOT_CLANG_VERSION_CHECK(major,minor,patch) (0) #else - #define HEDLEY_GCC_NOT_CLANG_VERSION_CHECK(major,minor,patch) HEDLEY_GCC_VERSION_CHECK(major,minor,patch) + #define NLOHMANN_JSON_HEDLEY_GCC_NOT_CLANG_VERSION_CHECK(major,minor,patch) NLOHMANN_JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch) #endif -#if defined(HEDLEY_CLANG_HAS_ATTRIBUTE) - #undef HEDLEY_CLANG_HAS_ATTRIBUTE +#if defined(NLOHMANN_JSON_HEDLEY_CLANG_HAS_ATTRIBUTE) + #undef NLOHMANN_JSON_HEDLEY_CLANG_HAS_ATTRIBUTE #endif -#define HEDLEY_CLANG_HAS_ATTRIBUTE(attribute) HEDLEY_HAS_ATTRIBUTE(attribute) +#define NLOHMANN_JSON_HEDLEY_CLANG_HAS_ATTRIBUTE(attribute) NLOHMANN_JSON_HEDLEY_HAS_ATTRIBUTE(attribute) -#if defined(HEDLEY_CLANG_HAS_CPP_ATTRIBUTE) - #undef HEDLEY_CLANG_HAS_CPP_ATTRIBUTE +#if defined(NLOHMANN_JSON_HEDLEY_CLANG_HAS_CPP_ATTRIBUTE) + #undef NLOHMANN_JSON_HEDLEY_CLANG_HAS_CPP_ATTRIBUTE #endif -#define HEDLEY_CLANG_HAS_CPP_ATTRIBUTE(attribute) HEDLEY_HAS_CPP_ATTRIBUTE(attribute) +#define NLOHMANN_JSON_HEDLEY_CLANG_HAS_CPP_ATTRIBUTE(attribute) NLOHMANN_JSON_HEDLEY_HAS_CPP_ATTRIBUTE(attribute) -#if defined(HEDLEY_CLANG_HAS_BUILTIN) - #undef HEDLEY_CLANG_HAS_BUILTIN +#if defined(NLOHMANN_JSON_HEDLEY_CLANG_HAS_BUILTIN) + #undef NLOHMANN_JSON_HEDLEY_CLANG_HAS_BUILTIN #endif -#define HEDLEY_CLANG_HAS_BUILTIN(builtin) HEDLEY_HAS_BUILTIN(builtin) +#define NLOHMANN_JSON_HEDLEY_CLANG_HAS_BUILTIN(builtin) NLOHMANN_JSON_HEDLEY_HAS_BUILTIN(builtin) -#if defined(HEDLEY_CLANG_HAS_FEATURE) - #undef HEDLEY_CLANG_HAS_FEATURE +#if defined(NLOHMANN_JSON_HEDLEY_CLANG_HAS_FEATURE) + #undef NLOHMANN_JSON_HEDLEY_CLANG_HAS_FEATURE #endif -#define HEDLEY_CLANG_HAS_FEATURE(feature) HEDLEY_HAS_FEATURE(feature) +#define NLOHMANN_JSON_HEDLEY_CLANG_HAS_FEATURE(feature) NLOHMANN_JSON_HEDLEY_HAS_FEATURE(feature) -#if defined(HEDLEY_CLANG_HAS_EXTENSION) - #undef HEDLEY_CLANG_HAS_EXTENSION +#if defined(NLOHMANN_JSON_HEDLEY_CLANG_HAS_EXTENSION) + #undef NLOHMANN_JSON_HEDLEY_CLANG_HAS_EXTENSION #endif -#define HEDLEY_CLANG_HAS_EXTENSION(extension) HEDLEY_HAS_EXTENSION(extension) +#define NLOHMANN_JSON_HEDLEY_CLANG_HAS_EXTENSION(extension) NLOHMANN_JSON_HEDLEY_HAS_EXTENSION(extension) -#if defined(HEDLEY_CLANG_HAS_DECLSPEC_DECLSPEC_ATTRIBUTE) - #undef HEDLEY_CLANG_HAS_DECLSPEC_DECLSPEC_ATTRIBUTE +#if defined(NLOHMANN_JSON_HEDLEY_CLANG_HAS_DECLSPEC_DECLSPEC_ATTRIBUTE) + #undef NLOHMANN_JSON_HEDLEY_CLANG_HAS_DECLSPEC_DECLSPEC_ATTRIBUTE #endif -#define HEDLEY_CLANG_HAS_DECLSPEC_ATTRIBUTE(attribute) HEDLEY_HAS_DECLSPEC_ATTRIBUTE(attribute) +#define NLOHMANN_JSON_HEDLEY_CLANG_HAS_DECLSPEC_ATTRIBUTE(attribute) NLOHMANN_JSON_HEDLEY_HAS_DECLSPEC_ATTRIBUTE(attribute) -#if defined(HEDLEY_CLANG_HAS_WARNING) - #undef HEDLEY_CLANG_HAS_WARNING +#if defined(NLOHMANN_JSON_HEDLEY_CLANG_HAS_WARNING) + #undef NLOHMANN_JSON_HEDLEY_CLANG_HAS_WARNING #endif -#define HEDLEY_CLANG_HAS_WARNING(warning) HEDLEY_HAS_WARNING(warning) +#define NLOHMANN_JSON_HEDLEY_CLANG_HAS_WARNING(warning) NLOHMANN_JSON_HEDLEY_HAS_WARNING(warning) -#endif /* !defined(HEDLEY_VERSION) || (HEDLEY_VERSION < X) */ +#endif /* !defined(NLOHMANN_JSON_HEDLEY_VERSION) || (NLOHMANN_JSON_HEDLEY_VERSION < X) */ // This file contains all internal macro definitions @@ -1775,7 +1775,7 @@ class exception : public std::exception { public: /// returns the explanatory string - HEDLEY_RETURNS_NON_NULL + NLOHMANN_JSON_HEDLEY_RETURNS_NON_NULL const char* what() const noexcept override { return m.what(); @@ -1785,7 +1785,7 @@ class exception : public std::exception const int id; protected: - HEDLEY_NON_NULL(3) + NLOHMANN_JSON_HEDLEY_NON_NULL(3) exception(int id_, const char* what_arg) : id(id_), m(what_arg) {} static std::string name(const std::string& ename, int id_) @@ -1938,7 +1938,7 @@ class invalid_iterator : public exception } private: - HEDLEY_NON_NULL(3) + NLOHMANN_JSON_HEDLEY_NON_NULL(3) invalid_iterator(int id_, const char* what_arg) : exception(id_, what_arg) {} }; @@ -1992,7 +1992,7 @@ class type_error : public exception } private: - HEDLEY_NON_NULL(3) + NLOHMANN_JSON_HEDLEY_NON_NULL(3) type_error(int id_, const char* what_arg) : exception(id_, what_arg) {} }; @@ -2039,7 +2039,7 @@ class out_of_range : public exception } private: - HEDLEY_NON_NULL(3) + NLOHMANN_JSON_HEDLEY_NON_NULL(3) out_of_range(int id_, const char* what_arg) : exception(id_, what_arg) {} }; @@ -2077,7 +2077,7 @@ class other_error : public exception } private: - HEDLEY_NON_NULL(3) + NLOHMANN_JSON_HEDLEY_NON_NULL(3) other_error(int id_, const char* what_arg) : exception(id_, what_arg) {} }; } // namespace detail @@ -2794,7 +2794,7 @@ namespace detail template void from_json(const BasicJsonType& j, typename std::nullptr_t& n) { - if (HEDLEY_UNLIKELY(not j.is_null())) + if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not j.is_null())) { JSON_THROW(type_error::create(302, "type must be null, but is " + std::string(j.type_name()))); } @@ -2834,7 +2834,7 @@ void get_arithmetic_value(const BasicJsonType& j, ArithmeticType& val) template void from_json(const BasicJsonType& j, typename BasicJsonType::boolean_t& b) { - if (HEDLEY_UNLIKELY(not j.is_boolean())) + if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not j.is_boolean())) { JSON_THROW(type_error::create(302, "type must be boolean, but is " + std::string(j.type_name()))); } @@ -2844,7 +2844,7 @@ void from_json(const BasicJsonType& j, typename BasicJsonType::boolean_t& b) template void from_json(const BasicJsonType& j, typename BasicJsonType::string_t& s) { - if (HEDLEY_UNLIKELY(not j.is_string())) + if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not j.is_string())) { JSON_THROW(type_error::create(302, "type must be string, but is " + std::string(j.type_name()))); } @@ -2860,7 +2860,7 @@ template < int > = 0 > void from_json(const BasicJsonType& j, ConstructibleStringType& s) { - if (HEDLEY_UNLIKELY(not j.is_string())) + if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not j.is_string())) { JSON_THROW(type_error::create(302, "type must be string, but is " + std::string(j.type_name()))); } @@ -2900,7 +2900,7 @@ template::value, int> = 0> void from_json(const BasicJsonType& j, std::forward_list& l) { - if (HEDLEY_UNLIKELY(not j.is_array())) + if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not j.is_array())) { JSON_THROW(type_error::create(302, "type must be array, but is " + std::string(j.type_name()))); } @@ -2917,7 +2917,7 @@ template::value, int> = 0> void from_json(const BasicJsonType& j, std::valarray& l) { - if (HEDLEY_UNLIKELY(not j.is_array())) + if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not j.is_array())) { JSON_THROW(type_error::create(302, "type must be array, but is " + std::string(j.type_name()))); } @@ -3004,7 +3004,7 @@ auto from_json(const BasicJsonType& j, ConstructibleArrayType& arr) j.template get(), void()) { - if (HEDLEY_UNLIKELY(not j.is_array())) + if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not j.is_array())) { JSON_THROW(type_error::create(302, "type must be array, but is " + std::string(j.type_name()))); @@ -3017,7 +3017,7 @@ template::value, int> = 0> void from_json(const BasicJsonType& j, ConstructibleObjectType& obj) { - if (HEDLEY_UNLIKELY(not j.is_object())) + if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not j.is_object())) { JSON_THROW(type_error::create(302, "type must be object, but is " + std::string(j.type_name()))); } @@ -3100,14 +3100,14 @@ template ::value>> void from_json(const BasicJsonType& j, std::map& m) { - if (HEDLEY_UNLIKELY(not j.is_array())) + if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not j.is_array())) { JSON_THROW(type_error::create(302, "type must be array, but is " + std::string(j.type_name()))); } m.clear(); for (const auto& p : j) { - if (HEDLEY_UNLIKELY(not p.is_array())) + if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not p.is_array())) { JSON_THROW(type_error::create(302, "type must be array, but is " + std::string(p.type_name()))); } @@ -3120,14 +3120,14 @@ template ::value>> void from_json(const BasicJsonType& j, std::unordered_map& m) { - if (HEDLEY_UNLIKELY(not j.is_array())) + if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not j.is_array())) { JSON_THROW(type_error::create(302, "type must be array, but is " + std::string(j.type_name()))); } m.clear(); for (const auto& p : j) { - if (HEDLEY_UNLIKELY(not p.is_array())) + if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not p.is_array())) { JSON_THROW(type_error::create(302, "type must be array, but is " + std::string(p.type_name()))); } @@ -3806,7 +3806,7 @@ Input adapter for stdio file access. This adapter read only 1 byte and do not us class file_input_adapter : public input_adapter_protocol { public: - HEDLEY_NON_NULL(2) + NLOHMANN_JSON_HEDLEY_NON_NULL(2) explicit file_input_adapter(std::FILE* f) noexcept : m_file(f) {} @@ -3882,7 +3882,7 @@ class input_stream_adapter : public input_adapter_protocol class input_buffer_adapter : public input_adapter_protocol { public: - HEDLEY_NON_NULL(2) + NLOHMANN_JSON_HEDLEY_NON_NULL(2) input_buffer_adapter(const char* b, const std::size_t l) noexcept : cursor(b), limit(b + l) {} @@ -3896,7 +3896,7 @@ class input_buffer_adapter : public input_adapter_protocol std::char_traits::int_type get_character() noexcept override { - if (HEDLEY_LIKELY(cursor < limit)) + if (NLOHMANN_JSON_HEDLEY_LIKELY(cursor < limit)) { return std::char_traits::to_int_type(*(cursor++)); } @@ -4086,7 +4086,7 @@ class input_adapter { public: // native support - HEDLEY_NON_NULL(2) + NLOHMANN_JSON_HEDLEY_NON_NULL(2) input_adapter(std::FILE* file) : ia(std::make_shared(file)) {} /// input adapter for input stream @@ -4155,7 +4155,7 @@ class input_adapter "each element in the iterator range must have the size of 1 byte"); const auto len = static_cast(std::distance(first, last)); - if (HEDLEY_LIKELY(len > 0)) + if (NLOHMANN_JSON_HEDLEY_LIKELY(len > 0)) { // there is at least one element: use the address of first ia = std::make_shared(reinterpret_cast(&(*first)), len); @@ -4403,7 +4403,7 @@ class json_sax_dom_parser { ref_stack.push_back(handle_value(BasicJsonType::value_t::object)); - if (HEDLEY_UNLIKELY(len != std::size_t(-1) and len > ref_stack.back()->max_size())) + if (NLOHMANN_JSON_HEDLEY_UNLIKELY(len != std::size_t(-1) and len > ref_stack.back()->max_size())) { JSON_THROW(out_of_range::create(408, "excessive object size: " + std::to_string(len))); @@ -4429,7 +4429,7 @@ class json_sax_dom_parser { ref_stack.push_back(handle_value(BasicJsonType::value_t::array)); - if (HEDLEY_UNLIKELY(len != std::size_t(-1) and len > ref_stack.back()->max_size())) + if (NLOHMANN_JSON_HEDLEY_UNLIKELY(len != std::size_t(-1) and len > ref_stack.back()->max_size())) { JSON_THROW(out_of_range::create(408, "excessive array size: " + std::to_string(len))); @@ -4485,7 +4485,7 @@ class json_sax_dom_parser object to which we can add elements */ template - HEDLEY_RETURNS_NON_NULL + NLOHMANN_JSON_HEDLEY_RETURNS_NON_NULL BasicJsonType* handle_value(Value&& v) { if (ref_stack.empty()) @@ -4592,7 +4592,7 @@ class json_sax_dom_callback_parser ref_stack.push_back(val.second); // check object limit - if (ref_stack.back() and HEDLEY_UNLIKELY(len != std::size_t(-1) and len > ref_stack.back()->max_size())) + if (ref_stack.back() and NLOHMANN_JSON_HEDLEY_UNLIKELY(len != std::size_t(-1) and len > ref_stack.back()->max_size())) { JSON_THROW(out_of_range::create(408, "excessive object size: " + std::to_string(len))); } @@ -4655,7 +4655,7 @@ class json_sax_dom_callback_parser ref_stack.push_back(val.second); // check array limit - if (ref_stack.back() and HEDLEY_UNLIKELY(len != std::size_t(-1) and len > ref_stack.back()->max_size())) + if (ref_stack.back() and NLOHMANN_JSON_HEDLEY_UNLIKELY(len != std::size_t(-1) and len > ref_stack.back()->max_size())) { JSON_THROW(out_of_range::create(408, "excessive array size: " + std::to_string(len))); } @@ -5094,7 +5094,7 @@ class binary_reader @return */ - HEDLEY_NON_NULL(3) + NLOHMANN_JSON_HEDLEY_NON_NULL(3) bool sax_parse(const input_format_t format, json_sax_t* sax_, const bool strict = true) @@ -5136,7 +5136,7 @@ class binary_reader get(); } - if (HEDLEY_UNLIKELY(current != std::char_traits::eof())) + if (NLOHMANN_JSON_HEDLEY_UNLIKELY(current != std::char_traits::eof())) { return sax->parse_error(chars_read, get_token_string(), parse_error::create(110, chars_read, exception_message(format, "expected end of input; last byte: 0x" + get_token_string(), "value"))); @@ -5172,12 +5172,12 @@ class binary_reader std::int32_t document_size; get_number(input_format_t::bson, document_size); - if (HEDLEY_UNLIKELY(not sax->start_object(std::size_t(-1)))) + if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not sax->start_object(std::size_t(-1)))) { return false; } - if (HEDLEY_UNLIKELY(not parse_bson_element_list(/*is_array*/false))) + if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not parse_bson_element_list(/*is_array*/false))) { return false; } @@ -5198,7 +5198,7 @@ class binary_reader while (true) { get(); - if (HEDLEY_UNLIKELY(not unexpect_eof(input_format_t::bson, "cstring"))) + if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not unexpect_eof(input_format_t::bson, "cstring"))) { return false; } @@ -5226,7 +5226,7 @@ class binary_reader template bool get_bson_string(const NumberType len, string_t& result) { - if (HEDLEY_UNLIKELY(len < 1)) + if (NLOHMANN_JSON_HEDLEY_UNLIKELY(len < 1)) { auto last_token = get_token_string(); return sax->parse_error(chars_read, last_token, parse_error::create(112, chars_read, exception_message(input_format_t::bson, "string length must be at least 1, is " + std::to_string(len), "string"))); @@ -5321,13 +5321,13 @@ class binary_reader string_t key; while (int element_type = get()) { - if (HEDLEY_UNLIKELY(not unexpect_eof(input_format_t::bson, "element list"))) + if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not unexpect_eof(input_format_t::bson, "element list"))) { return false; } const std::size_t element_type_parse_position = chars_read; - if (HEDLEY_UNLIKELY(not get_bson_cstr(key))) + if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not get_bson_cstr(key))) { return false; } @@ -5337,7 +5337,7 @@ class binary_reader return false; } - if (HEDLEY_UNLIKELY(not parse_bson_element_internal(element_type, element_type_parse_position))) + if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not parse_bson_element_internal(element_type, element_type_parse_position))) { return false; } @@ -5358,12 +5358,12 @@ class binary_reader std::int32_t document_size; get_number(input_format_t::bson, document_size); - if (HEDLEY_UNLIKELY(not sax->start_array(std::size_t(-1)))) + if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not sax->start_array(std::size_t(-1)))) { return false; } - if (HEDLEY_UNLIKELY(not parse_bson_element_list(/*is_array*/true))) + if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not parse_bson_element_list(/*is_array*/true))) { return false; } @@ -5648,12 +5648,12 @@ class binary_reader case 0xF9: // Half-Precision Float (two-byte IEEE 754) { const int byte1_raw = get(); - if (HEDLEY_UNLIKELY(not unexpect_eof(input_format_t::cbor, "number"))) + if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not unexpect_eof(input_format_t::cbor, "number"))) { return false; } const int byte2_raw = get(); - if (HEDLEY_UNLIKELY(not unexpect_eof(input_format_t::cbor, "number"))) + if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not unexpect_eof(input_format_t::cbor, "number"))) { return false; } @@ -5726,7 +5726,7 @@ class binary_reader */ bool get_cbor_string(string_t& result) { - if (HEDLEY_UNLIKELY(not unexpect_eof(input_format_t::cbor, "string"))) + if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not unexpect_eof(input_format_t::cbor, "string"))) { return false; } @@ -5815,7 +5815,7 @@ class binary_reader */ bool get_cbor_array(const std::size_t len) { - if (HEDLEY_UNLIKELY(not sax->start_array(len))) + if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not sax->start_array(len))) { return false; } @@ -5824,7 +5824,7 @@ class binary_reader { for (std::size_t i = 0; i < len; ++i) { - if (HEDLEY_UNLIKELY(not parse_cbor_internal())) + if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not parse_cbor_internal())) { return false; } @@ -5834,7 +5834,7 @@ class binary_reader { while (get() != 0xFF) { - if (HEDLEY_UNLIKELY(not parse_cbor_internal(false))) + if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not parse_cbor_internal(false))) { return false; } @@ -5851,7 +5851,7 @@ class binary_reader */ bool get_cbor_object(const std::size_t len) { - if (HEDLEY_UNLIKELY(not sax->start_object(len))) + if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not sax->start_object(len))) { return false; } @@ -5862,12 +5862,12 @@ class binary_reader for (std::size_t i = 0; i < len; ++i) { get(); - if (HEDLEY_UNLIKELY(not get_cbor_string(key) or not sax->key(key))) + if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not get_cbor_string(key) or not sax->key(key))) { return false; } - if (HEDLEY_UNLIKELY(not parse_cbor_internal())) + if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not parse_cbor_internal())) { return false; } @@ -5878,12 +5878,12 @@ class binary_reader { while (get() != 0xFF) { - if (HEDLEY_UNLIKELY(not get_cbor_string(key) or not sax->key(key))) + if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not get_cbor_string(key) or not sax->key(key))) { return false; } - if (HEDLEY_UNLIKELY(not parse_cbor_internal())) + if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not parse_cbor_internal())) { return false; } @@ -6272,7 +6272,7 @@ class binary_reader */ bool get_msgpack_string(string_t& result) { - if (HEDLEY_UNLIKELY(not unexpect_eof(input_format_t::msgpack, "string"))) + if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not unexpect_eof(input_format_t::msgpack, "string"))) { return false; } @@ -6348,14 +6348,14 @@ class binary_reader */ bool get_msgpack_array(const std::size_t len) { - if (HEDLEY_UNLIKELY(not sax->start_array(len))) + if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not sax->start_array(len))) { return false; } for (std::size_t i = 0; i < len; ++i) { - if (HEDLEY_UNLIKELY(not parse_msgpack_internal())) + if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not parse_msgpack_internal())) { return false; } @@ -6370,7 +6370,7 @@ class binary_reader */ bool get_msgpack_object(const std::size_t len) { - if (HEDLEY_UNLIKELY(not sax->start_object(len))) + if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not sax->start_object(len))) { return false; } @@ -6379,12 +6379,12 @@ class binary_reader for (std::size_t i = 0; i < len; ++i) { get(); - if (HEDLEY_UNLIKELY(not get_msgpack_string(key) or not sax->key(key))) + if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not get_msgpack_string(key) or not sax->key(key))) { return false; } - if (HEDLEY_UNLIKELY(not parse_msgpack_internal())) + if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not parse_msgpack_internal())) { return false; } @@ -6431,7 +6431,7 @@ class binary_reader get(); // TODO(niels): may we ignore N here? } - if (HEDLEY_UNLIKELY(not unexpect_eof(input_format_t::ubjson, "value"))) + if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not unexpect_eof(input_format_t::ubjson, "value"))) { return false; } @@ -6485,7 +6485,7 @@ class binary_reader case 'U': { std::uint8_t number; - if (HEDLEY_UNLIKELY(not get_number(input_format_t::ubjson, number))) + if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not get_number(input_format_t::ubjson, number))) { return false; } @@ -6496,7 +6496,7 @@ class binary_reader case 'i': { std::int8_t number; - if (HEDLEY_UNLIKELY(not get_number(input_format_t::ubjson, number))) + if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not get_number(input_format_t::ubjson, number))) { return false; } @@ -6507,7 +6507,7 @@ class binary_reader case 'I': { std::int16_t number; - if (HEDLEY_UNLIKELY(not get_number(input_format_t::ubjson, number))) + if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not get_number(input_format_t::ubjson, number))) { return false; } @@ -6518,7 +6518,7 @@ class binary_reader case 'l': { std::int32_t number; - if (HEDLEY_UNLIKELY(not get_number(input_format_t::ubjson, number))) + if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not get_number(input_format_t::ubjson, number))) { return false; } @@ -6529,7 +6529,7 @@ class binary_reader case 'L': { std::int64_t number; - if (HEDLEY_UNLIKELY(not get_number(input_format_t::ubjson, number))) + if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not get_number(input_format_t::ubjson, number))) { return false; } @@ -6565,15 +6565,15 @@ class binary_reader if (current == '$') { result.second = get(); // must not ignore 'N', because 'N' maybe the type - if (HEDLEY_UNLIKELY(not unexpect_eof(input_format_t::ubjson, "type"))) + if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not unexpect_eof(input_format_t::ubjson, "type"))) { return false; } get_ignore_noop(); - if (HEDLEY_UNLIKELY(current != '#')) + if (NLOHMANN_JSON_HEDLEY_UNLIKELY(current != '#')) { - if (HEDLEY_UNLIKELY(not unexpect_eof(input_format_t::ubjson, "value"))) + if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not unexpect_eof(input_format_t::ubjson, "value"))) { return false; } @@ -6656,11 +6656,11 @@ class binary_reader case 'C': // char { get(); - if (HEDLEY_UNLIKELY(not unexpect_eof(input_format_t::ubjson, "char"))) + if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not unexpect_eof(input_format_t::ubjson, "char"))) { return false; } - if (HEDLEY_UNLIKELY(current > 127)) + if (NLOHMANN_JSON_HEDLEY_UNLIKELY(current > 127)) { auto last_token = get_token_string(); return sax->parse_error(chars_read, last_token, parse_error::create(113, chars_read, exception_message(input_format_t::ubjson, "byte after 'C' must be in range 0x00..0x7F; last byte: 0x" + last_token, "char"))); @@ -6695,14 +6695,14 @@ class binary_reader bool get_ubjson_array() { std::pair size_and_type; - if (HEDLEY_UNLIKELY(not get_ubjson_size_type(size_and_type))) + if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not get_ubjson_size_type(size_and_type))) { return false; } if (size_and_type.first != string_t::npos) { - if (HEDLEY_UNLIKELY(not sax->start_array(size_and_type.first))) + if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not sax->start_array(size_and_type.first))) { return false; } @@ -6713,7 +6713,7 @@ class binary_reader { for (std::size_t i = 0; i < size_and_type.first; ++i) { - if (HEDLEY_UNLIKELY(not get_ubjson_value(size_and_type.second))) + if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not get_ubjson_value(size_and_type.second))) { return false; } @@ -6724,7 +6724,7 @@ class binary_reader { for (std::size_t i = 0; i < size_and_type.first; ++i) { - if (HEDLEY_UNLIKELY(not parse_ubjson_internal())) + if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not parse_ubjson_internal())) { return false; } @@ -6733,14 +6733,14 @@ class binary_reader } else { - if (HEDLEY_UNLIKELY(not sax->start_array(std::size_t(-1)))) + if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not sax->start_array(std::size_t(-1)))) { return false; } while (current != ']') { - if (HEDLEY_UNLIKELY(not parse_ubjson_internal(false))) + if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not parse_ubjson_internal(false))) { return false; } @@ -6757,7 +6757,7 @@ class binary_reader bool get_ubjson_object() { std::pair size_and_type; - if (HEDLEY_UNLIKELY(not get_ubjson_size_type(size_and_type))) + if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not get_ubjson_size_type(size_and_type))) { return false; } @@ -6765,7 +6765,7 @@ class binary_reader string_t key; if (size_and_type.first != string_t::npos) { - if (HEDLEY_UNLIKELY(not sax->start_object(size_and_type.first))) + if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not sax->start_object(size_and_type.first))) { return false; } @@ -6774,11 +6774,11 @@ class binary_reader { for (std::size_t i = 0; i < size_and_type.first; ++i) { - if (HEDLEY_UNLIKELY(not get_ubjson_string(key) or not sax->key(key))) + if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not get_ubjson_string(key) or not sax->key(key))) { return false; } - if (HEDLEY_UNLIKELY(not get_ubjson_value(size_and_type.second))) + if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not get_ubjson_value(size_and_type.second))) { return false; } @@ -6789,11 +6789,11 @@ class binary_reader { for (std::size_t i = 0; i < size_and_type.first; ++i) { - if (HEDLEY_UNLIKELY(not get_ubjson_string(key) or not sax->key(key))) + if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not get_ubjson_string(key) or not sax->key(key))) { return false; } - if (HEDLEY_UNLIKELY(not parse_ubjson_internal())) + if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not parse_ubjson_internal())) { return false; } @@ -6803,18 +6803,18 @@ class binary_reader } else { - if (HEDLEY_UNLIKELY(not sax->start_object(std::size_t(-1)))) + if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not sax->start_object(std::size_t(-1)))) { return false; } while (current != '}') { - if (HEDLEY_UNLIKELY(not get_ubjson_string(key, false) or not sax->key(key))) + if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not get_ubjson_string(key, false) or not sax->key(key))) { return false; } - if (HEDLEY_UNLIKELY(not parse_ubjson_internal())) + if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not parse_ubjson_internal())) { return false; } @@ -6880,7 +6880,7 @@ class binary_reader for (std::size_t i = 0; i < sizeof(NumberType); ++i) { get(); - if (HEDLEY_UNLIKELY(not unexpect_eof(format, "number"))) + if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not unexpect_eof(format, "number"))) { return false; } @@ -6924,7 +6924,7 @@ class binary_reader std::generate_n(std::back_inserter(result), len, [this, &success, &format]() { get(); - if (HEDLEY_UNLIKELY(not unexpect_eof(format, "string"))) + if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not unexpect_eof(format, "string"))) { success = false; } @@ -6938,10 +6938,10 @@ class binary_reader @param[in] context further context information (for diagnostics) @return whether the last read character is not EOF */ - HEDLEY_NON_NULL(3) + NLOHMANN_JSON_HEDLEY_NON_NULL(3) bool unexpect_eof(const input_format_t format, const char* context) const { - if (HEDLEY_UNLIKELY(current == std::char_traits::eof())) + if (NLOHMANN_JSON_HEDLEY_UNLIKELY(current == std::char_traits::eof())) { return sax->parse_error(chars_read, "", parse_error::create(110, chars_read, exception_message(format, "unexpected end of input", context))); @@ -7082,7 +7082,7 @@ class lexer }; /// return name of values of type token_type (only used for errors) - HEDLEY_RETURNS_NON_NULL + NLOHMANN_JSON_HEDLEY_RETURNS_NON_NULL static const char* token_type_name(const token_type t) noexcept { switch (t) @@ -7224,7 +7224,7 @@ class lexer for (auto range = ranges.begin(); range != ranges.end(); ++range) { get(); - if (HEDLEY_LIKELY(*range <= current and current <= *(++range))) + if (NLOHMANN_JSON_HEDLEY_LIKELY(*range <= current and current <= *(++range))) { add(current); } @@ -7323,7 +7323,7 @@ class lexer const int codepoint1 = get_codepoint(); int codepoint = codepoint1; // start with codepoint1 - if (HEDLEY_UNLIKELY(codepoint1 == -1)) + if (NLOHMANN_JSON_HEDLEY_UNLIKELY(codepoint1 == -1)) { error_message = "invalid string: '\\u' must be followed by 4 hex digits"; return token_type::parse_error; @@ -7333,18 +7333,18 @@ class lexer if (0xD800 <= codepoint1 and codepoint1 <= 0xDBFF) { // expect next \uxxxx entry - if (HEDLEY_LIKELY(get() == '\\' and get() == 'u')) + if (NLOHMANN_JSON_HEDLEY_LIKELY(get() == '\\' and get() == 'u')) { const int codepoint2 = get_codepoint(); - if (HEDLEY_UNLIKELY(codepoint2 == -1)) + if (NLOHMANN_JSON_HEDLEY_UNLIKELY(codepoint2 == -1)) { error_message = "invalid string: '\\u' must be followed by 4 hex digits"; return token_type::parse_error; } // check if codepoint2 is a low surrogate - if (HEDLEY_LIKELY(0xDC00 <= codepoint2 and codepoint2 <= 0xDFFF)) + if (NLOHMANN_JSON_HEDLEY_LIKELY(0xDC00 <= codepoint2 and codepoint2 <= 0xDFFF)) { // overwrite codepoint codepoint = static_cast( @@ -7371,7 +7371,7 @@ class lexer } else { - if (HEDLEY_UNLIKELY(0xDC00 <= codepoint1 and codepoint1 <= 0xDFFF)) + if (NLOHMANN_JSON_HEDLEY_UNLIKELY(0xDC00 <= codepoint1 and codepoint1 <= 0xDFFF)) { error_message = "invalid string: surrogate U+DC00..U+DFFF must follow U+D800..U+DBFF"; return token_type::parse_error; @@ -7746,7 +7746,7 @@ class lexer case 0xDE: case 0xDF: { - if (HEDLEY_UNLIKELY(not next_byte_in_range({0x80, 0xBF}))) + if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not next_byte_in_range({0x80, 0xBF}))) { return token_type::parse_error; } @@ -7756,7 +7756,7 @@ class lexer // U+0800..U+0FFF: bytes E0 A0..BF 80..BF case 0xE0: { - if (HEDLEY_UNLIKELY(not (next_byte_in_range({0xA0, 0xBF, 0x80, 0xBF})))) + if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not (next_byte_in_range({0xA0, 0xBF, 0x80, 0xBF})))) { return token_type::parse_error; } @@ -7780,7 +7780,7 @@ class lexer case 0xEE: case 0xEF: { - if (HEDLEY_UNLIKELY(not (next_byte_in_range({0x80, 0xBF, 0x80, 0xBF})))) + if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not (next_byte_in_range({0x80, 0xBF, 0x80, 0xBF})))) { return token_type::parse_error; } @@ -7790,7 +7790,7 @@ class lexer // U+D000..U+D7FF: bytes ED 80..9F 80..BF case 0xED: { - if (HEDLEY_UNLIKELY(not (next_byte_in_range({0x80, 0x9F, 0x80, 0xBF})))) + if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not (next_byte_in_range({0x80, 0x9F, 0x80, 0xBF})))) { return token_type::parse_error; } @@ -7800,7 +7800,7 @@ class lexer // U+10000..U+3FFFF F0 90..BF 80..BF 80..BF case 0xF0: { - if (HEDLEY_UNLIKELY(not (next_byte_in_range({0x90, 0xBF, 0x80, 0xBF, 0x80, 0xBF})))) + if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not (next_byte_in_range({0x90, 0xBF, 0x80, 0xBF, 0x80, 0xBF})))) { return token_type::parse_error; } @@ -7812,7 +7812,7 @@ class lexer case 0xF2: case 0xF3: { - if (HEDLEY_UNLIKELY(not (next_byte_in_range({0x80, 0xBF, 0x80, 0xBF, 0x80, 0xBF})))) + if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not (next_byte_in_range({0x80, 0xBF, 0x80, 0xBF, 0x80, 0xBF})))) { return token_type::parse_error; } @@ -7822,7 +7822,7 @@ class lexer // U+100000..U+10FFFF F4 80..8F 80..BF 80..BF case 0xF4: { - if (HEDLEY_UNLIKELY(not (next_byte_in_range({0x80, 0x8F, 0x80, 0xBF, 0x80, 0xBF})))) + if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not (next_byte_in_range({0x80, 0x8F, 0x80, 0xBF, 0x80, 0xBF})))) { return token_type::parse_error; } @@ -7839,19 +7839,19 @@ class lexer } } - HEDLEY_NON_NULL(2) + NLOHMANN_JSON_HEDLEY_NON_NULL(2) static void strtof(float& f, const char* str, char** endptr) noexcept { f = std::strtof(str, endptr); } - HEDLEY_NON_NULL(2) + NLOHMANN_JSON_HEDLEY_NON_NULL(2) static void strtof(double& f, const char* str, char** endptr) noexcept { f = std::strtod(str, endptr); } - HEDLEY_NON_NULL(2) + NLOHMANN_JSON_HEDLEY_NON_NULL(2) static void strtof(long double& f, const char* str, char** endptr) noexcept { f = std::strtold(str, endptr); @@ -8227,14 +8227,14 @@ scan_number_done: @param[in] length the length of the passed literal text @param[in] return_type the token type to return on success */ - HEDLEY_NON_NULL(2) + NLOHMANN_JSON_HEDLEY_NON_NULL(2) token_type scan_literal(const char* literal_text, const std::size_t length, token_type return_type) { assert(current == literal_text[0]); for (std::size_t i = 1; i < length; ++i) { - if (HEDLEY_UNLIKELY(get() != literal_text[i])) + if (NLOHMANN_JSON_HEDLEY_UNLIKELY(get() != literal_text[i])) { error_message = "invalid literal"; return token_type::parse_error; @@ -8280,7 +8280,7 @@ scan_number_done: current = ia->get_character(); } - if (HEDLEY_LIKELY(current != std::char_traits::eof())) + if (NLOHMANN_JSON_HEDLEY_LIKELY(current != std::char_traits::eof())) { token_string.push_back(std::char_traits::to_char_type(current)); } @@ -8321,7 +8321,7 @@ scan_number_done: --position.chars_read_current_line; } - if (HEDLEY_LIKELY(current != std::char_traits::eof())) + if (NLOHMANN_JSON_HEDLEY_LIKELY(current != std::char_traits::eof())) { assert(not token_string.empty()); token_string.pop_back(); @@ -8400,7 +8400,7 @@ scan_number_done: } /// return syntax error message - HEDLEY_RETURNS_NON_NULL + NLOHMANN_JSON_HEDLEY_RETURNS_NON_NULL constexpr const char* get_error_message() const noexcept { return error_message; @@ -8689,7 +8689,7 @@ class parser } template - HEDLEY_NON_NULL(2) + NLOHMANN_JSON_HEDLEY_NON_NULL(2) bool sax_parse(SAX* sax, const bool strict = true) { (void)detail::is_sax_static_asserts {}; @@ -8709,7 +8709,7 @@ class parser private: template - HEDLEY_NON_NULL(2) + NLOHMANN_JSON_HEDLEY_NON_NULL(2) bool sax_parse_internal(SAX* sax) { // stack to remember the hierarchy of structured values we are parsing @@ -8727,7 +8727,7 @@ class parser { case token_type::begin_object: { - if (HEDLEY_UNLIKELY(not sax->start_object(std::size_t(-1)))) + if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not sax->start_object(std::size_t(-1)))) { return false; } @@ -8735,7 +8735,7 @@ class parser // closing } -> we are done if (get_token() == token_type::end_object) { - if (HEDLEY_UNLIKELY(not sax->end_object())) + if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not sax->end_object())) { return false; } @@ -8743,20 +8743,20 @@ class parser } // parse key - if (HEDLEY_UNLIKELY(last_token != token_type::value_string)) + if (NLOHMANN_JSON_HEDLEY_UNLIKELY(last_token != token_type::value_string)) { return sax->parse_error(m_lexer.get_position(), m_lexer.get_token_string(), parse_error::create(101, m_lexer.get_position(), exception_message(token_type::value_string, "object key"))); } - if (HEDLEY_UNLIKELY(not sax->key(m_lexer.get_string()))) + if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not sax->key(m_lexer.get_string()))) { return false; } // parse separator (:) - if (HEDLEY_UNLIKELY(get_token() != token_type::name_separator)) + if (NLOHMANN_JSON_HEDLEY_UNLIKELY(get_token() != token_type::name_separator)) { return sax->parse_error(m_lexer.get_position(), m_lexer.get_token_string(), @@ -8774,7 +8774,7 @@ class parser case token_type::begin_array: { - if (HEDLEY_UNLIKELY(not sax->start_array(std::size_t(-1)))) + if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not sax->start_array(std::size_t(-1)))) { return false; } @@ -8782,7 +8782,7 @@ class parser // closing ] -> we are done if (get_token() == token_type::end_array) { - if (HEDLEY_UNLIKELY(not sax->end_array())) + if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not sax->end_array())) { return false; } @@ -8800,14 +8800,14 @@ class parser { const auto res = m_lexer.get_number_float(); - if (HEDLEY_UNLIKELY(not std::isfinite(res))) + if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not std::isfinite(res))) { return sax->parse_error(m_lexer.get_position(), m_lexer.get_token_string(), out_of_range::create(406, "number overflow parsing '" + m_lexer.get_token_string() + "'")); } - if (HEDLEY_UNLIKELY(not sax->number_float(res, m_lexer.get_string()))) + if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not sax->number_float(res, m_lexer.get_string()))) { return false; } @@ -8817,7 +8817,7 @@ class parser case token_type::literal_false: { - if (HEDLEY_UNLIKELY(not sax->boolean(false))) + if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not sax->boolean(false))) { return false; } @@ -8826,7 +8826,7 @@ class parser case token_type::literal_null: { - if (HEDLEY_UNLIKELY(not sax->null())) + if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not sax->null())) { return false; } @@ -8835,7 +8835,7 @@ class parser case token_type::literal_true: { - if (HEDLEY_UNLIKELY(not sax->boolean(true))) + if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not sax->boolean(true))) { return false; } @@ -8844,7 +8844,7 @@ class parser case token_type::value_integer: { - if (HEDLEY_UNLIKELY(not sax->number_integer(m_lexer.get_number_integer()))) + if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not sax->number_integer(m_lexer.get_number_integer()))) { return false; } @@ -8853,7 +8853,7 @@ class parser case token_type::value_string: { - if (HEDLEY_UNLIKELY(not sax->string(m_lexer.get_string()))) + if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not sax->string(m_lexer.get_string()))) { return false; } @@ -8862,7 +8862,7 @@ class parser case token_type::value_unsigned: { - if (HEDLEY_UNLIKELY(not sax->number_unsigned(m_lexer.get_number_unsigned()))) + if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not sax->number_unsigned(m_lexer.get_number_unsigned()))) { return false; } @@ -8910,9 +8910,9 @@ class parser } // closing ] - if (HEDLEY_LIKELY(last_token == token_type::end_array)) + if (NLOHMANN_JSON_HEDLEY_LIKELY(last_token == token_type::end_array)) { - if (HEDLEY_UNLIKELY(not sax->end_array())) + if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not sax->end_array())) { return false; } @@ -8938,7 +8938,7 @@ class parser if (get_token() == token_type::value_separator) { // parse key - if (HEDLEY_UNLIKELY(get_token() != token_type::value_string)) + if (NLOHMANN_JSON_HEDLEY_UNLIKELY(get_token() != token_type::value_string)) { return sax->parse_error(m_lexer.get_position(), m_lexer.get_token_string(), @@ -8946,13 +8946,13 @@ class parser exception_message(token_type::value_string, "object key"))); } - if (HEDLEY_UNLIKELY(not sax->key(m_lexer.get_string()))) + if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not sax->key(m_lexer.get_string()))) { return false; } // parse separator (:) - if (HEDLEY_UNLIKELY(get_token() != token_type::name_separator)) + if (NLOHMANN_JSON_HEDLEY_UNLIKELY(get_token() != token_type::name_separator)) { return sax->parse_error(m_lexer.get_position(), m_lexer.get_token_string(), @@ -8966,9 +8966,9 @@ class parser } // closing } - if (HEDLEY_LIKELY(last_token == token_type::end_object)) + if (NLOHMANN_JSON_HEDLEY_LIKELY(last_token == token_type::end_object)) { - if (HEDLEY_UNLIKELY(not sax->end_object())) + if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not sax->end_object())) { return false; } @@ -9452,7 +9452,7 @@ class iter_impl default: { - if (HEDLEY_LIKELY(m_it.primitive_iterator.is_begin())) + if (NLOHMANN_JSON_HEDLEY_LIKELY(m_it.primitive_iterator.is_begin())) { return *m_object; } @@ -9486,7 +9486,7 @@ class iter_impl default: { - if (HEDLEY_LIKELY(m_it.primitive_iterator.is_begin())) + if (NLOHMANN_JSON_HEDLEY_LIKELY(m_it.primitive_iterator.is_begin())) { return m_object; } @@ -9589,7 +9589,7 @@ class iter_impl bool operator==(const iter_impl& other) const { // if objects are not the same, the comparison is undefined - if (HEDLEY_UNLIKELY(m_object != other.m_object)) + if (NLOHMANN_JSON_HEDLEY_UNLIKELY(m_object != other.m_object)) { JSON_THROW(invalid_iterator::create(212, "cannot compare iterators of different containers")); } @@ -9625,7 +9625,7 @@ class iter_impl bool operator<(const iter_impl& other) const { // if objects are not the same, the comparison is undefined - if (HEDLEY_UNLIKELY(m_object != other.m_object)) + if (NLOHMANN_JSON_HEDLEY_UNLIKELY(m_object != other.m_object)) { JSON_THROW(invalid_iterator::create(212, "cannot compare iterators of different containers")); } @@ -9785,7 +9785,7 @@ class iter_impl default: { - if (HEDLEY_LIKELY(m_it.primitive_iterator.get_value() == -n)) + if (NLOHMANN_JSON_HEDLEY_LIKELY(m_it.primitive_iterator.get_value() == -n)) { return *m_object; } @@ -9803,7 +9803,7 @@ class iter_impl { assert(m_object != nullptr); - if (HEDLEY_LIKELY(m_object->is_object())) + if (NLOHMANN_JSON_HEDLEY_LIKELY(m_object->is_object())) { return m_it.object_iterator->first; } @@ -10204,7 +10204,7 @@ class json_pointer */ void pop_back() { - if (HEDLEY_UNLIKELY(empty())) + if (NLOHMANN_JSON_HEDLEY_UNLIKELY(empty())) { JSON_THROW(detail::out_of_range::create(405, "JSON pointer has no parent")); } @@ -10228,7 +10228,7 @@ class json_pointer */ const std::string& back() { - if (HEDLEY_UNLIKELY(empty())) + if (NLOHMANN_JSON_HEDLEY_UNLIKELY(empty())) { JSON_THROW(detail::out_of_range::create(405, "JSON pointer has no parent")); } @@ -10292,7 +10292,7 @@ class json_pointer const int res = std::stoi(s, &processed_chars); // check if the string was completely read - if (HEDLEY_UNLIKELY(processed_chars != s.size())) + if (NLOHMANN_JSON_HEDLEY_UNLIKELY(processed_chars != s.size())) { JSON_THROW(detail::out_of_range::create(404, "unresolved reference token '" + s + "'")); } @@ -10302,7 +10302,7 @@ class json_pointer json_pointer top() const { - if (HEDLEY_UNLIKELY(empty())) + if (NLOHMANN_JSON_HEDLEY_UNLIKELY(empty())) { JSON_THROW(detail::out_of_range::create(405, "JSON pointer has no parent")); } @@ -10434,7 +10434,7 @@ class json_pointer case detail::value_t::array: { // error condition (cf. RFC 6901, Sect. 4) - if (HEDLEY_UNLIKELY(reference_token.size() > 1 and reference_token[0] == '0')) + if (NLOHMANN_JSON_HEDLEY_UNLIKELY(reference_token.size() > 1 and reference_token[0] == '0')) { JSON_THROW(detail::parse_error::create(106, 0, "array index '" + reference_token + @@ -10492,7 +10492,7 @@ class json_pointer case detail::value_t::array: { - if (HEDLEY_UNLIKELY(reference_token == "-")) + if (NLOHMANN_JSON_HEDLEY_UNLIKELY(reference_token == "-")) { // "-" always fails the range check JSON_THROW(detail::out_of_range::create(402, @@ -10501,7 +10501,7 @@ class json_pointer } // error condition (cf. RFC 6901, Sect. 4) - if (HEDLEY_UNLIKELY(reference_token.size() > 1 and reference_token[0] == '0')) + if (NLOHMANN_JSON_HEDLEY_UNLIKELY(reference_token.size() > 1 and reference_token[0] == '0')) { JSON_THROW(detail::parse_error::create(106, 0, "array index '" + reference_token + @@ -10557,7 +10557,7 @@ class json_pointer case detail::value_t::array: { - if (HEDLEY_UNLIKELY(reference_token == "-")) + if (NLOHMANN_JSON_HEDLEY_UNLIKELY(reference_token == "-")) { // "-" cannot be used for const access JSON_THROW(detail::out_of_range::create(402, @@ -10566,7 +10566,7 @@ class json_pointer } // error condition (cf. RFC 6901, Sect. 4) - if (HEDLEY_UNLIKELY(reference_token.size() > 1 and reference_token[0] == '0')) + if (NLOHMANN_JSON_HEDLEY_UNLIKELY(reference_token.size() > 1 and reference_token[0] == '0')) { JSON_THROW(detail::parse_error::create(106, 0, "array index '" + reference_token + @@ -10616,7 +10616,7 @@ class json_pointer case detail::value_t::array: { - if (HEDLEY_UNLIKELY(reference_token == "-")) + if (NLOHMANN_JSON_HEDLEY_UNLIKELY(reference_token == "-")) { // "-" always fails the range check JSON_THROW(detail::out_of_range::create(402, @@ -10625,7 +10625,7 @@ class json_pointer } // error condition (cf. RFC 6901, Sect. 4) - if (HEDLEY_UNLIKELY(reference_token.size() > 1 and reference_token[0] == '0')) + if (NLOHMANN_JSON_HEDLEY_UNLIKELY(reference_token.size() > 1 and reference_token[0] == '0')) { JSON_THROW(detail::parse_error::create(106, 0, "array index '" + reference_token + @@ -10672,7 +10672,7 @@ class json_pointer } // check if nonempty reference string begins with slash - if (HEDLEY_UNLIKELY(reference_string[0] != '/')) + if (NLOHMANN_JSON_HEDLEY_UNLIKELY(reference_string[0] != '/')) { JSON_THROW(detail::parse_error::create(107, 1, "JSON pointer must be empty or begin with '/' - was: '" + @@ -10707,9 +10707,9 @@ class json_pointer assert(reference_token[pos] == '~'); // ~ must be followed by 0 or 1 - if (HEDLEY_UNLIKELY(pos == reference_token.size() - 1 or - (reference_token[pos + 1] != '0' and - reference_token[pos + 1] != '1'))) + if (NLOHMANN_JSON_HEDLEY_UNLIKELY(pos == reference_token.size() - 1 or + (reference_token[pos + 1] != '0' and + reference_token[pos + 1] != '1'))) { JSON_THROW(detail::parse_error::create(108, 0, "escape character '~' must be followed with '0' or '1'")); } @@ -10834,7 +10834,7 @@ class json_pointer static BasicJsonType unflatten(const BasicJsonType& value) { - if (HEDLEY_UNLIKELY(not value.is_object())) + if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not value.is_object())) { JSON_THROW(detail::type_error::create(314, "only objects can be unflattened")); } @@ -10844,7 +10844,7 @@ class json_pointer // iterate the JSON object values for (const auto& element : *value.m_value.object) { - if (HEDLEY_UNLIKELY(not element.second.is_primitive())) + if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not element.second.is_primitive())) { JSON_THROW(detail::type_error::create(315, "values in object must be primitive")); } @@ -11034,7 +11034,7 @@ class output_vector_adapter : public output_adapter_protocol v.push_back(c); } - HEDLEY_NON_NULL(2) + NLOHMANN_JSON_HEDLEY_NON_NULL(2) void write_characters(const CharType* s, std::size_t length) override { std::copy(s, s + length, std::back_inserter(v)); @@ -11058,7 +11058,7 @@ class output_stream_adapter : public output_adapter_protocol stream.put(c); } - HEDLEY_NON_NULL(2) + NLOHMANN_JSON_HEDLEY_NON_NULL(2) void write_characters(const CharType* s, std::size_t length) override { stream.write(s, static_cast(length)); @@ -11082,7 +11082,7 @@ class output_string_adapter : public output_adapter_protocol str.push_back(c); } - HEDLEY_NON_NULL(2) + NLOHMANN_JSON_HEDLEY_NON_NULL(2) void write_characters(const CharType* s, std::size_t length) override { str.append(s, length); @@ -11821,7 +11821,7 @@ class binary_writer static std::size_t calc_bson_entry_header_size(const string_t& name) { const auto it = name.find(static_cast(0)); - if (HEDLEY_UNLIKELY(it != BasicJsonType::string_t::npos)) + if (NLOHMANN_JSON_HEDLEY_UNLIKELY(it != BasicJsonType::string_t::npos)) { JSON_THROW(out_of_range::create(409, "BSON key cannot contain code point U+0000 (at byte " + std::to_string(it) + ")")); @@ -13283,7 +13283,7 @@ v = buf * 10^decimal_exponent len is the length of the buffer (number of decimal digits) The buffer must be large enough, i.e. >= max_digits10. */ -HEDLEY_NON_NULL(1) +NLOHMANN_JSON_HEDLEY_NON_NULL(1) inline void grisu2(char* buf, int& len, int& decimal_exponent, diyfp m_minus, diyfp v, diyfp m_plus) { @@ -13343,7 +13343,7 @@ len is the length of the buffer (number of decimal digits) The buffer must be large enough, i.e. >= max_digits10. */ template -HEDLEY_NON_NULL(1) +NLOHMANN_JSON_HEDLEY_NON_NULL(1) void grisu2(char* buf, int& len, int& decimal_exponent, FloatType value) { static_assert(diyfp::kPrecision >= std::numeric_limits::digits + 3, @@ -13382,8 +13382,8 @@ void grisu2(char* buf, int& len, int& decimal_exponent, FloatType value) @return a pointer to the element following the exponent. @pre -1000 < e < 1000 */ -HEDLEY_NON_NULL(1) -HEDLEY_RETURNS_NON_NULL +NLOHMANN_JSON_HEDLEY_NON_NULL(1) +NLOHMANN_JSON_HEDLEY_RETURNS_NON_NULL inline char* append_exponent(char* buf, int e) { assert(e > -1000); @@ -13434,8 +13434,8 @@ notation. Otherwise it will be printed in exponential notation. @pre min_exp < 0 @pre max_exp > 0 */ -HEDLEY_NON_NULL(1) -HEDLEY_RETURNS_NON_NULL +NLOHMANN_JSON_HEDLEY_NON_NULL(1) +NLOHMANN_JSON_HEDLEY_RETURNS_NON_NULL inline char* format_buffer(char* buf, int len, int decimal_exponent, int min_exp, int max_exp) { @@ -13519,8 +13519,8 @@ format. Returns an iterator pointing past-the-end of the decimal representation. @note The result is NOT null-terminated. */ template -HEDLEY_NON_NULL(1, 2) -HEDLEY_RETURNS_NON_NULL +NLOHMANN_JSON_HEDLEY_NON_NULL(1, 2) +NLOHMANN_JSON_HEDLEY_RETURNS_NON_NULL char* to_chars(char* first, const char* last, FloatType value) { static_cast(last); // maybe unused - fix warning @@ -13670,7 +13670,7 @@ class serializer // variable to hold indentation for recursive calls const auto new_indent = current_indent + indent_step; - if (HEDLEY_UNLIKELY(indent_string.size() < new_indent)) + if (NLOHMANN_JSON_HEDLEY_UNLIKELY(indent_string.size() < new_indent)) { indent_string.resize(indent_string.size() * 2, ' '); } @@ -13743,7 +13743,7 @@ class serializer // variable to hold indentation for recursive calls const auto new_indent = current_indent + indent_step; - if (HEDLEY_UNLIKELY(indent_string.size() < new_indent)) + if (NLOHMANN_JSON_HEDLEY_UNLIKELY(indent_string.size() < new_indent)) { indent_string.resize(indent_string.size() * 2, ' '); } @@ -14058,7 +14058,7 @@ class serializer } // we finished processing the string - if (HEDLEY_LIKELY(state == UTF8_ACCEPT)) + if (NLOHMANN_JSON_HEDLEY_LIKELY(state == UTF8_ACCEPT)) { // write buffer if (bytes > 0) @@ -14651,7 +14651,7 @@ class basic_json @since 2.1.0 */ - HEDLEY_WARN_UNUSED_RESULT + NLOHMANN_JSON_HEDLEY_WARN_UNUSED_RESULT static basic_json meta() { basic_json result; @@ -15156,7 +15156,7 @@ class basic_json /// helper for exception-safe object creation template - HEDLEY_RETURNS_NON_NULL + NLOHMANN_JSON_HEDLEY_RETURNS_NON_NULL static T* create(Args&& ... args) { AllocatorType alloc; @@ -15283,7 +15283,7 @@ class basic_json default: { object = nullptr; // silence warning, see #821 - if (HEDLEY_UNLIKELY(t == value_t::null)) + if (NLOHMANN_JSON_HEDLEY_UNLIKELY(t == value_t::null)) { JSON_THROW(other_error::create(500, "961c151d2e87f2686a955a9be24d316f1362bf21 3.6.1")); // LCOV_EXCL_LINE } @@ -15760,7 +15760,7 @@ class basic_json } // if object is wanted but impossible, throw an exception - if (HEDLEY_UNLIKELY(manual_type == value_t::object and not is_an_object)) + if (NLOHMANN_JSON_HEDLEY_UNLIKELY(manual_type == value_t::object and not is_an_object)) { JSON_THROW(type_error::create(301, "cannot create object from initializer list")); } @@ -15827,7 +15827,7 @@ class basic_json @since version 1.0.0 */ - HEDLEY_WARN_UNUSED_RESULT + NLOHMANN_JSON_HEDLEY_WARN_UNUSED_RESULT static basic_json array(initializer_list_t init = {}) { return basic_json(init, false, value_t::array); @@ -15871,7 +15871,7 @@ class basic_json @since version 1.0.0 */ - HEDLEY_WARN_UNUSED_RESULT + NLOHMANN_JSON_HEDLEY_WARN_UNUSED_RESULT static basic_json object(initializer_list_t init = {}) { return basic_json(init, false, value_t::object); @@ -15970,7 +15970,7 @@ class basic_json assert(last.m_object != nullptr); // make sure iterator fits the current value - if (HEDLEY_UNLIKELY(first.m_object != last.m_object)) + if (NLOHMANN_JSON_HEDLEY_UNLIKELY(first.m_object != last.m_object)) { JSON_THROW(invalid_iterator::create(201, "iterators are not compatible")); } @@ -15987,8 +15987,8 @@ class basic_json case value_t::number_unsigned: case value_t::string: { - if (HEDLEY_UNLIKELY(not first.m_it.primitive_iterator.is_begin() - or not last.m_it.primitive_iterator.is_end())) + if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not first.m_it.primitive_iterator.is_begin() + or not last.m_it.primitive_iterator.is_end())) { JSON_THROW(invalid_iterator::create(204, "iterators out of range")); } @@ -16701,7 +16701,7 @@ class basic_json /// get a boolean (explicit) boolean_t get_impl(boolean_t* /*unused*/) const { - if (HEDLEY_LIKELY(is_boolean())) + if (NLOHMANN_JSON_HEDLEY_LIKELY(is_boolean())) { return m_value.boolean; } @@ -16810,7 +16810,7 @@ class basic_json // delegate the call to get_ptr<>() auto ptr = obj.template get_ptr::type>(); - if (HEDLEY_LIKELY(ptr != nullptr)) + if (NLOHMANN_JSON_HEDLEY_LIKELY(ptr != nullptr)) { return *ptr; } @@ -17261,7 +17261,7 @@ class basic_json reference at(size_type idx) { // at only works for arrays - if (HEDLEY_LIKELY(is_array())) + if (NLOHMANN_JSON_HEDLEY_LIKELY(is_array())) { JSON_TRY { @@ -17308,7 +17308,7 @@ class basic_json const_reference at(size_type idx) const { // at only works for arrays - if (HEDLEY_LIKELY(is_array())) + if (NLOHMANN_JSON_HEDLEY_LIKELY(is_array())) { JSON_TRY { @@ -17359,7 +17359,7 @@ class basic_json reference at(const typename object_t::key_type& key) { // at only works for objects - if (HEDLEY_LIKELY(is_object())) + if (NLOHMANN_JSON_HEDLEY_LIKELY(is_object())) { JSON_TRY { @@ -17410,7 +17410,7 @@ class basic_json const_reference at(const typename object_t::key_type& key) const { // at only works for objects - if (HEDLEY_LIKELY(is_object())) + if (NLOHMANN_JSON_HEDLEY_LIKELY(is_object())) { JSON_TRY { @@ -17464,7 +17464,7 @@ class basic_json } // operator[] only works for arrays - if (HEDLEY_LIKELY(is_array())) + if (NLOHMANN_JSON_HEDLEY_LIKELY(is_array())) { // fill up array with null values if given idx is outside range if (idx >= m_value.array->size()) @@ -17502,7 +17502,7 @@ class basic_json const_reference operator[](size_type idx) const { // const operator[] only works for arrays - if (HEDLEY_LIKELY(is_array())) + if (NLOHMANN_JSON_HEDLEY_LIKELY(is_array())) { return m_value.array->operator[](idx); } @@ -17548,7 +17548,7 @@ class basic_json } // operator[] only works for objects - if (HEDLEY_LIKELY(is_object())) + if (NLOHMANN_JSON_HEDLEY_LIKELY(is_object())) { return m_value.object->operator[](key); } @@ -17589,7 +17589,7 @@ class basic_json const_reference operator[](const typename object_t::key_type& key) const { // const operator[] only works for objects - if (HEDLEY_LIKELY(is_object())) + if (NLOHMANN_JSON_HEDLEY_LIKELY(is_object())) { assert(m_value.object->find(key) != m_value.object->end()); return m_value.object->find(key)->second; @@ -17626,7 +17626,7 @@ class basic_json @since version 1.1.0 */ template - HEDLEY_NON_NULL(2) + NLOHMANN_JSON_HEDLEY_NON_NULL(2) reference operator[](T* key) { // implicitly convert null to object @@ -17638,7 +17638,7 @@ class basic_json } // at only works for objects - if (HEDLEY_LIKELY(is_object())) + if (NLOHMANN_JSON_HEDLEY_LIKELY(is_object())) { return m_value.object->operator[](key); } @@ -17677,11 +17677,11 @@ class basic_json @since version 1.1.0 */ template - HEDLEY_NON_NULL(2) + NLOHMANN_JSON_HEDLEY_NON_NULL(2) const_reference operator[](T* key) const { // at only works for objects - if (HEDLEY_LIKELY(is_object())) + if (NLOHMANN_JSON_HEDLEY_LIKELY(is_object())) { assert(m_value.object->find(key) != m_value.object->end()); return m_value.object->find(key)->second; @@ -17745,7 +17745,7 @@ class basic_json ValueType value(const typename object_t::key_type& key, const ValueType& default_value) const { // at only works for objects - if (HEDLEY_LIKELY(is_object())) + if (NLOHMANN_JSON_HEDLEY_LIKELY(is_object())) { // if key is found, return value and given default value otherwise const auto it = find(key); @@ -17817,7 +17817,7 @@ class basic_json ValueType value(const json_pointer& ptr, const ValueType& default_value) const { // at only works for objects - if (HEDLEY_LIKELY(is_object())) + if (NLOHMANN_JSON_HEDLEY_LIKELY(is_object())) { // if pointer resolves a value, return it or use default value JSON_TRY @@ -17837,7 +17837,7 @@ class basic_json @brief overload for a default value of type const char* @copydoc basic_json::value(const json_pointer&, ValueType) const */ - HEDLEY_NON_NULL(3) + NLOHMANN_JSON_HEDLEY_NON_NULL(3) string_t value(const json_pointer& ptr, const char* default_value) const { return value(ptr, string_t(default_value)); @@ -17982,7 +17982,7 @@ class basic_json IteratorType erase(IteratorType pos) { // make sure iterator fits the current value - if (HEDLEY_UNLIKELY(this != pos.m_object)) + if (NLOHMANN_JSON_HEDLEY_UNLIKELY(this != pos.m_object)) { JSON_THROW(invalid_iterator::create(202, "iterator does not fit current value")); } @@ -17997,7 +17997,7 @@ class basic_json case value_t::number_unsigned: case value_t::string: { - if (HEDLEY_UNLIKELY(not pos.m_it.primitive_iterator.is_begin())) + if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not pos.m_it.primitive_iterator.is_begin())) { JSON_THROW(invalid_iterator::create(205, "iterator out of range")); } @@ -18087,7 +18087,7 @@ class basic_json IteratorType erase(IteratorType first, IteratorType last) { // make sure iterator fits the current value - if (HEDLEY_UNLIKELY(this != first.m_object or this != last.m_object)) + if (NLOHMANN_JSON_HEDLEY_UNLIKELY(this != first.m_object or this != last.m_object)) { JSON_THROW(invalid_iterator::create(203, "iterators do not fit current value")); } @@ -18102,8 +18102,8 @@ class basic_json case value_t::number_unsigned: case value_t::string: { - if (HEDLEY_LIKELY(not first.m_it.primitive_iterator.is_begin() - or not last.m_it.primitive_iterator.is_end())) + if (NLOHMANN_JSON_HEDLEY_LIKELY(not first.m_it.primitive_iterator.is_begin() + or not last.m_it.primitive_iterator.is_end())) { JSON_THROW(invalid_iterator::create(204, "iterators out of range")); } @@ -18174,7 +18174,7 @@ class basic_json size_type erase(const typename object_t::key_type& key) { // this erase only works for objects - if (HEDLEY_LIKELY(is_object())) + if (NLOHMANN_JSON_HEDLEY_LIKELY(is_object())) { return m_value.object->erase(key); } @@ -18209,9 +18209,9 @@ class basic_json void erase(const size_type idx) { // this erase only works for arrays - if (HEDLEY_LIKELY(is_array())) + if (NLOHMANN_JSON_HEDLEY_LIKELY(is_array())) { - if (HEDLEY_UNLIKELY(idx >= size())) + if (NLOHMANN_JSON_HEDLEY_UNLIKELY(idx >= size())) { JSON_THROW(out_of_range::create(401, "array index " + std::to_string(idx) + " is out of range")); } @@ -18687,7 +18687,7 @@ class basic_json future 4.0.0 of the library. Please use @ref items() instead; that is, replace `json::iterator_wrapper(j)` with `j.items()`. */ - HEDLEY_DEPRECATED(3.1.0) + NLOHMANN_JSON_HEDLEY_DEPRECATED(3.1.0) static iteration_proxy iterator_wrapper(reference ref) noexcept { return ref.items(); @@ -18696,7 +18696,7 @@ class basic_json /*! @copydoc iterator_wrapper(reference) */ - HEDLEY_DEPRECATED(3.1.0) + NLOHMANN_JSON_HEDLEY_DEPRECATED(3.1.0) static iteration_proxy iterator_wrapper(const_reference ref) noexcept { return ref.items(); @@ -19115,7 +19115,7 @@ class basic_json void push_back(basic_json&& val) { // push_back only works for null objects or arrays - if (HEDLEY_UNLIKELY(not(is_null() or is_array()))) + if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not(is_null() or is_array()))) { JSON_THROW(type_error::create(308, "cannot use push_back() with " + std::string(type_name()))); } @@ -19152,7 +19152,7 @@ class basic_json void push_back(const basic_json& val) { // push_back only works for null objects or arrays - if (HEDLEY_UNLIKELY(not(is_null() or is_array()))) + if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not(is_null() or is_array()))) { JSON_THROW(type_error::create(308, "cannot use push_back() with " + std::string(type_name()))); } @@ -19202,7 +19202,7 @@ class basic_json void push_back(const typename object_t::value_type& val) { // push_back only works for null objects or objects - if (HEDLEY_UNLIKELY(not(is_null() or is_object()))) + if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not(is_null() or is_object()))) { JSON_THROW(type_error::create(308, "cannot use push_back() with " + std::string(type_name()))); } @@ -19303,7 +19303,7 @@ class basic_json void emplace_back(Args&& ... args) { // emplace_back only works for null objects or arrays - if (HEDLEY_UNLIKELY(not(is_null() or is_array()))) + if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not(is_null() or is_array()))) { JSON_THROW(type_error::create(311, "cannot use emplace_back() with " + std::string(type_name()))); } @@ -19351,7 +19351,7 @@ class basic_json std::pair emplace(Args&& ... args) { // emplace only works for null objects or arrays - if (HEDLEY_UNLIKELY(not(is_null() or is_object()))) + if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not(is_null() or is_object()))) { JSON_THROW(type_error::create(311, "cannot use emplace() with " + std::string(type_name()))); } @@ -19419,10 +19419,10 @@ class basic_json iterator insert(const_iterator pos, const basic_json& val) { // insert only works for arrays - if (HEDLEY_LIKELY(is_array())) + if (NLOHMANN_JSON_HEDLEY_LIKELY(is_array())) { // check if iterator pos fits to this JSON value - if (HEDLEY_UNLIKELY(pos.m_object != this)) + if (NLOHMANN_JSON_HEDLEY_UNLIKELY(pos.m_object != this)) { JSON_THROW(invalid_iterator::create(202, "iterator does not fit current value")); } @@ -19470,10 +19470,10 @@ class basic_json iterator insert(const_iterator pos, size_type cnt, const basic_json& val) { // insert only works for arrays - if (HEDLEY_LIKELY(is_array())) + if (NLOHMANN_JSON_HEDLEY_LIKELY(is_array())) { // check if iterator pos fits to this JSON value - if (HEDLEY_UNLIKELY(pos.m_object != this)) + if (NLOHMANN_JSON_HEDLEY_UNLIKELY(pos.m_object != this)) { JSON_THROW(invalid_iterator::create(202, "iterator does not fit current value")); } @@ -19518,24 +19518,24 @@ class basic_json iterator insert(const_iterator pos, const_iterator first, const_iterator last) { // insert only works for arrays - if (HEDLEY_UNLIKELY(not is_array())) + if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not is_array())) { JSON_THROW(type_error::create(309, "cannot use insert() with " + std::string(type_name()))); } // check if iterator pos fits to this JSON value - if (HEDLEY_UNLIKELY(pos.m_object != this)) + if (NLOHMANN_JSON_HEDLEY_UNLIKELY(pos.m_object != this)) { JSON_THROW(invalid_iterator::create(202, "iterator does not fit current value")); } // check if range iterators belong to the same JSON object - if (HEDLEY_UNLIKELY(first.m_object != last.m_object)) + if (NLOHMANN_JSON_HEDLEY_UNLIKELY(first.m_object != last.m_object)) { JSON_THROW(invalid_iterator::create(210, "iterators do not fit")); } - if (HEDLEY_UNLIKELY(first.m_object == this)) + if (NLOHMANN_JSON_HEDLEY_UNLIKELY(first.m_object == this)) { JSON_THROW(invalid_iterator::create(211, "passed iterators may not belong to container")); } @@ -19571,13 +19571,13 @@ class basic_json iterator insert(const_iterator pos, initializer_list_t ilist) { // insert only works for arrays - if (HEDLEY_UNLIKELY(not is_array())) + if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not is_array())) { JSON_THROW(type_error::create(309, "cannot use insert() with " + std::string(type_name()))); } // check if iterator pos fits to this JSON value - if (HEDLEY_UNLIKELY(pos.m_object != this)) + if (NLOHMANN_JSON_HEDLEY_UNLIKELY(pos.m_object != this)) { JSON_THROW(invalid_iterator::create(202, "iterator does not fit current value")); } @@ -19612,19 +19612,19 @@ class basic_json void insert(const_iterator first, const_iterator last) { // insert only works for objects - if (HEDLEY_UNLIKELY(not is_object())) + if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not is_object())) { JSON_THROW(type_error::create(309, "cannot use insert() with " + std::string(type_name()))); } // check if range iterators belong to the same JSON object - if (HEDLEY_UNLIKELY(first.m_object != last.m_object)) + if (NLOHMANN_JSON_HEDLEY_UNLIKELY(first.m_object != last.m_object)) { JSON_THROW(invalid_iterator::create(210, "iterators do not fit")); } // passed iterators must belong to objects - if (HEDLEY_UNLIKELY(not first.m_object->is_object())) + if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not first.m_object->is_object())) { JSON_THROW(invalid_iterator::create(202, "iterators first and last must point to objects")); } @@ -19661,11 +19661,11 @@ class basic_json assert_invariant(); } - if (HEDLEY_UNLIKELY(not is_object())) + if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not is_object())) { JSON_THROW(type_error::create(312, "cannot use update() with " + std::string(type_name()))); } - if (HEDLEY_UNLIKELY(not j.is_object())) + if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not j.is_object())) { JSON_THROW(type_error::create(312, "cannot use update() with " + std::string(j.type_name()))); } @@ -19712,20 +19712,20 @@ class basic_json assert_invariant(); } - if (HEDLEY_UNLIKELY(not is_object())) + if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not is_object())) { JSON_THROW(type_error::create(312, "cannot use update() with " + std::string(type_name()))); } // check if range iterators belong to the same JSON object - if (HEDLEY_UNLIKELY(first.m_object != last.m_object)) + if (NLOHMANN_JSON_HEDLEY_UNLIKELY(first.m_object != last.m_object)) { JSON_THROW(invalid_iterator::create(210, "iterators do not fit")); } // passed iterators must belong to objects - if (HEDLEY_UNLIKELY(not first.m_object->is_object() - or not last.m_object->is_object())) + if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not first.m_object->is_object() + or not last.m_object->is_object())) { JSON_THROW(invalid_iterator::create(202, "iterators first and last must point to objects")); } @@ -19788,7 +19788,7 @@ class basic_json void swap(array_t& other) { // swap only works for arrays - if (HEDLEY_LIKELY(is_array())) + if (NLOHMANN_JSON_HEDLEY_LIKELY(is_array())) { std::swap(*(m_value.array), other); } @@ -19821,7 +19821,7 @@ class basic_json void swap(object_t& other) { // swap only works for objects - if (HEDLEY_LIKELY(is_object())) + if (NLOHMANN_JSON_HEDLEY_LIKELY(is_object())) { std::swap(*(m_value.object), other); } @@ -19854,7 +19854,7 @@ class basic_json void swap(string_t& other) { // swap only works for strings - if (HEDLEY_LIKELY(is_string())) + if (NLOHMANN_JSON_HEDLEY_LIKELY(is_string())) { std::swap(*(m_value.string), other); } @@ -20364,7 +20364,7 @@ class basic_json instead; that is, replace calls like `j >> o;` with `o << j;`. @since version 1.0.0; deprecated since version 3.0.0 */ - HEDLEY_DEPRECATED(3.0.0) + NLOHMANN_JSON_HEDLEY_DEPRECATED(3.0.0) friend std::ostream& operator>>(const basic_json& j, std::ostream& o) { return o << j; @@ -20443,7 +20443,7 @@ class basic_json @since version 2.0.3 (contiguous containers) */ - HEDLEY_WARN_UNUSED_RESULT + NLOHMANN_JSON_HEDLEY_WARN_UNUSED_RESULT static basic_json parse(detail::input_adapter&& i, const parser_callback_t cb = nullptr, const bool allow_exceptions = true) @@ -20512,7 +20512,7 @@ class basic_json @since version 3.2.0 */ template - HEDLEY_NON_NULL(2) + NLOHMANN_JSON_HEDLEY_NON_NULL(2) static bool sax_parse(detail::input_adapter&& i, SAX* sax, input_format_t format = input_format_t::json, const bool strict = true) @@ -20598,7 +20598,7 @@ class basic_json std::is_base_of< std::random_access_iterator_tag, typename std::iterator_traits::iterator_category>::value, int>::type = 0> - HEDLEY_NON_NULL(3) + NLOHMANN_JSON_HEDLEY_NON_NULL(3) static bool sax_parse(IteratorType first, IteratorType last, SAX* sax) { return parser(detail::input_adapter(first, last)).sax_parse(sax); @@ -20612,7 +20612,7 @@ class basic_json instead; that is, replace calls like `j << i;` with `i >> j;`. @since version 1.0.0; deprecated since version 3.0.0 */ - HEDLEY_DEPRECATED(3.0.0) + NLOHMANN_JSON_HEDLEY_DEPRECATED(3.0.0) friend std::istream& operator<<(basic_json& j, std::istream& i) { return operator>>(i, j); @@ -20685,7 +20685,7 @@ class basic_json @since version 1.0.0, public since 2.1.0, `const char*` and `noexcept` since 3.0.0 */ - HEDLEY_RETURNS_NON_NULL + NLOHMANN_JSON_HEDLEY_RETURNS_NON_NULL const char* type_name() const noexcept { { @@ -21215,7 +21215,7 @@ class basic_json @a strict parameter since 3.0.0; added @a allow_exceptions parameter since 3.2.0 */ - HEDLEY_WARN_UNUSED_RESULT + NLOHMANN_JSON_HEDLEY_WARN_UNUSED_RESULT static basic_json from_cbor(detail::input_adapter&& i, const bool strict = true, const bool allow_exceptions = true) @@ -21231,7 +21231,7 @@ class basic_json */ template::value, int> = 0> - HEDLEY_WARN_UNUSED_RESULT + NLOHMANN_JSON_HEDLEY_WARN_UNUSED_RESULT static basic_json from_cbor(A1 && a1, A2 && a2, const bool strict = true, const bool allow_exceptions = true) @@ -21324,7 +21324,7 @@ class basic_json @a strict parameter since 3.0.0; added @a allow_exceptions parameter since 3.2.0 */ - HEDLEY_WARN_UNUSED_RESULT + NLOHMANN_JSON_HEDLEY_WARN_UNUSED_RESULT static basic_json from_msgpack(detail::input_adapter&& i, const bool strict = true, const bool allow_exceptions = true) @@ -21340,7 +21340,7 @@ class basic_json */ template::value, int> = 0> - HEDLEY_WARN_UNUSED_RESULT + NLOHMANN_JSON_HEDLEY_WARN_UNUSED_RESULT static basic_json from_msgpack(A1 && a1, A2 && a2, const bool strict = true, const bool allow_exceptions = true) @@ -21412,7 +21412,7 @@ class basic_json @since version 3.1.0; added @a allow_exceptions parameter since 3.2.0 */ - HEDLEY_WARN_UNUSED_RESULT + NLOHMANN_JSON_HEDLEY_WARN_UNUSED_RESULT static basic_json from_ubjson(detail::input_adapter&& i, const bool strict = true, const bool allow_exceptions = true) @@ -21428,7 +21428,7 @@ class basic_json */ template::value, int> = 0> - HEDLEY_WARN_UNUSED_RESULT + NLOHMANN_JSON_HEDLEY_WARN_UNUSED_RESULT static basic_json from_ubjson(A1 && a1, A2 && a2, const bool strict = true, const bool allow_exceptions = true) @@ -21499,7 +21499,7 @@ class basic_json @sa @ref from_ubjson(detail::input_adapter&&, const bool, const bool) for the related UBJSON format */ - HEDLEY_WARN_UNUSED_RESULT + NLOHMANN_JSON_HEDLEY_WARN_UNUSED_RESULT static basic_json from_bson(detail::input_adapter&& i, const bool strict = true, const bool allow_exceptions = true) @@ -21515,7 +21515,7 @@ class basic_json */ template::value, int> = 0> - HEDLEY_WARN_UNUSED_RESULT + NLOHMANN_JSON_HEDLEY_WARN_UNUSED_RESULT static basic_json from_bson(A1 && a1, A2 && a2, const bool strict = true, const bool allow_exceptions = true) @@ -21889,7 +21889,7 @@ class basic_json else { const auto idx = json_pointer::array_index(last_path); - if (HEDLEY_UNLIKELY(static_cast(idx) > parent.size())) + if (NLOHMANN_JSON_HEDLEY_UNLIKELY(static_cast(idx) > parent.size())) { // avoid undefined behavior JSON_THROW(out_of_range::create(401, "array index " + std::to_string(idx) + " is out of range")); @@ -21920,7 +21920,7 @@ class basic_json { // perform range check auto it = parent.find(last_path); - if (HEDLEY_LIKELY(it != parent.end())) + if (NLOHMANN_JSON_HEDLEY_LIKELY(it != parent.end())) { parent.erase(it); } @@ -21937,7 +21937,7 @@ class basic_json }; // type check: top level value must be an array - if (HEDLEY_UNLIKELY(not json_patch.is_array())) + if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not json_patch.is_array())) { JSON_THROW(parse_error::create(104, 0, "JSON patch must be an array of objects")); } @@ -21957,13 +21957,13 @@ class basic_json const auto error_msg = (op == "op") ? "operation" : "operation '" + op + "'"; // check if desired value is present - if (HEDLEY_UNLIKELY(it == val.m_value.object->end())) + if (NLOHMANN_JSON_HEDLEY_UNLIKELY(it == val.m_value.object->end())) { JSON_THROW(parse_error::create(105, 0, error_msg + " must have member '" + member + "'")); } // check if result is of type string - if (HEDLEY_UNLIKELY(string_type and not it->second.is_string())) + if (NLOHMANN_JSON_HEDLEY_UNLIKELY(string_type and not it->second.is_string())) { JSON_THROW(parse_error::create(105, 0, error_msg + " must have string member '" + member + "'")); } @@ -21973,7 +21973,7 @@ class basic_json }; // type check: every element of the array must be an object - if (HEDLEY_UNLIKELY(not val.is_object())) + if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not val.is_object())) { JSON_THROW(parse_error::create(104, 0, "JSON patch must be an array of objects")); } @@ -22051,7 +22051,7 @@ class basic_json } // throw an exception if test fails - if (HEDLEY_UNLIKELY(not success)) + if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not success)) { JSON_THROW(other_error::create(501, "unsuccessful: " + val.dump())); } @@ -22104,7 +22104,7 @@ class basic_json @since version 2.0.0 */ - HEDLEY_WARN_UNUSED_RESULT + NLOHMANN_JSON_HEDLEY_WARN_UNUSED_RESULT static basic_json diff(const basic_json& source, const basic_json& target, const std::string& path = "") { @@ -22396,7 +22396,7 @@ if no parse error occurred. @since version 1.0.0 */ -HEDLEY_NON_NULL(1) +NLOHMANN_JSON_HEDLEY_NON_NULL(1) inline nlohmann::json operator "" _json(const char* s, std::size_t n) { return nlohmann::json::parse(s, s + n); @@ -22415,7 +22415,7 @@ object if no parse error occurred. @since version 2.0.0 */ -HEDLEY_NON_NULL(1) +NLOHMANN_JSON_HEDLEY_NON_NULL(1) inline nlohmann::json::json_pointer operator "" _json_pointer(const char* s, std::size_t n) { return nlohmann::json::json_pointer(std::string(s, n)); @@ -22442,5 +22442,130 @@ inline nlohmann::json::json_pointer operator "" _json_pointer(const char* s, std #undef NLOHMANN_BASIC_JSON_TPL_DECLARATION #undef NLOHMANN_BASIC_JSON_TPL +// #include +#undef NLOHMANN_JSON_HEDLEY_ALWAYS_INLINE +#undef NLOHMANN_JSON_HEDLEY_ARM_VERSION +#undef NLOHMANN_JSON_HEDLEY_ARM_VERSION_CHECK +#undef NLOHMANN_JSON_HEDLEY_ARRAY_PARAM +#undef NLOHMANN_JSON_HEDLEY_ASSUME +#undef NLOHMANN_JSON_HEDLEY_BEGIN_C_DECLS +#undef NLOHMANN_JSON_HEDLEY_CLANG_HAS_ATTRIBUTE +#undef NLOHMANN_JSON_HEDLEY_CLANG_HAS_BUILTIN +#undef NLOHMANN_JSON_HEDLEY_CLANG_HAS_CPP_ATTRIBUTE +#undef NLOHMANN_JSON_HEDLEY_CLANG_HAS_DECLSPEC_DECLSPEC_ATTRIBUTE +#undef NLOHMANN_JSON_HEDLEY_CLANG_HAS_EXTENSION +#undef NLOHMANN_JSON_HEDLEY_CLANG_HAS_FEATURE +#undef NLOHMANN_JSON_HEDLEY_CLANG_HAS_WARNING +#undef NLOHMANN_JSON_HEDLEY_COMPCERT_VERSION +#undef NLOHMANN_JSON_HEDLEY_COMPCERT_VERSION_CHECK +#undef NLOHMANN_JSON_HEDLEY_CONCAT +#undef NLOHMANN_JSON_HEDLEY_CONCAT_EX +#undef NLOHMANN_JSON_HEDLEY_CONST +#undef NLOHMANN_JSON_HEDLEY_CONSTEXPR +#undef NLOHMANN_JSON_HEDLEY_CONST_CAST +#undef NLOHMANN_JSON_HEDLEY_CPP_CAST +#undef NLOHMANN_JSON_HEDLEY_CRAY_VERSION +#undef NLOHMANN_JSON_HEDLEY_CRAY_VERSION_CHECK +#undef NLOHMANN_JSON_HEDLEY_C_DECL +#undef NLOHMANN_JSON_HEDLEY_DEPRECATED +#undef NLOHMANN_JSON_HEDLEY_DEPRECATED_FOR +#undef NLOHMANN_JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL +#undef NLOHMANN_JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED +#undef NLOHMANN_JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS +#undef NLOHMANN_JSON_HEDLEY_DIAGNOSTIC_POP +#undef NLOHMANN_JSON_HEDLEY_DIAGNOSTIC_PUSH +#undef NLOHMANN_JSON_HEDLEY_DMC_VERSION +#undef NLOHMANN_JSON_HEDLEY_DMC_VERSION_CHECK +#undef NLOHMANN_JSON_HEDLEY_EMSCRIPTEN_VERSION +#undef NLOHMANN_JSON_HEDLEY_EMSCRIPTEN_VERSION_CHECK +#undef NLOHMANN_JSON_HEDLEY_END_C_DECLS +#undef NLOHMANN_JSON_HEDLEY_FALL_THROUGH +#undef NLOHMANN_JSON_HEDLEY_FLAGS +#undef NLOHMANN_JSON_HEDLEY_FLAGS_CAST +#undef NLOHMANN_JSON_HEDLEY_GCC_HAS_ATTRIBUTE +#undef NLOHMANN_JSON_HEDLEY_GCC_HAS_BUILTIN +#undef NLOHMANN_JSON_HEDLEY_GCC_HAS_CPP_ATTRIBUTE +#undef NLOHMANN_JSON_HEDLEY_GCC_HAS_DECLSPEC_ATTRIBUTE +#undef NLOHMANN_JSON_HEDLEY_GCC_HAS_EXTENSION +#undef NLOHMANN_JSON_HEDLEY_GCC_HAS_FEATURE +#undef NLOHMANN_JSON_HEDLEY_GCC_HAS_WARNING +#undef NLOHMANN_JSON_HEDLEY_GCC_NOT_CLANG_VERSION_CHECK +#undef NLOHMANN_JSON_HEDLEY_GCC_VERSION +#undef NLOHMANN_JSON_HEDLEY_GCC_VERSION_CHECK +#undef NLOHMANN_JSON_HEDLEY_GNUC_HAS_ATTRIBUTE +#undef NLOHMANN_JSON_HEDLEY_GNUC_HAS_BUILTIN +#undef NLOHMANN_JSON_HEDLEY_GNUC_HAS_CPP_ATTRIBUTE +#undef NLOHMANN_JSON_HEDLEY_GNUC_HAS_DECLSPEC_ATTRIBUTE +#undef NLOHMANN_JSON_HEDLEY_GNUC_HAS_EXTENSION +#undef NLOHMANN_JSON_HEDLEY_GNUC_HAS_FEATURE +#undef NLOHMANN_JSON_HEDLEY_GNUC_HAS_WARNING +#undef NLOHMANN_JSON_HEDLEY_GNUC_VERSION +#undef NLOHMANN_JSON_HEDLEY_GNUC_VERSION_CHECK +#undef NLOHMANN_JSON_HEDLEY_HAS_ATTRIBUTE +#undef NLOHMANN_JSON_HEDLEY_HAS_BUILTIN +#undef NLOHMANN_JSON_HEDLEY_HAS_CPP_ATTRIBUTE +#undef NLOHMANN_JSON_HEDLEY_HAS_DECLSPEC_ATTRIBUTE +#undef NLOHMANN_JSON_HEDLEY_HAS_EXTENSION +#undef NLOHMANN_JSON_HEDLEY_HAS_FEATURE +#undef NLOHMANN_JSON_HEDLEY_HAS_WARNING +#undef NLOHMANN_JSON_HEDLEY_IAR_VERSION +#undef NLOHMANN_JSON_HEDLEY_IAR_VERSION_CHECK +#undef NLOHMANN_JSON_HEDLEY_IBM_VERSION +#undef NLOHMANN_JSON_HEDLEY_IBM_VERSION_CHECK +#undef NLOHMANN_JSON_HEDLEY_IMPORT +#undef NLOHMANN_JSON_HEDLEY_INLINE +#undef NLOHMANN_JSON_HEDLEY_INTEL_VERSION +#undef NLOHMANN_JSON_HEDLEY_INTEL_VERSION_CHECK +#undef NLOHMANN_JSON_HEDLEY_IS_CONSTANT +#undef NLOHMANN_JSON_HEDLEY_LIKELY +#undef NLOHMANN_JSON_HEDLEY_MALLOC +#undef NLOHMANN_JSON_HEDLEY_MESSAGE +#undef NLOHMANN_JSON_HEDLEY_MSVC_VERSION +#undef NLOHMANN_JSON_HEDLEY_MSVC_VERSION_CHECK +#undef NLOHMANN_JSON_HEDLEY_NEVER_INLINE +#undef NLOHMANN_JSON_HEDLEY_NON_NULL +#undef NLOHMANN_JSON_HEDLEY_NO_RETURN +#undef NLOHMANN_JSON_HEDLEY_NO_THROW +#undef NLOHMANN_JSON_HEDLEY_PELLES_VERSION +#undef NLOHMANN_JSON_HEDLEY_PELLES_VERSION_CHECK +#undef NLOHMANN_JSON_HEDLEY_PGI_VERSION +#undef NLOHMANN_JSON_HEDLEY_PGI_VERSION_CHECK +#undef NLOHMANN_JSON_HEDLEY_PREDICT +#undef NLOHMANN_JSON_HEDLEY_PRINTF_FORMAT +#undef NLOHMANN_JSON_HEDLEY_PRIVATE +#undef NLOHMANN_JSON_HEDLEY_PUBLIC +#undef NLOHMANN_JSON_HEDLEY_PURE +#undef NLOHMANN_JSON_HEDLEY_REINTERPRET_CAST +#undef NLOHMANN_JSON_HEDLEY_REQUIRE +#undef NLOHMANN_JSON_HEDLEY_REQUIRE_CONSTEXPR +#undef NLOHMANN_JSON_HEDLEY_REQUIRE_MSG +#undef NLOHMANN_JSON_HEDLEY_RESTRICT +#undef NLOHMANN_JSON_HEDLEY_RETURNS_NON_NULL +#undef NLOHMANN_JSON_HEDLEY_SENTINEL +#undef NLOHMANN_JSON_HEDLEY_STATIC_ASSERT +#undef NLOHMANN_JSON_HEDLEY_STATIC_CAST +#undef NLOHMANN_JSON_HEDLEY_STRINGIFY +#undef NLOHMANN_JSON_HEDLEY_STRINGIFY_EX +#undef NLOHMANN_JSON_HEDLEY_SUNPRO_VERSION +#undef NLOHMANN_JSON_HEDLEY_SUNPRO_VERSION_CHECK +#undef NLOHMANN_JSON_HEDLEY_TINYC_VERSION +#undef NLOHMANN_JSON_HEDLEY_TINYC_VERSION_CHECK +#undef NLOHMANN_JSON_HEDLEY_TI_VERSION +#undef NLOHMANN_JSON_HEDLEY_TI_VERSION_CHECK +#undef NLOHMANN_JSON_HEDLEY_UNAVAILABLE +#undef NLOHMANN_JSON_HEDLEY_UNLIKELY +#undef NLOHMANN_JSON_HEDLEY_UNPREDICTABLE +#undef NLOHMANN_JSON_HEDLEY_UNREACHABLE +#undef NLOHMANN_JSON_HEDLEY_UNREACHABLE_RETURN +#undef NLOHMANN_JSON_HEDLEY_VERSION +#undef NLOHMANN_JSON_HEDLEY_VERSION_DECODE_MAJOR +#undef NLOHMANN_JSON_HEDLEY_VERSION_DECODE_MINOR +#undef NLOHMANN_JSON_HEDLEY_VERSION_DECODE_REVISION +#undef NLOHMANN_JSON_HEDLEY_VERSION_ENCODE +#undef NLOHMANN_JSON_HEDLEY_WARNING +#undef NLOHMANN_JSON_HEDLEY_WARN_UNUSED_RESULT +#undef NLOHMANN_JSON_HEDLEY__IS_CONSTEXPR + + #endif // INCLUDE_NLOHMANN_JSON_HPP_ From 025f4cea424e9c9bb5e942307387aee463c2865a Mon Sep 17 00:00:00 2001 From: Niels Lohmann Date: Mon, 1 Jul 2019 22:29:21 +0200 Subject: [PATCH 089/106] :rotating_light: fix warning --- Makefile | 2 +- include/nlohmann/thirdparty/hedley/hedley_undef.hpp | 1 - single_include/nlohmann/json.hpp | 1 - 3 files changed, 1 insertion(+), 3 deletions(-) diff --git a/Makefile b/Makefile index 141e1c78..011c7c4d 100644 --- a/Makefile +++ b/Makefile @@ -621,5 +621,5 @@ update_hedley: rm -f include/nlohmann/thirdparty/hedley/hedley.hpp include/nlohmann/thirdparty/hedley/hedley_undef.hpp curl https://raw.githubusercontent.com/nemequ/hedley/master/hedley.h -o include/nlohmann/thirdparty/hedley/hedley.hpp gsed -i 's/HEDLEY_/NLOHMANN_JSON_HEDLEY_/g' include/nlohmann/thirdparty/hedley/hedley.hpp - grep "[[:blank:]]*#[[:blank:]]*undef" include/nlohmann/thirdparty/hedley/hedley.hpp | sort | uniq | gsed 's/ //g' | gsed 's/undef/undef /g' > include/nlohmann/thirdparty/hedley/hedley_undef.hpp + grep "[[:blank:]]*#[[:blank:]]*undef" include/nlohmann/thirdparty/hedley/hedley.hpp | grep -v "__" | sort | uniq | gsed 's/ //g' | gsed 's/undef/undef /g' > include/nlohmann/thirdparty/hedley/hedley_undef.hpp $(MAKE) amalgamate diff --git a/include/nlohmann/thirdparty/hedley/hedley_undef.hpp b/include/nlohmann/thirdparty/hedley/hedley_undef.hpp index 5458f064..5e95ae5a 100644 --- a/include/nlohmann/thirdparty/hedley/hedley_undef.hpp +++ b/include/nlohmann/thirdparty/hedley/hedley_undef.hpp @@ -119,4 +119,3 @@ #undef NLOHMANN_JSON_HEDLEY_VERSION_ENCODE #undef NLOHMANN_JSON_HEDLEY_WARNING #undef NLOHMANN_JSON_HEDLEY_WARN_UNUSED_RESULT -#undef NLOHMANN_JSON_HEDLEY__IS_CONSTEXPR diff --git a/single_include/nlohmann/json.hpp b/single_include/nlohmann/json.hpp index 73a53ffb..6778fd41 100644 --- a/single_include/nlohmann/json.hpp +++ b/single_include/nlohmann/json.hpp @@ -22564,7 +22564,6 @@ inline nlohmann::json::json_pointer operator "" _json_pointer(const char* s, std #undef NLOHMANN_JSON_HEDLEY_VERSION_ENCODE #undef NLOHMANN_JSON_HEDLEY_WARNING #undef NLOHMANN_JSON_HEDLEY_WARN_UNUSED_RESULT -#undef NLOHMANN_JSON_HEDLEY__IS_CONSTEXPR From 90798caa627986c589b7a798c67bb9acc02f3de9 Mon Sep 17 00:00:00 2001 From: Niels Lohmann Date: Mon, 1 Jul 2019 22:37:30 +0200 Subject: [PATCH 090/106] :truck: rename Hedley macros --- Makefile | 6 +- .../nlohmann/detail/conversions/from_json.hpp | 24 +- .../nlohmann/detail/conversions/to_chars.hpp | 16 +- include/nlohmann/detail/exceptions.hpp | 12 +- .../nlohmann/detail/input/binary_reader.hpp | 116 +- .../nlohmann/detail/input/input_adapters.hpp | 10 +- include/nlohmann/detail/input/json_sax.hpp | 10 +- include/nlohmann/detail/input/lexer.hpp | 44 +- include/nlohmann/detail/input/parser.hpp | 48 +- .../nlohmann/detail/iterators/iter_impl.hpp | 12 +- include/nlohmann/detail/json_pointer.hpp | 34 +- .../nlohmann/detail/output/binary_writer.hpp | 2 +- .../detail/output/output_adapters.hpp | 6 +- include/nlohmann/detail/output/serializer.hpp | 6 +- include/nlohmann/json.hpp | 174 +- include/nlohmann/thirdparty/hedley/hedley.hpp | 1780 ++++++------ .../thirdparty/hedley/hedley_undef.hpp | 242 +- single_include/nlohmann/json.hpp | 2536 ++++++++--------- 18 files changed, 2541 insertions(+), 2537 deletions(-) diff --git a/Makefile b/Makefile index 011c7c4d..d64d42b2 100644 --- a/Makefile +++ b/Makefile @@ -617,9 +617,13 @@ clean: $(MAKE) clean -Cdoc $(MAKE) clean -Ctest +########################################################################## +# Thirdparty code +########################################################################## + update_hedley: rm -f include/nlohmann/thirdparty/hedley/hedley.hpp include/nlohmann/thirdparty/hedley/hedley_undef.hpp curl https://raw.githubusercontent.com/nemequ/hedley/master/hedley.h -o include/nlohmann/thirdparty/hedley/hedley.hpp - gsed -i 's/HEDLEY_/NLOHMANN_JSON_HEDLEY_/g' include/nlohmann/thirdparty/hedley/hedley.hpp + gsed -i 's/HEDLEY_/JSON_HEDLEY_/g' include/nlohmann/thirdparty/hedley/hedley.hpp grep "[[:blank:]]*#[[:blank:]]*undef" include/nlohmann/thirdparty/hedley/hedley.hpp | grep -v "__" | sort | uniq | gsed 's/ //g' | gsed 's/undef/undef /g' > include/nlohmann/thirdparty/hedley/hedley_undef.hpp $(MAKE) amalgamate diff --git a/include/nlohmann/detail/conversions/from_json.hpp b/include/nlohmann/detail/conversions/from_json.hpp index 4520041e..224fb33f 100644 --- a/include/nlohmann/detail/conversions/from_json.hpp +++ b/include/nlohmann/detail/conversions/from_json.hpp @@ -26,7 +26,7 @@ namespace detail template void from_json(const BasicJsonType& j, typename std::nullptr_t& n) { - if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not j.is_null())) + if (JSON_HEDLEY_UNLIKELY(not j.is_null())) { JSON_THROW(type_error::create(302, "type must be null, but is " + std::string(j.type_name()))); } @@ -66,7 +66,7 @@ void get_arithmetic_value(const BasicJsonType& j, ArithmeticType& val) template void from_json(const BasicJsonType& j, typename BasicJsonType::boolean_t& b) { - if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not j.is_boolean())) + if (JSON_HEDLEY_UNLIKELY(not j.is_boolean())) { JSON_THROW(type_error::create(302, "type must be boolean, but is " + std::string(j.type_name()))); } @@ -76,7 +76,7 @@ void from_json(const BasicJsonType& j, typename BasicJsonType::boolean_t& b) template void from_json(const BasicJsonType& j, typename BasicJsonType::string_t& s) { - if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not j.is_string())) + if (JSON_HEDLEY_UNLIKELY(not j.is_string())) { JSON_THROW(type_error::create(302, "type must be string, but is " + std::string(j.type_name()))); } @@ -92,7 +92,7 @@ template < int > = 0 > void from_json(const BasicJsonType& j, ConstructibleStringType& s) { - if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not j.is_string())) + if (JSON_HEDLEY_UNLIKELY(not j.is_string())) { JSON_THROW(type_error::create(302, "type must be string, but is " + std::string(j.type_name()))); } @@ -132,7 +132,7 @@ template::value, int> = 0> void from_json(const BasicJsonType& j, std::forward_list& l) { - if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not j.is_array())) + if (JSON_HEDLEY_UNLIKELY(not j.is_array())) { JSON_THROW(type_error::create(302, "type must be array, but is " + std::string(j.type_name()))); } @@ -149,7 +149,7 @@ template::value, int> = 0> void from_json(const BasicJsonType& j, std::valarray& l) { - if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not j.is_array())) + if (JSON_HEDLEY_UNLIKELY(not j.is_array())) { JSON_THROW(type_error::create(302, "type must be array, but is " + std::string(j.type_name()))); } @@ -236,7 +236,7 @@ auto from_json(const BasicJsonType& j, ConstructibleArrayType& arr) j.template get(), void()) { - if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not j.is_array())) + if (JSON_HEDLEY_UNLIKELY(not j.is_array())) { JSON_THROW(type_error::create(302, "type must be array, but is " + std::string(j.type_name()))); @@ -249,7 +249,7 @@ template::value, int> = 0> void from_json(const BasicJsonType& j, ConstructibleObjectType& obj) { - if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not j.is_object())) + if (JSON_HEDLEY_UNLIKELY(not j.is_object())) { JSON_THROW(type_error::create(302, "type must be object, but is " + std::string(j.type_name()))); } @@ -332,14 +332,14 @@ template ::value>> void from_json(const BasicJsonType& j, std::map& m) { - if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not j.is_array())) + if (JSON_HEDLEY_UNLIKELY(not j.is_array())) { JSON_THROW(type_error::create(302, "type must be array, but is " + std::string(j.type_name()))); } m.clear(); for (const auto& p : j) { - if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not p.is_array())) + if (JSON_HEDLEY_UNLIKELY(not p.is_array())) { JSON_THROW(type_error::create(302, "type must be array, but is " + std::string(p.type_name()))); } @@ -352,14 +352,14 @@ template ::value>> void from_json(const BasicJsonType& j, std::unordered_map& m) { - if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not j.is_array())) + if (JSON_HEDLEY_UNLIKELY(not j.is_array())) { JSON_THROW(type_error::create(302, "type must be array, but is " + std::string(j.type_name()))); } m.clear(); for (const auto& p : j) { - if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not p.is_array())) + if (JSON_HEDLEY_UNLIKELY(not p.is_array())) { JSON_THROW(type_error::create(302, "type must be array, but is " + std::string(p.type_name()))); } diff --git a/include/nlohmann/detail/conversions/to_chars.hpp b/include/nlohmann/detail/conversions/to_chars.hpp index 9a88937e..feafaec8 100644 --- a/include/nlohmann/detail/conversions/to_chars.hpp +++ b/include/nlohmann/detail/conversions/to_chars.hpp @@ -819,7 +819,7 @@ v = buf * 10^decimal_exponent len is the length of the buffer (number of decimal digits) The buffer must be large enough, i.e. >= max_digits10. */ -NLOHMANN_JSON_HEDLEY_NON_NULL(1) +JSON_HEDLEY_NON_NULL(1) inline void grisu2(char* buf, int& len, int& decimal_exponent, diyfp m_minus, diyfp v, diyfp m_plus) { @@ -879,7 +879,7 @@ len is the length of the buffer (number of decimal digits) The buffer must be large enough, i.e. >= max_digits10. */ template -NLOHMANN_JSON_HEDLEY_NON_NULL(1) +JSON_HEDLEY_NON_NULL(1) void grisu2(char* buf, int& len, int& decimal_exponent, FloatType value) { static_assert(diyfp::kPrecision >= std::numeric_limits::digits + 3, @@ -918,8 +918,8 @@ void grisu2(char* buf, int& len, int& decimal_exponent, FloatType value) @return a pointer to the element following the exponent. @pre -1000 < e < 1000 */ -NLOHMANN_JSON_HEDLEY_NON_NULL(1) -NLOHMANN_JSON_HEDLEY_RETURNS_NON_NULL +JSON_HEDLEY_NON_NULL(1) +JSON_HEDLEY_RETURNS_NON_NULL inline char* append_exponent(char* buf, int e) { assert(e > -1000); @@ -970,8 +970,8 @@ notation. Otherwise it will be printed in exponential notation. @pre min_exp < 0 @pre max_exp > 0 */ -NLOHMANN_JSON_HEDLEY_NON_NULL(1) -NLOHMANN_JSON_HEDLEY_RETURNS_NON_NULL +JSON_HEDLEY_NON_NULL(1) +JSON_HEDLEY_RETURNS_NON_NULL inline char* format_buffer(char* buf, int len, int decimal_exponent, int min_exp, int max_exp) { @@ -1055,8 +1055,8 @@ format. Returns an iterator pointing past-the-end of the decimal representation. @note The result is NOT null-terminated. */ template -NLOHMANN_JSON_HEDLEY_NON_NULL(1, 2) -NLOHMANN_JSON_HEDLEY_RETURNS_NON_NULL +JSON_HEDLEY_NON_NULL(1, 2) +JSON_HEDLEY_RETURNS_NON_NULL char* to_chars(char* first, const char* last, FloatType value) { static_cast(last); // maybe unused - fix warning diff --git a/include/nlohmann/detail/exceptions.hpp b/include/nlohmann/detail/exceptions.hpp index ad9673b6..ed836188 100644 --- a/include/nlohmann/detail/exceptions.hpp +++ b/include/nlohmann/detail/exceptions.hpp @@ -47,7 +47,7 @@ class exception : public std::exception { public: /// returns the explanatory string - NLOHMANN_JSON_HEDLEY_RETURNS_NON_NULL + JSON_HEDLEY_RETURNS_NON_NULL const char* what() const noexcept override { return m.what(); @@ -57,7 +57,7 @@ class exception : public std::exception const int id; protected: - NLOHMANN_JSON_HEDLEY_NON_NULL(3) + JSON_HEDLEY_NON_NULL(3) exception(int id_, const char* what_arg) : id(id_), m(what_arg) {} static std::string name(const std::string& ename, int id_) @@ -210,7 +210,7 @@ class invalid_iterator : public exception } private: - NLOHMANN_JSON_HEDLEY_NON_NULL(3) + JSON_HEDLEY_NON_NULL(3) invalid_iterator(int id_, const char* what_arg) : exception(id_, what_arg) {} }; @@ -264,7 +264,7 @@ class type_error : public exception } private: - NLOHMANN_JSON_HEDLEY_NON_NULL(3) + JSON_HEDLEY_NON_NULL(3) type_error(int id_, const char* what_arg) : exception(id_, what_arg) {} }; @@ -311,7 +311,7 @@ class out_of_range : public exception } private: - NLOHMANN_JSON_HEDLEY_NON_NULL(3) + JSON_HEDLEY_NON_NULL(3) out_of_range(int id_, const char* what_arg) : exception(id_, what_arg) {} }; @@ -349,7 +349,7 @@ class other_error : public exception } private: - NLOHMANN_JSON_HEDLEY_NON_NULL(3) + JSON_HEDLEY_NON_NULL(3) other_error(int id_, const char* what_arg) : exception(id_, what_arg) {} }; } // namespace detail diff --git a/include/nlohmann/detail/input/binary_reader.hpp b/include/nlohmann/detail/input/binary_reader.hpp index 48ad8c00..e44249ea 100644 --- a/include/nlohmann/detail/input/binary_reader.hpp +++ b/include/nlohmann/detail/input/binary_reader.hpp @@ -66,7 +66,7 @@ class binary_reader @return */ - NLOHMANN_JSON_HEDLEY_NON_NULL(3) + JSON_HEDLEY_NON_NULL(3) bool sax_parse(const input_format_t format, json_sax_t* sax_, const bool strict = true) @@ -108,7 +108,7 @@ class binary_reader get(); } - if (NLOHMANN_JSON_HEDLEY_UNLIKELY(current != std::char_traits::eof())) + if (JSON_HEDLEY_UNLIKELY(current != std::char_traits::eof())) { return sax->parse_error(chars_read, get_token_string(), parse_error::create(110, chars_read, exception_message(format, "expected end of input; last byte: 0x" + get_token_string(), "value"))); @@ -144,12 +144,12 @@ class binary_reader std::int32_t document_size; get_number(input_format_t::bson, document_size); - if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not sax->start_object(std::size_t(-1)))) + if (JSON_HEDLEY_UNLIKELY(not sax->start_object(std::size_t(-1)))) { return false; } - if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not parse_bson_element_list(/*is_array*/false))) + if (JSON_HEDLEY_UNLIKELY(not parse_bson_element_list(/*is_array*/false))) { return false; } @@ -170,7 +170,7 @@ class binary_reader while (true) { get(); - if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not unexpect_eof(input_format_t::bson, "cstring"))) + if (JSON_HEDLEY_UNLIKELY(not unexpect_eof(input_format_t::bson, "cstring"))) { return false; } @@ -198,7 +198,7 @@ class binary_reader template bool get_bson_string(const NumberType len, string_t& result) { - if (NLOHMANN_JSON_HEDLEY_UNLIKELY(len < 1)) + if (JSON_HEDLEY_UNLIKELY(len < 1)) { auto last_token = get_token_string(); return sax->parse_error(chars_read, last_token, parse_error::create(112, chars_read, exception_message(input_format_t::bson, "string length must be at least 1, is " + std::to_string(len), "string"))); @@ -293,13 +293,13 @@ class binary_reader string_t key; while (int element_type = get()) { - if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not unexpect_eof(input_format_t::bson, "element list"))) + if (JSON_HEDLEY_UNLIKELY(not unexpect_eof(input_format_t::bson, "element list"))) { return false; } const std::size_t element_type_parse_position = chars_read; - if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not get_bson_cstr(key))) + if (JSON_HEDLEY_UNLIKELY(not get_bson_cstr(key))) { return false; } @@ -309,7 +309,7 @@ class binary_reader return false; } - if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not parse_bson_element_internal(element_type, element_type_parse_position))) + if (JSON_HEDLEY_UNLIKELY(not parse_bson_element_internal(element_type, element_type_parse_position))) { return false; } @@ -330,12 +330,12 @@ class binary_reader std::int32_t document_size; get_number(input_format_t::bson, document_size); - if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not sax->start_array(std::size_t(-1)))) + if (JSON_HEDLEY_UNLIKELY(not sax->start_array(std::size_t(-1)))) { return false; } - if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not parse_bson_element_list(/*is_array*/true))) + if (JSON_HEDLEY_UNLIKELY(not parse_bson_element_list(/*is_array*/true))) { return false; } @@ -620,12 +620,12 @@ class binary_reader case 0xF9: // Half-Precision Float (two-byte IEEE 754) { const int byte1_raw = get(); - if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not unexpect_eof(input_format_t::cbor, "number"))) + if (JSON_HEDLEY_UNLIKELY(not unexpect_eof(input_format_t::cbor, "number"))) { return false; } const int byte2_raw = get(); - if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not unexpect_eof(input_format_t::cbor, "number"))) + if (JSON_HEDLEY_UNLIKELY(not unexpect_eof(input_format_t::cbor, "number"))) { return false; } @@ -698,7 +698,7 @@ class binary_reader */ bool get_cbor_string(string_t& result) { - if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not unexpect_eof(input_format_t::cbor, "string"))) + if (JSON_HEDLEY_UNLIKELY(not unexpect_eof(input_format_t::cbor, "string"))) { return false; } @@ -787,7 +787,7 @@ class binary_reader */ bool get_cbor_array(const std::size_t len) { - if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not sax->start_array(len))) + if (JSON_HEDLEY_UNLIKELY(not sax->start_array(len))) { return false; } @@ -796,7 +796,7 @@ class binary_reader { for (std::size_t i = 0; i < len; ++i) { - if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not parse_cbor_internal())) + if (JSON_HEDLEY_UNLIKELY(not parse_cbor_internal())) { return false; } @@ -806,7 +806,7 @@ class binary_reader { while (get() != 0xFF) { - if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not parse_cbor_internal(false))) + if (JSON_HEDLEY_UNLIKELY(not parse_cbor_internal(false))) { return false; } @@ -823,7 +823,7 @@ class binary_reader */ bool get_cbor_object(const std::size_t len) { - if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not sax->start_object(len))) + if (JSON_HEDLEY_UNLIKELY(not sax->start_object(len))) { return false; } @@ -834,12 +834,12 @@ class binary_reader for (std::size_t i = 0; i < len; ++i) { get(); - if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not get_cbor_string(key) or not sax->key(key))) + if (JSON_HEDLEY_UNLIKELY(not get_cbor_string(key) or not sax->key(key))) { return false; } - if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not parse_cbor_internal())) + if (JSON_HEDLEY_UNLIKELY(not parse_cbor_internal())) { return false; } @@ -850,12 +850,12 @@ class binary_reader { while (get() != 0xFF) { - if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not get_cbor_string(key) or not sax->key(key))) + if (JSON_HEDLEY_UNLIKELY(not get_cbor_string(key) or not sax->key(key))) { return false; } - if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not parse_cbor_internal())) + if (JSON_HEDLEY_UNLIKELY(not parse_cbor_internal())) { return false; } @@ -1244,7 +1244,7 @@ class binary_reader */ bool get_msgpack_string(string_t& result) { - if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not unexpect_eof(input_format_t::msgpack, "string"))) + if (JSON_HEDLEY_UNLIKELY(not unexpect_eof(input_format_t::msgpack, "string"))) { return false; } @@ -1320,14 +1320,14 @@ class binary_reader */ bool get_msgpack_array(const std::size_t len) { - if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not sax->start_array(len))) + if (JSON_HEDLEY_UNLIKELY(not sax->start_array(len))) { return false; } for (std::size_t i = 0; i < len; ++i) { - if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not parse_msgpack_internal())) + if (JSON_HEDLEY_UNLIKELY(not parse_msgpack_internal())) { return false; } @@ -1342,7 +1342,7 @@ class binary_reader */ bool get_msgpack_object(const std::size_t len) { - if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not sax->start_object(len))) + if (JSON_HEDLEY_UNLIKELY(not sax->start_object(len))) { return false; } @@ -1351,12 +1351,12 @@ class binary_reader for (std::size_t i = 0; i < len; ++i) { get(); - if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not get_msgpack_string(key) or not sax->key(key))) + if (JSON_HEDLEY_UNLIKELY(not get_msgpack_string(key) or not sax->key(key))) { return false; } - if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not parse_msgpack_internal())) + if (JSON_HEDLEY_UNLIKELY(not parse_msgpack_internal())) { return false; } @@ -1403,7 +1403,7 @@ class binary_reader get(); // TODO(niels): may we ignore N here? } - if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not unexpect_eof(input_format_t::ubjson, "value"))) + if (JSON_HEDLEY_UNLIKELY(not unexpect_eof(input_format_t::ubjson, "value"))) { return false; } @@ -1457,7 +1457,7 @@ class binary_reader case 'U': { std::uint8_t number; - if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not get_number(input_format_t::ubjson, number))) + if (JSON_HEDLEY_UNLIKELY(not get_number(input_format_t::ubjson, number))) { return false; } @@ -1468,7 +1468,7 @@ class binary_reader case 'i': { std::int8_t number; - if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not get_number(input_format_t::ubjson, number))) + if (JSON_HEDLEY_UNLIKELY(not get_number(input_format_t::ubjson, number))) { return false; } @@ -1479,7 +1479,7 @@ class binary_reader case 'I': { std::int16_t number; - if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not get_number(input_format_t::ubjson, number))) + if (JSON_HEDLEY_UNLIKELY(not get_number(input_format_t::ubjson, number))) { return false; } @@ -1490,7 +1490,7 @@ class binary_reader case 'l': { std::int32_t number; - if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not get_number(input_format_t::ubjson, number))) + if (JSON_HEDLEY_UNLIKELY(not get_number(input_format_t::ubjson, number))) { return false; } @@ -1501,7 +1501,7 @@ class binary_reader case 'L': { std::int64_t number; - if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not get_number(input_format_t::ubjson, number))) + if (JSON_HEDLEY_UNLIKELY(not get_number(input_format_t::ubjson, number))) { return false; } @@ -1537,15 +1537,15 @@ class binary_reader if (current == '$') { result.second = get(); // must not ignore 'N', because 'N' maybe the type - if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not unexpect_eof(input_format_t::ubjson, "type"))) + if (JSON_HEDLEY_UNLIKELY(not unexpect_eof(input_format_t::ubjson, "type"))) { return false; } get_ignore_noop(); - if (NLOHMANN_JSON_HEDLEY_UNLIKELY(current != '#')) + if (JSON_HEDLEY_UNLIKELY(current != '#')) { - if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not unexpect_eof(input_format_t::ubjson, "value"))) + if (JSON_HEDLEY_UNLIKELY(not unexpect_eof(input_format_t::ubjson, "value"))) { return false; } @@ -1628,11 +1628,11 @@ class binary_reader case 'C': // char { get(); - if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not unexpect_eof(input_format_t::ubjson, "char"))) + if (JSON_HEDLEY_UNLIKELY(not unexpect_eof(input_format_t::ubjson, "char"))) { return false; } - if (NLOHMANN_JSON_HEDLEY_UNLIKELY(current > 127)) + if (JSON_HEDLEY_UNLIKELY(current > 127)) { auto last_token = get_token_string(); return sax->parse_error(chars_read, last_token, parse_error::create(113, chars_read, exception_message(input_format_t::ubjson, "byte after 'C' must be in range 0x00..0x7F; last byte: 0x" + last_token, "char"))); @@ -1667,14 +1667,14 @@ class binary_reader bool get_ubjson_array() { std::pair size_and_type; - if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not get_ubjson_size_type(size_and_type))) + if (JSON_HEDLEY_UNLIKELY(not get_ubjson_size_type(size_and_type))) { return false; } if (size_and_type.first != string_t::npos) { - if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not sax->start_array(size_and_type.first))) + if (JSON_HEDLEY_UNLIKELY(not sax->start_array(size_and_type.first))) { return false; } @@ -1685,7 +1685,7 @@ class binary_reader { for (std::size_t i = 0; i < size_and_type.first; ++i) { - if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not get_ubjson_value(size_and_type.second))) + if (JSON_HEDLEY_UNLIKELY(not get_ubjson_value(size_and_type.second))) { return false; } @@ -1696,7 +1696,7 @@ class binary_reader { for (std::size_t i = 0; i < size_and_type.first; ++i) { - if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not parse_ubjson_internal())) + if (JSON_HEDLEY_UNLIKELY(not parse_ubjson_internal())) { return false; } @@ -1705,14 +1705,14 @@ class binary_reader } else { - if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not sax->start_array(std::size_t(-1)))) + if (JSON_HEDLEY_UNLIKELY(not sax->start_array(std::size_t(-1)))) { return false; } while (current != ']') { - if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not parse_ubjson_internal(false))) + if (JSON_HEDLEY_UNLIKELY(not parse_ubjson_internal(false))) { return false; } @@ -1729,7 +1729,7 @@ class binary_reader bool get_ubjson_object() { std::pair size_and_type; - if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not get_ubjson_size_type(size_and_type))) + if (JSON_HEDLEY_UNLIKELY(not get_ubjson_size_type(size_and_type))) { return false; } @@ -1737,7 +1737,7 @@ class binary_reader string_t key; if (size_and_type.first != string_t::npos) { - if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not sax->start_object(size_and_type.first))) + if (JSON_HEDLEY_UNLIKELY(not sax->start_object(size_and_type.first))) { return false; } @@ -1746,11 +1746,11 @@ class binary_reader { for (std::size_t i = 0; i < size_and_type.first; ++i) { - if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not get_ubjson_string(key) or not sax->key(key))) + if (JSON_HEDLEY_UNLIKELY(not get_ubjson_string(key) or not sax->key(key))) { return false; } - if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not get_ubjson_value(size_and_type.second))) + if (JSON_HEDLEY_UNLIKELY(not get_ubjson_value(size_and_type.second))) { return false; } @@ -1761,11 +1761,11 @@ class binary_reader { for (std::size_t i = 0; i < size_and_type.first; ++i) { - if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not get_ubjson_string(key) or not sax->key(key))) + if (JSON_HEDLEY_UNLIKELY(not get_ubjson_string(key) or not sax->key(key))) { return false; } - if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not parse_ubjson_internal())) + if (JSON_HEDLEY_UNLIKELY(not parse_ubjson_internal())) { return false; } @@ -1775,18 +1775,18 @@ class binary_reader } else { - if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not sax->start_object(std::size_t(-1)))) + if (JSON_HEDLEY_UNLIKELY(not sax->start_object(std::size_t(-1)))) { return false; } while (current != '}') { - if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not get_ubjson_string(key, false) or not sax->key(key))) + if (JSON_HEDLEY_UNLIKELY(not get_ubjson_string(key, false) or not sax->key(key))) { return false; } - if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not parse_ubjson_internal())) + if (JSON_HEDLEY_UNLIKELY(not parse_ubjson_internal())) { return false; } @@ -1852,7 +1852,7 @@ class binary_reader for (std::size_t i = 0; i < sizeof(NumberType); ++i) { get(); - if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not unexpect_eof(format, "number"))) + if (JSON_HEDLEY_UNLIKELY(not unexpect_eof(format, "number"))) { return false; } @@ -1896,7 +1896,7 @@ class binary_reader std::generate_n(std::back_inserter(result), len, [this, &success, &format]() { get(); - if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not unexpect_eof(format, "string"))) + if (JSON_HEDLEY_UNLIKELY(not unexpect_eof(format, "string"))) { success = false; } @@ -1910,10 +1910,10 @@ class binary_reader @param[in] context further context information (for diagnostics) @return whether the last read character is not EOF */ - NLOHMANN_JSON_HEDLEY_NON_NULL(3) + JSON_HEDLEY_NON_NULL(3) bool unexpect_eof(const input_format_t format, const char* context) const { - if (NLOHMANN_JSON_HEDLEY_UNLIKELY(current == std::char_traits::eof())) + if (JSON_HEDLEY_UNLIKELY(current == std::char_traits::eof())) { return sax->parse_error(chars_read, "", parse_error::create(110, chars_read, exception_message(format, "unexpected end of input", context))); diff --git a/include/nlohmann/detail/input/input_adapters.hpp b/include/nlohmann/detail/input/input_adapters.hpp index 55b2931c..b7b11de0 100644 --- a/include/nlohmann/detail/input/input_adapters.hpp +++ b/include/nlohmann/detail/input/input_adapters.hpp @@ -55,7 +55,7 @@ Input adapter for stdio file access. This adapter read only 1 byte and do not us class file_input_adapter : public input_adapter_protocol { public: - NLOHMANN_JSON_HEDLEY_NON_NULL(2) + JSON_HEDLEY_NON_NULL(2) explicit file_input_adapter(std::FILE* f) noexcept : m_file(f) {} @@ -131,7 +131,7 @@ class input_stream_adapter : public input_adapter_protocol class input_buffer_adapter : public input_adapter_protocol { public: - NLOHMANN_JSON_HEDLEY_NON_NULL(2) + JSON_HEDLEY_NON_NULL(2) input_buffer_adapter(const char* b, const std::size_t l) noexcept : cursor(b), limit(b + l) {} @@ -145,7 +145,7 @@ class input_buffer_adapter : public input_adapter_protocol std::char_traits::int_type get_character() noexcept override { - if (NLOHMANN_JSON_HEDLEY_LIKELY(cursor < limit)) + if (JSON_HEDLEY_LIKELY(cursor < limit)) { return std::char_traits::to_int_type(*(cursor++)); } @@ -335,7 +335,7 @@ class input_adapter { public: // native support - NLOHMANN_JSON_HEDLEY_NON_NULL(2) + JSON_HEDLEY_NON_NULL(2) input_adapter(std::FILE* file) : ia(std::make_shared(file)) {} /// input adapter for input stream @@ -404,7 +404,7 @@ class input_adapter "each element in the iterator range must have the size of 1 byte"); const auto len = static_cast(std::distance(first, last)); - if (NLOHMANN_JSON_HEDLEY_LIKELY(len > 0)) + if (JSON_HEDLEY_LIKELY(len > 0)) { // there is at least one element: use the address of first ia = std::make_shared(reinterpret_cast(&(*first)), len); diff --git a/include/nlohmann/detail/input/json_sax.hpp b/include/nlohmann/detail/input/json_sax.hpp index 65e48b31..606b7862 100644 --- a/include/nlohmann/detail/input/json_sax.hpp +++ b/include/nlohmann/detail/input/json_sax.hpp @@ -206,7 +206,7 @@ class json_sax_dom_parser { ref_stack.push_back(handle_value(BasicJsonType::value_t::object)); - if (NLOHMANN_JSON_HEDLEY_UNLIKELY(len != std::size_t(-1) and len > ref_stack.back()->max_size())) + if (JSON_HEDLEY_UNLIKELY(len != std::size_t(-1) and len > ref_stack.back()->max_size())) { JSON_THROW(out_of_range::create(408, "excessive object size: " + std::to_string(len))); @@ -232,7 +232,7 @@ class json_sax_dom_parser { ref_stack.push_back(handle_value(BasicJsonType::value_t::array)); - if (NLOHMANN_JSON_HEDLEY_UNLIKELY(len != std::size_t(-1) and len > ref_stack.back()->max_size())) + if (JSON_HEDLEY_UNLIKELY(len != std::size_t(-1) and len > ref_stack.back()->max_size())) { JSON_THROW(out_of_range::create(408, "excessive array size: " + std::to_string(len))); @@ -288,7 +288,7 @@ class json_sax_dom_parser object to which we can add elements */ template - NLOHMANN_JSON_HEDLEY_RETURNS_NON_NULL + JSON_HEDLEY_RETURNS_NON_NULL BasicJsonType* handle_value(Value&& v) { if (ref_stack.empty()) @@ -395,7 +395,7 @@ class json_sax_dom_callback_parser ref_stack.push_back(val.second); // check object limit - if (ref_stack.back() and NLOHMANN_JSON_HEDLEY_UNLIKELY(len != std::size_t(-1) and len > ref_stack.back()->max_size())) + if (ref_stack.back() and JSON_HEDLEY_UNLIKELY(len != std::size_t(-1) and len > ref_stack.back()->max_size())) { JSON_THROW(out_of_range::create(408, "excessive object size: " + std::to_string(len))); } @@ -458,7 +458,7 @@ class json_sax_dom_callback_parser ref_stack.push_back(val.second); // check array limit - if (ref_stack.back() and NLOHMANN_JSON_HEDLEY_UNLIKELY(len != std::size_t(-1) and len > ref_stack.back()->max_size())) + if (ref_stack.back() and JSON_HEDLEY_UNLIKELY(len != std::size_t(-1) and len > ref_stack.back()->max_size())) { JSON_THROW(out_of_range::create(408, "excessive array size: " + std::to_string(len))); } diff --git a/include/nlohmann/detail/input/lexer.hpp b/include/nlohmann/detail/input/lexer.hpp index 21e37d4b..d19836cb 100644 --- a/include/nlohmann/detail/input/lexer.hpp +++ b/include/nlohmann/detail/input/lexer.hpp @@ -59,7 +59,7 @@ class lexer }; /// return name of values of type token_type (only used for errors) - NLOHMANN_JSON_HEDLEY_RETURNS_NON_NULL + JSON_HEDLEY_RETURNS_NON_NULL static const char* token_type_name(const token_type t) noexcept { switch (t) @@ -201,7 +201,7 @@ class lexer for (auto range = ranges.begin(); range != ranges.end(); ++range) { get(); - if (NLOHMANN_JSON_HEDLEY_LIKELY(*range <= current and current <= *(++range))) + if (JSON_HEDLEY_LIKELY(*range <= current and current <= *(++range))) { add(current); } @@ -300,7 +300,7 @@ class lexer const int codepoint1 = get_codepoint(); int codepoint = codepoint1; // start with codepoint1 - if (NLOHMANN_JSON_HEDLEY_UNLIKELY(codepoint1 == -1)) + if (JSON_HEDLEY_UNLIKELY(codepoint1 == -1)) { error_message = "invalid string: '\\u' must be followed by 4 hex digits"; return token_type::parse_error; @@ -310,18 +310,18 @@ class lexer if (0xD800 <= codepoint1 and codepoint1 <= 0xDBFF) { // expect next \uxxxx entry - if (NLOHMANN_JSON_HEDLEY_LIKELY(get() == '\\' and get() == 'u')) + if (JSON_HEDLEY_LIKELY(get() == '\\' and get() == 'u')) { const int codepoint2 = get_codepoint(); - if (NLOHMANN_JSON_HEDLEY_UNLIKELY(codepoint2 == -1)) + if (JSON_HEDLEY_UNLIKELY(codepoint2 == -1)) { error_message = "invalid string: '\\u' must be followed by 4 hex digits"; return token_type::parse_error; } // check if codepoint2 is a low surrogate - if (NLOHMANN_JSON_HEDLEY_LIKELY(0xDC00 <= codepoint2 and codepoint2 <= 0xDFFF)) + if (JSON_HEDLEY_LIKELY(0xDC00 <= codepoint2 and codepoint2 <= 0xDFFF)) { // overwrite codepoint codepoint = static_cast( @@ -348,7 +348,7 @@ class lexer } else { - if (NLOHMANN_JSON_HEDLEY_UNLIKELY(0xDC00 <= codepoint1 and codepoint1 <= 0xDFFF)) + if (JSON_HEDLEY_UNLIKELY(0xDC00 <= codepoint1 and codepoint1 <= 0xDFFF)) { error_message = "invalid string: surrogate U+DC00..U+DFFF must follow U+D800..U+DBFF"; return token_type::parse_error; @@ -723,7 +723,7 @@ class lexer case 0xDE: case 0xDF: { - if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not next_byte_in_range({0x80, 0xBF}))) + if (JSON_HEDLEY_UNLIKELY(not next_byte_in_range({0x80, 0xBF}))) { return token_type::parse_error; } @@ -733,7 +733,7 @@ class lexer // U+0800..U+0FFF: bytes E0 A0..BF 80..BF case 0xE0: { - if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not (next_byte_in_range({0xA0, 0xBF, 0x80, 0xBF})))) + if (JSON_HEDLEY_UNLIKELY(not (next_byte_in_range({0xA0, 0xBF, 0x80, 0xBF})))) { return token_type::parse_error; } @@ -757,7 +757,7 @@ class lexer case 0xEE: case 0xEF: { - if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not (next_byte_in_range({0x80, 0xBF, 0x80, 0xBF})))) + if (JSON_HEDLEY_UNLIKELY(not (next_byte_in_range({0x80, 0xBF, 0x80, 0xBF})))) { return token_type::parse_error; } @@ -767,7 +767,7 @@ class lexer // U+D000..U+D7FF: bytes ED 80..9F 80..BF case 0xED: { - if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not (next_byte_in_range({0x80, 0x9F, 0x80, 0xBF})))) + if (JSON_HEDLEY_UNLIKELY(not (next_byte_in_range({0x80, 0x9F, 0x80, 0xBF})))) { return token_type::parse_error; } @@ -777,7 +777,7 @@ class lexer // U+10000..U+3FFFF F0 90..BF 80..BF 80..BF case 0xF0: { - if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not (next_byte_in_range({0x90, 0xBF, 0x80, 0xBF, 0x80, 0xBF})))) + if (JSON_HEDLEY_UNLIKELY(not (next_byte_in_range({0x90, 0xBF, 0x80, 0xBF, 0x80, 0xBF})))) { return token_type::parse_error; } @@ -789,7 +789,7 @@ class lexer case 0xF2: case 0xF3: { - if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not (next_byte_in_range({0x80, 0xBF, 0x80, 0xBF, 0x80, 0xBF})))) + if (JSON_HEDLEY_UNLIKELY(not (next_byte_in_range({0x80, 0xBF, 0x80, 0xBF, 0x80, 0xBF})))) { return token_type::parse_error; } @@ -799,7 +799,7 @@ class lexer // U+100000..U+10FFFF F4 80..8F 80..BF 80..BF case 0xF4: { - if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not (next_byte_in_range({0x80, 0x8F, 0x80, 0xBF, 0x80, 0xBF})))) + if (JSON_HEDLEY_UNLIKELY(not (next_byte_in_range({0x80, 0x8F, 0x80, 0xBF, 0x80, 0xBF})))) { return token_type::parse_error; } @@ -816,19 +816,19 @@ class lexer } } - NLOHMANN_JSON_HEDLEY_NON_NULL(2) + JSON_HEDLEY_NON_NULL(2) static void strtof(float& f, const char* str, char** endptr) noexcept { f = std::strtof(str, endptr); } - NLOHMANN_JSON_HEDLEY_NON_NULL(2) + JSON_HEDLEY_NON_NULL(2) static void strtof(double& f, const char* str, char** endptr) noexcept { f = std::strtod(str, endptr); } - NLOHMANN_JSON_HEDLEY_NON_NULL(2) + JSON_HEDLEY_NON_NULL(2) static void strtof(long double& f, const char* str, char** endptr) noexcept { f = std::strtold(str, endptr); @@ -1204,14 +1204,14 @@ scan_number_done: @param[in] length the length of the passed literal text @param[in] return_type the token type to return on success */ - NLOHMANN_JSON_HEDLEY_NON_NULL(2) + JSON_HEDLEY_NON_NULL(2) token_type scan_literal(const char* literal_text, const std::size_t length, token_type return_type) { assert(current == literal_text[0]); for (std::size_t i = 1; i < length; ++i) { - if (NLOHMANN_JSON_HEDLEY_UNLIKELY(get() != literal_text[i])) + if (JSON_HEDLEY_UNLIKELY(get() != literal_text[i])) { error_message = "invalid literal"; return token_type::parse_error; @@ -1257,7 +1257,7 @@ scan_number_done: current = ia->get_character(); } - if (NLOHMANN_JSON_HEDLEY_LIKELY(current != std::char_traits::eof())) + if (JSON_HEDLEY_LIKELY(current != std::char_traits::eof())) { token_string.push_back(std::char_traits::to_char_type(current)); } @@ -1298,7 +1298,7 @@ scan_number_done: --position.chars_read_current_line; } - if (NLOHMANN_JSON_HEDLEY_LIKELY(current != std::char_traits::eof())) + if (JSON_HEDLEY_LIKELY(current != std::char_traits::eof())) { assert(not token_string.empty()); token_string.pop_back(); @@ -1377,7 +1377,7 @@ scan_number_done: } /// return syntax error message - NLOHMANN_JSON_HEDLEY_RETURNS_NON_NULL + JSON_HEDLEY_RETURNS_NON_NULL constexpr const char* get_error_message() const noexcept { return error_message; diff --git a/include/nlohmann/detail/input/parser.hpp b/include/nlohmann/detail/input/parser.hpp index 2e3f3b62..8d4febcb 100644 --- a/include/nlohmann/detail/input/parser.hpp +++ b/include/nlohmann/detail/input/parser.hpp @@ -147,7 +147,7 @@ class parser } template - NLOHMANN_JSON_HEDLEY_NON_NULL(2) + JSON_HEDLEY_NON_NULL(2) bool sax_parse(SAX* sax, const bool strict = true) { (void)detail::is_sax_static_asserts {}; @@ -167,7 +167,7 @@ class parser private: template - NLOHMANN_JSON_HEDLEY_NON_NULL(2) + JSON_HEDLEY_NON_NULL(2) bool sax_parse_internal(SAX* sax) { // stack to remember the hierarchy of structured values we are parsing @@ -185,7 +185,7 @@ class parser { case token_type::begin_object: { - if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not sax->start_object(std::size_t(-1)))) + if (JSON_HEDLEY_UNLIKELY(not sax->start_object(std::size_t(-1)))) { return false; } @@ -193,7 +193,7 @@ class parser // closing } -> we are done if (get_token() == token_type::end_object) { - if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not sax->end_object())) + if (JSON_HEDLEY_UNLIKELY(not sax->end_object())) { return false; } @@ -201,20 +201,20 @@ class parser } // parse key - if (NLOHMANN_JSON_HEDLEY_UNLIKELY(last_token != token_type::value_string)) + if (JSON_HEDLEY_UNLIKELY(last_token != token_type::value_string)) { return sax->parse_error(m_lexer.get_position(), m_lexer.get_token_string(), parse_error::create(101, m_lexer.get_position(), exception_message(token_type::value_string, "object key"))); } - if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not sax->key(m_lexer.get_string()))) + if (JSON_HEDLEY_UNLIKELY(not sax->key(m_lexer.get_string()))) { return false; } // parse separator (:) - if (NLOHMANN_JSON_HEDLEY_UNLIKELY(get_token() != token_type::name_separator)) + if (JSON_HEDLEY_UNLIKELY(get_token() != token_type::name_separator)) { return sax->parse_error(m_lexer.get_position(), m_lexer.get_token_string(), @@ -232,7 +232,7 @@ class parser case token_type::begin_array: { - if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not sax->start_array(std::size_t(-1)))) + if (JSON_HEDLEY_UNLIKELY(not sax->start_array(std::size_t(-1)))) { return false; } @@ -240,7 +240,7 @@ class parser // closing ] -> we are done if (get_token() == token_type::end_array) { - if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not sax->end_array())) + if (JSON_HEDLEY_UNLIKELY(not sax->end_array())) { return false; } @@ -258,14 +258,14 @@ class parser { const auto res = m_lexer.get_number_float(); - if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not std::isfinite(res))) + if (JSON_HEDLEY_UNLIKELY(not std::isfinite(res))) { return sax->parse_error(m_lexer.get_position(), m_lexer.get_token_string(), out_of_range::create(406, "number overflow parsing '" + m_lexer.get_token_string() + "'")); } - if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not sax->number_float(res, m_lexer.get_string()))) + if (JSON_HEDLEY_UNLIKELY(not sax->number_float(res, m_lexer.get_string()))) { return false; } @@ -275,7 +275,7 @@ class parser case token_type::literal_false: { - if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not sax->boolean(false))) + if (JSON_HEDLEY_UNLIKELY(not sax->boolean(false))) { return false; } @@ -284,7 +284,7 @@ class parser case token_type::literal_null: { - if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not sax->null())) + if (JSON_HEDLEY_UNLIKELY(not sax->null())) { return false; } @@ -293,7 +293,7 @@ class parser case token_type::literal_true: { - if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not sax->boolean(true))) + if (JSON_HEDLEY_UNLIKELY(not sax->boolean(true))) { return false; } @@ -302,7 +302,7 @@ class parser case token_type::value_integer: { - if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not sax->number_integer(m_lexer.get_number_integer()))) + if (JSON_HEDLEY_UNLIKELY(not sax->number_integer(m_lexer.get_number_integer()))) { return false; } @@ -311,7 +311,7 @@ class parser case token_type::value_string: { - if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not sax->string(m_lexer.get_string()))) + if (JSON_HEDLEY_UNLIKELY(not sax->string(m_lexer.get_string()))) { return false; } @@ -320,7 +320,7 @@ class parser case token_type::value_unsigned: { - if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not sax->number_unsigned(m_lexer.get_number_unsigned()))) + if (JSON_HEDLEY_UNLIKELY(not sax->number_unsigned(m_lexer.get_number_unsigned()))) { return false; } @@ -368,9 +368,9 @@ class parser } // closing ] - if (NLOHMANN_JSON_HEDLEY_LIKELY(last_token == token_type::end_array)) + if (JSON_HEDLEY_LIKELY(last_token == token_type::end_array)) { - if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not sax->end_array())) + if (JSON_HEDLEY_UNLIKELY(not sax->end_array())) { return false; } @@ -396,7 +396,7 @@ class parser if (get_token() == token_type::value_separator) { // parse key - if (NLOHMANN_JSON_HEDLEY_UNLIKELY(get_token() != token_type::value_string)) + if (JSON_HEDLEY_UNLIKELY(get_token() != token_type::value_string)) { return sax->parse_error(m_lexer.get_position(), m_lexer.get_token_string(), @@ -404,13 +404,13 @@ class parser exception_message(token_type::value_string, "object key"))); } - if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not sax->key(m_lexer.get_string()))) + if (JSON_HEDLEY_UNLIKELY(not sax->key(m_lexer.get_string()))) { return false; } // parse separator (:) - if (NLOHMANN_JSON_HEDLEY_UNLIKELY(get_token() != token_type::name_separator)) + if (JSON_HEDLEY_UNLIKELY(get_token() != token_type::name_separator)) { return sax->parse_error(m_lexer.get_position(), m_lexer.get_token_string(), @@ -424,9 +424,9 @@ class parser } // closing } - if (NLOHMANN_JSON_HEDLEY_LIKELY(last_token == token_type::end_object)) + if (JSON_HEDLEY_LIKELY(last_token == token_type::end_object)) { - if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not sax->end_object())) + if (JSON_HEDLEY_UNLIKELY(not sax->end_object())) { return false; } diff --git a/include/nlohmann/detail/iterators/iter_impl.hpp b/include/nlohmann/detail/iterators/iter_impl.hpp index 887bcce4..f41d9517 100644 --- a/include/nlohmann/detail/iterators/iter_impl.hpp +++ b/include/nlohmann/detail/iterators/iter_impl.hpp @@ -255,7 +255,7 @@ class iter_impl default: { - if (NLOHMANN_JSON_HEDLEY_LIKELY(m_it.primitive_iterator.is_begin())) + if (JSON_HEDLEY_LIKELY(m_it.primitive_iterator.is_begin())) { return *m_object; } @@ -289,7 +289,7 @@ class iter_impl default: { - if (NLOHMANN_JSON_HEDLEY_LIKELY(m_it.primitive_iterator.is_begin())) + if (JSON_HEDLEY_LIKELY(m_it.primitive_iterator.is_begin())) { return m_object; } @@ -392,7 +392,7 @@ class iter_impl bool operator==(const iter_impl& other) const { // if objects are not the same, the comparison is undefined - if (NLOHMANN_JSON_HEDLEY_UNLIKELY(m_object != other.m_object)) + if (JSON_HEDLEY_UNLIKELY(m_object != other.m_object)) { JSON_THROW(invalid_iterator::create(212, "cannot compare iterators of different containers")); } @@ -428,7 +428,7 @@ class iter_impl bool operator<(const iter_impl& other) const { // if objects are not the same, the comparison is undefined - if (NLOHMANN_JSON_HEDLEY_UNLIKELY(m_object != other.m_object)) + if (JSON_HEDLEY_UNLIKELY(m_object != other.m_object)) { JSON_THROW(invalid_iterator::create(212, "cannot compare iterators of different containers")); } @@ -588,7 +588,7 @@ class iter_impl default: { - if (NLOHMANN_JSON_HEDLEY_LIKELY(m_it.primitive_iterator.get_value() == -n)) + if (JSON_HEDLEY_LIKELY(m_it.primitive_iterator.get_value() == -n)) { return *m_object; } @@ -606,7 +606,7 @@ class iter_impl { assert(m_object != nullptr); - if (NLOHMANN_JSON_HEDLEY_LIKELY(m_object->is_object())) + if (JSON_HEDLEY_LIKELY(m_object->is_object())) { return m_it.object_iterator->first; } diff --git a/include/nlohmann/detail/json_pointer.hpp b/include/nlohmann/detail/json_pointer.hpp index 609b433f..53118b2e 100644 --- a/include/nlohmann/detail/json_pointer.hpp +++ b/include/nlohmann/detail/json_pointer.hpp @@ -244,7 +244,7 @@ class json_pointer */ void pop_back() { - if (NLOHMANN_JSON_HEDLEY_UNLIKELY(empty())) + if (JSON_HEDLEY_UNLIKELY(empty())) { JSON_THROW(detail::out_of_range::create(405, "JSON pointer has no parent")); } @@ -268,7 +268,7 @@ class json_pointer */ const std::string& back() { - if (NLOHMANN_JSON_HEDLEY_UNLIKELY(empty())) + if (JSON_HEDLEY_UNLIKELY(empty())) { JSON_THROW(detail::out_of_range::create(405, "JSON pointer has no parent")); } @@ -332,7 +332,7 @@ class json_pointer const int res = std::stoi(s, &processed_chars); // check if the string was completely read - if (NLOHMANN_JSON_HEDLEY_UNLIKELY(processed_chars != s.size())) + if (JSON_HEDLEY_UNLIKELY(processed_chars != s.size())) { JSON_THROW(detail::out_of_range::create(404, "unresolved reference token '" + s + "'")); } @@ -342,7 +342,7 @@ class json_pointer json_pointer top() const { - if (NLOHMANN_JSON_HEDLEY_UNLIKELY(empty())) + if (JSON_HEDLEY_UNLIKELY(empty())) { JSON_THROW(detail::out_of_range::create(405, "JSON pointer has no parent")); } @@ -474,7 +474,7 @@ class json_pointer case detail::value_t::array: { // error condition (cf. RFC 6901, Sect. 4) - if (NLOHMANN_JSON_HEDLEY_UNLIKELY(reference_token.size() > 1 and reference_token[0] == '0')) + if (JSON_HEDLEY_UNLIKELY(reference_token.size() > 1 and reference_token[0] == '0')) { JSON_THROW(detail::parse_error::create(106, 0, "array index '" + reference_token + @@ -532,7 +532,7 @@ class json_pointer case detail::value_t::array: { - if (NLOHMANN_JSON_HEDLEY_UNLIKELY(reference_token == "-")) + if (JSON_HEDLEY_UNLIKELY(reference_token == "-")) { // "-" always fails the range check JSON_THROW(detail::out_of_range::create(402, @@ -541,7 +541,7 @@ class json_pointer } // error condition (cf. RFC 6901, Sect. 4) - if (NLOHMANN_JSON_HEDLEY_UNLIKELY(reference_token.size() > 1 and reference_token[0] == '0')) + if (JSON_HEDLEY_UNLIKELY(reference_token.size() > 1 and reference_token[0] == '0')) { JSON_THROW(detail::parse_error::create(106, 0, "array index '" + reference_token + @@ -597,7 +597,7 @@ class json_pointer case detail::value_t::array: { - if (NLOHMANN_JSON_HEDLEY_UNLIKELY(reference_token == "-")) + if (JSON_HEDLEY_UNLIKELY(reference_token == "-")) { // "-" cannot be used for const access JSON_THROW(detail::out_of_range::create(402, @@ -606,7 +606,7 @@ class json_pointer } // error condition (cf. RFC 6901, Sect. 4) - if (NLOHMANN_JSON_HEDLEY_UNLIKELY(reference_token.size() > 1 and reference_token[0] == '0')) + if (JSON_HEDLEY_UNLIKELY(reference_token.size() > 1 and reference_token[0] == '0')) { JSON_THROW(detail::parse_error::create(106, 0, "array index '" + reference_token + @@ -656,7 +656,7 @@ class json_pointer case detail::value_t::array: { - if (NLOHMANN_JSON_HEDLEY_UNLIKELY(reference_token == "-")) + if (JSON_HEDLEY_UNLIKELY(reference_token == "-")) { // "-" always fails the range check JSON_THROW(detail::out_of_range::create(402, @@ -665,7 +665,7 @@ class json_pointer } // error condition (cf. RFC 6901, Sect. 4) - if (NLOHMANN_JSON_HEDLEY_UNLIKELY(reference_token.size() > 1 and reference_token[0] == '0')) + if (JSON_HEDLEY_UNLIKELY(reference_token.size() > 1 and reference_token[0] == '0')) { JSON_THROW(detail::parse_error::create(106, 0, "array index '" + reference_token + @@ -712,7 +712,7 @@ class json_pointer } // check if nonempty reference string begins with slash - if (NLOHMANN_JSON_HEDLEY_UNLIKELY(reference_string[0] != '/')) + if (JSON_HEDLEY_UNLIKELY(reference_string[0] != '/')) { JSON_THROW(detail::parse_error::create(107, 1, "JSON pointer must be empty or begin with '/' - was: '" + @@ -747,9 +747,9 @@ class json_pointer assert(reference_token[pos] == '~'); // ~ must be followed by 0 or 1 - if (NLOHMANN_JSON_HEDLEY_UNLIKELY(pos == reference_token.size() - 1 or - (reference_token[pos + 1] != '0' and - reference_token[pos + 1] != '1'))) + if (JSON_HEDLEY_UNLIKELY(pos == reference_token.size() - 1 or + (reference_token[pos + 1] != '0' and + reference_token[pos + 1] != '1'))) { JSON_THROW(detail::parse_error::create(108, 0, "escape character '~' must be followed with '0' or '1'")); } @@ -874,7 +874,7 @@ class json_pointer static BasicJsonType unflatten(const BasicJsonType& value) { - if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not value.is_object())) + if (JSON_HEDLEY_UNLIKELY(not value.is_object())) { JSON_THROW(detail::type_error::create(314, "only objects can be unflattened")); } @@ -884,7 +884,7 @@ class json_pointer // iterate the JSON object values for (const auto& element : *value.m_value.object) { - if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not element.second.is_primitive())) + if (JSON_HEDLEY_UNLIKELY(not element.second.is_primitive())) { JSON_THROW(detail::type_error::create(315, "values in object must be primitive")); } diff --git a/include/nlohmann/detail/output/binary_writer.hpp b/include/nlohmann/detail/output/binary_writer.hpp index f09d151e..b0ab62d1 100644 --- a/include/nlohmann/detail/output/binary_writer.hpp +++ b/include/nlohmann/detail/output/binary_writer.hpp @@ -715,7 +715,7 @@ class binary_writer static std::size_t calc_bson_entry_header_size(const string_t& name) { const auto it = name.find(static_cast(0)); - if (NLOHMANN_JSON_HEDLEY_UNLIKELY(it != BasicJsonType::string_t::npos)) + if (JSON_HEDLEY_UNLIKELY(it != BasicJsonType::string_t::npos)) { JSON_THROW(out_of_range::create(409, "BSON key cannot contain code point U+0000 (at byte " + std::to_string(it) + ")")); diff --git a/include/nlohmann/detail/output/output_adapters.hpp b/include/nlohmann/detail/output/output_adapters.hpp index 1354a814..71ca65b9 100644 --- a/include/nlohmann/detail/output/output_adapters.hpp +++ b/include/nlohmann/detail/output/output_adapters.hpp @@ -40,7 +40,7 @@ class output_vector_adapter : public output_adapter_protocol v.push_back(c); } - NLOHMANN_JSON_HEDLEY_NON_NULL(2) + JSON_HEDLEY_NON_NULL(2) void write_characters(const CharType* s, std::size_t length) override { std::copy(s, s + length, std::back_inserter(v)); @@ -64,7 +64,7 @@ class output_stream_adapter : public output_adapter_protocol stream.put(c); } - NLOHMANN_JSON_HEDLEY_NON_NULL(2) + JSON_HEDLEY_NON_NULL(2) void write_characters(const CharType* s, std::size_t length) override { stream.write(s, static_cast(length)); @@ -88,7 +88,7 @@ class output_string_adapter : public output_adapter_protocol str.push_back(c); } - NLOHMANN_JSON_HEDLEY_NON_NULL(2) + JSON_HEDLEY_NON_NULL(2) void write_characters(const CharType* s, std::size_t length) override { str.append(s, length); diff --git a/include/nlohmann/detail/output/serializer.hpp b/include/nlohmann/detail/output/serializer.hpp index 7c0a681c..e6811ceb 100644 --- a/include/nlohmann/detail/output/serializer.hpp +++ b/include/nlohmann/detail/output/serializer.hpp @@ -110,7 +110,7 @@ class serializer // variable to hold indentation for recursive calls const auto new_indent = current_indent + indent_step; - if (NLOHMANN_JSON_HEDLEY_UNLIKELY(indent_string.size() < new_indent)) + if (JSON_HEDLEY_UNLIKELY(indent_string.size() < new_indent)) { indent_string.resize(indent_string.size() * 2, ' '); } @@ -183,7 +183,7 @@ class serializer // variable to hold indentation for recursive calls const auto new_indent = current_indent + indent_step; - if (NLOHMANN_JSON_HEDLEY_UNLIKELY(indent_string.size() < new_indent)) + if (JSON_HEDLEY_UNLIKELY(indent_string.size() < new_indent)) { indent_string.resize(indent_string.size() * 2, ' '); } @@ -498,7 +498,7 @@ class serializer } // we finished processing the string - if (NLOHMANN_JSON_HEDLEY_LIKELY(state == UTF8_ACCEPT)) + if (JSON_HEDLEY_LIKELY(state == UTF8_ACCEPT)) { // write buffer if (bytes > 0) diff --git a/include/nlohmann/json.hpp b/include/nlohmann/json.hpp index ab8dd2e9..60f31135 100644 --- a/include/nlohmann/json.hpp +++ b/include/nlohmann/json.hpp @@ -319,7 +319,7 @@ class basic_json @since 2.1.0 */ - NLOHMANN_JSON_HEDLEY_WARN_UNUSED_RESULT + JSON_HEDLEY_WARN_UNUSED_RESULT static basic_json meta() { basic_json result; @@ -824,7 +824,7 @@ class basic_json /// helper for exception-safe object creation template - NLOHMANN_JSON_HEDLEY_RETURNS_NON_NULL + JSON_HEDLEY_RETURNS_NON_NULL static T* create(Args&& ... args) { AllocatorType alloc; @@ -951,7 +951,7 @@ class basic_json default: { object = nullptr; // silence warning, see #821 - if (NLOHMANN_JSON_HEDLEY_UNLIKELY(t == value_t::null)) + if (JSON_HEDLEY_UNLIKELY(t == value_t::null)) { JSON_THROW(other_error::create(500, "961c151d2e87f2686a955a9be24d316f1362bf21 3.6.1")); // LCOV_EXCL_LINE } @@ -1428,7 +1428,7 @@ class basic_json } // if object is wanted but impossible, throw an exception - if (NLOHMANN_JSON_HEDLEY_UNLIKELY(manual_type == value_t::object and not is_an_object)) + if (JSON_HEDLEY_UNLIKELY(manual_type == value_t::object and not is_an_object)) { JSON_THROW(type_error::create(301, "cannot create object from initializer list")); } @@ -1495,7 +1495,7 @@ class basic_json @since version 1.0.0 */ - NLOHMANN_JSON_HEDLEY_WARN_UNUSED_RESULT + JSON_HEDLEY_WARN_UNUSED_RESULT static basic_json array(initializer_list_t init = {}) { return basic_json(init, false, value_t::array); @@ -1539,7 +1539,7 @@ class basic_json @since version 1.0.0 */ - NLOHMANN_JSON_HEDLEY_WARN_UNUSED_RESULT + JSON_HEDLEY_WARN_UNUSED_RESULT static basic_json object(initializer_list_t init = {}) { return basic_json(init, false, value_t::object); @@ -1638,7 +1638,7 @@ class basic_json assert(last.m_object != nullptr); // make sure iterator fits the current value - if (NLOHMANN_JSON_HEDLEY_UNLIKELY(first.m_object != last.m_object)) + if (JSON_HEDLEY_UNLIKELY(first.m_object != last.m_object)) { JSON_THROW(invalid_iterator::create(201, "iterators are not compatible")); } @@ -1655,8 +1655,8 @@ class basic_json case value_t::number_unsigned: case value_t::string: { - if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not first.m_it.primitive_iterator.is_begin() - or not last.m_it.primitive_iterator.is_end())) + if (JSON_HEDLEY_UNLIKELY(not first.m_it.primitive_iterator.is_begin() + or not last.m_it.primitive_iterator.is_end())) { JSON_THROW(invalid_iterator::create(204, "iterators out of range")); } @@ -2369,7 +2369,7 @@ class basic_json /// get a boolean (explicit) boolean_t get_impl(boolean_t* /*unused*/) const { - if (NLOHMANN_JSON_HEDLEY_LIKELY(is_boolean())) + if (JSON_HEDLEY_LIKELY(is_boolean())) { return m_value.boolean; } @@ -2478,7 +2478,7 @@ class basic_json // delegate the call to get_ptr<>() auto ptr = obj.template get_ptr::type>(); - if (NLOHMANN_JSON_HEDLEY_LIKELY(ptr != nullptr)) + if (JSON_HEDLEY_LIKELY(ptr != nullptr)) { return *ptr; } @@ -2929,7 +2929,7 @@ class basic_json reference at(size_type idx) { // at only works for arrays - if (NLOHMANN_JSON_HEDLEY_LIKELY(is_array())) + if (JSON_HEDLEY_LIKELY(is_array())) { JSON_TRY { @@ -2976,7 +2976,7 @@ class basic_json const_reference at(size_type idx) const { // at only works for arrays - if (NLOHMANN_JSON_HEDLEY_LIKELY(is_array())) + if (JSON_HEDLEY_LIKELY(is_array())) { JSON_TRY { @@ -3027,7 +3027,7 @@ class basic_json reference at(const typename object_t::key_type& key) { // at only works for objects - if (NLOHMANN_JSON_HEDLEY_LIKELY(is_object())) + if (JSON_HEDLEY_LIKELY(is_object())) { JSON_TRY { @@ -3078,7 +3078,7 @@ class basic_json const_reference at(const typename object_t::key_type& key) const { // at only works for objects - if (NLOHMANN_JSON_HEDLEY_LIKELY(is_object())) + if (JSON_HEDLEY_LIKELY(is_object())) { JSON_TRY { @@ -3132,7 +3132,7 @@ class basic_json } // operator[] only works for arrays - if (NLOHMANN_JSON_HEDLEY_LIKELY(is_array())) + if (JSON_HEDLEY_LIKELY(is_array())) { // fill up array with null values if given idx is outside range if (idx >= m_value.array->size()) @@ -3170,7 +3170,7 @@ class basic_json const_reference operator[](size_type idx) const { // const operator[] only works for arrays - if (NLOHMANN_JSON_HEDLEY_LIKELY(is_array())) + if (JSON_HEDLEY_LIKELY(is_array())) { return m_value.array->operator[](idx); } @@ -3216,7 +3216,7 @@ class basic_json } // operator[] only works for objects - if (NLOHMANN_JSON_HEDLEY_LIKELY(is_object())) + if (JSON_HEDLEY_LIKELY(is_object())) { return m_value.object->operator[](key); } @@ -3257,7 +3257,7 @@ class basic_json const_reference operator[](const typename object_t::key_type& key) const { // const operator[] only works for objects - if (NLOHMANN_JSON_HEDLEY_LIKELY(is_object())) + if (JSON_HEDLEY_LIKELY(is_object())) { assert(m_value.object->find(key) != m_value.object->end()); return m_value.object->find(key)->second; @@ -3294,7 +3294,7 @@ class basic_json @since version 1.1.0 */ template - NLOHMANN_JSON_HEDLEY_NON_NULL(2) + JSON_HEDLEY_NON_NULL(2) reference operator[](T* key) { // implicitly convert null to object @@ -3306,7 +3306,7 @@ class basic_json } // at only works for objects - if (NLOHMANN_JSON_HEDLEY_LIKELY(is_object())) + if (JSON_HEDLEY_LIKELY(is_object())) { return m_value.object->operator[](key); } @@ -3345,11 +3345,11 @@ class basic_json @since version 1.1.0 */ template - NLOHMANN_JSON_HEDLEY_NON_NULL(2) + JSON_HEDLEY_NON_NULL(2) const_reference operator[](T* key) const { // at only works for objects - if (NLOHMANN_JSON_HEDLEY_LIKELY(is_object())) + if (JSON_HEDLEY_LIKELY(is_object())) { assert(m_value.object->find(key) != m_value.object->end()); return m_value.object->find(key)->second; @@ -3413,7 +3413,7 @@ class basic_json ValueType value(const typename object_t::key_type& key, const ValueType& default_value) const { // at only works for objects - if (NLOHMANN_JSON_HEDLEY_LIKELY(is_object())) + if (JSON_HEDLEY_LIKELY(is_object())) { // if key is found, return value and given default value otherwise const auto it = find(key); @@ -3485,7 +3485,7 @@ class basic_json ValueType value(const json_pointer& ptr, const ValueType& default_value) const { // at only works for objects - if (NLOHMANN_JSON_HEDLEY_LIKELY(is_object())) + if (JSON_HEDLEY_LIKELY(is_object())) { // if pointer resolves a value, return it or use default value JSON_TRY @@ -3505,7 +3505,7 @@ class basic_json @brief overload for a default value of type const char* @copydoc basic_json::value(const json_pointer&, ValueType) const */ - NLOHMANN_JSON_HEDLEY_NON_NULL(3) + JSON_HEDLEY_NON_NULL(3) string_t value(const json_pointer& ptr, const char* default_value) const { return value(ptr, string_t(default_value)); @@ -3650,7 +3650,7 @@ class basic_json IteratorType erase(IteratorType pos) { // make sure iterator fits the current value - if (NLOHMANN_JSON_HEDLEY_UNLIKELY(this != pos.m_object)) + if (JSON_HEDLEY_UNLIKELY(this != pos.m_object)) { JSON_THROW(invalid_iterator::create(202, "iterator does not fit current value")); } @@ -3665,7 +3665,7 @@ class basic_json case value_t::number_unsigned: case value_t::string: { - if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not pos.m_it.primitive_iterator.is_begin())) + if (JSON_HEDLEY_UNLIKELY(not pos.m_it.primitive_iterator.is_begin())) { JSON_THROW(invalid_iterator::create(205, "iterator out of range")); } @@ -3755,7 +3755,7 @@ class basic_json IteratorType erase(IteratorType first, IteratorType last) { // make sure iterator fits the current value - if (NLOHMANN_JSON_HEDLEY_UNLIKELY(this != first.m_object or this != last.m_object)) + if (JSON_HEDLEY_UNLIKELY(this != first.m_object or this != last.m_object)) { JSON_THROW(invalid_iterator::create(203, "iterators do not fit current value")); } @@ -3770,8 +3770,8 @@ class basic_json case value_t::number_unsigned: case value_t::string: { - if (NLOHMANN_JSON_HEDLEY_LIKELY(not first.m_it.primitive_iterator.is_begin() - or not last.m_it.primitive_iterator.is_end())) + if (JSON_HEDLEY_LIKELY(not first.m_it.primitive_iterator.is_begin() + or not last.m_it.primitive_iterator.is_end())) { JSON_THROW(invalid_iterator::create(204, "iterators out of range")); } @@ -3842,7 +3842,7 @@ class basic_json size_type erase(const typename object_t::key_type& key) { // this erase only works for objects - if (NLOHMANN_JSON_HEDLEY_LIKELY(is_object())) + if (JSON_HEDLEY_LIKELY(is_object())) { return m_value.object->erase(key); } @@ -3877,9 +3877,9 @@ class basic_json void erase(const size_type idx) { // this erase only works for arrays - if (NLOHMANN_JSON_HEDLEY_LIKELY(is_array())) + if (JSON_HEDLEY_LIKELY(is_array())) { - if (NLOHMANN_JSON_HEDLEY_UNLIKELY(idx >= size())) + if (JSON_HEDLEY_UNLIKELY(idx >= size())) { JSON_THROW(out_of_range::create(401, "array index " + std::to_string(idx) + " is out of range")); } @@ -4355,7 +4355,7 @@ class basic_json future 4.0.0 of the library. Please use @ref items() instead; that is, replace `json::iterator_wrapper(j)` with `j.items()`. */ - NLOHMANN_JSON_HEDLEY_DEPRECATED(3.1.0) + JSON_HEDLEY_DEPRECATED(3.1.0) static iteration_proxy iterator_wrapper(reference ref) noexcept { return ref.items(); @@ -4364,7 +4364,7 @@ class basic_json /*! @copydoc iterator_wrapper(reference) */ - NLOHMANN_JSON_HEDLEY_DEPRECATED(3.1.0) + JSON_HEDLEY_DEPRECATED(3.1.0) static iteration_proxy iterator_wrapper(const_reference ref) noexcept { return ref.items(); @@ -4783,7 +4783,7 @@ class basic_json void push_back(basic_json&& val) { // push_back only works for null objects or arrays - if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not(is_null() or is_array()))) + if (JSON_HEDLEY_UNLIKELY(not(is_null() or is_array()))) { JSON_THROW(type_error::create(308, "cannot use push_back() with " + std::string(type_name()))); } @@ -4820,7 +4820,7 @@ class basic_json void push_back(const basic_json& val) { // push_back only works for null objects or arrays - if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not(is_null() or is_array()))) + if (JSON_HEDLEY_UNLIKELY(not(is_null() or is_array()))) { JSON_THROW(type_error::create(308, "cannot use push_back() with " + std::string(type_name()))); } @@ -4870,7 +4870,7 @@ class basic_json void push_back(const typename object_t::value_type& val) { // push_back only works for null objects or objects - if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not(is_null() or is_object()))) + if (JSON_HEDLEY_UNLIKELY(not(is_null() or is_object()))) { JSON_THROW(type_error::create(308, "cannot use push_back() with " + std::string(type_name()))); } @@ -4971,7 +4971,7 @@ class basic_json void emplace_back(Args&& ... args) { // emplace_back only works for null objects or arrays - if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not(is_null() or is_array()))) + if (JSON_HEDLEY_UNLIKELY(not(is_null() or is_array()))) { JSON_THROW(type_error::create(311, "cannot use emplace_back() with " + std::string(type_name()))); } @@ -5019,7 +5019,7 @@ class basic_json std::pair emplace(Args&& ... args) { // emplace only works for null objects or arrays - if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not(is_null() or is_object()))) + if (JSON_HEDLEY_UNLIKELY(not(is_null() or is_object()))) { JSON_THROW(type_error::create(311, "cannot use emplace() with " + std::string(type_name()))); } @@ -5087,10 +5087,10 @@ class basic_json iterator insert(const_iterator pos, const basic_json& val) { // insert only works for arrays - if (NLOHMANN_JSON_HEDLEY_LIKELY(is_array())) + if (JSON_HEDLEY_LIKELY(is_array())) { // check if iterator pos fits to this JSON value - if (NLOHMANN_JSON_HEDLEY_UNLIKELY(pos.m_object != this)) + if (JSON_HEDLEY_UNLIKELY(pos.m_object != this)) { JSON_THROW(invalid_iterator::create(202, "iterator does not fit current value")); } @@ -5138,10 +5138,10 @@ class basic_json iterator insert(const_iterator pos, size_type cnt, const basic_json& val) { // insert only works for arrays - if (NLOHMANN_JSON_HEDLEY_LIKELY(is_array())) + if (JSON_HEDLEY_LIKELY(is_array())) { // check if iterator pos fits to this JSON value - if (NLOHMANN_JSON_HEDLEY_UNLIKELY(pos.m_object != this)) + if (JSON_HEDLEY_UNLIKELY(pos.m_object != this)) { JSON_THROW(invalid_iterator::create(202, "iterator does not fit current value")); } @@ -5186,24 +5186,24 @@ class basic_json iterator insert(const_iterator pos, const_iterator first, const_iterator last) { // insert only works for arrays - if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not is_array())) + if (JSON_HEDLEY_UNLIKELY(not is_array())) { JSON_THROW(type_error::create(309, "cannot use insert() with " + std::string(type_name()))); } // check if iterator pos fits to this JSON value - if (NLOHMANN_JSON_HEDLEY_UNLIKELY(pos.m_object != this)) + if (JSON_HEDLEY_UNLIKELY(pos.m_object != this)) { JSON_THROW(invalid_iterator::create(202, "iterator does not fit current value")); } // check if range iterators belong to the same JSON object - if (NLOHMANN_JSON_HEDLEY_UNLIKELY(first.m_object != last.m_object)) + if (JSON_HEDLEY_UNLIKELY(first.m_object != last.m_object)) { JSON_THROW(invalid_iterator::create(210, "iterators do not fit")); } - if (NLOHMANN_JSON_HEDLEY_UNLIKELY(first.m_object == this)) + if (JSON_HEDLEY_UNLIKELY(first.m_object == this)) { JSON_THROW(invalid_iterator::create(211, "passed iterators may not belong to container")); } @@ -5239,13 +5239,13 @@ class basic_json iterator insert(const_iterator pos, initializer_list_t ilist) { // insert only works for arrays - if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not is_array())) + if (JSON_HEDLEY_UNLIKELY(not is_array())) { JSON_THROW(type_error::create(309, "cannot use insert() with " + std::string(type_name()))); } // check if iterator pos fits to this JSON value - if (NLOHMANN_JSON_HEDLEY_UNLIKELY(pos.m_object != this)) + if (JSON_HEDLEY_UNLIKELY(pos.m_object != this)) { JSON_THROW(invalid_iterator::create(202, "iterator does not fit current value")); } @@ -5280,19 +5280,19 @@ class basic_json void insert(const_iterator first, const_iterator last) { // insert only works for objects - if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not is_object())) + if (JSON_HEDLEY_UNLIKELY(not is_object())) { JSON_THROW(type_error::create(309, "cannot use insert() with " + std::string(type_name()))); } // check if range iterators belong to the same JSON object - if (NLOHMANN_JSON_HEDLEY_UNLIKELY(first.m_object != last.m_object)) + if (JSON_HEDLEY_UNLIKELY(first.m_object != last.m_object)) { JSON_THROW(invalid_iterator::create(210, "iterators do not fit")); } // passed iterators must belong to objects - if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not first.m_object->is_object())) + if (JSON_HEDLEY_UNLIKELY(not first.m_object->is_object())) { JSON_THROW(invalid_iterator::create(202, "iterators first and last must point to objects")); } @@ -5329,11 +5329,11 @@ class basic_json assert_invariant(); } - if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not is_object())) + if (JSON_HEDLEY_UNLIKELY(not is_object())) { JSON_THROW(type_error::create(312, "cannot use update() with " + std::string(type_name()))); } - if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not j.is_object())) + if (JSON_HEDLEY_UNLIKELY(not j.is_object())) { JSON_THROW(type_error::create(312, "cannot use update() with " + std::string(j.type_name()))); } @@ -5380,20 +5380,20 @@ class basic_json assert_invariant(); } - if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not is_object())) + if (JSON_HEDLEY_UNLIKELY(not is_object())) { JSON_THROW(type_error::create(312, "cannot use update() with " + std::string(type_name()))); } // check if range iterators belong to the same JSON object - if (NLOHMANN_JSON_HEDLEY_UNLIKELY(first.m_object != last.m_object)) + if (JSON_HEDLEY_UNLIKELY(first.m_object != last.m_object)) { JSON_THROW(invalid_iterator::create(210, "iterators do not fit")); } // passed iterators must belong to objects - if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not first.m_object->is_object() - or not last.m_object->is_object())) + if (JSON_HEDLEY_UNLIKELY(not first.m_object->is_object() + or not last.m_object->is_object())) { JSON_THROW(invalid_iterator::create(202, "iterators first and last must point to objects")); } @@ -5456,7 +5456,7 @@ class basic_json void swap(array_t& other) { // swap only works for arrays - if (NLOHMANN_JSON_HEDLEY_LIKELY(is_array())) + if (JSON_HEDLEY_LIKELY(is_array())) { std::swap(*(m_value.array), other); } @@ -5489,7 +5489,7 @@ class basic_json void swap(object_t& other) { // swap only works for objects - if (NLOHMANN_JSON_HEDLEY_LIKELY(is_object())) + if (JSON_HEDLEY_LIKELY(is_object())) { std::swap(*(m_value.object), other); } @@ -5522,7 +5522,7 @@ class basic_json void swap(string_t& other) { // swap only works for strings - if (NLOHMANN_JSON_HEDLEY_LIKELY(is_string())) + if (JSON_HEDLEY_LIKELY(is_string())) { std::swap(*(m_value.string), other); } @@ -6032,7 +6032,7 @@ class basic_json instead; that is, replace calls like `j >> o;` with `o << j;`. @since version 1.0.0; deprecated since version 3.0.0 */ - NLOHMANN_JSON_HEDLEY_DEPRECATED(3.0.0) + JSON_HEDLEY_DEPRECATED(3.0.0) friend std::ostream& operator>>(const basic_json& j, std::ostream& o) { return o << j; @@ -6111,7 +6111,7 @@ class basic_json @since version 2.0.3 (contiguous containers) */ - NLOHMANN_JSON_HEDLEY_WARN_UNUSED_RESULT + JSON_HEDLEY_WARN_UNUSED_RESULT static basic_json parse(detail::input_adapter&& i, const parser_callback_t cb = nullptr, const bool allow_exceptions = true) @@ -6180,7 +6180,7 @@ class basic_json @since version 3.2.0 */ template - NLOHMANN_JSON_HEDLEY_NON_NULL(2) + JSON_HEDLEY_NON_NULL(2) static bool sax_parse(detail::input_adapter&& i, SAX* sax, input_format_t format = input_format_t::json, const bool strict = true) @@ -6266,7 +6266,7 @@ class basic_json std::is_base_of< std::random_access_iterator_tag, typename std::iterator_traits::iterator_category>::value, int>::type = 0> - NLOHMANN_JSON_HEDLEY_NON_NULL(3) + JSON_HEDLEY_NON_NULL(3) static bool sax_parse(IteratorType first, IteratorType last, SAX* sax) { return parser(detail::input_adapter(first, last)).sax_parse(sax); @@ -6280,7 +6280,7 @@ class basic_json instead; that is, replace calls like `j << i;` with `i >> j;`. @since version 1.0.0; deprecated since version 3.0.0 */ - NLOHMANN_JSON_HEDLEY_DEPRECATED(3.0.0) + JSON_HEDLEY_DEPRECATED(3.0.0) friend std::istream& operator<<(basic_json& j, std::istream& i) { return operator>>(i, j); @@ -6353,7 +6353,7 @@ class basic_json @since version 1.0.0, public since 2.1.0, `const char*` and `noexcept` since 3.0.0 */ - NLOHMANN_JSON_HEDLEY_RETURNS_NON_NULL + JSON_HEDLEY_RETURNS_NON_NULL const char* type_name() const noexcept { { @@ -6883,7 +6883,7 @@ class basic_json @a strict parameter since 3.0.0; added @a allow_exceptions parameter since 3.2.0 */ - NLOHMANN_JSON_HEDLEY_WARN_UNUSED_RESULT + JSON_HEDLEY_WARN_UNUSED_RESULT static basic_json from_cbor(detail::input_adapter&& i, const bool strict = true, const bool allow_exceptions = true) @@ -6899,7 +6899,7 @@ class basic_json */ template::value, int> = 0> - NLOHMANN_JSON_HEDLEY_WARN_UNUSED_RESULT + JSON_HEDLEY_WARN_UNUSED_RESULT static basic_json from_cbor(A1 && a1, A2 && a2, const bool strict = true, const bool allow_exceptions = true) @@ -6992,7 +6992,7 @@ class basic_json @a strict parameter since 3.0.0; added @a allow_exceptions parameter since 3.2.0 */ - NLOHMANN_JSON_HEDLEY_WARN_UNUSED_RESULT + JSON_HEDLEY_WARN_UNUSED_RESULT static basic_json from_msgpack(detail::input_adapter&& i, const bool strict = true, const bool allow_exceptions = true) @@ -7008,7 +7008,7 @@ class basic_json */ template::value, int> = 0> - NLOHMANN_JSON_HEDLEY_WARN_UNUSED_RESULT + JSON_HEDLEY_WARN_UNUSED_RESULT static basic_json from_msgpack(A1 && a1, A2 && a2, const bool strict = true, const bool allow_exceptions = true) @@ -7080,7 +7080,7 @@ class basic_json @since version 3.1.0; added @a allow_exceptions parameter since 3.2.0 */ - NLOHMANN_JSON_HEDLEY_WARN_UNUSED_RESULT + JSON_HEDLEY_WARN_UNUSED_RESULT static basic_json from_ubjson(detail::input_adapter&& i, const bool strict = true, const bool allow_exceptions = true) @@ -7096,7 +7096,7 @@ class basic_json */ template::value, int> = 0> - NLOHMANN_JSON_HEDLEY_WARN_UNUSED_RESULT + JSON_HEDLEY_WARN_UNUSED_RESULT static basic_json from_ubjson(A1 && a1, A2 && a2, const bool strict = true, const bool allow_exceptions = true) @@ -7167,7 +7167,7 @@ class basic_json @sa @ref from_ubjson(detail::input_adapter&&, const bool, const bool) for the related UBJSON format */ - NLOHMANN_JSON_HEDLEY_WARN_UNUSED_RESULT + JSON_HEDLEY_WARN_UNUSED_RESULT static basic_json from_bson(detail::input_adapter&& i, const bool strict = true, const bool allow_exceptions = true) @@ -7183,7 +7183,7 @@ class basic_json */ template::value, int> = 0> - NLOHMANN_JSON_HEDLEY_WARN_UNUSED_RESULT + JSON_HEDLEY_WARN_UNUSED_RESULT static basic_json from_bson(A1 && a1, A2 && a2, const bool strict = true, const bool allow_exceptions = true) @@ -7557,7 +7557,7 @@ class basic_json else { const auto idx = json_pointer::array_index(last_path); - if (NLOHMANN_JSON_HEDLEY_UNLIKELY(static_cast(idx) > parent.size())) + if (JSON_HEDLEY_UNLIKELY(static_cast(idx) > parent.size())) { // avoid undefined behavior JSON_THROW(out_of_range::create(401, "array index " + std::to_string(idx) + " is out of range")); @@ -7588,7 +7588,7 @@ class basic_json { // perform range check auto it = parent.find(last_path); - if (NLOHMANN_JSON_HEDLEY_LIKELY(it != parent.end())) + if (JSON_HEDLEY_LIKELY(it != parent.end())) { parent.erase(it); } @@ -7605,7 +7605,7 @@ class basic_json }; // type check: top level value must be an array - if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not json_patch.is_array())) + if (JSON_HEDLEY_UNLIKELY(not json_patch.is_array())) { JSON_THROW(parse_error::create(104, 0, "JSON patch must be an array of objects")); } @@ -7625,13 +7625,13 @@ class basic_json const auto error_msg = (op == "op") ? "operation" : "operation '" + op + "'"; // check if desired value is present - if (NLOHMANN_JSON_HEDLEY_UNLIKELY(it == val.m_value.object->end())) + if (JSON_HEDLEY_UNLIKELY(it == val.m_value.object->end())) { JSON_THROW(parse_error::create(105, 0, error_msg + " must have member '" + member + "'")); } // check if result is of type string - if (NLOHMANN_JSON_HEDLEY_UNLIKELY(string_type and not it->second.is_string())) + if (JSON_HEDLEY_UNLIKELY(string_type and not it->second.is_string())) { JSON_THROW(parse_error::create(105, 0, error_msg + " must have string member '" + member + "'")); } @@ -7641,7 +7641,7 @@ class basic_json }; // type check: every element of the array must be an object - if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not val.is_object())) + if (JSON_HEDLEY_UNLIKELY(not val.is_object())) { JSON_THROW(parse_error::create(104, 0, "JSON patch must be an array of objects")); } @@ -7719,7 +7719,7 @@ class basic_json } // throw an exception if test fails - if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not success)) + if (JSON_HEDLEY_UNLIKELY(not success)) { JSON_THROW(other_error::create(501, "unsuccessful: " + val.dump())); } @@ -7772,7 +7772,7 @@ class basic_json @since version 2.0.0 */ - NLOHMANN_JSON_HEDLEY_WARN_UNUSED_RESULT + JSON_HEDLEY_WARN_UNUSED_RESULT static basic_json diff(const basic_json& source, const basic_json& target, const std::string& path = "") { @@ -8064,7 +8064,7 @@ if no parse error occurred. @since version 1.0.0 */ -NLOHMANN_JSON_HEDLEY_NON_NULL(1) +JSON_HEDLEY_NON_NULL(1) inline nlohmann::json operator "" _json(const char* s, std::size_t n) { return nlohmann::json::parse(s, s + n); @@ -8083,7 +8083,7 @@ object if no parse error occurred. @since version 2.0.0 */ -NLOHMANN_JSON_HEDLEY_NON_NULL(1) +JSON_HEDLEY_NON_NULL(1) inline nlohmann::json::json_pointer operator "" _json_pointer(const char* s, std::size_t n) { return nlohmann::json::json_pointer(std::string(s, n)); diff --git a/include/nlohmann/thirdparty/hedley/hedley.hpp b/include/nlohmann/thirdparty/hedley/hedley.hpp index 31d63a6b..453e6488 100644 --- a/include/nlohmann/thirdparty/hedley/hedley.hpp +++ b/include/nlohmann/thirdparty/hedley/hedley.hpp @@ -10,1257 +10,1257 @@ * SPDX-License-Identifier: CC0-1.0 */ -#if !defined(NLOHMANN_JSON_HEDLEY_VERSION) || (NLOHMANN_JSON_HEDLEY_VERSION < 9) -#if defined(NLOHMANN_JSON_HEDLEY_VERSION) - #undef NLOHMANN_JSON_HEDLEY_VERSION +#if !defined(JSON_HEDLEY_VERSION) || (JSON_HEDLEY_VERSION < 9) +#if defined(JSON_HEDLEY_VERSION) + #undef JSON_HEDLEY_VERSION #endif -#define NLOHMANN_JSON_HEDLEY_VERSION 9 +#define JSON_HEDLEY_VERSION 9 -#if defined(NLOHMANN_JSON_HEDLEY_STRINGIFY_EX) - #undef NLOHMANN_JSON_HEDLEY_STRINGIFY_EX +#if defined(JSON_HEDLEY_STRINGIFY_EX) + #undef JSON_HEDLEY_STRINGIFY_EX #endif -#define NLOHMANN_JSON_HEDLEY_STRINGIFY_EX(x) #x +#define JSON_HEDLEY_STRINGIFY_EX(x) #x -#if defined(NLOHMANN_JSON_HEDLEY_STRINGIFY) - #undef NLOHMANN_JSON_HEDLEY_STRINGIFY +#if defined(JSON_HEDLEY_STRINGIFY) + #undef JSON_HEDLEY_STRINGIFY #endif -#define NLOHMANN_JSON_HEDLEY_STRINGIFY(x) NLOHMANN_JSON_HEDLEY_STRINGIFY_EX(x) +#define JSON_HEDLEY_STRINGIFY(x) JSON_HEDLEY_STRINGIFY_EX(x) -#if defined(NLOHMANN_JSON_HEDLEY_CONCAT_EX) - #undef NLOHMANN_JSON_HEDLEY_CONCAT_EX +#if defined(JSON_HEDLEY_CONCAT_EX) + #undef JSON_HEDLEY_CONCAT_EX #endif -#define NLOHMANN_JSON_HEDLEY_CONCAT_EX(a,b) a##b +#define JSON_HEDLEY_CONCAT_EX(a,b) a##b -#if defined(NLOHMANN_JSON_HEDLEY_CONCAT) - #undef NLOHMANN_JSON_HEDLEY_CONCAT +#if defined(JSON_HEDLEY_CONCAT) + #undef JSON_HEDLEY_CONCAT #endif -#define NLOHMANN_JSON_HEDLEY_CONCAT(a,b) NLOHMANN_JSON_HEDLEY_CONCAT_EX(a,b) +#define JSON_HEDLEY_CONCAT(a,b) JSON_HEDLEY_CONCAT_EX(a,b) -#if defined(NLOHMANN_JSON_HEDLEY_VERSION_ENCODE) - #undef NLOHMANN_JSON_HEDLEY_VERSION_ENCODE +#if defined(JSON_HEDLEY_VERSION_ENCODE) + #undef JSON_HEDLEY_VERSION_ENCODE #endif -#define NLOHMANN_JSON_HEDLEY_VERSION_ENCODE(major,minor,revision) (((major) * 1000000) + ((minor) * 1000) + (revision)) +#define JSON_HEDLEY_VERSION_ENCODE(major,minor,revision) (((major) * 1000000) + ((minor) * 1000) + (revision)) -#if defined(NLOHMANN_JSON_HEDLEY_VERSION_DECODE_MAJOR) - #undef NLOHMANN_JSON_HEDLEY_VERSION_DECODE_MAJOR +#if defined(JSON_HEDLEY_VERSION_DECODE_MAJOR) + #undef JSON_HEDLEY_VERSION_DECODE_MAJOR #endif -#define NLOHMANN_JSON_HEDLEY_VERSION_DECODE_MAJOR(version) ((version) / 1000000) +#define JSON_HEDLEY_VERSION_DECODE_MAJOR(version) ((version) / 1000000) -#if defined(NLOHMANN_JSON_HEDLEY_VERSION_DECODE_MINOR) - #undef NLOHMANN_JSON_HEDLEY_VERSION_DECODE_MINOR +#if defined(JSON_HEDLEY_VERSION_DECODE_MINOR) + #undef JSON_HEDLEY_VERSION_DECODE_MINOR #endif -#define NLOHMANN_JSON_HEDLEY_VERSION_DECODE_MINOR(version) (((version) % 1000000) / 1000) +#define JSON_HEDLEY_VERSION_DECODE_MINOR(version) (((version) % 1000000) / 1000) -#if defined(NLOHMANN_JSON_HEDLEY_VERSION_DECODE_REVISION) - #undef NLOHMANN_JSON_HEDLEY_VERSION_DECODE_REVISION +#if defined(JSON_HEDLEY_VERSION_DECODE_REVISION) + #undef JSON_HEDLEY_VERSION_DECODE_REVISION #endif -#define NLOHMANN_JSON_HEDLEY_VERSION_DECODE_REVISION(version) ((version) % 1000) +#define JSON_HEDLEY_VERSION_DECODE_REVISION(version) ((version) % 1000) -#if defined(NLOHMANN_JSON_HEDLEY_GNUC_VERSION) - #undef NLOHMANN_JSON_HEDLEY_GNUC_VERSION +#if defined(JSON_HEDLEY_GNUC_VERSION) + #undef JSON_HEDLEY_GNUC_VERSION #endif #if defined(__GNUC__) && defined(__GNUC_PATCHLEVEL__) - #define NLOHMANN_JSON_HEDLEY_GNUC_VERSION NLOHMANN_JSON_HEDLEY_VERSION_ENCODE(__GNUC__, __GNUC_MINOR__, __GNUC_PATCHLEVEL__) + #define JSON_HEDLEY_GNUC_VERSION JSON_HEDLEY_VERSION_ENCODE(__GNUC__, __GNUC_MINOR__, __GNUC_PATCHLEVEL__) #elif defined(__GNUC__) - #define NLOHMANN_JSON_HEDLEY_GNUC_VERSION NLOHMANN_JSON_HEDLEY_VERSION_ENCODE(__GNUC__, __GNUC_MINOR__, 0) + #define JSON_HEDLEY_GNUC_VERSION JSON_HEDLEY_VERSION_ENCODE(__GNUC__, __GNUC_MINOR__, 0) #endif -#if defined(NLOHMANN_JSON_HEDLEY_GNUC_VERSION_CHECK) - #undef NLOHMANN_JSON_HEDLEY_GNUC_VERSION_CHECK +#if defined(JSON_HEDLEY_GNUC_VERSION_CHECK) + #undef JSON_HEDLEY_GNUC_VERSION_CHECK #endif -#if defined(NLOHMANN_JSON_HEDLEY_GNUC_VERSION) - #define NLOHMANN_JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch) (NLOHMANN_JSON_HEDLEY_GNUC_VERSION >= NLOHMANN_JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) +#if defined(JSON_HEDLEY_GNUC_VERSION) + #define JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_GNUC_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) #else - #define NLOHMANN_JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch) (0) + #define JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch) (0) #endif -#if defined(NLOHMANN_JSON_HEDLEY_MSVC_VERSION) - #undef NLOHMANN_JSON_HEDLEY_MSVC_VERSION +#if defined(JSON_HEDLEY_MSVC_VERSION) + #undef JSON_HEDLEY_MSVC_VERSION #endif #if defined(_MSC_FULL_VER) && (_MSC_FULL_VER >= 140000000) - #define NLOHMANN_JSON_HEDLEY_MSVC_VERSION NLOHMANN_JSON_HEDLEY_VERSION_ENCODE(_MSC_FULL_VER / 10000000, (_MSC_FULL_VER % 10000000) / 100000, (_MSC_FULL_VER % 100000) / 100) + #define JSON_HEDLEY_MSVC_VERSION JSON_HEDLEY_VERSION_ENCODE(_MSC_FULL_VER / 10000000, (_MSC_FULL_VER % 10000000) / 100000, (_MSC_FULL_VER % 100000) / 100) #elif defined(_MSC_FULL_VER) - #define NLOHMANN_JSON_HEDLEY_MSVC_VERSION NLOHMANN_JSON_HEDLEY_VERSION_ENCODE(_MSC_FULL_VER / 1000000, (_MSC_FULL_VER % 1000000) / 10000, (_MSC_FULL_VER % 10000) / 10) + #define JSON_HEDLEY_MSVC_VERSION JSON_HEDLEY_VERSION_ENCODE(_MSC_FULL_VER / 1000000, (_MSC_FULL_VER % 1000000) / 10000, (_MSC_FULL_VER % 10000) / 10) #elif defined(_MSC_VER) - #define NLOHMANN_JSON_HEDLEY_MSVC_VERSION NLOHMANN_JSON_HEDLEY_VERSION_ENCODE(_MSC_VER / 100, _MSC_VER % 100, 0) + #define JSON_HEDLEY_MSVC_VERSION JSON_HEDLEY_VERSION_ENCODE(_MSC_VER / 100, _MSC_VER % 100, 0) #endif -#if defined(NLOHMANN_JSON_HEDLEY_MSVC_VERSION_CHECK) - #undef NLOHMANN_JSON_HEDLEY_MSVC_VERSION_CHECK +#if defined(JSON_HEDLEY_MSVC_VERSION_CHECK) + #undef JSON_HEDLEY_MSVC_VERSION_CHECK #endif #if !defined(_MSC_VER) - #define NLOHMANN_JSON_HEDLEY_MSVC_VERSION_CHECK(major,minor,patch) (0) + #define JSON_HEDLEY_MSVC_VERSION_CHECK(major,minor,patch) (0) #elif defined(_MSC_VER) && (_MSC_VER >= 1400) - #define NLOHMANN_JSON_HEDLEY_MSVC_VERSION_CHECK(major,minor,patch) (_MSC_FULL_VER >= ((major * 10000000) + (minor * 100000) + (patch))) + #define JSON_HEDLEY_MSVC_VERSION_CHECK(major,minor,patch) (_MSC_FULL_VER >= ((major * 10000000) + (minor * 100000) + (patch))) #elif defined(_MSC_VER) && (_MSC_VER >= 1200) - #define NLOHMANN_JSON_HEDLEY_MSVC_VERSION_CHECK(major,minor,patch) (_MSC_FULL_VER >= ((major * 1000000) + (minor * 10000) + (patch))) + #define JSON_HEDLEY_MSVC_VERSION_CHECK(major,minor,patch) (_MSC_FULL_VER >= ((major * 1000000) + (minor * 10000) + (patch))) #else - #define NLOHMANN_JSON_HEDLEY_MSVC_VERSION_CHECK(major,minor,patch) (_MSC_VER >= ((major * 100) + (minor))) + #define JSON_HEDLEY_MSVC_VERSION_CHECK(major,minor,patch) (_MSC_VER >= ((major * 100) + (minor))) #endif -#if defined(NLOHMANN_JSON_HEDLEY_INTEL_VERSION) - #undef NLOHMANN_JSON_HEDLEY_INTEL_VERSION +#if defined(JSON_HEDLEY_INTEL_VERSION) + #undef JSON_HEDLEY_INTEL_VERSION #endif #if defined(__INTEL_COMPILER) && defined(__INTEL_COMPILER_UPDATE) - #define NLOHMANN_JSON_HEDLEY_INTEL_VERSION NLOHMANN_JSON_HEDLEY_VERSION_ENCODE(__INTEL_COMPILER / 100, __INTEL_COMPILER % 100, __INTEL_COMPILER_UPDATE) + #define JSON_HEDLEY_INTEL_VERSION JSON_HEDLEY_VERSION_ENCODE(__INTEL_COMPILER / 100, __INTEL_COMPILER % 100, __INTEL_COMPILER_UPDATE) #elif defined(__INTEL_COMPILER) - #define NLOHMANN_JSON_HEDLEY_INTEL_VERSION NLOHMANN_JSON_HEDLEY_VERSION_ENCODE(__INTEL_COMPILER / 100, __INTEL_COMPILER % 100, 0) + #define JSON_HEDLEY_INTEL_VERSION JSON_HEDLEY_VERSION_ENCODE(__INTEL_COMPILER / 100, __INTEL_COMPILER % 100, 0) #endif -#if defined(NLOHMANN_JSON_HEDLEY_INTEL_VERSION_CHECK) - #undef NLOHMANN_JSON_HEDLEY_INTEL_VERSION_CHECK +#if defined(JSON_HEDLEY_INTEL_VERSION_CHECK) + #undef JSON_HEDLEY_INTEL_VERSION_CHECK #endif -#if defined(NLOHMANN_JSON_HEDLEY_INTEL_VERSION) - #define NLOHMANN_JSON_HEDLEY_INTEL_VERSION_CHECK(major,minor,patch) (NLOHMANN_JSON_HEDLEY_INTEL_VERSION >= NLOHMANN_JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) +#if defined(JSON_HEDLEY_INTEL_VERSION) + #define JSON_HEDLEY_INTEL_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_INTEL_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) #else - #define NLOHMANN_JSON_HEDLEY_INTEL_VERSION_CHECK(major,minor,patch) (0) + #define JSON_HEDLEY_INTEL_VERSION_CHECK(major,minor,patch) (0) #endif -#if defined(NLOHMANN_JSON_HEDLEY_PGI_VERSION) - #undef NLOHMANN_JSON_HEDLEY_PGI_VERSION +#if defined(JSON_HEDLEY_PGI_VERSION) + #undef JSON_HEDLEY_PGI_VERSION #endif #if defined(__PGI) && defined(__PGIC__) && defined(__PGIC_MINOR__) && defined(__PGIC_PATCHLEVEL__) - #define NLOHMANN_JSON_HEDLEY_PGI_VERSION NLOHMANN_JSON_HEDLEY_VERSION_ENCODE(__PGIC__, __PGIC_MINOR__, __PGIC_PATCHLEVEL__) + #define JSON_HEDLEY_PGI_VERSION JSON_HEDLEY_VERSION_ENCODE(__PGIC__, __PGIC_MINOR__, __PGIC_PATCHLEVEL__) #endif -#if defined(NLOHMANN_JSON_HEDLEY_PGI_VERSION_CHECK) - #undef NLOHMANN_JSON_HEDLEY_PGI_VERSION_CHECK +#if defined(JSON_HEDLEY_PGI_VERSION_CHECK) + #undef JSON_HEDLEY_PGI_VERSION_CHECK #endif -#if defined(NLOHMANN_JSON_HEDLEY_PGI_VERSION) - #define NLOHMANN_JSON_HEDLEY_PGI_VERSION_CHECK(major,minor,patch) (NLOHMANN_JSON_HEDLEY_PGI_VERSION >= NLOHMANN_JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) +#if defined(JSON_HEDLEY_PGI_VERSION) + #define JSON_HEDLEY_PGI_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_PGI_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) #else - #define NLOHMANN_JSON_HEDLEY_PGI_VERSION_CHECK(major,minor,patch) (0) + #define JSON_HEDLEY_PGI_VERSION_CHECK(major,minor,patch) (0) #endif -#if defined(NLOHMANN_JSON_HEDLEY_SUNPRO_VERSION) - #undef NLOHMANN_JSON_HEDLEY_SUNPRO_VERSION +#if defined(JSON_HEDLEY_SUNPRO_VERSION) + #undef JSON_HEDLEY_SUNPRO_VERSION #endif #if defined(__SUNPRO_C) && (__SUNPRO_C > 0x1000) - #define NLOHMANN_JSON_HEDLEY_SUNPRO_VERSION NLOHMANN_JSON_HEDLEY_VERSION_ENCODE((((__SUNPRO_C >> 16) & 0xf) * 10) + ((__SUNPRO_C >> 12) & 0xf), (((__SUNPRO_C >> 8) & 0xf) * 10) + ((__SUNPRO_C >> 4) & 0xf), (__SUNPRO_C & 0xf) * 10) + #define JSON_HEDLEY_SUNPRO_VERSION JSON_HEDLEY_VERSION_ENCODE((((__SUNPRO_C >> 16) & 0xf) * 10) + ((__SUNPRO_C >> 12) & 0xf), (((__SUNPRO_C >> 8) & 0xf) * 10) + ((__SUNPRO_C >> 4) & 0xf), (__SUNPRO_C & 0xf) * 10) #elif defined(__SUNPRO_C) - #define NLOHMANN_JSON_HEDLEY_SUNPRO_VERSION NLOHMANN_JSON_HEDLEY_VERSION_ENCODE((__SUNPRO_C >> 8) & 0xf, (__SUNPRO_C >> 4) & 0xf, (__SUNPRO_C) & 0xf) + #define JSON_HEDLEY_SUNPRO_VERSION JSON_HEDLEY_VERSION_ENCODE((__SUNPRO_C >> 8) & 0xf, (__SUNPRO_C >> 4) & 0xf, (__SUNPRO_C) & 0xf) #elif defined(__SUNPRO_CC) && (__SUNPRO_CC > 0x1000) - #define NLOHMANN_JSON_HEDLEY_SUNPRO_VERSION NLOHMANN_JSON_HEDLEY_VERSION_ENCODE((((__SUNPRO_CC >> 16) & 0xf) * 10) + ((__SUNPRO_CC >> 12) & 0xf), (((__SUNPRO_CC >> 8) & 0xf) * 10) + ((__SUNPRO_CC >> 4) & 0xf), (__SUNPRO_CC & 0xf) * 10) + #define JSON_HEDLEY_SUNPRO_VERSION JSON_HEDLEY_VERSION_ENCODE((((__SUNPRO_CC >> 16) & 0xf) * 10) + ((__SUNPRO_CC >> 12) & 0xf), (((__SUNPRO_CC >> 8) & 0xf) * 10) + ((__SUNPRO_CC >> 4) & 0xf), (__SUNPRO_CC & 0xf) * 10) #elif defined(__SUNPRO_CC) - #define NLOHMANN_JSON_HEDLEY_SUNPRO_VERSION NLOHMANN_JSON_HEDLEY_VERSION_ENCODE((__SUNPRO_CC >> 8) & 0xf, (__SUNPRO_CC >> 4) & 0xf, (__SUNPRO_CC) & 0xf) + #define JSON_HEDLEY_SUNPRO_VERSION JSON_HEDLEY_VERSION_ENCODE((__SUNPRO_CC >> 8) & 0xf, (__SUNPRO_CC >> 4) & 0xf, (__SUNPRO_CC) & 0xf) #endif -#if defined(NLOHMANN_JSON_HEDLEY_SUNPRO_VERSION_CHECK) - #undef NLOHMANN_JSON_HEDLEY_SUNPRO_VERSION_CHECK +#if defined(JSON_HEDLEY_SUNPRO_VERSION_CHECK) + #undef JSON_HEDLEY_SUNPRO_VERSION_CHECK #endif -#if defined(NLOHMANN_JSON_HEDLEY_SUNPRO_VERSION) - #define NLOHMANN_JSON_HEDLEY_SUNPRO_VERSION_CHECK(major,minor,patch) (NLOHMANN_JSON_HEDLEY_SUNPRO_VERSION >= NLOHMANN_JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) +#if defined(JSON_HEDLEY_SUNPRO_VERSION) + #define JSON_HEDLEY_SUNPRO_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_SUNPRO_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) #else - #define NLOHMANN_JSON_HEDLEY_SUNPRO_VERSION_CHECK(major,minor,patch) (0) + #define JSON_HEDLEY_SUNPRO_VERSION_CHECK(major,minor,patch) (0) #endif -#if defined(NLOHMANN_JSON_HEDLEY_EMSCRIPTEN_VERSION) - #undef NLOHMANN_JSON_HEDLEY_EMSCRIPTEN_VERSION +#if defined(JSON_HEDLEY_EMSCRIPTEN_VERSION) + #undef JSON_HEDLEY_EMSCRIPTEN_VERSION #endif #if defined(__EMSCRIPTEN__) - #define NLOHMANN_JSON_HEDLEY_EMSCRIPTEN_VERSION NLOHMANN_JSON_HEDLEY_VERSION_ENCODE(__EMSCRIPTEN_major__, __EMSCRIPTEN_minor__, __EMSCRIPTEN_tiny__) + #define JSON_HEDLEY_EMSCRIPTEN_VERSION JSON_HEDLEY_VERSION_ENCODE(__EMSCRIPTEN_major__, __EMSCRIPTEN_minor__, __EMSCRIPTEN_tiny__) #endif -#if defined(NLOHMANN_JSON_HEDLEY_EMSCRIPTEN_VERSION_CHECK) - #undef NLOHMANN_JSON_HEDLEY_EMSCRIPTEN_VERSION_CHECK +#if defined(JSON_HEDLEY_EMSCRIPTEN_VERSION_CHECK) + #undef JSON_HEDLEY_EMSCRIPTEN_VERSION_CHECK #endif -#if defined(NLOHMANN_JSON_HEDLEY_EMSCRIPTEN_VERSION) - #define NLOHMANN_JSON_HEDLEY_EMSCRIPTEN_VERSION_CHECK(major,minor,patch) (NLOHMANN_JSON_HEDLEY_EMSCRIPTEN_VERSION >= NLOHMANN_JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) +#if defined(JSON_HEDLEY_EMSCRIPTEN_VERSION) + #define JSON_HEDLEY_EMSCRIPTEN_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_EMSCRIPTEN_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) #else - #define NLOHMANN_JSON_HEDLEY_EMSCRIPTEN_VERSION_CHECK(major,minor,patch) (0) + #define JSON_HEDLEY_EMSCRIPTEN_VERSION_CHECK(major,minor,patch) (0) #endif -#if defined(NLOHMANN_JSON_HEDLEY_ARM_VERSION) - #undef NLOHMANN_JSON_HEDLEY_ARM_VERSION +#if defined(JSON_HEDLEY_ARM_VERSION) + #undef JSON_HEDLEY_ARM_VERSION #endif #if defined(__CC_ARM) && defined(__ARMCOMPILER_VERSION) - #define NLOHMANN_JSON_HEDLEY_ARM_VERSION NLOHMANN_JSON_HEDLEY_VERSION_ENCODE(__ARMCOMPILER_VERSION / 1000000, (__ARMCOMPILER_VERSION % 1000000) / 10000, (__ARMCOMPILER_VERSION % 10000) / 100) + #define JSON_HEDLEY_ARM_VERSION JSON_HEDLEY_VERSION_ENCODE(__ARMCOMPILER_VERSION / 1000000, (__ARMCOMPILER_VERSION % 1000000) / 10000, (__ARMCOMPILER_VERSION % 10000) / 100) #elif defined(__CC_ARM) && defined(__ARMCC_VERSION) - #define NLOHMANN_JSON_HEDLEY_ARM_VERSION NLOHMANN_JSON_HEDLEY_VERSION_ENCODE(__ARMCC_VERSION / 1000000, (__ARMCC_VERSION % 1000000) / 10000, (__ARMCC_VERSION % 10000) / 100) + #define JSON_HEDLEY_ARM_VERSION JSON_HEDLEY_VERSION_ENCODE(__ARMCC_VERSION / 1000000, (__ARMCC_VERSION % 1000000) / 10000, (__ARMCC_VERSION % 10000) / 100) #endif -#if defined(NLOHMANN_JSON_HEDLEY_ARM_VERSION_CHECK) - #undef NLOHMANN_JSON_HEDLEY_ARM_VERSION_CHECK +#if defined(JSON_HEDLEY_ARM_VERSION_CHECK) + #undef JSON_HEDLEY_ARM_VERSION_CHECK #endif -#if defined(NLOHMANN_JSON_HEDLEY_ARM_VERSION) - #define NLOHMANN_JSON_HEDLEY_ARM_VERSION_CHECK(major,minor,patch) (NLOHMANN_JSON_HEDLEY_ARM_VERSION >= NLOHMANN_JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) +#if defined(JSON_HEDLEY_ARM_VERSION) + #define JSON_HEDLEY_ARM_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_ARM_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) #else - #define NLOHMANN_JSON_HEDLEY_ARM_VERSION_CHECK(major,minor,patch) (0) + #define JSON_HEDLEY_ARM_VERSION_CHECK(major,minor,patch) (0) #endif -#if defined(NLOHMANN_JSON_HEDLEY_IBM_VERSION) - #undef NLOHMANN_JSON_HEDLEY_IBM_VERSION +#if defined(JSON_HEDLEY_IBM_VERSION) + #undef JSON_HEDLEY_IBM_VERSION #endif #if defined(__ibmxl__) - #define NLOHMANN_JSON_HEDLEY_IBM_VERSION NLOHMANN_JSON_HEDLEY_VERSION_ENCODE(__ibmxl_version__, __ibmxl_release__, __ibmxl_modification__) + #define JSON_HEDLEY_IBM_VERSION JSON_HEDLEY_VERSION_ENCODE(__ibmxl_version__, __ibmxl_release__, __ibmxl_modification__) #elif defined(__xlC__) && defined(__xlC_ver__) - #define NLOHMANN_JSON_HEDLEY_IBM_VERSION NLOHMANN_JSON_HEDLEY_VERSION_ENCODE(__xlC__ >> 8, __xlC__ & 0xff, (__xlC_ver__ >> 8) & 0xff) + #define JSON_HEDLEY_IBM_VERSION JSON_HEDLEY_VERSION_ENCODE(__xlC__ >> 8, __xlC__ & 0xff, (__xlC_ver__ >> 8) & 0xff) #elif defined(__xlC__) - #define NLOHMANN_JSON_HEDLEY_IBM_VERSION NLOHMANN_JSON_HEDLEY_VERSION_ENCODE(__xlC__ >> 8, __xlC__ & 0xff, 0) + #define JSON_HEDLEY_IBM_VERSION JSON_HEDLEY_VERSION_ENCODE(__xlC__ >> 8, __xlC__ & 0xff, 0) #endif -#if defined(NLOHMANN_JSON_HEDLEY_IBM_VERSION_CHECK) - #undef NLOHMANN_JSON_HEDLEY_IBM_VERSION_CHECK +#if defined(JSON_HEDLEY_IBM_VERSION_CHECK) + #undef JSON_HEDLEY_IBM_VERSION_CHECK #endif -#if defined(NLOHMANN_JSON_HEDLEY_IBM_VERSION) - #define NLOHMANN_JSON_HEDLEY_IBM_VERSION_CHECK(major,minor,patch) (NLOHMANN_JSON_HEDLEY_IBM_VERSION >= NLOHMANN_JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) +#if defined(JSON_HEDLEY_IBM_VERSION) + #define JSON_HEDLEY_IBM_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_IBM_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) #else - #define NLOHMANN_JSON_HEDLEY_IBM_VERSION_CHECK(major,minor,patch) (0) + #define JSON_HEDLEY_IBM_VERSION_CHECK(major,minor,patch) (0) #endif -#if defined(NLOHMANN_JSON_HEDLEY_TI_VERSION) - #undef NLOHMANN_JSON_HEDLEY_TI_VERSION +#if defined(JSON_HEDLEY_TI_VERSION) + #undef JSON_HEDLEY_TI_VERSION #endif #if defined(__TI_COMPILER_VERSION__) - #define NLOHMANN_JSON_HEDLEY_TI_VERSION NLOHMANN_JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000)) + #define JSON_HEDLEY_TI_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000)) #endif -#if defined(NLOHMANN_JSON_HEDLEY_TI_VERSION_CHECK) - #undef NLOHMANN_JSON_HEDLEY_TI_VERSION_CHECK +#if defined(JSON_HEDLEY_TI_VERSION_CHECK) + #undef JSON_HEDLEY_TI_VERSION_CHECK #endif -#if defined(NLOHMANN_JSON_HEDLEY_TI_VERSION) - #define NLOHMANN_JSON_HEDLEY_TI_VERSION_CHECK(major,minor,patch) (NLOHMANN_JSON_HEDLEY_TI_VERSION >= NLOHMANN_JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) +#if defined(JSON_HEDLEY_TI_VERSION) + #define JSON_HEDLEY_TI_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TI_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) #else - #define NLOHMANN_JSON_HEDLEY_TI_VERSION_CHECK(major,minor,patch) (0) + #define JSON_HEDLEY_TI_VERSION_CHECK(major,minor,patch) (0) #endif -#if defined(NLOHMANN_JSON_HEDLEY_CRAY_VERSION) - #undef NLOHMANN_JSON_HEDLEY_CRAY_VERSION +#if defined(JSON_HEDLEY_CRAY_VERSION) + #undef JSON_HEDLEY_CRAY_VERSION #endif #if defined(_CRAYC) #if defined(_RELEASE_PATCHLEVEL) - #define NLOHMANN_JSON_HEDLEY_CRAY_VERSION NLOHMANN_JSON_HEDLEY_VERSION_ENCODE(_RELEASE_MAJOR, _RELEASE_MINOR, _RELEASE_PATCHLEVEL) + #define JSON_HEDLEY_CRAY_VERSION JSON_HEDLEY_VERSION_ENCODE(_RELEASE_MAJOR, _RELEASE_MINOR, _RELEASE_PATCHLEVEL) #else - #define NLOHMANN_JSON_HEDLEY_CRAY_VERSION NLOHMANN_JSON_HEDLEY_VERSION_ENCODE(_RELEASE_MAJOR, _RELEASE_MINOR, 0) + #define JSON_HEDLEY_CRAY_VERSION JSON_HEDLEY_VERSION_ENCODE(_RELEASE_MAJOR, _RELEASE_MINOR, 0) #endif #endif -#if defined(NLOHMANN_JSON_HEDLEY_CRAY_VERSION_CHECK) - #undef NLOHMANN_JSON_HEDLEY_CRAY_VERSION_CHECK +#if defined(JSON_HEDLEY_CRAY_VERSION_CHECK) + #undef JSON_HEDLEY_CRAY_VERSION_CHECK #endif -#if defined(NLOHMANN_JSON_HEDLEY_CRAY_VERSION) - #define NLOHMANN_JSON_HEDLEY_CRAY_VERSION_CHECK(major,minor,patch) (NLOHMANN_JSON_HEDLEY_CRAY_VERSION >= NLOHMANN_JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) +#if defined(JSON_HEDLEY_CRAY_VERSION) + #define JSON_HEDLEY_CRAY_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_CRAY_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) #else - #define NLOHMANN_JSON_HEDLEY_CRAY_VERSION_CHECK(major,minor,patch) (0) + #define JSON_HEDLEY_CRAY_VERSION_CHECK(major,minor,patch) (0) #endif -#if defined(NLOHMANN_JSON_HEDLEY_IAR_VERSION) - #undef NLOHMANN_JSON_HEDLEY_IAR_VERSION +#if defined(JSON_HEDLEY_IAR_VERSION) + #undef JSON_HEDLEY_IAR_VERSION #endif #if defined(__IAR_SYSTEMS_ICC__) #if __VER__ > 1000 - #define NLOHMANN_JSON_HEDLEY_IAR_VERSION NLOHMANN_JSON_HEDLEY_VERSION_ENCODE((__VER__ / 1000000), ((__VER__ / 1000) % 1000), (__VER__ % 1000)) + #define JSON_HEDLEY_IAR_VERSION JSON_HEDLEY_VERSION_ENCODE((__VER__ / 1000000), ((__VER__ / 1000) % 1000), (__VER__ % 1000)) #else - #define NLOHMANN_JSON_HEDLEY_IAR_VERSION NLOHMANN_JSON_HEDLEY_VERSION_ENCODE(VER / 100, __VER__ % 100, 0) + #define JSON_HEDLEY_IAR_VERSION JSON_HEDLEY_VERSION_ENCODE(VER / 100, __VER__ % 100, 0) #endif #endif -#if defined(NLOHMANN_JSON_HEDLEY_IAR_VERSION_CHECK) - #undef NLOHMANN_JSON_HEDLEY_IAR_VERSION_CHECK +#if defined(JSON_HEDLEY_IAR_VERSION_CHECK) + #undef JSON_HEDLEY_IAR_VERSION_CHECK #endif -#if defined(NLOHMANN_JSON_HEDLEY_IAR_VERSION) - #define NLOHMANN_JSON_HEDLEY_IAR_VERSION_CHECK(major,minor,patch) (NLOHMANN_JSON_HEDLEY_IAR_VERSION >= NLOHMANN_JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) +#if defined(JSON_HEDLEY_IAR_VERSION) + #define JSON_HEDLEY_IAR_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_IAR_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) #else - #define NLOHMANN_JSON_HEDLEY_IAR_VERSION_CHECK(major,minor,patch) (0) + #define JSON_HEDLEY_IAR_VERSION_CHECK(major,minor,patch) (0) #endif -#if defined(NLOHMANN_JSON_HEDLEY_TINYC_VERSION) - #undef NLOHMANN_JSON_HEDLEY_TINYC_VERSION +#if defined(JSON_HEDLEY_TINYC_VERSION) + #undef JSON_HEDLEY_TINYC_VERSION #endif #if defined(__TINYC__) - #define NLOHMANN_JSON_HEDLEY_TINYC_VERSION NLOHMANN_JSON_HEDLEY_VERSION_ENCODE(__TINYC__ / 1000, (__TINYC__ / 100) % 10, __TINYC__ % 100) + #define JSON_HEDLEY_TINYC_VERSION JSON_HEDLEY_VERSION_ENCODE(__TINYC__ / 1000, (__TINYC__ / 100) % 10, __TINYC__ % 100) #endif -#if defined(NLOHMANN_JSON_HEDLEY_TINYC_VERSION_CHECK) - #undef NLOHMANN_JSON_HEDLEY_TINYC_VERSION_CHECK +#if defined(JSON_HEDLEY_TINYC_VERSION_CHECK) + #undef JSON_HEDLEY_TINYC_VERSION_CHECK #endif -#if defined(NLOHMANN_JSON_HEDLEY_TINYC_VERSION) - #define NLOHMANN_JSON_HEDLEY_TINYC_VERSION_CHECK(major,minor,patch) (NLOHMANN_JSON_HEDLEY_TINYC_VERSION >= NLOHMANN_JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) +#if defined(JSON_HEDLEY_TINYC_VERSION) + #define JSON_HEDLEY_TINYC_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TINYC_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) #else - #define NLOHMANN_JSON_HEDLEY_TINYC_VERSION_CHECK(major,minor,patch) (0) + #define JSON_HEDLEY_TINYC_VERSION_CHECK(major,minor,patch) (0) #endif -#if defined(NLOHMANN_JSON_HEDLEY_DMC_VERSION) - #undef NLOHMANN_JSON_HEDLEY_DMC_VERSION +#if defined(JSON_HEDLEY_DMC_VERSION) + #undef JSON_HEDLEY_DMC_VERSION #endif #if defined(__DMC__) - #define NLOHMANN_JSON_HEDLEY_DMC_VERSION NLOHMANN_JSON_HEDLEY_VERSION_ENCODE(__DMC__ >> 8, (__DMC__ >> 4) & 0xf, __DMC__ & 0xf) + #define JSON_HEDLEY_DMC_VERSION JSON_HEDLEY_VERSION_ENCODE(__DMC__ >> 8, (__DMC__ >> 4) & 0xf, __DMC__ & 0xf) #endif -#if defined(NLOHMANN_JSON_HEDLEY_DMC_VERSION_CHECK) - #undef NLOHMANN_JSON_HEDLEY_DMC_VERSION_CHECK +#if defined(JSON_HEDLEY_DMC_VERSION_CHECK) + #undef JSON_HEDLEY_DMC_VERSION_CHECK #endif -#if defined(NLOHMANN_JSON_HEDLEY_DMC_VERSION) - #define NLOHMANN_JSON_HEDLEY_DMC_VERSION_CHECK(major,minor,patch) (NLOHMANN_JSON_HEDLEY_DMC_VERSION >= NLOHMANN_JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) +#if defined(JSON_HEDLEY_DMC_VERSION) + #define JSON_HEDLEY_DMC_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_DMC_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) #else - #define NLOHMANN_JSON_HEDLEY_DMC_VERSION_CHECK(major,minor,patch) (0) + #define JSON_HEDLEY_DMC_VERSION_CHECK(major,minor,patch) (0) #endif -#if defined(NLOHMANN_JSON_HEDLEY_COMPCERT_VERSION) - #undef NLOHMANN_JSON_HEDLEY_COMPCERT_VERSION +#if defined(JSON_HEDLEY_COMPCERT_VERSION) + #undef JSON_HEDLEY_COMPCERT_VERSION #endif #if defined(__COMPCERT_VERSION__) - #define NLOHMANN_JSON_HEDLEY_COMPCERT_VERSION NLOHMANN_JSON_HEDLEY_VERSION_ENCODE(__COMPCERT_VERSION__ / 10000, (__COMPCERT_VERSION__ / 100) % 100, __COMPCERT_VERSION__ % 100) + #define JSON_HEDLEY_COMPCERT_VERSION JSON_HEDLEY_VERSION_ENCODE(__COMPCERT_VERSION__ / 10000, (__COMPCERT_VERSION__ / 100) % 100, __COMPCERT_VERSION__ % 100) #endif -#if defined(NLOHMANN_JSON_HEDLEY_COMPCERT_VERSION_CHECK) - #undef NLOHMANN_JSON_HEDLEY_COMPCERT_VERSION_CHECK +#if defined(JSON_HEDLEY_COMPCERT_VERSION_CHECK) + #undef JSON_HEDLEY_COMPCERT_VERSION_CHECK #endif -#if defined(NLOHMANN_JSON_HEDLEY_COMPCERT_VERSION) - #define NLOHMANN_JSON_HEDLEY_COMPCERT_VERSION_CHECK(major,minor,patch) (NLOHMANN_JSON_HEDLEY_COMPCERT_VERSION >= NLOHMANN_JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) +#if defined(JSON_HEDLEY_COMPCERT_VERSION) + #define JSON_HEDLEY_COMPCERT_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_COMPCERT_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) #else - #define NLOHMANN_JSON_HEDLEY_COMPCERT_VERSION_CHECK(major,minor,patch) (0) + #define JSON_HEDLEY_COMPCERT_VERSION_CHECK(major,minor,patch) (0) #endif -#if defined(NLOHMANN_JSON_HEDLEY_PELLES_VERSION) - #undef NLOHMANN_JSON_HEDLEY_PELLES_VERSION +#if defined(JSON_HEDLEY_PELLES_VERSION) + #undef JSON_HEDLEY_PELLES_VERSION #endif #if defined(__POCC__) - #define NLOHMANN_JSON_HEDLEY_PELLES_VERSION NLOHMANN_JSON_HEDLEY_VERSION_ENCODE(__POCC__ / 100, __POCC__ % 100, 0) + #define JSON_HEDLEY_PELLES_VERSION JSON_HEDLEY_VERSION_ENCODE(__POCC__ / 100, __POCC__ % 100, 0) #endif -#if defined(NLOHMANN_JSON_HEDLEY_PELLES_VERSION_CHECK) - #undef NLOHMANN_JSON_HEDLEY_PELLES_VERSION_CHECK +#if defined(JSON_HEDLEY_PELLES_VERSION_CHECK) + #undef JSON_HEDLEY_PELLES_VERSION_CHECK #endif -#if defined(NLOHMANN_JSON_HEDLEY_PELLES_VERSION) - #define NLOHMANN_JSON_HEDLEY_PELLES_VERSION_CHECK(major,minor,patch) (NLOHMANN_JSON_HEDLEY_PELLES_VERSION >= NLOHMANN_JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) +#if defined(JSON_HEDLEY_PELLES_VERSION) + #define JSON_HEDLEY_PELLES_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_PELLES_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) #else - #define NLOHMANN_JSON_HEDLEY_PELLES_VERSION_CHECK(major,minor,patch) (0) + #define JSON_HEDLEY_PELLES_VERSION_CHECK(major,minor,patch) (0) #endif -#if defined(NLOHMANN_JSON_HEDLEY_GCC_VERSION) - #undef NLOHMANN_JSON_HEDLEY_GCC_VERSION +#if defined(JSON_HEDLEY_GCC_VERSION) + #undef JSON_HEDLEY_GCC_VERSION #endif #if \ - defined(NLOHMANN_JSON_HEDLEY_GNUC_VERSION) && \ + defined(JSON_HEDLEY_GNUC_VERSION) && \ !defined(__clang__) && \ - !defined(NLOHMANN_JSON_HEDLEY_INTEL_VERSION) && \ - !defined(NLOHMANN_JSON_HEDLEY_PGI_VERSION) && \ - !defined(NLOHMANN_JSON_HEDLEY_ARM_VERSION) && \ - !defined(NLOHMANN_JSON_HEDLEY_TI_VERSION) && \ + !defined(JSON_HEDLEY_INTEL_VERSION) && \ + !defined(JSON_HEDLEY_PGI_VERSION) && \ + !defined(JSON_HEDLEY_ARM_VERSION) && \ + !defined(JSON_HEDLEY_TI_VERSION) && \ !defined(__COMPCERT__) - #define NLOHMANN_JSON_HEDLEY_GCC_VERSION NLOHMANN_JSON_HEDLEY_GNUC_VERSION + #define JSON_HEDLEY_GCC_VERSION JSON_HEDLEY_GNUC_VERSION #endif -#if defined(NLOHMANN_JSON_HEDLEY_GCC_VERSION_CHECK) - #undef NLOHMANN_JSON_HEDLEY_GCC_VERSION_CHECK +#if defined(JSON_HEDLEY_GCC_VERSION_CHECK) + #undef JSON_HEDLEY_GCC_VERSION_CHECK #endif -#if defined(NLOHMANN_JSON_HEDLEY_GCC_VERSION) - #define NLOHMANN_JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch) (NLOHMANN_JSON_HEDLEY_GCC_VERSION >= NLOHMANN_JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) +#if defined(JSON_HEDLEY_GCC_VERSION) + #define JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_GCC_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) #else - #define NLOHMANN_JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch) (0) + #define JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch) (0) #endif -#if defined(NLOHMANN_JSON_HEDLEY_HAS_ATTRIBUTE) - #undef NLOHMANN_JSON_HEDLEY_HAS_ATTRIBUTE +#if defined(JSON_HEDLEY_HAS_ATTRIBUTE) + #undef JSON_HEDLEY_HAS_ATTRIBUTE #endif #if defined(__has_attribute) - #define NLOHMANN_JSON_HEDLEY_HAS_ATTRIBUTE(attribute) __has_attribute(attribute) + #define JSON_HEDLEY_HAS_ATTRIBUTE(attribute) __has_attribute(attribute) #else - #define NLOHMANN_JSON_HEDLEY_HAS_ATTRIBUTE(attribute) (0) + #define JSON_HEDLEY_HAS_ATTRIBUTE(attribute) (0) #endif -#if defined(NLOHMANN_JSON_HEDLEY_GNUC_HAS_ATTRIBUTE) - #undef NLOHMANN_JSON_HEDLEY_GNUC_HAS_ATTRIBUTE +#if defined(JSON_HEDLEY_GNUC_HAS_ATTRIBUTE) + #undef JSON_HEDLEY_GNUC_HAS_ATTRIBUTE #endif #if defined(__has_attribute) - #define NLOHMANN_JSON_HEDLEY_GNUC_HAS_ATTRIBUTE(attribute,major,minor,patch) __has_attribute(attribute) + #define JSON_HEDLEY_GNUC_HAS_ATTRIBUTE(attribute,major,minor,patch) __has_attribute(attribute) #else - #define NLOHMANN_JSON_HEDLEY_GNUC_HAS_ATTRIBUTE(attribute,major,minor,patch) NLOHMANN_JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch) + #define JSON_HEDLEY_GNUC_HAS_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch) #endif -#if defined(NLOHMANN_JSON_HEDLEY_GCC_HAS_ATTRIBUTE) - #undef NLOHMANN_JSON_HEDLEY_GCC_HAS_ATTRIBUTE +#if defined(JSON_HEDLEY_GCC_HAS_ATTRIBUTE) + #undef JSON_HEDLEY_GCC_HAS_ATTRIBUTE #endif #if defined(__has_attribute) - #define NLOHMANN_JSON_HEDLEY_GCC_HAS_ATTRIBUTE(attribute,major,minor,patch) __has_attribute(attribute) + #define JSON_HEDLEY_GCC_HAS_ATTRIBUTE(attribute,major,minor,patch) __has_attribute(attribute) #else - #define NLOHMANN_JSON_HEDLEY_GCC_HAS_ATTRIBUTE(attribute,major,minor,patch) NLOHMANN_JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch) + #define JSON_HEDLEY_GCC_HAS_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch) #endif -#if defined(NLOHMANN_JSON_HEDLEY_HAS_CPP_ATTRIBUTE) - #undef NLOHMANN_JSON_HEDLEY_HAS_CPP_ATTRIBUTE +#if defined(JSON_HEDLEY_HAS_CPP_ATTRIBUTE) + #undef JSON_HEDLEY_HAS_CPP_ATTRIBUTE #endif #if defined(__has_cpp_attribute) && defined(__cplusplus) - #define NLOHMANN_JSON_HEDLEY_HAS_CPP_ATTRIBUTE(attribute) __has_cpp_attribute(attribute) + #define JSON_HEDLEY_HAS_CPP_ATTRIBUTE(attribute) __has_cpp_attribute(attribute) #else - #define NLOHMANN_JSON_HEDLEY_HAS_CPP_ATTRIBUTE(attribute) (0) + #define JSON_HEDLEY_HAS_CPP_ATTRIBUTE(attribute) (0) #endif -#if defined(NLOHMANN_JSON_HEDLEY_GNUC_HAS_CPP_ATTRIBUTE) - #undef NLOHMANN_JSON_HEDLEY_GNUC_HAS_CPP_ATTRIBUTE +#if defined(JSON_HEDLEY_GNUC_HAS_CPP_ATTRIBUTE) + #undef JSON_HEDLEY_GNUC_HAS_CPP_ATTRIBUTE #endif #if defined(__has_cpp_attribute) && defined(__cplusplus) - #define NLOHMANN_JSON_HEDLEY_GNUC_HAS_CPP_ATTRIBUTE(attribute,major,minor,patch) __has_cpp_attribute(attribute) + #define JSON_HEDLEY_GNUC_HAS_CPP_ATTRIBUTE(attribute,major,minor,patch) __has_cpp_attribute(attribute) #else - #define NLOHMANN_JSON_HEDLEY_GNUC_HAS_CPP_ATTRIBUTE(attribute,major,minor,patch) NLOHMANN_JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch) + #define JSON_HEDLEY_GNUC_HAS_CPP_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch) #endif -#if defined(NLOHMANN_JSON_HEDLEY_GCC_HAS_CPP_ATTRIBUTE) - #undef NLOHMANN_JSON_HEDLEY_GCC_HAS_CPP_ATTRIBUTE +#if defined(JSON_HEDLEY_GCC_HAS_CPP_ATTRIBUTE) + #undef JSON_HEDLEY_GCC_HAS_CPP_ATTRIBUTE #endif #if defined(__has_cpp_attribute) && defined(__cplusplus) - #define NLOHMANN_JSON_HEDLEY_GCC_HAS_CPP_ATTRIBUTE(attribute,major,minor,patch) __has_cpp_attribute(attribute) + #define JSON_HEDLEY_GCC_HAS_CPP_ATTRIBUTE(attribute,major,minor,patch) __has_cpp_attribute(attribute) #else - #define NLOHMANN_JSON_HEDLEY_GCC_HAS_CPP_ATTRIBUTE(attribute,major,minor,patch) NLOHMANN_JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch) + #define JSON_HEDLEY_GCC_HAS_CPP_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch) #endif -#if defined(NLOHMANN_JSON_HEDLEY_HAS_BUILTIN) - #undef NLOHMANN_JSON_HEDLEY_HAS_BUILTIN +#if defined(JSON_HEDLEY_HAS_BUILTIN) + #undef JSON_HEDLEY_HAS_BUILTIN #endif #if defined(__has_builtin) - #define NLOHMANN_JSON_HEDLEY_HAS_BUILTIN(builtin) __has_builtin(builtin) + #define JSON_HEDLEY_HAS_BUILTIN(builtin) __has_builtin(builtin) #else - #define NLOHMANN_JSON_HEDLEY_HAS_BUILTIN(builtin) (0) + #define JSON_HEDLEY_HAS_BUILTIN(builtin) (0) #endif -#if defined(NLOHMANN_JSON_HEDLEY_GNUC_HAS_BUILTIN) - #undef NLOHMANN_JSON_HEDLEY_GNUC_HAS_BUILTIN +#if defined(JSON_HEDLEY_GNUC_HAS_BUILTIN) + #undef JSON_HEDLEY_GNUC_HAS_BUILTIN #endif #if defined(__has_builtin) - #define NLOHMANN_JSON_HEDLEY_GNUC_HAS_BUILTIN(builtin,major,minor,patch) __has_builtin(builtin) + #define JSON_HEDLEY_GNUC_HAS_BUILTIN(builtin,major,minor,patch) __has_builtin(builtin) #else - #define NLOHMANN_JSON_HEDLEY_GNUC_HAS_BUILTIN(builtin,major,minor,patch) NLOHMANN_JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch) + #define JSON_HEDLEY_GNUC_HAS_BUILTIN(builtin,major,minor,patch) JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch) #endif -#if defined(NLOHMANN_JSON_HEDLEY_GCC_HAS_BUILTIN) - #undef NLOHMANN_JSON_HEDLEY_GCC_HAS_BUILTIN +#if defined(JSON_HEDLEY_GCC_HAS_BUILTIN) + #undef JSON_HEDLEY_GCC_HAS_BUILTIN #endif #if defined(__has_builtin) - #define NLOHMANN_JSON_HEDLEY_GCC_HAS_BUILTIN(builtin,major,minor,patch) __has_builtin(builtin) + #define JSON_HEDLEY_GCC_HAS_BUILTIN(builtin,major,minor,patch) __has_builtin(builtin) #else - #define NLOHMANN_JSON_HEDLEY_GCC_HAS_BUILTIN(builtin,major,minor,patch) NLOHMANN_JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch) + #define JSON_HEDLEY_GCC_HAS_BUILTIN(builtin,major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch) #endif -#if defined(NLOHMANN_JSON_HEDLEY_HAS_FEATURE) - #undef NLOHMANN_JSON_HEDLEY_HAS_FEATURE +#if defined(JSON_HEDLEY_HAS_FEATURE) + #undef JSON_HEDLEY_HAS_FEATURE #endif #if defined(__has_feature) - #define NLOHMANN_JSON_HEDLEY_HAS_FEATURE(feature) __has_feature(feature) + #define JSON_HEDLEY_HAS_FEATURE(feature) __has_feature(feature) #else - #define NLOHMANN_JSON_HEDLEY_HAS_FEATURE(feature) (0) + #define JSON_HEDLEY_HAS_FEATURE(feature) (0) #endif -#if defined(NLOHMANN_JSON_HEDLEY_GNUC_HAS_FEATURE) - #undef NLOHMANN_JSON_HEDLEY_GNUC_HAS_FEATURE +#if defined(JSON_HEDLEY_GNUC_HAS_FEATURE) + #undef JSON_HEDLEY_GNUC_HAS_FEATURE #endif #if defined(__has_feature) - #define NLOHMANN_JSON_HEDLEY_GNUC_HAS_FEATURE(feature,major,minor,patch) __has_feature(feature) + #define JSON_HEDLEY_GNUC_HAS_FEATURE(feature,major,minor,patch) __has_feature(feature) #else - #define NLOHMANN_JSON_HEDLEY_GNUC_HAS_FEATURE(feature,major,minor,patch) NLOHMANN_JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch) + #define JSON_HEDLEY_GNUC_HAS_FEATURE(feature,major,minor,patch) JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch) #endif -#if defined(NLOHMANN_JSON_HEDLEY_GCC_HAS_FEATURE) - #undef NLOHMANN_JSON_HEDLEY_GCC_HAS_FEATURE +#if defined(JSON_HEDLEY_GCC_HAS_FEATURE) + #undef JSON_HEDLEY_GCC_HAS_FEATURE #endif #if defined(__has_feature) - #define NLOHMANN_JSON_HEDLEY_GCC_HAS_FEATURE(feature,major,minor,patch) __has_feature(feature) + #define JSON_HEDLEY_GCC_HAS_FEATURE(feature,major,minor,patch) __has_feature(feature) #else - #define NLOHMANN_JSON_HEDLEY_GCC_HAS_FEATURE(feature,major,minor,patch) NLOHMANN_JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch) + #define JSON_HEDLEY_GCC_HAS_FEATURE(feature,major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch) #endif -#if defined(NLOHMANN_JSON_HEDLEY_HAS_EXTENSION) - #undef NLOHMANN_JSON_HEDLEY_HAS_EXTENSION +#if defined(JSON_HEDLEY_HAS_EXTENSION) + #undef JSON_HEDLEY_HAS_EXTENSION #endif #if defined(__has_extension) - #define NLOHMANN_JSON_HEDLEY_HAS_EXTENSION(extension) __has_extension(extension) + #define JSON_HEDLEY_HAS_EXTENSION(extension) __has_extension(extension) #else - #define NLOHMANN_JSON_HEDLEY_HAS_EXTENSION(extension) (0) + #define JSON_HEDLEY_HAS_EXTENSION(extension) (0) #endif -#if defined(NLOHMANN_JSON_HEDLEY_GNUC_HAS_EXTENSION) - #undef NLOHMANN_JSON_HEDLEY_GNUC_HAS_EXTENSION +#if defined(JSON_HEDLEY_GNUC_HAS_EXTENSION) + #undef JSON_HEDLEY_GNUC_HAS_EXTENSION #endif #if defined(__has_extension) - #define NLOHMANN_JSON_HEDLEY_GNUC_HAS_EXTENSION(extension,major,minor,patch) __has_extension(extension) + #define JSON_HEDLEY_GNUC_HAS_EXTENSION(extension,major,minor,patch) __has_extension(extension) #else - #define NLOHMANN_JSON_HEDLEY_GNUC_HAS_EXTENSION(extension,major,minor,patch) NLOHMANN_JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch) + #define JSON_HEDLEY_GNUC_HAS_EXTENSION(extension,major,minor,patch) JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch) #endif -#if defined(NLOHMANN_JSON_HEDLEY_GCC_HAS_EXTENSION) - #undef NLOHMANN_JSON_HEDLEY_GCC_HAS_EXTENSION +#if defined(JSON_HEDLEY_GCC_HAS_EXTENSION) + #undef JSON_HEDLEY_GCC_HAS_EXTENSION #endif #if defined(__has_extension) - #define NLOHMANN_JSON_HEDLEY_GCC_HAS_EXTENSION(extension,major,minor,patch) __has_extension(extension) + #define JSON_HEDLEY_GCC_HAS_EXTENSION(extension,major,minor,patch) __has_extension(extension) #else - #define NLOHMANN_JSON_HEDLEY_GCC_HAS_EXTENSION(extension,major,minor,patch) NLOHMANN_JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch) + #define JSON_HEDLEY_GCC_HAS_EXTENSION(extension,major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch) #endif -#if defined(NLOHMANN_JSON_HEDLEY_HAS_DECLSPEC_ATTRIBUTE) - #undef NLOHMANN_JSON_HEDLEY_HAS_DECLSPEC_ATTRIBUTE +#if defined(JSON_HEDLEY_HAS_DECLSPEC_ATTRIBUTE) + #undef JSON_HEDLEY_HAS_DECLSPEC_ATTRIBUTE #endif #if defined(__has_declspec_attribute) - #define NLOHMANN_JSON_HEDLEY_HAS_DECLSPEC_ATTRIBUTE(attribute) __has_declspec_attribute(attribute) + #define JSON_HEDLEY_HAS_DECLSPEC_ATTRIBUTE(attribute) __has_declspec_attribute(attribute) #else - #define NLOHMANN_JSON_HEDLEY_HAS_DECLSPEC_ATTRIBUTE(attribute) (0) + #define JSON_HEDLEY_HAS_DECLSPEC_ATTRIBUTE(attribute) (0) #endif -#if defined(NLOHMANN_JSON_HEDLEY_GNUC_HAS_DECLSPEC_ATTRIBUTE) - #undef NLOHMANN_JSON_HEDLEY_GNUC_HAS_DECLSPEC_ATTRIBUTE +#if defined(JSON_HEDLEY_GNUC_HAS_DECLSPEC_ATTRIBUTE) + #undef JSON_HEDLEY_GNUC_HAS_DECLSPEC_ATTRIBUTE #endif #if defined(__has_declspec_attribute) - #define NLOHMANN_JSON_HEDLEY_GNUC_HAS_DECLSPEC_ATTRIBUTE(attribute,major,minor,patch) __has_declspec_attribute(attribute) + #define JSON_HEDLEY_GNUC_HAS_DECLSPEC_ATTRIBUTE(attribute,major,minor,patch) __has_declspec_attribute(attribute) #else - #define NLOHMANN_JSON_HEDLEY_GNUC_HAS_DECLSPEC_ATTRIBUTE(attribute,major,minor,patch) NLOHMANN_JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch) + #define JSON_HEDLEY_GNUC_HAS_DECLSPEC_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch) #endif -#if defined(NLOHMANN_JSON_HEDLEY_GCC_HAS_DECLSPEC_ATTRIBUTE) - #undef NLOHMANN_JSON_HEDLEY_GCC_HAS_DECLSPEC_ATTRIBUTE +#if defined(JSON_HEDLEY_GCC_HAS_DECLSPEC_ATTRIBUTE) + #undef JSON_HEDLEY_GCC_HAS_DECLSPEC_ATTRIBUTE #endif #if defined(__has_declspec_attribute) - #define NLOHMANN_JSON_HEDLEY_GCC_HAS_DECLSPEC_ATTRIBUTE(attribute,major,minor,patch) __has_declspec_attribute(attribute) + #define JSON_HEDLEY_GCC_HAS_DECLSPEC_ATTRIBUTE(attribute,major,minor,patch) __has_declspec_attribute(attribute) #else - #define NLOHMANN_JSON_HEDLEY_GCC_HAS_DECLSPEC_ATTRIBUTE(attribute,major,minor,patch) NLOHMANN_JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch) + #define JSON_HEDLEY_GCC_HAS_DECLSPEC_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch) #endif -#if defined(NLOHMANN_JSON_HEDLEY_HAS_WARNING) - #undef NLOHMANN_JSON_HEDLEY_HAS_WARNING +#if defined(JSON_HEDLEY_HAS_WARNING) + #undef JSON_HEDLEY_HAS_WARNING #endif #if defined(__has_warning) - #define NLOHMANN_JSON_HEDLEY_HAS_WARNING(warning) __has_warning(warning) + #define JSON_HEDLEY_HAS_WARNING(warning) __has_warning(warning) #else - #define NLOHMANN_JSON_HEDLEY_HAS_WARNING(warning) (0) + #define JSON_HEDLEY_HAS_WARNING(warning) (0) #endif -#if defined(NLOHMANN_JSON_HEDLEY_GNUC_HAS_WARNING) - #undef NLOHMANN_JSON_HEDLEY_GNUC_HAS_WARNING +#if defined(JSON_HEDLEY_GNUC_HAS_WARNING) + #undef JSON_HEDLEY_GNUC_HAS_WARNING #endif #if defined(__has_warning) - #define NLOHMANN_JSON_HEDLEY_GNUC_HAS_WARNING(warning,major,minor,patch) __has_warning(warning) + #define JSON_HEDLEY_GNUC_HAS_WARNING(warning,major,minor,patch) __has_warning(warning) #else - #define NLOHMANN_JSON_HEDLEY_GNUC_HAS_WARNING(warning,major,minor,patch) NLOHMANN_JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch) + #define JSON_HEDLEY_GNUC_HAS_WARNING(warning,major,minor,patch) JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch) #endif -#if defined(NLOHMANN_JSON_HEDLEY_GCC_HAS_WARNING) - #undef NLOHMANN_JSON_HEDLEY_GCC_HAS_WARNING +#if defined(JSON_HEDLEY_GCC_HAS_WARNING) + #undef JSON_HEDLEY_GCC_HAS_WARNING #endif #if defined(__has_warning) - #define NLOHMANN_JSON_HEDLEY_GCC_HAS_WARNING(warning,major,minor,patch) __has_warning(warning) + #define JSON_HEDLEY_GCC_HAS_WARNING(warning,major,minor,patch) __has_warning(warning) #else - #define NLOHMANN_JSON_HEDLEY_GCC_HAS_WARNING(warning,major,minor,patch) NLOHMANN_JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch) + #define JSON_HEDLEY_GCC_HAS_WARNING(warning,major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch) #endif #if \ (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)) || \ defined(__clang__) || \ - NLOHMANN_JSON_HEDLEY_GCC_VERSION_CHECK(3,0,0) || \ - NLOHMANN_JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ - NLOHMANN_JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0) || \ - NLOHMANN_JSON_HEDLEY_PGI_VERSION_CHECK(18,4,0) || \ - NLOHMANN_JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ - NLOHMANN_JSON_HEDLEY_TI_VERSION_CHECK(6,0,0) || \ - NLOHMANN_JSON_HEDLEY_CRAY_VERSION_CHECK(5,0,0) || \ - NLOHMANN_JSON_HEDLEY_TINYC_VERSION_CHECK(0,9,17) || \ - NLOHMANN_JSON_HEDLEY_SUNPRO_VERSION_CHECK(8,0,0) || \ - (NLOHMANN_JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) && defined(__C99_PRAGMA_OPERATOR)) - #define NLOHMANN_JSON_HEDLEY_PRAGMA(value) _Pragma(#value) -#elif NLOHMANN_JSON_HEDLEY_MSVC_VERSION_CHECK(15,0,0) - #define NLOHMANN_JSON_HEDLEY_PRAGMA(value) __pragma(value) + JSON_HEDLEY_GCC_VERSION_CHECK(3,0,0) || \ + JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ + JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0) || \ + JSON_HEDLEY_PGI_VERSION_CHECK(18,4,0) || \ + JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ + JSON_HEDLEY_TI_VERSION_CHECK(6,0,0) || \ + JSON_HEDLEY_CRAY_VERSION_CHECK(5,0,0) || \ + JSON_HEDLEY_TINYC_VERSION_CHECK(0,9,17) || \ + JSON_HEDLEY_SUNPRO_VERSION_CHECK(8,0,0) || \ + (JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) && defined(__C99_PRAGMA_OPERATOR)) + #define JSON_HEDLEY_PRAGMA(value) _Pragma(#value) +#elif JSON_HEDLEY_MSVC_VERSION_CHECK(15,0,0) + #define JSON_HEDLEY_PRAGMA(value) __pragma(value) #else - #define NLOHMANN_JSON_HEDLEY_PRAGMA(value) + #define JSON_HEDLEY_PRAGMA(value) #endif -#if defined(NLOHMANN_JSON_HEDLEY_DIAGNOSTIC_PUSH) - #undef NLOHMANN_JSON_HEDLEY_DIAGNOSTIC_PUSH +#if defined(JSON_HEDLEY_DIAGNOSTIC_PUSH) + #undef JSON_HEDLEY_DIAGNOSTIC_PUSH #endif -#if defined(NLOHMANN_JSON_HEDLEY_DIAGNOSTIC_POP) - #undef NLOHMANN_JSON_HEDLEY_DIAGNOSTIC_POP +#if defined(JSON_HEDLEY_DIAGNOSTIC_POP) + #undef JSON_HEDLEY_DIAGNOSTIC_POP #endif #if defined(__clang__) - #define NLOHMANN_JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("clang diagnostic push") - #define NLOHMANN_JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("clang diagnostic pop") -#elif NLOHMANN_JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) - #define NLOHMANN_JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("warning(push)") - #define NLOHMANN_JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("warning(pop)") -#elif NLOHMANN_JSON_HEDLEY_GCC_VERSION_CHECK(4,6,0) - #define NLOHMANN_JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("GCC diagnostic push") - #define NLOHMANN_JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("GCC diagnostic pop") -#elif NLOHMANN_JSON_HEDLEY_MSVC_VERSION_CHECK(15,0,0) - #define NLOHMANN_JSON_HEDLEY_DIAGNOSTIC_PUSH __pragma(warning(push)) - #define NLOHMANN_JSON_HEDLEY_DIAGNOSTIC_POP __pragma(warning(pop)) -#elif NLOHMANN_JSON_HEDLEY_ARM_VERSION_CHECK(5,6,0) - #define NLOHMANN_JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("push") - #define NLOHMANN_JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("pop") -#elif NLOHMANN_JSON_HEDLEY_TI_VERSION_CHECK(8,1,0) - #define NLOHMANN_JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("diag_push") - #define NLOHMANN_JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("diag_pop") -#elif NLOHMANN_JSON_HEDLEY_PELLES_VERSION_CHECK(2,90,0) - #define NLOHMANN_JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("warning(push)") - #define NLOHMANN_JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("warning(pop)") + #define JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("clang diagnostic push") + #define JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("clang diagnostic pop") +#elif JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) + #define JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("warning(push)") + #define JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("warning(pop)") +#elif JSON_HEDLEY_GCC_VERSION_CHECK(4,6,0) + #define JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("GCC diagnostic push") + #define JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("GCC diagnostic pop") +#elif JSON_HEDLEY_MSVC_VERSION_CHECK(15,0,0) + #define JSON_HEDLEY_DIAGNOSTIC_PUSH __pragma(warning(push)) + #define JSON_HEDLEY_DIAGNOSTIC_POP __pragma(warning(pop)) +#elif JSON_HEDLEY_ARM_VERSION_CHECK(5,6,0) + #define JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("push") + #define JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("pop") +#elif JSON_HEDLEY_TI_VERSION_CHECK(8,1,0) + #define JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("diag_push") + #define JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("diag_pop") +#elif JSON_HEDLEY_PELLES_VERSION_CHECK(2,90,0) + #define JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("warning(push)") + #define JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("warning(pop)") #else - #define NLOHMANN_JSON_HEDLEY_DIAGNOSTIC_PUSH - #define NLOHMANN_JSON_HEDLEY_DIAGNOSTIC_POP + #define JSON_HEDLEY_DIAGNOSTIC_PUSH + #define JSON_HEDLEY_DIAGNOSTIC_POP #endif -#if defined(NLOHMANN_JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED) - #undef NLOHMANN_JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED +#if defined(JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED) + #undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED #endif -#if NLOHMANN_JSON_HEDLEY_HAS_WARNING("-Wdeprecated-declarations") - #define NLOHMANN_JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("clang diagnostic ignored \"-Wdeprecated-declarations\"") -#elif NLOHMANN_JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) - #define NLOHMANN_JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("warning(disable:1478 1786)") -#elif NLOHMANN_JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) - #define NLOHMANN_JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("diag_suppress 1215,1444") -#elif NLOHMANN_JSON_HEDLEY_GCC_VERSION_CHECK(4,3,0) - #define NLOHMANN_JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"") -#elif NLOHMANN_JSON_HEDLEY_MSVC_VERSION_CHECK(15,0,0) - #define NLOHMANN_JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED __pragma(warning(disable:4996)) -#elif NLOHMANN_JSON_HEDLEY_TI_VERSION_CHECK(8,0,0) - #define NLOHMANN_JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("diag_suppress 1291,1718") -#elif NLOHMANN_JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,13,0) && !defined(__cplusplus) - #define NLOHMANN_JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("error_messages(off,E_DEPRECATED_ATT,E_DEPRECATED_ATT_MESS)") -#elif NLOHMANN_JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,13,0) && defined(__cplusplus) - #define NLOHMANN_JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("error_messages(off,symdeprecated,symdeprecated2)") -#elif NLOHMANN_JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0) - #define NLOHMANN_JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("diag_suppress=Pe1444,Pe1215") -#elif NLOHMANN_JSON_HEDLEY_PELLES_VERSION_CHECK(2,90,0) - #define NLOHMANN_JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("warn(disable:2241)") +#if JSON_HEDLEY_HAS_WARNING("-Wdeprecated-declarations") + #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("clang diagnostic ignored \"-Wdeprecated-declarations\"") +#elif JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) + #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("warning(disable:1478 1786)") +#elif JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) + #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("diag_suppress 1215,1444") +#elif JSON_HEDLEY_GCC_VERSION_CHECK(4,3,0) + #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"") +#elif JSON_HEDLEY_MSVC_VERSION_CHECK(15,0,0) + #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED __pragma(warning(disable:4996)) +#elif JSON_HEDLEY_TI_VERSION_CHECK(8,0,0) + #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("diag_suppress 1291,1718") +#elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,13,0) && !defined(__cplusplus) + #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("error_messages(off,E_DEPRECATED_ATT,E_DEPRECATED_ATT_MESS)") +#elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,13,0) && defined(__cplusplus) + #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("error_messages(off,symdeprecated,symdeprecated2)") +#elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0) + #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("diag_suppress=Pe1444,Pe1215") +#elif JSON_HEDLEY_PELLES_VERSION_CHECK(2,90,0) + #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("warn(disable:2241)") #else - #define NLOHMANN_JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED + #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED #endif -#if defined(NLOHMANN_JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS) - #undef NLOHMANN_JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS +#if defined(JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS) + #undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS #endif -#if NLOHMANN_JSON_HEDLEY_HAS_WARNING("-Wunknown-pragmas") - #define NLOHMANN_JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("clang diagnostic ignored \"-Wunknown-pragmas\"") -#elif NLOHMANN_JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) - #define NLOHMANN_JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("warning(disable:161)") -#elif NLOHMANN_JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) - #define NLOHMANN_JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("diag_suppress 1675") -#elif NLOHMANN_JSON_HEDLEY_GCC_VERSION_CHECK(4,3,0) - #define NLOHMANN_JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("GCC diagnostic ignored \"-Wunknown-pragmas\"") -#elif NLOHMANN_JSON_HEDLEY_MSVC_VERSION_CHECK(15,0,0) - #define NLOHMANN_JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS __pragma(warning(disable:4068)) -#elif NLOHMANN_JSON_HEDLEY_TI_VERSION_CHECK(8,0,0) - #define NLOHMANN_JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("diag_suppress 163") -#elif NLOHMANN_JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0) - #define NLOHMANN_JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("diag_suppress=Pe161") +#if JSON_HEDLEY_HAS_WARNING("-Wunknown-pragmas") + #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("clang diagnostic ignored \"-Wunknown-pragmas\"") +#elif JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) + #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("warning(disable:161)") +#elif JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) + #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("diag_suppress 1675") +#elif JSON_HEDLEY_GCC_VERSION_CHECK(4,3,0) + #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("GCC diagnostic ignored \"-Wunknown-pragmas\"") +#elif JSON_HEDLEY_MSVC_VERSION_CHECK(15,0,0) + #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS __pragma(warning(disable:4068)) +#elif JSON_HEDLEY_TI_VERSION_CHECK(8,0,0) + #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("diag_suppress 163") +#elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0) + #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("diag_suppress=Pe161") #else - #define NLOHMANN_JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS + #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS #endif -#if defined(NLOHMANN_JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL) - #undef NLOHMANN_JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL +#if defined(JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL) + #undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL #endif -#if NLOHMANN_JSON_HEDLEY_HAS_WARNING("-Wcast-qual") - #define NLOHMANN_JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL _Pragma("clang diagnostic ignored \"-Wcast-qual\"") -#elif NLOHMANN_JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) - #define NLOHMANN_JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL _Pragma("warning(disable:2203 2331)") -#elif NLOHMANN_JSON_HEDLEY_GCC_VERSION_CHECK(3,0,0) - #define NLOHMANN_JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL _Pragma("GCC diagnostic ignored \"-Wcast-qual\"") +#if JSON_HEDLEY_HAS_WARNING("-Wcast-qual") + #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL _Pragma("clang diagnostic ignored \"-Wcast-qual\"") +#elif JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) + #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL _Pragma("warning(disable:2203 2331)") +#elif JSON_HEDLEY_GCC_VERSION_CHECK(3,0,0) + #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL _Pragma("GCC diagnostic ignored \"-Wcast-qual\"") #else - #define NLOHMANN_JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL + #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL #endif -#if defined(NLOHMANN_JSON_HEDLEY_DEPRECATED) - #undef NLOHMANN_JSON_HEDLEY_DEPRECATED +#if defined(JSON_HEDLEY_DEPRECATED) + #undef JSON_HEDLEY_DEPRECATED #endif -#if defined(NLOHMANN_JSON_HEDLEY_DEPRECATED_FOR) - #undef NLOHMANN_JSON_HEDLEY_DEPRECATED_FOR +#if defined(JSON_HEDLEY_DEPRECATED_FOR) + #undef JSON_HEDLEY_DEPRECATED_FOR #endif #if defined(__cplusplus) && (__cplusplus >= 201402L) - #define NLOHMANN_JSON_HEDLEY_DEPRECATED(since) [[deprecated("Since " #since)]] - #define NLOHMANN_JSON_HEDLEY_DEPRECATED_FOR(since, replacement) [[deprecated("Since " #since "; use " #replacement)]] + #define JSON_HEDLEY_DEPRECATED(since) [[deprecated("Since " #since)]] + #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) [[deprecated("Since " #since "; use " #replacement)]] #elif \ - NLOHMANN_JSON_HEDLEY_HAS_EXTENSION(attribute_deprecated_with_message) || \ - NLOHMANN_JSON_HEDLEY_GCC_VERSION_CHECK(4,5,0) || \ - NLOHMANN_JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ - NLOHMANN_JSON_HEDLEY_ARM_VERSION_CHECK(5,6,0) || \ - NLOHMANN_JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,13,0) || \ - NLOHMANN_JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) || \ - NLOHMANN_JSON_HEDLEY_TI_VERSION_CHECK(8,3,0) - #define NLOHMANN_JSON_HEDLEY_DEPRECATED(since) __attribute__((__deprecated__("Since " #since))) - #define NLOHMANN_JSON_HEDLEY_DEPRECATED_FOR(since, replacement) __attribute__((__deprecated__("Since " #since "; use " #replacement))) + JSON_HEDLEY_HAS_EXTENSION(attribute_deprecated_with_message) || \ + JSON_HEDLEY_GCC_VERSION_CHECK(4,5,0) || \ + JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ + JSON_HEDLEY_ARM_VERSION_CHECK(5,6,0) || \ + JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,13,0) || \ + JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) || \ + JSON_HEDLEY_TI_VERSION_CHECK(8,3,0) + #define JSON_HEDLEY_DEPRECATED(since) __attribute__((__deprecated__("Since " #since))) + #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) __attribute__((__deprecated__("Since " #since "; use " #replacement))) #elif \ - NLOHMANN_JSON_HEDLEY_HAS_ATTRIBUTE(deprecated) || \ - NLOHMANN_JSON_HEDLEY_GCC_VERSION_CHECK(3,1,0) || \ - NLOHMANN_JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ - NLOHMANN_JSON_HEDLEY_TI_VERSION_CHECK(8,0,0) || \ - (NLOHMANN_JSON_HEDLEY_TI_VERSION_CHECK(7,3,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) - #define NLOHMANN_JSON_HEDLEY_DEPRECATED(since) __attribute__((__deprecated__)) - #define NLOHMANN_JSON_HEDLEY_DEPRECATED_FOR(since, replacement) __attribute__((__deprecated__)) -#elif NLOHMANN_JSON_HEDLEY_MSVC_VERSION_CHECK(14,0,0) - #define NLOHMANN_JSON_HEDLEY_DEPRECATED(since) __declspec(deprecated("Since " # since)) - #define NLOHMANN_JSON_HEDLEY_DEPRECATED_FOR(since, replacement) __declspec(deprecated("Since " #since "; use " #replacement)) + JSON_HEDLEY_HAS_ATTRIBUTE(deprecated) || \ + JSON_HEDLEY_GCC_VERSION_CHECK(3,1,0) || \ + JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ + JSON_HEDLEY_TI_VERSION_CHECK(8,0,0) || \ + (JSON_HEDLEY_TI_VERSION_CHECK(7,3,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) + #define JSON_HEDLEY_DEPRECATED(since) __attribute__((__deprecated__)) + #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) __attribute__((__deprecated__)) +#elif JSON_HEDLEY_MSVC_VERSION_CHECK(14,0,0) + #define JSON_HEDLEY_DEPRECATED(since) __declspec(deprecated("Since " # since)) + #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) __declspec(deprecated("Since " #since "; use " #replacement)) #elif \ - NLOHMANN_JSON_HEDLEY_MSVC_VERSION_CHECK(13,10,0) || \ - NLOHMANN_JSON_HEDLEY_PELLES_VERSION_CHECK(6,50,0) - #define NLOHMANN_JSON_HEDLEY_DEPRECATED(since) _declspec(deprecated) - #define NLOHMANN_JSON_HEDLEY_DEPRECATED_FOR(since, replacement) __declspec(deprecated) -#elif NLOHMANN_JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0) - #define NLOHMANN_JSON_HEDLEY_DEPRECATED(since) _Pragma("deprecated") - #define NLOHMANN_JSON_HEDLEY_DEPRECATED_FOR(since, replacement) _Pragma("deprecated") + JSON_HEDLEY_MSVC_VERSION_CHECK(13,10,0) || \ + JSON_HEDLEY_PELLES_VERSION_CHECK(6,50,0) + #define JSON_HEDLEY_DEPRECATED(since) _declspec(deprecated) + #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) __declspec(deprecated) +#elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0) + #define JSON_HEDLEY_DEPRECATED(since) _Pragma("deprecated") + #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) _Pragma("deprecated") #else - #define NLOHMANN_JSON_HEDLEY_DEPRECATED(since) - #define NLOHMANN_JSON_HEDLEY_DEPRECATED_FOR(since, replacement) + #define JSON_HEDLEY_DEPRECATED(since) + #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) #endif -#if defined(NLOHMANN_JSON_HEDLEY_UNAVAILABLE) - #undef NLOHMANN_JSON_HEDLEY_UNAVAILABLE +#if defined(JSON_HEDLEY_UNAVAILABLE) + #undef JSON_HEDLEY_UNAVAILABLE #endif #if \ - NLOHMANN_JSON_HEDLEY_HAS_ATTRIBUTE(warning) || \ - NLOHMANN_JSON_HEDLEY_GCC_VERSION_CHECK(4,3,0) || \ - NLOHMANN_JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) - #define NLOHMANN_JSON_HEDLEY_UNAVAILABLE(available_since) __attribute__((__warning__("Not available until " #available_since))) + JSON_HEDLEY_HAS_ATTRIBUTE(warning) || \ + JSON_HEDLEY_GCC_VERSION_CHECK(4,3,0) || \ + JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) + #define JSON_HEDLEY_UNAVAILABLE(available_since) __attribute__((__warning__("Not available until " #available_since))) #else - #define NLOHMANN_JSON_HEDLEY_UNAVAILABLE(available_since) + #define JSON_HEDLEY_UNAVAILABLE(available_since) #endif -#if defined(NLOHMANN_JSON_HEDLEY_WARN_UNUSED_RESULT) - #undef NLOHMANN_JSON_HEDLEY_WARN_UNUSED_RESULT +#if defined(JSON_HEDLEY_WARN_UNUSED_RESULT) + #undef JSON_HEDLEY_WARN_UNUSED_RESULT #endif #if defined(__cplusplus) && (__cplusplus >= 201703L) - #define NLOHMANN_JSON_HEDLEY_WARN_UNUSED_RESULT [[nodiscard]] + #define JSON_HEDLEY_WARN_UNUSED_RESULT [[nodiscard]] #elif \ - NLOHMANN_JSON_HEDLEY_HAS_ATTRIBUTE(warn_unused_result) || \ - NLOHMANN_JSON_HEDLEY_GCC_VERSION_CHECK(3,4,0) || \ - NLOHMANN_JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ - NLOHMANN_JSON_HEDLEY_TI_VERSION_CHECK(8,0,0) || \ - (NLOHMANN_JSON_HEDLEY_TI_VERSION_CHECK(7,3,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ - (NLOHMANN_JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,15,0) && defined(__cplusplus)) || \ - NLOHMANN_JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) - #define NLOHMANN_JSON_HEDLEY_WARN_UNUSED_RESULT __attribute__((__warn_unused_result__)) + JSON_HEDLEY_HAS_ATTRIBUTE(warn_unused_result) || \ + JSON_HEDLEY_GCC_VERSION_CHECK(3,4,0) || \ + JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ + JSON_HEDLEY_TI_VERSION_CHECK(8,0,0) || \ + (JSON_HEDLEY_TI_VERSION_CHECK(7,3,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ + (JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,15,0) && defined(__cplusplus)) || \ + JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) + #define JSON_HEDLEY_WARN_UNUSED_RESULT __attribute__((__warn_unused_result__)) #elif defined(_Check_return_) /* SAL */ - #define NLOHMANN_JSON_HEDLEY_WARN_UNUSED_RESULT _Check_return_ + #define JSON_HEDLEY_WARN_UNUSED_RESULT _Check_return_ #else - #define NLOHMANN_JSON_HEDLEY_WARN_UNUSED_RESULT + #define JSON_HEDLEY_WARN_UNUSED_RESULT #endif -#if defined(NLOHMANN_JSON_HEDLEY_SENTINEL) - #undef NLOHMANN_JSON_HEDLEY_SENTINEL +#if defined(JSON_HEDLEY_SENTINEL) + #undef JSON_HEDLEY_SENTINEL #endif #if \ - NLOHMANN_JSON_HEDLEY_HAS_ATTRIBUTE(sentinel) || \ - NLOHMANN_JSON_HEDLEY_GCC_VERSION_CHECK(4,0,0) || \ - NLOHMANN_JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ - NLOHMANN_JSON_HEDLEY_ARM_VERSION_CHECK(5,4,0) - #define NLOHMANN_JSON_HEDLEY_SENTINEL(position) __attribute__((__sentinel__(position))) + JSON_HEDLEY_HAS_ATTRIBUTE(sentinel) || \ + JSON_HEDLEY_GCC_VERSION_CHECK(4,0,0) || \ + JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ + JSON_HEDLEY_ARM_VERSION_CHECK(5,4,0) + #define JSON_HEDLEY_SENTINEL(position) __attribute__((__sentinel__(position))) #else - #define NLOHMANN_JSON_HEDLEY_SENTINEL(position) + #define JSON_HEDLEY_SENTINEL(position) #endif -#if defined(NLOHMANN_JSON_HEDLEY_NO_RETURN) - #undef NLOHMANN_JSON_HEDLEY_NO_RETURN +#if defined(JSON_HEDLEY_NO_RETURN) + #undef JSON_HEDLEY_NO_RETURN #endif -#if NLOHMANN_JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0) - #define NLOHMANN_JSON_HEDLEY_NO_RETURN __noreturn -#elif NLOHMANN_JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) - #define NLOHMANN_JSON_HEDLEY_NO_RETURN __attribute__((__noreturn__)) +#if JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0) + #define JSON_HEDLEY_NO_RETURN __noreturn +#elif JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) + #define JSON_HEDLEY_NO_RETURN __attribute__((__noreturn__)) #elif defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L - #define NLOHMANN_JSON_HEDLEY_NO_RETURN _Noreturn + #define JSON_HEDLEY_NO_RETURN _Noreturn #elif defined(__cplusplus) && (__cplusplus >= 201103L) - #define NLOHMANN_JSON_HEDLEY_NO_RETURN [[noreturn]] + #define JSON_HEDLEY_NO_RETURN [[noreturn]] #elif \ - NLOHMANN_JSON_HEDLEY_HAS_ATTRIBUTE(noreturn) || \ - NLOHMANN_JSON_HEDLEY_GCC_VERSION_CHECK(3,2,0) || \ - NLOHMANN_JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \ - NLOHMANN_JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ - NLOHMANN_JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \ - NLOHMANN_JSON_HEDLEY_TI_VERSION_CHECK(18,0,0) || \ - (NLOHMANN_JSON_HEDLEY_TI_VERSION_CHECK(17,3,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) - #define NLOHMANN_JSON_HEDLEY_NO_RETURN __attribute__((__noreturn__)) -#elif NLOHMANN_JSON_HEDLEY_MSVC_VERSION_CHECK(13,10,0) - #define NLOHMANN_JSON_HEDLEY_NO_RETURN __declspec(noreturn) -#elif NLOHMANN_JSON_HEDLEY_TI_VERSION_CHECK(6,0,0) && defined(__cplusplus) - #define NLOHMANN_JSON_HEDLEY_NO_RETURN _Pragma("FUNC_NEVER_RETURNS;") -#elif NLOHMANN_JSON_HEDLEY_COMPCERT_VERSION_CHECK(3,2,0) - #define NLOHMANN_JSON_HEDLEY_NO_RETURN __attribute((noreturn)) -#elif NLOHMANN_JSON_HEDLEY_PELLES_VERSION_CHECK(9,0,0) - #define NLOHMANN_JSON_HEDLEY_NO_RETURN __declspec(noreturn) + JSON_HEDLEY_HAS_ATTRIBUTE(noreturn) || \ + JSON_HEDLEY_GCC_VERSION_CHECK(3,2,0) || \ + JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \ + JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ + JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \ + JSON_HEDLEY_TI_VERSION_CHECK(18,0,0) || \ + (JSON_HEDLEY_TI_VERSION_CHECK(17,3,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) + #define JSON_HEDLEY_NO_RETURN __attribute__((__noreturn__)) +#elif JSON_HEDLEY_MSVC_VERSION_CHECK(13,10,0) + #define JSON_HEDLEY_NO_RETURN __declspec(noreturn) +#elif JSON_HEDLEY_TI_VERSION_CHECK(6,0,0) && defined(__cplusplus) + #define JSON_HEDLEY_NO_RETURN _Pragma("FUNC_NEVER_RETURNS;") +#elif JSON_HEDLEY_COMPCERT_VERSION_CHECK(3,2,0) + #define JSON_HEDLEY_NO_RETURN __attribute((noreturn)) +#elif JSON_HEDLEY_PELLES_VERSION_CHECK(9,0,0) + #define JSON_HEDLEY_NO_RETURN __declspec(noreturn) #else - #define NLOHMANN_JSON_HEDLEY_NO_RETURN + #define JSON_HEDLEY_NO_RETURN #endif -#if defined(NLOHMANN_JSON_HEDLEY_UNREACHABLE) - #undef NLOHMANN_JSON_HEDLEY_UNREACHABLE +#if defined(JSON_HEDLEY_UNREACHABLE) + #undef JSON_HEDLEY_UNREACHABLE #endif -#if defined(NLOHMANN_JSON_HEDLEY_UNREACHABLE_RETURN) - #undef NLOHMANN_JSON_HEDLEY_UNREACHABLE_RETURN +#if defined(JSON_HEDLEY_UNREACHABLE_RETURN) + #undef JSON_HEDLEY_UNREACHABLE_RETURN #endif #if \ - (NLOHMANN_JSON_HEDLEY_HAS_BUILTIN(__builtin_unreachable) && (!defined(NLOHMANN_JSON_HEDLEY_ARM_VERSION))) || \ - NLOHMANN_JSON_HEDLEY_GCC_VERSION_CHECK(4,5,0) || \ - NLOHMANN_JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ - NLOHMANN_JSON_HEDLEY_IBM_VERSION_CHECK(13,1,5) - #define NLOHMANN_JSON_HEDLEY_UNREACHABLE() __builtin_unreachable() -#elif NLOHMANN_JSON_HEDLEY_MSVC_VERSION_CHECK(13,10,0) - #define NLOHMANN_JSON_HEDLEY_UNREACHABLE() __assume(0) -#elif NLOHMANN_JSON_HEDLEY_TI_VERSION_CHECK(6,0,0) + (JSON_HEDLEY_HAS_BUILTIN(__builtin_unreachable) && (!defined(JSON_HEDLEY_ARM_VERSION))) || \ + JSON_HEDLEY_GCC_VERSION_CHECK(4,5,0) || \ + JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ + JSON_HEDLEY_IBM_VERSION_CHECK(13,1,5) + #define JSON_HEDLEY_UNREACHABLE() __builtin_unreachable() +#elif JSON_HEDLEY_MSVC_VERSION_CHECK(13,10,0) + #define JSON_HEDLEY_UNREACHABLE() __assume(0) +#elif JSON_HEDLEY_TI_VERSION_CHECK(6,0,0) #if defined(__cplusplus) - #define NLOHMANN_JSON_HEDLEY_UNREACHABLE() std::_nassert(0) + #define JSON_HEDLEY_UNREACHABLE() std::_nassert(0) #else - #define NLOHMANN_JSON_HEDLEY_UNREACHABLE() _nassert(0) + #define JSON_HEDLEY_UNREACHABLE() _nassert(0) #endif - #define NLOHMANN_JSON_HEDLEY_UNREACHABLE_RETURN(value) return value + #define JSON_HEDLEY_UNREACHABLE_RETURN(value) return value #elif defined(EXIT_FAILURE) - #define NLOHMANN_JSON_HEDLEY_UNREACHABLE() abort() + #define JSON_HEDLEY_UNREACHABLE() abort() #else - #define NLOHMANN_JSON_HEDLEY_UNREACHABLE() - #define NLOHMANN_JSON_HEDLEY_UNREACHABLE_RETURN(value) return value + #define JSON_HEDLEY_UNREACHABLE() + #define JSON_HEDLEY_UNREACHABLE_RETURN(value) return value #endif -#if !defined(NLOHMANN_JSON_HEDLEY_UNREACHABLE_RETURN) - #define NLOHMANN_JSON_HEDLEY_UNREACHABLE_RETURN(value) NLOHMANN_JSON_HEDLEY_UNREACHABLE() +#if !defined(JSON_HEDLEY_UNREACHABLE_RETURN) + #define JSON_HEDLEY_UNREACHABLE_RETURN(value) JSON_HEDLEY_UNREACHABLE() #endif -#if defined(NLOHMANN_JSON_HEDLEY_ASSUME) - #undef NLOHMANN_JSON_HEDLEY_ASSUME +#if defined(JSON_HEDLEY_ASSUME) + #undef JSON_HEDLEY_ASSUME #endif #if \ - NLOHMANN_JSON_HEDLEY_MSVC_VERSION_CHECK(13,10,0) || \ - NLOHMANN_JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) - #define NLOHMANN_JSON_HEDLEY_ASSUME(expr) __assume(expr) -#elif NLOHMANN_JSON_HEDLEY_HAS_BUILTIN(__builtin_assume) - #define NLOHMANN_JSON_HEDLEY_ASSUME(expr) __builtin_assume(expr) -#elif NLOHMANN_JSON_HEDLEY_TI_VERSION_CHECK(6,0,0) + JSON_HEDLEY_MSVC_VERSION_CHECK(13,10,0) || \ + JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) + #define JSON_HEDLEY_ASSUME(expr) __assume(expr) +#elif JSON_HEDLEY_HAS_BUILTIN(__builtin_assume) + #define JSON_HEDLEY_ASSUME(expr) __builtin_assume(expr) +#elif JSON_HEDLEY_TI_VERSION_CHECK(6,0,0) #if defined(__cplusplus) - #define NLOHMANN_JSON_HEDLEY_ASSUME(expr) std::_nassert(expr) + #define JSON_HEDLEY_ASSUME(expr) std::_nassert(expr) #else - #define NLOHMANN_JSON_HEDLEY_ASSUME(expr) _nassert(expr) + #define JSON_HEDLEY_ASSUME(expr) _nassert(expr) #endif #elif \ - (NLOHMANN_JSON_HEDLEY_HAS_BUILTIN(__builtin_unreachable) && !defined(NLOHMANN_JSON_HEDLEY_ARM_VERSION)) || \ - NLOHMANN_JSON_HEDLEY_GCC_VERSION_CHECK(4,5,0) || \ - NLOHMANN_JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ - NLOHMANN_JSON_HEDLEY_IBM_VERSION_CHECK(13,1,5) - #define NLOHMANN_JSON_HEDLEY_ASSUME(expr) ((void) ((expr) ? 1 : (__builtin_unreachable(), 1))) + (JSON_HEDLEY_HAS_BUILTIN(__builtin_unreachable) && !defined(JSON_HEDLEY_ARM_VERSION)) || \ + JSON_HEDLEY_GCC_VERSION_CHECK(4,5,0) || \ + JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ + JSON_HEDLEY_IBM_VERSION_CHECK(13,1,5) + #define JSON_HEDLEY_ASSUME(expr) ((void) ((expr) ? 1 : (__builtin_unreachable(), 1))) #else - #define NLOHMANN_JSON_HEDLEY_ASSUME(expr) ((void) (expr)) + #define JSON_HEDLEY_ASSUME(expr) ((void) (expr)) #endif -NLOHMANN_JSON_HEDLEY_DIAGNOSTIC_PUSH +JSON_HEDLEY_DIAGNOSTIC_PUSH #if \ - NLOHMANN_JSON_HEDLEY_HAS_WARNING("-Wvariadic-macros") || \ - NLOHMANN_JSON_HEDLEY_GCC_VERSION_CHECK(4,0,0) + JSON_HEDLEY_HAS_WARNING("-Wvariadic-macros") || \ + JSON_HEDLEY_GCC_VERSION_CHECK(4,0,0) #if defined(__clang__) #pragma clang diagnostic ignored "-Wvariadic-macros" - #elif defined(NLOHMANN_JSON_HEDLEY_GCC_VERSION) + #elif defined(JSON_HEDLEY_GCC_VERSION) #pragma GCC diagnostic ignored "-Wvariadic-macros" #endif #endif -#if defined(NLOHMANN_JSON_HEDLEY_NON_NULL) - #undef NLOHMANN_JSON_HEDLEY_NON_NULL +#if defined(JSON_HEDLEY_NON_NULL) + #undef JSON_HEDLEY_NON_NULL #endif #if \ - NLOHMANN_JSON_HEDLEY_HAS_ATTRIBUTE(nonnull) || \ - NLOHMANN_JSON_HEDLEY_GCC_VERSION_CHECK(3,3,0) || \ - NLOHMANN_JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ - NLOHMANN_JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) - #define NLOHMANN_JSON_HEDLEY_NON_NULL(...) __attribute__((__nonnull__(__VA_ARGS__))) + JSON_HEDLEY_HAS_ATTRIBUTE(nonnull) || \ + JSON_HEDLEY_GCC_VERSION_CHECK(3,3,0) || \ + JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ + JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) + #define JSON_HEDLEY_NON_NULL(...) __attribute__((__nonnull__(__VA_ARGS__))) #else - #define NLOHMANN_JSON_HEDLEY_NON_NULL(...) + #define JSON_HEDLEY_NON_NULL(...) #endif -NLOHMANN_JSON_HEDLEY_DIAGNOSTIC_POP +JSON_HEDLEY_DIAGNOSTIC_POP -#if defined(NLOHMANN_JSON_HEDLEY_PRINTF_FORMAT) - #undef NLOHMANN_JSON_HEDLEY_PRINTF_FORMAT +#if defined(JSON_HEDLEY_PRINTF_FORMAT) + #undef JSON_HEDLEY_PRINTF_FORMAT #endif -#if defined(__MINGW32__) && NLOHMANN_JSON_HEDLEY_GCC_HAS_ATTRIBUTE(format,4,4,0) && !defined(__USE_MINGW_ANSI_STDIO) - #define NLOHMANN_JSON_HEDLEY_PRINTF_FORMAT(string_idx,first_to_check) __attribute__((__format__(ms_printf, string_idx, first_to_check))) -#elif defined(__MINGW32__) && NLOHMANN_JSON_HEDLEY_GCC_HAS_ATTRIBUTE(format,4,4,0) && defined(__USE_MINGW_ANSI_STDIO) - #define NLOHMANN_JSON_HEDLEY_PRINTF_FORMAT(string_idx,first_to_check) __attribute__((__format__(gnu_printf, string_idx, first_to_check))) +#if defined(__MINGW32__) && JSON_HEDLEY_GCC_HAS_ATTRIBUTE(format,4,4,0) && !defined(__USE_MINGW_ANSI_STDIO) + #define JSON_HEDLEY_PRINTF_FORMAT(string_idx,first_to_check) __attribute__((__format__(ms_printf, string_idx, first_to_check))) +#elif defined(__MINGW32__) && JSON_HEDLEY_GCC_HAS_ATTRIBUTE(format,4,4,0) && defined(__USE_MINGW_ANSI_STDIO) + #define JSON_HEDLEY_PRINTF_FORMAT(string_idx,first_to_check) __attribute__((__format__(gnu_printf, string_idx, first_to_check))) #elif \ - NLOHMANN_JSON_HEDLEY_HAS_ATTRIBUTE(format) || \ - NLOHMANN_JSON_HEDLEY_GCC_VERSION_CHECK(3,1,0) || \ - NLOHMANN_JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ - NLOHMANN_JSON_HEDLEY_ARM_VERSION_CHECK(5,6,0) || \ - NLOHMANN_JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \ - NLOHMANN_JSON_HEDLEY_TI_VERSION_CHECK(8,0,0) || \ - (NLOHMANN_JSON_HEDLEY_TI_VERSION_CHECK(7,3,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) - #define NLOHMANN_JSON_HEDLEY_PRINTF_FORMAT(string_idx,first_to_check) __attribute__((__format__(__printf__, string_idx, first_to_check))) -#elif NLOHMANN_JSON_HEDLEY_PELLES_VERSION_CHECK(6,0,0) - #define NLOHMANN_JSON_HEDLEY_PRINTF_FORMAT(string_idx,first_to_check) __declspec(vaformat(printf,string_idx,first_to_check)) + JSON_HEDLEY_HAS_ATTRIBUTE(format) || \ + JSON_HEDLEY_GCC_VERSION_CHECK(3,1,0) || \ + JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ + JSON_HEDLEY_ARM_VERSION_CHECK(5,6,0) || \ + JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \ + JSON_HEDLEY_TI_VERSION_CHECK(8,0,0) || \ + (JSON_HEDLEY_TI_VERSION_CHECK(7,3,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) + #define JSON_HEDLEY_PRINTF_FORMAT(string_idx,first_to_check) __attribute__((__format__(__printf__, string_idx, first_to_check))) +#elif JSON_HEDLEY_PELLES_VERSION_CHECK(6,0,0) + #define JSON_HEDLEY_PRINTF_FORMAT(string_idx,first_to_check) __declspec(vaformat(printf,string_idx,first_to_check)) #else - #define NLOHMANN_JSON_HEDLEY_PRINTF_FORMAT(string_idx,first_to_check) + #define JSON_HEDLEY_PRINTF_FORMAT(string_idx,first_to_check) #endif -#if defined(NLOHMANN_JSON_HEDLEY_CONSTEXPR) - #undef NLOHMANN_JSON_HEDLEY_CONSTEXPR +#if defined(JSON_HEDLEY_CONSTEXPR) + #undef JSON_HEDLEY_CONSTEXPR #endif #if defined(__cplusplus) #if __cplusplus >= 201103L - #define NLOHMANN_JSON_HEDLEY_CONSTEXPR constexpr + #define JSON_HEDLEY_CONSTEXPR constexpr #endif #endif -#if !defined(NLOHMANN_JSON_HEDLEY_CONSTEXPR) - #define NLOHMANN_JSON_HEDLEY_CONSTEXPR +#if !defined(JSON_HEDLEY_CONSTEXPR) + #define JSON_HEDLEY_CONSTEXPR #endif -#if defined(NLOHMANN_JSON_HEDLEY_PREDICT) - #undef NLOHMANN_JSON_HEDLEY_PREDICT +#if defined(JSON_HEDLEY_PREDICT) + #undef JSON_HEDLEY_PREDICT #endif -#if defined(NLOHMANN_JSON_HEDLEY_LIKELY) - #undef NLOHMANN_JSON_HEDLEY_LIKELY +#if defined(JSON_HEDLEY_LIKELY) + #undef JSON_HEDLEY_LIKELY #endif -#if defined(NLOHMANN_JSON_HEDLEY_UNLIKELY) - #undef NLOHMANN_JSON_HEDLEY_UNLIKELY +#if defined(JSON_HEDLEY_UNLIKELY) + #undef JSON_HEDLEY_UNLIKELY #endif -#if defined(NLOHMANN_JSON_HEDLEY_UNPREDICTABLE) - #undef NLOHMANN_JSON_HEDLEY_UNPREDICTABLE +#if defined(JSON_HEDLEY_UNPREDICTABLE) + #undef JSON_HEDLEY_UNPREDICTABLE #endif -#if NLOHMANN_JSON_HEDLEY_HAS_BUILTIN(__builtin_unpredictable) - #define NLOHMANN_JSON_HEDLEY_UNPREDICTABLE(expr) __builtin_unpredictable(!!(expr)) +#if JSON_HEDLEY_HAS_BUILTIN(__builtin_unpredictable) + #define JSON_HEDLEY_UNPREDICTABLE(expr) __builtin_unpredictable(!!(expr)) #endif #if \ - NLOHMANN_JSON_HEDLEY_HAS_BUILTIN(__builtin_expect_with_probability) || \ - NLOHMANN_JSON_HEDLEY_GCC_VERSION_CHECK(9,0,0) -# define NLOHMANN_JSON_HEDLEY_PREDICT(expr, value, probability) __builtin_expect_with_probability(expr, value, probability) -# define NLOHMANN_JSON_HEDLEY_PREDICT_TRUE(expr, probability) __builtin_expect_with_probability(!!(expr), 1, probability) -# define NLOHMANN_JSON_HEDLEY_PREDICT_FALSE(expr, probability) __builtin_expect_with_probability(!!(expr), 0, probability) -# define NLOHMANN_JSON_HEDLEY_LIKELY(expr) __builtin_expect(!!(expr), 1) -# define NLOHMANN_JSON_HEDLEY_UNLIKELY(expr) __builtin_expect(!!(expr), 0) -#if !defined(NLOHMANN_JSON_HEDLEY_BUILTIN_UNPREDICTABLE) - #define NLOHMANN_JSON_HEDLEY_BUILTIN_UNPREDICTABLE(expr) __builtin_expect_with_probability(!!(expr), 1, 0.5) + JSON_HEDLEY_HAS_BUILTIN(__builtin_expect_with_probability) || \ + JSON_HEDLEY_GCC_VERSION_CHECK(9,0,0) +# define JSON_HEDLEY_PREDICT(expr, value, probability) __builtin_expect_with_probability(expr, value, probability) +# define JSON_HEDLEY_PREDICT_TRUE(expr, probability) __builtin_expect_with_probability(!!(expr), 1, probability) +# define JSON_HEDLEY_PREDICT_FALSE(expr, probability) __builtin_expect_with_probability(!!(expr), 0, probability) +# define JSON_HEDLEY_LIKELY(expr) __builtin_expect(!!(expr), 1) +# define JSON_HEDLEY_UNLIKELY(expr) __builtin_expect(!!(expr), 0) +#if !defined(JSON_HEDLEY_BUILTIN_UNPREDICTABLE) + #define JSON_HEDLEY_BUILTIN_UNPREDICTABLE(expr) __builtin_expect_with_probability(!!(expr), 1, 0.5) #endif #elif \ - NLOHMANN_JSON_HEDLEY_HAS_BUILTIN(__builtin_expect) || \ - NLOHMANN_JSON_HEDLEY_GCC_VERSION_CHECK(3,0,0) || \ - NLOHMANN_JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ - (NLOHMANN_JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,15,0) && defined(__cplusplus)) || \ - NLOHMANN_JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ - NLOHMANN_JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \ - NLOHMANN_JSON_HEDLEY_TI_VERSION_CHECK(6,1,0) || \ - NLOHMANN_JSON_HEDLEY_TINYC_VERSION_CHECK(0,9,27) -# define NLOHMANN_JSON_HEDLEY_PREDICT(expr, expected, probability) \ + JSON_HEDLEY_HAS_BUILTIN(__builtin_expect) || \ + JSON_HEDLEY_GCC_VERSION_CHECK(3,0,0) || \ + JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ + (JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,15,0) && defined(__cplusplus)) || \ + JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ + JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \ + JSON_HEDLEY_TI_VERSION_CHECK(6,1,0) || \ + JSON_HEDLEY_TINYC_VERSION_CHECK(0,9,27) +# define JSON_HEDLEY_PREDICT(expr, expected, probability) \ (((probability) >= 0.9) ? __builtin_expect(!!(expr), (expected)) : (((void) (expected)), !!(expr))) -# define NLOHMANN_JSON_HEDLEY_PREDICT_TRUE(expr, probability) \ +# define JSON_HEDLEY_PREDICT_TRUE(expr, probability) \ (__extension__ ({ \ - NLOHMANN_JSON_HEDLEY_CONSTEXPR double hedley_probability_ = (probability); \ + JSON_HEDLEY_CONSTEXPR double hedley_probability_ = (probability); \ ((hedley_probability_ >= 0.9) ? __builtin_expect(!!(expr), 1) : ((hedley_probability_ <= 0.1) ? __builtin_expect(!!(expr), 0) : !!(expr))); \ })) -# define NLOHMANN_JSON_HEDLEY_PREDICT_FALSE(expr, probability) \ +# define JSON_HEDLEY_PREDICT_FALSE(expr, probability) \ (__extension__ ({ \ - NLOHMANN_JSON_HEDLEY_CONSTEXPR double hedley_probability_ = (probability); \ + JSON_HEDLEY_CONSTEXPR double hedley_probability_ = (probability); \ ((hedley_probability_ >= 0.9) ? __builtin_expect(!!(expr), 0) : ((hedley_probability_ <= 0.1) ? __builtin_expect(!!(expr), 1) : !!(expr))); \ })) -# define NLOHMANN_JSON_HEDLEY_LIKELY(expr) __builtin_expect(!!(expr), 1) -# define NLOHMANN_JSON_HEDLEY_UNLIKELY(expr) __builtin_expect(!!(expr), 0) +# define JSON_HEDLEY_LIKELY(expr) __builtin_expect(!!(expr), 1) +# define JSON_HEDLEY_UNLIKELY(expr) __builtin_expect(!!(expr), 0) #else -# define NLOHMANN_JSON_HEDLEY_PREDICT(expr, expected, probability) (((void) (expected)), !!(expr)) -# define NLOHMANN_JSON_HEDLEY_PREDICT_TRUE(expr, probability) (!!(expr)) -# define NLOHMANN_JSON_HEDLEY_PREDICT_FALSE(expr, probability) (!!(expr)) -# define NLOHMANN_JSON_HEDLEY_LIKELY(expr) (!!(expr)) -# define NLOHMANN_JSON_HEDLEY_UNLIKELY(expr) (!!(expr)) +# define JSON_HEDLEY_PREDICT(expr, expected, probability) (((void) (expected)), !!(expr)) +# define JSON_HEDLEY_PREDICT_TRUE(expr, probability) (!!(expr)) +# define JSON_HEDLEY_PREDICT_FALSE(expr, probability) (!!(expr)) +# define JSON_HEDLEY_LIKELY(expr) (!!(expr)) +# define JSON_HEDLEY_UNLIKELY(expr) (!!(expr)) #endif -#if !defined(NLOHMANN_JSON_HEDLEY_UNPREDICTABLE) - #define NLOHMANN_JSON_HEDLEY_UNPREDICTABLE(expr) NLOHMANN_JSON_HEDLEY_PREDICT(expr, 1, 0.5) +#if !defined(JSON_HEDLEY_UNPREDICTABLE) + #define JSON_HEDLEY_UNPREDICTABLE(expr) JSON_HEDLEY_PREDICT(expr, 1, 0.5) #endif -#if defined(NLOHMANN_JSON_HEDLEY_MALLOC) - #undef NLOHMANN_JSON_HEDLEY_MALLOC +#if defined(JSON_HEDLEY_MALLOC) + #undef JSON_HEDLEY_MALLOC #endif #if \ - NLOHMANN_JSON_HEDLEY_HAS_ATTRIBUTE(malloc) || \ - NLOHMANN_JSON_HEDLEY_GCC_VERSION_CHECK(3,1,0) || \ - NLOHMANN_JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ - NLOHMANN_JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \ - NLOHMANN_JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ - NLOHMANN_JSON_HEDLEY_IBM_VERSION_CHECK(12,1,0) || \ - NLOHMANN_JSON_HEDLEY_TI_VERSION_CHECK(8,0,0) || \ - (NLOHMANN_JSON_HEDLEY_TI_VERSION_CHECK(7,3,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) - #define NLOHMANN_JSON_HEDLEY_MALLOC __attribute__((__malloc__)) -#elif NLOHMANN_JSON_HEDLEY_MSVC_VERSION_CHECK(14, 0, 0) - #define NLOHMANN_JSON_HEDLEY_MALLOC __declspec(restrict) + JSON_HEDLEY_HAS_ATTRIBUTE(malloc) || \ + JSON_HEDLEY_GCC_VERSION_CHECK(3,1,0) || \ + JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ + JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \ + JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ + JSON_HEDLEY_IBM_VERSION_CHECK(12,1,0) || \ + JSON_HEDLEY_TI_VERSION_CHECK(8,0,0) || \ + (JSON_HEDLEY_TI_VERSION_CHECK(7,3,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) + #define JSON_HEDLEY_MALLOC __attribute__((__malloc__)) +#elif JSON_HEDLEY_MSVC_VERSION_CHECK(14, 0, 0) + #define JSON_HEDLEY_MALLOC __declspec(restrict) #else - #define NLOHMANN_JSON_HEDLEY_MALLOC + #define JSON_HEDLEY_MALLOC #endif -#if defined(NLOHMANN_JSON_HEDLEY_PURE) - #undef NLOHMANN_JSON_HEDLEY_PURE +#if defined(JSON_HEDLEY_PURE) + #undef JSON_HEDLEY_PURE #endif #if \ - NLOHMANN_JSON_HEDLEY_HAS_ATTRIBUTE(pure) || \ - NLOHMANN_JSON_HEDLEY_GCC_VERSION_CHECK(2,96,0) || \ - NLOHMANN_JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ - NLOHMANN_JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \ - NLOHMANN_JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ - NLOHMANN_JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \ - NLOHMANN_JSON_HEDLEY_TI_VERSION_CHECK(8,0,0) || \ - (NLOHMANN_JSON_HEDLEY_TI_VERSION_CHECK(7,3,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ - NLOHMANN_JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) - #define NLOHMANN_JSON_HEDLEY_PURE __attribute__((__pure__)) -#elif NLOHMANN_JSON_HEDLEY_TI_VERSION_CHECK(6,0,0) && defined(__cplusplus) - #define NLOHMANN_JSON_HEDLEY_PURE _Pragma("FUNC_IS_PURE;") + JSON_HEDLEY_HAS_ATTRIBUTE(pure) || \ + JSON_HEDLEY_GCC_VERSION_CHECK(2,96,0) || \ + JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ + JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \ + JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ + JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \ + JSON_HEDLEY_TI_VERSION_CHECK(8,0,0) || \ + (JSON_HEDLEY_TI_VERSION_CHECK(7,3,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ + JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) + #define JSON_HEDLEY_PURE __attribute__((__pure__)) +#elif JSON_HEDLEY_TI_VERSION_CHECK(6,0,0) && defined(__cplusplus) + #define JSON_HEDLEY_PURE _Pragma("FUNC_IS_PURE;") #else - #define NLOHMANN_JSON_HEDLEY_PURE + #define JSON_HEDLEY_PURE #endif -#if defined(NLOHMANN_JSON_HEDLEY_CONST) - #undef NLOHMANN_JSON_HEDLEY_CONST +#if defined(JSON_HEDLEY_CONST) + #undef JSON_HEDLEY_CONST #endif #if \ - NLOHMANN_JSON_HEDLEY_HAS_ATTRIBUTE(const) || \ - NLOHMANN_JSON_HEDLEY_GCC_VERSION_CHECK(2,5,0) || \ - NLOHMANN_JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ - NLOHMANN_JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \ - NLOHMANN_JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ - NLOHMANN_JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \ - NLOHMANN_JSON_HEDLEY_TI_VERSION_CHECK(8,0,0) || \ - (NLOHMANN_JSON_HEDLEY_TI_VERSION_CHECK(7,3,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ - NLOHMANN_JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) - #define NLOHMANN_JSON_HEDLEY_CONST __attribute__((__const__)) + JSON_HEDLEY_HAS_ATTRIBUTE(const) || \ + JSON_HEDLEY_GCC_VERSION_CHECK(2,5,0) || \ + JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ + JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \ + JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ + JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \ + JSON_HEDLEY_TI_VERSION_CHECK(8,0,0) || \ + (JSON_HEDLEY_TI_VERSION_CHECK(7,3,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ + JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) + #define JSON_HEDLEY_CONST __attribute__((__const__)) #else - #define NLOHMANN_JSON_HEDLEY_CONST NLOHMANN_JSON_HEDLEY_PURE + #define JSON_HEDLEY_CONST JSON_HEDLEY_PURE #endif -#if defined(NLOHMANN_JSON_HEDLEY_RESTRICT) - #undef NLOHMANN_JSON_HEDLEY_RESTRICT +#if defined(JSON_HEDLEY_RESTRICT) + #undef JSON_HEDLEY_RESTRICT #endif #if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) && !defined(__cplusplus) - #define NLOHMANN_JSON_HEDLEY_RESTRICT restrict + #define JSON_HEDLEY_RESTRICT restrict #elif \ - NLOHMANN_JSON_HEDLEY_GCC_VERSION_CHECK(3,1,0) || \ - NLOHMANN_JSON_HEDLEY_MSVC_VERSION_CHECK(14,0,0) || \ - NLOHMANN_JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ - NLOHMANN_JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ - NLOHMANN_JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \ - NLOHMANN_JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) || \ - NLOHMANN_JSON_HEDLEY_TI_VERSION_CHECK(8,0,0) || \ - (NLOHMANN_JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,14,0) && defined(__cplusplus)) || \ - NLOHMANN_JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0) || \ + JSON_HEDLEY_GCC_VERSION_CHECK(3,1,0) || \ + JSON_HEDLEY_MSVC_VERSION_CHECK(14,0,0) || \ + JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ + JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ + JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \ + JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) || \ + JSON_HEDLEY_TI_VERSION_CHECK(8,0,0) || \ + (JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,14,0) && defined(__cplusplus)) || \ + JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0) || \ defined(__clang__) - #define NLOHMANN_JSON_HEDLEY_RESTRICT __restrict -#elif NLOHMANN_JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,3,0) && !defined(__cplusplus) - #define NLOHMANN_JSON_HEDLEY_RESTRICT _Restrict + #define JSON_HEDLEY_RESTRICT __restrict +#elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,3,0) && !defined(__cplusplus) + #define JSON_HEDLEY_RESTRICT _Restrict #else - #define NLOHMANN_JSON_HEDLEY_RESTRICT + #define JSON_HEDLEY_RESTRICT #endif -#if defined(NLOHMANN_JSON_HEDLEY_INLINE) - #undef NLOHMANN_JSON_HEDLEY_INLINE +#if defined(JSON_HEDLEY_INLINE) + #undef JSON_HEDLEY_INLINE #endif #if \ (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)) || \ (defined(__cplusplus) && (__cplusplus >= 199711L)) - #define NLOHMANN_JSON_HEDLEY_INLINE inline + #define JSON_HEDLEY_INLINE inline #elif \ - defined(NLOHMANN_JSON_HEDLEY_GCC_VERSION) || \ - NLOHMANN_JSON_HEDLEY_ARM_VERSION_CHECK(6,2,0) - #define NLOHMANN_JSON_HEDLEY_INLINE __inline__ + defined(JSON_HEDLEY_GCC_VERSION) || \ + JSON_HEDLEY_ARM_VERSION_CHECK(6,2,0) + #define JSON_HEDLEY_INLINE __inline__ #elif \ - NLOHMANN_JSON_HEDLEY_MSVC_VERSION_CHECK(12,0,0) || \ - NLOHMANN_JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ - NLOHMANN_JSON_HEDLEY_TI_VERSION_CHECK(8,0,0) - #define NLOHMANN_JSON_HEDLEY_INLINE __inline + JSON_HEDLEY_MSVC_VERSION_CHECK(12,0,0) || \ + JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ + JSON_HEDLEY_TI_VERSION_CHECK(8,0,0) + #define JSON_HEDLEY_INLINE __inline #else - #define NLOHMANN_JSON_HEDLEY_INLINE + #define JSON_HEDLEY_INLINE #endif -#if defined(NLOHMANN_JSON_HEDLEY_ALWAYS_INLINE) - #undef NLOHMANN_JSON_HEDLEY_ALWAYS_INLINE +#if defined(JSON_HEDLEY_ALWAYS_INLINE) + #undef JSON_HEDLEY_ALWAYS_INLINE #endif #if \ - NLOHMANN_JSON_HEDLEY_HAS_ATTRIBUTE(always_inline) || \ - NLOHMANN_JSON_HEDLEY_GCC_VERSION_CHECK(4,0,0) || \ - NLOHMANN_JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ - NLOHMANN_JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \ - NLOHMANN_JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ - NLOHMANN_JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \ - NLOHMANN_JSON_HEDLEY_TI_VERSION_CHECK(8,0,0) || \ - (NLOHMANN_JSON_HEDLEY_TI_VERSION_CHECK(7,3,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) - #define NLOHMANN_JSON_HEDLEY_ALWAYS_INLINE __attribute__((__always_inline__)) NLOHMANN_JSON_HEDLEY_INLINE -#elif NLOHMANN_JSON_HEDLEY_MSVC_VERSION_CHECK(12,0,0) - #define NLOHMANN_JSON_HEDLEY_ALWAYS_INLINE __forceinline -#elif NLOHMANN_JSON_HEDLEY_TI_VERSION_CHECK(7,0,0) && defined(__cplusplus) - #define NLOHMANN_JSON_HEDLEY_ALWAYS_INLINE _Pragma("FUNC_ALWAYS_INLINE;") -#elif NLOHMANN_JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0) - #define NLOHMANN_JSON_HEDLEY_ALWAYS_INLINE _Pragma("inline=forced") + JSON_HEDLEY_HAS_ATTRIBUTE(always_inline) || \ + JSON_HEDLEY_GCC_VERSION_CHECK(4,0,0) || \ + JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ + JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \ + JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ + JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \ + JSON_HEDLEY_TI_VERSION_CHECK(8,0,0) || \ + (JSON_HEDLEY_TI_VERSION_CHECK(7,3,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) + #define JSON_HEDLEY_ALWAYS_INLINE __attribute__((__always_inline__)) JSON_HEDLEY_INLINE +#elif JSON_HEDLEY_MSVC_VERSION_CHECK(12,0,0) + #define JSON_HEDLEY_ALWAYS_INLINE __forceinline +#elif JSON_HEDLEY_TI_VERSION_CHECK(7,0,0) && defined(__cplusplus) + #define JSON_HEDLEY_ALWAYS_INLINE _Pragma("FUNC_ALWAYS_INLINE;") +#elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0) + #define JSON_HEDLEY_ALWAYS_INLINE _Pragma("inline=forced") #else - #define NLOHMANN_JSON_HEDLEY_ALWAYS_INLINE NLOHMANN_JSON_HEDLEY_INLINE + #define JSON_HEDLEY_ALWAYS_INLINE JSON_HEDLEY_INLINE #endif -#if defined(NLOHMANN_JSON_HEDLEY_NEVER_INLINE) - #undef NLOHMANN_JSON_HEDLEY_NEVER_INLINE +#if defined(JSON_HEDLEY_NEVER_INLINE) + #undef JSON_HEDLEY_NEVER_INLINE #endif #if \ - NLOHMANN_JSON_HEDLEY_HAS_ATTRIBUTE(noinline) || \ - NLOHMANN_JSON_HEDLEY_GCC_VERSION_CHECK(4,0,0) || \ - NLOHMANN_JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ - NLOHMANN_JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \ - NLOHMANN_JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ - NLOHMANN_JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \ - NLOHMANN_JSON_HEDLEY_TI_VERSION_CHECK(8,0,0) || \ - (NLOHMANN_JSON_HEDLEY_TI_VERSION_CHECK(7,3,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) - #define NLOHMANN_JSON_HEDLEY_NEVER_INLINE __attribute__((__noinline__)) -#elif NLOHMANN_JSON_HEDLEY_MSVC_VERSION_CHECK(13,10,0) - #define NLOHMANN_JSON_HEDLEY_NEVER_INLINE __declspec(noinline) -#elif NLOHMANN_JSON_HEDLEY_PGI_VERSION_CHECK(10,2,0) - #define NLOHMANN_JSON_HEDLEY_NEVER_INLINE _Pragma("noinline") -#elif NLOHMANN_JSON_HEDLEY_TI_VERSION_CHECK(6,0,0) && defined(__cplusplus) - #define NLOHMANN_JSON_HEDLEY_NEVER_INLINE _Pragma("FUNC_CANNOT_INLINE;") -#elif NLOHMANN_JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0) - #define NLOHMANN_JSON_HEDLEY_NEVER_INLINE _Pragma("inline=never") -#elif NLOHMANN_JSON_HEDLEY_COMPCERT_VERSION_CHECK(3,2,0) - #define NLOHMANN_JSON_HEDLEY_NEVER_INLINE __attribute((noinline)) -#elif NLOHMANN_JSON_HEDLEY_PELLES_VERSION_CHECK(9,0,0) - #define NLOHMANN_JSON_HEDLEY_NEVER_INLINE __declspec(noinline) + JSON_HEDLEY_HAS_ATTRIBUTE(noinline) || \ + JSON_HEDLEY_GCC_VERSION_CHECK(4,0,0) || \ + JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ + JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \ + JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ + JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \ + JSON_HEDLEY_TI_VERSION_CHECK(8,0,0) || \ + (JSON_HEDLEY_TI_VERSION_CHECK(7,3,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) + #define JSON_HEDLEY_NEVER_INLINE __attribute__((__noinline__)) +#elif JSON_HEDLEY_MSVC_VERSION_CHECK(13,10,0) + #define JSON_HEDLEY_NEVER_INLINE __declspec(noinline) +#elif JSON_HEDLEY_PGI_VERSION_CHECK(10,2,0) + #define JSON_HEDLEY_NEVER_INLINE _Pragma("noinline") +#elif JSON_HEDLEY_TI_VERSION_CHECK(6,0,0) && defined(__cplusplus) + #define JSON_HEDLEY_NEVER_INLINE _Pragma("FUNC_CANNOT_INLINE;") +#elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0) + #define JSON_HEDLEY_NEVER_INLINE _Pragma("inline=never") +#elif JSON_HEDLEY_COMPCERT_VERSION_CHECK(3,2,0) + #define JSON_HEDLEY_NEVER_INLINE __attribute((noinline)) +#elif JSON_HEDLEY_PELLES_VERSION_CHECK(9,0,0) + #define JSON_HEDLEY_NEVER_INLINE __declspec(noinline) #else - #define NLOHMANN_JSON_HEDLEY_NEVER_INLINE + #define JSON_HEDLEY_NEVER_INLINE #endif -#if defined(NLOHMANN_JSON_HEDLEY_PRIVATE) - #undef NLOHMANN_JSON_HEDLEY_PRIVATE +#if defined(JSON_HEDLEY_PRIVATE) + #undef JSON_HEDLEY_PRIVATE #endif -#if defined(NLOHMANN_JSON_HEDLEY_PUBLIC) - #undef NLOHMANN_JSON_HEDLEY_PUBLIC +#if defined(JSON_HEDLEY_PUBLIC) + #undef JSON_HEDLEY_PUBLIC #endif -#if defined(NLOHMANN_JSON_HEDLEY_IMPORT) - #undef NLOHMANN_JSON_HEDLEY_IMPORT +#if defined(JSON_HEDLEY_IMPORT) + #undef JSON_HEDLEY_IMPORT #endif #if defined(_WIN32) || defined(__CYGWIN__) - #define NLOHMANN_JSON_HEDLEY_PRIVATE - #define NLOHMANN_JSON_HEDLEY_PUBLIC __declspec(dllexport) - #define NLOHMANN_JSON_HEDLEY_IMPORT __declspec(dllimport) + #define JSON_HEDLEY_PRIVATE + #define JSON_HEDLEY_PUBLIC __declspec(dllexport) + #define JSON_HEDLEY_IMPORT __declspec(dllimport) #else #if \ - NLOHMANN_JSON_HEDLEY_HAS_ATTRIBUTE(visibility) || \ - NLOHMANN_JSON_HEDLEY_GCC_VERSION_CHECK(3,3,0) || \ - NLOHMANN_JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \ - NLOHMANN_JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ - NLOHMANN_JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ - NLOHMANN_JSON_HEDLEY_IBM_VERSION_CHECK(13,1,0) || \ - NLOHMANN_JSON_HEDLEY_TI_VERSION_CHECK(8,0,0) || \ - (NLOHMANN_JSON_HEDLEY_TI_VERSION_CHECK(7,3,0) && defined(__TI_EABI__) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) - #define NLOHMANN_JSON_HEDLEY_PRIVATE __attribute__((__visibility__("hidden"))) - #define NLOHMANN_JSON_HEDLEY_PUBLIC __attribute__((__visibility__("default"))) + JSON_HEDLEY_HAS_ATTRIBUTE(visibility) || \ + JSON_HEDLEY_GCC_VERSION_CHECK(3,3,0) || \ + JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \ + JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ + JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ + JSON_HEDLEY_IBM_VERSION_CHECK(13,1,0) || \ + JSON_HEDLEY_TI_VERSION_CHECK(8,0,0) || \ + (JSON_HEDLEY_TI_VERSION_CHECK(7,3,0) && defined(__TI_EABI__) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) + #define JSON_HEDLEY_PRIVATE __attribute__((__visibility__("hidden"))) + #define JSON_HEDLEY_PUBLIC __attribute__((__visibility__("default"))) #else - #define NLOHMANN_JSON_HEDLEY_PRIVATE - #define NLOHMANN_JSON_HEDLEY_PUBLIC + #define JSON_HEDLEY_PRIVATE + #define JSON_HEDLEY_PUBLIC #endif - #define NLOHMANN_JSON_HEDLEY_IMPORT extern + #define JSON_HEDLEY_IMPORT extern #endif -#if defined(NLOHMANN_JSON_HEDLEY_NO_THROW) - #undef NLOHMANN_JSON_HEDLEY_NO_THROW +#if defined(JSON_HEDLEY_NO_THROW) + #undef JSON_HEDLEY_NO_THROW #endif #if \ - NLOHMANN_JSON_HEDLEY_HAS_ATTRIBUTE(nothrow) || \ - NLOHMANN_JSON_HEDLEY_GCC_VERSION_CHECK(3,3,0) || \ - NLOHMANN_JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) - #define NLOHMANN_JSON_HEDLEY_NO_THROW __attribute__((__nothrow__)) + JSON_HEDLEY_HAS_ATTRIBUTE(nothrow) || \ + JSON_HEDLEY_GCC_VERSION_CHECK(3,3,0) || \ + JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) + #define JSON_HEDLEY_NO_THROW __attribute__((__nothrow__)) #elif \ - NLOHMANN_JSON_HEDLEY_MSVC_VERSION_CHECK(13,1,0) || \ - NLOHMANN_JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) - #define NLOHMANN_JSON_HEDLEY_NO_THROW __declspec(nothrow) + JSON_HEDLEY_MSVC_VERSION_CHECK(13,1,0) || \ + JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) + #define JSON_HEDLEY_NO_THROW __declspec(nothrow) #else - #define NLOHMANN_JSON_HEDLEY_NO_THROW + #define JSON_HEDLEY_NO_THROW #endif -#if defined(NLOHMANN_JSON_HEDLEY_FALL_THROUGH) - #undef NLOHMANN_JSON_HEDLEY_FALL_THROUGH +#if defined(JSON_HEDLEY_FALL_THROUGH) + #undef JSON_HEDLEY_FALL_THROUGH #endif #if \ defined(__cplusplus) && \ - (!defined(NLOHMANN_JSON_HEDLEY_SUNPRO_VERSION) || NLOHMANN_JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,15,0)) && \ - !defined(NLOHMANN_JSON_HEDLEY_PGI_VERSION) + (!defined(JSON_HEDLEY_SUNPRO_VERSION) || JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,15,0)) && \ + !defined(JSON_HEDLEY_PGI_VERSION) #if \ (__cplusplus >= 201703L) || \ - ((__cplusplus >= 201103L) && NLOHMANN_JSON_HEDLEY_HAS_CPP_ATTRIBUTE(fallthrough)) - #define NLOHMANN_JSON_HEDLEY_FALL_THROUGH [[fallthrough]] - #elif (__cplusplus >= 201103L) && NLOHMANN_JSON_HEDLEY_HAS_CPP_ATTRIBUTE(clang::fallthrough) - #define NLOHMANN_JSON_HEDLEY_FALL_THROUGH [[clang::fallthrough]] - #elif (__cplusplus >= 201103L) && NLOHMANN_JSON_HEDLEY_GCC_VERSION_CHECK(7,0,0) - #define NLOHMANN_JSON_HEDLEY_FALL_THROUGH [[gnu::fallthrough]] + ((__cplusplus >= 201103L) && JSON_HEDLEY_HAS_CPP_ATTRIBUTE(fallthrough)) + #define JSON_HEDLEY_FALL_THROUGH [[fallthrough]] + #elif (__cplusplus >= 201103L) && JSON_HEDLEY_HAS_CPP_ATTRIBUTE(clang::fallthrough) + #define JSON_HEDLEY_FALL_THROUGH [[clang::fallthrough]] + #elif (__cplusplus >= 201103L) && JSON_HEDLEY_GCC_VERSION_CHECK(7,0,0) + #define JSON_HEDLEY_FALL_THROUGH [[gnu::fallthrough]] #endif #endif -#if !defined(NLOHMANN_JSON_HEDLEY_FALL_THROUGH) - #if NLOHMANN_JSON_HEDLEY_GNUC_HAS_ATTRIBUTE(fallthrough,7,0,0) && !defined(NLOHMANN_JSON_HEDLEY_PGI_VERSION) - #define NLOHMANN_JSON_HEDLEY_FALL_THROUGH __attribute__((__fallthrough__)) +#if !defined(JSON_HEDLEY_FALL_THROUGH) + #if JSON_HEDLEY_GNUC_HAS_ATTRIBUTE(fallthrough,7,0,0) && !defined(JSON_HEDLEY_PGI_VERSION) + #define JSON_HEDLEY_FALL_THROUGH __attribute__((__fallthrough__)) #elif defined(__fallthrough) /* SAL */ - #define NLOHMANN_JSON_HEDLEY_FALL_THROUGH __fallthrough + #define JSON_HEDLEY_FALL_THROUGH __fallthrough #else - #define NLOHMANN_JSON_HEDLEY_FALL_THROUGH + #define JSON_HEDLEY_FALL_THROUGH #endif #endif -#if defined(NLOHMANN_JSON_HEDLEY_RETURNS_NON_NULL) - #undef NLOHMANN_JSON_HEDLEY_RETURNS_NON_NULL +#if defined(JSON_HEDLEY_RETURNS_NON_NULL) + #undef JSON_HEDLEY_RETURNS_NON_NULL #endif #if \ - NLOHMANN_JSON_HEDLEY_HAS_ATTRIBUTE(returns_nonnull) || \ - NLOHMANN_JSON_HEDLEY_GCC_VERSION_CHECK(4,9,0) - #define NLOHMANN_JSON_HEDLEY_RETURNS_NON_NULL __attribute__((__returns_nonnull__)) + JSON_HEDLEY_HAS_ATTRIBUTE(returns_nonnull) || \ + JSON_HEDLEY_GCC_VERSION_CHECK(4,9,0) + #define JSON_HEDLEY_RETURNS_NON_NULL __attribute__((__returns_nonnull__)) #elif defined(_Ret_notnull_) /* SAL */ - #define NLOHMANN_JSON_HEDLEY_RETURNS_NON_NULL _Ret_notnull_ + #define JSON_HEDLEY_RETURNS_NON_NULL _Ret_notnull_ #else - #define NLOHMANN_JSON_HEDLEY_RETURNS_NON_NULL + #define JSON_HEDLEY_RETURNS_NON_NULL #endif -#if defined(NLOHMANN_JSON_HEDLEY_ARRAY_PARAM) - #undef NLOHMANN_JSON_HEDLEY_ARRAY_PARAM +#if defined(JSON_HEDLEY_ARRAY_PARAM) + #undef JSON_HEDLEY_ARRAY_PARAM #endif #if \ defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) && \ !defined(__STDC_NO_VLA__) && \ !defined(__cplusplus) && \ - !defined(NLOHMANN_JSON_HEDLEY_PGI_VERSION) && \ - !defined(NLOHMANN_JSON_HEDLEY_TINYC_VERSION) - #define NLOHMANN_JSON_HEDLEY_ARRAY_PARAM(name) (name) + !defined(JSON_HEDLEY_PGI_VERSION) && \ + !defined(JSON_HEDLEY_TINYC_VERSION) + #define JSON_HEDLEY_ARRAY_PARAM(name) (name) #else - #define NLOHMANN_JSON_HEDLEY_ARRAY_PARAM(name) + #define JSON_HEDLEY_ARRAY_PARAM(name) #endif -#if defined(NLOHMANN_JSON_HEDLEY_IS_CONSTANT) - #undef NLOHMANN_JSON_HEDLEY_IS_CONSTANT +#if defined(JSON_HEDLEY_IS_CONSTANT) + #undef JSON_HEDLEY_IS_CONSTANT #endif -#if defined(NLOHMANN_JSON_HEDLEY_REQUIRE_CONSTEXPR) - #undef NLOHMANN_JSON_HEDLEY_REQUIRE_CONSTEXPR +#if defined(JSON_HEDLEY_REQUIRE_CONSTEXPR) + #undef JSON_HEDLEY_REQUIRE_CONSTEXPR #endif /* Note the double-underscore. For internal use only; no API * guarantees! */ -#if defined(NLOHMANN_JSON_HEDLEY__IS_CONSTEXPR) - #undef NLOHMANN_JSON_HEDLEY__IS_CONSTEXPR +#if defined(JSON_HEDLEY__IS_CONSTEXPR) + #undef JSON_HEDLEY__IS_CONSTEXPR #endif #if \ - NLOHMANN_JSON_HEDLEY_HAS_BUILTIN(__builtin_constant_p) || \ - NLOHMANN_JSON_HEDLEY_GCC_VERSION_CHECK(3,4,0) || \ - NLOHMANN_JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ - NLOHMANN_JSON_HEDLEY_TINYC_VERSION_CHECK(0,9,19) || \ - NLOHMANN_JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ - NLOHMANN_JSON_HEDLEY_IBM_VERSION_CHECK(13,1,0) || \ - NLOHMANN_JSON_HEDLEY_TI_VERSION_CHECK(6,1,0) || \ - NLOHMANN_JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,10,0) || \ - NLOHMANN_JSON_HEDLEY_CRAY_VERSION_CHECK(8,1,0) - #define NLOHMANN_JSON_HEDLEY_IS_CONSTANT(expr) __builtin_constant_p(expr) + JSON_HEDLEY_HAS_BUILTIN(__builtin_constant_p) || \ + JSON_HEDLEY_GCC_VERSION_CHECK(3,4,0) || \ + JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ + JSON_HEDLEY_TINYC_VERSION_CHECK(0,9,19) || \ + JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ + JSON_HEDLEY_IBM_VERSION_CHECK(13,1,0) || \ + JSON_HEDLEY_TI_VERSION_CHECK(6,1,0) || \ + JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,10,0) || \ + JSON_HEDLEY_CRAY_VERSION_CHECK(8,1,0) + #define JSON_HEDLEY_IS_CONSTANT(expr) __builtin_constant_p(expr) #endif #if !defined(__cplusplus) # if \ - NLOHMANN_JSON_HEDLEY_HAS_BUILTIN(__builtin_types_compatible_p) || \ - NLOHMANN_JSON_HEDLEY_GCC_VERSION_CHECK(3,4,0) || \ - NLOHMANN_JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ - NLOHMANN_JSON_HEDLEY_IBM_VERSION_CHECK(13,1,0) || \ - NLOHMANN_JSON_HEDLEY_CRAY_VERSION_CHECK(8,1,0) || \ - NLOHMANN_JSON_HEDLEY_ARM_VERSION_CHECK(5,4,0) || \ - NLOHMANN_JSON_HEDLEY_TINYC_VERSION_CHECK(0,9,24) + JSON_HEDLEY_HAS_BUILTIN(__builtin_types_compatible_p) || \ + JSON_HEDLEY_GCC_VERSION_CHECK(3,4,0) || \ + JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ + JSON_HEDLEY_IBM_VERSION_CHECK(13,1,0) || \ + JSON_HEDLEY_CRAY_VERSION_CHECK(8,1,0) || \ + JSON_HEDLEY_ARM_VERSION_CHECK(5,4,0) || \ + JSON_HEDLEY_TINYC_VERSION_CHECK(0,9,24) #if defined(__INTPTR_TYPE__) - #define NLOHMANN_JSON_HEDLEY__IS_CONSTEXPR(expr) __builtin_types_compatible_p(__typeof__((1 ? (void*) ((__INTPTR_TYPE__) ((expr) * 0)) : (int*) 0)), int*) + #define JSON_HEDLEY__IS_CONSTEXPR(expr) __builtin_types_compatible_p(__typeof__((1 ? (void*) ((__INTPTR_TYPE__) ((expr) * 0)) : (int*) 0)), int*) #else #include - #define NLOHMANN_JSON_HEDLEY__IS_CONSTEXPR(expr) __builtin_types_compatible_p(__typeof__((1 ? (void*) ((intptr_t) ((expr) * 0)) : (int*) 0)), int*) + #define JSON_HEDLEY__IS_CONSTEXPR(expr) __builtin_types_compatible_p(__typeof__((1 ? (void*) ((intptr_t) ((expr) * 0)) : (int*) 0)), int*) #endif # elif \ - (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 201112L) && !defined(NLOHMANN_JSON_HEDLEY_SUNPRO_VERSION) && !defined(NLOHMANN_JSON_HEDLEY_PGI_VERSION)) || \ - NLOHMANN_JSON_HEDLEY_HAS_EXTENSION(c_generic_selections) || \ - NLOHMANN_JSON_HEDLEY_GCC_VERSION_CHECK(4,9,0) || \ - NLOHMANN_JSON_HEDLEY_INTEL_VERSION_CHECK(17,0,0) || \ - NLOHMANN_JSON_HEDLEY_IBM_VERSION_CHECK(12,1,0) || \ - NLOHMANN_JSON_HEDLEY_ARM_VERSION_CHECK(5,3,0) + (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 201112L) && !defined(JSON_HEDLEY_SUNPRO_VERSION) && !defined(JSON_HEDLEY_PGI_VERSION)) || \ + JSON_HEDLEY_HAS_EXTENSION(c_generic_selections) || \ + JSON_HEDLEY_GCC_VERSION_CHECK(4,9,0) || \ + JSON_HEDLEY_INTEL_VERSION_CHECK(17,0,0) || \ + JSON_HEDLEY_IBM_VERSION_CHECK(12,1,0) || \ + JSON_HEDLEY_ARM_VERSION_CHECK(5,3,0) #if defined(__INTPTR_TYPE__) - #define NLOHMANN_JSON_HEDLEY__IS_CONSTEXPR(expr) _Generic((1 ? (void*) ((__INTPTR_TYPE__) ((expr) * 0)) : (int*) 0), int*: 1, void*: 0) + #define JSON_HEDLEY__IS_CONSTEXPR(expr) _Generic((1 ? (void*) ((__INTPTR_TYPE__) ((expr) * 0)) : (int*) 0), int*: 1, void*: 0) #else #include - #define NLOHMANN_JSON_HEDLEY__IS_CONSTEXPR(expr) _Generic((1 ? (void*) ((intptr_t) * 0) : (int*) 0), int*: 1, void*: 0) + #define JSON_HEDLEY__IS_CONSTEXPR(expr) _Generic((1 ? (void*) ((intptr_t) * 0) : (int*) 0), int*: 1, void*: 0) #endif # elif \ - defined(NLOHMANN_JSON_HEDLEY_GCC_VERSION) || \ - defined(NLOHMANN_JSON_HEDLEY_INTEL_VERSION) || \ - defined(NLOHMANN_JSON_HEDLEY_TINYC_VERSION) || \ - defined(NLOHMANN_JSON_HEDLEY_TI_VERSION) || \ + defined(JSON_HEDLEY_GCC_VERSION) || \ + defined(JSON_HEDLEY_INTEL_VERSION) || \ + defined(JSON_HEDLEY_TINYC_VERSION) || \ + defined(JSON_HEDLEY_TI_VERSION) || \ defined(__clang__) -# define NLOHMANN_JSON_HEDLEY__IS_CONSTEXPR(expr) ( \ +# define JSON_HEDLEY__IS_CONSTEXPR(expr) ( \ sizeof(void) != \ sizeof(*( \ 1 ? \ @@ -1268,238 +1268,238 @@ NLOHMANN_JSON_HEDLEY_DIAGNOSTIC_POP ((struct { char v[sizeof(void) * 2]; } *) 1) \ ) \ ) \ - ) + ) # endif #endif -#if defined(NLOHMANN_JSON_HEDLEY__IS_CONSTEXPR) - #if !defined(NLOHMANN_JSON_HEDLEY_IS_CONSTANT) - #define NLOHMANN_JSON_HEDLEY_IS_CONSTANT(expr) NLOHMANN_JSON_HEDLEY__IS_CONSTEXPR(expr) +#if defined(JSON_HEDLEY__IS_CONSTEXPR) + #if !defined(JSON_HEDLEY_IS_CONSTANT) + #define JSON_HEDLEY_IS_CONSTANT(expr) JSON_HEDLEY__IS_CONSTEXPR(expr) #endif - #define NLOHMANN_JSON_HEDLEY_REQUIRE_CONSTEXPR(expr) (NLOHMANN_JSON_HEDLEY__IS_CONSTEXPR(expr) ? (expr) : (-1)) + #define JSON_HEDLEY_REQUIRE_CONSTEXPR(expr) (JSON_HEDLEY__IS_CONSTEXPR(expr) ? (expr) : (-1)) #else - #if !defined(NLOHMANN_JSON_HEDLEY_IS_CONSTANT) - #define NLOHMANN_JSON_HEDLEY_IS_CONSTANT(expr) (0) + #if !defined(JSON_HEDLEY_IS_CONSTANT) + #define JSON_HEDLEY_IS_CONSTANT(expr) (0) #endif - #define NLOHMANN_JSON_HEDLEY_REQUIRE_CONSTEXPR(expr) (expr) + #define JSON_HEDLEY_REQUIRE_CONSTEXPR(expr) (expr) #endif -#if defined(NLOHMANN_JSON_HEDLEY_BEGIN_C_DECLS) - #undef NLOHMANN_JSON_HEDLEY_BEGIN_C_DECLS +#if defined(JSON_HEDLEY_BEGIN_C_DECLS) + #undef JSON_HEDLEY_BEGIN_C_DECLS #endif -#if defined(NLOHMANN_JSON_HEDLEY_END_C_DECLS) - #undef NLOHMANN_JSON_HEDLEY_END_C_DECLS +#if defined(JSON_HEDLEY_END_C_DECLS) + #undef JSON_HEDLEY_END_C_DECLS #endif -#if defined(NLOHMANN_JSON_HEDLEY_C_DECL) - #undef NLOHMANN_JSON_HEDLEY_C_DECL +#if defined(JSON_HEDLEY_C_DECL) + #undef JSON_HEDLEY_C_DECL #endif #if defined(__cplusplus) - #define NLOHMANN_JSON_HEDLEY_BEGIN_C_DECLS extern "C" { - #define NLOHMANN_JSON_HEDLEY_END_C_DECLS } - #define NLOHMANN_JSON_HEDLEY_C_DECL extern "C" + #define JSON_HEDLEY_BEGIN_C_DECLS extern "C" { + #define JSON_HEDLEY_END_C_DECLS } + #define JSON_HEDLEY_C_DECL extern "C" #else - #define NLOHMANN_JSON_HEDLEY_BEGIN_C_DECLS - #define NLOHMANN_JSON_HEDLEY_END_C_DECLS - #define NLOHMANN_JSON_HEDLEY_C_DECL + #define JSON_HEDLEY_BEGIN_C_DECLS + #define JSON_HEDLEY_END_C_DECLS + #define JSON_HEDLEY_C_DECL #endif -#if defined(NLOHMANN_JSON_HEDLEY_STATIC_ASSERT) - #undef NLOHMANN_JSON_HEDLEY_STATIC_ASSERT +#if defined(JSON_HEDLEY_STATIC_ASSERT) + #undef JSON_HEDLEY_STATIC_ASSERT #endif #if \ !defined(__cplusplus) && ( \ (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 201112L)) || \ - NLOHMANN_JSON_HEDLEY_HAS_FEATURE(c_static_assert) || \ - NLOHMANN_JSON_HEDLEY_GCC_VERSION_CHECK(6,0,0) || \ - NLOHMANN_JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ + JSON_HEDLEY_HAS_FEATURE(c_static_assert) || \ + JSON_HEDLEY_GCC_VERSION_CHECK(6,0,0) || \ + JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ defined(_Static_assert) \ ) -# define NLOHMANN_JSON_HEDLEY_STATIC_ASSERT(expr, message) _Static_assert(expr, message) +# define JSON_HEDLEY_STATIC_ASSERT(expr, message) _Static_assert(expr, message) #elif \ (defined(__cplusplus) && (__cplusplus >= 201703L)) || \ - NLOHMANN_JSON_HEDLEY_MSVC_VERSION_CHECK(16,0,0) || \ - (defined(__cplusplus) && NLOHMANN_JSON_HEDLEY_TI_VERSION_CHECK(8,3,0)) -# define NLOHMANN_JSON_HEDLEY_STATIC_ASSERT(expr, message) static_assert(expr, message) + JSON_HEDLEY_MSVC_VERSION_CHECK(16,0,0) || \ + (defined(__cplusplus) && JSON_HEDLEY_TI_VERSION_CHECK(8,3,0)) +# define JSON_HEDLEY_STATIC_ASSERT(expr, message) static_assert(expr, message) #elif defined(__cplusplus) && (__cplusplus >= 201103L) -# define NLOHMANN_JSON_HEDLEY_STATIC_ASSERT(expr, message) static_assert(expr) +# define JSON_HEDLEY_STATIC_ASSERT(expr, message) static_assert(expr) #else -# define NLOHMANN_JSON_HEDLEY_STATIC_ASSERT(expr, message) +# define JSON_HEDLEY_STATIC_ASSERT(expr, message) #endif -#if defined(NLOHMANN_JSON_HEDLEY_CONST_CAST) - #undef NLOHMANN_JSON_HEDLEY_CONST_CAST +#if defined(JSON_HEDLEY_CONST_CAST) + #undef JSON_HEDLEY_CONST_CAST #endif #if defined(__cplusplus) -# define NLOHMANN_JSON_HEDLEY_CONST_CAST(T, expr) (const_cast(expr)) +# define JSON_HEDLEY_CONST_CAST(T, expr) (const_cast(expr)) #elif \ - NLOHMANN_JSON_HEDLEY_HAS_WARNING("-Wcast-qual") || \ - NLOHMANN_JSON_HEDLEY_GCC_VERSION_CHECK(4,6,0) || \ - NLOHMANN_JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) -# define NLOHMANN_JSON_HEDLEY_CONST_CAST(T, expr) (__extension__ ({ \ - NLOHMANN_JSON_HEDLEY_DIAGNOSTIC_PUSH \ - NLOHMANN_JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL \ + JSON_HEDLEY_HAS_WARNING("-Wcast-qual") || \ + JSON_HEDLEY_GCC_VERSION_CHECK(4,6,0) || \ + JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) +# define JSON_HEDLEY_CONST_CAST(T, expr) (__extension__ ({ \ + JSON_HEDLEY_DIAGNOSTIC_PUSH \ + JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL \ ((T) (expr)); \ - NLOHMANN_JSON_HEDLEY_DIAGNOSTIC_POP \ + JSON_HEDLEY_DIAGNOSTIC_POP \ })) #else -# define NLOHMANN_JSON_HEDLEY_CONST_CAST(T, expr) ((T) (expr)) +# define JSON_HEDLEY_CONST_CAST(T, expr) ((T) (expr)) #endif -#if defined(NLOHMANN_JSON_HEDLEY_REINTERPRET_CAST) - #undef NLOHMANN_JSON_HEDLEY_REINTERPRET_CAST +#if defined(JSON_HEDLEY_REINTERPRET_CAST) + #undef JSON_HEDLEY_REINTERPRET_CAST #endif #if defined(__cplusplus) - #define NLOHMANN_JSON_HEDLEY_REINTERPRET_CAST(T, expr) (reinterpret_cast(expr)) + #define JSON_HEDLEY_REINTERPRET_CAST(T, expr) (reinterpret_cast(expr)) #else - #define NLOHMANN_JSON_HEDLEY_REINTERPRET_CAST(T, expr) (*((T*) &(expr))) + #define JSON_HEDLEY_REINTERPRET_CAST(T, expr) (*((T*) &(expr))) #endif -#if defined(NLOHMANN_JSON_HEDLEY_STATIC_CAST) - #undef NLOHMANN_JSON_HEDLEY_STATIC_CAST +#if defined(JSON_HEDLEY_STATIC_CAST) + #undef JSON_HEDLEY_STATIC_CAST #endif #if defined(__cplusplus) - #define NLOHMANN_JSON_HEDLEY_STATIC_CAST(T, expr) (static_cast(expr)) + #define JSON_HEDLEY_STATIC_CAST(T, expr) (static_cast(expr)) #else - #define NLOHMANN_JSON_HEDLEY_STATIC_CAST(T, expr) ((T) (expr)) + #define JSON_HEDLEY_STATIC_CAST(T, expr) ((T) (expr)) #endif -#if defined(NLOHMANN_JSON_HEDLEY_CPP_CAST) - #undef NLOHMANN_JSON_HEDLEY_CPP_CAST +#if defined(JSON_HEDLEY_CPP_CAST) + #undef JSON_HEDLEY_CPP_CAST #endif #if defined(__cplusplus) - #define NLOHMANN_JSON_HEDLEY_CPP_CAST(T, expr) static_cast(expr) + #define JSON_HEDLEY_CPP_CAST(T, expr) static_cast(expr) #else - #define NLOHMANN_JSON_HEDLEY_CPP_CAST(T, expr) (expr) + #define JSON_HEDLEY_CPP_CAST(T, expr) (expr) #endif -#if defined(NLOHMANN_JSON_HEDLEY_MESSAGE) - #undef NLOHMANN_JSON_HEDLEY_MESSAGE +#if defined(JSON_HEDLEY_MESSAGE) + #undef JSON_HEDLEY_MESSAGE #endif -#if NLOHMANN_JSON_HEDLEY_HAS_WARNING("-Wunknown-pragmas") -# define NLOHMANN_JSON_HEDLEY_MESSAGE(msg) \ - NLOHMANN_JSON_HEDLEY_DIAGNOSTIC_PUSH \ - NLOHMANN_JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS \ - NLOHMANN_JSON_HEDLEY_PRAGMA(message msg) \ - NLOHMANN_JSON_HEDLEY_DIAGNOSTIC_POP +#if JSON_HEDLEY_HAS_WARNING("-Wunknown-pragmas") +# define JSON_HEDLEY_MESSAGE(msg) \ + JSON_HEDLEY_DIAGNOSTIC_PUSH \ + JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS \ + JSON_HEDLEY_PRAGMA(message msg) \ + JSON_HEDLEY_DIAGNOSTIC_POP #elif \ - NLOHMANN_JSON_HEDLEY_GCC_VERSION_CHECK(4,4,0) || \ - NLOHMANN_JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) -# define NLOHMANN_JSON_HEDLEY_MESSAGE(msg) NLOHMANN_JSON_HEDLEY_PRAGMA(message msg) -#elif NLOHMANN_JSON_HEDLEY_CRAY_VERSION_CHECK(5,0,0) -# define NLOHMANN_JSON_HEDLEY_MESSAGE(msg) NLOHMANN_JSON_HEDLEY_PRAGMA(_CRI message msg) -#elif NLOHMANN_JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0) -# define NLOHMANN_JSON_HEDLEY_MESSAGE(msg) NLOHMANN_JSON_HEDLEY_PRAGMA(message(msg)) -#elif NLOHMANN_JSON_HEDLEY_PELLES_VERSION_CHECK(2,0,0) -# define NLOHMANN_JSON_HEDLEY_MESSAGE(msg) NLOHMANN_JSON_HEDLEY_PRAGMA(message(msg)) + JSON_HEDLEY_GCC_VERSION_CHECK(4,4,0) || \ + JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) +# define JSON_HEDLEY_MESSAGE(msg) JSON_HEDLEY_PRAGMA(message msg) +#elif JSON_HEDLEY_CRAY_VERSION_CHECK(5,0,0) +# define JSON_HEDLEY_MESSAGE(msg) JSON_HEDLEY_PRAGMA(_CRI message msg) +#elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0) +# define JSON_HEDLEY_MESSAGE(msg) JSON_HEDLEY_PRAGMA(message(msg)) +#elif JSON_HEDLEY_PELLES_VERSION_CHECK(2,0,0) +# define JSON_HEDLEY_MESSAGE(msg) JSON_HEDLEY_PRAGMA(message(msg)) #else -# define NLOHMANN_JSON_HEDLEY_MESSAGE(msg) +# define JSON_HEDLEY_MESSAGE(msg) #endif -#if defined(NLOHMANN_JSON_HEDLEY_WARNING) - #undef NLOHMANN_JSON_HEDLEY_WARNING +#if defined(JSON_HEDLEY_WARNING) + #undef JSON_HEDLEY_WARNING #endif -#if NLOHMANN_JSON_HEDLEY_HAS_WARNING("-Wunknown-pragmas") -# define NLOHMANN_JSON_HEDLEY_WARNING(msg) \ - NLOHMANN_JSON_HEDLEY_DIAGNOSTIC_PUSH \ - NLOHMANN_JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS \ - NLOHMANN_JSON_HEDLEY_PRAGMA(clang warning msg) \ - NLOHMANN_JSON_HEDLEY_DIAGNOSTIC_POP +#if JSON_HEDLEY_HAS_WARNING("-Wunknown-pragmas") +# define JSON_HEDLEY_WARNING(msg) \ + JSON_HEDLEY_DIAGNOSTIC_PUSH \ + JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS \ + JSON_HEDLEY_PRAGMA(clang warning msg) \ + JSON_HEDLEY_DIAGNOSTIC_POP #elif \ - NLOHMANN_JSON_HEDLEY_GCC_VERSION_CHECK(4,8,0) || \ - NLOHMANN_JSON_HEDLEY_PGI_VERSION_CHECK(18,4,0) -# define NLOHMANN_JSON_HEDLEY_WARNING(msg) NLOHMANN_JSON_HEDLEY_PRAGMA(GCC warning msg) -#elif NLOHMANN_JSON_HEDLEY_MSVC_VERSION_CHECK(15,0,0) -# define NLOHMANN_JSON_HEDLEY_WARNING(msg) NLOHMANN_JSON_HEDLEY_PRAGMA(message(msg)) + JSON_HEDLEY_GCC_VERSION_CHECK(4,8,0) || \ + JSON_HEDLEY_PGI_VERSION_CHECK(18,4,0) +# define JSON_HEDLEY_WARNING(msg) JSON_HEDLEY_PRAGMA(GCC warning msg) +#elif JSON_HEDLEY_MSVC_VERSION_CHECK(15,0,0) +# define JSON_HEDLEY_WARNING(msg) JSON_HEDLEY_PRAGMA(message(msg)) #else -# define NLOHMANN_JSON_HEDLEY_WARNING(msg) NLOHMANN_JSON_HEDLEY_MESSAGE(msg) +# define JSON_HEDLEY_WARNING(msg) JSON_HEDLEY_MESSAGE(msg) #endif -#if defined(NLOHMANN_JSON_HEDLEY_REQUIRE_MSG) - #undef NLOHMANN_JSON_HEDLEY_REQUIRE_MSG +#if defined(JSON_HEDLEY_REQUIRE_MSG) + #undef JSON_HEDLEY_REQUIRE_MSG #endif -#if NLOHMANN_JSON_HEDLEY_HAS_ATTRIBUTE(diagnose_if) -# if NLOHMANN_JSON_HEDLEY_HAS_WARNING("-Wgcc-compat") -# define NLOHMANN_JSON_HEDLEY_REQUIRE_MSG(expr, msg) \ - NLOHMANN_JSON_HEDLEY_DIAGNOSTIC_PUSH \ +#if JSON_HEDLEY_HAS_ATTRIBUTE(diagnose_if) +# if JSON_HEDLEY_HAS_WARNING("-Wgcc-compat") +# define JSON_HEDLEY_REQUIRE_MSG(expr, msg) \ + JSON_HEDLEY_DIAGNOSTIC_PUSH \ _Pragma("clang diagnostic ignored \"-Wgcc-compat\"") \ __attribute__((__diagnose_if__(!(expr), msg, "error"))) \ - NLOHMANN_JSON_HEDLEY_DIAGNOSTIC_POP + JSON_HEDLEY_DIAGNOSTIC_POP # else -# define NLOHMANN_JSON_HEDLEY_REQUIRE_MSG(expr, msg) __attribute__((__diagnose_if__(!(expr), msg, "error"))) +# define JSON_HEDLEY_REQUIRE_MSG(expr, msg) __attribute__((__diagnose_if__(!(expr), msg, "error"))) # endif #else -# define NLOHMANN_JSON_HEDLEY_REQUIRE_MSG(expr, msg) +# define JSON_HEDLEY_REQUIRE_MSG(expr, msg) #endif -#if defined(NLOHMANN_JSON_HEDLEY_REQUIRE) - #undef NLOHMANN_JSON_HEDLEY_REQUIRE +#if defined(JSON_HEDLEY_REQUIRE) + #undef JSON_HEDLEY_REQUIRE #endif -#define NLOHMANN_JSON_HEDLEY_REQUIRE(expr) NLOHMANN_JSON_HEDLEY_REQUIRE_MSG(expr, #expr) +#define JSON_HEDLEY_REQUIRE(expr) JSON_HEDLEY_REQUIRE_MSG(expr, #expr) -#if defined(NLOHMANN_JSON_HEDLEY_FLAGS) - #undef NLOHMANN_JSON_HEDLEY_FLAGS +#if defined(JSON_HEDLEY_FLAGS) + #undef JSON_HEDLEY_FLAGS #endif -#if NLOHMANN_JSON_HEDLEY_HAS_ATTRIBUTE(flag_enum) - #define NLOHMANN_JSON_HEDLEY_FLAGS __attribute__((__flag_enum__)) +#if JSON_HEDLEY_HAS_ATTRIBUTE(flag_enum) + #define JSON_HEDLEY_FLAGS __attribute__((__flag_enum__)) #endif -#if defined(NLOHMANN_JSON_HEDLEY_FLAGS_CAST) - #undef NLOHMANN_JSON_HEDLEY_FLAGS_CAST +#if defined(JSON_HEDLEY_FLAGS_CAST) + #undef JSON_HEDLEY_FLAGS_CAST #endif -#if NLOHMANN_JSON_HEDLEY_INTEL_VERSION_CHECK(19,0,0) -# define NLOHMANN_JSON_HEDLEY_FLAGS_CAST(T, expr) (__extension__ ({ \ - NLOHMANN_JSON_HEDLEY_DIAGNOSTIC_PUSH \ +#if JSON_HEDLEY_INTEL_VERSION_CHECK(19,0,0) +# define JSON_HEDLEY_FLAGS_CAST(T, expr) (__extension__ ({ \ + JSON_HEDLEY_DIAGNOSTIC_PUSH \ _Pragma("warning(disable:188)") \ ((T) (expr)); \ - NLOHMANN_JSON_HEDLEY_DIAGNOSTIC_POP \ + JSON_HEDLEY_DIAGNOSTIC_POP \ })) #else -# define NLOHMANN_JSON_HEDLEY_FLAGS_CAST(T, expr) NLOHMANN_JSON_HEDLEY_STATIC_CAST(T, expr) +# define JSON_HEDLEY_FLAGS_CAST(T, expr) JSON_HEDLEY_STATIC_CAST(T, expr) #endif /* Remaining macros are deprecated. */ -#if defined(NLOHMANN_JSON_HEDLEY_GCC_NOT_CLANG_VERSION_CHECK) - #undef NLOHMANN_JSON_HEDLEY_GCC_NOT_CLANG_VERSION_CHECK +#if defined(JSON_HEDLEY_GCC_NOT_CLANG_VERSION_CHECK) + #undef JSON_HEDLEY_GCC_NOT_CLANG_VERSION_CHECK #endif #if defined(__clang__) - #define NLOHMANN_JSON_HEDLEY_GCC_NOT_CLANG_VERSION_CHECK(major,minor,patch) (0) + #define JSON_HEDLEY_GCC_NOT_CLANG_VERSION_CHECK(major,minor,patch) (0) #else - #define NLOHMANN_JSON_HEDLEY_GCC_NOT_CLANG_VERSION_CHECK(major,minor,patch) NLOHMANN_JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch) + #define JSON_HEDLEY_GCC_NOT_CLANG_VERSION_CHECK(major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch) #endif -#if defined(NLOHMANN_JSON_HEDLEY_CLANG_HAS_ATTRIBUTE) - #undef NLOHMANN_JSON_HEDLEY_CLANG_HAS_ATTRIBUTE +#if defined(JSON_HEDLEY_CLANG_HAS_ATTRIBUTE) + #undef JSON_HEDLEY_CLANG_HAS_ATTRIBUTE #endif -#define NLOHMANN_JSON_HEDLEY_CLANG_HAS_ATTRIBUTE(attribute) NLOHMANN_JSON_HEDLEY_HAS_ATTRIBUTE(attribute) +#define JSON_HEDLEY_CLANG_HAS_ATTRIBUTE(attribute) JSON_HEDLEY_HAS_ATTRIBUTE(attribute) -#if defined(NLOHMANN_JSON_HEDLEY_CLANG_HAS_CPP_ATTRIBUTE) - #undef NLOHMANN_JSON_HEDLEY_CLANG_HAS_CPP_ATTRIBUTE +#if defined(JSON_HEDLEY_CLANG_HAS_CPP_ATTRIBUTE) + #undef JSON_HEDLEY_CLANG_HAS_CPP_ATTRIBUTE #endif -#define NLOHMANN_JSON_HEDLEY_CLANG_HAS_CPP_ATTRIBUTE(attribute) NLOHMANN_JSON_HEDLEY_HAS_CPP_ATTRIBUTE(attribute) +#define JSON_HEDLEY_CLANG_HAS_CPP_ATTRIBUTE(attribute) JSON_HEDLEY_HAS_CPP_ATTRIBUTE(attribute) -#if defined(NLOHMANN_JSON_HEDLEY_CLANG_HAS_BUILTIN) - #undef NLOHMANN_JSON_HEDLEY_CLANG_HAS_BUILTIN +#if defined(JSON_HEDLEY_CLANG_HAS_BUILTIN) + #undef JSON_HEDLEY_CLANG_HAS_BUILTIN #endif -#define NLOHMANN_JSON_HEDLEY_CLANG_HAS_BUILTIN(builtin) NLOHMANN_JSON_HEDLEY_HAS_BUILTIN(builtin) +#define JSON_HEDLEY_CLANG_HAS_BUILTIN(builtin) JSON_HEDLEY_HAS_BUILTIN(builtin) -#if defined(NLOHMANN_JSON_HEDLEY_CLANG_HAS_FEATURE) - #undef NLOHMANN_JSON_HEDLEY_CLANG_HAS_FEATURE +#if defined(JSON_HEDLEY_CLANG_HAS_FEATURE) + #undef JSON_HEDLEY_CLANG_HAS_FEATURE #endif -#define NLOHMANN_JSON_HEDLEY_CLANG_HAS_FEATURE(feature) NLOHMANN_JSON_HEDLEY_HAS_FEATURE(feature) +#define JSON_HEDLEY_CLANG_HAS_FEATURE(feature) JSON_HEDLEY_HAS_FEATURE(feature) -#if defined(NLOHMANN_JSON_HEDLEY_CLANG_HAS_EXTENSION) - #undef NLOHMANN_JSON_HEDLEY_CLANG_HAS_EXTENSION +#if defined(JSON_HEDLEY_CLANG_HAS_EXTENSION) + #undef JSON_HEDLEY_CLANG_HAS_EXTENSION #endif -#define NLOHMANN_JSON_HEDLEY_CLANG_HAS_EXTENSION(extension) NLOHMANN_JSON_HEDLEY_HAS_EXTENSION(extension) +#define JSON_HEDLEY_CLANG_HAS_EXTENSION(extension) JSON_HEDLEY_HAS_EXTENSION(extension) -#if defined(NLOHMANN_JSON_HEDLEY_CLANG_HAS_DECLSPEC_DECLSPEC_ATTRIBUTE) - #undef NLOHMANN_JSON_HEDLEY_CLANG_HAS_DECLSPEC_DECLSPEC_ATTRIBUTE +#if defined(JSON_HEDLEY_CLANG_HAS_DECLSPEC_DECLSPEC_ATTRIBUTE) + #undef JSON_HEDLEY_CLANG_HAS_DECLSPEC_DECLSPEC_ATTRIBUTE #endif -#define NLOHMANN_JSON_HEDLEY_CLANG_HAS_DECLSPEC_ATTRIBUTE(attribute) NLOHMANN_JSON_HEDLEY_HAS_DECLSPEC_ATTRIBUTE(attribute) +#define JSON_HEDLEY_CLANG_HAS_DECLSPEC_ATTRIBUTE(attribute) JSON_HEDLEY_HAS_DECLSPEC_ATTRIBUTE(attribute) -#if defined(NLOHMANN_JSON_HEDLEY_CLANG_HAS_WARNING) - #undef NLOHMANN_JSON_HEDLEY_CLANG_HAS_WARNING +#if defined(JSON_HEDLEY_CLANG_HAS_WARNING) + #undef JSON_HEDLEY_CLANG_HAS_WARNING #endif -#define NLOHMANN_JSON_HEDLEY_CLANG_HAS_WARNING(warning) NLOHMANN_JSON_HEDLEY_HAS_WARNING(warning) +#define JSON_HEDLEY_CLANG_HAS_WARNING(warning) JSON_HEDLEY_HAS_WARNING(warning) -#endif /* !defined(NLOHMANN_JSON_HEDLEY_VERSION) || (NLOHMANN_JSON_HEDLEY_VERSION < X) */ +#endif /* !defined(JSON_HEDLEY_VERSION) || (JSON_HEDLEY_VERSION < X) */ diff --git a/include/nlohmann/thirdparty/hedley/hedley_undef.hpp b/include/nlohmann/thirdparty/hedley/hedley_undef.hpp index 5e95ae5a..9e8f6d48 100644 --- a/include/nlohmann/thirdparty/hedley/hedley_undef.hpp +++ b/include/nlohmann/thirdparty/hedley/hedley_undef.hpp @@ -1,121 +1,121 @@ -#undef NLOHMANN_JSON_HEDLEY_ALWAYS_INLINE -#undef NLOHMANN_JSON_HEDLEY_ARM_VERSION -#undef NLOHMANN_JSON_HEDLEY_ARM_VERSION_CHECK -#undef NLOHMANN_JSON_HEDLEY_ARRAY_PARAM -#undef NLOHMANN_JSON_HEDLEY_ASSUME -#undef NLOHMANN_JSON_HEDLEY_BEGIN_C_DECLS -#undef NLOHMANN_JSON_HEDLEY_CLANG_HAS_ATTRIBUTE -#undef NLOHMANN_JSON_HEDLEY_CLANG_HAS_BUILTIN -#undef NLOHMANN_JSON_HEDLEY_CLANG_HAS_CPP_ATTRIBUTE -#undef NLOHMANN_JSON_HEDLEY_CLANG_HAS_DECLSPEC_DECLSPEC_ATTRIBUTE -#undef NLOHMANN_JSON_HEDLEY_CLANG_HAS_EXTENSION -#undef NLOHMANN_JSON_HEDLEY_CLANG_HAS_FEATURE -#undef NLOHMANN_JSON_HEDLEY_CLANG_HAS_WARNING -#undef NLOHMANN_JSON_HEDLEY_COMPCERT_VERSION -#undef NLOHMANN_JSON_HEDLEY_COMPCERT_VERSION_CHECK -#undef NLOHMANN_JSON_HEDLEY_CONCAT -#undef NLOHMANN_JSON_HEDLEY_CONCAT_EX -#undef NLOHMANN_JSON_HEDLEY_CONST -#undef NLOHMANN_JSON_HEDLEY_CONSTEXPR -#undef NLOHMANN_JSON_HEDLEY_CONST_CAST -#undef NLOHMANN_JSON_HEDLEY_CPP_CAST -#undef NLOHMANN_JSON_HEDLEY_CRAY_VERSION -#undef NLOHMANN_JSON_HEDLEY_CRAY_VERSION_CHECK -#undef NLOHMANN_JSON_HEDLEY_C_DECL -#undef NLOHMANN_JSON_HEDLEY_DEPRECATED -#undef NLOHMANN_JSON_HEDLEY_DEPRECATED_FOR -#undef NLOHMANN_JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL -#undef NLOHMANN_JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED -#undef NLOHMANN_JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS -#undef NLOHMANN_JSON_HEDLEY_DIAGNOSTIC_POP -#undef NLOHMANN_JSON_HEDLEY_DIAGNOSTIC_PUSH -#undef NLOHMANN_JSON_HEDLEY_DMC_VERSION -#undef NLOHMANN_JSON_HEDLEY_DMC_VERSION_CHECK -#undef NLOHMANN_JSON_HEDLEY_EMSCRIPTEN_VERSION -#undef NLOHMANN_JSON_HEDLEY_EMSCRIPTEN_VERSION_CHECK -#undef NLOHMANN_JSON_HEDLEY_END_C_DECLS -#undef NLOHMANN_JSON_HEDLEY_FALL_THROUGH -#undef NLOHMANN_JSON_HEDLEY_FLAGS -#undef NLOHMANN_JSON_HEDLEY_FLAGS_CAST -#undef NLOHMANN_JSON_HEDLEY_GCC_HAS_ATTRIBUTE -#undef NLOHMANN_JSON_HEDLEY_GCC_HAS_BUILTIN -#undef NLOHMANN_JSON_HEDLEY_GCC_HAS_CPP_ATTRIBUTE -#undef NLOHMANN_JSON_HEDLEY_GCC_HAS_DECLSPEC_ATTRIBUTE -#undef NLOHMANN_JSON_HEDLEY_GCC_HAS_EXTENSION -#undef NLOHMANN_JSON_HEDLEY_GCC_HAS_FEATURE -#undef NLOHMANN_JSON_HEDLEY_GCC_HAS_WARNING -#undef NLOHMANN_JSON_HEDLEY_GCC_NOT_CLANG_VERSION_CHECK -#undef NLOHMANN_JSON_HEDLEY_GCC_VERSION -#undef NLOHMANN_JSON_HEDLEY_GCC_VERSION_CHECK -#undef NLOHMANN_JSON_HEDLEY_GNUC_HAS_ATTRIBUTE -#undef NLOHMANN_JSON_HEDLEY_GNUC_HAS_BUILTIN -#undef NLOHMANN_JSON_HEDLEY_GNUC_HAS_CPP_ATTRIBUTE -#undef NLOHMANN_JSON_HEDLEY_GNUC_HAS_DECLSPEC_ATTRIBUTE -#undef NLOHMANN_JSON_HEDLEY_GNUC_HAS_EXTENSION -#undef NLOHMANN_JSON_HEDLEY_GNUC_HAS_FEATURE -#undef NLOHMANN_JSON_HEDLEY_GNUC_HAS_WARNING -#undef NLOHMANN_JSON_HEDLEY_GNUC_VERSION -#undef NLOHMANN_JSON_HEDLEY_GNUC_VERSION_CHECK -#undef NLOHMANN_JSON_HEDLEY_HAS_ATTRIBUTE -#undef NLOHMANN_JSON_HEDLEY_HAS_BUILTIN -#undef NLOHMANN_JSON_HEDLEY_HAS_CPP_ATTRIBUTE -#undef NLOHMANN_JSON_HEDLEY_HAS_DECLSPEC_ATTRIBUTE -#undef NLOHMANN_JSON_HEDLEY_HAS_EXTENSION -#undef NLOHMANN_JSON_HEDLEY_HAS_FEATURE -#undef NLOHMANN_JSON_HEDLEY_HAS_WARNING -#undef NLOHMANN_JSON_HEDLEY_IAR_VERSION -#undef NLOHMANN_JSON_HEDLEY_IAR_VERSION_CHECK -#undef NLOHMANN_JSON_HEDLEY_IBM_VERSION -#undef NLOHMANN_JSON_HEDLEY_IBM_VERSION_CHECK -#undef NLOHMANN_JSON_HEDLEY_IMPORT -#undef NLOHMANN_JSON_HEDLEY_INLINE -#undef NLOHMANN_JSON_HEDLEY_INTEL_VERSION -#undef NLOHMANN_JSON_HEDLEY_INTEL_VERSION_CHECK -#undef NLOHMANN_JSON_HEDLEY_IS_CONSTANT -#undef NLOHMANN_JSON_HEDLEY_LIKELY -#undef NLOHMANN_JSON_HEDLEY_MALLOC -#undef NLOHMANN_JSON_HEDLEY_MESSAGE -#undef NLOHMANN_JSON_HEDLEY_MSVC_VERSION -#undef NLOHMANN_JSON_HEDLEY_MSVC_VERSION_CHECK -#undef NLOHMANN_JSON_HEDLEY_NEVER_INLINE -#undef NLOHMANN_JSON_HEDLEY_NON_NULL -#undef NLOHMANN_JSON_HEDLEY_NO_RETURN -#undef NLOHMANN_JSON_HEDLEY_NO_THROW -#undef NLOHMANN_JSON_HEDLEY_PELLES_VERSION -#undef NLOHMANN_JSON_HEDLEY_PELLES_VERSION_CHECK -#undef NLOHMANN_JSON_HEDLEY_PGI_VERSION -#undef NLOHMANN_JSON_HEDLEY_PGI_VERSION_CHECK -#undef NLOHMANN_JSON_HEDLEY_PREDICT -#undef NLOHMANN_JSON_HEDLEY_PRINTF_FORMAT -#undef NLOHMANN_JSON_HEDLEY_PRIVATE -#undef NLOHMANN_JSON_HEDLEY_PUBLIC -#undef NLOHMANN_JSON_HEDLEY_PURE -#undef NLOHMANN_JSON_HEDLEY_REINTERPRET_CAST -#undef NLOHMANN_JSON_HEDLEY_REQUIRE -#undef NLOHMANN_JSON_HEDLEY_REQUIRE_CONSTEXPR -#undef NLOHMANN_JSON_HEDLEY_REQUIRE_MSG -#undef NLOHMANN_JSON_HEDLEY_RESTRICT -#undef NLOHMANN_JSON_HEDLEY_RETURNS_NON_NULL -#undef NLOHMANN_JSON_HEDLEY_SENTINEL -#undef NLOHMANN_JSON_HEDLEY_STATIC_ASSERT -#undef NLOHMANN_JSON_HEDLEY_STATIC_CAST -#undef NLOHMANN_JSON_HEDLEY_STRINGIFY -#undef NLOHMANN_JSON_HEDLEY_STRINGIFY_EX -#undef NLOHMANN_JSON_HEDLEY_SUNPRO_VERSION -#undef NLOHMANN_JSON_HEDLEY_SUNPRO_VERSION_CHECK -#undef NLOHMANN_JSON_HEDLEY_TINYC_VERSION -#undef NLOHMANN_JSON_HEDLEY_TINYC_VERSION_CHECK -#undef NLOHMANN_JSON_HEDLEY_TI_VERSION -#undef NLOHMANN_JSON_HEDLEY_TI_VERSION_CHECK -#undef NLOHMANN_JSON_HEDLEY_UNAVAILABLE -#undef NLOHMANN_JSON_HEDLEY_UNLIKELY -#undef NLOHMANN_JSON_HEDLEY_UNPREDICTABLE -#undef NLOHMANN_JSON_HEDLEY_UNREACHABLE -#undef NLOHMANN_JSON_HEDLEY_UNREACHABLE_RETURN -#undef NLOHMANN_JSON_HEDLEY_VERSION -#undef NLOHMANN_JSON_HEDLEY_VERSION_DECODE_MAJOR -#undef NLOHMANN_JSON_HEDLEY_VERSION_DECODE_MINOR -#undef NLOHMANN_JSON_HEDLEY_VERSION_DECODE_REVISION -#undef NLOHMANN_JSON_HEDLEY_VERSION_ENCODE -#undef NLOHMANN_JSON_HEDLEY_WARNING -#undef NLOHMANN_JSON_HEDLEY_WARN_UNUSED_RESULT +#undef JSON_HEDLEY_ALWAYS_INLINE +#undef JSON_HEDLEY_ARM_VERSION +#undef JSON_HEDLEY_ARM_VERSION_CHECK +#undef JSON_HEDLEY_ARRAY_PARAM +#undef JSON_HEDLEY_ASSUME +#undef JSON_HEDLEY_BEGIN_C_DECLS +#undef JSON_HEDLEY_CLANG_HAS_ATTRIBUTE +#undef JSON_HEDLEY_CLANG_HAS_BUILTIN +#undef JSON_HEDLEY_CLANG_HAS_CPP_ATTRIBUTE +#undef JSON_HEDLEY_CLANG_HAS_DECLSPEC_DECLSPEC_ATTRIBUTE +#undef JSON_HEDLEY_CLANG_HAS_EXTENSION +#undef JSON_HEDLEY_CLANG_HAS_FEATURE +#undef JSON_HEDLEY_CLANG_HAS_WARNING +#undef JSON_HEDLEY_COMPCERT_VERSION +#undef JSON_HEDLEY_COMPCERT_VERSION_CHECK +#undef JSON_HEDLEY_CONCAT +#undef JSON_HEDLEY_CONCAT_EX +#undef JSON_HEDLEY_CONST +#undef JSON_HEDLEY_CONSTEXPR +#undef JSON_HEDLEY_CONST_CAST +#undef JSON_HEDLEY_CPP_CAST +#undef JSON_HEDLEY_CRAY_VERSION +#undef JSON_HEDLEY_CRAY_VERSION_CHECK +#undef JSON_HEDLEY_C_DECL +#undef JSON_HEDLEY_DEPRECATED +#undef JSON_HEDLEY_DEPRECATED_FOR +#undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL +#undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED +#undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS +#undef JSON_HEDLEY_DIAGNOSTIC_POP +#undef JSON_HEDLEY_DIAGNOSTIC_PUSH +#undef JSON_HEDLEY_DMC_VERSION +#undef JSON_HEDLEY_DMC_VERSION_CHECK +#undef JSON_HEDLEY_EMSCRIPTEN_VERSION +#undef JSON_HEDLEY_EMSCRIPTEN_VERSION_CHECK +#undef JSON_HEDLEY_END_C_DECLS +#undef JSON_HEDLEY_FALL_THROUGH +#undef JSON_HEDLEY_FLAGS +#undef JSON_HEDLEY_FLAGS_CAST +#undef JSON_HEDLEY_GCC_HAS_ATTRIBUTE +#undef JSON_HEDLEY_GCC_HAS_BUILTIN +#undef JSON_HEDLEY_GCC_HAS_CPP_ATTRIBUTE +#undef JSON_HEDLEY_GCC_HAS_DECLSPEC_ATTRIBUTE +#undef JSON_HEDLEY_GCC_HAS_EXTENSION +#undef JSON_HEDLEY_GCC_HAS_FEATURE +#undef JSON_HEDLEY_GCC_HAS_WARNING +#undef JSON_HEDLEY_GCC_NOT_CLANG_VERSION_CHECK +#undef JSON_HEDLEY_GCC_VERSION +#undef JSON_HEDLEY_GCC_VERSION_CHECK +#undef JSON_HEDLEY_GNUC_HAS_ATTRIBUTE +#undef JSON_HEDLEY_GNUC_HAS_BUILTIN +#undef JSON_HEDLEY_GNUC_HAS_CPP_ATTRIBUTE +#undef JSON_HEDLEY_GNUC_HAS_DECLSPEC_ATTRIBUTE +#undef JSON_HEDLEY_GNUC_HAS_EXTENSION +#undef JSON_HEDLEY_GNUC_HAS_FEATURE +#undef JSON_HEDLEY_GNUC_HAS_WARNING +#undef JSON_HEDLEY_GNUC_VERSION +#undef JSON_HEDLEY_GNUC_VERSION_CHECK +#undef JSON_HEDLEY_HAS_ATTRIBUTE +#undef JSON_HEDLEY_HAS_BUILTIN +#undef JSON_HEDLEY_HAS_CPP_ATTRIBUTE +#undef JSON_HEDLEY_HAS_DECLSPEC_ATTRIBUTE +#undef JSON_HEDLEY_HAS_EXTENSION +#undef JSON_HEDLEY_HAS_FEATURE +#undef JSON_HEDLEY_HAS_WARNING +#undef JSON_HEDLEY_IAR_VERSION +#undef JSON_HEDLEY_IAR_VERSION_CHECK +#undef JSON_HEDLEY_IBM_VERSION +#undef JSON_HEDLEY_IBM_VERSION_CHECK +#undef JSON_HEDLEY_IMPORT +#undef JSON_HEDLEY_INLINE +#undef JSON_HEDLEY_INTEL_VERSION +#undef JSON_HEDLEY_INTEL_VERSION_CHECK +#undef JSON_HEDLEY_IS_CONSTANT +#undef JSON_HEDLEY_LIKELY +#undef JSON_HEDLEY_MALLOC +#undef JSON_HEDLEY_MESSAGE +#undef JSON_HEDLEY_MSVC_VERSION +#undef JSON_HEDLEY_MSVC_VERSION_CHECK +#undef JSON_HEDLEY_NEVER_INLINE +#undef JSON_HEDLEY_NON_NULL +#undef JSON_HEDLEY_NO_RETURN +#undef JSON_HEDLEY_NO_THROW +#undef JSON_HEDLEY_PELLES_VERSION +#undef JSON_HEDLEY_PELLES_VERSION_CHECK +#undef JSON_HEDLEY_PGI_VERSION +#undef JSON_HEDLEY_PGI_VERSION_CHECK +#undef JSON_HEDLEY_PREDICT +#undef JSON_HEDLEY_PRINTF_FORMAT +#undef JSON_HEDLEY_PRIVATE +#undef JSON_HEDLEY_PUBLIC +#undef JSON_HEDLEY_PURE +#undef JSON_HEDLEY_REINTERPRET_CAST +#undef JSON_HEDLEY_REQUIRE +#undef JSON_HEDLEY_REQUIRE_CONSTEXPR +#undef JSON_HEDLEY_REQUIRE_MSG +#undef JSON_HEDLEY_RESTRICT +#undef JSON_HEDLEY_RETURNS_NON_NULL +#undef JSON_HEDLEY_SENTINEL +#undef JSON_HEDLEY_STATIC_ASSERT +#undef JSON_HEDLEY_STATIC_CAST +#undef JSON_HEDLEY_STRINGIFY +#undef JSON_HEDLEY_STRINGIFY_EX +#undef JSON_HEDLEY_SUNPRO_VERSION +#undef JSON_HEDLEY_SUNPRO_VERSION_CHECK +#undef JSON_HEDLEY_TINYC_VERSION +#undef JSON_HEDLEY_TINYC_VERSION_CHECK +#undef JSON_HEDLEY_TI_VERSION +#undef JSON_HEDLEY_TI_VERSION_CHECK +#undef JSON_HEDLEY_UNAVAILABLE +#undef JSON_HEDLEY_UNLIKELY +#undef JSON_HEDLEY_UNPREDICTABLE +#undef JSON_HEDLEY_UNREACHABLE +#undef JSON_HEDLEY_UNREACHABLE_RETURN +#undef JSON_HEDLEY_VERSION +#undef JSON_HEDLEY_VERSION_DECODE_MAJOR +#undef JSON_HEDLEY_VERSION_DECODE_MINOR +#undef JSON_HEDLEY_VERSION_DECODE_REVISION +#undef JSON_HEDLEY_VERSION_ENCODE +#undef JSON_HEDLEY_WARNING +#undef JSON_HEDLEY_WARN_UNUSED_RESULT diff --git a/single_include/nlohmann/json.hpp b/single_include/nlohmann/json.hpp index 6778fd41..e2704b9f 100644 --- a/single_include/nlohmann/json.hpp +++ b/single_include/nlohmann/json.hpp @@ -122,1257 +122,1257 @@ struct position_t * SPDX-License-Identifier: CC0-1.0 */ -#if !defined(NLOHMANN_JSON_HEDLEY_VERSION) || (NLOHMANN_JSON_HEDLEY_VERSION < 9) -#if defined(NLOHMANN_JSON_HEDLEY_VERSION) - #undef NLOHMANN_JSON_HEDLEY_VERSION +#if !defined(JSON_HEDLEY_VERSION) || (JSON_HEDLEY_VERSION < 9) +#if defined(JSON_HEDLEY_VERSION) + #undef JSON_HEDLEY_VERSION #endif -#define NLOHMANN_JSON_HEDLEY_VERSION 9 +#define JSON_HEDLEY_VERSION 9 -#if defined(NLOHMANN_JSON_HEDLEY_STRINGIFY_EX) - #undef NLOHMANN_JSON_HEDLEY_STRINGIFY_EX +#if defined(JSON_HEDLEY_STRINGIFY_EX) + #undef JSON_HEDLEY_STRINGIFY_EX #endif -#define NLOHMANN_JSON_HEDLEY_STRINGIFY_EX(x) #x +#define JSON_HEDLEY_STRINGIFY_EX(x) #x -#if defined(NLOHMANN_JSON_HEDLEY_STRINGIFY) - #undef NLOHMANN_JSON_HEDLEY_STRINGIFY +#if defined(JSON_HEDLEY_STRINGIFY) + #undef JSON_HEDLEY_STRINGIFY #endif -#define NLOHMANN_JSON_HEDLEY_STRINGIFY(x) NLOHMANN_JSON_HEDLEY_STRINGIFY_EX(x) +#define JSON_HEDLEY_STRINGIFY(x) JSON_HEDLEY_STRINGIFY_EX(x) -#if defined(NLOHMANN_JSON_HEDLEY_CONCAT_EX) - #undef NLOHMANN_JSON_HEDLEY_CONCAT_EX +#if defined(JSON_HEDLEY_CONCAT_EX) + #undef JSON_HEDLEY_CONCAT_EX #endif -#define NLOHMANN_JSON_HEDLEY_CONCAT_EX(a,b) a##b +#define JSON_HEDLEY_CONCAT_EX(a,b) a##b -#if defined(NLOHMANN_JSON_HEDLEY_CONCAT) - #undef NLOHMANN_JSON_HEDLEY_CONCAT +#if defined(JSON_HEDLEY_CONCAT) + #undef JSON_HEDLEY_CONCAT #endif -#define NLOHMANN_JSON_HEDLEY_CONCAT(a,b) NLOHMANN_JSON_HEDLEY_CONCAT_EX(a,b) +#define JSON_HEDLEY_CONCAT(a,b) JSON_HEDLEY_CONCAT_EX(a,b) -#if defined(NLOHMANN_JSON_HEDLEY_VERSION_ENCODE) - #undef NLOHMANN_JSON_HEDLEY_VERSION_ENCODE +#if defined(JSON_HEDLEY_VERSION_ENCODE) + #undef JSON_HEDLEY_VERSION_ENCODE #endif -#define NLOHMANN_JSON_HEDLEY_VERSION_ENCODE(major,minor,revision) (((major) * 1000000) + ((minor) * 1000) + (revision)) +#define JSON_HEDLEY_VERSION_ENCODE(major,minor,revision) (((major) * 1000000) + ((minor) * 1000) + (revision)) -#if defined(NLOHMANN_JSON_HEDLEY_VERSION_DECODE_MAJOR) - #undef NLOHMANN_JSON_HEDLEY_VERSION_DECODE_MAJOR +#if defined(JSON_HEDLEY_VERSION_DECODE_MAJOR) + #undef JSON_HEDLEY_VERSION_DECODE_MAJOR #endif -#define NLOHMANN_JSON_HEDLEY_VERSION_DECODE_MAJOR(version) ((version) / 1000000) +#define JSON_HEDLEY_VERSION_DECODE_MAJOR(version) ((version) / 1000000) -#if defined(NLOHMANN_JSON_HEDLEY_VERSION_DECODE_MINOR) - #undef NLOHMANN_JSON_HEDLEY_VERSION_DECODE_MINOR +#if defined(JSON_HEDLEY_VERSION_DECODE_MINOR) + #undef JSON_HEDLEY_VERSION_DECODE_MINOR #endif -#define NLOHMANN_JSON_HEDLEY_VERSION_DECODE_MINOR(version) (((version) % 1000000) / 1000) +#define JSON_HEDLEY_VERSION_DECODE_MINOR(version) (((version) % 1000000) / 1000) -#if defined(NLOHMANN_JSON_HEDLEY_VERSION_DECODE_REVISION) - #undef NLOHMANN_JSON_HEDLEY_VERSION_DECODE_REVISION +#if defined(JSON_HEDLEY_VERSION_DECODE_REVISION) + #undef JSON_HEDLEY_VERSION_DECODE_REVISION #endif -#define NLOHMANN_JSON_HEDLEY_VERSION_DECODE_REVISION(version) ((version) % 1000) +#define JSON_HEDLEY_VERSION_DECODE_REVISION(version) ((version) % 1000) -#if defined(NLOHMANN_JSON_HEDLEY_GNUC_VERSION) - #undef NLOHMANN_JSON_HEDLEY_GNUC_VERSION +#if defined(JSON_HEDLEY_GNUC_VERSION) + #undef JSON_HEDLEY_GNUC_VERSION #endif #if defined(__GNUC__) && defined(__GNUC_PATCHLEVEL__) - #define NLOHMANN_JSON_HEDLEY_GNUC_VERSION NLOHMANN_JSON_HEDLEY_VERSION_ENCODE(__GNUC__, __GNUC_MINOR__, __GNUC_PATCHLEVEL__) + #define JSON_HEDLEY_GNUC_VERSION JSON_HEDLEY_VERSION_ENCODE(__GNUC__, __GNUC_MINOR__, __GNUC_PATCHLEVEL__) #elif defined(__GNUC__) - #define NLOHMANN_JSON_HEDLEY_GNUC_VERSION NLOHMANN_JSON_HEDLEY_VERSION_ENCODE(__GNUC__, __GNUC_MINOR__, 0) + #define JSON_HEDLEY_GNUC_VERSION JSON_HEDLEY_VERSION_ENCODE(__GNUC__, __GNUC_MINOR__, 0) #endif -#if defined(NLOHMANN_JSON_HEDLEY_GNUC_VERSION_CHECK) - #undef NLOHMANN_JSON_HEDLEY_GNUC_VERSION_CHECK +#if defined(JSON_HEDLEY_GNUC_VERSION_CHECK) + #undef JSON_HEDLEY_GNUC_VERSION_CHECK #endif -#if defined(NLOHMANN_JSON_HEDLEY_GNUC_VERSION) - #define NLOHMANN_JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch) (NLOHMANN_JSON_HEDLEY_GNUC_VERSION >= NLOHMANN_JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) +#if defined(JSON_HEDLEY_GNUC_VERSION) + #define JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_GNUC_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) #else - #define NLOHMANN_JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch) (0) + #define JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch) (0) #endif -#if defined(NLOHMANN_JSON_HEDLEY_MSVC_VERSION) - #undef NLOHMANN_JSON_HEDLEY_MSVC_VERSION +#if defined(JSON_HEDLEY_MSVC_VERSION) + #undef JSON_HEDLEY_MSVC_VERSION #endif #if defined(_MSC_FULL_VER) && (_MSC_FULL_VER >= 140000000) - #define NLOHMANN_JSON_HEDLEY_MSVC_VERSION NLOHMANN_JSON_HEDLEY_VERSION_ENCODE(_MSC_FULL_VER / 10000000, (_MSC_FULL_VER % 10000000) / 100000, (_MSC_FULL_VER % 100000) / 100) + #define JSON_HEDLEY_MSVC_VERSION JSON_HEDLEY_VERSION_ENCODE(_MSC_FULL_VER / 10000000, (_MSC_FULL_VER % 10000000) / 100000, (_MSC_FULL_VER % 100000) / 100) #elif defined(_MSC_FULL_VER) - #define NLOHMANN_JSON_HEDLEY_MSVC_VERSION NLOHMANN_JSON_HEDLEY_VERSION_ENCODE(_MSC_FULL_VER / 1000000, (_MSC_FULL_VER % 1000000) / 10000, (_MSC_FULL_VER % 10000) / 10) + #define JSON_HEDLEY_MSVC_VERSION JSON_HEDLEY_VERSION_ENCODE(_MSC_FULL_VER / 1000000, (_MSC_FULL_VER % 1000000) / 10000, (_MSC_FULL_VER % 10000) / 10) #elif defined(_MSC_VER) - #define NLOHMANN_JSON_HEDLEY_MSVC_VERSION NLOHMANN_JSON_HEDLEY_VERSION_ENCODE(_MSC_VER / 100, _MSC_VER % 100, 0) + #define JSON_HEDLEY_MSVC_VERSION JSON_HEDLEY_VERSION_ENCODE(_MSC_VER / 100, _MSC_VER % 100, 0) #endif -#if defined(NLOHMANN_JSON_HEDLEY_MSVC_VERSION_CHECK) - #undef NLOHMANN_JSON_HEDLEY_MSVC_VERSION_CHECK +#if defined(JSON_HEDLEY_MSVC_VERSION_CHECK) + #undef JSON_HEDLEY_MSVC_VERSION_CHECK #endif #if !defined(_MSC_VER) - #define NLOHMANN_JSON_HEDLEY_MSVC_VERSION_CHECK(major,minor,patch) (0) + #define JSON_HEDLEY_MSVC_VERSION_CHECK(major,minor,patch) (0) #elif defined(_MSC_VER) && (_MSC_VER >= 1400) - #define NLOHMANN_JSON_HEDLEY_MSVC_VERSION_CHECK(major,minor,patch) (_MSC_FULL_VER >= ((major * 10000000) + (minor * 100000) + (patch))) + #define JSON_HEDLEY_MSVC_VERSION_CHECK(major,minor,patch) (_MSC_FULL_VER >= ((major * 10000000) + (minor * 100000) + (patch))) #elif defined(_MSC_VER) && (_MSC_VER >= 1200) - #define NLOHMANN_JSON_HEDLEY_MSVC_VERSION_CHECK(major,minor,patch) (_MSC_FULL_VER >= ((major * 1000000) + (minor * 10000) + (patch))) + #define JSON_HEDLEY_MSVC_VERSION_CHECK(major,minor,patch) (_MSC_FULL_VER >= ((major * 1000000) + (minor * 10000) + (patch))) #else - #define NLOHMANN_JSON_HEDLEY_MSVC_VERSION_CHECK(major,minor,patch) (_MSC_VER >= ((major * 100) + (minor))) + #define JSON_HEDLEY_MSVC_VERSION_CHECK(major,minor,patch) (_MSC_VER >= ((major * 100) + (minor))) #endif -#if defined(NLOHMANN_JSON_HEDLEY_INTEL_VERSION) - #undef NLOHMANN_JSON_HEDLEY_INTEL_VERSION +#if defined(JSON_HEDLEY_INTEL_VERSION) + #undef JSON_HEDLEY_INTEL_VERSION #endif #if defined(__INTEL_COMPILER) && defined(__INTEL_COMPILER_UPDATE) - #define NLOHMANN_JSON_HEDLEY_INTEL_VERSION NLOHMANN_JSON_HEDLEY_VERSION_ENCODE(__INTEL_COMPILER / 100, __INTEL_COMPILER % 100, __INTEL_COMPILER_UPDATE) + #define JSON_HEDLEY_INTEL_VERSION JSON_HEDLEY_VERSION_ENCODE(__INTEL_COMPILER / 100, __INTEL_COMPILER % 100, __INTEL_COMPILER_UPDATE) #elif defined(__INTEL_COMPILER) - #define NLOHMANN_JSON_HEDLEY_INTEL_VERSION NLOHMANN_JSON_HEDLEY_VERSION_ENCODE(__INTEL_COMPILER / 100, __INTEL_COMPILER % 100, 0) + #define JSON_HEDLEY_INTEL_VERSION JSON_HEDLEY_VERSION_ENCODE(__INTEL_COMPILER / 100, __INTEL_COMPILER % 100, 0) #endif -#if defined(NLOHMANN_JSON_HEDLEY_INTEL_VERSION_CHECK) - #undef NLOHMANN_JSON_HEDLEY_INTEL_VERSION_CHECK +#if defined(JSON_HEDLEY_INTEL_VERSION_CHECK) + #undef JSON_HEDLEY_INTEL_VERSION_CHECK #endif -#if defined(NLOHMANN_JSON_HEDLEY_INTEL_VERSION) - #define NLOHMANN_JSON_HEDLEY_INTEL_VERSION_CHECK(major,minor,patch) (NLOHMANN_JSON_HEDLEY_INTEL_VERSION >= NLOHMANN_JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) +#if defined(JSON_HEDLEY_INTEL_VERSION) + #define JSON_HEDLEY_INTEL_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_INTEL_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) #else - #define NLOHMANN_JSON_HEDLEY_INTEL_VERSION_CHECK(major,minor,patch) (0) + #define JSON_HEDLEY_INTEL_VERSION_CHECK(major,minor,patch) (0) #endif -#if defined(NLOHMANN_JSON_HEDLEY_PGI_VERSION) - #undef NLOHMANN_JSON_HEDLEY_PGI_VERSION +#if defined(JSON_HEDLEY_PGI_VERSION) + #undef JSON_HEDLEY_PGI_VERSION #endif #if defined(__PGI) && defined(__PGIC__) && defined(__PGIC_MINOR__) && defined(__PGIC_PATCHLEVEL__) - #define NLOHMANN_JSON_HEDLEY_PGI_VERSION NLOHMANN_JSON_HEDLEY_VERSION_ENCODE(__PGIC__, __PGIC_MINOR__, __PGIC_PATCHLEVEL__) + #define JSON_HEDLEY_PGI_VERSION JSON_HEDLEY_VERSION_ENCODE(__PGIC__, __PGIC_MINOR__, __PGIC_PATCHLEVEL__) #endif -#if defined(NLOHMANN_JSON_HEDLEY_PGI_VERSION_CHECK) - #undef NLOHMANN_JSON_HEDLEY_PGI_VERSION_CHECK +#if defined(JSON_HEDLEY_PGI_VERSION_CHECK) + #undef JSON_HEDLEY_PGI_VERSION_CHECK #endif -#if defined(NLOHMANN_JSON_HEDLEY_PGI_VERSION) - #define NLOHMANN_JSON_HEDLEY_PGI_VERSION_CHECK(major,minor,patch) (NLOHMANN_JSON_HEDLEY_PGI_VERSION >= NLOHMANN_JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) +#if defined(JSON_HEDLEY_PGI_VERSION) + #define JSON_HEDLEY_PGI_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_PGI_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) #else - #define NLOHMANN_JSON_HEDLEY_PGI_VERSION_CHECK(major,minor,patch) (0) + #define JSON_HEDLEY_PGI_VERSION_CHECK(major,minor,patch) (0) #endif -#if defined(NLOHMANN_JSON_HEDLEY_SUNPRO_VERSION) - #undef NLOHMANN_JSON_HEDLEY_SUNPRO_VERSION +#if defined(JSON_HEDLEY_SUNPRO_VERSION) + #undef JSON_HEDLEY_SUNPRO_VERSION #endif #if defined(__SUNPRO_C) && (__SUNPRO_C > 0x1000) - #define NLOHMANN_JSON_HEDLEY_SUNPRO_VERSION NLOHMANN_JSON_HEDLEY_VERSION_ENCODE((((__SUNPRO_C >> 16) & 0xf) * 10) + ((__SUNPRO_C >> 12) & 0xf), (((__SUNPRO_C >> 8) & 0xf) * 10) + ((__SUNPRO_C >> 4) & 0xf), (__SUNPRO_C & 0xf) * 10) + #define JSON_HEDLEY_SUNPRO_VERSION JSON_HEDLEY_VERSION_ENCODE((((__SUNPRO_C >> 16) & 0xf) * 10) + ((__SUNPRO_C >> 12) & 0xf), (((__SUNPRO_C >> 8) & 0xf) * 10) + ((__SUNPRO_C >> 4) & 0xf), (__SUNPRO_C & 0xf) * 10) #elif defined(__SUNPRO_C) - #define NLOHMANN_JSON_HEDLEY_SUNPRO_VERSION NLOHMANN_JSON_HEDLEY_VERSION_ENCODE((__SUNPRO_C >> 8) & 0xf, (__SUNPRO_C >> 4) & 0xf, (__SUNPRO_C) & 0xf) + #define JSON_HEDLEY_SUNPRO_VERSION JSON_HEDLEY_VERSION_ENCODE((__SUNPRO_C >> 8) & 0xf, (__SUNPRO_C >> 4) & 0xf, (__SUNPRO_C) & 0xf) #elif defined(__SUNPRO_CC) && (__SUNPRO_CC > 0x1000) - #define NLOHMANN_JSON_HEDLEY_SUNPRO_VERSION NLOHMANN_JSON_HEDLEY_VERSION_ENCODE((((__SUNPRO_CC >> 16) & 0xf) * 10) + ((__SUNPRO_CC >> 12) & 0xf), (((__SUNPRO_CC >> 8) & 0xf) * 10) + ((__SUNPRO_CC >> 4) & 0xf), (__SUNPRO_CC & 0xf) * 10) + #define JSON_HEDLEY_SUNPRO_VERSION JSON_HEDLEY_VERSION_ENCODE((((__SUNPRO_CC >> 16) & 0xf) * 10) + ((__SUNPRO_CC >> 12) & 0xf), (((__SUNPRO_CC >> 8) & 0xf) * 10) + ((__SUNPRO_CC >> 4) & 0xf), (__SUNPRO_CC & 0xf) * 10) #elif defined(__SUNPRO_CC) - #define NLOHMANN_JSON_HEDLEY_SUNPRO_VERSION NLOHMANN_JSON_HEDLEY_VERSION_ENCODE((__SUNPRO_CC >> 8) & 0xf, (__SUNPRO_CC >> 4) & 0xf, (__SUNPRO_CC) & 0xf) + #define JSON_HEDLEY_SUNPRO_VERSION JSON_HEDLEY_VERSION_ENCODE((__SUNPRO_CC >> 8) & 0xf, (__SUNPRO_CC >> 4) & 0xf, (__SUNPRO_CC) & 0xf) #endif -#if defined(NLOHMANN_JSON_HEDLEY_SUNPRO_VERSION_CHECK) - #undef NLOHMANN_JSON_HEDLEY_SUNPRO_VERSION_CHECK +#if defined(JSON_HEDLEY_SUNPRO_VERSION_CHECK) + #undef JSON_HEDLEY_SUNPRO_VERSION_CHECK #endif -#if defined(NLOHMANN_JSON_HEDLEY_SUNPRO_VERSION) - #define NLOHMANN_JSON_HEDLEY_SUNPRO_VERSION_CHECK(major,minor,patch) (NLOHMANN_JSON_HEDLEY_SUNPRO_VERSION >= NLOHMANN_JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) +#if defined(JSON_HEDLEY_SUNPRO_VERSION) + #define JSON_HEDLEY_SUNPRO_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_SUNPRO_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) #else - #define NLOHMANN_JSON_HEDLEY_SUNPRO_VERSION_CHECK(major,minor,patch) (0) + #define JSON_HEDLEY_SUNPRO_VERSION_CHECK(major,minor,patch) (0) #endif -#if defined(NLOHMANN_JSON_HEDLEY_EMSCRIPTEN_VERSION) - #undef NLOHMANN_JSON_HEDLEY_EMSCRIPTEN_VERSION +#if defined(JSON_HEDLEY_EMSCRIPTEN_VERSION) + #undef JSON_HEDLEY_EMSCRIPTEN_VERSION #endif #if defined(__EMSCRIPTEN__) - #define NLOHMANN_JSON_HEDLEY_EMSCRIPTEN_VERSION NLOHMANN_JSON_HEDLEY_VERSION_ENCODE(__EMSCRIPTEN_major__, __EMSCRIPTEN_minor__, __EMSCRIPTEN_tiny__) + #define JSON_HEDLEY_EMSCRIPTEN_VERSION JSON_HEDLEY_VERSION_ENCODE(__EMSCRIPTEN_major__, __EMSCRIPTEN_minor__, __EMSCRIPTEN_tiny__) #endif -#if defined(NLOHMANN_JSON_HEDLEY_EMSCRIPTEN_VERSION_CHECK) - #undef NLOHMANN_JSON_HEDLEY_EMSCRIPTEN_VERSION_CHECK +#if defined(JSON_HEDLEY_EMSCRIPTEN_VERSION_CHECK) + #undef JSON_HEDLEY_EMSCRIPTEN_VERSION_CHECK #endif -#if defined(NLOHMANN_JSON_HEDLEY_EMSCRIPTEN_VERSION) - #define NLOHMANN_JSON_HEDLEY_EMSCRIPTEN_VERSION_CHECK(major,minor,patch) (NLOHMANN_JSON_HEDLEY_EMSCRIPTEN_VERSION >= NLOHMANN_JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) +#if defined(JSON_HEDLEY_EMSCRIPTEN_VERSION) + #define JSON_HEDLEY_EMSCRIPTEN_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_EMSCRIPTEN_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) #else - #define NLOHMANN_JSON_HEDLEY_EMSCRIPTEN_VERSION_CHECK(major,minor,patch) (0) + #define JSON_HEDLEY_EMSCRIPTEN_VERSION_CHECK(major,minor,patch) (0) #endif -#if defined(NLOHMANN_JSON_HEDLEY_ARM_VERSION) - #undef NLOHMANN_JSON_HEDLEY_ARM_VERSION +#if defined(JSON_HEDLEY_ARM_VERSION) + #undef JSON_HEDLEY_ARM_VERSION #endif #if defined(__CC_ARM) && defined(__ARMCOMPILER_VERSION) - #define NLOHMANN_JSON_HEDLEY_ARM_VERSION NLOHMANN_JSON_HEDLEY_VERSION_ENCODE(__ARMCOMPILER_VERSION / 1000000, (__ARMCOMPILER_VERSION % 1000000) / 10000, (__ARMCOMPILER_VERSION % 10000) / 100) + #define JSON_HEDLEY_ARM_VERSION JSON_HEDLEY_VERSION_ENCODE(__ARMCOMPILER_VERSION / 1000000, (__ARMCOMPILER_VERSION % 1000000) / 10000, (__ARMCOMPILER_VERSION % 10000) / 100) #elif defined(__CC_ARM) && defined(__ARMCC_VERSION) - #define NLOHMANN_JSON_HEDLEY_ARM_VERSION NLOHMANN_JSON_HEDLEY_VERSION_ENCODE(__ARMCC_VERSION / 1000000, (__ARMCC_VERSION % 1000000) / 10000, (__ARMCC_VERSION % 10000) / 100) + #define JSON_HEDLEY_ARM_VERSION JSON_HEDLEY_VERSION_ENCODE(__ARMCC_VERSION / 1000000, (__ARMCC_VERSION % 1000000) / 10000, (__ARMCC_VERSION % 10000) / 100) #endif -#if defined(NLOHMANN_JSON_HEDLEY_ARM_VERSION_CHECK) - #undef NLOHMANN_JSON_HEDLEY_ARM_VERSION_CHECK +#if defined(JSON_HEDLEY_ARM_VERSION_CHECK) + #undef JSON_HEDLEY_ARM_VERSION_CHECK #endif -#if defined(NLOHMANN_JSON_HEDLEY_ARM_VERSION) - #define NLOHMANN_JSON_HEDLEY_ARM_VERSION_CHECK(major,minor,patch) (NLOHMANN_JSON_HEDLEY_ARM_VERSION >= NLOHMANN_JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) +#if defined(JSON_HEDLEY_ARM_VERSION) + #define JSON_HEDLEY_ARM_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_ARM_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) #else - #define NLOHMANN_JSON_HEDLEY_ARM_VERSION_CHECK(major,minor,patch) (0) + #define JSON_HEDLEY_ARM_VERSION_CHECK(major,minor,patch) (0) #endif -#if defined(NLOHMANN_JSON_HEDLEY_IBM_VERSION) - #undef NLOHMANN_JSON_HEDLEY_IBM_VERSION +#if defined(JSON_HEDLEY_IBM_VERSION) + #undef JSON_HEDLEY_IBM_VERSION #endif #if defined(__ibmxl__) - #define NLOHMANN_JSON_HEDLEY_IBM_VERSION NLOHMANN_JSON_HEDLEY_VERSION_ENCODE(__ibmxl_version__, __ibmxl_release__, __ibmxl_modification__) + #define JSON_HEDLEY_IBM_VERSION JSON_HEDLEY_VERSION_ENCODE(__ibmxl_version__, __ibmxl_release__, __ibmxl_modification__) #elif defined(__xlC__) && defined(__xlC_ver__) - #define NLOHMANN_JSON_HEDLEY_IBM_VERSION NLOHMANN_JSON_HEDLEY_VERSION_ENCODE(__xlC__ >> 8, __xlC__ & 0xff, (__xlC_ver__ >> 8) & 0xff) + #define JSON_HEDLEY_IBM_VERSION JSON_HEDLEY_VERSION_ENCODE(__xlC__ >> 8, __xlC__ & 0xff, (__xlC_ver__ >> 8) & 0xff) #elif defined(__xlC__) - #define NLOHMANN_JSON_HEDLEY_IBM_VERSION NLOHMANN_JSON_HEDLEY_VERSION_ENCODE(__xlC__ >> 8, __xlC__ & 0xff, 0) + #define JSON_HEDLEY_IBM_VERSION JSON_HEDLEY_VERSION_ENCODE(__xlC__ >> 8, __xlC__ & 0xff, 0) #endif -#if defined(NLOHMANN_JSON_HEDLEY_IBM_VERSION_CHECK) - #undef NLOHMANN_JSON_HEDLEY_IBM_VERSION_CHECK +#if defined(JSON_HEDLEY_IBM_VERSION_CHECK) + #undef JSON_HEDLEY_IBM_VERSION_CHECK #endif -#if defined(NLOHMANN_JSON_HEDLEY_IBM_VERSION) - #define NLOHMANN_JSON_HEDLEY_IBM_VERSION_CHECK(major,minor,patch) (NLOHMANN_JSON_HEDLEY_IBM_VERSION >= NLOHMANN_JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) +#if defined(JSON_HEDLEY_IBM_VERSION) + #define JSON_HEDLEY_IBM_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_IBM_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) #else - #define NLOHMANN_JSON_HEDLEY_IBM_VERSION_CHECK(major,minor,patch) (0) + #define JSON_HEDLEY_IBM_VERSION_CHECK(major,minor,patch) (0) #endif -#if defined(NLOHMANN_JSON_HEDLEY_TI_VERSION) - #undef NLOHMANN_JSON_HEDLEY_TI_VERSION +#if defined(JSON_HEDLEY_TI_VERSION) + #undef JSON_HEDLEY_TI_VERSION #endif #if defined(__TI_COMPILER_VERSION__) - #define NLOHMANN_JSON_HEDLEY_TI_VERSION NLOHMANN_JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000)) + #define JSON_HEDLEY_TI_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000)) #endif -#if defined(NLOHMANN_JSON_HEDLEY_TI_VERSION_CHECK) - #undef NLOHMANN_JSON_HEDLEY_TI_VERSION_CHECK +#if defined(JSON_HEDLEY_TI_VERSION_CHECK) + #undef JSON_HEDLEY_TI_VERSION_CHECK #endif -#if defined(NLOHMANN_JSON_HEDLEY_TI_VERSION) - #define NLOHMANN_JSON_HEDLEY_TI_VERSION_CHECK(major,minor,patch) (NLOHMANN_JSON_HEDLEY_TI_VERSION >= NLOHMANN_JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) +#if defined(JSON_HEDLEY_TI_VERSION) + #define JSON_HEDLEY_TI_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TI_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) #else - #define NLOHMANN_JSON_HEDLEY_TI_VERSION_CHECK(major,minor,patch) (0) + #define JSON_HEDLEY_TI_VERSION_CHECK(major,minor,patch) (0) #endif -#if defined(NLOHMANN_JSON_HEDLEY_CRAY_VERSION) - #undef NLOHMANN_JSON_HEDLEY_CRAY_VERSION +#if defined(JSON_HEDLEY_CRAY_VERSION) + #undef JSON_HEDLEY_CRAY_VERSION #endif #if defined(_CRAYC) #if defined(_RELEASE_PATCHLEVEL) - #define NLOHMANN_JSON_HEDLEY_CRAY_VERSION NLOHMANN_JSON_HEDLEY_VERSION_ENCODE(_RELEASE_MAJOR, _RELEASE_MINOR, _RELEASE_PATCHLEVEL) + #define JSON_HEDLEY_CRAY_VERSION JSON_HEDLEY_VERSION_ENCODE(_RELEASE_MAJOR, _RELEASE_MINOR, _RELEASE_PATCHLEVEL) #else - #define NLOHMANN_JSON_HEDLEY_CRAY_VERSION NLOHMANN_JSON_HEDLEY_VERSION_ENCODE(_RELEASE_MAJOR, _RELEASE_MINOR, 0) + #define JSON_HEDLEY_CRAY_VERSION JSON_HEDLEY_VERSION_ENCODE(_RELEASE_MAJOR, _RELEASE_MINOR, 0) #endif #endif -#if defined(NLOHMANN_JSON_HEDLEY_CRAY_VERSION_CHECK) - #undef NLOHMANN_JSON_HEDLEY_CRAY_VERSION_CHECK +#if defined(JSON_HEDLEY_CRAY_VERSION_CHECK) + #undef JSON_HEDLEY_CRAY_VERSION_CHECK #endif -#if defined(NLOHMANN_JSON_HEDLEY_CRAY_VERSION) - #define NLOHMANN_JSON_HEDLEY_CRAY_VERSION_CHECK(major,minor,patch) (NLOHMANN_JSON_HEDLEY_CRAY_VERSION >= NLOHMANN_JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) +#if defined(JSON_HEDLEY_CRAY_VERSION) + #define JSON_HEDLEY_CRAY_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_CRAY_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) #else - #define NLOHMANN_JSON_HEDLEY_CRAY_VERSION_CHECK(major,minor,patch) (0) + #define JSON_HEDLEY_CRAY_VERSION_CHECK(major,minor,patch) (0) #endif -#if defined(NLOHMANN_JSON_HEDLEY_IAR_VERSION) - #undef NLOHMANN_JSON_HEDLEY_IAR_VERSION +#if defined(JSON_HEDLEY_IAR_VERSION) + #undef JSON_HEDLEY_IAR_VERSION #endif #if defined(__IAR_SYSTEMS_ICC__) #if __VER__ > 1000 - #define NLOHMANN_JSON_HEDLEY_IAR_VERSION NLOHMANN_JSON_HEDLEY_VERSION_ENCODE((__VER__ / 1000000), ((__VER__ / 1000) % 1000), (__VER__ % 1000)) + #define JSON_HEDLEY_IAR_VERSION JSON_HEDLEY_VERSION_ENCODE((__VER__ / 1000000), ((__VER__ / 1000) % 1000), (__VER__ % 1000)) #else - #define NLOHMANN_JSON_HEDLEY_IAR_VERSION NLOHMANN_JSON_HEDLEY_VERSION_ENCODE(VER / 100, __VER__ % 100, 0) + #define JSON_HEDLEY_IAR_VERSION JSON_HEDLEY_VERSION_ENCODE(VER / 100, __VER__ % 100, 0) #endif #endif -#if defined(NLOHMANN_JSON_HEDLEY_IAR_VERSION_CHECK) - #undef NLOHMANN_JSON_HEDLEY_IAR_VERSION_CHECK +#if defined(JSON_HEDLEY_IAR_VERSION_CHECK) + #undef JSON_HEDLEY_IAR_VERSION_CHECK #endif -#if defined(NLOHMANN_JSON_HEDLEY_IAR_VERSION) - #define NLOHMANN_JSON_HEDLEY_IAR_VERSION_CHECK(major,minor,patch) (NLOHMANN_JSON_HEDLEY_IAR_VERSION >= NLOHMANN_JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) +#if defined(JSON_HEDLEY_IAR_VERSION) + #define JSON_HEDLEY_IAR_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_IAR_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) #else - #define NLOHMANN_JSON_HEDLEY_IAR_VERSION_CHECK(major,minor,patch) (0) + #define JSON_HEDLEY_IAR_VERSION_CHECK(major,minor,patch) (0) #endif -#if defined(NLOHMANN_JSON_HEDLEY_TINYC_VERSION) - #undef NLOHMANN_JSON_HEDLEY_TINYC_VERSION +#if defined(JSON_HEDLEY_TINYC_VERSION) + #undef JSON_HEDLEY_TINYC_VERSION #endif #if defined(__TINYC__) - #define NLOHMANN_JSON_HEDLEY_TINYC_VERSION NLOHMANN_JSON_HEDLEY_VERSION_ENCODE(__TINYC__ / 1000, (__TINYC__ / 100) % 10, __TINYC__ % 100) + #define JSON_HEDLEY_TINYC_VERSION JSON_HEDLEY_VERSION_ENCODE(__TINYC__ / 1000, (__TINYC__ / 100) % 10, __TINYC__ % 100) #endif -#if defined(NLOHMANN_JSON_HEDLEY_TINYC_VERSION_CHECK) - #undef NLOHMANN_JSON_HEDLEY_TINYC_VERSION_CHECK +#if defined(JSON_HEDLEY_TINYC_VERSION_CHECK) + #undef JSON_HEDLEY_TINYC_VERSION_CHECK #endif -#if defined(NLOHMANN_JSON_HEDLEY_TINYC_VERSION) - #define NLOHMANN_JSON_HEDLEY_TINYC_VERSION_CHECK(major,minor,patch) (NLOHMANN_JSON_HEDLEY_TINYC_VERSION >= NLOHMANN_JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) +#if defined(JSON_HEDLEY_TINYC_VERSION) + #define JSON_HEDLEY_TINYC_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TINYC_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) #else - #define NLOHMANN_JSON_HEDLEY_TINYC_VERSION_CHECK(major,minor,patch) (0) + #define JSON_HEDLEY_TINYC_VERSION_CHECK(major,minor,patch) (0) #endif -#if defined(NLOHMANN_JSON_HEDLEY_DMC_VERSION) - #undef NLOHMANN_JSON_HEDLEY_DMC_VERSION +#if defined(JSON_HEDLEY_DMC_VERSION) + #undef JSON_HEDLEY_DMC_VERSION #endif #if defined(__DMC__) - #define NLOHMANN_JSON_HEDLEY_DMC_VERSION NLOHMANN_JSON_HEDLEY_VERSION_ENCODE(__DMC__ >> 8, (__DMC__ >> 4) & 0xf, __DMC__ & 0xf) + #define JSON_HEDLEY_DMC_VERSION JSON_HEDLEY_VERSION_ENCODE(__DMC__ >> 8, (__DMC__ >> 4) & 0xf, __DMC__ & 0xf) #endif -#if defined(NLOHMANN_JSON_HEDLEY_DMC_VERSION_CHECK) - #undef NLOHMANN_JSON_HEDLEY_DMC_VERSION_CHECK +#if defined(JSON_HEDLEY_DMC_VERSION_CHECK) + #undef JSON_HEDLEY_DMC_VERSION_CHECK #endif -#if defined(NLOHMANN_JSON_HEDLEY_DMC_VERSION) - #define NLOHMANN_JSON_HEDLEY_DMC_VERSION_CHECK(major,minor,patch) (NLOHMANN_JSON_HEDLEY_DMC_VERSION >= NLOHMANN_JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) +#if defined(JSON_HEDLEY_DMC_VERSION) + #define JSON_HEDLEY_DMC_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_DMC_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) #else - #define NLOHMANN_JSON_HEDLEY_DMC_VERSION_CHECK(major,minor,patch) (0) + #define JSON_HEDLEY_DMC_VERSION_CHECK(major,minor,patch) (0) #endif -#if defined(NLOHMANN_JSON_HEDLEY_COMPCERT_VERSION) - #undef NLOHMANN_JSON_HEDLEY_COMPCERT_VERSION +#if defined(JSON_HEDLEY_COMPCERT_VERSION) + #undef JSON_HEDLEY_COMPCERT_VERSION #endif #if defined(__COMPCERT_VERSION__) - #define NLOHMANN_JSON_HEDLEY_COMPCERT_VERSION NLOHMANN_JSON_HEDLEY_VERSION_ENCODE(__COMPCERT_VERSION__ / 10000, (__COMPCERT_VERSION__ / 100) % 100, __COMPCERT_VERSION__ % 100) + #define JSON_HEDLEY_COMPCERT_VERSION JSON_HEDLEY_VERSION_ENCODE(__COMPCERT_VERSION__ / 10000, (__COMPCERT_VERSION__ / 100) % 100, __COMPCERT_VERSION__ % 100) #endif -#if defined(NLOHMANN_JSON_HEDLEY_COMPCERT_VERSION_CHECK) - #undef NLOHMANN_JSON_HEDLEY_COMPCERT_VERSION_CHECK +#if defined(JSON_HEDLEY_COMPCERT_VERSION_CHECK) + #undef JSON_HEDLEY_COMPCERT_VERSION_CHECK #endif -#if defined(NLOHMANN_JSON_HEDLEY_COMPCERT_VERSION) - #define NLOHMANN_JSON_HEDLEY_COMPCERT_VERSION_CHECK(major,minor,patch) (NLOHMANN_JSON_HEDLEY_COMPCERT_VERSION >= NLOHMANN_JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) +#if defined(JSON_HEDLEY_COMPCERT_VERSION) + #define JSON_HEDLEY_COMPCERT_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_COMPCERT_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) #else - #define NLOHMANN_JSON_HEDLEY_COMPCERT_VERSION_CHECK(major,minor,patch) (0) + #define JSON_HEDLEY_COMPCERT_VERSION_CHECK(major,minor,patch) (0) #endif -#if defined(NLOHMANN_JSON_HEDLEY_PELLES_VERSION) - #undef NLOHMANN_JSON_HEDLEY_PELLES_VERSION +#if defined(JSON_HEDLEY_PELLES_VERSION) + #undef JSON_HEDLEY_PELLES_VERSION #endif #if defined(__POCC__) - #define NLOHMANN_JSON_HEDLEY_PELLES_VERSION NLOHMANN_JSON_HEDLEY_VERSION_ENCODE(__POCC__ / 100, __POCC__ % 100, 0) + #define JSON_HEDLEY_PELLES_VERSION JSON_HEDLEY_VERSION_ENCODE(__POCC__ / 100, __POCC__ % 100, 0) #endif -#if defined(NLOHMANN_JSON_HEDLEY_PELLES_VERSION_CHECK) - #undef NLOHMANN_JSON_HEDLEY_PELLES_VERSION_CHECK +#if defined(JSON_HEDLEY_PELLES_VERSION_CHECK) + #undef JSON_HEDLEY_PELLES_VERSION_CHECK #endif -#if defined(NLOHMANN_JSON_HEDLEY_PELLES_VERSION) - #define NLOHMANN_JSON_HEDLEY_PELLES_VERSION_CHECK(major,minor,patch) (NLOHMANN_JSON_HEDLEY_PELLES_VERSION >= NLOHMANN_JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) +#if defined(JSON_HEDLEY_PELLES_VERSION) + #define JSON_HEDLEY_PELLES_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_PELLES_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) #else - #define NLOHMANN_JSON_HEDLEY_PELLES_VERSION_CHECK(major,minor,patch) (0) + #define JSON_HEDLEY_PELLES_VERSION_CHECK(major,minor,patch) (0) #endif -#if defined(NLOHMANN_JSON_HEDLEY_GCC_VERSION) - #undef NLOHMANN_JSON_HEDLEY_GCC_VERSION +#if defined(JSON_HEDLEY_GCC_VERSION) + #undef JSON_HEDLEY_GCC_VERSION #endif #if \ - defined(NLOHMANN_JSON_HEDLEY_GNUC_VERSION) && \ + defined(JSON_HEDLEY_GNUC_VERSION) && \ !defined(__clang__) && \ - !defined(NLOHMANN_JSON_HEDLEY_INTEL_VERSION) && \ - !defined(NLOHMANN_JSON_HEDLEY_PGI_VERSION) && \ - !defined(NLOHMANN_JSON_HEDLEY_ARM_VERSION) && \ - !defined(NLOHMANN_JSON_HEDLEY_TI_VERSION) && \ + !defined(JSON_HEDLEY_INTEL_VERSION) && \ + !defined(JSON_HEDLEY_PGI_VERSION) && \ + !defined(JSON_HEDLEY_ARM_VERSION) && \ + !defined(JSON_HEDLEY_TI_VERSION) && \ !defined(__COMPCERT__) - #define NLOHMANN_JSON_HEDLEY_GCC_VERSION NLOHMANN_JSON_HEDLEY_GNUC_VERSION + #define JSON_HEDLEY_GCC_VERSION JSON_HEDLEY_GNUC_VERSION #endif -#if defined(NLOHMANN_JSON_HEDLEY_GCC_VERSION_CHECK) - #undef NLOHMANN_JSON_HEDLEY_GCC_VERSION_CHECK +#if defined(JSON_HEDLEY_GCC_VERSION_CHECK) + #undef JSON_HEDLEY_GCC_VERSION_CHECK #endif -#if defined(NLOHMANN_JSON_HEDLEY_GCC_VERSION) - #define NLOHMANN_JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch) (NLOHMANN_JSON_HEDLEY_GCC_VERSION >= NLOHMANN_JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) +#if defined(JSON_HEDLEY_GCC_VERSION) + #define JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_GCC_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) #else - #define NLOHMANN_JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch) (0) + #define JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch) (0) #endif -#if defined(NLOHMANN_JSON_HEDLEY_HAS_ATTRIBUTE) - #undef NLOHMANN_JSON_HEDLEY_HAS_ATTRIBUTE +#if defined(JSON_HEDLEY_HAS_ATTRIBUTE) + #undef JSON_HEDLEY_HAS_ATTRIBUTE #endif #if defined(__has_attribute) - #define NLOHMANN_JSON_HEDLEY_HAS_ATTRIBUTE(attribute) __has_attribute(attribute) + #define JSON_HEDLEY_HAS_ATTRIBUTE(attribute) __has_attribute(attribute) #else - #define NLOHMANN_JSON_HEDLEY_HAS_ATTRIBUTE(attribute) (0) + #define JSON_HEDLEY_HAS_ATTRIBUTE(attribute) (0) #endif -#if defined(NLOHMANN_JSON_HEDLEY_GNUC_HAS_ATTRIBUTE) - #undef NLOHMANN_JSON_HEDLEY_GNUC_HAS_ATTRIBUTE +#if defined(JSON_HEDLEY_GNUC_HAS_ATTRIBUTE) + #undef JSON_HEDLEY_GNUC_HAS_ATTRIBUTE #endif #if defined(__has_attribute) - #define NLOHMANN_JSON_HEDLEY_GNUC_HAS_ATTRIBUTE(attribute,major,minor,patch) __has_attribute(attribute) + #define JSON_HEDLEY_GNUC_HAS_ATTRIBUTE(attribute,major,minor,patch) __has_attribute(attribute) #else - #define NLOHMANN_JSON_HEDLEY_GNUC_HAS_ATTRIBUTE(attribute,major,minor,patch) NLOHMANN_JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch) + #define JSON_HEDLEY_GNUC_HAS_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch) #endif -#if defined(NLOHMANN_JSON_HEDLEY_GCC_HAS_ATTRIBUTE) - #undef NLOHMANN_JSON_HEDLEY_GCC_HAS_ATTRIBUTE +#if defined(JSON_HEDLEY_GCC_HAS_ATTRIBUTE) + #undef JSON_HEDLEY_GCC_HAS_ATTRIBUTE #endif #if defined(__has_attribute) - #define NLOHMANN_JSON_HEDLEY_GCC_HAS_ATTRIBUTE(attribute,major,minor,patch) __has_attribute(attribute) + #define JSON_HEDLEY_GCC_HAS_ATTRIBUTE(attribute,major,minor,patch) __has_attribute(attribute) #else - #define NLOHMANN_JSON_HEDLEY_GCC_HAS_ATTRIBUTE(attribute,major,minor,patch) NLOHMANN_JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch) + #define JSON_HEDLEY_GCC_HAS_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch) #endif -#if defined(NLOHMANN_JSON_HEDLEY_HAS_CPP_ATTRIBUTE) - #undef NLOHMANN_JSON_HEDLEY_HAS_CPP_ATTRIBUTE +#if defined(JSON_HEDLEY_HAS_CPP_ATTRIBUTE) + #undef JSON_HEDLEY_HAS_CPP_ATTRIBUTE #endif #if defined(__has_cpp_attribute) && defined(__cplusplus) - #define NLOHMANN_JSON_HEDLEY_HAS_CPP_ATTRIBUTE(attribute) __has_cpp_attribute(attribute) + #define JSON_HEDLEY_HAS_CPP_ATTRIBUTE(attribute) __has_cpp_attribute(attribute) #else - #define NLOHMANN_JSON_HEDLEY_HAS_CPP_ATTRIBUTE(attribute) (0) + #define JSON_HEDLEY_HAS_CPP_ATTRIBUTE(attribute) (0) #endif -#if defined(NLOHMANN_JSON_HEDLEY_GNUC_HAS_CPP_ATTRIBUTE) - #undef NLOHMANN_JSON_HEDLEY_GNUC_HAS_CPP_ATTRIBUTE +#if defined(JSON_HEDLEY_GNUC_HAS_CPP_ATTRIBUTE) + #undef JSON_HEDLEY_GNUC_HAS_CPP_ATTRIBUTE #endif #if defined(__has_cpp_attribute) && defined(__cplusplus) - #define NLOHMANN_JSON_HEDLEY_GNUC_HAS_CPP_ATTRIBUTE(attribute,major,minor,patch) __has_cpp_attribute(attribute) + #define JSON_HEDLEY_GNUC_HAS_CPP_ATTRIBUTE(attribute,major,minor,patch) __has_cpp_attribute(attribute) #else - #define NLOHMANN_JSON_HEDLEY_GNUC_HAS_CPP_ATTRIBUTE(attribute,major,minor,patch) NLOHMANN_JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch) + #define JSON_HEDLEY_GNUC_HAS_CPP_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch) #endif -#if defined(NLOHMANN_JSON_HEDLEY_GCC_HAS_CPP_ATTRIBUTE) - #undef NLOHMANN_JSON_HEDLEY_GCC_HAS_CPP_ATTRIBUTE +#if defined(JSON_HEDLEY_GCC_HAS_CPP_ATTRIBUTE) + #undef JSON_HEDLEY_GCC_HAS_CPP_ATTRIBUTE #endif #if defined(__has_cpp_attribute) && defined(__cplusplus) - #define NLOHMANN_JSON_HEDLEY_GCC_HAS_CPP_ATTRIBUTE(attribute,major,minor,patch) __has_cpp_attribute(attribute) + #define JSON_HEDLEY_GCC_HAS_CPP_ATTRIBUTE(attribute,major,minor,patch) __has_cpp_attribute(attribute) #else - #define NLOHMANN_JSON_HEDLEY_GCC_HAS_CPP_ATTRIBUTE(attribute,major,minor,patch) NLOHMANN_JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch) + #define JSON_HEDLEY_GCC_HAS_CPP_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch) #endif -#if defined(NLOHMANN_JSON_HEDLEY_HAS_BUILTIN) - #undef NLOHMANN_JSON_HEDLEY_HAS_BUILTIN +#if defined(JSON_HEDLEY_HAS_BUILTIN) + #undef JSON_HEDLEY_HAS_BUILTIN #endif #if defined(__has_builtin) - #define NLOHMANN_JSON_HEDLEY_HAS_BUILTIN(builtin) __has_builtin(builtin) + #define JSON_HEDLEY_HAS_BUILTIN(builtin) __has_builtin(builtin) #else - #define NLOHMANN_JSON_HEDLEY_HAS_BUILTIN(builtin) (0) + #define JSON_HEDLEY_HAS_BUILTIN(builtin) (0) #endif -#if defined(NLOHMANN_JSON_HEDLEY_GNUC_HAS_BUILTIN) - #undef NLOHMANN_JSON_HEDLEY_GNUC_HAS_BUILTIN +#if defined(JSON_HEDLEY_GNUC_HAS_BUILTIN) + #undef JSON_HEDLEY_GNUC_HAS_BUILTIN #endif #if defined(__has_builtin) - #define NLOHMANN_JSON_HEDLEY_GNUC_HAS_BUILTIN(builtin,major,minor,patch) __has_builtin(builtin) + #define JSON_HEDLEY_GNUC_HAS_BUILTIN(builtin,major,minor,patch) __has_builtin(builtin) #else - #define NLOHMANN_JSON_HEDLEY_GNUC_HAS_BUILTIN(builtin,major,minor,patch) NLOHMANN_JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch) + #define JSON_HEDLEY_GNUC_HAS_BUILTIN(builtin,major,minor,patch) JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch) #endif -#if defined(NLOHMANN_JSON_HEDLEY_GCC_HAS_BUILTIN) - #undef NLOHMANN_JSON_HEDLEY_GCC_HAS_BUILTIN +#if defined(JSON_HEDLEY_GCC_HAS_BUILTIN) + #undef JSON_HEDLEY_GCC_HAS_BUILTIN #endif #if defined(__has_builtin) - #define NLOHMANN_JSON_HEDLEY_GCC_HAS_BUILTIN(builtin,major,minor,patch) __has_builtin(builtin) + #define JSON_HEDLEY_GCC_HAS_BUILTIN(builtin,major,minor,patch) __has_builtin(builtin) #else - #define NLOHMANN_JSON_HEDLEY_GCC_HAS_BUILTIN(builtin,major,minor,patch) NLOHMANN_JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch) + #define JSON_HEDLEY_GCC_HAS_BUILTIN(builtin,major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch) #endif -#if defined(NLOHMANN_JSON_HEDLEY_HAS_FEATURE) - #undef NLOHMANN_JSON_HEDLEY_HAS_FEATURE +#if defined(JSON_HEDLEY_HAS_FEATURE) + #undef JSON_HEDLEY_HAS_FEATURE #endif #if defined(__has_feature) - #define NLOHMANN_JSON_HEDLEY_HAS_FEATURE(feature) __has_feature(feature) + #define JSON_HEDLEY_HAS_FEATURE(feature) __has_feature(feature) #else - #define NLOHMANN_JSON_HEDLEY_HAS_FEATURE(feature) (0) + #define JSON_HEDLEY_HAS_FEATURE(feature) (0) #endif -#if defined(NLOHMANN_JSON_HEDLEY_GNUC_HAS_FEATURE) - #undef NLOHMANN_JSON_HEDLEY_GNUC_HAS_FEATURE +#if defined(JSON_HEDLEY_GNUC_HAS_FEATURE) + #undef JSON_HEDLEY_GNUC_HAS_FEATURE #endif #if defined(__has_feature) - #define NLOHMANN_JSON_HEDLEY_GNUC_HAS_FEATURE(feature,major,minor,patch) __has_feature(feature) + #define JSON_HEDLEY_GNUC_HAS_FEATURE(feature,major,minor,patch) __has_feature(feature) #else - #define NLOHMANN_JSON_HEDLEY_GNUC_HAS_FEATURE(feature,major,minor,patch) NLOHMANN_JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch) + #define JSON_HEDLEY_GNUC_HAS_FEATURE(feature,major,minor,patch) JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch) #endif -#if defined(NLOHMANN_JSON_HEDLEY_GCC_HAS_FEATURE) - #undef NLOHMANN_JSON_HEDLEY_GCC_HAS_FEATURE +#if defined(JSON_HEDLEY_GCC_HAS_FEATURE) + #undef JSON_HEDLEY_GCC_HAS_FEATURE #endif #if defined(__has_feature) - #define NLOHMANN_JSON_HEDLEY_GCC_HAS_FEATURE(feature,major,minor,patch) __has_feature(feature) + #define JSON_HEDLEY_GCC_HAS_FEATURE(feature,major,minor,patch) __has_feature(feature) #else - #define NLOHMANN_JSON_HEDLEY_GCC_HAS_FEATURE(feature,major,minor,patch) NLOHMANN_JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch) + #define JSON_HEDLEY_GCC_HAS_FEATURE(feature,major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch) #endif -#if defined(NLOHMANN_JSON_HEDLEY_HAS_EXTENSION) - #undef NLOHMANN_JSON_HEDLEY_HAS_EXTENSION +#if defined(JSON_HEDLEY_HAS_EXTENSION) + #undef JSON_HEDLEY_HAS_EXTENSION #endif #if defined(__has_extension) - #define NLOHMANN_JSON_HEDLEY_HAS_EXTENSION(extension) __has_extension(extension) + #define JSON_HEDLEY_HAS_EXTENSION(extension) __has_extension(extension) #else - #define NLOHMANN_JSON_HEDLEY_HAS_EXTENSION(extension) (0) + #define JSON_HEDLEY_HAS_EXTENSION(extension) (0) #endif -#if defined(NLOHMANN_JSON_HEDLEY_GNUC_HAS_EXTENSION) - #undef NLOHMANN_JSON_HEDLEY_GNUC_HAS_EXTENSION +#if defined(JSON_HEDLEY_GNUC_HAS_EXTENSION) + #undef JSON_HEDLEY_GNUC_HAS_EXTENSION #endif #if defined(__has_extension) - #define NLOHMANN_JSON_HEDLEY_GNUC_HAS_EXTENSION(extension,major,minor,patch) __has_extension(extension) + #define JSON_HEDLEY_GNUC_HAS_EXTENSION(extension,major,minor,patch) __has_extension(extension) #else - #define NLOHMANN_JSON_HEDLEY_GNUC_HAS_EXTENSION(extension,major,minor,patch) NLOHMANN_JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch) + #define JSON_HEDLEY_GNUC_HAS_EXTENSION(extension,major,minor,patch) JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch) #endif -#if defined(NLOHMANN_JSON_HEDLEY_GCC_HAS_EXTENSION) - #undef NLOHMANN_JSON_HEDLEY_GCC_HAS_EXTENSION +#if defined(JSON_HEDLEY_GCC_HAS_EXTENSION) + #undef JSON_HEDLEY_GCC_HAS_EXTENSION #endif #if defined(__has_extension) - #define NLOHMANN_JSON_HEDLEY_GCC_HAS_EXTENSION(extension,major,minor,patch) __has_extension(extension) + #define JSON_HEDLEY_GCC_HAS_EXTENSION(extension,major,minor,patch) __has_extension(extension) #else - #define NLOHMANN_JSON_HEDLEY_GCC_HAS_EXTENSION(extension,major,minor,patch) NLOHMANN_JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch) + #define JSON_HEDLEY_GCC_HAS_EXTENSION(extension,major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch) #endif -#if defined(NLOHMANN_JSON_HEDLEY_HAS_DECLSPEC_ATTRIBUTE) - #undef NLOHMANN_JSON_HEDLEY_HAS_DECLSPEC_ATTRIBUTE +#if defined(JSON_HEDLEY_HAS_DECLSPEC_ATTRIBUTE) + #undef JSON_HEDLEY_HAS_DECLSPEC_ATTRIBUTE #endif #if defined(__has_declspec_attribute) - #define NLOHMANN_JSON_HEDLEY_HAS_DECLSPEC_ATTRIBUTE(attribute) __has_declspec_attribute(attribute) + #define JSON_HEDLEY_HAS_DECLSPEC_ATTRIBUTE(attribute) __has_declspec_attribute(attribute) #else - #define NLOHMANN_JSON_HEDLEY_HAS_DECLSPEC_ATTRIBUTE(attribute) (0) + #define JSON_HEDLEY_HAS_DECLSPEC_ATTRIBUTE(attribute) (0) #endif -#if defined(NLOHMANN_JSON_HEDLEY_GNUC_HAS_DECLSPEC_ATTRIBUTE) - #undef NLOHMANN_JSON_HEDLEY_GNUC_HAS_DECLSPEC_ATTRIBUTE +#if defined(JSON_HEDLEY_GNUC_HAS_DECLSPEC_ATTRIBUTE) + #undef JSON_HEDLEY_GNUC_HAS_DECLSPEC_ATTRIBUTE #endif #if defined(__has_declspec_attribute) - #define NLOHMANN_JSON_HEDLEY_GNUC_HAS_DECLSPEC_ATTRIBUTE(attribute,major,minor,patch) __has_declspec_attribute(attribute) + #define JSON_HEDLEY_GNUC_HAS_DECLSPEC_ATTRIBUTE(attribute,major,minor,patch) __has_declspec_attribute(attribute) #else - #define NLOHMANN_JSON_HEDLEY_GNUC_HAS_DECLSPEC_ATTRIBUTE(attribute,major,minor,patch) NLOHMANN_JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch) + #define JSON_HEDLEY_GNUC_HAS_DECLSPEC_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch) #endif -#if defined(NLOHMANN_JSON_HEDLEY_GCC_HAS_DECLSPEC_ATTRIBUTE) - #undef NLOHMANN_JSON_HEDLEY_GCC_HAS_DECLSPEC_ATTRIBUTE +#if defined(JSON_HEDLEY_GCC_HAS_DECLSPEC_ATTRIBUTE) + #undef JSON_HEDLEY_GCC_HAS_DECLSPEC_ATTRIBUTE #endif #if defined(__has_declspec_attribute) - #define NLOHMANN_JSON_HEDLEY_GCC_HAS_DECLSPEC_ATTRIBUTE(attribute,major,minor,patch) __has_declspec_attribute(attribute) + #define JSON_HEDLEY_GCC_HAS_DECLSPEC_ATTRIBUTE(attribute,major,minor,patch) __has_declspec_attribute(attribute) #else - #define NLOHMANN_JSON_HEDLEY_GCC_HAS_DECLSPEC_ATTRIBUTE(attribute,major,minor,patch) NLOHMANN_JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch) + #define JSON_HEDLEY_GCC_HAS_DECLSPEC_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch) #endif -#if defined(NLOHMANN_JSON_HEDLEY_HAS_WARNING) - #undef NLOHMANN_JSON_HEDLEY_HAS_WARNING +#if defined(JSON_HEDLEY_HAS_WARNING) + #undef JSON_HEDLEY_HAS_WARNING #endif #if defined(__has_warning) - #define NLOHMANN_JSON_HEDLEY_HAS_WARNING(warning) __has_warning(warning) + #define JSON_HEDLEY_HAS_WARNING(warning) __has_warning(warning) #else - #define NLOHMANN_JSON_HEDLEY_HAS_WARNING(warning) (0) + #define JSON_HEDLEY_HAS_WARNING(warning) (0) #endif -#if defined(NLOHMANN_JSON_HEDLEY_GNUC_HAS_WARNING) - #undef NLOHMANN_JSON_HEDLEY_GNUC_HAS_WARNING +#if defined(JSON_HEDLEY_GNUC_HAS_WARNING) + #undef JSON_HEDLEY_GNUC_HAS_WARNING #endif #if defined(__has_warning) - #define NLOHMANN_JSON_HEDLEY_GNUC_HAS_WARNING(warning,major,minor,patch) __has_warning(warning) + #define JSON_HEDLEY_GNUC_HAS_WARNING(warning,major,minor,patch) __has_warning(warning) #else - #define NLOHMANN_JSON_HEDLEY_GNUC_HAS_WARNING(warning,major,minor,patch) NLOHMANN_JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch) + #define JSON_HEDLEY_GNUC_HAS_WARNING(warning,major,minor,patch) JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch) #endif -#if defined(NLOHMANN_JSON_HEDLEY_GCC_HAS_WARNING) - #undef NLOHMANN_JSON_HEDLEY_GCC_HAS_WARNING +#if defined(JSON_HEDLEY_GCC_HAS_WARNING) + #undef JSON_HEDLEY_GCC_HAS_WARNING #endif #if defined(__has_warning) - #define NLOHMANN_JSON_HEDLEY_GCC_HAS_WARNING(warning,major,minor,patch) __has_warning(warning) + #define JSON_HEDLEY_GCC_HAS_WARNING(warning,major,minor,patch) __has_warning(warning) #else - #define NLOHMANN_JSON_HEDLEY_GCC_HAS_WARNING(warning,major,minor,patch) NLOHMANN_JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch) + #define JSON_HEDLEY_GCC_HAS_WARNING(warning,major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch) #endif #if \ (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)) || \ defined(__clang__) || \ - NLOHMANN_JSON_HEDLEY_GCC_VERSION_CHECK(3,0,0) || \ - NLOHMANN_JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ - NLOHMANN_JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0) || \ - NLOHMANN_JSON_HEDLEY_PGI_VERSION_CHECK(18,4,0) || \ - NLOHMANN_JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ - NLOHMANN_JSON_HEDLEY_TI_VERSION_CHECK(6,0,0) || \ - NLOHMANN_JSON_HEDLEY_CRAY_VERSION_CHECK(5,0,0) || \ - NLOHMANN_JSON_HEDLEY_TINYC_VERSION_CHECK(0,9,17) || \ - NLOHMANN_JSON_HEDLEY_SUNPRO_VERSION_CHECK(8,0,0) || \ - (NLOHMANN_JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) && defined(__C99_PRAGMA_OPERATOR)) - #define NLOHMANN_JSON_HEDLEY_PRAGMA(value) _Pragma(#value) -#elif NLOHMANN_JSON_HEDLEY_MSVC_VERSION_CHECK(15,0,0) - #define NLOHMANN_JSON_HEDLEY_PRAGMA(value) __pragma(value) + JSON_HEDLEY_GCC_VERSION_CHECK(3,0,0) || \ + JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ + JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0) || \ + JSON_HEDLEY_PGI_VERSION_CHECK(18,4,0) || \ + JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ + JSON_HEDLEY_TI_VERSION_CHECK(6,0,0) || \ + JSON_HEDLEY_CRAY_VERSION_CHECK(5,0,0) || \ + JSON_HEDLEY_TINYC_VERSION_CHECK(0,9,17) || \ + JSON_HEDLEY_SUNPRO_VERSION_CHECK(8,0,0) || \ + (JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) && defined(__C99_PRAGMA_OPERATOR)) + #define JSON_HEDLEY_PRAGMA(value) _Pragma(#value) +#elif JSON_HEDLEY_MSVC_VERSION_CHECK(15,0,0) + #define JSON_HEDLEY_PRAGMA(value) __pragma(value) #else - #define NLOHMANN_JSON_HEDLEY_PRAGMA(value) + #define JSON_HEDLEY_PRAGMA(value) #endif -#if defined(NLOHMANN_JSON_HEDLEY_DIAGNOSTIC_PUSH) - #undef NLOHMANN_JSON_HEDLEY_DIAGNOSTIC_PUSH +#if defined(JSON_HEDLEY_DIAGNOSTIC_PUSH) + #undef JSON_HEDLEY_DIAGNOSTIC_PUSH #endif -#if defined(NLOHMANN_JSON_HEDLEY_DIAGNOSTIC_POP) - #undef NLOHMANN_JSON_HEDLEY_DIAGNOSTIC_POP +#if defined(JSON_HEDLEY_DIAGNOSTIC_POP) + #undef JSON_HEDLEY_DIAGNOSTIC_POP #endif #if defined(__clang__) - #define NLOHMANN_JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("clang diagnostic push") - #define NLOHMANN_JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("clang diagnostic pop") -#elif NLOHMANN_JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) - #define NLOHMANN_JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("warning(push)") - #define NLOHMANN_JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("warning(pop)") -#elif NLOHMANN_JSON_HEDLEY_GCC_VERSION_CHECK(4,6,0) - #define NLOHMANN_JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("GCC diagnostic push") - #define NLOHMANN_JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("GCC diagnostic pop") -#elif NLOHMANN_JSON_HEDLEY_MSVC_VERSION_CHECK(15,0,0) - #define NLOHMANN_JSON_HEDLEY_DIAGNOSTIC_PUSH __pragma(warning(push)) - #define NLOHMANN_JSON_HEDLEY_DIAGNOSTIC_POP __pragma(warning(pop)) -#elif NLOHMANN_JSON_HEDLEY_ARM_VERSION_CHECK(5,6,0) - #define NLOHMANN_JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("push") - #define NLOHMANN_JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("pop") -#elif NLOHMANN_JSON_HEDLEY_TI_VERSION_CHECK(8,1,0) - #define NLOHMANN_JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("diag_push") - #define NLOHMANN_JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("diag_pop") -#elif NLOHMANN_JSON_HEDLEY_PELLES_VERSION_CHECK(2,90,0) - #define NLOHMANN_JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("warning(push)") - #define NLOHMANN_JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("warning(pop)") + #define JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("clang diagnostic push") + #define JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("clang diagnostic pop") +#elif JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) + #define JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("warning(push)") + #define JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("warning(pop)") +#elif JSON_HEDLEY_GCC_VERSION_CHECK(4,6,0) + #define JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("GCC diagnostic push") + #define JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("GCC diagnostic pop") +#elif JSON_HEDLEY_MSVC_VERSION_CHECK(15,0,0) + #define JSON_HEDLEY_DIAGNOSTIC_PUSH __pragma(warning(push)) + #define JSON_HEDLEY_DIAGNOSTIC_POP __pragma(warning(pop)) +#elif JSON_HEDLEY_ARM_VERSION_CHECK(5,6,0) + #define JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("push") + #define JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("pop") +#elif JSON_HEDLEY_TI_VERSION_CHECK(8,1,0) + #define JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("diag_push") + #define JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("diag_pop") +#elif JSON_HEDLEY_PELLES_VERSION_CHECK(2,90,0) + #define JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("warning(push)") + #define JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("warning(pop)") #else - #define NLOHMANN_JSON_HEDLEY_DIAGNOSTIC_PUSH - #define NLOHMANN_JSON_HEDLEY_DIAGNOSTIC_POP + #define JSON_HEDLEY_DIAGNOSTIC_PUSH + #define JSON_HEDLEY_DIAGNOSTIC_POP #endif -#if defined(NLOHMANN_JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED) - #undef NLOHMANN_JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED +#if defined(JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED) + #undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED #endif -#if NLOHMANN_JSON_HEDLEY_HAS_WARNING("-Wdeprecated-declarations") - #define NLOHMANN_JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("clang diagnostic ignored \"-Wdeprecated-declarations\"") -#elif NLOHMANN_JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) - #define NLOHMANN_JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("warning(disable:1478 1786)") -#elif NLOHMANN_JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) - #define NLOHMANN_JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("diag_suppress 1215,1444") -#elif NLOHMANN_JSON_HEDLEY_GCC_VERSION_CHECK(4,3,0) - #define NLOHMANN_JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"") -#elif NLOHMANN_JSON_HEDLEY_MSVC_VERSION_CHECK(15,0,0) - #define NLOHMANN_JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED __pragma(warning(disable:4996)) -#elif NLOHMANN_JSON_HEDLEY_TI_VERSION_CHECK(8,0,0) - #define NLOHMANN_JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("diag_suppress 1291,1718") -#elif NLOHMANN_JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,13,0) && !defined(__cplusplus) - #define NLOHMANN_JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("error_messages(off,E_DEPRECATED_ATT,E_DEPRECATED_ATT_MESS)") -#elif NLOHMANN_JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,13,0) && defined(__cplusplus) - #define NLOHMANN_JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("error_messages(off,symdeprecated,symdeprecated2)") -#elif NLOHMANN_JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0) - #define NLOHMANN_JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("diag_suppress=Pe1444,Pe1215") -#elif NLOHMANN_JSON_HEDLEY_PELLES_VERSION_CHECK(2,90,0) - #define NLOHMANN_JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("warn(disable:2241)") +#if JSON_HEDLEY_HAS_WARNING("-Wdeprecated-declarations") + #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("clang diagnostic ignored \"-Wdeprecated-declarations\"") +#elif JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) + #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("warning(disable:1478 1786)") +#elif JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) + #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("diag_suppress 1215,1444") +#elif JSON_HEDLEY_GCC_VERSION_CHECK(4,3,0) + #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"") +#elif JSON_HEDLEY_MSVC_VERSION_CHECK(15,0,0) + #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED __pragma(warning(disable:4996)) +#elif JSON_HEDLEY_TI_VERSION_CHECK(8,0,0) + #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("diag_suppress 1291,1718") +#elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,13,0) && !defined(__cplusplus) + #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("error_messages(off,E_DEPRECATED_ATT,E_DEPRECATED_ATT_MESS)") +#elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,13,0) && defined(__cplusplus) + #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("error_messages(off,symdeprecated,symdeprecated2)") +#elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0) + #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("diag_suppress=Pe1444,Pe1215") +#elif JSON_HEDLEY_PELLES_VERSION_CHECK(2,90,0) + #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("warn(disable:2241)") #else - #define NLOHMANN_JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED + #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED #endif -#if defined(NLOHMANN_JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS) - #undef NLOHMANN_JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS +#if defined(JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS) + #undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS #endif -#if NLOHMANN_JSON_HEDLEY_HAS_WARNING("-Wunknown-pragmas") - #define NLOHMANN_JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("clang diagnostic ignored \"-Wunknown-pragmas\"") -#elif NLOHMANN_JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) - #define NLOHMANN_JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("warning(disable:161)") -#elif NLOHMANN_JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) - #define NLOHMANN_JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("diag_suppress 1675") -#elif NLOHMANN_JSON_HEDLEY_GCC_VERSION_CHECK(4,3,0) - #define NLOHMANN_JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("GCC diagnostic ignored \"-Wunknown-pragmas\"") -#elif NLOHMANN_JSON_HEDLEY_MSVC_VERSION_CHECK(15,0,0) - #define NLOHMANN_JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS __pragma(warning(disable:4068)) -#elif NLOHMANN_JSON_HEDLEY_TI_VERSION_CHECK(8,0,0) - #define NLOHMANN_JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("diag_suppress 163") -#elif NLOHMANN_JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0) - #define NLOHMANN_JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("diag_suppress=Pe161") +#if JSON_HEDLEY_HAS_WARNING("-Wunknown-pragmas") + #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("clang diagnostic ignored \"-Wunknown-pragmas\"") +#elif JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) + #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("warning(disable:161)") +#elif JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) + #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("diag_suppress 1675") +#elif JSON_HEDLEY_GCC_VERSION_CHECK(4,3,0) + #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("GCC diagnostic ignored \"-Wunknown-pragmas\"") +#elif JSON_HEDLEY_MSVC_VERSION_CHECK(15,0,0) + #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS __pragma(warning(disable:4068)) +#elif JSON_HEDLEY_TI_VERSION_CHECK(8,0,0) + #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("diag_suppress 163") +#elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0) + #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("diag_suppress=Pe161") #else - #define NLOHMANN_JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS + #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS #endif -#if defined(NLOHMANN_JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL) - #undef NLOHMANN_JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL +#if defined(JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL) + #undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL #endif -#if NLOHMANN_JSON_HEDLEY_HAS_WARNING("-Wcast-qual") - #define NLOHMANN_JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL _Pragma("clang diagnostic ignored \"-Wcast-qual\"") -#elif NLOHMANN_JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) - #define NLOHMANN_JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL _Pragma("warning(disable:2203 2331)") -#elif NLOHMANN_JSON_HEDLEY_GCC_VERSION_CHECK(3,0,0) - #define NLOHMANN_JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL _Pragma("GCC diagnostic ignored \"-Wcast-qual\"") +#if JSON_HEDLEY_HAS_WARNING("-Wcast-qual") + #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL _Pragma("clang diagnostic ignored \"-Wcast-qual\"") +#elif JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) + #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL _Pragma("warning(disable:2203 2331)") +#elif JSON_HEDLEY_GCC_VERSION_CHECK(3,0,0) + #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL _Pragma("GCC diagnostic ignored \"-Wcast-qual\"") #else - #define NLOHMANN_JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL + #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL #endif -#if defined(NLOHMANN_JSON_HEDLEY_DEPRECATED) - #undef NLOHMANN_JSON_HEDLEY_DEPRECATED +#if defined(JSON_HEDLEY_DEPRECATED) + #undef JSON_HEDLEY_DEPRECATED #endif -#if defined(NLOHMANN_JSON_HEDLEY_DEPRECATED_FOR) - #undef NLOHMANN_JSON_HEDLEY_DEPRECATED_FOR +#if defined(JSON_HEDLEY_DEPRECATED_FOR) + #undef JSON_HEDLEY_DEPRECATED_FOR #endif #if defined(__cplusplus) && (__cplusplus >= 201402L) - #define NLOHMANN_JSON_HEDLEY_DEPRECATED(since) [[deprecated("Since " #since)]] - #define NLOHMANN_JSON_HEDLEY_DEPRECATED_FOR(since, replacement) [[deprecated("Since " #since "; use " #replacement)]] + #define JSON_HEDLEY_DEPRECATED(since) [[deprecated("Since " #since)]] + #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) [[deprecated("Since " #since "; use " #replacement)]] #elif \ - NLOHMANN_JSON_HEDLEY_HAS_EXTENSION(attribute_deprecated_with_message) || \ - NLOHMANN_JSON_HEDLEY_GCC_VERSION_CHECK(4,5,0) || \ - NLOHMANN_JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ - NLOHMANN_JSON_HEDLEY_ARM_VERSION_CHECK(5,6,0) || \ - NLOHMANN_JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,13,0) || \ - NLOHMANN_JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) || \ - NLOHMANN_JSON_HEDLEY_TI_VERSION_CHECK(8,3,0) - #define NLOHMANN_JSON_HEDLEY_DEPRECATED(since) __attribute__((__deprecated__("Since " #since))) - #define NLOHMANN_JSON_HEDLEY_DEPRECATED_FOR(since, replacement) __attribute__((__deprecated__("Since " #since "; use " #replacement))) + JSON_HEDLEY_HAS_EXTENSION(attribute_deprecated_with_message) || \ + JSON_HEDLEY_GCC_VERSION_CHECK(4,5,0) || \ + JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ + JSON_HEDLEY_ARM_VERSION_CHECK(5,6,0) || \ + JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,13,0) || \ + JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) || \ + JSON_HEDLEY_TI_VERSION_CHECK(8,3,0) + #define JSON_HEDLEY_DEPRECATED(since) __attribute__((__deprecated__("Since " #since))) + #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) __attribute__((__deprecated__("Since " #since "; use " #replacement))) #elif \ - NLOHMANN_JSON_HEDLEY_HAS_ATTRIBUTE(deprecated) || \ - NLOHMANN_JSON_HEDLEY_GCC_VERSION_CHECK(3,1,0) || \ - NLOHMANN_JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ - NLOHMANN_JSON_HEDLEY_TI_VERSION_CHECK(8,0,0) || \ - (NLOHMANN_JSON_HEDLEY_TI_VERSION_CHECK(7,3,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) - #define NLOHMANN_JSON_HEDLEY_DEPRECATED(since) __attribute__((__deprecated__)) - #define NLOHMANN_JSON_HEDLEY_DEPRECATED_FOR(since, replacement) __attribute__((__deprecated__)) -#elif NLOHMANN_JSON_HEDLEY_MSVC_VERSION_CHECK(14,0,0) - #define NLOHMANN_JSON_HEDLEY_DEPRECATED(since) __declspec(deprecated("Since " # since)) - #define NLOHMANN_JSON_HEDLEY_DEPRECATED_FOR(since, replacement) __declspec(deprecated("Since " #since "; use " #replacement)) + JSON_HEDLEY_HAS_ATTRIBUTE(deprecated) || \ + JSON_HEDLEY_GCC_VERSION_CHECK(3,1,0) || \ + JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ + JSON_HEDLEY_TI_VERSION_CHECK(8,0,0) || \ + (JSON_HEDLEY_TI_VERSION_CHECK(7,3,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) + #define JSON_HEDLEY_DEPRECATED(since) __attribute__((__deprecated__)) + #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) __attribute__((__deprecated__)) +#elif JSON_HEDLEY_MSVC_VERSION_CHECK(14,0,0) + #define JSON_HEDLEY_DEPRECATED(since) __declspec(deprecated("Since " # since)) + #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) __declspec(deprecated("Since " #since "; use " #replacement)) #elif \ - NLOHMANN_JSON_HEDLEY_MSVC_VERSION_CHECK(13,10,0) || \ - NLOHMANN_JSON_HEDLEY_PELLES_VERSION_CHECK(6,50,0) - #define NLOHMANN_JSON_HEDLEY_DEPRECATED(since) _declspec(deprecated) - #define NLOHMANN_JSON_HEDLEY_DEPRECATED_FOR(since, replacement) __declspec(deprecated) -#elif NLOHMANN_JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0) - #define NLOHMANN_JSON_HEDLEY_DEPRECATED(since) _Pragma("deprecated") - #define NLOHMANN_JSON_HEDLEY_DEPRECATED_FOR(since, replacement) _Pragma("deprecated") + JSON_HEDLEY_MSVC_VERSION_CHECK(13,10,0) || \ + JSON_HEDLEY_PELLES_VERSION_CHECK(6,50,0) + #define JSON_HEDLEY_DEPRECATED(since) _declspec(deprecated) + #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) __declspec(deprecated) +#elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0) + #define JSON_HEDLEY_DEPRECATED(since) _Pragma("deprecated") + #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) _Pragma("deprecated") #else - #define NLOHMANN_JSON_HEDLEY_DEPRECATED(since) - #define NLOHMANN_JSON_HEDLEY_DEPRECATED_FOR(since, replacement) + #define JSON_HEDLEY_DEPRECATED(since) + #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) #endif -#if defined(NLOHMANN_JSON_HEDLEY_UNAVAILABLE) - #undef NLOHMANN_JSON_HEDLEY_UNAVAILABLE +#if defined(JSON_HEDLEY_UNAVAILABLE) + #undef JSON_HEDLEY_UNAVAILABLE #endif #if \ - NLOHMANN_JSON_HEDLEY_HAS_ATTRIBUTE(warning) || \ - NLOHMANN_JSON_HEDLEY_GCC_VERSION_CHECK(4,3,0) || \ - NLOHMANN_JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) - #define NLOHMANN_JSON_HEDLEY_UNAVAILABLE(available_since) __attribute__((__warning__("Not available until " #available_since))) + JSON_HEDLEY_HAS_ATTRIBUTE(warning) || \ + JSON_HEDLEY_GCC_VERSION_CHECK(4,3,0) || \ + JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) + #define JSON_HEDLEY_UNAVAILABLE(available_since) __attribute__((__warning__("Not available until " #available_since))) #else - #define NLOHMANN_JSON_HEDLEY_UNAVAILABLE(available_since) + #define JSON_HEDLEY_UNAVAILABLE(available_since) #endif -#if defined(NLOHMANN_JSON_HEDLEY_WARN_UNUSED_RESULT) - #undef NLOHMANN_JSON_HEDLEY_WARN_UNUSED_RESULT +#if defined(JSON_HEDLEY_WARN_UNUSED_RESULT) + #undef JSON_HEDLEY_WARN_UNUSED_RESULT #endif #if defined(__cplusplus) && (__cplusplus >= 201703L) - #define NLOHMANN_JSON_HEDLEY_WARN_UNUSED_RESULT [[nodiscard]] + #define JSON_HEDLEY_WARN_UNUSED_RESULT [[nodiscard]] #elif \ - NLOHMANN_JSON_HEDLEY_HAS_ATTRIBUTE(warn_unused_result) || \ - NLOHMANN_JSON_HEDLEY_GCC_VERSION_CHECK(3,4,0) || \ - NLOHMANN_JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ - NLOHMANN_JSON_HEDLEY_TI_VERSION_CHECK(8,0,0) || \ - (NLOHMANN_JSON_HEDLEY_TI_VERSION_CHECK(7,3,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ - (NLOHMANN_JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,15,0) && defined(__cplusplus)) || \ - NLOHMANN_JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) - #define NLOHMANN_JSON_HEDLEY_WARN_UNUSED_RESULT __attribute__((__warn_unused_result__)) + JSON_HEDLEY_HAS_ATTRIBUTE(warn_unused_result) || \ + JSON_HEDLEY_GCC_VERSION_CHECK(3,4,0) || \ + JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ + JSON_HEDLEY_TI_VERSION_CHECK(8,0,0) || \ + (JSON_HEDLEY_TI_VERSION_CHECK(7,3,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ + (JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,15,0) && defined(__cplusplus)) || \ + JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) + #define JSON_HEDLEY_WARN_UNUSED_RESULT __attribute__((__warn_unused_result__)) #elif defined(_Check_return_) /* SAL */ - #define NLOHMANN_JSON_HEDLEY_WARN_UNUSED_RESULT _Check_return_ + #define JSON_HEDLEY_WARN_UNUSED_RESULT _Check_return_ #else - #define NLOHMANN_JSON_HEDLEY_WARN_UNUSED_RESULT + #define JSON_HEDLEY_WARN_UNUSED_RESULT #endif -#if defined(NLOHMANN_JSON_HEDLEY_SENTINEL) - #undef NLOHMANN_JSON_HEDLEY_SENTINEL +#if defined(JSON_HEDLEY_SENTINEL) + #undef JSON_HEDLEY_SENTINEL #endif #if \ - NLOHMANN_JSON_HEDLEY_HAS_ATTRIBUTE(sentinel) || \ - NLOHMANN_JSON_HEDLEY_GCC_VERSION_CHECK(4,0,0) || \ - NLOHMANN_JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ - NLOHMANN_JSON_HEDLEY_ARM_VERSION_CHECK(5,4,0) - #define NLOHMANN_JSON_HEDLEY_SENTINEL(position) __attribute__((__sentinel__(position))) + JSON_HEDLEY_HAS_ATTRIBUTE(sentinel) || \ + JSON_HEDLEY_GCC_VERSION_CHECK(4,0,0) || \ + JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ + JSON_HEDLEY_ARM_VERSION_CHECK(5,4,0) + #define JSON_HEDLEY_SENTINEL(position) __attribute__((__sentinel__(position))) #else - #define NLOHMANN_JSON_HEDLEY_SENTINEL(position) + #define JSON_HEDLEY_SENTINEL(position) #endif -#if defined(NLOHMANN_JSON_HEDLEY_NO_RETURN) - #undef NLOHMANN_JSON_HEDLEY_NO_RETURN +#if defined(JSON_HEDLEY_NO_RETURN) + #undef JSON_HEDLEY_NO_RETURN #endif -#if NLOHMANN_JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0) - #define NLOHMANN_JSON_HEDLEY_NO_RETURN __noreturn -#elif NLOHMANN_JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) - #define NLOHMANN_JSON_HEDLEY_NO_RETURN __attribute__((__noreturn__)) +#if JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0) + #define JSON_HEDLEY_NO_RETURN __noreturn +#elif JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) + #define JSON_HEDLEY_NO_RETURN __attribute__((__noreturn__)) #elif defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L - #define NLOHMANN_JSON_HEDLEY_NO_RETURN _Noreturn + #define JSON_HEDLEY_NO_RETURN _Noreturn #elif defined(__cplusplus) && (__cplusplus >= 201103L) - #define NLOHMANN_JSON_HEDLEY_NO_RETURN [[noreturn]] + #define JSON_HEDLEY_NO_RETURN [[noreturn]] #elif \ - NLOHMANN_JSON_HEDLEY_HAS_ATTRIBUTE(noreturn) || \ - NLOHMANN_JSON_HEDLEY_GCC_VERSION_CHECK(3,2,0) || \ - NLOHMANN_JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \ - NLOHMANN_JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ - NLOHMANN_JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \ - NLOHMANN_JSON_HEDLEY_TI_VERSION_CHECK(18,0,0) || \ - (NLOHMANN_JSON_HEDLEY_TI_VERSION_CHECK(17,3,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) - #define NLOHMANN_JSON_HEDLEY_NO_RETURN __attribute__((__noreturn__)) -#elif NLOHMANN_JSON_HEDLEY_MSVC_VERSION_CHECK(13,10,0) - #define NLOHMANN_JSON_HEDLEY_NO_RETURN __declspec(noreturn) -#elif NLOHMANN_JSON_HEDLEY_TI_VERSION_CHECK(6,0,0) && defined(__cplusplus) - #define NLOHMANN_JSON_HEDLEY_NO_RETURN _Pragma("FUNC_NEVER_RETURNS;") -#elif NLOHMANN_JSON_HEDLEY_COMPCERT_VERSION_CHECK(3,2,0) - #define NLOHMANN_JSON_HEDLEY_NO_RETURN __attribute((noreturn)) -#elif NLOHMANN_JSON_HEDLEY_PELLES_VERSION_CHECK(9,0,0) - #define NLOHMANN_JSON_HEDLEY_NO_RETURN __declspec(noreturn) + JSON_HEDLEY_HAS_ATTRIBUTE(noreturn) || \ + JSON_HEDLEY_GCC_VERSION_CHECK(3,2,0) || \ + JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \ + JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ + JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \ + JSON_HEDLEY_TI_VERSION_CHECK(18,0,0) || \ + (JSON_HEDLEY_TI_VERSION_CHECK(17,3,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) + #define JSON_HEDLEY_NO_RETURN __attribute__((__noreturn__)) +#elif JSON_HEDLEY_MSVC_VERSION_CHECK(13,10,0) + #define JSON_HEDLEY_NO_RETURN __declspec(noreturn) +#elif JSON_HEDLEY_TI_VERSION_CHECK(6,0,0) && defined(__cplusplus) + #define JSON_HEDLEY_NO_RETURN _Pragma("FUNC_NEVER_RETURNS;") +#elif JSON_HEDLEY_COMPCERT_VERSION_CHECK(3,2,0) + #define JSON_HEDLEY_NO_RETURN __attribute((noreturn)) +#elif JSON_HEDLEY_PELLES_VERSION_CHECK(9,0,0) + #define JSON_HEDLEY_NO_RETURN __declspec(noreturn) #else - #define NLOHMANN_JSON_HEDLEY_NO_RETURN + #define JSON_HEDLEY_NO_RETURN #endif -#if defined(NLOHMANN_JSON_HEDLEY_UNREACHABLE) - #undef NLOHMANN_JSON_HEDLEY_UNREACHABLE +#if defined(JSON_HEDLEY_UNREACHABLE) + #undef JSON_HEDLEY_UNREACHABLE #endif -#if defined(NLOHMANN_JSON_HEDLEY_UNREACHABLE_RETURN) - #undef NLOHMANN_JSON_HEDLEY_UNREACHABLE_RETURN +#if defined(JSON_HEDLEY_UNREACHABLE_RETURN) + #undef JSON_HEDLEY_UNREACHABLE_RETURN #endif #if \ - (NLOHMANN_JSON_HEDLEY_HAS_BUILTIN(__builtin_unreachable) && (!defined(NLOHMANN_JSON_HEDLEY_ARM_VERSION))) || \ - NLOHMANN_JSON_HEDLEY_GCC_VERSION_CHECK(4,5,0) || \ - NLOHMANN_JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ - NLOHMANN_JSON_HEDLEY_IBM_VERSION_CHECK(13,1,5) - #define NLOHMANN_JSON_HEDLEY_UNREACHABLE() __builtin_unreachable() -#elif NLOHMANN_JSON_HEDLEY_MSVC_VERSION_CHECK(13,10,0) - #define NLOHMANN_JSON_HEDLEY_UNREACHABLE() __assume(0) -#elif NLOHMANN_JSON_HEDLEY_TI_VERSION_CHECK(6,0,0) + (JSON_HEDLEY_HAS_BUILTIN(__builtin_unreachable) && (!defined(JSON_HEDLEY_ARM_VERSION))) || \ + JSON_HEDLEY_GCC_VERSION_CHECK(4,5,0) || \ + JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ + JSON_HEDLEY_IBM_VERSION_CHECK(13,1,5) + #define JSON_HEDLEY_UNREACHABLE() __builtin_unreachable() +#elif JSON_HEDLEY_MSVC_VERSION_CHECK(13,10,0) + #define JSON_HEDLEY_UNREACHABLE() __assume(0) +#elif JSON_HEDLEY_TI_VERSION_CHECK(6,0,0) #if defined(__cplusplus) - #define NLOHMANN_JSON_HEDLEY_UNREACHABLE() std::_nassert(0) + #define JSON_HEDLEY_UNREACHABLE() std::_nassert(0) #else - #define NLOHMANN_JSON_HEDLEY_UNREACHABLE() _nassert(0) + #define JSON_HEDLEY_UNREACHABLE() _nassert(0) #endif - #define NLOHMANN_JSON_HEDLEY_UNREACHABLE_RETURN(value) return value + #define JSON_HEDLEY_UNREACHABLE_RETURN(value) return value #elif defined(EXIT_FAILURE) - #define NLOHMANN_JSON_HEDLEY_UNREACHABLE() abort() + #define JSON_HEDLEY_UNREACHABLE() abort() #else - #define NLOHMANN_JSON_HEDLEY_UNREACHABLE() - #define NLOHMANN_JSON_HEDLEY_UNREACHABLE_RETURN(value) return value + #define JSON_HEDLEY_UNREACHABLE() + #define JSON_HEDLEY_UNREACHABLE_RETURN(value) return value #endif -#if !defined(NLOHMANN_JSON_HEDLEY_UNREACHABLE_RETURN) - #define NLOHMANN_JSON_HEDLEY_UNREACHABLE_RETURN(value) NLOHMANN_JSON_HEDLEY_UNREACHABLE() +#if !defined(JSON_HEDLEY_UNREACHABLE_RETURN) + #define JSON_HEDLEY_UNREACHABLE_RETURN(value) JSON_HEDLEY_UNREACHABLE() #endif -#if defined(NLOHMANN_JSON_HEDLEY_ASSUME) - #undef NLOHMANN_JSON_HEDLEY_ASSUME +#if defined(JSON_HEDLEY_ASSUME) + #undef JSON_HEDLEY_ASSUME #endif #if \ - NLOHMANN_JSON_HEDLEY_MSVC_VERSION_CHECK(13,10,0) || \ - NLOHMANN_JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) - #define NLOHMANN_JSON_HEDLEY_ASSUME(expr) __assume(expr) -#elif NLOHMANN_JSON_HEDLEY_HAS_BUILTIN(__builtin_assume) - #define NLOHMANN_JSON_HEDLEY_ASSUME(expr) __builtin_assume(expr) -#elif NLOHMANN_JSON_HEDLEY_TI_VERSION_CHECK(6,0,0) + JSON_HEDLEY_MSVC_VERSION_CHECK(13,10,0) || \ + JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) + #define JSON_HEDLEY_ASSUME(expr) __assume(expr) +#elif JSON_HEDLEY_HAS_BUILTIN(__builtin_assume) + #define JSON_HEDLEY_ASSUME(expr) __builtin_assume(expr) +#elif JSON_HEDLEY_TI_VERSION_CHECK(6,0,0) #if defined(__cplusplus) - #define NLOHMANN_JSON_HEDLEY_ASSUME(expr) std::_nassert(expr) + #define JSON_HEDLEY_ASSUME(expr) std::_nassert(expr) #else - #define NLOHMANN_JSON_HEDLEY_ASSUME(expr) _nassert(expr) + #define JSON_HEDLEY_ASSUME(expr) _nassert(expr) #endif #elif \ - (NLOHMANN_JSON_HEDLEY_HAS_BUILTIN(__builtin_unreachable) && !defined(NLOHMANN_JSON_HEDLEY_ARM_VERSION)) || \ - NLOHMANN_JSON_HEDLEY_GCC_VERSION_CHECK(4,5,0) || \ - NLOHMANN_JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ - NLOHMANN_JSON_HEDLEY_IBM_VERSION_CHECK(13,1,5) - #define NLOHMANN_JSON_HEDLEY_ASSUME(expr) ((void) ((expr) ? 1 : (__builtin_unreachable(), 1))) + (JSON_HEDLEY_HAS_BUILTIN(__builtin_unreachable) && !defined(JSON_HEDLEY_ARM_VERSION)) || \ + JSON_HEDLEY_GCC_VERSION_CHECK(4,5,0) || \ + JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ + JSON_HEDLEY_IBM_VERSION_CHECK(13,1,5) + #define JSON_HEDLEY_ASSUME(expr) ((void) ((expr) ? 1 : (__builtin_unreachable(), 1))) #else - #define NLOHMANN_JSON_HEDLEY_ASSUME(expr) ((void) (expr)) + #define JSON_HEDLEY_ASSUME(expr) ((void) (expr)) #endif -NLOHMANN_JSON_HEDLEY_DIAGNOSTIC_PUSH +JSON_HEDLEY_DIAGNOSTIC_PUSH #if \ - NLOHMANN_JSON_HEDLEY_HAS_WARNING("-Wvariadic-macros") || \ - NLOHMANN_JSON_HEDLEY_GCC_VERSION_CHECK(4,0,0) + JSON_HEDLEY_HAS_WARNING("-Wvariadic-macros") || \ + JSON_HEDLEY_GCC_VERSION_CHECK(4,0,0) #if defined(__clang__) #pragma clang diagnostic ignored "-Wvariadic-macros" - #elif defined(NLOHMANN_JSON_HEDLEY_GCC_VERSION) + #elif defined(JSON_HEDLEY_GCC_VERSION) #pragma GCC diagnostic ignored "-Wvariadic-macros" #endif #endif -#if defined(NLOHMANN_JSON_HEDLEY_NON_NULL) - #undef NLOHMANN_JSON_HEDLEY_NON_NULL +#if defined(JSON_HEDLEY_NON_NULL) + #undef JSON_HEDLEY_NON_NULL #endif #if \ - NLOHMANN_JSON_HEDLEY_HAS_ATTRIBUTE(nonnull) || \ - NLOHMANN_JSON_HEDLEY_GCC_VERSION_CHECK(3,3,0) || \ - NLOHMANN_JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ - NLOHMANN_JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) - #define NLOHMANN_JSON_HEDLEY_NON_NULL(...) __attribute__((__nonnull__(__VA_ARGS__))) + JSON_HEDLEY_HAS_ATTRIBUTE(nonnull) || \ + JSON_HEDLEY_GCC_VERSION_CHECK(3,3,0) || \ + JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ + JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) + #define JSON_HEDLEY_NON_NULL(...) __attribute__((__nonnull__(__VA_ARGS__))) #else - #define NLOHMANN_JSON_HEDLEY_NON_NULL(...) + #define JSON_HEDLEY_NON_NULL(...) #endif -NLOHMANN_JSON_HEDLEY_DIAGNOSTIC_POP +JSON_HEDLEY_DIAGNOSTIC_POP -#if defined(NLOHMANN_JSON_HEDLEY_PRINTF_FORMAT) - #undef NLOHMANN_JSON_HEDLEY_PRINTF_FORMAT +#if defined(JSON_HEDLEY_PRINTF_FORMAT) + #undef JSON_HEDLEY_PRINTF_FORMAT #endif -#if defined(__MINGW32__) && NLOHMANN_JSON_HEDLEY_GCC_HAS_ATTRIBUTE(format,4,4,0) && !defined(__USE_MINGW_ANSI_STDIO) - #define NLOHMANN_JSON_HEDLEY_PRINTF_FORMAT(string_idx,first_to_check) __attribute__((__format__(ms_printf, string_idx, first_to_check))) -#elif defined(__MINGW32__) && NLOHMANN_JSON_HEDLEY_GCC_HAS_ATTRIBUTE(format,4,4,0) && defined(__USE_MINGW_ANSI_STDIO) - #define NLOHMANN_JSON_HEDLEY_PRINTF_FORMAT(string_idx,first_to_check) __attribute__((__format__(gnu_printf, string_idx, first_to_check))) +#if defined(__MINGW32__) && JSON_HEDLEY_GCC_HAS_ATTRIBUTE(format,4,4,0) && !defined(__USE_MINGW_ANSI_STDIO) + #define JSON_HEDLEY_PRINTF_FORMAT(string_idx,first_to_check) __attribute__((__format__(ms_printf, string_idx, first_to_check))) +#elif defined(__MINGW32__) && JSON_HEDLEY_GCC_HAS_ATTRIBUTE(format,4,4,0) && defined(__USE_MINGW_ANSI_STDIO) + #define JSON_HEDLEY_PRINTF_FORMAT(string_idx,first_to_check) __attribute__((__format__(gnu_printf, string_idx, first_to_check))) #elif \ - NLOHMANN_JSON_HEDLEY_HAS_ATTRIBUTE(format) || \ - NLOHMANN_JSON_HEDLEY_GCC_VERSION_CHECK(3,1,0) || \ - NLOHMANN_JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ - NLOHMANN_JSON_HEDLEY_ARM_VERSION_CHECK(5,6,0) || \ - NLOHMANN_JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \ - NLOHMANN_JSON_HEDLEY_TI_VERSION_CHECK(8,0,0) || \ - (NLOHMANN_JSON_HEDLEY_TI_VERSION_CHECK(7,3,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) - #define NLOHMANN_JSON_HEDLEY_PRINTF_FORMAT(string_idx,first_to_check) __attribute__((__format__(__printf__, string_idx, first_to_check))) -#elif NLOHMANN_JSON_HEDLEY_PELLES_VERSION_CHECK(6,0,0) - #define NLOHMANN_JSON_HEDLEY_PRINTF_FORMAT(string_idx,first_to_check) __declspec(vaformat(printf,string_idx,first_to_check)) + JSON_HEDLEY_HAS_ATTRIBUTE(format) || \ + JSON_HEDLEY_GCC_VERSION_CHECK(3,1,0) || \ + JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ + JSON_HEDLEY_ARM_VERSION_CHECK(5,6,0) || \ + JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \ + JSON_HEDLEY_TI_VERSION_CHECK(8,0,0) || \ + (JSON_HEDLEY_TI_VERSION_CHECK(7,3,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) + #define JSON_HEDLEY_PRINTF_FORMAT(string_idx,first_to_check) __attribute__((__format__(__printf__, string_idx, first_to_check))) +#elif JSON_HEDLEY_PELLES_VERSION_CHECK(6,0,0) + #define JSON_HEDLEY_PRINTF_FORMAT(string_idx,first_to_check) __declspec(vaformat(printf,string_idx,first_to_check)) #else - #define NLOHMANN_JSON_HEDLEY_PRINTF_FORMAT(string_idx,first_to_check) + #define JSON_HEDLEY_PRINTF_FORMAT(string_idx,first_to_check) #endif -#if defined(NLOHMANN_JSON_HEDLEY_CONSTEXPR) - #undef NLOHMANN_JSON_HEDLEY_CONSTEXPR +#if defined(JSON_HEDLEY_CONSTEXPR) + #undef JSON_HEDLEY_CONSTEXPR #endif #if defined(__cplusplus) #if __cplusplus >= 201103L - #define NLOHMANN_JSON_HEDLEY_CONSTEXPR constexpr + #define JSON_HEDLEY_CONSTEXPR constexpr #endif #endif -#if !defined(NLOHMANN_JSON_HEDLEY_CONSTEXPR) - #define NLOHMANN_JSON_HEDLEY_CONSTEXPR +#if !defined(JSON_HEDLEY_CONSTEXPR) + #define JSON_HEDLEY_CONSTEXPR #endif -#if defined(NLOHMANN_JSON_HEDLEY_PREDICT) - #undef NLOHMANN_JSON_HEDLEY_PREDICT +#if defined(JSON_HEDLEY_PREDICT) + #undef JSON_HEDLEY_PREDICT #endif -#if defined(NLOHMANN_JSON_HEDLEY_LIKELY) - #undef NLOHMANN_JSON_HEDLEY_LIKELY +#if defined(JSON_HEDLEY_LIKELY) + #undef JSON_HEDLEY_LIKELY #endif -#if defined(NLOHMANN_JSON_HEDLEY_UNLIKELY) - #undef NLOHMANN_JSON_HEDLEY_UNLIKELY +#if defined(JSON_HEDLEY_UNLIKELY) + #undef JSON_HEDLEY_UNLIKELY #endif -#if defined(NLOHMANN_JSON_HEDLEY_UNPREDICTABLE) - #undef NLOHMANN_JSON_HEDLEY_UNPREDICTABLE +#if defined(JSON_HEDLEY_UNPREDICTABLE) + #undef JSON_HEDLEY_UNPREDICTABLE #endif -#if NLOHMANN_JSON_HEDLEY_HAS_BUILTIN(__builtin_unpredictable) - #define NLOHMANN_JSON_HEDLEY_UNPREDICTABLE(expr) __builtin_unpredictable(!!(expr)) +#if JSON_HEDLEY_HAS_BUILTIN(__builtin_unpredictable) + #define JSON_HEDLEY_UNPREDICTABLE(expr) __builtin_unpredictable(!!(expr)) #endif #if \ - NLOHMANN_JSON_HEDLEY_HAS_BUILTIN(__builtin_expect_with_probability) || \ - NLOHMANN_JSON_HEDLEY_GCC_VERSION_CHECK(9,0,0) -# define NLOHMANN_JSON_HEDLEY_PREDICT(expr, value, probability) __builtin_expect_with_probability(expr, value, probability) -# define NLOHMANN_JSON_HEDLEY_PREDICT_TRUE(expr, probability) __builtin_expect_with_probability(!!(expr), 1, probability) -# define NLOHMANN_JSON_HEDLEY_PREDICT_FALSE(expr, probability) __builtin_expect_with_probability(!!(expr), 0, probability) -# define NLOHMANN_JSON_HEDLEY_LIKELY(expr) __builtin_expect(!!(expr), 1) -# define NLOHMANN_JSON_HEDLEY_UNLIKELY(expr) __builtin_expect(!!(expr), 0) -#if !defined(NLOHMANN_JSON_HEDLEY_BUILTIN_UNPREDICTABLE) - #define NLOHMANN_JSON_HEDLEY_BUILTIN_UNPREDICTABLE(expr) __builtin_expect_with_probability(!!(expr), 1, 0.5) + JSON_HEDLEY_HAS_BUILTIN(__builtin_expect_with_probability) || \ + JSON_HEDLEY_GCC_VERSION_CHECK(9,0,0) +# define JSON_HEDLEY_PREDICT(expr, value, probability) __builtin_expect_with_probability(expr, value, probability) +# define JSON_HEDLEY_PREDICT_TRUE(expr, probability) __builtin_expect_with_probability(!!(expr), 1, probability) +# define JSON_HEDLEY_PREDICT_FALSE(expr, probability) __builtin_expect_with_probability(!!(expr), 0, probability) +# define JSON_HEDLEY_LIKELY(expr) __builtin_expect(!!(expr), 1) +# define JSON_HEDLEY_UNLIKELY(expr) __builtin_expect(!!(expr), 0) +#if !defined(JSON_HEDLEY_BUILTIN_UNPREDICTABLE) + #define JSON_HEDLEY_BUILTIN_UNPREDICTABLE(expr) __builtin_expect_with_probability(!!(expr), 1, 0.5) #endif #elif \ - NLOHMANN_JSON_HEDLEY_HAS_BUILTIN(__builtin_expect) || \ - NLOHMANN_JSON_HEDLEY_GCC_VERSION_CHECK(3,0,0) || \ - NLOHMANN_JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ - (NLOHMANN_JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,15,0) && defined(__cplusplus)) || \ - NLOHMANN_JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ - NLOHMANN_JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \ - NLOHMANN_JSON_HEDLEY_TI_VERSION_CHECK(6,1,0) || \ - NLOHMANN_JSON_HEDLEY_TINYC_VERSION_CHECK(0,9,27) -# define NLOHMANN_JSON_HEDLEY_PREDICT(expr, expected, probability) \ + JSON_HEDLEY_HAS_BUILTIN(__builtin_expect) || \ + JSON_HEDLEY_GCC_VERSION_CHECK(3,0,0) || \ + JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ + (JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,15,0) && defined(__cplusplus)) || \ + JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ + JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \ + JSON_HEDLEY_TI_VERSION_CHECK(6,1,0) || \ + JSON_HEDLEY_TINYC_VERSION_CHECK(0,9,27) +# define JSON_HEDLEY_PREDICT(expr, expected, probability) \ (((probability) >= 0.9) ? __builtin_expect(!!(expr), (expected)) : (((void) (expected)), !!(expr))) -# define NLOHMANN_JSON_HEDLEY_PREDICT_TRUE(expr, probability) \ +# define JSON_HEDLEY_PREDICT_TRUE(expr, probability) \ (__extension__ ({ \ - NLOHMANN_JSON_HEDLEY_CONSTEXPR double hedley_probability_ = (probability); \ + JSON_HEDLEY_CONSTEXPR double hedley_probability_ = (probability); \ ((hedley_probability_ >= 0.9) ? __builtin_expect(!!(expr), 1) : ((hedley_probability_ <= 0.1) ? __builtin_expect(!!(expr), 0) : !!(expr))); \ })) -# define NLOHMANN_JSON_HEDLEY_PREDICT_FALSE(expr, probability) \ +# define JSON_HEDLEY_PREDICT_FALSE(expr, probability) \ (__extension__ ({ \ - NLOHMANN_JSON_HEDLEY_CONSTEXPR double hedley_probability_ = (probability); \ + JSON_HEDLEY_CONSTEXPR double hedley_probability_ = (probability); \ ((hedley_probability_ >= 0.9) ? __builtin_expect(!!(expr), 0) : ((hedley_probability_ <= 0.1) ? __builtin_expect(!!(expr), 1) : !!(expr))); \ })) -# define NLOHMANN_JSON_HEDLEY_LIKELY(expr) __builtin_expect(!!(expr), 1) -# define NLOHMANN_JSON_HEDLEY_UNLIKELY(expr) __builtin_expect(!!(expr), 0) +# define JSON_HEDLEY_LIKELY(expr) __builtin_expect(!!(expr), 1) +# define JSON_HEDLEY_UNLIKELY(expr) __builtin_expect(!!(expr), 0) #else -# define NLOHMANN_JSON_HEDLEY_PREDICT(expr, expected, probability) (((void) (expected)), !!(expr)) -# define NLOHMANN_JSON_HEDLEY_PREDICT_TRUE(expr, probability) (!!(expr)) -# define NLOHMANN_JSON_HEDLEY_PREDICT_FALSE(expr, probability) (!!(expr)) -# define NLOHMANN_JSON_HEDLEY_LIKELY(expr) (!!(expr)) -# define NLOHMANN_JSON_HEDLEY_UNLIKELY(expr) (!!(expr)) +# define JSON_HEDLEY_PREDICT(expr, expected, probability) (((void) (expected)), !!(expr)) +# define JSON_HEDLEY_PREDICT_TRUE(expr, probability) (!!(expr)) +# define JSON_HEDLEY_PREDICT_FALSE(expr, probability) (!!(expr)) +# define JSON_HEDLEY_LIKELY(expr) (!!(expr)) +# define JSON_HEDLEY_UNLIKELY(expr) (!!(expr)) #endif -#if !defined(NLOHMANN_JSON_HEDLEY_UNPREDICTABLE) - #define NLOHMANN_JSON_HEDLEY_UNPREDICTABLE(expr) NLOHMANN_JSON_HEDLEY_PREDICT(expr, 1, 0.5) +#if !defined(JSON_HEDLEY_UNPREDICTABLE) + #define JSON_HEDLEY_UNPREDICTABLE(expr) JSON_HEDLEY_PREDICT(expr, 1, 0.5) #endif -#if defined(NLOHMANN_JSON_HEDLEY_MALLOC) - #undef NLOHMANN_JSON_HEDLEY_MALLOC +#if defined(JSON_HEDLEY_MALLOC) + #undef JSON_HEDLEY_MALLOC #endif #if \ - NLOHMANN_JSON_HEDLEY_HAS_ATTRIBUTE(malloc) || \ - NLOHMANN_JSON_HEDLEY_GCC_VERSION_CHECK(3,1,0) || \ - NLOHMANN_JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ - NLOHMANN_JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \ - NLOHMANN_JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ - NLOHMANN_JSON_HEDLEY_IBM_VERSION_CHECK(12,1,0) || \ - NLOHMANN_JSON_HEDLEY_TI_VERSION_CHECK(8,0,0) || \ - (NLOHMANN_JSON_HEDLEY_TI_VERSION_CHECK(7,3,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) - #define NLOHMANN_JSON_HEDLEY_MALLOC __attribute__((__malloc__)) -#elif NLOHMANN_JSON_HEDLEY_MSVC_VERSION_CHECK(14, 0, 0) - #define NLOHMANN_JSON_HEDLEY_MALLOC __declspec(restrict) + JSON_HEDLEY_HAS_ATTRIBUTE(malloc) || \ + JSON_HEDLEY_GCC_VERSION_CHECK(3,1,0) || \ + JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ + JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \ + JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ + JSON_HEDLEY_IBM_VERSION_CHECK(12,1,0) || \ + JSON_HEDLEY_TI_VERSION_CHECK(8,0,0) || \ + (JSON_HEDLEY_TI_VERSION_CHECK(7,3,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) + #define JSON_HEDLEY_MALLOC __attribute__((__malloc__)) +#elif JSON_HEDLEY_MSVC_VERSION_CHECK(14, 0, 0) + #define JSON_HEDLEY_MALLOC __declspec(restrict) #else - #define NLOHMANN_JSON_HEDLEY_MALLOC + #define JSON_HEDLEY_MALLOC #endif -#if defined(NLOHMANN_JSON_HEDLEY_PURE) - #undef NLOHMANN_JSON_HEDLEY_PURE +#if defined(JSON_HEDLEY_PURE) + #undef JSON_HEDLEY_PURE #endif #if \ - NLOHMANN_JSON_HEDLEY_HAS_ATTRIBUTE(pure) || \ - NLOHMANN_JSON_HEDLEY_GCC_VERSION_CHECK(2,96,0) || \ - NLOHMANN_JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ - NLOHMANN_JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \ - NLOHMANN_JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ - NLOHMANN_JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \ - NLOHMANN_JSON_HEDLEY_TI_VERSION_CHECK(8,0,0) || \ - (NLOHMANN_JSON_HEDLEY_TI_VERSION_CHECK(7,3,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ - NLOHMANN_JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) - #define NLOHMANN_JSON_HEDLEY_PURE __attribute__((__pure__)) -#elif NLOHMANN_JSON_HEDLEY_TI_VERSION_CHECK(6,0,0) && defined(__cplusplus) - #define NLOHMANN_JSON_HEDLEY_PURE _Pragma("FUNC_IS_PURE;") + JSON_HEDLEY_HAS_ATTRIBUTE(pure) || \ + JSON_HEDLEY_GCC_VERSION_CHECK(2,96,0) || \ + JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ + JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \ + JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ + JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \ + JSON_HEDLEY_TI_VERSION_CHECK(8,0,0) || \ + (JSON_HEDLEY_TI_VERSION_CHECK(7,3,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ + JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) + #define JSON_HEDLEY_PURE __attribute__((__pure__)) +#elif JSON_HEDLEY_TI_VERSION_CHECK(6,0,0) && defined(__cplusplus) + #define JSON_HEDLEY_PURE _Pragma("FUNC_IS_PURE;") #else - #define NLOHMANN_JSON_HEDLEY_PURE + #define JSON_HEDLEY_PURE #endif -#if defined(NLOHMANN_JSON_HEDLEY_CONST) - #undef NLOHMANN_JSON_HEDLEY_CONST +#if defined(JSON_HEDLEY_CONST) + #undef JSON_HEDLEY_CONST #endif #if \ - NLOHMANN_JSON_HEDLEY_HAS_ATTRIBUTE(const) || \ - NLOHMANN_JSON_HEDLEY_GCC_VERSION_CHECK(2,5,0) || \ - NLOHMANN_JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ - NLOHMANN_JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \ - NLOHMANN_JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ - NLOHMANN_JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \ - NLOHMANN_JSON_HEDLEY_TI_VERSION_CHECK(8,0,0) || \ - (NLOHMANN_JSON_HEDLEY_TI_VERSION_CHECK(7,3,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ - NLOHMANN_JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) - #define NLOHMANN_JSON_HEDLEY_CONST __attribute__((__const__)) + JSON_HEDLEY_HAS_ATTRIBUTE(const) || \ + JSON_HEDLEY_GCC_VERSION_CHECK(2,5,0) || \ + JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ + JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \ + JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ + JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \ + JSON_HEDLEY_TI_VERSION_CHECK(8,0,0) || \ + (JSON_HEDLEY_TI_VERSION_CHECK(7,3,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ + JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) + #define JSON_HEDLEY_CONST __attribute__((__const__)) #else - #define NLOHMANN_JSON_HEDLEY_CONST NLOHMANN_JSON_HEDLEY_PURE + #define JSON_HEDLEY_CONST JSON_HEDLEY_PURE #endif -#if defined(NLOHMANN_JSON_HEDLEY_RESTRICT) - #undef NLOHMANN_JSON_HEDLEY_RESTRICT +#if defined(JSON_HEDLEY_RESTRICT) + #undef JSON_HEDLEY_RESTRICT #endif #if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) && !defined(__cplusplus) - #define NLOHMANN_JSON_HEDLEY_RESTRICT restrict + #define JSON_HEDLEY_RESTRICT restrict #elif \ - NLOHMANN_JSON_HEDLEY_GCC_VERSION_CHECK(3,1,0) || \ - NLOHMANN_JSON_HEDLEY_MSVC_VERSION_CHECK(14,0,0) || \ - NLOHMANN_JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ - NLOHMANN_JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ - NLOHMANN_JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \ - NLOHMANN_JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) || \ - NLOHMANN_JSON_HEDLEY_TI_VERSION_CHECK(8,0,0) || \ - (NLOHMANN_JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,14,0) && defined(__cplusplus)) || \ - NLOHMANN_JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0) || \ + JSON_HEDLEY_GCC_VERSION_CHECK(3,1,0) || \ + JSON_HEDLEY_MSVC_VERSION_CHECK(14,0,0) || \ + JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ + JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ + JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \ + JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) || \ + JSON_HEDLEY_TI_VERSION_CHECK(8,0,0) || \ + (JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,14,0) && defined(__cplusplus)) || \ + JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0) || \ defined(__clang__) - #define NLOHMANN_JSON_HEDLEY_RESTRICT __restrict -#elif NLOHMANN_JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,3,0) && !defined(__cplusplus) - #define NLOHMANN_JSON_HEDLEY_RESTRICT _Restrict + #define JSON_HEDLEY_RESTRICT __restrict +#elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,3,0) && !defined(__cplusplus) + #define JSON_HEDLEY_RESTRICT _Restrict #else - #define NLOHMANN_JSON_HEDLEY_RESTRICT + #define JSON_HEDLEY_RESTRICT #endif -#if defined(NLOHMANN_JSON_HEDLEY_INLINE) - #undef NLOHMANN_JSON_HEDLEY_INLINE +#if defined(JSON_HEDLEY_INLINE) + #undef JSON_HEDLEY_INLINE #endif #if \ (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)) || \ (defined(__cplusplus) && (__cplusplus >= 199711L)) - #define NLOHMANN_JSON_HEDLEY_INLINE inline + #define JSON_HEDLEY_INLINE inline #elif \ - defined(NLOHMANN_JSON_HEDLEY_GCC_VERSION) || \ - NLOHMANN_JSON_HEDLEY_ARM_VERSION_CHECK(6,2,0) - #define NLOHMANN_JSON_HEDLEY_INLINE __inline__ + defined(JSON_HEDLEY_GCC_VERSION) || \ + JSON_HEDLEY_ARM_VERSION_CHECK(6,2,0) + #define JSON_HEDLEY_INLINE __inline__ #elif \ - NLOHMANN_JSON_HEDLEY_MSVC_VERSION_CHECK(12,0,0) || \ - NLOHMANN_JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ - NLOHMANN_JSON_HEDLEY_TI_VERSION_CHECK(8,0,0) - #define NLOHMANN_JSON_HEDLEY_INLINE __inline + JSON_HEDLEY_MSVC_VERSION_CHECK(12,0,0) || \ + JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ + JSON_HEDLEY_TI_VERSION_CHECK(8,0,0) + #define JSON_HEDLEY_INLINE __inline #else - #define NLOHMANN_JSON_HEDLEY_INLINE + #define JSON_HEDLEY_INLINE #endif -#if defined(NLOHMANN_JSON_HEDLEY_ALWAYS_INLINE) - #undef NLOHMANN_JSON_HEDLEY_ALWAYS_INLINE +#if defined(JSON_HEDLEY_ALWAYS_INLINE) + #undef JSON_HEDLEY_ALWAYS_INLINE #endif #if \ - NLOHMANN_JSON_HEDLEY_HAS_ATTRIBUTE(always_inline) || \ - NLOHMANN_JSON_HEDLEY_GCC_VERSION_CHECK(4,0,0) || \ - NLOHMANN_JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ - NLOHMANN_JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \ - NLOHMANN_JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ - NLOHMANN_JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \ - NLOHMANN_JSON_HEDLEY_TI_VERSION_CHECK(8,0,0) || \ - (NLOHMANN_JSON_HEDLEY_TI_VERSION_CHECK(7,3,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) - #define NLOHMANN_JSON_HEDLEY_ALWAYS_INLINE __attribute__((__always_inline__)) NLOHMANN_JSON_HEDLEY_INLINE -#elif NLOHMANN_JSON_HEDLEY_MSVC_VERSION_CHECK(12,0,0) - #define NLOHMANN_JSON_HEDLEY_ALWAYS_INLINE __forceinline -#elif NLOHMANN_JSON_HEDLEY_TI_VERSION_CHECK(7,0,0) && defined(__cplusplus) - #define NLOHMANN_JSON_HEDLEY_ALWAYS_INLINE _Pragma("FUNC_ALWAYS_INLINE;") -#elif NLOHMANN_JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0) - #define NLOHMANN_JSON_HEDLEY_ALWAYS_INLINE _Pragma("inline=forced") + JSON_HEDLEY_HAS_ATTRIBUTE(always_inline) || \ + JSON_HEDLEY_GCC_VERSION_CHECK(4,0,0) || \ + JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ + JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \ + JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ + JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \ + JSON_HEDLEY_TI_VERSION_CHECK(8,0,0) || \ + (JSON_HEDLEY_TI_VERSION_CHECK(7,3,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) + #define JSON_HEDLEY_ALWAYS_INLINE __attribute__((__always_inline__)) JSON_HEDLEY_INLINE +#elif JSON_HEDLEY_MSVC_VERSION_CHECK(12,0,0) + #define JSON_HEDLEY_ALWAYS_INLINE __forceinline +#elif JSON_HEDLEY_TI_VERSION_CHECK(7,0,0) && defined(__cplusplus) + #define JSON_HEDLEY_ALWAYS_INLINE _Pragma("FUNC_ALWAYS_INLINE;") +#elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0) + #define JSON_HEDLEY_ALWAYS_INLINE _Pragma("inline=forced") #else - #define NLOHMANN_JSON_HEDLEY_ALWAYS_INLINE NLOHMANN_JSON_HEDLEY_INLINE + #define JSON_HEDLEY_ALWAYS_INLINE JSON_HEDLEY_INLINE #endif -#if defined(NLOHMANN_JSON_HEDLEY_NEVER_INLINE) - #undef NLOHMANN_JSON_HEDLEY_NEVER_INLINE +#if defined(JSON_HEDLEY_NEVER_INLINE) + #undef JSON_HEDLEY_NEVER_INLINE #endif #if \ - NLOHMANN_JSON_HEDLEY_HAS_ATTRIBUTE(noinline) || \ - NLOHMANN_JSON_HEDLEY_GCC_VERSION_CHECK(4,0,0) || \ - NLOHMANN_JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ - NLOHMANN_JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \ - NLOHMANN_JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ - NLOHMANN_JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \ - NLOHMANN_JSON_HEDLEY_TI_VERSION_CHECK(8,0,0) || \ - (NLOHMANN_JSON_HEDLEY_TI_VERSION_CHECK(7,3,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) - #define NLOHMANN_JSON_HEDLEY_NEVER_INLINE __attribute__((__noinline__)) -#elif NLOHMANN_JSON_HEDLEY_MSVC_VERSION_CHECK(13,10,0) - #define NLOHMANN_JSON_HEDLEY_NEVER_INLINE __declspec(noinline) -#elif NLOHMANN_JSON_HEDLEY_PGI_VERSION_CHECK(10,2,0) - #define NLOHMANN_JSON_HEDLEY_NEVER_INLINE _Pragma("noinline") -#elif NLOHMANN_JSON_HEDLEY_TI_VERSION_CHECK(6,0,0) && defined(__cplusplus) - #define NLOHMANN_JSON_HEDLEY_NEVER_INLINE _Pragma("FUNC_CANNOT_INLINE;") -#elif NLOHMANN_JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0) - #define NLOHMANN_JSON_HEDLEY_NEVER_INLINE _Pragma("inline=never") -#elif NLOHMANN_JSON_HEDLEY_COMPCERT_VERSION_CHECK(3,2,0) - #define NLOHMANN_JSON_HEDLEY_NEVER_INLINE __attribute((noinline)) -#elif NLOHMANN_JSON_HEDLEY_PELLES_VERSION_CHECK(9,0,0) - #define NLOHMANN_JSON_HEDLEY_NEVER_INLINE __declspec(noinline) + JSON_HEDLEY_HAS_ATTRIBUTE(noinline) || \ + JSON_HEDLEY_GCC_VERSION_CHECK(4,0,0) || \ + JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ + JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \ + JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ + JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \ + JSON_HEDLEY_TI_VERSION_CHECK(8,0,0) || \ + (JSON_HEDLEY_TI_VERSION_CHECK(7,3,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) + #define JSON_HEDLEY_NEVER_INLINE __attribute__((__noinline__)) +#elif JSON_HEDLEY_MSVC_VERSION_CHECK(13,10,0) + #define JSON_HEDLEY_NEVER_INLINE __declspec(noinline) +#elif JSON_HEDLEY_PGI_VERSION_CHECK(10,2,0) + #define JSON_HEDLEY_NEVER_INLINE _Pragma("noinline") +#elif JSON_HEDLEY_TI_VERSION_CHECK(6,0,0) && defined(__cplusplus) + #define JSON_HEDLEY_NEVER_INLINE _Pragma("FUNC_CANNOT_INLINE;") +#elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0) + #define JSON_HEDLEY_NEVER_INLINE _Pragma("inline=never") +#elif JSON_HEDLEY_COMPCERT_VERSION_CHECK(3,2,0) + #define JSON_HEDLEY_NEVER_INLINE __attribute((noinline)) +#elif JSON_HEDLEY_PELLES_VERSION_CHECK(9,0,0) + #define JSON_HEDLEY_NEVER_INLINE __declspec(noinline) #else - #define NLOHMANN_JSON_HEDLEY_NEVER_INLINE + #define JSON_HEDLEY_NEVER_INLINE #endif -#if defined(NLOHMANN_JSON_HEDLEY_PRIVATE) - #undef NLOHMANN_JSON_HEDLEY_PRIVATE +#if defined(JSON_HEDLEY_PRIVATE) + #undef JSON_HEDLEY_PRIVATE #endif -#if defined(NLOHMANN_JSON_HEDLEY_PUBLIC) - #undef NLOHMANN_JSON_HEDLEY_PUBLIC +#if defined(JSON_HEDLEY_PUBLIC) + #undef JSON_HEDLEY_PUBLIC #endif -#if defined(NLOHMANN_JSON_HEDLEY_IMPORT) - #undef NLOHMANN_JSON_HEDLEY_IMPORT +#if defined(JSON_HEDLEY_IMPORT) + #undef JSON_HEDLEY_IMPORT #endif #if defined(_WIN32) || defined(__CYGWIN__) - #define NLOHMANN_JSON_HEDLEY_PRIVATE - #define NLOHMANN_JSON_HEDLEY_PUBLIC __declspec(dllexport) - #define NLOHMANN_JSON_HEDLEY_IMPORT __declspec(dllimport) + #define JSON_HEDLEY_PRIVATE + #define JSON_HEDLEY_PUBLIC __declspec(dllexport) + #define JSON_HEDLEY_IMPORT __declspec(dllimport) #else #if \ - NLOHMANN_JSON_HEDLEY_HAS_ATTRIBUTE(visibility) || \ - NLOHMANN_JSON_HEDLEY_GCC_VERSION_CHECK(3,3,0) || \ - NLOHMANN_JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \ - NLOHMANN_JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ - NLOHMANN_JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ - NLOHMANN_JSON_HEDLEY_IBM_VERSION_CHECK(13,1,0) || \ - NLOHMANN_JSON_HEDLEY_TI_VERSION_CHECK(8,0,0) || \ - (NLOHMANN_JSON_HEDLEY_TI_VERSION_CHECK(7,3,0) && defined(__TI_EABI__) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) - #define NLOHMANN_JSON_HEDLEY_PRIVATE __attribute__((__visibility__("hidden"))) - #define NLOHMANN_JSON_HEDLEY_PUBLIC __attribute__((__visibility__("default"))) + JSON_HEDLEY_HAS_ATTRIBUTE(visibility) || \ + JSON_HEDLEY_GCC_VERSION_CHECK(3,3,0) || \ + JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \ + JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ + JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ + JSON_HEDLEY_IBM_VERSION_CHECK(13,1,0) || \ + JSON_HEDLEY_TI_VERSION_CHECK(8,0,0) || \ + (JSON_HEDLEY_TI_VERSION_CHECK(7,3,0) && defined(__TI_EABI__) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) + #define JSON_HEDLEY_PRIVATE __attribute__((__visibility__("hidden"))) + #define JSON_HEDLEY_PUBLIC __attribute__((__visibility__("default"))) #else - #define NLOHMANN_JSON_HEDLEY_PRIVATE - #define NLOHMANN_JSON_HEDLEY_PUBLIC + #define JSON_HEDLEY_PRIVATE + #define JSON_HEDLEY_PUBLIC #endif - #define NLOHMANN_JSON_HEDLEY_IMPORT extern + #define JSON_HEDLEY_IMPORT extern #endif -#if defined(NLOHMANN_JSON_HEDLEY_NO_THROW) - #undef NLOHMANN_JSON_HEDLEY_NO_THROW +#if defined(JSON_HEDLEY_NO_THROW) + #undef JSON_HEDLEY_NO_THROW #endif #if \ - NLOHMANN_JSON_HEDLEY_HAS_ATTRIBUTE(nothrow) || \ - NLOHMANN_JSON_HEDLEY_GCC_VERSION_CHECK(3,3,0) || \ - NLOHMANN_JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) - #define NLOHMANN_JSON_HEDLEY_NO_THROW __attribute__((__nothrow__)) + JSON_HEDLEY_HAS_ATTRIBUTE(nothrow) || \ + JSON_HEDLEY_GCC_VERSION_CHECK(3,3,0) || \ + JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) + #define JSON_HEDLEY_NO_THROW __attribute__((__nothrow__)) #elif \ - NLOHMANN_JSON_HEDLEY_MSVC_VERSION_CHECK(13,1,0) || \ - NLOHMANN_JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) - #define NLOHMANN_JSON_HEDLEY_NO_THROW __declspec(nothrow) + JSON_HEDLEY_MSVC_VERSION_CHECK(13,1,0) || \ + JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) + #define JSON_HEDLEY_NO_THROW __declspec(nothrow) #else - #define NLOHMANN_JSON_HEDLEY_NO_THROW + #define JSON_HEDLEY_NO_THROW #endif -#if defined(NLOHMANN_JSON_HEDLEY_FALL_THROUGH) - #undef NLOHMANN_JSON_HEDLEY_FALL_THROUGH +#if defined(JSON_HEDLEY_FALL_THROUGH) + #undef JSON_HEDLEY_FALL_THROUGH #endif #if \ defined(__cplusplus) && \ - (!defined(NLOHMANN_JSON_HEDLEY_SUNPRO_VERSION) || NLOHMANN_JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,15,0)) && \ - !defined(NLOHMANN_JSON_HEDLEY_PGI_VERSION) + (!defined(JSON_HEDLEY_SUNPRO_VERSION) || JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,15,0)) && \ + !defined(JSON_HEDLEY_PGI_VERSION) #if \ (__cplusplus >= 201703L) || \ - ((__cplusplus >= 201103L) && NLOHMANN_JSON_HEDLEY_HAS_CPP_ATTRIBUTE(fallthrough)) - #define NLOHMANN_JSON_HEDLEY_FALL_THROUGH [[fallthrough]] - #elif (__cplusplus >= 201103L) && NLOHMANN_JSON_HEDLEY_HAS_CPP_ATTRIBUTE(clang::fallthrough) - #define NLOHMANN_JSON_HEDLEY_FALL_THROUGH [[clang::fallthrough]] - #elif (__cplusplus >= 201103L) && NLOHMANN_JSON_HEDLEY_GCC_VERSION_CHECK(7,0,0) - #define NLOHMANN_JSON_HEDLEY_FALL_THROUGH [[gnu::fallthrough]] + ((__cplusplus >= 201103L) && JSON_HEDLEY_HAS_CPP_ATTRIBUTE(fallthrough)) + #define JSON_HEDLEY_FALL_THROUGH [[fallthrough]] + #elif (__cplusplus >= 201103L) && JSON_HEDLEY_HAS_CPP_ATTRIBUTE(clang::fallthrough) + #define JSON_HEDLEY_FALL_THROUGH [[clang::fallthrough]] + #elif (__cplusplus >= 201103L) && JSON_HEDLEY_GCC_VERSION_CHECK(7,0,0) + #define JSON_HEDLEY_FALL_THROUGH [[gnu::fallthrough]] #endif #endif -#if !defined(NLOHMANN_JSON_HEDLEY_FALL_THROUGH) - #if NLOHMANN_JSON_HEDLEY_GNUC_HAS_ATTRIBUTE(fallthrough,7,0,0) && !defined(NLOHMANN_JSON_HEDLEY_PGI_VERSION) - #define NLOHMANN_JSON_HEDLEY_FALL_THROUGH __attribute__((__fallthrough__)) +#if !defined(JSON_HEDLEY_FALL_THROUGH) + #if JSON_HEDLEY_GNUC_HAS_ATTRIBUTE(fallthrough,7,0,0) && !defined(JSON_HEDLEY_PGI_VERSION) + #define JSON_HEDLEY_FALL_THROUGH __attribute__((__fallthrough__)) #elif defined(__fallthrough) /* SAL */ - #define NLOHMANN_JSON_HEDLEY_FALL_THROUGH __fallthrough + #define JSON_HEDLEY_FALL_THROUGH __fallthrough #else - #define NLOHMANN_JSON_HEDLEY_FALL_THROUGH + #define JSON_HEDLEY_FALL_THROUGH #endif #endif -#if defined(NLOHMANN_JSON_HEDLEY_RETURNS_NON_NULL) - #undef NLOHMANN_JSON_HEDLEY_RETURNS_NON_NULL +#if defined(JSON_HEDLEY_RETURNS_NON_NULL) + #undef JSON_HEDLEY_RETURNS_NON_NULL #endif #if \ - NLOHMANN_JSON_HEDLEY_HAS_ATTRIBUTE(returns_nonnull) || \ - NLOHMANN_JSON_HEDLEY_GCC_VERSION_CHECK(4,9,0) - #define NLOHMANN_JSON_HEDLEY_RETURNS_NON_NULL __attribute__((__returns_nonnull__)) + JSON_HEDLEY_HAS_ATTRIBUTE(returns_nonnull) || \ + JSON_HEDLEY_GCC_VERSION_CHECK(4,9,0) + #define JSON_HEDLEY_RETURNS_NON_NULL __attribute__((__returns_nonnull__)) #elif defined(_Ret_notnull_) /* SAL */ - #define NLOHMANN_JSON_HEDLEY_RETURNS_NON_NULL _Ret_notnull_ + #define JSON_HEDLEY_RETURNS_NON_NULL _Ret_notnull_ #else - #define NLOHMANN_JSON_HEDLEY_RETURNS_NON_NULL + #define JSON_HEDLEY_RETURNS_NON_NULL #endif -#if defined(NLOHMANN_JSON_HEDLEY_ARRAY_PARAM) - #undef NLOHMANN_JSON_HEDLEY_ARRAY_PARAM +#if defined(JSON_HEDLEY_ARRAY_PARAM) + #undef JSON_HEDLEY_ARRAY_PARAM #endif #if \ defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) && \ !defined(__STDC_NO_VLA__) && \ !defined(__cplusplus) && \ - !defined(NLOHMANN_JSON_HEDLEY_PGI_VERSION) && \ - !defined(NLOHMANN_JSON_HEDLEY_TINYC_VERSION) - #define NLOHMANN_JSON_HEDLEY_ARRAY_PARAM(name) (name) + !defined(JSON_HEDLEY_PGI_VERSION) && \ + !defined(JSON_HEDLEY_TINYC_VERSION) + #define JSON_HEDLEY_ARRAY_PARAM(name) (name) #else - #define NLOHMANN_JSON_HEDLEY_ARRAY_PARAM(name) + #define JSON_HEDLEY_ARRAY_PARAM(name) #endif -#if defined(NLOHMANN_JSON_HEDLEY_IS_CONSTANT) - #undef NLOHMANN_JSON_HEDLEY_IS_CONSTANT +#if defined(JSON_HEDLEY_IS_CONSTANT) + #undef JSON_HEDLEY_IS_CONSTANT #endif -#if defined(NLOHMANN_JSON_HEDLEY_REQUIRE_CONSTEXPR) - #undef NLOHMANN_JSON_HEDLEY_REQUIRE_CONSTEXPR +#if defined(JSON_HEDLEY_REQUIRE_CONSTEXPR) + #undef JSON_HEDLEY_REQUIRE_CONSTEXPR #endif /* Note the double-underscore. For internal use only; no API * guarantees! */ -#if defined(NLOHMANN_JSON_HEDLEY__IS_CONSTEXPR) - #undef NLOHMANN_JSON_HEDLEY__IS_CONSTEXPR +#if defined(JSON_HEDLEY__IS_CONSTEXPR) + #undef JSON_HEDLEY__IS_CONSTEXPR #endif #if \ - NLOHMANN_JSON_HEDLEY_HAS_BUILTIN(__builtin_constant_p) || \ - NLOHMANN_JSON_HEDLEY_GCC_VERSION_CHECK(3,4,0) || \ - NLOHMANN_JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ - NLOHMANN_JSON_HEDLEY_TINYC_VERSION_CHECK(0,9,19) || \ - NLOHMANN_JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ - NLOHMANN_JSON_HEDLEY_IBM_VERSION_CHECK(13,1,0) || \ - NLOHMANN_JSON_HEDLEY_TI_VERSION_CHECK(6,1,0) || \ - NLOHMANN_JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,10,0) || \ - NLOHMANN_JSON_HEDLEY_CRAY_VERSION_CHECK(8,1,0) - #define NLOHMANN_JSON_HEDLEY_IS_CONSTANT(expr) __builtin_constant_p(expr) + JSON_HEDLEY_HAS_BUILTIN(__builtin_constant_p) || \ + JSON_HEDLEY_GCC_VERSION_CHECK(3,4,0) || \ + JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ + JSON_HEDLEY_TINYC_VERSION_CHECK(0,9,19) || \ + JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ + JSON_HEDLEY_IBM_VERSION_CHECK(13,1,0) || \ + JSON_HEDLEY_TI_VERSION_CHECK(6,1,0) || \ + JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,10,0) || \ + JSON_HEDLEY_CRAY_VERSION_CHECK(8,1,0) + #define JSON_HEDLEY_IS_CONSTANT(expr) __builtin_constant_p(expr) #endif #if !defined(__cplusplus) # if \ - NLOHMANN_JSON_HEDLEY_HAS_BUILTIN(__builtin_types_compatible_p) || \ - NLOHMANN_JSON_HEDLEY_GCC_VERSION_CHECK(3,4,0) || \ - NLOHMANN_JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ - NLOHMANN_JSON_HEDLEY_IBM_VERSION_CHECK(13,1,0) || \ - NLOHMANN_JSON_HEDLEY_CRAY_VERSION_CHECK(8,1,0) || \ - NLOHMANN_JSON_HEDLEY_ARM_VERSION_CHECK(5,4,0) || \ - NLOHMANN_JSON_HEDLEY_TINYC_VERSION_CHECK(0,9,24) + JSON_HEDLEY_HAS_BUILTIN(__builtin_types_compatible_p) || \ + JSON_HEDLEY_GCC_VERSION_CHECK(3,4,0) || \ + JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ + JSON_HEDLEY_IBM_VERSION_CHECK(13,1,0) || \ + JSON_HEDLEY_CRAY_VERSION_CHECK(8,1,0) || \ + JSON_HEDLEY_ARM_VERSION_CHECK(5,4,0) || \ + JSON_HEDLEY_TINYC_VERSION_CHECK(0,9,24) #if defined(__INTPTR_TYPE__) - #define NLOHMANN_JSON_HEDLEY__IS_CONSTEXPR(expr) __builtin_types_compatible_p(__typeof__((1 ? (void*) ((__INTPTR_TYPE__) ((expr) * 0)) : (int*) 0)), int*) + #define JSON_HEDLEY__IS_CONSTEXPR(expr) __builtin_types_compatible_p(__typeof__((1 ? (void*) ((__INTPTR_TYPE__) ((expr) * 0)) : (int*) 0)), int*) #else #include - #define NLOHMANN_JSON_HEDLEY__IS_CONSTEXPR(expr) __builtin_types_compatible_p(__typeof__((1 ? (void*) ((intptr_t) ((expr) * 0)) : (int*) 0)), int*) + #define JSON_HEDLEY__IS_CONSTEXPR(expr) __builtin_types_compatible_p(__typeof__((1 ? (void*) ((intptr_t) ((expr) * 0)) : (int*) 0)), int*) #endif # elif \ - (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 201112L) && !defined(NLOHMANN_JSON_HEDLEY_SUNPRO_VERSION) && !defined(NLOHMANN_JSON_HEDLEY_PGI_VERSION)) || \ - NLOHMANN_JSON_HEDLEY_HAS_EXTENSION(c_generic_selections) || \ - NLOHMANN_JSON_HEDLEY_GCC_VERSION_CHECK(4,9,0) || \ - NLOHMANN_JSON_HEDLEY_INTEL_VERSION_CHECK(17,0,0) || \ - NLOHMANN_JSON_HEDLEY_IBM_VERSION_CHECK(12,1,0) || \ - NLOHMANN_JSON_HEDLEY_ARM_VERSION_CHECK(5,3,0) + (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 201112L) && !defined(JSON_HEDLEY_SUNPRO_VERSION) && !defined(JSON_HEDLEY_PGI_VERSION)) || \ + JSON_HEDLEY_HAS_EXTENSION(c_generic_selections) || \ + JSON_HEDLEY_GCC_VERSION_CHECK(4,9,0) || \ + JSON_HEDLEY_INTEL_VERSION_CHECK(17,0,0) || \ + JSON_HEDLEY_IBM_VERSION_CHECK(12,1,0) || \ + JSON_HEDLEY_ARM_VERSION_CHECK(5,3,0) #if defined(__INTPTR_TYPE__) - #define NLOHMANN_JSON_HEDLEY__IS_CONSTEXPR(expr) _Generic((1 ? (void*) ((__INTPTR_TYPE__) ((expr) * 0)) : (int*) 0), int*: 1, void*: 0) + #define JSON_HEDLEY__IS_CONSTEXPR(expr) _Generic((1 ? (void*) ((__INTPTR_TYPE__) ((expr) * 0)) : (int*) 0), int*: 1, void*: 0) #else #include - #define NLOHMANN_JSON_HEDLEY__IS_CONSTEXPR(expr) _Generic((1 ? (void*) ((intptr_t) * 0) : (int*) 0), int*: 1, void*: 0) + #define JSON_HEDLEY__IS_CONSTEXPR(expr) _Generic((1 ? (void*) ((intptr_t) * 0) : (int*) 0), int*: 1, void*: 0) #endif # elif \ - defined(NLOHMANN_JSON_HEDLEY_GCC_VERSION) || \ - defined(NLOHMANN_JSON_HEDLEY_INTEL_VERSION) || \ - defined(NLOHMANN_JSON_HEDLEY_TINYC_VERSION) || \ - defined(NLOHMANN_JSON_HEDLEY_TI_VERSION) || \ + defined(JSON_HEDLEY_GCC_VERSION) || \ + defined(JSON_HEDLEY_INTEL_VERSION) || \ + defined(JSON_HEDLEY_TINYC_VERSION) || \ + defined(JSON_HEDLEY_TI_VERSION) || \ defined(__clang__) -# define NLOHMANN_JSON_HEDLEY__IS_CONSTEXPR(expr) ( \ +# define JSON_HEDLEY__IS_CONSTEXPR(expr) ( \ sizeof(void) != \ sizeof(*( \ 1 ? \ @@ -1380,241 +1380,241 @@ NLOHMANN_JSON_HEDLEY_DIAGNOSTIC_POP ((struct { char v[sizeof(void) * 2]; } *) 1) \ ) \ ) \ - ) + ) # endif #endif -#if defined(NLOHMANN_JSON_HEDLEY__IS_CONSTEXPR) - #if !defined(NLOHMANN_JSON_HEDLEY_IS_CONSTANT) - #define NLOHMANN_JSON_HEDLEY_IS_CONSTANT(expr) NLOHMANN_JSON_HEDLEY__IS_CONSTEXPR(expr) +#if defined(JSON_HEDLEY__IS_CONSTEXPR) + #if !defined(JSON_HEDLEY_IS_CONSTANT) + #define JSON_HEDLEY_IS_CONSTANT(expr) JSON_HEDLEY__IS_CONSTEXPR(expr) #endif - #define NLOHMANN_JSON_HEDLEY_REQUIRE_CONSTEXPR(expr) (NLOHMANN_JSON_HEDLEY__IS_CONSTEXPR(expr) ? (expr) : (-1)) + #define JSON_HEDLEY_REQUIRE_CONSTEXPR(expr) (JSON_HEDLEY__IS_CONSTEXPR(expr) ? (expr) : (-1)) #else - #if !defined(NLOHMANN_JSON_HEDLEY_IS_CONSTANT) - #define NLOHMANN_JSON_HEDLEY_IS_CONSTANT(expr) (0) + #if !defined(JSON_HEDLEY_IS_CONSTANT) + #define JSON_HEDLEY_IS_CONSTANT(expr) (0) #endif - #define NLOHMANN_JSON_HEDLEY_REQUIRE_CONSTEXPR(expr) (expr) + #define JSON_HEDLEY_REQUIRE_CONSTEXPR(expr) (expr) #endif -#if defined(NLOHMANN_JSON_HEDLEY_BEGIN_C_DECLS) - #undef NLOHMANN_JSON_HEDLEY_BEGIN_C_DECLS +#if defined(JSON_HEDLEY_BEGIN_C_DECLS) + #undef JSON_HEDLEY_BEGIN_C_DECLS #endif -#if defined(NLOHMANN_JSON_HEDLEY_END_C_DECLS) - #undef NLOHMANN_JSON_HEDLEY_END_C_DECLS +#if defined(JSON_HEDLEY_END_C_DECLS) + #undef JSON_HEDLEY_END_C_DECLS #endif -#if defined(NLOHMANN_JSON_HEDLEY_C_DECL) - #undef NLOHMANN_JSON_HEDLEY_C_DECL +#if defined(JSON_HEDLEY_C_DECL) + #undef JSON_HEDLEY_C_DECL #endif #if defined(__cplusplus) - #define NLOHMANN_JSON_HEDLEY_BEGIN_C_DECLS extern "C" { - #define NLOHMANN_JSON_HEDLEY_END_C_DECLS } - #define NLOHMANN_JSON_HEDLEY_C_DECL extern "C" + #define JSON_HEDLEY_BEGIN_C_DECLS extern "C" { + #define JSON_HEDLEY_END_C_DECLS } + #define JSON_HEDLEY_C_DECL extern "C" #else - #define NLOHMANN_JSON_HEDLEY_BEGIN_C_DECLS - #define NLOHMANN_JSON_HEDLEY_END_C_DECLS - #define NLOHMANN_JSON_HEDLEY_C_DECL + #define JSON_HEDLEY_BEGIN_C_DECLS + #define JSON_HEDLEY_END_C_DECLS + #define JSON_HEDLEY_C_DECL #endif -#if defined(NLOHMANN_JSON_HEDLEY_STATIC_ASSERT) - #undef NLOHMANN_JSON_HEDLEY_STATIC_ASSERT +#if defined(JSON_HEDLEY_STATIC_ASSERT) + #undef JSON_HEDLEY_STATIC_ASSERT #endif #if \ !defined(__cplusplus) && ( \ (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 201112L)) || \ - NLOHMANN_JSON_HEDLEY_HAS_FEATURE(c_static_assert) || \ - NLOHMANN_JSON_HEDLEY_GCC_VERSION_CHECK(6,0,0) || \ - NLOHMANN_JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ + JSON_HEDLEY_HAS_FEATURE(c_static_assert) || \ + JSON_HEDLEY_GCC_VERSION_CHECK(6,0,0) || \ + JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ defined(_Static_assert) \ ) -# define NLOHMANN_JSON_HEDLEY_STATIC_ASSERT(expr, message) _Static_assert(expr, message) +# define JSON_HEDLEY_STATIC_ASSERT(expr, message) _Static_assert(expr, message) #elif \ (defined(__cplusplus) && (__cplusplus >= 201703L)) || \ - NLOHMANN_JSON_HEDLEY_MSVC_VERSION_CHECK(16,0,0) || \ - (defined(__cplusplus) && NLOHMANN_JSON_HEDLEY_TI_VERSION_CHECK(8,3,0)) -# define NLOHMANN_JSON_HEDLEY_STATIC_ASSERT(expr, message) static_assert(expr, message) + JSON_HEDLEY_MSVC_VERSION_CHECK(16,0,0) || \ + (defined(__cplusplus) && JSON_HEDLEY_TI_VERSION_CHECK(8,3,0)) +# define JSON_HEDLEY_STATIC_ASSERT(expr, message) static_assert(expr, message) #elif defined(__cplusplus) && (__cplusplus >= 201103L) -# define NLOHMANN_JSON_HEDLEY_STATIC_ASSERT(expr, message) static_assert(expr) +# define JSON_HEDLEY_STATIC_ASSERT(expr, message) static_assert(expr) #else -# define NLOHMANN_JSON_HEDLEY_STATIC_ASSERT(expr, message) +# define JSON_HEDLEY_STATIC_ASSERT(expr, message) #endif -#if defined(NLOHMANN_JSON_HEDLEY_CONST_CAST) - #undef NLOHMANN_JSON_HEDLEY_CONST_CAST +#if defined(JSON_HEDLEY_CONST_CAST) + #undef JSON_HEDLEY_CONST_CAST #endif #if defined(__cplusplus) -# define NLOHMANN_JSON_HEDLEY_CONST_CAST(T, expr) (const_cast(expr)) +# define JSON_HEDLEY_CONST_CAST(T, expr) (const_cast(expr)) #elif \ - NLOHMANN_JSON_HEDLEY_HAS_WARNING("-Wcast-qual") || \ - NLOHMANN_JSON_HEDLEY_GCC_VERSION_CHECK(4,6,0) || \ - NLOHMANN_JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) -# define NLOHMANN_JSON_HEDLEY_CONST_CAST(T, expr) (__extension__ ({ \ - NLOHMANN_JSON_HEDLEY_DIAGNOSTIC_PUSH \ - NLOHMANN_JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL \ + JSON_HEDLEY_HAS_WARNING("-Wcast-qual") || \ + JSON_HEDLEY_GCC_VERSION_CHECK(4,6,0) || \ + JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) +# define JSON_HEDLEY_CONST_CAST(T, expr) (__extension__ ({ \ + JSON_HEDLEY_DIAGNOSTIC_PUSH \ + JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL \ ((T) (expr)); \ - NLOHMANN_JSON_HEDLEY_DIAGNOSTIC_POP \ + JSON_HEDLEY_DIAGNOSTIC_POP \ })) #else -# define NLOHMANN_JSON_HEDLEY_CONST_CAST(T, expr) ((T) (expr)) +# define JSON_HEDLEY_CONST_CAST(T, expr) ((T) (expr)) #endif -#if defined(NLOHMANN_JSON_HEDLEY_REINTERPRET_CAST) - #undef NLOHMANN_JSON_HEDLEY_REINTERPRET_CAST +#if defined(JSON_HEDLEY_REINTERPRET_CAST) + #undef JSON_HEDLEY_REINTERPRET_CAST #endif #if defined(__cplusplus) - #define NLOHMANN_JSON_HEDLEY_REINTERPRET_CAST(T, expr) (reinterpret_cast(expr)) + #define JSON_HEDLEY_REINTERPRET_CAST(T, expr) (reinterpret_cast(expr)) #else - #define NLOHMANN_JSON_HEDLEY_REINTERPRET_CAST(T, expr) (*((T*) &(expr))) + #define JSON_HEDLEY_REINTERPRET_CAST(T, expr) (*((T*) &(expr))) #endif -#if defined(NLOHMANN_JSON_HEDLEY_STATIC_CAST) - #undef NLOHMANN_JSON_HEDLEY_STATIC_CAST +#if defined(JSON_HEDLEY_STATIC_CAST) + #undef JSON_HEDLEY_STATIC_CAST #endif #if defined(__cplusplus) - #define NLOHMANN_JSON_HEDLEY_STATIC_CAST(T, expr) (static_cast(expr)) + #define JSON_HEDLEY_STATIC_CAST(T, expr) (static_cast(expr)) #else - #define NLOHMANN_JSON_HEDLEY_STATIC_CAST(T, expr) ((T) (expr)) + #define JSON_HEDLEY_STATIC_CAST(T, expr) ((T) (expr)) #endif -#if defined(NLOHMANN_JSON_HEDLEY_CPP_CAST) - #undef NLOHMANN_JSON_HEDLEY_CPP_CAST +#if defined(JSON_HEDLEY_CPP_CAST) + #undef JSON_HEDLEY_CPP_CAST #endif #if defined(__cplusplus) - #define NLOHMANN_JSON_HEDLEY_CPP_CAST(T, expr) static_cast(expr) + #define JSON_HEDLEY_CPP_CAST(T, expr) static_cast(expr) #else - #define NLOHMANN_JSON_HEDLEY_CPP_CAST(T, expr) (expr) + #define JSON_HEDLEY_CPP_CAST(T, expr) (expr) #endif -#if defined(NLOHMANN_JSON_HEDLEY_MESSAGE) - #undef NLOHMANN_JSON_HEDLEY_MESSAGE +#if defined(JSON_HEDLEY_MESSAGE) + #undef JSON_HEDLEY_MESSAGE #endif -#if NLOHMANN_JSON_HEDLEY_HAS_WARNING("-Wunknown-pragmas") -# define NLOHMANN_JSON_HEDLEY_MESSAGE(msg) \ - NLOHMANN_JSON_HEDLEY_DIAGNOSTIC_PUSH \ - NLOHMANN_JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS \ - NLOHMANN_JSON_HEDLEY_PRAGMA(message msg) \ - NLOHMANN_JSON_HEDLEY_DIAGNOSTIC_POP +#if JSON_HEDLEY_HAS_WARNING("-Wunknown-pragmas") +# define JSON_HEDLEY_MESSAGE(msg) \ + JSON_HEDLEY_DIAGNOSTIC_PUSH \ + JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS \ + JSON_HEDLEY_PRAGMA(message msg) \ + JSON_HEDLEY_DIAGNOSTIC_POP #elif \ - NLOHMANN_JSON_HEDLEY_GCC_VERSION_CHECK(4,4,0) || \ - NLOHMANN_JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) -# define NLOHMANN_JSON_HEDLEY_MESSAGE(msg) NLOHMANN_JSON_HEDLEY_PRAGMA(message msg) -#elif NLOHMANN_JSON_HEDLEY_CRAY_VERSION_CHECK(5,0,0) -# define NLOHMANN_JSON_HEDLEY_MESSAGE(msg) NLOHMANN_JSON_HEDLEY_PRAGMA(_CRI message msg) -#elif NLOHMANN_JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0) -# define NLOHMANN_JSON_HEDLEY_MESSAGE(msg) NLOHMANN_JSON_HEDLEY_PRAGMA(message(msg)) -#elif NLOHMANN_JSON_HEDLEY_PELLES_VERSION_CHECK(2,0,0) -# define NLOHMANN_JSON_HEDLEY_MESSAGE(msg) NLOHMANN_JSON_HEDLEY_PRAGMA(message(msg)) + JSON_HEDLEY_GCC_VERSION_CHECK(4,4,0) || \ + JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) +# define JSON_HEDLEY_MESSAGE(msg) JSON_HEDLEY_PRAGMA(message msg) +#elif JSON_HEDLEY_CRAY_VERSION_CHECK(5,0,0) +# define JSON_HEDLEY_MESSAGE(msg) JSON_HEDLEY_PRAGMA(_CRI message msg) +#elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0) +# define JSON_HEDLEY_MESSAGE(msg) JSON_HEDLEY_PRAGMA(message(msg)) +#elif JSON_HEDLEY_PELLES_VERSION_CHECK(2,0,0) +# define JSON_HEDLEY_MESSAGE(msg) JSON_HEDLEY_PRAGMA(message(msg)) #else -# define NLOHMANN_JSON_HEDLEY_MESSAGE(msg) +# define JSON_HEDLEY_MESSAGE(msg) #endif -#if defined(NLOHMANN_JSON_HEDLEY_WARNING) - #undef NLOHMANN_JSON_HEDLEY_WARNING +#if defined(JSON_HEDLEY_WARNING) + #undef JSON_HEDLEY_WARNING #endif -#if NLOHMANN_JSON_HEDLEY_HAS_WARNING("-Wunknown-pragmas") -# define NLOHMANN_JSON_HEDLEY_WARNING(msg) \ - NLOHMANN_JSON_HEDLEY_DIAGNOSTIC_PUSH \ - NLOHMANN_JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS \ - NLOHMANN_JSON_HEDLEY_PRAGMA(clang warning msg) \ - NLOHMANN_JSON_HEDLEY_DIAGNOSTIC_POP +#if JSON_HEDLEY_HAS_WARNING("-Wunknown-pragmas") +# define JSON_HEDLEY_WARNING(msg) \ + JSON_HEDLEY_DIAGNOSTIC_PUSH \ + JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS \ + JSON_HEDLEY_PRAGMA(clang warning msg) \ + JSON_HEDLEY_DIAGNOSTIC_POP #elif \ - NLOHMANN_JSON_HEDLEY_GCC_VERSION_CHECK(4,8,0) || \ - NLOHMANN_JSON_HEDLEY_PGI_VERSION_CHECK(18,4,0) -# define NLOHMANN_JSON_HEDLEY_WARNING(msg) NLOHMANN_JSON_HEDLEY_PRAGMA(GCC warning msg) -#elif NLOHMANN_JSON_HEDLEY_MSVC_VERSION_CHECK(15,0,0) -# define NLOHMANN_JSON_HEDLEY_WARNING(msg) NLOHMANN_JSON_HEDLEY_PRAGMA(message(msg)) + JSON_HEDLEY_GCC_VERSION_CHECK(4,8,0) || \ + JSON_HEDLEY_PGI_VERSION_CHECK(18,4,0) +# define JSON_HEDLEY_WARNING(msg) JSON_HEDLEY_PRAGMA(GCC warning msg) +#elif JSON_HEDLEY_MSVC_VERSION_CHECK(15,0,0) +# define JSON_HEDLEY_WARNING(msg) JSON_HEDLEY_PRAGMA(message(msg)) #else -# define NLOHMANN_JSON_HEDLEY_WARNING(msg) NLOHMANN_JSON_HEDLEY_MESSAGE(msg) +# define JSON_HEDLEY_WARNING(msg) JSON_HEDLEY_MESSAGE(msg) #endif -#if defined(NLOHMANN_JSON_HEDLEY_REQUIRE_MSG) - #undef NLOHMANN_JSON_HEDLEY_REQUIRE_MSG +#if defined(JSON_HEDLEY_REQUIRE_MSG) + #undef JSON_HEDLEY_REQUIRE_MSG #endif -#if NLOHMANN_JSON_HEDLEY_HAS_ATTRIBUTE(diagnose_if) -# if NLOHMANN_JSON_HEDLEY_HAS_WARNING("-Wgcc-compat") -# define NLOHMANN_JSON_HEDLEY_REQUIRE_MSG(expr, msg) \ - NLOHMANN_JSON_HEDLEY_DIAGNOSTIC_PUSH \ +#if JSON_HEDLEY_HAS_ATTRIBUTE(diagnose_if) +# if JSON_HEDLEY_HAS_WARNING("-Wgcc-compat") +# define JSON_HEDLEY_REQUIRE_MSG(expr, msg) \ + JSON_HEDLEY_DIAGNOSTIC_PUSH \ _Pragma("clang diagnostic ignored \"-Wgcc-compat\"") \ __attribute__((__diagnose_if__(!(expr), msg, "error"))) \ - NLOHMANN_JSON_HEDLEY_DIAGNOSTIC_POP + JSON_HEDLEY_DIAGNOSTIC_POP # else -# define NLOHMANN_JSON_HEDLEY_REQUIRE_MSG(expr, msg) __attribute__((__diagnose_if__(!(expr), msg, "error"))) +# define JSON_HEDLEY_REQUIRE_MSG(expr, msg) __attribute__((__diagnose_if__(!(expr), msg, "error"))) # endif #else -# define NLOHMANN_JSON_HEDLEY_REQUIRE_MSG(expr, msg) +# define JSON_HEDLEY_REQUIRE_MSG(expr, msg) #endif -#if defined(NLOHMANN_JSON_HEDLEY_REQUIRE) - #undef NLOHMANN_JSON_HEDLEY_REQUIRE +#if defined(JSON_HEDLEY_REQUIRE) + #undef JSON_HEDLEY_REQUIRE #endif -#define NLOHMANN_JSON_HEDLEY_REQUIRE(expr) NLOHMANN_JSON_HEDLEY_REQUIRE_MSG(expr, #expr) +#define JSON_HEDLEY_REQUIRE(expr) JSON_HEDLEY_REQUIRE_MSG(expr, #expr) -#if defined(NLOHMANN_JSON_HEDLEY_FLAGS) - #undef NLOHMANN_JSON_HEDLEY_FLAGS +#if defined(JSON_HEDLEY_FLAGS) + #undef JSON_HEDLEY_FLAGS #endif -#if NLOHMANN_JSON_HEDLEY_HAS_ATTRIBUTE(flag_enum) - #define NLOHMANN_JSON_HEDLEY_FLAGS __attribute__((__flag_enum__)) +#if JSON_HEDLEY_HAS_ATTRIBUTE(flag_enum) + #define JSON_HEDLEY_FLAGS __attribute__((__flag_enum__)) #endif -#if defined(NLOHMANN_JSON_HEDLEY_FLAGS_CAST) - #undef NLOHMANN_JSON_HEDLEY_FLAGS_CAST +#if defined(JSON_HEDLEY_FLAGS_CAST) + #undef JSON_HEDLEY_FLAGS_CAST #endif -#if NLOHMANN_JSON_HEDLEY_INTEL_VERSION_CHECK(19,0,0) -# define NLOHMANN_JSON_HEDLEY_FLAGS_CAST(T, expr) (__extension__ ({ \ - NLOHMANN_JSON_HEDLEY_DIAGNOSTIC_PUSH \ +#if JSON_HEDLEY_INTEL_VERSION_CHECK(19,0,0) +# define JSON_HEDLEY_FLAGS_CAST(T, expr) (__extension__ ({ \ + JSON_HEDLEY_DIAGNOSTIC_PUSH \ _Pragma("warning(disable:188)") \ ((T) (expr)); \ - NLOHMANN_JSON_HEDLEY_DIAGNOSTIC_POP \ + JSON_HEDLEY_DIAGNOSTIC_POP \ })) #else -# define NLOHMANN_JSON_HEDLEY_FLAGS_CAST(T, expr) NLOHMANN_JSON_HEDLEY_STATIC_CAST(T, expr) +# define JSON_HEDLEY_FLAGS_CAST(T, expr) JSON_HEDLEY_STATIC_CAST(T, expr) #endif /* Remaining macros are deprecated. */ -#if defined(NLOHMANN_JSON_HEDLEY_GCC_NOT_CLANG_VERSION_CHECK) - #undef NLOHMANN_JSON_HEDLEY_GCC_NOT_CLANG_VERSION_CHECK +#if defined(JSON_HEDLEY_GCC_NOT_CLANG_VERSION_CHECK) + #undef JSON_HEDLEY_GCC_NOT_CLANG_VERSION_CHECK #endif #if defined(__clang__) - #define NLOHMANN_JSON_HEDLEY_GCC_NOT_CLANG_VERSION_CHECK(major,minor,patch) (0) + #define JSON_HEDLEY_GCC_NOT_CLANG_VERSION_CHECK(major,minor,patch) (0) #else - #define NLOHMANN_JSON_HEDLEY_GCC_NOT_CLANG_VERSION_CHECK(major,minor,patch) NLOHMANN_JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch) + #define JSON_HEDLEY_GCC_NOT_CLANG_VERSION_CHECK(major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch) #endif -#if defined(NLOHMANN_JSON_HEDLEY_CLANG_HAS_ATTRIBUTE) - #undef NLOHMANN_JSON_HEDLEY_CLANG_HAS_ATTRIBUTE +#if defined(JSON_HEDLEY_CLANG_HAS_ATTRIBUTE) + #undef JSON_HEDLEY_CLANG_HAS_ATTRIBUTE #endif -#define NLOHMANN_JSON_HEDLEY_CLANG_HAS_ATTRIBUTE(attribute) NLOHMANN_JSON_HEDLEY_HAS_ATTRIBUTE(attribute) +#define JSON_HEDLEY_CLANG_HAS_ATTRIBUTE(attribute) JSON_HEDLEY_HAS_ATTRIBUTE(attribute) -#if defined(NLOHMANN_JSON_HEDLEY_CLANG_HAS_CPP_ATTRIBUTE) - #undef NLOHMANN_JSON_HEDLEY_CLANG_HAS_CPP_ATTRIBUTE +#if defined(JSON_HEDLEY_CLANG_HAS_CPP_ATTRIBUTE) + #undef JSON_HEDLEY_CLANG_HAS_CPP_ATTRIBUTE #endif -#define NLOHMANN_JSON_HEDLEY_CLANG_HAS_CPP_ATTRIBUTE(attribute) NLOHMANN_JSON_HEDLEY_HAS_CPP_ATTRIBUTE(attribute) +#define JSON_HEDLEY_CLANG_HAS_CPP_ATTRIBUTE(attribute) JSON_HEDLEY_HAS_CPP_ATTRIBUTE(attribute) -#if defined(NLOHMANN_JSON_HEDLEY_CLANG_HAS_BUILTIN) - #undef NLOHMANN_JSON_HEDLEY_CLANG_HAS_BUILTIN +#if defined(JSON_HEDLEY_CLANG_HAS_BUILTIN) + #undef JSON_HEDLEY_CLANG_HAS_BUILTIN #endif -#define NLOHMANN_JSON_HEDLEY_CLANG_HAS_BUILTIN(builtin) NLOHMANN_JSON_HEDLEY_HAS_BUILTIN(builtin) +#define JSON_HEDLEY_CLANG_HAS_BUILTIN(builtin) JSON_HEDLEY_HAS_BUILTIN(builtin) -#if defined(NLOHMANN_JSON_HEDLEY_CLANG_HAS_FEATURE) - #undef NLOHMANN_JSON_HEDLEY_CLANG_HAS_FEATURE +#if defined(JSON_HEDLEY_CLANG_HAS_FEATURE) + #undef JSON_HEDLEY_CLANG_HAS_FEATURE #endif -#define NLOHMANN_JSON_HEDLEY_CLANG_HAS_FEATURE(feature) NLOHMANN_JSON_HEDLEY_HAS_FEATURE(feature) +#define JSON_HEDLEY_CLANG_HAS_FEATURE(feature) JSON_HEDLEY_HAS_FEATURE(feature) -#if defined(NLOHMANN_JSON_HEDLEY_CLANG_HAS_EXTENSION) - #undef NLOHMANN_JSON_HEDLEY_CLANG_HAS_EXTENSION +#if defined(JSON_HEDLEY_CLANG_HAS_EXTENSION) + #undef JSON_HEDLEY_CLANG_HAS_EXTENSION #endif -#define NLOHMANN_JSON_HEDLEY_CLANG_HAS_EXTENSION(extension) NLOHMANN_JSON_HEDLEY_HAS_EXTENSION(extension) +#define JSON_HEDLEY_CLANG_HAS_EXTENSION(extension) JSON_HEDLEY_HAS_EXTENSION(extension) -#if defined(NLOHMANN_JSON_HEDLEY_CLANG_HAS_DECLSPEC_DECLSPEC_ATTRIBUTE) - #undef NLOHMANN_JSON_HEDLEY_CLANG_HAS_DECLSPEC_DECLSPEC_ATTRIBUTE +#if defined(JSON_HEDLEY_CLANG_HAS_DECLSPEC_DECLSPEC_ATTRIBUTE) + #undef JSON_HEDLEY_CLANG_HAS_DECLSPEC_DECLSPEC_ATTRIBUTE #endif -#define NLOHMANN_JSON_HEDLEY_CLANG_HAS_DECLSPEC_ATTRIBUTE(attribute) NLOHMANN_JSON_HEDLEY_HAS_DECLSPEC_ATTRIBUTE(attribute) +#define JSON_HEDLEY_CLANG_HAS_DECLSPEC_ATTRIBUTE(attribute) JSON_HEDLEY_HAS_DECLSPEC_ATTRIBUTE(attribute) -#if defined(NLOHMANN_JSON_HEDLEY_CLANG_HAS_WARNING) - #undef NLOHMANN_JSON_HEDLEY_CLANG_HAS_WARNING +#if defined(JSON_HEDLEY_CLANG_HAS_WARNING) + #undef JSON_HEDLEY_CLANG_HAS_WARNING #endif -#define NLOHMANN_JSON_HEDLEY_CLANG_HAS_WARNING(warning) NLOHMANN_JSON_HEDLEY_HAS_WARNING(warning) +#define JSON_HEDLEY_CLANG_HAS_WARNING(warning) JSON_HEDLEY_HAS_WARNING(warning) -#endif /* !defined(NLOHMANN_JSON_HEDLEY_VERSION) || (NLOHMANN_JSON_HEDLEY_VERSION < X) */ +#endif /* !defined(JSON_HEDLEY_VERSION) || (JSON_HEDLEY_VERSION < X) */ // This file contains all internal macro definitions @@ -1775,7 +1775,7 @@ class exception : public std::exception { public: /// returns the explanatory string - NLOHMANN_JSON_HEDLEY_RETURNS_NON_NULL + JSON_HEDLEY_RETURNS_NON_NULL const char* what() const noexcept override { return m.what(); @@ -1785,7 +1785,7 @@ class exception : public std::exception const int id; protected: - NLOHMANN_JSON_HEDLEY_NON_NULL(3) + JSON_HEDLEY_NON_NULL(3) exception(int id_, const char* what_arg) : id(id_), m(what_arg) {} static std::string name(const std::string& ename, int id_) @@ -1938,7 +1938,7 @@ class invalid_iterator : public exception } private: - NLOHMANN_JSON_HEDLEY_NON_NULL(3) + JSON_HEDLEY_NON_NULL(3) invalid_iterator(int id_, const char* what_arg) : exception(id_, what_arg) {} }; @@ -1992,7 +1992,7 @@ class type_error : public exception } private: - NLOHMANN_JSON_HEDLEY_NON_NULL(3) + JSON_HEDLEY_NON_NULL(3) type_error(int id_, const char* what_arg) : exception(id_, what_arg) {} }; @@ -2039,7 +2039,7 @@ class out_of_range : public exception } private: - NLOHMANN_JSON_HEDLEY_NON_NULL(3) + JSON_HEDLEY_NON_NULL(3) out_of_range(int id_, const char* what_arg) : exception(id_, what_arg) {} }; @@ -2077,7 +2077,7 @@ class other_error : public exception } private: - NLOHMANN_JSON_HEDLEY_NON_NULL(3) + JSON_HEDLEY_NON_NULL(3) other_error(int id_, const char* what_arg) : exception(id_, what_arg) {} }; } // namespace detail @@ -2794,7 +2794,7 @@ namespace detail template void from_json(const BasicJsonType& j, typename std::nullptr_t& n) { - if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not j.is_null())) + if (JSON_HEDLEY_UNLIKELY(not j.is_null())) { JSON_THROW(type_error::create(302, "type must be null, but is " + std::string(j.type_name()))); } @@ -2834,7 +2834,7 @@ void get_arithmetic_value(const BasicJsonType& j, ArithmeticType& val) template void from_json(const BasicJsonType& j, typename BasicJsonType::boolean_t& b) { - if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not j.is_boolean())) + if (JSON_HEDLEY_UNLIKELY(not j.is_boolean())) { JSON_THROW(type_error::create(302, "type must be boolean, but is " + std::string(j.type_name()))); } @@ -2844,7 +2844,7 @@ void from_json(const BasicJsonType& j, typename BasicJsonType::boolean_t& b) template void from_json(const BasicJsonType& j, typename BasicJsonType::string_t& s) { - if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not j.is_string())) + if (JSON_HEDLEY_UNLIKELY(not j.is_string())) { JSON_THROW(type_error::create(302, "type must be string, but is " + std::string(j.type_name()))); } @@ -2860,7 +2860,7 @@ template < int > = 0 > void from_json(const BasicJsonType& j, ConstructibleStringType& s) { - if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not j.is_string())) + if (JSON_HEDLEY_UNLIKELY(not j.is_string())) { JSON_THROW(type_error::create(302, "type must be string, but is " + std::string(j.type_name()))); } @@ -2900,7 +2900,7 @@ template::value, int> = 0> void from_json(const BasicJsonType& j, std::forward_list& l) { - if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not j.is_array())) + if (JSON_HEDLEY_UNLIKELY(not j.is_array())) { JSON_THROW(type_error::create(302, "type must be array, but is " + std::string(j.type_name()))); } @@ -2917,7 +2917,7 @@ template::value, int> = 0> void from_json(const BasicJsonType& j, std::valarray& l) { - if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not j.is_array())) + if (JSON_HEDLEY_UNLIKELY(not j.is_array())) { JSON_THROW(type_error::create(302, "type must be array, but is " + std::string(j.type_name()))); } @@ -3004,7 +3004,7 @@ auto from_json(const BasicJsonType& j, ConstructibleArrayType& arr) j.template get(), void()) { - if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not j.is_array())) + if (JSON_HEDLEY_UNLIKELY(not j.is_array())) { JSON_THROW(type_error::create(302, "type must be array, but is " + std::string(j.type_name()))); @@ -3017,7 +3017,7 @@ template::value, int> = 0> void from_json(const BasicJsonType& j, ConstructibleObjectType& obj) { - if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not j.is_object())) + if (JSON_HEDLEY_UNLIKELY(not j.is_object())) { JSON_THROW(type_error::create(302, "type must be object, but is " + std::string(j.type_name()))); } @@ -3100,14 +3100,14 @@ template ::value>> void from_json(const BasicJsonType& j, std::map& m) { - if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not j.is_array())) + if (JSON_HEDLEY_UNLIKELY(not j.is_array())) { JSON_THROW(type_error::create(302, "type must be array, but is " + std::string(j.type_name()))); } m.clear(); for (const auto& p : j) { - if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not p.is_array())) + if (JSON_HEDLEY_UNLIKELY(not p.is_array())) { JSON_THROW(type_error::create(302, "type must be array, but is " + std::string(p.type_name()))); } @@ -3120,14 +3120,14 @@ template ::value>> void from_json(const BasicJsonType& j, std::unordered_map& m) { - if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not j.is_array())) + if (JSON_HEDLEY_UNLIKELY(not j.is_array())) { JSON_THROW(type_error::create(302, "type must be array, but is " + std::string(j.type_name()))); } m.clear(); for (const auto& p : j) { - if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not p.is_array())) + if (JSON_HEDLEY_UNLIKELY(not p.is_array())) { JSON_THROW(type_error::create(302, "type must be array, but is " + std::string(p.type_name()))); } @@ -3806,7 +3806,7 @@ Input adapter for stdio file access. This adapter read only 1 byte and do not us class file_input_adapter : public input_adapter_protocol { public: - NLOHMANN_JSON_HEDLEY_NON_NULL(2) + JSON_HEDLEY_NON_NULL(2) explicit file_input_adapter(std::FILE* f) noexcept : m_file(f) {} @@ -3882,7 +3882,7 @@ class input_stream_adapter : public input_adapter_protocol class input_buffer_adapter : public input_adapter_protocol { public: - NLOHMANN_JSON_HEDLEY_NON_NULL(2) + JSON_HEDLEY_NON_NULL(2) input_buffer_adapter(const char* b, const std::size_t l) noexcept : cursor(b), limit(b + l) {} @@ -3896,7 +3896,7 @@ class input_buffer_adapter : public input_adapter_protocol std::char_traits::int_type get_character() noexcept override { - if (NLOHMANN_JSON_HEDLEY_LIKELY(cursor < limit)) + if (JSON_HEDLEY_LIKELY(cursor < limit)) { return std::char_traits::to_int_type(*(cursor++)); } @@ -4086,7 +4086,7 @@ class input_adapter { public: // native support - NLOHMANN_JSON_HEDLEY_NON_NULL(2) + JSON_HEDLEY_NON_NULL(2) input_adapter(std::FILE* file) : ia(std::make_shared(file)) {} /// input adapter for input stream @@ -4155,7 +4155,7 @@ class input_adapter "each element in the iterator range must have the size of 1 byte"); const auto len = static_cast(std::distance(first, last)); - if (NLOHMANN_JSON_HEDLEY_LIKELY(len > 0)) + if (JSON_HEDLEY_LIKELY(len > 0)) { // there is at least one element: use the address of first ia = std::make_shared(reinterpret_cast(&(*first)), len); @@ -4403,7 +4403,7 @@ class json_sax_dom_parser { ref_stack.push_back(handle_value(BasicJsonType::value_t::object)); - if (NLOHMANN_JSON_HEDLEY_UNLIKELY(len != std::size_t(-1) and len > ref_stack.back()->max_size())) + if (JSON_HEDLEY_UNLIKELY(len != std::size_t(-1) and len > ref_stack.back()->max_size())) { JSON_THROW(out_of_range::create(408, "excessive object size: " + std::to_string(len))); @@ -4429,7 +4429,7 @@ class json_sax_dom_parser { ref_stack.push_back(handle_value(BasicJsonType::value_t::array)); - if (NLOHMANN_JSON_HEDLEY_UNLIKELY(len != std::size_t(-1) and len > ref_stack.back()->max_size())) + if (JSON_HEDLEY_UNLIKELY(len != std::size_t(-1) and len > ref_stack.back()->max_size())) { JSON_THROW(out_of_range::create(408, "excessive array size: " + std::to_string(len))); @@ -4485,7 +4485,7 @@ class json_sax_dom_parser object to which we can add elements */ template - NLOHMANN_JSON_HEDLEY_RETURNS_NON_NULL + JSON_HEDLEY_RETURNS_NON_NULL BasicJsonType* handle_value(Value&& v) { if (ref_stack.empty()) @@ -4592,7 +4592,7 @@ class json_sax_dom_callback_parser ref_stack.push_back(val.second); // check object limit - if (ref_stack.back() and NLOHMANN_JSON_HEDLEY_UNLIKELY(len != std::size_t(-1) and len > ref_stack.back()->max_size())) + if (ref_stack.back() and JSON_HEDLEY_UNLIKELY(len != std::size_t(-1) and len > ref_stack.back()->max_size())) { JSON_THROW(out_of_range::create(408, "excessive object size: " + std::to_string(len))); } @@ -4655,7 +4655,7 @@ class json_sax_dom_callback_parser ref_stack.push_back(val.second); // check array limit - if (ref_stack.back() and NLOHMANN_JSON_HEDLEY_UNLIKELY(len != std::size_t(-1) and len > ref_stack.back()->max_size())) + if (ref_stack.back() and JSON_HEDLEY_UNLIKELY(len != std::size_t(-1) and len > ref_stack.back()->max_size())) { JSON_THROW(out_of_range::create(408, "excessive array size: " + std::to_string(len))); } @@ -5094,7 +5094,7 @@ class binary_reader @return */ - NLOHMANN_JSON_HEDLEY_NON_NULL(3) + JSON_HEDLEY_NON_NULL(3) bool sax_parse(const input_format_t format, json_sax_t* sax_, const bool strict = true) @@ -5136,7 +5136,7 @@ class binary_reader get(); } - if (NLOHMANN_JSON_HEDLEY_UNLIKELY(current != std::char_traits::eof())) + if (JSON_HEDLEY_UNLIKELY(current != std::char_traits::eof())) { return sax->parse_error(chars_read, get_token_string(), parse_error::create(110, chars_read, exception_message(format, "expected end of input; last byte: 0x" + get_token_string(), "value"))); @@ -5172,12 +5172,12 @@ class binary_reader std::int32_t document_size; get_number(input_format_t::bson, document_size); - if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not sax->start_object(std::size_t(-1)))) + if (JSON_HEDLEY_UNLIKELY(not sax->start_object(std::size_t(-1)))) { return false; } - if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not parse_bson_element_list(/*is_array*/false))) + if (JSON_HEDLEY_UNLIKELY(not parse_bson_element_list(/*is_array*/false))) { return false; } @@ -5198,7 +5198,7 @@ class binary_reader while (true) { get(); - if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not unexpect_eof(input_format_t::bson, "cstring"))) + if (JSON_HEDLEY_UNLIKELY(not unexpect_eof(input_format_t::bson, "cstring"))) { return false; } @@ -5226,7 +5226,7 @@ class binary_reader template bool get_bson_string(const NumberType len, string_t& result) { - if (NLOHMANN_JSON_HEDLEY_UNLIKELY(len < 1)) + if (JSON_HEDLEY_UNLIKELY(len < 1)) { auto last_token = get_token_string(); return sax->parse_error(chars_read, last_token, parse_error::create(112, chars_read, exception_message(input_format_t::bson, "string length must be at least 1, is " + std::to_string(len), "string"))); @@ -5321,13 +5321,13 @@ class binary_reader string_t key; while (int element_type = get()) { - if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not unexpect_eof(input_format_t::bson, "element list"))) + if (JSON_HEDLEY_UNLIKELY(not unexpect_eof(input_format_t::bson, "element list"))) { return false; } const std::size_t element_type_parse_position = chars_read; - if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not get_bson_cstr(key))) + if (JSON_HEDLEY_UNLIKELY(not get_bson_cstr(key))) { return false; } @@ -5337,7 +5337,7 @@ class binary_reader return false; } - if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not parse_bson_element_internal(element_type, element_type_parse_position))) + if (JSON_HEDLEY_UNLIKELY(not parse_bson_element_internal(element_type, element_type_parse_position))) { return false; } @@ -5358,12 +5358,12 @@ class binary_reader std::int32_t document_size; get_number(input_format_t::bson, document_size); - if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not sax->start_array(std::size_t(-1)))) + if (JSON_HEDLEY_UNLIKELY(not sax->start_array(std::size_t(-1)))) { return false; } - if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not parse_bson_element_list(/*is_array*/true))) + if (JSON_HEDLEY_UNLIKELY(not parse_bson_element_list(/*is_array*/true))) { return false; } @@ -5648,12 +5648,12 @@ class binary_reader case 0xF9: // Half-Precision Float (two-byte IEEE 754) { const int byte1_raw = get(); - if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not unexpect_eof(input_format_t::cbor, "number"))) + if (JSON_HEDLEY_UNLIKELY(not unexpect_eof(input_format_t::cbor, "number"))) { return false; } const int byte2_raw = get(); - if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not unexpect_eof(input_format_t::cbor, "number"))) + if (JSON_HEDLEY_UNLIKELY(not unexpect_eof(input_format_t::cbor, "number"))) { return false; } @@ -5726,7 +5726,7 @@ class binary_reader */ bool get_cbor_string(string_t& result) { - if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not unexpect_eof(input_format_t::cbor, "string"))) + if (JSON_HEDLEY_UNLIKELY(not unexpect_eof(input_format_t::cbor, "string"))) { return false; } @@ -5815,7 +5815,7 @@ class binary_reader */ bool get_cbor_array(const std::size_t len) { - if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not sax->start_array(len))) + if (JSON_HEDLEY_UNLIKELY(not sax->start_array(len))) { return false; } @@ -5824,7 +5824,7 @@ class binary_reader { for (std::size_t i = 0; i < len; ++i) { - if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not parse_cbor_internal())) + if (JSON_HEDLEY_UNLIKELY(not parse_cbor_internal())) { return false; } @@ -5834,7 +5834,7 @@ class binary_reader { while (get() != 0xFF) { - if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not parse_cbor_internal(false))) + if (JSON_HEDLEY_UNLIKELY(not parse_cbor_internal(false))) { return false; } @@ -5851,7 +5851,7 @@ class binary_reader */ bool get_cbor_object(const std::size_t len) { - if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not sax->start_object(len))) + if (JSON_HEDLEY_UNLIKELY(not sax->start_object(len))) { return false; } @@ -5862,12 +5862,12 @@ class binary_reader for (std::size_t i = 0; i < len; ++i) { get(); - if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not get_cbor_string(key) or not sax->key(key))) + if (JSON_HEDLEY_UNLIKELY(not get_cbor_string(key) or not sax->key(key))) { return false; } - if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not parse_cbor_internal())) + if (JSON_HEDLEY_UNLIKELY(not parse_cbor_internal())) { return false; } @@ -5878,12 +5878,12 @@ class binary_reader { while (get() != 0xFF) { - if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not get_cbor_string(key) or not sax->key(key))) + if (JSON_HEDLEY_UNLIKELY(not get_cbor_string(key) or not sax->key(key))) { return false; } - if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not parse_cbor_internal())) + if (JSON_HEDLEY_UNLIKELY(not parse_cbor_internal())) { return false; } @@ -6272,7 +6272,7 @@ class binary_reader */ bool get_msgpack_string(string_t& result) { - if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not unexpect_eof(input_format_t::msgpack, "string"))) + if (JSON_HEDLEY_UNLIKELY(not unexpect_eof(input_format_t::msgpack, "string"))) { return false; } @@ -6348,14 +6348,14 @@ class binary_reader */ bool get_msgpack_array(const std::size_t len) { - if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not sax->start_array(len))) + if (JSON_HEDLEY_UNLIKELY(not sax->start_array(len))) { return false; } for (std::size_t i = 0; i < len; ++i) { - if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not parse_msgpack_internal())) + if (JSON_HEDLEY_UNLIKELY(not parse_msgpack_internal())) { return false; } @@ -6370,7 +6370,7 @@ class binary_reader */ bool get_msgpack_object(const std::size_t len) { - if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not sax->start_object(len))) + if (JSON_HEDLEY_UNLIKELY(not sax->start_object(len))) { return false; } @@ -6379,12 +6379,12 @@ class binary_reader for (std::size_t i = 0; i < len; ++i) { get(); - if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not get_msgpack_string(key) or not sax->key(key))) + if (JSON_HEDLEY_UNLIKELY(not get_msgpack_string(key) or not sax->key(key))) { return false; } - if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not parse_msgpack_internal())) + if (JSON_HEDLEY_UNLIKELY(not parse_msgpack_internal())) { return false; } @@ -6431,7 +6431,7 @@ class binary_reader get(); // TODO(niels): may we ignore N here? } - if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not unexpect_eof(input_format_t::ubjson, "value"))) + if (JSON_HEDLEY_UNLIKELY(not unexpect_eof(input_format_t::ubjson, "value"))) { return false; } @@ -6485,7 +6485,7 @@ class binary_reader case 'U': { std::uint8_t number; - if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not get_number(input_format_t::ubjson, number))) + if (JSON_HEDLEY_UNLIKELY(not get_number(input_format_t::ubjson, number))) { return false; } @@ -6496,7 +6496,7 @@ class binary_reader case 'i': { std::int8_t number; - if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not get_number(input_format_t::ubjson, number))) + if (JSON_HEDLEY_UNLIKELY(not get_number(input_format_t::ubjson, number))) { return false; } @@ -6507,7 +6507,7 @@ class binary_reader case 'I': { std::int16_t number; - if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not get_number(input_format_t::ubjson, number))) + if (JSON_HEDLEY_UNLIKELY(not get_number(input_format_t::ubjson, number))) { return false; } @@ -6518,7 +6518,7 @@ class binary_reader case 'l': { std::int32_t number; - if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not get_number(input_format_t::ubjson, number))) + if (JSON_HEDLEY_UNLIKELY(not get_number(input_format_t::ubjson, number))) { return false; } @@ -6529,7 +6529,7 @@ class binary_reader case 'L': { std::int64_t number; - if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not get_number(input_format_t::ubjson, number))) + if (JSON_HEDLEY_UNLIKELY(not get_number(input_format_t::ubjson, number))) { return false; } @@ -6565,15 +6565,15 @@ class binary_reader if (current == '$') { result.second = get(); // must not ignore 'N', because 'N' maybe the type - if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not unexpect_eof(input_format_t::ubjson, "type"))) + if (JSON_HEDLEY_UNLIKELY(not unexpect_eof(input_format_t::ubjson, "type"))) { return false; } get_ignore_noop(); - if (NLOHMANN_JSON_HEDLEY_UNLIKELY(current != '#')) + if (JSON_HEDLEY_UNLIKELY(current != '#')) { - if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not unexpect_eof(input_format_t::ubjson, "value"))) + if (JSON_HEDLEY_UNLIKELY(not unexpect_eof(input_format_t::ubjson, "value"))) { return false; } @@ -6656,11 +6656,11 @@ class binary_reader case 'C': // char { get(); - if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not unexpect_eof(input_format_t::ubjson, "char"))) + if (JSON_HEDLEY_UNLIKELY(not unexpect_eof(input_format_t::ubjson, "char"))) { return false; } - if (NLOHMANN_JSON_HEDLEY_UNLIKELY(current > 127)) + if (JSON_HEDLEY_UNLIKELY(current > 127)) { auto last_token = get_token_string(); return sax->parse_error(chars_read, last_token, parse_error::create(113, chars_read, exception_message(input_format_t::ubjson, "byte after 'C' must be in range 0x00..0x7F; last byte: 0x" + last_token, "char"))); @@ -6695,14 +6695,14 @@ class binary_reader bool get_ubjson_array() { std::pair size_and_type; - if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not get_ubjson_size_type(size_and_type))) + if (JSON_HEDLEY_UNLIKELY(not get_ubjson_size_type(size_and_type))) { return false; } if (size_and_type.first != string_t::npos) { - if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not sax->start_array(size_and_type.first))) + if (JSON_HEDLEY_UNLIKELY(not sax->start_array(size_and_type.first))) { return false; } @@ -6713,7 +6713,7 @@ class binary_reader { for (std::size_t i = 0; i < size_and_type.first; ++i) { - if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not get_ubjson_value(size_and_type.second))) + if (JSON_HEDLEY_UNLIKELY(not get_ubjson_value(size_and_type.second))) { return false; } @@ -6724,7 +6724,7 @@ class binary_reader { for (std::size_t i = 0; i < size_and_type.first; ++i) { - if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not parse_ubjson_internal())) + if (JSON_HEDLEY_UNLIKELY(not parse_ubjson_internal())) { return false; } @@ -6733,14 +6733,14 @@ class binary_reader } else { - if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not sax->start_array(std::size_t(-1)))) + if (JSON_HEDLEY_UNLIKELY(not sax->start_array(std::size_t(-1)))) { return false; } while (current != ']') { - if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not parse_ubjson_internal(false))) + if (JSON_HEDLEY_UNLIKELY(not parse_ubjson_internal(false))) { return false; } @@ -6757,7 +6757,7 @@ class binary_reader bool get_ubjson_object() { std::pair size_and_type; - if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not get_ubjson_size_type(size_and_type))) + if (JSON_HEDLEY_UNLIKELY(not get_ubjson_size_type(size_and_type))) { return false; } @@ -6765,7 +6765,7 @@ class binary_reader string_t key; if (size_and_type.first != string_t::npos) { - if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not sax->start_object(size_and_type.first))) + if (JSON_HEDLEY_UNLIKELY(not sax->start_object(size_and_type.first))) { return false; } @@ -6774,11 +6774,11 @@ class binary_reader { for (std::size_t i = 0; i < size_and_type.first; ++i) { - if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not get_ubjson_string(key) or not sax->key(key))) + if (JSON_HEDLEY_UNLIKELY(not get_ubjson_string(key) or not sax->key(key))) { return false; } - if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not get_ubjson_value(size_and_type.second))) + if (JSON_HEDLEY_UNLIKELY(not get_ubjson_value(size_and_type.second))) { return false; } @@ -6789,11 +6789,11 @@ class binary_reader { for (std::size_t i = 0; i < size_and_type.first; ++i) { - if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not get_ubjson_string(key) or not sax->key(key))) + if (JSON_HEDLEY_UNLIKELY(not get_ubjson_string(key) or not sax->key(key))) { return false; } - if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not parse_ubjson_internal())) + if (JSON_HEDLEY_UNLIKELY(not parse_ubjson_internal())) { return false; } @@ -6803,18 +6803,18 @@ class binary_reader } else { - if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not sax->start_object(std::size_t(-1)))) + if (JSON_HEDLEY_UNLIKELY(not sax->start_object(std::size_t(-1)))) { return false; } while (current != '}') { - if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not get_ubjson_string(key, false) or not sax->key(key))) + if (JSON_HEDLEY_UNLIKELY(not get_ubjson_string(key, false) or not sax->key(key))) { return false; } - if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not parse_ubjson_internal())) + if (JSON_HEDLEY_UNLIKELY(not parse_ubjson_internal())) { return false; } @@ -6880,7 +6880,7 @@ class binary_reader for (std::size_t i = 0; i < sizeof(NumberType); ++i) { get(); - if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not unexpect_eof(format, "number"))) + if (JSON_HEDLEY_UNLIKELY(not unexpect_eof(format, "number"))) { return false; } @@ -6924,7 +6924,7 @@ class binary_reader std::generate_n(std::back_inserter(result), len, [this, &success, &format]() { get(); - if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not unexpect_eof(format, "string"))) + if (JSON_HEDLEY_UNLIKELY(not unexpect_eof(format, "string"))) { success = false; } @@ -6938,10 +6938,10 @@ class binary_reader @param[in] context further context information (for diagnostics) @return whether the last read character is not EOF */ - NLOHMANN_JSON_HEDLEY_NON_NULL(3) + JSON_HEDLEY_NON_NULL(3) bool unexpect_eof(const input_format_t format, const char* context) const { - if (NLOHMANN_JSON_HEDLEY_UNLIKELY(current == std::char_traits::eof())) + if (JSON_HEDLEY_UNLIKELY(current == std::char_traits::eof())) { return sax->parse_error(chars_read, "", parse_error::create(110, chars_read, exception_message(format, "unexpected end of input", context))); @@ -7082,7 +7082,7 @@ class lexer }; /// return name of values of type token_type (only used for errors) - NLOHMANN_JSON_HEDLEY_RETURNS_NON_NULL + JSON_HEDLEY_RETURNS_NON_NULL static const char* token_type_name(const token_type t) noexcept { switch (t) @@ -7224,7 +7224,7 @@ class lexer for (auto range = ranges.begin(); range != ranges.end(); ++range) { get(); - if (NLOHMANN_JSON_HEDLEY_LIKELY(*range <= current and current <= *(++range))) + if (JSON_HEDLEY_LIKELY(*range <= current and current <= *(++range))) { add(current); } @@ -7323,7 +7323,7 @@ class lexer const int codepoint1 = get_codepoint(); int codepoint = codepoint1; // start with codepoint1 - if (NLOHMANN_JSON_HEDLEY_UNLIKELY(codepoint1 == -1)) + if (JSON_HEDLEY_UNLIKELY(codepoint1 == -1)) { error_message = "invalid string: '\\u' must be followed by 4 hex digits"; return token_type::parse_error; @@ -7333,18 +7333,18 @@ class lexer if (0xD800 <= codepoint1 and codepoint1 <= 0xDBFF) { // expect next \uxxxx entry - if (NLOHMANN_JSON_HEDLEY_LIKELY(get() == '\\' and get() == 'u')) + if (JSON_HEDLEY_LIKELY(get() == '\\' and get() == 'u')) { const int codepoint2 = get_codepoint(); - if (NLOHMANN_JSON_HEDLEY_UNLIKELY(codepoint2 == -1)) + if (JSON_HEDLEY_UNLIKELY(codepoint2 == -1)) { error_message = "invalid string: '\\u' must be followed by 4 hex digits"; return token_type::parse_error; } // check if codepoint2 is a low surrogate - if (NLOHMANN_JSON_HEDLEY_LIKELY(0xDC00 <= codepoint2 and codepoint2 <= 0xDFFF)) + if (JSON_HEDLEY_LIKELY(0xDC00 <= codepoint2 and codepoint2 <= 0xDFFF)) { // overwrite codepoint codepoint = static_cast( @@ -7371,7 +7371,7 @@ class lexer } else { - if (NLOHMANN_JSON_HEDLEY_UNLIKELY(0xDC00 <= codepoint1 and codepoint1 <= 0xDFFF)) + if (JSON_HEDLEY_UNLIKELY(0xDC00 <= codepoint1 and codepoint1 <= 0xDFFF)) { error_message = "invalid string: surrogate U+DC00..U+DFFF must follow U+D800..U+DBFF"; return token_type::parse_error; @@ -7746,7 +7746,7 @@ class lexer case 0xDE: case 0xDF: { - if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not next_byte_in_range({0x80, 0xBF}))) + if (JSON_HEDLEY_UNLIKELY(not next_byte_in_range({0x80, 0xBF}))) { return token_type::parse_error; } @@ -7756,7 +7756,7 @@ class lexer // U+0800..U+0FFF: bytes E0 A0..BF 80..BF case 0xE0: { - if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not (next_byte_in_range({0xA0, 0xBF, 0x80, 0xBF})))) + if (JSON_HEDLEY_UNLIKELY(not (next_byte_in_range({0xA0, 0xBF, 0x80, 0xBF})))) { return token_type::parse_error; } @@ -7780,7 +7780,7 @@ class lexer case 0xEE: case 0xEF: { - if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not (next_byte_in_range({0x80, 0xBF, 0x80, 0xBF})))) + if (JSON_HEDLEY_UNLIKELY(not (next_byte_in_range({0x80, 0xBF, 0x80, 0xBF})))) { return token_type::parse_error; } @@ -7790,7 +7790,7 @@ class lexer // U+D000..U+D7FF: bytes ED 80..9F 80..BF case 0xED: { - if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not (next_byte_in_range({0x80, 0x9F, 0x80, 0xBF})))) + if (JSON_HEDLEY_UNLIKELY(not (next_byte_in_range({0x80, 0x9F, 0x80, 0xBF})))) { return token_type::parse_error; } @@ -7800,7 +7800,7 @@ class lexer // U+10000..U+3FFFF F0 90..BF 80..BF 80..BF case 0xF0: { - if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not (next_byte_in_range({0x90, 0xBF, 0x80, 0xBF, 0x80, 0xBF})))) + if (JSON_HEDLEY_UNLIKELY(not (next_byte_in_range({0x90, 0xBF, 0x80, 0xBF, 0x80, 0xBF})))) { return token_type::parse_error; } @@ -7812,7 +7812,7 @@ class lexer case 0xF2: case 0xF3: { - if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not (next_byte_in_range({0x80, 0xBF, 0x80, 0xBF, 0x80, 0xBF})))) + if (JSON_HEDLEY_UNLIKELY(not (next_byte_in_range({0x80, 0xBF, 0x80, 0xBF, 0x80, 0xBF})))) { return token_type::parse_error; } @@ -7822,7 +7822,7 @@ class lexer // U+100000..U+10FFFF F4 80..8F 80..BF 80..BF case 0xF4: { - if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not (next_byte_in_range({0x80, 0x8F, 0x80, 0xBF, 0x80, 0xBF})))) + if (JSON_HEDLEY_UNLIKELY(not (next_byte_in_range({0x80, 0x8F, 0x80, 0xBF, 0x80, 0xBF})))) { return token_type::parse_error; } @@ -7839,19 +7839,19 @@ class lexer } } - NLOHMANN_JSON_HEDLEY_NON_NULL(2) + JSON_HEDLEY_NON_NULL(2) static void strtof(float& f, const char* str, char** endptr) noexcept { f = std::strtof(str, endptr); } - NLOHMANN_JSON_HEDLEY_NON_NULL(2) + JSON_HEDLEY_NON_NULL(2) static void strtof(double& f, const char* str, char** endptr) noexcept { f = std::strtod(str, endptr); } - NLOHMANN_JSON_HEDLEY_NON_NULL(2) + JSON_HEDLEY_NON_NULL(2) static void strtof(long double& f, const char* str, char** endptr) noexcept { f = std::strtold(str, endptr); @@ -8227,14 +8227,14 @@ scan_number_done: @param[in] length the length of the passed literal text @param[in] return_type the token type to return on success */ - NLOHMANN_JSON_HEDLEY_NON_NULL(2) + JSON_HEDLEY_NON_NULL(2) token_type scan_literal(const char* literal_text, const std::size_t length, token_type return_type) { assert(current == literal_text[0]); for (std::size_t i = 1; i < length; ++i) { - if (NLOHMANN_JSON_HEDLEY_UNLIKELY(get() != literal_text[i])) + if (JSON_HEDLEY_UNLIKELY(get() != literal_text[i])) { error_message = "invalid literal"; return token_type::parse_error; @@ -8280,7 +8280,7 @@ scan_number_done: current = ia->get_character(); } - if (NLOHMANN_JSON_HEDLEY_LIKELY(current != std::char_traits::eof())) + if (JSON_HEDLEY_LIKELY(current != std::char_traits::eof())) { token_string.push_back(std::char_traits::to_char_type(current)); } @@ -8321,7 +8321,7 @@ scan_number_done: --position.chars_read_current_line; } - if (NLOHMANN_JSON_HEDLEY_LIKELY(current != std::char_traits::eof())) + if (JSON_HEDLEY_LIKELY(current != std::char_traits::eof())) { assert(not token_string.empty()); token_string.pop_back(); @@ -8400,7 +8400,7 @@ scan_number_done: } /// return syntax error message - NLOHMANN_JSON_HEDLEY_RETURNS_NON_NULL + JSON_HEDLEY_RETURNS_NON_NULL constexpr const char* get_error_message() const noexcept { return error_message; @@ -8689,7 +8689,7 @@ class parser } template - NLOHMANN_JSON_HEDLEY_NON_NULL(2) + JSON_HEDLEY_NON_NULL(2) bool sax_parse(SAX* sax, const bool strict = true) { (void)detail::is_sax_static_asserts {}; @@ -8709,7 +8709,7 @@ class parser private: template - NLOHMANN_JSON_HEDLEY_NON_NULL(2) + JSON_HEDLEY_NON_NULL(2) bool sax_parse_internal(SAX* sax) { // stack to remember the hierarchy of structured values we are parsing @@ -8727,7 +8727,7 @@ class parser { case token_type::begin_object: { - if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not sax->start_object(std::size_t(-1)))) + if (JSON_HEDLEY_UNLIKELY(not sax->start_object(std::size_t(-1)))) { return false; } @@ -8735,7 +8735,7 @@ class parser // closing } -> we are done if (get_token() == token_type::end_object) { - if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not sax->end_object())) + if (JSON_HEDLEY_UNLIKELY(not sax->end_object())) { return false; } @@ -8743,20 +8743,20 @@ class parser } // parse key - if (NLOHMANN_JSON_HEDLEY_UNLIKELY(last_token != token_type::value_string)) + if (JSON_HEDLEY_UNLIKELY(last_token != token_type::value_string)) { return sax->parse_error(m_lexer.get_position(), m_lexer.get_token_string(), parse_error::create(101, m_lexer.get_position(), exception_message(token_type::value_string, "object key"))); } - if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not sax->key(m_lexer.get_string()))) + if (JSON_HEDLEY_UNLIKELY(not sax->key(m_lexer.get_string()))) { return false; } // parse separator (:) - if (NLOHMANN_JSON_HEDLEY_UNLIKELY(get_token() != token_type::name_separator)) + if (JSON_HEDLEY_UNLIKELY(get_token() != token_type::name_separator)) { return sax->parse_error(m_lexer.get_position(), m_lexer.get_token_string(), @@ -8774,7 +8774,7 @@ class parser case token_type::begin_array: { - if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not sax->start_array(std::size_t(-1)))) + if (JSON_HEDLEY_UNLIKELY(not sax->start_array(std::size_t(-1)))) { return false; } @@ -8782,7 +8782,7 @@ class parser // closing ] -> we are done if (get_token() == token_type::end_array) { - if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not sax->end_array())) + if (JSON_HEDLEY_UNLIKELY(not sax->end_array())) { return false; } @@ -8800,14 +8800,14 @@ class parser { const auto res = m_lexer.get_number_float(); - if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not std::isfinite(res))) + if (JSON_HEDLEY_UNLIKELY(not std::isfinite(res))) { return sax->parse_error(m_lexer.get_position(), m_lexer.get_token_string(), out_of_range::create(406, "number overflow parsing '" + m_lexer.get_token_string() + "'")); } - if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not sax->number_float(res, m_lexer.get_string()))) + if (JSON_HEDLEY_UNLIKELY(not sax->number_float(res, m_lexer.get_string()))) { return false; } @@ -8817,7 +8817,7 @@ class parser case token_type::literal_false: { - if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not sax->boolean(false))) + if (JSON_HEDLEY_UNLIKELY(not sax->boolean(false))) { return false; } @@ -8826,7 +8826,7 @@ class parser case token_type::literal_null: { - if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not sax->null())) + if (JSON_HEDLEY_UNLIKELY(not sax->null())) { return false; } @@ -8835,7 +8835,7 @@ class parser case token_type::literal_true: { - if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not sax->boolean(true))) + if (JSON_HEDLEY_UNLIKELY(not sax->boolean(true))) { return false; } @@ -8844,7 +8844,7 @@ class parser case token_type::value_integer: { - if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not sax->number_integer(m_lexer.get_number_integer()))) + if (JSON_HEDLEY_UNLIKELY(not sax->number_integer(m_lexer.get_number_integer()))) { return false; } @@ -8853,7 +8853,7 @@ class parser case token_type::value_string: { - if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not sax->string(m_lexer.get_string()))) + if (JSON_HEDLEY_UNLIKELY(not sax->string(m_lexer.get_string()))) { return false; } @@ -8862,7 +8862,7 @@ class parser case token_type::value_unsigned: { - if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not sax->number_unsigned(m_lexer.get_number_unsigned()))) + if (JSON_HEDLEY_UNLIKELY(not sax->number_unsigned(m_lexer.get_number_unsigned()))) { return false; } @@ -8910,9 +8910,9 @@ class parser } // closing ] - if (NLOHMANN_JSON_HEDLEY_LIKELY(last_token == token_type::end_array)) + if (JSON_HEDLEY_LIKELY(last_token == token_type::end_array)) { - if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not sax->end_array())) + if (JSON_HEDLEY_UNLIKELY(not sax->end_array())) { return false; } @@ -8938,7 +8938,7 @@ class parser if (get_token() == token_type::value_separator) { // parse key - if (NLOHMANN_JSON_HEDLEY_UNLIKELY(get_token() != token_type::value_string)) + if (JSON_HEDLEY_UNLIKELY(get_token() != token_type::value_string)) { return sax->parse_error(m_lexer.get_position(), m_lexer.get_token_string(), @@ -8946,13 +8946,13 @@ class parser exception_message(token_type::value_string, "object key"))); } - if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not sax->key(m_lexer.get_string()))) + if (JSON_HEDLEY_UNLIKELY(not sax->key(m_lexer.get_string()))) { return false; } // parse separator (:) - if (NLOHMANN_JSON_HEDLEY_UNLIKELY(get_token() != token_type::name_separator)) + if (JSON_HEDLEY_UNLIKELY(get_token() != token_type::name_separator)) { return sax->parse_error(m_lexer.get_position(), m_lexer.get_token_string(), @@ -8966,9 +8966,9 @@ class parser } // closing } - if (NLOHMANN_JSON_HEDLEY_LIKELY(last_token == token_type::end_object)) + if (JSON_HEDLEY_LIKELY(last_token == token_type::end_object)) { - if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not sax->end_object())) + if (JSON_HEDLEY_UNLIKELY(not sax->end_object())) { return false; } @@ -9452,7 +9452,7 @@ class iter_impl default: { - if (NLOHMANN_JSON_HEDLEY_LIKELY(m_it.primitive_iterator.is_begin())) + if (JSON_HEDLEY_LIKELY(m_it.primitive_iterator.is_begin())) { return *m_object; } @@ -9486,7 +9486,7 @@ class iter_impl default: { - if (NLOHMANN_JSON_HEDLEY_LIKELY(m_it.primitive_iterator.is_begin())) + if (JSON_HEDLEY_LIKELY(m_it.primitive_iterator.is_begin())) { return m_object; } @@ -9589,7 +9589,7 @@ class iter_impl bool operator==(const iter_impl& other) const { // if objects are not the same, the comparison is undefined - if (NLOHMANN_JSON_HEDLEY_UNLIKELY(m_object != other.m_object)) + if (JSON_HEDLEY_UNLIKELY(m_object != other.m_object)) { JSON_THROW(invalid_iterator::create(212, "cannot compare iterators of different containers")); } @@ -9625,7 +9625,7 @@ class iter_impl bool operator<(const iter_impl& other) const { // if objects are not the same, the comparison is undefined - if (NLOHMANN_JSON_HEDLEY_UNLIKELY(m_object != other.m_object)) + if (JSON_HEDLEY_UNLIKELY(m_object != other.m_object)) { JSON_THROW(invalid_iterator::create(212, "cannot compare iterators of different containers")); } @@ -9785,7 +9785,7 @@ class iter_impl default: { - if (NLOHMANN_JSON_HEDLEY_LIKELY(m_it.primitive_iterator.get_value() == -n)) + if (JSON_HEDLEY_LIKELY(m_it.primitive_iterator.get_value() == -n)) { return *m_object; } @@ -9803,7 +9803,7 @@ class iter_impl { assert(m_object != nullptr); - if (NLOHMANN_JSON_HEDLEY_LIKELY(m_object->is_object())) + if (JSON_HEDLEY_LIKELY(m_object->is_object())) { return m_it.object_iterator->first; } @@ -10204,7 +10204,7 @@ class json_pointer */ void pop_back() { - if (NLOHMANN_JSON_HEDLEY_UNLIKELY(empty())) + if (JSON_HEDLEY_UNLIKELY(empty())) { JSON_THROW(detail::out_of_range::create(405, "JSON pointer has no parent")); } @@ -10228,7 +10228,7 @@ class json_pointer */ const std::string& back() { - if (NLOHMANN_JSON_HEDLEY_UNLIKELY(empty())) + if (JSON_HEDLEY_UNLIKELY(empty())) { JSON_THROW(detail::out_of_range::create(405, "JSON pointer has no parent")); } @@ -10292,7 +10292,7 @@ class json_pointer const int res = std::stoi(s, &processed_chars); // check if the string was completely read - if (NLOHMANN_JSON_HEDLEY_UNLIKELY(processed_chars != s.size())) + if (JSON_HEDLEY_UNLIKELY(processed_chars != s.size())) { JSON_THROW(detail::out_of_range::create(404, "unresolved reference token '" + s + "'")); } @@ -10302,7 +10302,7 @@ class json_pointer json_pointer top() const { - if (NLOHMANN_JSON_HEDLEY_UNLIKELY(empty())) + if (JSON_HEDLEY_UNLIKELY(empty())) { JSON_THROW(detail::out_of_range::create(405, "JSON pointer has no parent")); } @@ -10434,7 +10434,7 @@ class json_pointer case detail::value_t::array: { // error condition (cf. RFC 6901, Sect. 4) - if (NLOHMANN_JSON_HEDLEY_UNLIKELY(reference_token.size() > 1 and reference_token[0] == '0')) + if (JSON_HEDLEY_UNLIKELY(reference_token.size() > 1 and reference_token[0] == '0')) { JSON_THROW(detail::parse_error::create(106, 0, "array index '" + reference_token + @@ -10492,7 +10492,7 @@ class json_pointer case detail::value_t::array: { - if (NLOHMANN_JSON_HEDLEY_UNLIKELY(reference_token == "-")) + if (JSON_HEDLEY_UNLIKELY(reference_token == "-")) { // "-" always fails the range check JSON_THROW(detail::out_of_range::create(402, @@ -10501,7 +10501,7 @@ class json_pointer } // error condition (cf. RFC 6901, Sect. 4) - if (NLOHMANN_JSON_HEDLEY_UNLIKELY(reference_token.size() > 1 and reference_token[0] == '0')) + if (JSON_HEDLEY_UNLIKELY(reference_token.size() > 1 and reference_token[0] == '0')) { JSON_THROW(detail::parse_error::create(106, 0, "array index '" + reference_token + @@ -10557,7 +10557,7 @@ class json_pointer case detail::value_t::array: { - if (NLOHMANN_JSON_HEDLEY_UNLIKELY(reference_token == "-")) + if (JSON_HEDLEY_UNLIKELY(reference_token == "-")) { // "-" cannot be used for const access JSON_THROW(detail::out_of_range::create(402, @@ -10566,7 +10566,7 @@ class json_pointer } // error condition (cf. RFC 6901, Sect. 4) - if (NLOHMANN_JSON_HEDLEY_UNLIKELY(reference_token.size() > 1 and reference_token[0] == '0')) + if (JSON_HEDLEY_UNLIKELY(reference_token.size() > 1 and reference_token[0] == '0')) { JSON_THROW(detail::parse_error::create(106, 0, "array index '" + reference_token + @@ -10616,7 +10616,7 @@ class json_pointer case detail::value_t::array: { - if (NLOHMANN_JSON_HEDLEY_UNLIKELY(reference_token == "-")) + if (JSON_HEDLEY_UNLIKELY(reference_token == "-")) { // "-" always fails the range check JSON_THROW(detail::out_of_range::create(402, @@ -10625,7 +10625,7 @@ class json_pointer } // error condition (cf. RFC 6901, Sect. 4) - if (NLOHMANN_JSON_HEDLEY_UNLIKELY(reference_token.size() > 1 and reference_token[0] == '0')) + if (JSON_HEDLEY_UNLIKELY(reference_token.size() > 1 and reference_token[0] == '0')) { JSON_THROW(detail::parse_error::create(106, 0, "array index '" + reference_token + @@ -10672,7 +10672,7 @@ class json_pointer } // check if nonempty reference string begins with slash - if (NLOHMANN_JSON_HEDLEY_UNLIKELY(reference_string[0] != '/')) + if (JSON_HEDLEY_UNLIKELY(reference_string[0] != '/')) { JSON_THROW(detail::parse_error::create(107, 1, "JSON pointer must be empty or begin with '/' - was: '" + @@ -10707,9 +10707,9 @@ class json_pointer assert(reference_token[pos] == '~'); // ~ must be followed by 0 or 1 - if (NLOHMANN_JSON_HEDLEY_UNLIKELY(pos == reference_token.size() - 1 or - (reference_token[pos + 1] != '0' and - reference_token[pos + 1] != '1'))) + if (JSON_HEDLEY_UNLIKELY(pos == reference_token.size() - 1 or + (reference_token[pos + 1] != '0' and + reference_token[pos + 1] != '1'))) { JSON_THROW(detail::parse_error::create(108, 0, "escape character '~' must be followed with '0' or '1'")); } @@ -10834,7 +10834,7 @@ class json_pointer static BasicJsonType unflatten(const BasicJsonType& value) { - if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not value.is_object())) + if (JSON_HEDLEY_UNLIKELY(not value.is_object())) { JSON_THROW(detail::type_error::create(314, "only objects can be unflattened")); } @@ -10844,7 +10844,7 @@ class json_pointer // iterate the JSON object values for (const auto& element : *value.m_value.object) { - if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not element.second.is_primitive())) + if (JSON_HEDLEY_UNLIKELY(not element.second.is_primitive())) { JSON_THROW(detail::type_error::create(315, "values in object must be primitive")); } @@ -11034,7 +11034,7 @@ class output_vector_adapter : public output_adapter_protocol v.push_back(c); } - NLOHMANN_JSON_HEDLEY_NON_NULL(2) + JSON_HEDLEY_NON_NULL(2) void write_characters(const CharType* s, std::size_t length) override { std::copy(s, s + length, std::back_inserter(v)); @@ -11058,7 +11058,7 @@ class output_stream_adapter : public output_adapter_protocol stream.put(c); } - NLOHMANN_JSON_HEDLEY_NON_NULL(2) + JSON_HEDLEY_NON_NULL(2) void write_characters(const CharType* s, std::size_t length) override { stream.write(s, static_cast(length)); @@ -11082,7 +11082,7 @@ class output_string_adapter : public output_adapter_protocol str.push_back(c); } - NLOHMANN_JSON_HEDLEY_NON_NULL(2) + JSON_HEDLEY_NON_NULL(2) void write_characters(const CharType* s, std::size_t length) override { str.append(s, length); @@ -11821,7 +11821,7 @@ class binary_writer static std::size_t calc_bson_entry_header_size(const string_t& name) { const auto it = name.find(static_cast(0)); - if (NLOHMANN_JSON_HEDLEY_UNLIKELY(it != BasicJsonType::string_t::npos)) + if (JSON_HEDLEY_UNLIKELY(it != BasicJsonType::string_t::npos)) { JSON_THROW(out_of_range::create(409, "BSON key cannot contain code point U+0000 (at byte " + std::to_string(it) + ")")); @@ -13283,7 +13283,7 @@ v = buf * 10^decimal_exponent len is the length of the buffer (number of decimal digits) The buffer must be large enough, i.e. >= max_digits10. */ -NLOHMANN_JSON_HEDLEY_NON_NULL(1) +JSON_HEDLEY_NON_NULL(1) inline void grisu2(char* buf, int& len, int& decimal_exponent, diyfp m_minus, diyfp v, diyfp m_plus) { @@ -13343,7 +13343,7 @@ len is the length of the buffer (number of decimal digits) The buffer must be large enough, i.e. >= max_digits10. */ template -NLOHMANN_JSON_HEDLEY_NON_NULL(1) +JSON_HEDLEY_NON_NULL(1) void grisu2(char* buf, int& len, int& decimal_exponent, FloatType value) { static_assert(diyfp::kPrecision >= std::numeric_limits::digits + 3, @@ -13382,8 +13382,8 @@ void grisu2(char* buf, int& len, int& decimal_exponent, FloatType value) @return a pointer to the element following the exponent. @pre -1000 < e < 1000 */ -NLOHMANN_JSON_HEDLEY_NON_NULL(1) -NLOHMANN_JSON_HEDLEY_RETURNS_NON_NULL +JSON_HEDLEY_NON_NULL(1) +JSON_HEDLEY_RETURNS_NON_NULL inline char* append_exponent(char* buf, int e) { assert(e > -1000); @@ -13434,8 +13434,8 @@ notation. Otherwise it will be printed in exponential notation. @pre min_exp < 0 @pre max_exp > 0 */ -NLOHMANN_JSON_HEDLEY_NON_NULL(1) -NLOHMANN_JSON_HEDLEY_RETURNS_NON_NULL +JSON_HEDLEY_NON_NULL(1) +JSON_HEDLEY_RETURNS_NON_NULL inline char* format_buffer(char* buf, int len, int decimal_exponent, int min_exp, int max_exp) { @@ -13519,8 +13519,8 @@ format. Returns an iterator pointing past-the-end of the decimal representation. @note The result is NOT null-terminated. */ template -NLOHMANN_JSON_HEDLEY_NON_NULL(1, 2) -NLOHMANN_JSON_HEDLEY_RETURNS_NON_NULL +JSON_HEDLEY_NON_NULL(1, 2) +JSON_HEDLEY_RETURNS_NON_NULL char* to_chars(char* first, const char* last, FloatType value) { static_cast(last); // maybe unused - fix warning @@ -13670,7 +13670,7 @@ class serializer // variable to hold indentation for recursive calls const auto new_indent = current_indent + indent_step; - if (NLOHMANN_JSON_HEDLEY_UNLIKELY(indent_string.size() < new_indent)) + if (JSON_HEDLEY_UNLIKELY(indent_string.size() < new_indent)) { indent_string.resize(indent_string.size() * 2, ' '); } @@ -13743,7 +13743,7 @@ class serializer // variable to hold indentation for recursive calls const auto new_indent = current_indent + indent_step; - if (NLOHMANN_JSON_HEDLEY_UNLIKELY(indent_string.size() < new_indent)) + if (JSON_HEDLEY_UNLIKELY(indent_string.size() < new_indent)) { indent_string.resize(indent_string.size() * 2, ' '); } @@ -14058,7 +14058,7 @@ class serializer } // we finished processing the string - if (NLOHMANN_JSON_HEDLEY_LIKELY(state == UTF8_ACCEPT)) + if (JSON_HEDLEY_LIKELY(state == UTF8_ACCEPT)) { // write buffer if (bytes > 0) @@ -14651,7 +14651,7 @@ class basic_json @since 2.1.0 */ - NLOHMANN_JSON_HEDLEY_WARN_UNUSED_RESULT + JSON_HEDLEY_WARN_UNUSED_RESULT static basic_json meta() { basic_json result; @@ -15156,7 +15156,7 @@ class basic_json /// helper for exception-safe object creation template - NLOHMANN_JSON_HEDLEY_RETURNS_NON_NULL + JSON_HEDLEY_RETURNS_NON_NULL static T* create(Args&& ... args) { AllocatorType alloc; @@ -15283,7 +15283,7 @@ class basic_json default: { object = nullptr; // silence warning, see #821 - if (NLOHMANN_JSON_HEDLEY_UNLIKELY(t == value_t::null)) + if (JSON_HEDLEY_UNLIKELY(t == value_t::null)) { JSON_THROW(other_error::create(500, "961c151d2e87f2686a955a9be24d316f1362bf21 3.6.1")); // LCOV_EXCL_LINE } @@ -15760,7 +15760,7 @@ class basic_json } // if object is wanted but impossible, throw an exception - if (NLOHMANN_JSON_HEDLEY_UNLIKELY(manual_type == value_t::object and not is_an_object)) + if (JSON_HEDLEY_UNLIKELY(manual_type == value_t::object and not is_an_object)) { JSON_THROW(type_error::create(301, "cannot create object from initializer list")); } @@ -15827,7 +15827,7 @@ class basic_json @since version 1.0.0 */ - NLOHMANN_JSON_HEDLEY_WARN_UNUSED_RESULT + JSON_HEDLEY_WARN_UNUSED_RESULT static basic_json array(initializer_list_t init = {}) { return basic_json(init, false, value_t::array); @@ -15871,7 +15871,7 @@ class basic_json @since version 1.0.0 */ - NLOHMANN_JSON_HEDLEY_WARN_UNUSED_RESULT + JSON_HEDLEY_WARN_UNUSED_RESULT static basic_json object(initializer_list_t init = {}) { return basic_json(init, false, value_t::object); @@ -15970,7 +15970,7 @@ class basic_json assert(last.m_object != nullptr); // make sure iterator fits the current value - if (NLOHMANN_JSON_HEDLEY_UNLIKELY(first.m_object != last.m_object)) + if (JSON_HEDLEY_UNLIKELY(first.m_object != last.m_object)) { JSON_THROW(invalid_iterator::create(201, "iterators are not compatible")); } @@ -15987,8 +15987,8 @@ class basic_json case value_t::number_unsigned: case value_t::string: { - if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not first.m_it.primitive_iterator.is_begin() - or not last.m_it.primitive_iterator.is_end())) + if (JSON_HEDLEY_UNLIKELY(not first.m_it.primitive_iterator.is_begin() + or not last.m_it.primitive_iterator.is_end())) { JSON_THROW(invalid_iterator::create(204, "iterators out of range")); } @@ -16701,7 +16701,7 @@ class basic_json /// get a boolean (explicit) boolean_t get_impl(boolean_t* /*unused*/) const { - if (NLOHMANN_JSON_HEDLEY_LIKELY(is_boolean())) + if (JSON_HEDLEY_LIKELY(is_boolean())) { return m_value.boolean; } @@ -16810,7 +16810,7 @@ class basic_json // delegate the call to get_ptr<>() auto ptr = obj.template get_ptr::type>(); - if (NLOHMANN_JSON_HEDLEY_LIKELY(ptr != nullptr)) + if (JSON_HEDLEY_LIKELY(ptr != nullptr)) { return *ptr; } @@ -17261,7 +17261,7 @@ class basic_json reference at(size_type idx) { // at only works for arrays - if (NLOHMANN_JSON_HEDLEY_LIKELY(is_array())) + if (JSON_HEDLEY_LIKELY(is_array())) { JSON_TRY { @@ -17308,7 +17308,7 @@ class basic_json const_reference at(size_type idx) const { // at only works for arrays - if (NLOHMANN_JSON_HEDLEY_LIKELY(is_array())) + if (JSON_HEDLEY_LIKELY(is_array())) { JSON_TRY { @@ -17359,7 +17359,7 @@ class basic_json reference at(const typename object_t::key_type& key) { // at only works for objects - if (NLOHMANN_JSON_HEDLEY_LIKELY(is_object())) + if (JSON_HEDLEY_LIKELY(is_object())) { JSON_TRY { @@ -17410,7 +17410,7 @@ class basic_json const_reference at(const typename object_t::key_type& key) const { // at only works for objects - if (NLOHMANN_JSON_HEDLEY_LIKELY(is_object())) + if (JSON_HEDLEY_LIKELY(is_object())) { JSON_TRY { @@ -17464,7 +17464,7 @@ class basic_json } // operator[] only works for arrays - if (NLOHMANN_JSON_HEDLEY_LIKELY(is_array())) + if (JSON_HEDLEY_LIKELY(is_array())) { // fill up array with null values if given idx is outside range if (idx >= m_value.array->size()) @@ -17502,7 +17502,7 @@ class basic_json const_reference operator[](size_type idx) const { // const operator[] only works for arrays - if (NLOHMANN_JSON_HEDLEY_LIKELY(is_array())) + if (JSON_HEDLEY_LIKELY(is_array())) { return m_value.array->operator[](idx); } @@ -17548,7 +17548,7 @@ class basic_json } // operator[] only works for objects - if (NLOHMANN_JSON_HEDLEY_LIKELY(is_object())) + if (JSON_HEDLEY_LIKELY(is_object())) { return m_value.object->operator[](key); } @@ -17589,7 +17589,7 @@ class basic_json const_reference operator[](const typename object_t::key_type& key) const { // const operator[] only works for objects - if (NLOHMANN_JSON_HEDLEY_LIKELY(is_object())) + if (JSON_HEDLEY_LIKELY(is_object())) { assert(m_value.object->find(key) != m_value.object->end()); return m_value.object->find(key)->second; @@ -17626,7 +17626,7 @@ class basic_json @since version 1.1.0 */ template - NLOHMANN_JSON_HEDLEY_NON_NULL(2) + JSON_HEDLEY_NON_NULL(2) reference operator[](T* key) { // implicitly convert null to object @@ -17638,7 +17638,7 @@ class basic_json } // at only works for objects - if (NLOHMANN_JSON_HEDLEY_LIKELY(is_object())) + if (JSON_HEDLEY_LIKELY(is_object())) { return m_value.object->operator[](key); } @@ -17677,11 +17677,11 @@ class basic_json @since version 1.1.0 */ template - NLOHMANN_JSON_HEDLEY_NON_NULL(2) + JSON_HEDLEY_NON_NULL(2) const_reference operator[](T* key) const { // at only works for objects - if (NLOHMANN_JSON_HEDLEY_LIKELY(is_object())) + if (JSON_HEDLEY_LIKELY(is_object())) { assert(m_value.object->find(key) != m_value.object->end()); return m_value.object->find(key)->second; @@ -17745,7 +17745,7 @@ class basic_json ValueType value(const typename object_t::key_type& key, const ValueType& default_value) const { // at only works for objects - if (NLOHMANN_JSON_HEDLEY_LIKELY(is_object())) + if (JSON_HEDLEY_LIKELY(is_object())) { // if key is found, return value and given default value otherwise const auto it = find(key); @@ -17817,7 +17817,7 @@ class basic_json ValueType value(const json_pointer& ptr, const ValueType& default_value) const { // at only works for objects - if (NLOHMANN_JSON_HEDLEY_LIKELY(is_object())) + if (JSON_HEDLEY_LIKELY(is_object())) { // if pointer resolves a value, return it or use default value JSON_TRY @@ -17837,7 +17837,7 @@ class basic_json @brief overload for a default value of type const char* @copydoc basic_json::value(const json_pointer&, ValueType) const */ - NLOHMANN_JSON_HEDLEY_NON_NULL(3) + JSON_HEDLEY_NON_NULL(3) string_t value(const json_pointer& ptr, const char* default_value) const { return value(ptr, string_t(default_value)); @@ -17982,7 +17982,7 @@ class basic_json IteratorType erase(IteratorType pos) { // make sure iterator fits the current value - if (NLOHMANN_JSON_HEDLEY_UNLIKELY(this != pos.m_object)) + if (JSON_HEDLEY_UNLIKELY(this != pos.m_object)) { JSON_THROW(invalid_iterator::create(202, "iterator does not fit current value")); } @@ -17997,7 +17997,7 @@ class basic_json case value_t::number_unsigned: case value_t::string: { - if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not pos.m_it.primitive_iterator.is_begin())) + if (JSON_HEDLEY_UNLIKELY(not pos.m_it.primitive_iterator.is_begin())) { JSON_THROW(invalid_iterator::create(205, "iterator out of range")); } @@ -18087,7 +18087,7 @@ class basic_json IteratorType erase(IteratorType first, IteratorType last) { // make sure iterator fits the current value - if (NLOHMANN_JSON_HEDLEY_UNLIKELY(this != first.m_object or this != last.m_object)) + if (JSON_HEDLEY_UNLIKELY(this != first.m_object or this != last.m_object)) { JSON_THROW(invalid_iterator::create(203, "iterators do not fit current value")); } @@ -18102,8 +18102,8 @@ class basic_json case value_t::number_unsigned: case value_t::string: { - if (NLOHMANN_JSON_HEDLEY_LIKELY(not first.m_it.primitive_iterator.is_begin() - or not last.m_it.primitive_iterator.is_end())) + if (JSON_HEDLEY_LIKELY(not first.m_it.primitive_iterator.is_begin() + or not last.m_it.primitive_iterator.is_end())) { JSON_THROW(invalid_iterator::create(204, "iterators out of range")); } @@ -18174,7 +18174,7 @@ class basic_json size_type erase(const typename object_t::key_type& key) { // this erase only works for objects - if (NLOHMANN_JSON_HEDLEY_LIKELY(is_object())) + if (JSON_HEDLEY_LIKELY(is_object())) { return m_value.object->erase(key); } @@ -18209,9 +18209,9 @@ class basic_json void erase(const size_type idx) { // this erase only works for arrays - if (NLOHMANN_JSON_HEDLEY_LIKELY(is_array())) + if (JSON_HEDLEY_LIKELY(is_array())) { - if (NLOHMANN_JSON_HEDLEY_UNLIKELY(idx >= size())) + if (JSON_HEDLEY_UNLIKELY(idx >= size())) { JSON_THROW(out_of_range::create(401, "array index " + std::to_string(idx) + " is out of range")); } @@ -18687,7 +18687,7 @@ class basic_json future 4.0.0 of the library. Please use @ref items() instead; that is, replace `json::iterator_wrapper(j)` with `j.items()`. */ - NLOHMANN_JSON_HEDLEY_DEPRECATED(3.1.0) + JSON_HEDLEY_DEPRECATED(3.1.0) static iteration_proxy iterator_wrapper(reference ref) noexcept { return ref.items(); @@ -18696,7 +18696,7 @@ class basic_json /*! @copydoc iterator_wrapper(reference) */ - NLOHMANN_JSON_HEDLEY_DEPRECATED(3.1.0) + JSON_HEDLEY_DEPRECATED(3.1.0) static iteration_proxy iterator_wrapper(const_reference ref) noexcept { return ref.items(); @@ -19115,7 +19115,7 @@ class basic_json void push_back(basic_json&& val) { // push_back only works for null objects or arrays - if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not(is_null() or is_array()))) + if (JSON_HEDLEY_UNLIKELY(not(is_null() or is_array()))) { JSON_THROW(type_error::create(308, "cannot use push_back() with " + std::string(type_name()))); } @@ -19152,7 +19152,7 @@ class basic_json void push_back(const basic_json& val) { // push_back only works for null objects or arrays - if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not(is_null() or is_array()))) + if (JSON_HEDLEY_UNLIKELY(not(is_null() or is_array()))) { JSON_THROW(type_error::create(308, "cannot use push_back() with " + std::string(type_name()))); } @@ -19202,7 +19202,7 @@ class basic_json void push_back(const typename object_t::value_type& val) { // push_back only works for null objects or objects - if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not(is_null() or is_object()))) + if (JSON_HEDLEY_UNLIKELY(not(is_null() or is_object()))) { JSON_THROW(type_error::create(308, "cannot use push_back() with " + std::string(type_name()))); } @@ -19303,7 +19303,7 @@ class basic_json void emplace_back(Args&& ... args) { // emplace_back only works for null objects or arrays - if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not(is_null() or is_array()))) + if (JSON_HEDLEY_UNLIKELY(not(is_null() or is_array()))) { JSON_THROW(type_error::create(311, "cannot use emplace_back() with " + std::string(type_name()))); } @@ -19351,7 +19351,7 @@ class basic_json std::pair emplace(Args&& ... args) { // emplace only works for null objects or arrays - if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not(is_null() or is_object()))) + if (JSON_HEDLEY_UNLIKELY(not(is_null() or is_object()))) { JSON_THROW(type_error::create(311, "cannot use emplace() with " + std::string(type_name()))); } @@ -19419,10 +19419,10 @@ class basic_json iterator insert(const_iterator pos, const basic_json& val) { // insert only works for arrays - if (NLOHMANN_JSON_HEDLEY_LIKELY(is_array())) + if (JSON_HEDLEY_LIKELY(is_array())) { // check if iterator pos fits to this JSON value - if (NLOHMANN_JSON_HEDLEY_UNLIKELY(pos.m_object != this)) + if (JSON_HEDLEY_UNLIKELY(pos.m_object != this)) { JSON_THROW(invalid_iterator::create(202, "iterator does not fit current value")); } @@ -19470,10 +19470,10 @@ class basic_json iterator insert(const_iterator pos, size_type cnt, const basic_json& val) { // insert only works for arrays - if (NLOHMANN_JSON_HEDLEY_LIKELY(is_array())) + if (JSON_HEDLEY_LIKELY(is_array())) { // check if iterator pos fits to this JSON value - if (NLOHMANN_JSON_HEDLEY_UNLIKELY(pos.m_object != this)) + if (JSON_HEDLEY_UNLIKELY(pos.m_object != this)) { JSON_THROW(invalid_iterator::create(202, "iterator does not fit current value")); } @@ -19518,24 +19518,24 @@ class basic_json iterator insert(const_iterator pos, const_iterator first, const_iterator last) { // insert only works for arrays - if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not is_array())) + if (JSON_HEDLEY_UNLIKELY(not is_array())) { JSON_THROW(type_error::create(309, "cannot use insert() with " + std::string(type_name()))); } // check if iterator pos fits to this JSON value - if (NLOHMANN_JSON_HEDLEY_UNLIKELY(pos.m_object != this)) + if (JSON_HEDLEY_UNLIKELY(pos.m_object != this)) { JSON_THROW(invalid_iterator::create(202, "iterator does not fit current value")); } // check if range iterators belong to the same JSON object - if (NLOHMANN_JSON_HEDLEY_UNLIKELY(first.m_object != last.m_object)) + if (JSON_HEDLEY_UNLIKELY(first.m_object != last.m_object)) { JSON_THROW(invalid_iterator::create(210, "iterators do not fit")); } - if (NLOHMANN_JSON_HEDLEY_UNLIKELY(first.m_object == this)) + if (JSON_HEDLEY_UNLIKELY(first.m_object == this)) { JSON_THROW(invalid_iterator::create(211, "passed iterators may not belong to container")); } @@ -19571,13 +19571,13 @@ class basic_json iterator insert(const_iterator pos, initializer_list_t ilist) { // insert only works for arrays - if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not is_array())) + if (JSON_HEDLEY_UNLIKELY(not is_array())) { JSON_THROW(type_error::create(309, "cannot use insert() with " + std::string(type_name()))); } // check if iterator pos fits to this JSON value - if (NLOHMANN_JSON_HEDLEY_UNLIKELY(pos.m_object != this)) + if (JSON_HEDLEY_UNLIKELY(pos.m_object != this)) { JSON_THROW(invalid_iterator::create(202, "iterator does not fit current value")); } @@ -19612,19 +19612,19 @@ class basic_json void insert(const_iterator first, const_iterator last) { // insert only works for objects - if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not is_object())) + if (JSON_HEDLEY_UNLIKELY(not is_object())) { JSON_THROW(type_error::create(309, "cannot use insert() with " + std::string(type_name()))); } // check if range iterators belong to the same JSON object - if (NLOHMANN_JSON_HEDLEY_UNLIKELY(first.m_object != last.m_object)) + if (JSON_HEDLEY_UNLIKELY(first.m_object != last.m_object)) { JSON_THROW(invalid_iterator::create(210, "iterators do not fit")); } // passed iterators must belong to objects - if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not first.m_object->is_object())) + if (JSON_HEDLEY_UNLIKELY(not first.m_object->is_object())) { JSON_THROW(invalid_iterator::create(202, "iterators first and last must point to objects")); } @@ -19661,11 +19661,11 @@ class basic_json assert_invariant(); } - if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not is_object())) + if (JSON_HEDLEY_UNLIKELY(not is_object())) { JSON_THROW(type_error::create(312, "cannot use update() with " + std::string(type_name()))); } - if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not j.is_object())) + if (JSON_HEDLEY_UNLIKELY(not j.is_object())) { JSON_THROW(type_error::create(312, "cannot use update() with " + std::string(j.type_name()))); } @@ -19712,20 +19712,20 @@ class basic_json assert_invariant(); } - if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not is_object())) + if (JSON_HEDLEY_UNLIKELY(not is_object())) { JSON_THROW(type_error::create(312, "cannot use update() with " + std::string(type_name()))); } // check if range iterators belong to the same JSON object - if (NLOHMANN_JSON_HEDLEY_UNLIKELY(first.m_object != last.m_object)) + if (JSON_HEDLEY_UNLIKELY(first.m_object != last.m_object)) { JSON_THROW(invalid_iterator::create(210, "iterators do not fit")); } // passed iterators must belong to objects - if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not first.m_object->is_object() - or not last.m_object->is_object())) + if (JSON_HEDLEY_UNLIKELY(not first.m_object->is_object() + or not last.m_object->is_object())) { JSON_THROW(invalid_iterator::create(202, "iterators first and last must point to objects")); } @@ -19788,7 +19788,7 @@ class basic_json void swap(array_t& other) { // swap only works for arrays - if (NLOHMANN_JSON_HEDLEY_LIKELY(is_array())) + if (JSON_HEDLEY_LIKELY(is_array())) { std::swap(*(m_value.array), other); } @@ -19821,7 +19821,7 @@ class basic_json void swap(object_t& other) { // swap only works for objects - if (NLOHMANN_JSON_HEDLEY_LIKELY(is_object())) + if (JSON_HEDLEY_LIKELY(is_object())) { std::swap(*(m_value.object), other); } @@ -19854,7 +19854,7 @@ class basic_json void swap(string_t& other) { // swap only works for strings - if (NLOHMANN_JSON_HEDLEY_LIKELY(is_string())) + if (JSON_HEDLEY_LIKELY(is_string())) { std::swap(*(m_value.string), other); } @@ -20364,7 +20364,7 @@ class basic_json instead; that is, replace calls like `j >> o;` with `o << j;`. @since version 1.0.0; deprecated since version 3.0.0 */ - NLOHMANN_JSON_HEDLEY_DEPRECATED(3.0.0) + JSON_HEDLEY_DEPRECATED(3.0.0) friend std::ostream& operator>>(const basic_json& j, std::ostream& o) { return o << j; @@ -20443,7 +20443,7 @@ class basic_json @since version 2.0.3 (contiguous containers) */ - NLOHMANN_JSON_HEDLEY_WARN_UNUSED_RESULT + JSON_HEDLEY_WARN_UNUSED_RESULT static basic_json parse(detail::input_adapter&& i, const parser_callback_t cb = nullptr, const bool allow_exceptions = true) @@ -20512,7 +20512,7 @@ class basic_json @since version 3.2.0 */ template - NLOHMANN_JSON_HEDLEY_NON_NULL(2) + JSON_HEDLEY_NON_NULL(2) static bool sax_parse(detail::input_adapter&& i, SAX* sax, input_format_t format = input_format_t::json, const bool strict = true) @@ -20598,7 +20598,7 @@ class basic_json std::is_base_of< std::random_access_iterator_tag, typename std::iterator_traits::iterator_category>::value, int>::type = 0> - NLOHMANN_JSON_HEDLEY_NON_NULL(3) + JSON_HEDLEY_NON_NULL(3) static bool sax_parse(IteratorType first, IteratorType last, SAX* sax) { return parser(detail::input_adapter(first, last)).sax_parse(sax); @@ -20612,7 +20612,7 @@ class basic_json instead; that is, replace calls like `j << i;` with `i >> j;`. @since version 1.0.0; deprecated since version 3.0.0 */ - NLOHMANN_JSON_HEDLEY_DEPRECATED(3.0.0) + JSON_HEDLEY_DEPRECATED(3.0.0) friend std::istream& operator<<(basic_json& j, std::istream& i) { return operator>>(i, j); @@ -20685,7 +20685,7 @@ class basic_json @since version 1.0.0, public since 2.1.0, `const char*` and `noexcept` since 3.0.0 */ - NLOHMANN_JSON_HEDLEY_RETURNS_NON_NULL + JSON_HEDLEY_RETURNS_NON_NULL const char* type_name() const noexcept { { @@ -21215,7 +21215,7 @@ class basic_json @a strict parameter since 3.0.0; added @a allow_exceptions parameter since 3.2.0 */ - NLOHMANN_JSON_HEDLEY_WARN_UNUSED_RESULT + JSON_HEDLEY_WARN_UNUSED_RESULT static basic_json from_cbor(detail::input_adapter&& i, const bool strict = true, const bool allow_exceptions = true) @@ -21231,7 +21231,7 @@ class basic_json */ template::value, int> = 0> - NLOHMANN_JSON_HEDLEY_WARN_UNUSED_RESULT + JSON_HEDLEY_WARN_UNUSED_RESULT static basic_json from_cbor(A1 && a1, A2 && a2, const bool strict = true, const bool allow_exceptions = true) @@ -21324,7 +21324,7 @@ class basic_json @a strict parameter since 3.0.0; added @a allow_exceptions parameter since 3.2.0 */ - NLOHMANN_JSON_HEDLEY_WARN_UNUSED_RESULT + JSON_HEDLEY_WARN_UNUSED_RESULT static basic_json from_msgpack(detail::input_adapter&& i, const bool strict = true, const bool allow_exceptions = true) @@ -21340,7 +21340,7 @@ class basic_json */ template::value, int> = 0> - NLOHMANN_JSON_HEDLEY_WARN_UNUSED_RESULT + JSON_HEDLEY_WARN_UNUSED_RESULT static basic_json from_msgpack(A1 && a1, A2 && a2, const bool strict = true, const bool allow_exceptions = true) @@ -21412,7 +21412,7 @@ class basic_json @since version 3.1.0; added @a allow_exceptions parameter since 3.2.0 */ - NLOHMANN_JSON_HEDLEY_WARN_UNUSED_RESULT + JSON_HEDLEY_WARN_UNUSED_RESULT static basic_json from_ubjson(detail::input_adapter&& i, const bool strict = true, const bool allow_exceptions = true) @@ -21428,7 +21428,7 @@ class basic_json */ template::value, int> = 0> - NLOHMANN_JSON_HEDLEY_WARN_UNUSED_RESULT + JSON_HEDLEY_WARN_UNUSED_RESULT static basic_json from_ubjson(A1 && a1, A2 && a2, const bool strict = true, const bool allow_exceptions = true) @@ -21499,7 +21499,7 @@ class basic_json @sa @ref from_ubjson(detail::input_adapter&&, const bool, const bool) for the related UBJSON format */ - NLOHMANN_JSON_HEDLEY_WARN_UNUSED_RESULT + JSON_HEDLEY_WARN_UNUSED_RESULT static basic_json from_bson(detail::input_adapter&& i, const bool strict = true, const bool allow_exceptions = true) @@ -21515,7 +21515,7 @@ class basic_json */ template::value, int> = 0> - NLOHMANN_JSON_HEDLEY_WARN_UNUSED_RESULT + JSON_HEDLEY_WARN_UNUSED_RESULT static basic_json from_bson(A1 && a1, A2 && a2, const bool strict = true, const bool allow_exceptions = true) @@ -21889,7 +21889,7 @@ class basic_json else { const auto idx = json_pointer::array_index(last_path); - if (NLOHMANN_JSON_HEDLEY_UNLIKELY(static_cast(idx) > parent.size())) + if (JSON_HEDLEY_UNLIKELY(static_cast(idx) > parent.size())) { // avoid undefined behavior JSON_THROW(out_of_range::create(401, "array index " + std::to_string(idx) + " is out of range")); @@ -21920,7 +21920,7 @@ class basic_json { // perform range check auto it = parent.find(last_path); - if (NLOHMANN_JSON_HEDLEY_LIKELY(it != parent.end())) + if (JSON_HEDLEY_LIKELY(it != parent.end())) { parent.erase(it); } @@ -21937,7 +21937,7 @@ class basic_json }; // type check: top level value must be an array - if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not json_patch.is_array())) + if (JSON_HEDLEY_UNLIKELY(not json_patch.is_array())) { JSON_THROW(parse_error::create(104, 0, "JSON patch must be an array of objects")); } @@ -21957,13 +21957,13 @@ class basic_json const auto error_msg = (op == "op") ? "operation" : "operation '" + op + "'"; // check if desired value is present - if (NLOHMANN_JSON_HEDLEY_UNLIKELY(it == val.m_value.object->end())) + if (JSON_HEDLEY_UNLIKELY(it == val.m_value.object->end())) { JSON_THROW(parse_error::create(105, 0, error_msg + " must have member '" + member + "'")); } // check if result is of type string - if (NLOHMANN_JSON_HEDLEY_UNLIKELY(string_type and not it->second.is_string())) + if (JSON_HEDLEY_UNLIKELY(string_type and not it->second.is_string())) { JSON_THROW(parse_error::create(105, 0, error_msg + " must have string member '" + member + "'")); } @@ -21973,7 +21973,7 @@ class basic_json }; // type check: every element of the array must be an object - if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not val.is_object())) + if (JSON_HEDLEY_UNLIKELY(not val.is_object())) { JSON_THROW(parse_error::create(104, 0, "JSON patch must be an array of objects")); } @@ -22051,7 +22051,7 @@ class basic_json } // throw an exception if test fails - if (NLOHMANN_JSON_HEDLEY_UNLIKELY(not success)) + if (JSON_HEDLEY_UNLIKELY(not success)) { JSON_THROW(other_error::create(501, "unsuccessful: " + val.dump())); } @@ -22104,7 +22104,7 @@ class basic_json @since version 2.0.0 */ - NLOHMANN_JSON_HEDLEY_WARN_UNUSED_RESULT + JSON_HEDLEY_WARN_UNUSED_RESULT static basic_json diff(const basic_json& source, const basic_json& target, const std::string& path = "") { @@ -22396,7 +22396,7 @@ if no parse error occurred. @since version 1.0.0 */ -NLOHMANN_JSON_HEDLEY_NON_NULL(1) +JSON_HEDLEY_NON_NULL(1) inline nlohmann::json operator "" _json(const char* s, std::size_t n) { return nlohmann::json::parse(s, s + n); @@ -22415,7 +22415,7 @@ object if no parse error occurred. @since version 2.0.0 */ -NLOHMANN_JSON_HEDLEY_NON_NULL(1) +JSON_HEDLEY_NON_NULL(1) inline nlohmann::json::json_pointer operator "" _json_pointer(const char* s, std::size_t n) { return nlohmann::json::json_pointer(std::string(s, n)); @@ -22443,127 +22443,127 @@ inline nlohmann::json::json_pointer operator "" _json_pointer(const char* s, std #undef NLOHMANN_BASIC_JSON_TPL // #include -#undef NLOHMANN_JSON_HEDLEY_ALWAYS_INLINE -#undef NLOHMANN_JSON_HEDLEY_ARM_VERSION -#undef NLOHMANN_JSON_HEDLEY_ARM_VERSION_CHECK -#undef NLOHMANN_JSON_HEDLEY_ARRAY_PARAM -#undef NLOHMANN_JSON_HEDLEY_ASSUME -#undef NLOHMANN_JSON_HEDLEY_BEGIN_C_DECLS -#undef NLOHMANN_JSON_HEDLEY_CLANG_HAS_ATTRIBUTE -#undef NLOHMANN_JSON_HEDLEY_CLANG_HAS_BUILTIN -#undef NLOHMANN_JSON_HEDLEY_CLANG_HAS_CPP_ATTRIBUTE -#undef NLOHMANN_JSON_HEDLEY_CLANG_HAS_DECLSPEC_DECLSPEC_ATTRIBUTE -#undef NLOHMANN_JSON_HEDLEY_CLANG_HAS_EXTENSION -#undef NLOHMANN_JSON_HEDLEY_CLANG_HAS_FEATURE -#undef NLOHMANN_JSON_HEDLEY_CLANG_HAS_WARNING -#undef NLOHMANN_JSON_HEDLEY_COMPCERT_VERSION -#undef NLOHMANN_JSON_HEDLEY_COMPCERT_VERSION_CHECK -#undef NLOHMANN_JSON_HEDLEY_CONCAT -#undef NLOHMANN_JSON_HEDLEY_CONCAT_EX -#undef NLOHMANN_JSON_HEDLEY_CONST -#undef NLOHMANN_JSON_HEDLEY_CONSTEXPR -#undef NLOHMANN_JSON_HEDLEY_CONST_CAST -#undef NLOHMANN_JSON_HEDLEY_CPP_CAST -#undef NLOHMANN_JSON_HEDLEY_CRAY_VERSION -#undef NLOHMANN_JSON_HEDLEY_CRAY_VERSION_CHECK -#undef NLOHMANN_JSON_HEDLEY_C_DECL -#undef NLOHMANN_JSON_HEDLEY_DEPRECATED -#undef NLOHMANN_JSON_HEDLEY_DEPRECATED_FOR -#undef NLOHMANN_JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL -#undef NLOHMANN_JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED -#undef NLOHMANN_JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS -#undef NLOHMANN_JSON_HEDLEY_DIAGNOSTIC_POP -#undef NLOHMANN_JSON_HEDLEY_DIAGNOSTIC_PUSH -#undef NLOHMANN_JSON_HEDLEY_DMC_VERSION -#undef NLOHMANN_JSON_HEDLEY_DMC_VERSION_CHECK -#undef NLOHMANN_JSON_HEDLEY_EMSCRIPTEN_VERSION -#undef NLOHMANN_JSON_HEDLEY_EMSCRIPTEN_VERSION_CHECK -#undef NLOHMANN_JSON_HEDLEY_END_C_DECLS -#undef NLOHMANN_JSON_HEDLEY_FALL_THROUGH -#undef NLOHMANN_JSON_HEDLEY_FLAGS -#undef NLOHMANN_JSON_HEDLEY_FLAGS_CAST -#undef NLOHMANN_JSON_HEDLEY_GCC_HAS_ATTRIBUTE -#undef NLOHMANN_JSON_HEDLEY_GCC_HAS_BUILTIN -#undef NLOHMANN_JSON_HEDLEY_GCC_HAS_CPP_ATTRIBUTE -#undef NLOHMANN_JSON_HEDLEY_GCC_HAS_DECLSPEC_ATTRIBUTE -#undef NLOHMANN_JSON_HEDLEY_GCC_HAS_EXTENSION -#undef NLOHMANN_JSON_HEDLEY_GCC_HAS_FEATURE -#undef NLOHMANN_JSON_HEDLEY_GCC_HAS_WARNING -#undef NLOHMANN_JSON_HEDLEY_GCC_NOT_CLANG_VERSION_CHECK -#undef NLOHMANN_JSON_HEDLEY_GCC_VERSION -#undef NLOHMANN_JSON_HEDLEY_GCC_VERSION_CHECK -#undef NLOHMANN_JSON_HEDLEY_GNUC_HAS_ATTRIBUTE -#undef NLOHMANN_JSON_HEDLEY_GNUC_HAS_BUILTIN -#undef NLOHMANN_JSON_HEDLEY_GNUC_HAS_CPP_ATTRIBUTE -#undef NLOHMANN_JSON_HEDLEY_GNUC_HAS_DECLSPEC_ATTRIBUTE -#undef NLOHMANN_JSON_HEDLEY_GNUC_HAS_EXTENSION -#undef NLOHMANN_JSON_HEDLEY_GNUC_HAS_FEATURE -#undef NLOHMANN_JSON_HEDLEY_GNUC_HAS_WARNING -#undef NLOHMANN_JSON_HEDLEY_GNUC_VERSION -#undef NLOHMANN_JSON_HEDLEY_GNUC_VERSION_CHECK -#undef NLOHMANN_JSON_HEDLEY_HAS_ATTRIBUTE -#undef NLOHMANN_JSON_HEDLEY_HAS_BUILTIN -#undef NLOHMANN_JSON_HEDLEY_HAS_CPP_ATTRIBUTE -#undef NLOHMANN_JSON_HEDLEY_HAS_DECLSPEC_ATTRIBUTE -#undef NLOHMANN_JSON_HEDLEY_HAS_EXTENSION -#undef NLOHMANN_JSON_HEDLEY_HAS_FEATURE -#undef NLOHMANN_JSON_HEDLEY_HAS_WARNING -#undef NLOHMANN_JSON_HEDLEY_IAR_VERSION -#undef NLOHMANN_JSON_HEDLEY_IAR_VERSION_CHECK -#undef NLOHMANN_JSON_HEDLEY_IBM_VERSION -#undef NLOHMANN_JSON_HEDLEY_IBM_VERSION_CHECK -#undef NLOHMANN_JSON_HEDLEY_IMPORT -#undef NLOHMANN_JSON_HEDLEY_INLINE -#undef NLOHMANN_JSON_HEDLEY_INTEL_VERSION -#undef NLOHMANN_JSON_HEDLEY_INTEL_VERSION_CHECK -#undef NLOHMANN_JSON_HEDLEY_IS_CONSTANT -#undef NLOHMANN_JSON_HEDLEY_LIKELY -#undef NLOHMANN_JSON_HEDLEY_MALLOC -#undef NLOHMANN_JSON_HEDLEY_MESSAGE -#undef NLOHMANN_JSON_HEDLEY_MSVC_VERSION -#undef NLOHMANN_JSON_HEDLEY_MSVC_VERSION_CHECK -#undef NLOHMANN_JSON_HEDLEY_NEVER_INLINE -#undef NLOHMANN_JSON_HEDLEY_NON_NULL -#undef NLOHMANN_JSON_HEDLEY_NO_RETURN -#undef NLOHMANN_JSON_HEDLEY_NO_THROW -#undef NLOHMANN_JSON_HEDLEY_PELLES_VERSION -#undef NLOHMANN_JSON_HEDLEY_PELLES_VERSION_CHECK -#undef NLOHMANN_JSON_HEDLEY_PGI_VERSION -#undef NLOHMANN_JSON_HEDLEY_PGI_VERSION_CHECK -#undef NLOHMANN_JSON_HEDLEY_PREDICT -#undef NLOHMANN_JSON_HEDLEY_PRINTF_FORMAT -#undef NLOHMANN_JSON_HEDLEY_PRIVATE -#undef NLOHMANN_JSON_HEDLEY_PUBLIC -#undef NLOHMANN_JSON_HEDLEY_PURE -#undef NLOHMANN_JSON_HEDLEY_REINTERPRET_CAST -#undef NLOHMANN_JSON_HEDLEY_REQUIRE -#undef NLOHMANN_JSON_HEDLEY_REQUIRE_CONSTEXPR -#undef NLOHMANN_JSON_HEDLEY_REQUIRE_MSG -#undef NLOHMANN_JSON_HEDLEY_RESTRICT -#undef NLOHMANN_JSON_HEDLEY_RETURNS_NON_NULL -#undef NLOHMANN_JSON_HEDLEY_SENTINEL -#undef NLOHMANN_JSON_HEDLEY_STATIC_ASSERT -#undef NLOHMANN_JSON_HEDLEY_STATIC_CAST -#undef NLOHMANN_JSON_HEDLEY_STRINGIFY -#undef NLOHMANN_JSON_HEDLEY_STRINGIFY_EX -#undef NLOHMANN_JSON_HEDLEY_SUNPRO_VERSION -#undef NLOHMANN_JSON_HEDLEY_SUNPRO_VERSION_CHECK -#undef NLOHMANN_JSON_HEDLEY_TINYC_VERSION -#undef NLOHMANN_JSON_HEDLEY_TINYC_VERSION_CHECK -#undef NLOHMANN_JSON_HEDLEY_TI_VERSION -#undef NLOHMANN_JSON_HEDLEY_TI_VERSION_CHECK -#undef NLOHMANN_JSON_HEDLEY_UNAVAILABLE -#undef NLOHMANN_JSON_HEDLEY_UNLIKELY -#undef NLOHMANN_JSON_HEDLEY_UNPREDICTABLE -#undef NLOHMANN_JSON_HEDLEY_UNREACHABLE -#undef NLOHMANN_JSON_HEDLEY_UNREACHABLE_RETURN -#undef NLOHMANN_JSON_HEDLEY_VERSION -#undef NLOHMANN_JSON_HEDLEY_VERSION_DECODE_MAJOR -#undef NLOHMANN_JSON_HEDLEY_VERSION_DECODE_MINOR -#undef NLOHMANN_JSON_HEDLEY_VERSION_DECODE_REVISION -#undef NLOHMANN_JSON_HEDLEY_VERSION_ENCODE -#undef NLOHMANN_JSON_HEDLEY_WARNING -#undef NLOHMANN_JSON_HEDLEY_WARN_UNUSED_RESULT +#undef JSON_HEDLEY_ALWAYS_INLINE +#undef JSON_HEDLEY_ARM_VERSION +#undef JSON_HEDLEY_ARM_VERSION_CHECK +#undef JSON_HEDLEY_ARRAY_PARAM +#undef JSON_HEDLEY_ASSUME +#undef JSON_HEDLEY_BEGIN_C_DECLS +#undef JSON_HEDLEY_CLANG_HAS_ATTRIBUTE +#undef JSON_HEDLEY_CLANG_HAS_BUILTIN +#undef JSON_HEDLEY_CLANG_HAS_CPP_ATTRIBUTE +#undef JSON_HEDLEY_CLANG_HAS_DECLSPEC_DECLSPEC_ATTRIBUTE +#undef JSON_HEDLEY_CLANG_HAS_EXTENSION +#undef JSON_HEDLEY_CLANG_HAS_FEATURE +#undef JSON_HEDLEY_CLANG_HAS_WARNING +#undef JSON_HEDLEY_COMPCERT_VERSION +#undef JSON_HEDLEY_COMPCERT_VERSION_CHECK +#undef JSON_HEDLEY_CONCAT +#undef JSON_HEDLEY_CONCAT_EX +#undef JSON_HEDLEY_CONST +#undef JSON_HEDLEY_CONSTEXPR +#undef JSON_HEDLEY_CONST_CAST +#undef JSON_HEDLEY_CPP_CAST +#undef JSON_HEDLEY_CRAY_VERSION +#undef JSON_HEDLEY_CRAY_VERSION_CHECK +#undef JSON_HEDLEY_C_DECL +#undef JSON_HEDLEY_DEPRECATED +#undef JSON_HEDLEY_DEPRECATED_FOR +#undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL +#undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED +#undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS +#undef JSON_HEDLEY_DIAGNOSTIC_POP +#undef JSON_HEDLEY_DIAGNOSTIC_PUSH +#undef JSON_HEDLEY_DMC_VERSION +#undef JSON_HEDLEY_DMC_VERSION_CHECK +#undef JSON_HEDLEY_EMSCRIPTEN_VERSION +#undef JSON_HEDLEY_EMSCRIPTEN_VERSION_CHECK +#undef JSON_HEDLEY_END_C_DECLS +#undef JSON_HEDLEY_FALL_THROUGH +#undef JSON_HEDLEY_FLAGS +#undef JSON_HEDLEY_FLAGS_CAST +#undef JSON_HEDLEY_GCC_HAS_ATTRIBUTE +#undef JSON_HEDLEY_GCC_HAS_BUILTIN +#undef JSON_HEDLEY_GCC_HAS_CPP_ATTRIBUTE +#undef JSON_HEDLEY_GCC_HAS_DECLSPEC_ATTRIBUTE +#undef JSON_HEDLEY_GCC_HAS_EXTENSION +#undef JSON_HEDLEY_GCC_HAS_FEATURE +#undef JSON_HEDLEY_GCC_HAS_WARNING +#undef JSON_HEDLEY_GCC_NOT_CLANG_VERSION_CHECK +#undef JSON_HEDLEY_GCC_VERSION +#undef JSON_HEDLEY_GCC_VERSION_CHECK +#undef JSON_HEDLEY_GNUC_HAS_ATTRIBUTE +#undef JSON_HEDLEY_GNUC_HAS_BUILTIN +#undef JSON_HEDLEY_GNUC_HAS_CPP_ATTRIBUTE +#undef JSON_HEDLEY_GNUC_HAS_DECLSPEC_ATTRIBUTE +#undef JSON_HEDLEY_GNUC_HAS_EXTENSION +#undef JSON_HEDLEY_GNUC_HAS_FEATURE +#undef JSON_HEDLEY_GNUC_HAS_WARNING +#undef JSON_HEDLEY_GNUC_VERSION +#undef JSON_HEDLEY_GNUC_VERSION_CHECK +#undef JSON_HEDLEY_HAS_ATTRIBUTE +#undef JSON_HEDLEY_HAS_BUILTIN +#undef JSON_HEDLEY_HAS_CPP_ATTRIBUTE +#undef JSON_HEDLEY_HAS_DECLSPEC_ATTRIBUTE +#undef JSON_HEDLEY_HAS_EXTENSION +#undef JSON_HEDLEY_HAS_FEATURE +#undef JSON_HEDLEY_HAS_WARNING +#undef JSON_HEDLEY_IAR_VERSION +#undef JSON_HEDLEY_IAR_VERSION_CHECK +#undef JSON_HEDLEY_IBM_VERSION +#undef JSON_HEDLEY_IBM_VERSION_CHECK +#undef JSON_HEDLEY_IMPORT +#undef JSON_HEDLEY_INLINE +#undef JSON_HEDLEY_INTEL_VERSION +#undef JSON_HEDLEY_INTEL_VERSION_CHECK +#undef JSON_HEDLEY_IS_CONSTANT +#undef JSON_HEDLEY_LIKELY +#undef JSON_HEDLEY_MALLOC +#undef JSON_HEDLEY_MESSAGE +#undef JSON_HEDLEY_MSVC_VERSION +#undef JSON_HEDLEY_MSVC_VERSION_CHECK +#undef JSON_HEDLEY_NEVER_INLINE +#undef JSON_HEDLEY_NON_NULL +#undef JSON_HEDLEY_NO_RETURN +#undef JSON_HEDLEY_NO_THROW +#undef JSON_HEDLEY_PELLES_VERSION +#undef JSON_HEDLEY_PELLES_VERSION_CHECK +#undef JSON_HEDLEY_PGI_VERSION +#undef JSON_HEDLEY_PGI_VERSION_CHECK +#undef JSON_HEDLEY_PREDICT +#undef JSON_HEDLEY_PRINTF_FORMAT +#undef JSON_HEDLEY_PRIVATE +#undef JSON_HEDLEY_PUBLIC +#undef JSON_HEDLEY_PURE +#undef JSON_HEDLEY_REINTERPRET_CAST +#undef JSON_HEDLEY_REQUIRE +#undef JSON_HEDLEY_REQUIRE_CONSTEXPR +#undef JSON_HEDLEY_REQUIRE_MSG +#undef JSON_HEDLEY_RESTRICT +#undef JSON_HEDLEY_RETURNS_NON_NULL +#undef JSON_HEDLEY_SENTINEL +#undef JSON_HEDLEY_STATIC_ASSERT +#undef JSON_HEDLEY_STATIC_CAST +#undef JSON_HEDLEY_STRINGIFY +#undef JSON_HEDLEY_STRINGIFY_EX +#undef JSON_HEDLEY_SUNPRO_VERSION +#undef JSON_HEDLEY_SUNPRO_VERSION_CHECK +#undef JSON_HEDLEY_TINYC_VERSION +#undef JSON_HEDLEY_TINYC_VERSION_CHECK +#undef JSON_HEDLEY_TI_VERSION +#undef JSON_HEDLEY_TI_VERSION_CHECK +#undef JSON_HEDLEY_UNAVAILABLE +#undef JSON_HEDLEY_UNLIKELY +#undef JSON_HEDLEY_UNPREDICTABLE +#undef JSON_HEDLEY_UNREACHABLE +#undef JSON_HEDLEY_UNREACHABLE_RETURN +#undef JSON_HEDLEY_VERSION +#undef JSON_HEDLEY_VERSION_DECODE_MAJOR +#undef JSON_HEDLEY_VERSION_DECODE_MINOR +#undef JSON_HEDLEY_VERSION_DECODE_REVISION +#undef JSON_HEDLEY_VERSION_ENCODE +#undef JSON_HEDLEY_WARNING +#undef JSON_HEDLEY_WARN_UNUSED_RESULT From 346e9813c524fe79b3819d6cf8dcbd92be785452 Mon Sep 17 00:00:00 2001 From: Niels Lohmann Date: Tue, 2 Jul 2019 20:25:51 +0200 Subject: [PATCH 091/106] :construction: add more annotations --- README.md | 3 +++ include/nlohmann/detail/input/lexer.hpp | 5 +++++ single_include/nlohmann/json.hpp | 5 +++++ 3 files changed, 13 insertions(+) diff --git a/README.md b/README.md index 9ebd0789..071770c8 100644 --- a/README.md +++ b/README.md @@ -1076,6 +1076,8 @@ The class contains the UTF-8 Decoder from Bjoern Hoehrmann which is licensed und The class contains a slightly modified version of the Grisu2 algorithm from Florian Loitsch which is licensed under the [MIT License](http://opensource.org/licenses/MIT) (see above). Copyright © 2009 [Florian Loitsch](http://florian.loitsch.com/) +The class contains a copy of [Hedley](https://nemequ.github.io/hedley/) from Evan Nemerson which is licensed as [CC0-1.0](http://creativecommons.org/publicdomain/zero/1.0/). + ## Contact If you have questions regarding the library, I would like to invite you to [open an issue at GitHub](https://github.com/nlohmann/json/issues/new/choose). Please describe your request, problem, or question as detailed as possible, and also mention the version of the library you are using as well as the version of your compiler and operating system. Opening an issue at GitHub allows other users and contributors to this library to collaborate. For instance, I have little experience with MSVC, and most issues in this regard have been solved by a growing community. If you have a look at the [closed issues](https://github.com/nlohmann/json/issues?q=is%3Aissue+is%3Aclosed), you will see that we react quite timely in most cases. @@ -1285,6 +1287,7 @@ The library itself consists of a single header file licensed under the MIT licen - [**git-update-ghpages**](https://github.com/rstacruz/git-update-ghpages) to upload the documentation to gh-pages - [**GitHub Changelog Generator**](https://github.com/skywinder/github-changelog-generator) to generate the [ChangeLog](https://github.com/nlohmann/json/blob/develop/ChangeLog.md) - [**Google Benchmark**](https://github.com/google/benchmark) to implement the benchmarks +- [**Hedley**](https://nemequ.github.io/hedley/) to avoid re-inventing several compiler-agnostic feature macros - [**lcov**](http://ltp.sourceforge.net/coverage/lcov.php) to process coverage information and create a HTML view - [**libFuzzer**](http://llvm.org/docs/LibFuzzer.html) to implement fuzz testing for OSS-Fuzz - [**OSS-Fuzz**](https://github.com/google/oss-fuzz) for continuous fuzz testing of the library ([project repository](https://github.com/google/oss-fuzz/tree/master/projects/json)) diff --git a/include/nlohmann/detail/input/lexer.hpp b/include/nlohmann/detail/input/lexer.hpp index d19836cb..35e4e5d0 100644 --- a/include/nlohmann/detail/input/lexer.hpp +++ b/include/nlohmann/detail/input/lexer.hpp @@ -60,6 +60,7 @@ class lexer /// return name of values of type token_type (only used for errors) JSON_HEDLEY_RETURNS_NON_NULL + JSON_HEDLEY_CONST static const char* token_type_name(const token_type t) noexcept { switch (t) @@ -119,6 +120,7 @@ class lexer ///////////////////// /// return the locale-dependent decimal point + JSON_HEDLEY_PURE static char get_decimal_point() noexcept { const auto loc = localeconv(); @@ -817,18 +819,21 @@ class lexer } JSON_HEDLEY_NON_NULL(2) + JSON_HEDLEY_CONST static void strtof(float& f, const char* str, char** endptr) noexcept { f = std::strtof(str, endptr); } JSON_HEDLEY_NON_NULL(2) + JSON_HEDLEY_CONST static void strtof(double& f, const char* str, char** endptr) noexcept { f = std::strtod(str, endptr); } JSON_HEDLEY_NON_NULL(2) + JSON_HEDLEY_CONST static void strtof(long double& f, const char* str, char** endptr) noexcept { f = std::strtold(str, endptr); diff --git a/single_include/nlohmann/json.hpp b/single_include/nlohmann/json.hpp index e2704b9f..8eab28c2 100644 --- a/single_include/nlohmann/json.hpp +++ b/single_include/nlohmann/json.hpp @@ -7083,6 +7083,7 @@ class lexer /// return name of values of type token_type (only used for errors) JSON_HEDLEY_RETURNS_NON_NULL + JSON_HEDLEY_CONST static const char* token_type_name(const token_type t) noexcept { switch (t) @@ -7142,6 +7143,7 @@ class lexer ///////////////////// /// return the locale-dependent decimal point + JSON_HEDLEY_PURE static char get_decimal_point() noexcept { const auto loc = localeconv(); @@ -7840,18 +7842,21 @@ class lexer } JSON_HEDLEY_NON_NULL(2) + JSON_HEDLEY_CONST static void strtof(float& f, const char* str, char** endptr) noexcept { f = std::strtof(str, endptr); } JSON_HEDLEY_NON_NULL(2) + JSON_HEDLEY_CONST static void strtof(double& f, const char* str, char** endptr) noexcept { f = std::strtod(str, endptr); } JSON_HEDLEY_NON_NULL(2) + JSON_HEDLEY_CONST static void strtof(long double& f, const char* str, char** endptr) noexcept { f = std::strtold(str, endptr); From 947656544d133d9da7fb8b02d52e25d670ff050f Mon Sep 17 00:00:00 2001 From: Niels Lohmann Date: Tue, 2 Jul 2019 21:06:42 +0200 Subject: [PATCH 092/106] :rotating_light: fix warnings --- include/nlohmann/detail/input/lexer.hpp | 3 - .../nlohmann/detail/output/binary_writer.hpp | 6 +- single_include/nlohmann/json.hpp | 9 +- test/src/unit-bson.cpp | 30 ++-- test/src/unit-cbor.cpp | 134 ++++++++-------- test/src/unit-class_parser.cpp | 32 ++-- test/src/unit-constructor1.cpp | 5 +- test/src/unit-deserialization.cpp | 51 +++--- test/src/unit-msgpack.cpp | 104 +++++++------ test/src/unit-regression.cpp | 117 ++++++++------ test/src/unit-testsuites.cpp | 38 +++-- test/src/unit-ubjson.cpp | 147 ++++++++++-------- test/src/unit-unicode.cpp | 50 +++--- test/src/unit-wstring.cpp | 9 +- 14 files changed, 406 insertions(+), 329 deletions(-) diff --git a/include/nlohmann/detail/input/lexer.hpp b/include/nlohmann/detail/input/lexer.hpp index 35e4e5d0..0843d749 100644 --- a/include/nlohmann/detail/input/lexer.hpp +++ b/include/nlohmann/detail/input/lexer.hpp @@ -819,21 +819,18 @@ class lexer } JSON_HEDLEY_NON_NULL(2) - JSON_HEDLEY_CONST static void strtof(float& f, const char* str, char** endptr) noexcept { f = std::strtof(str, endptr); } JSON_HEDLEY_NON_NULL(2) - JSON_HEDLEY_CONST static void strtof(double& f, const char* str, char** endptr) noexcept { f = std::strtod(str, endptr); } JSON_HEDLEY_NON_NULL(2) - JSON_HEDLEY_CONST static void strtof(long double& f, const char* str, char** endptr) noexcept { f = std::strtold(str, endptr); diff --git a/include/nlohmann/detail/output/binary_writer.hpp b/include/nlohmann/detail/output/binary_writer.hpp index b0ab62d1..306f969b 100644 --- a/include/nlohmann/detail/output/binary_writer.hpp +++ b/include/nlohmann/detail/output/binary_writer.hpp @@ -1205,7 +1205,7 @@ class binary_writer case value_t::number_unsigned: { - if (j.m_value.number_unsigned <= (std::numeric_limits::max)()) + if (j.m_value.number_unsigned <= static_cast((std::numeric_limits::max)())) { return 'i'; } @@ -1213,11 +1213,11 @@ class binary_writer { return 'U'; } - if (j.m_value.number_unsigned <= (std::numeric_limits::max)()) + if (j.m_value.number_unsigned <= static_cast((std::numeric_limits::max)())) { return 'I'; } - if (j.m_value.number_unsigned <= (std::numeric_limits::max)()) + if (j.m_value.number_unsigned <= static_cast((std::numeric_limits::max)())) { return 'l'; } diff --git a/single_include/nlohmann/json.hpp b/single_include/nlohmann/json.hpp index 8eab28c2..6d32ff44 100644 --- a/single_include/nlohmann/json.hpp +++ b/single_include/nlohmann/json.hpp @@ -7842,21 +7842,18 @@ class lexer } JSON_HEDLEY_NON_NULL(2) - JSON_HEDLEY_CONST static void strtof(float& f, const char* str, char** endptr) noexcept { f = std::strtof(str, endptr); } JSON_HEDLEY_NON_NULL(2) - JSON_HEDLEY_CONST static void strtof(double& f, const char* str, char** endptr) noexcept { f = std::strtod(str, endptr); } JSON_HEDLEY_NON_NULL(2) - JSON_HEDLEY_CONST static void strtof(long double& f, const char* str, char** endptr) noexcept { f = std::strtold(str, endptr); @@ -12316,7 +12313,7 @@ class binary_writer case value_t::number_unsigned: { - if (j.m_value.number_unsigned <= (std::numeric_limits::max)()) + if (j.m_value.number_unsigned <= static_cast((std::numeric_limits::max)())) { return 'i'; } @@ -12324,11 +12321,11 @@ class binary_writer { return 'U'; } - if (j.m_value.number_unsigned <= (std::numeric_limits::max)()) + if (j.m_value.number_unsigned <= static_cast((std::numeric_limits::max)())) { return 'I'; } - if (j.m_value.number_unsigned <= (std::numeric_limits::max)()) + if (j.m_value.number_unsigned <= static_cast((std::numeric_limits::max)())) { return 'l'; } diff --git a/test/src/unit-bson.cpp b/test/src/unit-bson.cpp index 2689dcec..cc4b5a65 100644 --- a/test/src/unit-bson.cpp +++ b/test/src/unit-bson.cpp @@ -112,8 +112,9 @@ TEST_CASE("BSON") 0x00, 0x00, 0x00, 0x00, 0x80 }; - CHECK_THROWS_AS(json::from_bson(v), json::parse_error&); - CHECK_THROWS_WITH(json::from_bson(v), "[json.exception.parse_error.112] parse error at byte 10: syntax error while parsing BSON string: string length must be at least 1, is -2147483648"); + json _; + CHECK_THROWS_AS(_ = json::from_bson(v), json::parse_error&); + CHECK_THROWS_WITH(_ = json::from_bson(v), "[json.exception.parse_error.112] parse error at byte 10: syntax error while parsing BSON string: string length must be at least 1, is -2147483648"); } SECTION("objects") @@ -692,8 +693,9 @@ TEST_CASE("Incomplete BSON Input") 'e', 'n', 't' // unexpected EOF }; - CHECK_THROWS_AS(json::from_bson(incomplete_bson), json::parse_error&); - CHECK_THROWS_WITH(json::from_bson(incomplete_bson), + json _; + CHECK_THROWS_AS(_ = json::from_bson(incomplete_bson), json::parse_error&); + CHECK_THROWS_WITH(_ = json::from_bson(incomplete_bson), "[json.exception.parse_error.110] parse error at byte 9: syntax error while parsing BSON cstring: unexpected end of input"); CHECK(json::from_bson(incomplete_bson, true, false).is_discarded()); @@ -710,8 +712,9 @@ TEST_CASE("Incomplete BSON Input") 0x08, // entry: boolean, unexpected EOF }; - CHECK_THROWS_AS(json::from_bson(incomplete_bson), json::parse_error&); - CHECK_THROWS_WITH(json::from_bson(incomplete_bson), + json _; + CHECK_THROWS_AS(_ = json::from_bson(incomplete_bson), json::parse_error&); + CHECK_THROWS_WITH(_ = json::from_bson(incomplete_bson), "[json.exception.parse_error.110] parse error at byte 6: syntax error while parsing BSON cstring: unexpected end of input"); CHECK(json::from_bson(incomplete_bson, true, false).is_discarded()); @@ -733,8 +736,9 @@ TEST_CASE("Incomplete BSON Input") // missing input data... }; - CHECK_THROWS_AS(json::from_bson(incomplete_bson), json::parse_error&); - CHECK_THROWS_WITH(json::from_bson(incomplete_bson), + json _; + CHECK_THROWS_AS(_ = json::from_bson(incomplete_bson), json::parse_error&); + CHECK_THROWS_WITH(_ = json::from_bson(incomplete_bson), "[json.exception.parse_error.110] parse error at byte 28: syntax error while parsing BSON element list: unexpected end of input"); CHECK(json::from_bson(incomplete_bson, true, false).is_discarded()); @@ -749,8 +753,9 @@ TEST_CASE("Incomplete BSON Input") 0x0D, 0x00, // size (incomplete), unexpected EOF }; - CHECK_THROWS_AS(json::from_bson(incomplete_bson), json::parse_error&); - CHECK_THROWS_WITH(json::from_bson(incomplete_bson), + json _; + CHECK_THROWS_AS(_ = json::from_bson(incomplete_bson), json::parse_error&); + CHECK_THROWS_WITH(_ = json::from_bson(incomplete_bson), "[json.exception.parse_error.110] parse error at byte 3: syntax error while parsing BSON number: unexpected end of input"); CHECK(json::from_bson(incomplete_bson, true, false).is_discarded()); @@ -791,8 +796,9 @@ TEST_CASE("Unsupported BSON input") 0x00 // end marker }; - CHECK_THROWS_AS(json::from_bson(bson), json::parse_error&); - CHECK_THROWS_WITH(json::from_bson(bson), + json _; + CHECK_THROWS_AS(_ = json::from_bson(bson), json::parse_error&); + CHECK_THROWS_WITH(_ = json::from_bson(bson), "[json.exception.parse_error.114] parse error at byte 5: Unsupported BSON record type 0xFF"); CHECK(json::from_bson(bson, true, false).is_discarded()); diff --git a/test/src/unit-cbor.cpp b/test/src/unit-cbor.cpp index 69368b41..8b4a1707 100644 --- a/test/src/unit-cbor.cpp +++ b/test/src/unit-cbor.cpp @@ -836,15 +836,17 @@ TEST_CASE("CBOR") { SECTION("no byte follows") { - CHECK_THROWS_AS(json::from_cbor(std::vector({0xf9})), json::parse_error&); - CHECK_THROWS_WITH(json::from_cbor(std::vector({0xf9})), + json _; + CHECK_THROWS_AS(_ = json::from_cbor(std::vector({0xf9})), json::parse_error&); + CHECK_THROWS_WITH(_ = json::from_cbor(std::vector({0xf9})), "[json.exception.parse_error.110] parse error at byte 2: syntax error while parsing CBOR number: unexpected end of input"); CHECK(json::from_cbor(std::vector({0xf9}), true, false).is_discarded()); } SECTION("only one byte follows") { - CHECK_THROWS_AS(json::from_cbor(std::vector({0xf9, 0x7c})), json::parse_error&); - CHECK_THROWS_WITH(json::from_cbor(std::vector({0xf9, 0x7c})), + json _; + CHECK_THROWS_AS(_ = json::from_cbor(std::vector({0xf9, 0x7c})), json::parse_error&); + CHECK_THROWS_WITH(_ = json::from_cbor(std::vector({0xf9, 0x7c})), "[json.exception.parse_error.110] parse error at byte 3: syntax error while parsing CBOR number: unexpected end of input"); CHECK(json::from_cbor(std::vector({0xf9, 0x7c}), true, false).is_discarded()); } @@ -1319,86 +1321,88 @@ TEST_CASE("CBOR") { SECTION("empty byte vector") { - CHECK_THROWS_AS(json::from_cbor(std::vector()), json::parse_error&); - CHECK_THROWS_WITH(json::from_cbor(std::vector()), + json _; + CHECK_THROWS_AS(_ = json::from_cbor(std::vector()), json::parse_error&); + CHECK_THROWS_WITH(_ = json::from_cbor(std::vector()), "[json.exception.parse_error.110] parse error at byte 1: syntax error while parsing CBOR value: unexpected end of input"); CHECK(json::from_cbor(std::vector(), true, false).is_discarded()); } SECTION("too short byte vector") { - CHECK_THROWS_AS(json::from_cbor(std::vector({0x18})), json::parse_error&); - CHECK_THROWS_AS(json::from_cbor(std::vector({0x19})), json::parse_error&); - CHECK_THROWS_AS(json::from_cbor(std::vector({0x19, 0x00})), json::parse_error&); - CHECK_THROWS_AS(json::from_cbor(std::vector({0x1a})), json::parse_error&); - CHECK_THROWS_AS(json::from_cbor(std::vector({0x1a, 0x00})), json::parse_error&); - CHECK_THROWS_AS(json::from_cbor(std::vector({0x1a, 0x00, 0x00})), json::parse_error&); - CHECK_THROWS_AS(json::from_cbor(std::vector({0x1a, 0x00, 0x00, 0x00})), json::parse_error&); - CHECK_THROWS_AS(json::from_cbor(std::vector({0x1b})), json::parse_error&); - CHECK_THROWS_AS(json::from_cbor(std::vector({0x1b, 0x00})), json::parse_error&); - CHECK_THROWS_AS(json::from_cbor(std::vector({0x1b, 0x00, 0x00})), json::parse_error&); - CHECK_THROWS_AS(json::from_cbor(std::vector({0x1b, 0x00, 0x00, 0x00})), json::parse_error&); - CHECK_THROWS_AS(json::from_cbor(std::vector({0x1b, 0x00, 0x00, 0x00, 0x00})), json::parse_error&); - CHECK_THROWS_AS(json::from_cbor(std::vector({0x1b, 0x00, 0x00, 0x00, 0x00, 0x00})), json::parse_error&); - CHECK_THROWS_AS(json::from_cbor(std::vector({0x1b, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00})), json::parse_error&); - CHECK_THROWS_AS(json::from_cbor(std::vector({0x1b, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00})), json::parse_error&); - CHECK_THROWS_AS(json::from_cbor(std::vector({0x62})), json::parse_error&); - CHECK_THROWS_AS(json::from_cbor(std::vector({0x62, 0x60})), json::parse_error&); - CHECK_THROWS_AS(json::from_cbor(std::vector({0x7F})), json::parse_error&); - CHECK_THROWS_AS(json::from_cbor(std::vector({0x7F, 0x60})), json::parse_error&); - CHECK_THROWS_AS(json::from_cbor(std::vector({0x82, 0x01})), json::parse_error&); - CHECK_THROWS_AS(json::from_cbor(std::vector({0x9F, 0x01})), json::parse_error&); - CHECK_THROWS_AS(json::from_cbor(std::vector({0xBF, 0x61, 0x61, 0xF5})), json::parse_error&); - CHECK_THROWS_AS(json::from_cbor(std::vector({0xA1, 0x61, 0X61})), json::parse_error&); - CHECK_THROWS_AS(json::from_cbor(std::vector({0xBF, 0x61, 0X61})), json::parse_error&); + json _; + CHECK_THROWS_AS(_ = json::from_cbor(std::vector({0x18})), json::parse_error&); + CHECK_THROWS_AS(_ = json::from_cbor(std::vector({0x19})), json::parse_error&); + CHECK_THROWS_AS(_ = json::from_cbor(std::vector({0x19, 0x00})), json::parse_error&); + CHECK_THROWS_AS(_ = json::from_cbor(std::vector({0x1a})), json::parse_error&); + CHECK_THROWS_AS(_ = json::from_cbor(std::vector({0x1a, 0x00})), json::parse_error&); + CHECK_THROWS_AS(_ = json::from_cbor(std::vector({0x1a, 0x00, 0x00})), json::parse_error&); + CHECK_THROWS_AS(_ = json::from_cbor(std::vector({0x1a, 0x00, 0x00, 0x00})), json::parse_error&); + CHECK_THROWS_AS(_ = json::from_cbor(std::vector({0x1b})), json::parse_error&); + CHECK_THROWS_AS(_ = json::from_cbor(std::vector({0x1b, 0x00})), json::parse_error&); + CHECK_THROWS_AS(_ = json::from_cbor(std::vector({0x1b, 0x00, 0x00})), json::parse_error&); + CHECK_THROWS_AS(_ = json::from_cbor(std::vector({0x1b, 0x00, 0x00, 0x00})), json::parse_error&); + CHECK_THROWS_AS(_ = json::from_cbor(std::vector({0x1b, 0x00, 0x00, 0x00, 0x00})), json::parse_error&); + CHECK_THROWS_AS(_ = json::from_cbor(std::vector({0x1b, 0x00, 0x00, 0x00, 0x00, 0x00})), json::parse_error&); + CHECK_THROWS_AS(_ = json::from_cbor(std::vector({0x1b, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00})), json::parse_error&); + CHECK_THROWS_AS(_ = json::from_cbor(std::vector({0x1b, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00})), json::parse_error&); + CHECK_THROWS_AS(_ = json::from_cbor(std::vector({0x62})), json::parse_error&); + CHECK_THROWS_AS(_ = json::from_cbor(std::vector({0x62, 0x60})), json::parse_error&); + CHECK_THROWS_AS(_ = json::from_cbor(std::vector({0x7F})), json::parse_error&); + CHECK_THROWS_AS(_ = json::from_cbor(std::vector({0x7F, 0x60})), json::parse_error&); + CHECK_THROWS_AS(_ = json::from_cbor(std::vector({0x82, 0x01})), json::parse_error&); + CHECK_THROWS_AS(_ = json::from_cbor(std::vector({0x9F, 0x01})), json::parse_error&); + CHECK_THROWS_AS(_ = json::from_cbor(std::vector({0xBF, 0x61, 0x61, 0xF5})), json::parse_error&); + CHECK_THROWS_AS(_ = json::from_cbor(std::vector({0xA1, 0x61, 0X61})), json::parse_error&); + CHECK_THROWS_AS(_ = json::from_cbor(std::vector({0xBF, 0x61, 0X61})), json::parse_error&); - CHECK_THROWS_WITH(json::from_cbor(std::vector({0x18})), + CHECK_THROWS_WITH(_ = json::from_cbor(std::vector({0x18})), "[json.exception.parse_error.110] parse error at byte 2: syntax error while parsing CBOR number: unexpected end of input"); - CHECK_THROWS_WITH(json::from_cbor(std::vector({0x19})), + CHECK_THROWS_WITH(_ = json::from_cbor(std::vector({0x19})), "[json.exception.parse_error.110] parse error at byte 2: syntax error while parsing CBOR number: unexpected end of input"); - CHECK_THROWS_WITH(json::from_cbor(std::vector({0x19, 0x00})), + CHECK_THROWS_WITH(_ = json::from_cbor(std::vector({0x19, 0x00})), "[json.exception.parse_error.110] parse error at byte 3: syntax error while parsing CBOR number: unexpected end of input"); - CHECK_THROWS_WITH(json::from_cbor(std::vector({0x1a})), + CHECK_THROWS_WITH(_ = json::from_cbor(std::vector({0x1a})), "[json.exception.parse_error.110] parse error at byte 2: syntax error while parsing CBOR number: unexpected end of input"); - CHECK_THROWS_WITH(json::from_cbor(std::vector({0x1a, 0x00})), + CHECK_THROWS_WITH(_ = json::from_cbor(std::vector({0x1a, 0x00})), "[json.exception.parse_error.110] parse error at byte 3: syntax error while parsing CBOR number: unexpected end of input"); - CHECK_THROWS_WITH(json::from_cbor(std::vector({0x1a, 0x00, 0x00})), + CHECK_THROWS_WITH(_ = json::from_cbor(std::vector({0x1a, 0x00, 0x00})), "[json.exception.parse_error.110] parse error at byte 4: syntax error while parsing CBOR number: unexpected end of input"); - CHECK_THROWS_WITH(json::from_cbor(std::vector({0x1a, 0x00, 0x00, 0x00})), + CHECK_THROWS_WITH(_ = json::from_cbor(std::vector({0x1a, 0x00, 0x00, 0x00})), "[json.exception.parse_error.110] parse error at byte 5: syntax error while parsing CBOR number: unexpected end of input"); - CHECK_THROWS_WITH(json::from_cbor(std::vector({0x1b})), + CHECK_THROWS_WITH(_ = json::from_cbor(std::vector({0x1b})), "[json.exception.parse_error.110] parse error at byte 2: syntax error while parsing CBOR number: unexpected end of input"); - CHECK_THROWS_WITH(json::from_cbor(std::vector({0x1b, 0x00})), + CHECK_THROWS_WITH(_ = json::from_cbor(std::vector({0x1b, 0x00})), "[json.exception.parse_error.110] parse error at byte 3: syntax error while parsing CBOR number: unexpected end of input"); - CHECK_THROWS_WITH(json::from_cbor(std::vector({0x1b, 0x00, 0x00})), + CHECK_THROWS_WITH(_ = json::from_cbor(std::vector({0x1b, 0x00, 0x00})), "[json.exception.parse_error.110] parse error at byte 4: syntax error while parsing CBOR number: unexpected end of input"); - CHECK_THROWS_WITH(json::from_cbor(std::vector({0x1b, 0x00, 0x00, 0x00})), + CHECK_THROWS_WITH(_ = json::from_cbor(std::vector({0x1b, 0x00, 0x00, 0x00})), "[json.exception.parse_error.110] parse error at byte 5: syntax error while parsing CBOR number: unexpected end of input"); - CHECK_THROWS_WITH(json::from_cbor(std::vector({0x1b, 0x00, 0x00, 0x00, 0x00})), + CHECK_THROWS_WITH(_ = json::from_cbor(std::vector({0x1b, 0x00, 0x00, 0x00, 0x00})), "[json.exception.parse_error.110] parse error at byte 6: syntax error while parsing CBOR number: unexpected end of input"); - CHECK_THROWS_WITH(json::from_cbor(std::vector({0x1b, 0x00, 0x00, 0x00, 0x00, 0x00})), + CHECK_THROWS_WITH(_ = json::from_cbor(std::vector({0x1b, 0x00, 0x00, 0x00, 0x00, 0x00})), "[json.exception.parse_error.110] parse error at byte 7: syntax error while parsing CBOR number: unexpected end of input"); - CHECK_THROWS_WITH(json::from_cbor(std::vector({0x1b, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00})), + CHECK_THROWS_WITH(_ = json::from_cbor(std::vector({0x1b, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00})), "[json.exception.parse_error.110] parse error at byte 8: syntax error while parsing CBOR number: unexpected end of input"); - CHECK_THROWS_WITH(json::from_cbor(std::vector({0x1b, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00})), + CHECK_THROWS_WITH(_ = json::from_cbor(std::vector({0x1b, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00})), "[json.exception.parse_error.110] parse error at byte 9: syntax error while parsing CBOR number: unexpected end of input"); - CHECK_THROWS_WITH(json::from_cbor(std::vector({0x62})), + CHECK_THROWS_WITH(_ = json::from_cbor(std::vector({0x62})), "[json.exception.parse_error.110] parse error at byte 2: syntax error while parsing CBOR string: unexpected end of input"); - CHECK_THROWS_WITH(json::from_cbor(std::vector({0x62, 0x60})), + CHECK_THROWS_WITH(_ = json::from_cbor(std::vector({0x62, 0x60})), "[json.exception.parse_error.110] parse error at byte 3: syntax error while parsing CBOR string: unexpected end of input"); - CHECK_THROWS_WITH(json::from_cbor(std::vector({0x7F})), + CHECK_THROWS_WITH(_ = json::from_cbor(std::vector({0x7F})), "[json.exception.parse_error.110] parse error at byte 2: syntax error while parsing CBOR string: unexpected end of input"); - CHECK_THROWS_WITH(json::from_cbor(std::vector({0x7F, 0x60})), + CHECK_THROWS_WITH(_ = json::from_cbor(std::vector({0x7F, 0x60})), "[json.exception.parse_error.110] parse error at byte 3: syntax error while parsing CBOR string: unexpected end of input"); - CHECK_THROWS_WITH(json::from_cbor(std::vector({0x82, 0x01})), + CHECK_THROWS_WITH(_ = json::from_cbor(std::vector({0x82, 0x01})), "[json.exception.parse_error.110] parse error at byte 3: syntax error while parsing CBOR value: unexpected end of input"); - CHECK_THROWS_WITH(json::from_cbor(std::vector({0x9F, 0x01})), + CHECK_THROWS_WITH(_ = json::from_cbor(std::vector({0x9F, 0x01})), "[json.exception.parse_error.110] parse error at byte 3: syntax error while parsing CBOR value: unexpected end of input"); - CHECK_THROWS_WITH(json::from_cbor(std::vector({0xBF, 0x61, 0x61, 0xF5})), + CHECK_THROWS_WITH(_ = json::from_cbor(std::vector({0xBF, 0x61, 0x61, 0xF5})), "[json.exception.parse_error.110] parse error at byte 5: syntax error while parsing CBOR string: unexpected end of input"); - CHECK_THROWS_WITH(json::from_cbor(std::vector({0xA1, 0x61, 0x61})), + CHECK_THROWS_WITH(_ = json::from_cbor(std::vector({0xA1, 0x61, 0x61})), "[json.exception.parse_error.110] parse error at byte 4: syntax error while parsing CBOR value: unexpected end of input"); - CHECK_THROWS_WITH(json::from_cbor(std::vector({0xBF, 0x61, 0x61})), + CHECK_THROWS_WITH(_ = json::from_cbor(std::vector({0xBF, 0x61, 0x61})), "[json.exception.parse_error.110] parse error at byte 4: syntax error while parsing CBOR value: unexpected end of input"); CHECK(json::from_cbor(std::vector({0x18}), true, false).is_discarded()); @@ -1431,13 +1435,14 @@ TEST_CASE("CBOR") { SECTION("concrete examples") { - CHECK_THROWS_AS(json::from_cbor(std::vector({0x1c})), json::parse_error&); - CHECK_THROWS_WITH(json::from_cbor(std::vector({0x1c})), + json _; + CHECK_THROWS_AS(_ = json::from_cbor(std::vector({0x1c})), json::parse_error&); + CHECK_THROWS_WITH(_ = json::from_cbor(std::vector({0x1c})), "[json.exception.parse_error.112] parse error at byte 1: syntax error while parsing CBOR value: invalid byte: 0x1C"); CHECK(json::from_cbor(std::vector({0x1c}), true, false).is_discarded()); - CHECK_THROWS_AS(json::from_cbor(std::vector({0xf8})), json::parse_error&); - CHECK_THROWS_WITH(json::from_cbor(std::vector({0xf8})), + CHECK_THROWS_AS(_ = json::from_cbor(std::vector({0xf8})), json::parse_error&); + CHECK_THROWS_WITH(_ = json::from_cbor(std::vector({0xf8})), "[json.exception.parse_error.112] parse error at byte 1: syntax error while parsing CBOR value: invalid byte: 0xF8"); CHECK(json::from_cbor(std::vector({0xf8}), true, false).is_discarded()); } @@ -1488,7 +1493,8 @@ TEST_CASE("CBOR") 0xf8 }) { - CHECK_THROWS_AS(json::from_cbor(std::vector({static_cast(byte)})), json::parse_error&); + json _; + CHECK_THROWS_AS(_ = json::from_cbor(std::vector({static_cast(byte)})), json::parse_error&); CHECK(json::from_cbor(std::vector({static_cast(byte)}), true, false).is_discarded()); } } @@ -1496,8 +1502,9 @@ TEST_CASE("CBOR") SECTION("invalid string in map") { - CHECK_THROWS_AS(json::from_cbor(std::vector({0xa1, 0xff, 0x01})), json::parse_error&); - CHECK_THROWS_WITH(json::from_cbor(std::vector({0xa1, 0xff, 0x01})), + json _; + CHECK_THROWS_AS(_ = json::from_cbor(std::vector({0xa1, 0xff, 0x01})), json::parse_error&); + CHECK_THROWS_WITH(_ = json::from_cbor(std::vector({0xa1, 0xff, 0x01})), "[json.exception.parse_error.113] parse error at byte 2: syntax error while parsing CBOR string: expected length specification (0x60-0x7B) or indefinite string type (0x7F); last byte: 0xFF"); CHECK(json::from_cbor(std::vector({0xa1, 0xff, 0x01}), true, false).is_discarded()); } @@ -1514,8 +1521,9 @@ TEST_CASE("CBOR") SECTION("strict mode") { - CHECK_THROWS_AS(json::from_cbor(vec), json::parse_error&); - CHECK_THROWS_WITH(json::from_cbor(vec), + json _; + CHECK_THROWS_AS(_ = json::from_cbor(vec), json::parse_error&); + CHECK_THROWS_WITH(_ = json::from_cbor(vec), "[json.exception.parse_error.110] parse error at byte 2: syntax error while parsing CBOR value: expected end of input; last byte: 0xF6"); CHECK(json::from_cbor(vec, true, false).is_discarded()); } diff --git a/test/src/unit-class_parser.cpp b/test/src/unit-class_parser.cpp index edbef499..fa09c565 100644 --- a/test/src/unit-class_parser.cpp +++ b/test/src/unit-class_parser.cpp @@ -406,8 +406,9 @@ TEST_CASE("parser class") // uses an iterator range. std::string s = "\"1\""; s[1] = '\0'; - CHECK_THROWS_AS(json::parse(s.begin(), s.end()), json::parse_error&); - CHECK_THROWS_WITH(json::parse(s.begin(), s.end()), "[json.exception.parse_error.101] parse error at line 1, column 2: syntax error while parsing value - invalid string: control character U+0000 (NUL) must be escaped to \\u0000; last read: '\"'"); + json _; + CHECK_THROWS_AS(_ = json::parse(s.begin(), s.end()), json::parse_error&); + CHECK_THROWS_WITH(_ = json::parse(s.begin(), s.end()), "[json.exception.parse_error.101] parse error at line 1, column 2: syntax error while parsing value - invalid string: control character U+0000 (NUL) must be escaped to \\u0000; last read: '\"'"); } } @@ -1219,19 +1220,21 @@ TEST_CASE("parser class") } } + json _; + // missing part of a surrogate pair - CHECK_THROWS_AS(json::parse("\"\\uD80C\""), json::parse_error&); - CHECK_THROWS_WITH(json::parse("\"\\uD80C\""), + CHECK_THROWS_AS(_ = json::parse("\"\\uD80C\""), json::parse_error&); + CHECK_THROWS_WITH(_ = json::parse("\"\\uD80C\""), "[json.exception.parse_error.101] parse error at line 1, column 8: syntax error while parsing value - invalid string: surrogate U+DC00..U+DFFF must be followed by U+DC00..U+DFFF; last read: '\"\\uD80C\"'"); // invalid surrogate pair - CHECK_THROWS_AS(json::parse("\"\\uD80C\\uD80C\""), json::parse_error&); - CHECK_THROWS_AS(json::parse("\"\\uD80C\\u0000\""), json::parse_error&); - CHECK_THROWS_AS(json::parse("\"\\uD80C\\uFFFF\""), json::parse_error&); - CHECK_THROWS_WITH(json::parse("\"\\uD80C\\uD80C\""), + CHECK_THROWS_AS(_ = json::parse("\"\\uD80C\\uD80C\""), json::parse_error&); + CHECK_THROWS_AS(_ = json::parse("\"\\uD80C\\u0000\""), json::parse_error&); + CHECK_THROWS_AS(_ = json::parse("\"\\uD80C\\uFFFF\""), json::parse_error&); + CHECK_THROWS_WITH(_ = json::parse("\"\\uD80C\\uD80C\""), "[json.exception.parse_error.101] parse error at line 1, column 13: syntax error while parsing value - invalid string: surrogate U+DC00..U+DFFF must be followed by U+DC00..U+DFFF; last read: '\"\\uD80C\\uD80C'"); - CHECK_THROWS_WITH(json::parse("\"\\uD80C\\u0000\""), + CHECK_THROWS_WITH(_ = json::parse("\"\\uD80C\\u0000\""), "[json.exception.parse_error.101] parse error at line 1, column 13: syntax error while parsing value - invalid string: surrogate U+DC00..U+DFFF must be followed by U+DC00..U+DFFF; last read: '\"\\uD80C\\u0000'"); - CHECK_THROWS_WITH(json::parse("\"\\uD80C\\uFFFF\""), + CHECK_THROWS_WITH(_ = json::parse("\"\\uD80C\\uFFFF\""), "[json.exception.parse_error.101] parse error at line 1, column 13: syntax error while parsing value - invalid string: surrogate U+DC00..U+DFFF must be followed by U+DC00..U+DFFF; last read: '\"\\uD80C\\uFFFF'"); } @@ -1679,12 +1682,13 @@ TEST_CASE("parser class") CHECK(json::parse("{\"foo\": true:", cb, false).is_discarded()); - CHECK_THROWS_AS(json::parse("{\"foo\": true:", cb), json::parse_error&); - CHECK_THROWS_WITH(json::parse("{\"foo\": true:", cb), + json _; + CHECK_THROWS_AS(_ = json::parse("{\"foo\": true:", cb), json::parse_error&); + CHECK_THROWS_WITH(_ = json::parse("{\"foo\": true:", cb), "[json.exception.parse_error.101] parse error at line 1, column 13: syntax error while parsing object - unexpected ':'; expected '}'"); - CHECK_THROWS_AS(json::parse("1.18973e+4932", cb), json::out_of_range&); - CHECK_THROWS_WITH(json::parse("1.18973e+4932", cb), + CHECK_THROWS_AS(_ = json::parse("1.18973e+4932", cb), json::out_of_range&); + CHECK_THROWS_WITH(_ = json::parse("1.18973e+4932", cb), "[json.exception.out_of_range.406] number overflow parsing '1.18973e+4932'"); } diff --git a/test/src/unit-constructor1.cpp b/test/src/unit-constructor1.cpp index f7b6c775..93528d37 100644 --- a/test/src/unit-constructor1.cpp +++ b/test/src/unit-constructor1.cpp @@ -1052,9 +1052,10 @@ TEST_CASE("constructors") SECTION("object with error") { - CHECK_THROWS_AS(json::object({ {"one", 1}, {"two", 1u}, {"three", 2.2}, {"four", false}, 13 }), + json _; + CHECK_THROWS_AS(_ = json::object({ {"one", 1}, {"two", 1u}, {"three", 2.2}, {"four", false}, 13 }), json::type_error&); - CHECK_THROWS_WITH(json::object({ {"one", 1}, {"two", 1u}, {"three", 2.2}, {"four", false}, 13 }), + CHECK_THROWS_WITH(_ = json::object({ {"one", 1}, {"two", 1u}, {"three", 2.2}, {"four", false}, 13 }), "[json.exception.type_error.301] cannot create object from initializer list"); } diff --git a/test/src/unit-deserialization.cpp b/test/src/unit-deserialization.cpp index 10bece66..f49f1025 100644 --- a/test/src/unit-deserialization.cpp +++ b/test/src/unit-deserialization.cpp @@ -269,8 +269,10 @@ TEST_CASE("deserialization") ss3 << "[\"foo\",1,2,3,false,{\"one\":1}"; ss4 << "[\"foo\",1,2,3,false,{\"one\":1}"; ss5 << "[\"foo\",1,2,3,false,{\"one\":1}"; - CHECK_THROWS_AS(json::parse(ss1), json::parse_error&); - CHECK_THROWS_WITH(json::parse(ss2), + + json _; + CHECK_THROWS_AS(_ = json::parse(ss1), json::parse_error&); + CHECK_THROWS_WITH(_ = json::parse(ss2), "[json.exception.parse_error.101] parse error at line 1, column 29: syntax error while parsing array - unexpected end of input; expected ']'"); CHECK(not json::accept(ss3)); @@ -293,8 +295,9 @@ TEST_CASE("deserialization") SECTION("string") { json::string_t s = "[\"foo\",1,2,3,false,{\"one\":1}"; - CHECK_THROWS_AS(json::parse(s), json::parse_error&); - CHECK_THROWS_WITH(json::parse(s), + json _; + CHECK_THROWS_AS(_ = json::parse(s), json::parse_error&); + CHECK_THROWS_WITH(_ = json::parse(s), "[json.exception.parse_error.101] parse error at line 1, column 29: syntax error while parsing array - unexpected end of input; expected ']'"); CHECK(not json::accept(s)); @@ -430,7 +433,8 @@ TEST_CASE("deserialization") SECTION("empty container") { std::vector v; - CHECK_THROWS_AS(json::parse(v), json::parse_error&); + json _; + CHECK_THROWS_AS(_ = json::parse(v), json::parse_error&); CHECK(not json::accept(v)); SaxEventLogger l; @@ -614,8 +618,9 @@ TEST_CASE("deserialization") SECTION("case 6") { uint8_t v[] = {'\"', 0x7F, 0xDF, 0x7F}; - CHECK_THROWS_AS(json::parse(std::begin(v), std::end(v)), json::parse_error&); - CHECK_THROWS_WITH(json::parse(std::begin(v), std::end(v)), + json _; + CHECK_THROWS_AS(_ = json::parse(std::begin(v), std::end(v)), json::parse_error&); + CHECK_THROWS_WITH(_ = json::parse(std::begin(v), std::end(v)), "[json.exception.parse_error.101] parse error at line 1, column 4: syntax error while parsing value - invalid string: ill-formed UTF-8 byte; last read: '\"\x7f\xdf\x7f'"); CHECK(not json::accept(std::begin(v), std::end(v))); @@ -801,12 +806,13 @@ TEST_CASE("deserialization") SECTION("BOM only") { - CHECK_THROWS_AS(json::parse(bom), json::parse_error&); - CHECK_THROWS_WITH(json::parse(bom), + json _; + CHECK_THROWS_AS(_ = json::parse(bom), json::parse_error&); + CHECK_THROWS_WITH(_ = json::parse(bom), "[json.exception.parse_error.101] parse error at line 1, column 4: syntax error while parsing value - unexpected end of input; expected '[', '{', or a literal"); - CHECK_THROWS_AS(json::parse(std::istringstream(bom)), json::parse_error&); - CHECK_THROWS_WITH(json::parse(std::istringstream(bom)), + CHECK_THROWS_AS(_ = json::parse(std::istringstream(bom)), json::parse_error&); + CHECK_THROWS_WITH(_ = json::parse(std::istringstream(bom)), "[json.exception.parse_error.101] parse error at line 1, column 4: syntax error while parsing value - unexpected end of input; expected '[', '{', or a literal"); SaxEventLogger l; @@ -840,12 +846,13 @@ TEST_CASE("deserialization") SECTION("2 byte of BOM") { - CHECK_THROWS_AS(json::parse(bom.substr(0, 2)), json::parse_error&); - CHECK_THROWS_WITH(json::parse(bom.substr(0, 2)), + json _; + CHECK_THROWS_AS(_ = json::parse(bom.substr(0, 2)), json::parse_error&); + CHECK_THROWS_WITH(_ = json::parse(bom.substr(0, 2)), "[json.exception.parse_error.101] parse error at line 1, column 3: syntax error while parsing value - invalid BOM; must be 0xEF 0xBB 0xBF if given; last read: '\xEF\xBB'"); - CHECK_THROWS_AS(json::parse(std::istringstream(bom.substr(0, 2))), json::parse_error&); - CHECK_THROWS_WITH(json::parse(std::istringstream(bom.substr(0, 2))), + CHECK_THROWS_AS(_ = json::parse(std::istringstream(bom.substr(0, 2))), json::parse_error&); + CHECK_THROWS_WITH(_ = json::parse(std::istringstream(bom.substr(0, 2))), "[json.exception.parse_error.101] parse error at line 1, column 3: syntax error while parsing value - invalid BOM; must be 0xEF 0xBB 0xBF if given; last read: '\xEF\xBB'"); SaxEventLogger l1, l2; @@ -865,12 +872,13 @@ TEST_CASE("deserialization") SECTION("1 byte of BOM") { - CHECK_THROWS_AS(json::parse(bom.substr(0, 1)), json::parse_error&); - CHECK_THROWS_WITH(json::parse(bom.substr(0, 1)), + json _; + CHECK_THROWS_AS(_ = json::parse(bom.substr(0, 1)), json::parse_error&); + CHECK_THROWS_WITH(_ = json::parse(bom.substr(0, 1)), "[json.exception.parse_error.101] parse error at line 1, column 2: syntax error while parsing value - invalid BOM; must be 0xEF 0xBB 0xBF if given; last read: '\xEF'"); - CHECK_THROWS_AS(json::parse(std::istringstream(bom.substr(0, 1))), json::parse_error&); - CHECK_THROWS_WITH(json::parse(std::istringstream(bom.substr(0, 1))), + CHECK_THROWS_AS(_ = json::parse(std::istringstream(bom.substr(0, 1))), json::parse_error&); + CHECK_THROWS_WITH(_ = json::parse(std::istringstream(bom.substr(0, 1))), "[json.exception.parse_error.101] parse error at line 1, column 2: syntax error while parsing value - invalid BOM; must be 0xEF 0xBB 0xBF if given; last read: '\xEF'"); SaxEventLogger l1, l2; @@ -925,8 +933,9 @@ TEST_CASE("deserialization") else { // any variation is an error - CHECK_THROWS_AS(json::parse(s + "null"), json::parse_error&); - CHECK_THROWS_AS(json::parse(std::istringstream(s + "null")), json::parse_error&); + json _; + CHECK_THROWS_AS(_ = json::parse(s + "null"), json::parse_error&); + CHECK_THROWS_AS(_ = json::parse(std::istringstream(s + "null")), json::parse_error&); SaxEventLogger l; CHECK(not json::sax_parse(s + "null", &l)); diff --git a/test/src/unit-msgpack.cpp b/test/src/unit-msgpack.cpp index cc1b8ae3..7a095544 100644 --- a/test/src/unit-msgpack.cpp +++ b/test/src/unit-msgpack.cpp @@ -1128,71 +1128,73 @@ TEST_CASE("MessagePack") { SECTION("empty byte vector") { - CHECK_THROWS_AS(json::from_msgpack(std::vector()), json::parse_error&); - CHECK_THROWS_WITH(json::from_msgpack(std::vector()), + json _; + CHECK_THROWS_AS(_ = json::from_msgpack(std::vector()), json::parse_error&); + CHECK_THROWS_WITH(_ = json::from_msgpack(std::vector()), "[json.exception.parse_error.110] parse error at byte 1: syntax error while parsing MessagePack value: unexpected end of input"); CHECK(json::from_msgpack(std::vector(), true, false).is_discarded()); } SECTION("too short byte vector") { - CHECK_THROWS_AS(json::from_msgpack(std::vector({0x87})), json::parse_error&); - CHECK_THROWS_AS(json::from_msgpack(std::vector({0xcc})), json::parse_error&); - CHECK_THROWS_AS(json::from_msgpack(std::vector({0xcd})), json::parse_error&); - CHECK_THROWS_AS(json::from_msgpack(std::vector({0xcd, 0x00})), json::parse_error&); - CHECK_THROWS_AS(json::from_msgpack(std::vector({0xce})), json::parse_error&); - CHECK_THROWS_AS(json::from_msgpack(std::vector({0xce, 0x00})), json::parse_error&); - CHECK_THROWS_AS(json::from_msgpack(std::vector({0xce, 0x00, 0x00})), json::parse_error&); - CHECK_THROWS_AS(json::from_msgpack(std::vector({0xce, 0x00, 0x00, 0x00})), json::parse_error&); - CHECK_THROWS_AS(json::from_msgpack(std::vector({0xcf})), json::parse_error&); - CHECK_THROWS_AS(json::from_msgpack(std::vector({0xcf, 0x00})), json::parse_error&); - CHECK_THROWS_AS(json::from_msgpack(std::vector({0xcf, 0x00, 0x00})), json::parse_error&); - CHECK_THROWS_AS(json::from_msgpack(std::vector({0xcf, 0x00, 0x00, 0x00})), json::parse_error&); - CHECK_THROWS_AS(json::from_msgpack(std::vector({0xcf, 0x00, 0x00, 0x00, 0x00})), json::parse_error&); - CHECK_THROWS_AS(json::from_msgpack(std::vector({0xcf, 0x00, 0x00, 0x00, 0x00, 0x00})), json::parse_error&); - CHECK_THROWS_AS(json::from_msgpack(std::vector({0xcf, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00})), json::parse_error&); - CHECK_THROWS_AS(json::from_msgpack(std::vector({0xcf, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00})), json::parse_error&); - CHECK_THROWS_AS(json::from_msgpack(std::vector({0xa5, 0x68, 0x65})), json::parse_error&); - CHECK_THROWS_AS(json::from_msgpack(std::vector({0x92, 0x01})), json::parse_error&); - CHECK_THROWS_AS(json::from_msgpack(std::vector({0x81, 0xa1, 0x61})), json::parse_error&); + json _; + CHECK_THROWS_AS(_ = json::from_msgpack(std::vector({0x87})), json::parse_error&); + CHECK_THROWS_AS(_ = json::from_msgpack(std::vector({0xcc})), json::parse_error&); + CHECK_THROWS_AS(_ = json::from_msgpack(std::vector({0xcd})), json::parse_error&); + CHECK_THROWS_AS(_ = json::from_msgpack(std::vector({0xcd, 0x00})), json::parse_error&); + CHECK_THROWS_AS(_ = json::from_msgpack(std::vector({0xce})), json::parse_error&); + CHECK_THROWS_AS(_ = json::from_msgpack(std::vector({0xce, 0x00})), json::parse_error&); + CHECK_THROWS_AS(_ = json::from_msgpack(std::vector({0xce, 0x00, 0x00})), json::parse_error&); + CHECK_THROWS_AS(_ = json::from_msgpack(std::vector({0xce, 0x00, 0x00, 0x00})), json::parse_error&); + CHECK_THROWS_AS(_ = json::from_msgpack(std::vector({0xcf})), json::parse_error&); + CHECK_THROWS_AS(_ = json::from_msgpack(std::vector({0xcf, 0x00})), json::parse_error&); + CHECK_THROWS_AS(_ = json::from_msgpack(std::vector({0xcf, 0x00, 0x00})), json::parse_error&); + CHECK_THROWS_AS(_ = json::from_msgpack(std::vector({0xcf, 0x00, 0x00, 0x00})), json::parse_error&); + CHECK_THROWS_AS(_ = json::from_msgpack(std::vector({0xcf, 0x00, 0x00, 0x00, 0x00})), json::parse_error&); + CHECK_THROWS_AS(_ = json::from_msgpack(std::vector({0xcf, 0x00, 0x00, 0x00, 0x00, 0x00})), json::parse_error&); + CHECK_THROWS_AS(_ = json::from_msgpack(std::vector({0xcf, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00})), json::parse_error&); + CHECK_THROWS_AS(_ = json::from_msgpack(std::vector({0xcf, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00})), json::parse_error&); + CHECK_THROWS_AS(_ = json::from_msgpack(std::vector({0xa5, 0x68, 0x65})), json::parse_error&); + CHECK_THROWS_AS(_ = json::from_msgpack(std::vector({0x92, 0x01})), json::parse_error&); + CHECK_THROWS_AS(_ = json::from_msgpack(std::vector({0x81, 0xa1, 0x61})), json::parse_error&); - CHECK_THROWS_WITH(json::from_msgpack(std::vector({0x87})), + CHECK_THROWS_WITH(_ = json::from_msgpack(std::vector({0x87})), "[json.exception.parse_error.110] parse error at byte 2: syntax error while parsing MessagePack string: unexpected end of input"); - CHECK_THROWS_WITH(json::from_msgpack(std::vector({0xcc})), + CHECK_THROWS_WITH(_ = json::from_msgpack(std::vector({0xcc})), "[json.exception.parse_error.110] parse error at byte 2: syntax error while parsing MessagePack number: unexpected end of input"); - CHECK_THROWS_WITH(json::from_msgpack(std::vector({0xcd})), + CHECK_THROWS_WITH(_ = json::from_msgpack(std::vector({0xcd})), "[json.exception.parse_error.110] parse error at byte 2: syntax error while parsing MessagePack number: unexpected end of input"); - CHECK_THROWS_WITH(json::from_msgpack(std::vector({0xcd, 0x00})), + CHECK_THROWS_WITH(_ = json::from_msgpack(std::vector({0xcd, 0x00})), "[json.exception.parse_error.110] parse error at byte 3: syntax error while parsing MessagePack number: unexpected end of input"); - CHECK_THROWS_WITH(json::from_msgpack(std::vector({0xce})), + CHECK_THROWS_WITH(_ = json::from_msgpack(std::vector({0xce})), "[json.exception.parse_error.110] parse error at byte 2: syntax error while parsing MessagePack number: unexpected end of input"); - CHECK_THROWS_WITH(json::from_msgpack(std::vector({0xce, 0x00})), + CHECK_THROWS_WITH(_ = json::from_msgpack(std::vector({0xce, 0x00})), "[json.exception.parse_error.110] parse error at byte 3: syntax error while parsing MessagePack number: unexpected end of input"); - CHECK_THROWS_WITH(json::from_msgpack(std::vector({0xce, 0x00, 0x00})), + CHECK_THROWS_WITH(_ = json::from_msgpack(std::vector({0xce, 0x00, 0x00})), "[json.exception.parse_error.110] parse error at byte 4: syntax error while parsing MessagePack number: unexpected end of input"); - CHECK_THROWS_WITH(json::from_msgpack(std::vector({0xce, 0x00, 0x00, 0x00})), + CHECK_THROWS_WITH(_ = json::from_msgpack(std::vector({0xce, 0x00, 0x00, 0x00})), "[json.exception.parse_error.110] parse error at byte 5: syntax error while parsing MessagePack number: unexpected end of input"); - CHECK_THROWS_WITH(json::from_msgpack(std::vector({0xcf})), + CHECK_THROWS_WITH(_ = json::from_msgpack(std::vector({0xcf})), "[json.exception.parse_error.110] parse error at byte 2: syntax error while parsing MessagePack number: unexpected end of input"); - CHECK_THROWS_WITH(json::from_msgpack(std::vector({0xcf, 0x00})), + CHECK_THROWS_WITH(_ = json::from_msgpack(std::vector({0xcf, 0x00})), "[json.exception.parse_error.110] parse error at byte 3: syntax error while parsing MessagePack number: unexpected end of input"); - CHECK_THROWS_WITH(json::from_msgpack(std::vector({0xcf, 0x00, 0x00})), + CHECK_THROWS_WITH(_ = json::from_msgpack(std::vector({0xcf, 0x00, 0x00})), "[json.exception.parse_error.110] parse error at byte 4: syntax error while parsing MessagePack number: unexpected end of input"); - CHECK_THROWS_WITH(json::from_msgpack(std::vector({0xcf, 0x00, 0x00, 0x00})), + CHECK_THROWS_WITH(_ = json::from_msgpack(std::vector({0xcf, 0x00, 0x00, 0x00})), "[json.exception.parse_error.110] parse error at byte 5: syntax error while parsing MessagePack number: unexpected end of input"); - CHECK_THROWS_WITH(json::from_msgpack(std::vector({0xcf, 0x00, 0x00, 0x00, 0x00})), + CHECK_THROWS_WITH(_ = json::from_msgpack(std::vector({0xcf, 0x00, 0x00, 0x00, 0x00})), "[json.exception.parse_error.110] parse error at byte 6: syntax error while parsing MessagePack number: unexpected end of input"); - CHECK_THROWS_WITH(json::from_msgpack(std::vector({0xcf, 0x00, 0x00, 0x00, 0x00, 0x00})), + CHECK_THROWS_WITH(_ = json::from_msgpack(std::vector({0xcf, 0x00, 0x00, 0x00, 0x00, 0x00})), "[json.exception.parse_error.110] parse error at byte 7: syntax error while parsing MessagePack number: unexpected end of input"); - CHECK_THROWS_WITH(json::from_msgpack(std::vector({0xcf, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00})), + CHECK_THROWS_WITH(_ = json::from_msgpack(std::vector({0xcf, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00})), "[json.exception.parse_error.110] parse error at byte 8: syntax error while parsing MessagePack number: unexpected end of input"); - CHECK_THROWS_WITH(json::from_msgpack(std::vector({0xcf, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00})), + CHECK_THROWS_WITH(_ = json::from_msgpack(std::vector({0xcf, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00})), "[json.exception.parse_error.110] parse error at byte 9: syntax error while parsing MessagePack number: unexpected end of input"); - CHECK_THROWS_WITH(json::from_msgpack(std::vector({0xa5, 0x68, 0x65})), + CHECK_THROWS_WITH(_ = json::from_msgpack(std::vector({0xa5, 0x68, 0x65})), "[json.exception.parse_error.110] parse error at byte 4: syntax error while parsing MessagePack string: unexpected end of input"); - CHECK_THROWS_WITH(json::from_msgpack(std::vector({0x92, 0x01})), + CHECK_THROWS_WITH(_ = json::from_msgpack(std::vector({0x92, 0x01})), "[json.exception.parse_error.110] parse error at byte 3: syntax error while parsing MessagePack value: unexpected end of input"); - CHECK_THROWS_WITH(json::from_msgpack(std::vector({0x81, 0xa1, 0x61})), + CHECK_THROWS_WITH(_ = json::from_msgpack(std::vector({0x81, 0xa1, 0x61})), "[json.exception.parse_error.110] parse error at byte 4: syntax error while parsing MessagePack value: unexpected end of input"); CHECK(json::from_msgpack(std::vector({0x87}), true, false).is_discarded()); @@ -1220,13 +1222,14 @@ TEST_CASE("MessagePack") { SECTION("concrete examples") { - CHECK_THROWS_AS(json::from_msgpack(std::vector({0xc1})), json::parse_error&); - CHECK_THROWS_WITH(json::from_msgpack(std::vector({0xc1})), + json _; + CHECK_THROWS_AS(_ = json::from_msgpack(std::vector({0xc1})), json::parse_error&); + CHECK_THROWS_WITH(_ = json::from_msgpack(std::vector({0xc1})), "[json.exception.parse_error.112] parse error at byte 1: syntax error while parsing MessagePack value: invalid byte: 0xC1"); CHECK(json::from_msgpack(std::vector({0xc6}), true, false).is_discarded()); - CHECK_THROWS_AS(json::from_msgpack(std::vector({0xc6})), json::parse_error&); - CHECK_THROWS_WITH(json::from_msgpack(std::vector({0xc6})), + CHECK_THROWS_AS(_ = json::from_msgpack(std::vector({0xc6})), json::parse_error&); + CHECK_THROWS_WITH(_ = json::from_msgpack(std::vector({0xc6})), "[json.exception.parse_error.112] parse error at byte 1: syntax error while parsing MessagePack value: invalid byte: 0xC6"); CHECK(json::from_msgpack(std::vector({0xc6}), true, false).is_discarded()); } @@ -1245,7 +1248,8 @@ TEST_CASE("MessagePack") 0xd4, 0xd5, 0xd6, 0xd7, 0xd8 }) { - CHECK_THROWS_AS(json::from_msgpack(std::vector({static_cast(byte)})), json::parse_error&); + json _; + CHECK_THROWS_AS(_ = json::from_msgpack(std::vector({static_cast(byte)})), json::parse_error&); CHECK(json::from_msgpack(std::vector({static_cast(byte)}), true, false).is_discarded()); } } @@ -1253,8 +1257,9 @@ TEST_CASE("MessagePack") SECTION("invalid string in map") { - CHECK_THROWS_AS(json::from_msgpack(std::vector({0x81, 0xff, 0x01})), json::parse_error&); - CHECK_THROWS_WITH(json::from_msgpack(std::vector({0x81, 0xff, 0x01})), + json _; + CHECK_THROWS_AS(_ = json::from_msgpack(std::vector({0x81, 0xff, 0x01})), json::parse_error&); + CHECK_THROWS_WITH(_ = json::from_msgpack(std::vector({0x81, 0xff, 0x01})), "[json.exception.parse_error.113] parse error at byte 2: syntax error while parsing MessagePack string: expected length specification (0xA0-0xBF, 0xD9-0xDB); last byte: 0xFF"); CHECK(json::from_msgpack(std::vector({0x81, 0xff, 0x01}), true, false).is_discarded()); } @@ -1270,8 +1275,9 @@ TEST_CASE("MessagePack") SECTION("strict mode") { - CHECK_THROWS_AS(json::from_msgpack(vec), json::parse_error&); - CHECK_THROWS_WITH(json::from_msgpack(vec), + json _; + CHECK_THROWS_AS(_ = json::from_msgpack(vec), json::parse_error&); + CHECK_THROWS_WITH(_ = json::from_msgpack(vec), "[json.exception.parse_error.110] parse error at byte 2: syntax error while parsing MessagePack value: expected end of input; last byte: 0xC0"); CHECK(json::from_msgpack(vec, true, false).is_discarded()); } diff --git a/test/src/unit-regression.cpp b/test/src/unit-regression.cpp index 88b12114..2bac06b8 100644 --- a/test/src/unit-regression.cpp +++ b/test/src/unit-regression.cpp @@ -696,8 +696,9 @@ TEST_CASE("regression tests") SECTION("issue #329 - serialized value not always can be parsed") { - CHECK_THROWS_AS(json::parse("22e2222"), json::out_of_range&); - CHECK_THROWS_WITH(json::parse("22e2222"), + json _; + CHECK_THROWS_AS(_ = json::parse("22e2222"), json::out_of_range&); + CHECK_THROWS_WITH(_ = json::parse("22e2222"), "[json.exception.out_of_range.406] number overflow parsing '22e2222'"); } @@ -762,8 +763,9 @@ TEST_CASE("regression tests") SECTION("issue #366 - json::parse on failed stream gets stuck") { std::ifstream f("file_not_found.json"); - CHECK_THROWS_AS(json::parse(f), json::parse_error&); - CHECK_THROWS_WITH(json::parse(f), "[json.exception.parse_error.101] parse error at line 1, column 1: syntax error while parsing value - unexpected end of input; expected '[', '{', or a literal"); + json _; + CHECK_THROWS_AS(_ = json::parse(f), json::parse_error&); + CHECK_THROWS_WITH(_ = json::parse(f), "[json.exception.parse_error.101] parse error at line 1, column 1: syntax error while parsing value - unexpected end of input; expected '[', '{', or a literal"); } SECTION("issue #367 - calling stream at EOF") @@ -958,50 +960,55 @@ TEST_CASE("regression tests") { // original test case std::vector vec {0x65, 0xf5, 0x0a, 0x48, 0x21}; - CHECK_THROWS_AS(json::from_cbor(vec), json::parse_error&); - CHECK_THROWS_WITH(json::from_cbor(vec), + json _; + CHECK_THROWS_AS(_ = json::from_cbor(vec), json::parse_error&); + CHECK_THROWS_WITH(_ = json::from_cbor(vec), "[json.exception.parse_error.110] parse error at byte 6: syntax error while parsing CBOR string: unexpected end of input"); } SECTION("issue #407 - Heap-buffer-overflow (OSS-Fuzz issue 343)") { + json _; + // original test case: incomplete float64 std::vector vec1 {0xcb, 0x8f, 0x0a}; - CHECK_THROWS_AS(json::from_msgpack(vec1), json::parse_error&); - CHECK_THROWS_WITH(json::from_msgpack(vec1), + CHECK_THROWS_AS(_ = json::from_msgpack(vec1), json::parse_error&); + CHECK_THROWS_WITH(_ = json::from_msgpack(vec1), "[json.exception.parse_error.110] parse error at byte 4: syntax error while parsing MessagePack number: unexpected end of input"); // related test case: incomplete float32 std::vector vec2 {0xca, 0x8f, 0x0a}; - CHECK_THROWS_AS(json::from_msgpack(vec2), json::parse_error&); - CHECK_THROWS_WITH(json::from_msgpack(vec2), + CHECK_THROWS_AS(_ = json::from_msgpack(vec2), json::parse_error&); + CHECK_THROWS_WITH(_ = json::from_msgpack(vec2), "[json.exception.parse_error.110] parse error at byte 4: syntax error while parsing MessagePack number: unexpected end of input"); // related test case: incomplete Half-Precision Float (CBOR) std::vector vec3 {0xf9, 0x8f}; - CHECK_THROWS_AS(json::from_cbor(vec3), json::parse_error&); - CHECK_THROWS_WITH(json::from_cbor(vec3), + CHECK_THROWS_AS(_ = json::from_cbor(vec3), json::parse_error&); + CHECK_THROWS_WITH(_ = json::from_cbor(vec3), "[json.exception.parse_error.110] parse error at byte 3: syntax error while parsing CBOR number: unexpected end of input"); // related test case: incomplete Single-Precision Float (CBOR) std::vector vec4 {0xfa, 0x8f, 0x0a}; - CHECK_THROWS_AS(json::from_cbor(vec4), json::parse_error&); - CHECK_THROWS_WITH(json::from_cbor(vec4), + CHECK_THROWS_AS(_ = json::from_cbor(vec4), json::parse_error&); + CHECK_THROWS_WITH(_ = json::from_cbor(vec4), "[json.exception.parse_error.110] parse error at byte 4: syntax error while parsing CBOR number: unexpected end of input"); // related test case: incomplete Double-Precision Float (CBOR) std::vector vec5 {0xfb, 0x8f, 0x0a}; - CHECK_THROWS_AS(json::from_cbor(vec5), json::parse_error&); - CHECK_THROWS_WITH(json::from_cbor(vec5), + CHECK_THROWS_AS(_ = json::from_cbor(vec5), json::parse_error&); + CHECK_THROWS_WITH(_ = json::from_cbor(vec5), "[json.exception.parse_error.110] parse error at byte 4: syntax error while parsing CBOR number: unexpected end of input"); } SECTION("issue #408 - Heap-buffer-overflow (OSS-Fuzz issue 344)") { + json _; + // original test case std::vector vec1 {0x87}; - CHECK_THROWS_AS(json::from_msgpack(vec1), json::parse_error&); - CHECK_THROWS_WITH(json::from_msgpack(vec1), + CHECK_THROWS_AS(_ = json::from_msgpack(vec1), json::parse_error&); + CHECK_THROWS_WITH(_ = json::from_msgpack(vec1), "[json.exception.parse_error.110] parse error at byte 2: syntax error while parsing MessagePack string: unexpected end of input"); // more test cases for MessagePack @@ -1014,7 +1021,7 @@ TEST_CASE("regression tests") }) { std::vector vec(1, static_cast(b)); - CHECK_THROWS_AS(json::from_msgpack(vec), json::parse_error&); + CHECK_THROWS_AS(_ = json::from_msgpack(vec), json::parse_error&); } // more test cases for CBOR @@ -1029,37 +1036,39 @@ TEST_CASE("regression tests") }) { std::vector vec(1, static_cast(b)); - CHECK_THROWS_AS(json::from_cbor(vec), json::parse_error&); + CHECK_THROWS_AS(_ = json::from_cbor(vec), json::parse_error&); } // special case: empty input std::vector vec2; - CHECK_THROWS_AS(json::from_cbor(vec2), json::parse_error&); - CHECK_THROWS_WITH(json::from_cbor(vec2), + CHECK_THROWS_AS(_ = json::from_cbor(vec2), json::parse_error&); + CHECK_THROWS_WITH(_ = json::from_cbor(vec2), "[json.exception.parse_error.110] parse error at byte 1: syntax error while parsing CBOR value: unexpected end of input"); - CHECK_THROWS_AS(json::from_msgpack(vec2), json::parse_error&); - CHECK_THROWS_WITH(json::from_msgpack(vec2), + CHECK_THROWS_AS(_ = json::from_msgpack(vec2), json::parse_error&); + CHECK_THROWS_WITH(_ = json::from_msgpack(vec2), "[json.exception.parse_error.110] parse error at byte 1: syntax error while parsing MessagePack value: unexpected end of input"); } SECTION("issue #411 - Heap-buffer-overflow (OSS-Fuzz issue 366)") { + json _; + // original test case: empty UTF-8 string (indefinite length) std::vector vec1 {0x7f}; - CHECK_THROWS_AS(json::from_cbor(vec1), json::parse_error&); - CHECK_THROWS_WITH(json::from_cbor(vec1), + CHECK_THROWS_AS(_ = json::from_cbor(vec1), json::parse_error&); + CHECK_THROWS_WITH(_ = json::from_cbor(vec1), "[json.exception.parse_error.110] parse error at byte 2: syntax error while parsing CBOR string: unexpected end of input"); // related test case: empty array (indefinite length) std::vector vec2 {0x9f}; - CHECK_THROWS_AS(json::from_cbor(vec2), json::parse_error&); - CHECK_THROWS_WITH(json::from_cbor(vec2), + CHECK_THROWS_AS(_ = json::from_cbor(vec2), json::parse_error&); + CHECK_THROWS_WITH(_ = json::from_cbor(vec2), "[json.exception.parse_error.110] parse error at byte 2: syntax error while parsing CBOR value: unexpected end of input"); // related test case: empty map (indefinite length) std::vector vec3 {0xbf}; - CHECK_THROWS_AS(json::from_cbor(vec3), json::parse_error&); - CHECK_THROWS_WITH(json::from_cbor(vec3), + CHECK_THROWS_AS(_ = json::from_cbor(vec3), json::parse_error&); + CHECK_THROWS_WITH(_ = json::from_cbor(vec3), "[json.exception.parse_error.110] parse error at byte 2: syntax error while parsing CBOR string: unexpected end of input"); } @@ -1086,26 +1095,28 @@ TEST_CASE("regression tests") 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x60 }; - CHECK_THROWS_AS(json::from_cbor(vec), json::parse_error&); - CHECK_THROWS_WITH(json::from_cbor(vec), + + json _; + CHECK_THROWS_AS(_ = json::from_cbor(vec), json::parse_error&); + CHECK_THROWS_WITH(_ = json::from_cbor(vec), "[json.exception.parse_error.113] parse error at byte 2: syntax error while parsing CBOR string: expected length specification (0x60-0x7B) or indefinite string type (0x7F); last byte: 0x98"); // related test case: nonempty UTF-8 string (indefinite length) std::vector vec1 {0x7f, 0x61, 0x61}; - CHECK_THROWS_AS(json::from_cbor(vec1), json::parse_error&); - CHECK_THROWS_WITH(json::from_cbor(vec1), + CHECK_THROWS_AS(_ = json::from_cbor(vec1), json::parse_error&); + CHECK_THROWS_WITH(_ = json::from_cbor(vec1), "[json.exception.parse_error.110] parse error at byte 4: syntax error while parsing CBOR string: unexpected end of input"); // related test case: nonempty array (indefinite length) std::vector vec2 {0x9f, 0x01}; - CHECK_THROWS_AS(json::from_cbor(vec2), json::parse_error&); - CHECK_THROWS_WITH(json::from_cbor(vec2), + CHECK_THROWS_AS(_ = json::from_cbor(vec2), json::parse_error&); + CHECK_THROWS_WITH(_ = json::from_cbor(vec2), "[json.exception.parse_error.110] parse error at byte 3: syntax error while parsing CBOR value: unexpected end of input"); // related test case: nonempty map (indefinite length) std::vector vec3 {0xbf, 0x61, 0x61, 0x01}; - CHECK_THROWS_AS(json::from_cbor(vec3), json::parse_error&); - CHECK_THROWS_WITH(json::from_cbor(vec3), + CHECK_THROWS_AS(_ = json::from_cbor(vec3), json::parse_error&); + CHECK_THROWS_WITH(_ = json::from_cbor(vec3), "[json.exception.parse_error.110] parse error at byte 5: syntax error while parsing CBOR string: unexpected end of input"); } @@ -1139,8 +1150,10 @@ TEST_CASE("regression tests") 0x96, 0x96, 0xb4, 0xb4, 0xfa, 0x94, 0x94, 0x61, 0x61, 0x61, 0x61, 0x61, 0x61, 0x61, 0x61, 0xfa }; - CHECK_THROWS_AS(json::from_cbor(vec1), json::parse_error&); - CHECK_THROWS_WITH(json::from_cbor(vec1), + + json _; + CHECK_THROWS_AS(_ = json::from_cbor(vec1), json::parse_error&); + CHECK_THROWS_WITH(_ = json::from_cbor(vec1), "[json.exception.parse_error.113] parse error at byte 13: syntax error while parsing CBOR string: expected length specification (0x60-0x7B) or indefinite string type (0x7F); last byte: 0xB4"); // related test case: double-precision @@ -1153,15 +1166,16 @@ TEST_CASE("regression tests") 0x96, 0x96, 0xb4, 0xb4, 0xfa, 0x94, 0x94, 0x61, 0x61, 0x61, 0x61, 0x61, 0x61, 0x61, 0x61, 0xfb }; - CHECK_THROWS_AS(json::from_cbor(vec2), json::parse_error&); - CHECK_THROWS_WITH(json::from_cbor(vec2), + CHECK_THROWS_AS(_ = json::from_cbor(vec2), json::parse_error&); + CHECK_THROWS_WITH(_ = json::from_cbor(vec2), "[json.exception.parse_error.113] parse error at byte 13: syntax error while parsing CBOR string: expected length specification (0x60-0x7B) or indefinite string type (0x7F); last byte: 0xB4"); } SECTION("issue #452 - Heap-buffer-overflow (OSS-Fuzz issue 585)") { std::vector vec = {'-', '0', '1', '2', '2', '7', '4'}; - CHECK_THROWS_AS(json::parse(vec), json::parse_error&); + json _; + CHECK_THROWS_AS(_ = json::parse(vec), json::parse_error&); } SECTION("issue #454 - doubles are printed as integers") @@ -1309,8 +1323,9 @@ TEST_CASE("regression tests") SECTION("issue #575 - heap-buffer-overflow (OSS-Fuzz 1400)") { + json _; std::vector vec = {'"', '\\', '"', 'X', '"', '"'}; - CHECK_THROWS_AS(json::parse(vec), json::parse_error&); + CHECK_THROWS_AS(_ = json::parse(vec), json::parse_error&); } SECTION("issue #600 - how does one convert a map in Json back to std::map?") @@ -1349,7 +1364,8 @@ TEST_CASE("regression tests") SECTION("issue #602 - BOM not skipped when using json:parse(iterator)") { std::string i = "\xef\xbb\xbf{\n \"foo\": true\n}"; - CHECK_NOTHROW(json::parse(i.begin(), i.end())); + json _; + CHECK_NOTHROW(_ = json::parse(i.begin(), i.end())); } SECTION("issue #702 - conversion from valarray to json fails to build") @@ -1412,7 +1428,8 @@ TEST_CASE("regression tests") ); // handle different exceptions as 'file not found', 'permission denied' is.open("test/data/regression/working_file.json"); - CHECK_NOTHROW(nlohmann::json::parse(is)); + json _; + CHECK_NOTHROW(_ = nlohmann::json::parse(is)); } { @@ -1425,7 +1442,8 @@ TEST_CASE("regression tests") is.open("test/data/json_nlohmann_tests/all_unicode.json.cbor", std::ios_base::in | std::ios_base::binary); - CHECK_NOTHROW(nlohmann::json::from_cbor(is)); + json _; + CHECK_NOTHROW(_ = nlohmann::json::from_cbor(is)); } } @@ -1505,13 +1523,14 @@ TEST_CASE("regression tests") SECTION("issue #962 - Timeout (OSS-Fuzz 6034)") { + json _; std::vector v_ubjson = {'[', '$', 'Z', '#', 'L', 0x78, 0x28, 0x00, 0x68, 0x28, 0x69, 0x69, 0x17}; - CHECK_THROWS_AS(json::from_ubjson(v_ubjson), json::out_of_range&); + CHECK_THROWS_AS(_ = json::from_ubjson(v_ubjson), json::out_of_range&); //CHECK_THROWS_WITH(json::from_ubjson(v_ubjson), // "[json.exception.out_of_range.408] excessive array size: 8658170730974374167"); v_ubjson[0] = '{'; - CHECK_THROWS_AS(json::from_ubjson(v_ubjson), json::out_of_range&); + CHECK_THROWS_AS(_ = json::from_ubjson(v_ubjson), json::out_of_range&); //CHECK_THROWS_WITH(json::from_ubjson(v_ubjson), // "[json.exception.out_of_range.408] excessive object size: 8658170730974374167"); } diff --git a/test/src/unit-testsuites.cpp b/test/src/unit-testsuites.cpp index 6496be10..e65fb88e 100644 --- a/test/src/unit-testsuites.cpp +++ b/test/src/unit-testsuites.cpp @@ -79,7 +79,8 @@ TEST_CASE("compliance tests from json.org") { CAPTURE(filename) std::ifstream f(filename); - CHECK_THROWS_AS(json::parse(f), json::parse_error&); + json _; + CHECK_THROWS_AS(_ = json::parse(f), json::parse_error&); } } @@ -387,36 +388,36 @@ TEST_CASE("json.org examples") SECTION("FILE 1.json") { std::unique_ptr f(std::fopen("test/data/json.org/1.json", "r"), &std::fclose); - json j; - CHECK_NOTHROW(j.parse(f.get())); + json _; + CHECK_NOTHROW(_ = json::parse(f.get())); } SECTION("FILE 2.json") { std::unique_ptr f(std::fopen("test/data/json.org/2.json", "r"), &std::fclose); - json j; - CHECK_NOTHROW(j.parse(f.get())); + json _; + CHECK_NOTHROW(_ = json::parse(f.get())); } SECTION("FILE 3.json") { std::unique_ptr f(std::fopen("test/data/json.org/3.json", "r"), &std::fclose); - json j; - CHECK_NOTHROW(j.parse(f.get())); + json _; + CHECK_NOTHROW(_ = json::parse(f.get())); } SECTION("FILE 4.json") { std::unique_ptr f(std::fopen("test/data/json.org/4.json", "r"), &std::fclose); - json j; - CHECK_NOTHROW(j.parse(f.get())); + json _; + CHECK_NOTHROW(_ = json::parse(f.get())); } SECTION("FILE 5.json") { std::unique_ptr f(std::fopen("test/data/json.org/5.json", "r"), &std::fclose); - json j; - CHECK_NOTHROW(j.parse(f.get())); + json _; + CHECK_NOTHROW(_ = json::parse(f.get())); } } @@ -810,7 +811,8 @@ TEST_CASE("nst's JSONTestSuite") { CAPTURE(filename) std::ifstream f(filename); - CHECK_THROWS_AS(json::parse(f), json::parse_error&); + json _; + CHECK_THROWS_AS(_ = json::parse(f), json::parse_error&); } } @@ -1027,7 +1029,8 @@ TEST_CASE("nst's JSONTestSuite (2)") { CAPTURE(filename) std::ifstream f(filename); - CHECK_NOTHROW(json::parse(f)); + json _; + CHECK_NOTHROW(_ = json::parse(f)); std::ifstream f2(filename); CHECK(json::accept(f2)); } @@ -1228,7 +1231,8 @@ TEST_CASE("nst's JSONTestSuite (2)") { CAPTURE(filename) std::ifstream f(filename); - CHECK_THROWS_AS(json::parse(f), json::parse_error&); + json _; + CHECK_THROWS_AS(_ = json::parse(f), json::parse_error&); std::ifstream f2(filename); CHECK(not json::accept(f2)); } @@ -1293,7 +1297,8 @@ TEST_CASE("nst's JSONTestSuite (2)") { CAPTURE(filename) std::ifstream f(filename); - CHECK_NOTHROW(json::parse(f)); + json _; + CHECK_NOTHROW(_ = json::parse(f)); std::ifstream f2(filename); CHECK(json::accept(f2)); } @@ -1343,7 +1348,8 @@ TEST_CASE("nst's JSONTestSuite (2)") { CAPTURE(filename) std::ifstream f(filename); - CHECK_THROWS_AS(json::parse(f), json::exception&); // could be parse_error or out_of_range + json _; + CHECK_THROWS_AS(_ = json::parse(f), json::exception&); // could be parse_error or out_of_range std::ifstream f2(filename); CHECK(not json::accept(f2)); } diff --git a/test/src/unit-ubjson.cpp b/test/src/unit-ubjson.cpp index ca6b70fd..46539dd6 100644 --- a/test/src/unit-ubjson.cpp +++ b/test/src/unit-ubjson.cpp @@ -1301,8 +1301,9 @@ TEST_CASE("UBJSON") SECTION("strict mode") { - CHECK_THROWS_AS(json::from_ubjson(vec), json::parse_error&); - CHECK_THROWS_WITH(json::from_ubjson(vec), + json _; + CHECK_THROWS_AS(_ = json::from_ubjson(vec), json::parse_error&); + CHECK_THROWS_WITH(_ = json::from_ubjson(vec), "[json.exception.parse_error.110] parse error at byte 2: syntax error while parsing UBJSON value: expected end of input; last byte: 0x5A"); } } @@ -1311,8 +1312,9 @@ TEST_CASE("UBJSON") { // larger than max int64 json j = 9223372036854775808llu; - CHECK_THROWS_AS(json::to_ubjson(j), json::out_of_range&); - CHECK_THROWS_WITH(json::to_ubjson(j), "[json.exception.out_of_range.407] integer number 9223372036854775808 cannot be represented by UBJSON as it does not fit int64"); + json _; + CHECK_THROWS_AS(_ = json::to_ubjson(j), json::out_of_range&); + CHECK_THROWS_WITH(_ = json::to_ubjson(j), "[json.exception.out_of_range.407] integer number 9223372036854775808 cannot be represented by UBJSON as it does not fit int64"); } SECTION("excessive size") @@ -1320,27 +1322,29 @@ TEST_CASE("UBJSON") SECTION("array") { std::vector v_ubjson = {'[', '$', 'Z', '#', 'L', 0x78, 0x28, 0x00, 0x68, 0x28, 0x69, 0x69, 0x17}; - CHECK_THROWS_AS(json::from_ubjson(v_ubjson), json::out_of_range&); + json _; + CHECK_THROWS_AS(_ = json::from_ubjson(v_ubjson), json::out_of_range&); json j; nlohmann::detail::json_sax_dom_callback_parser scp(j, [](int, json::parse_event_t, const json&) { return true; }); - CHECK_THROWS_AS(json::sax_parse(v_ubjson, &scp, json::input_format_t::ubjson), json::out_of_range&); + CHECK_THROWS_AS(_ = json::sax_parse(v_ubjson, &scp, json::input_format_t::ubjson), json::out_of_range&); } SECTION("object") { std::vector v_ubjson = {'{', '$', 'Z', '#', 'L', 0x78, 0x28, 0x00, 0x68, 0x28, 0x69, 0x69, 0x17}; - CHECK_THROWS_AS(json::from_ubjson(v_ubjson), json::out_of_range&); + json _; + CHECK_THROWS_AS(_ = json::from_ubjson(v_ubjson), json::out_of_range&); json j; nlohmann::detail::json_sax_dom_callback_parser scp(j, [](int, json::parse_event_t, const json&) { return true; }); - CHECK_THROWS_AS(json::sax_parse(v_ubjson, &scp, json::input_format_t::ubjson), json::out_of_range&); + CHECK_THROWS_AS(_ = json::sax_parse(v_ubjson, &scp, json::input_format_t::ubjson), json::out_of_range&); } } } @@ -1531,8 +1535,9 @@ TEST_CASE("UBJSON") { SECTION("empty byte vector") { - CHECK_THROWS_AS(json::from_ubjson(std::vector()), json::parse_error&); - CHECK_THROWS_WITH(json::from_ubjson(std::vector()), + json _; + CHECK_THROWS_AS(_ = json::from_ubjson(std::vector()), json::parse_error&); + CHECK_THROWS_WITH(_ = json::from_ubjson(std::vector()), "[json.exception.parse_error.110] parse error at byte 1: syntax error while parsing UBJSON value: unexpected end of input"); } @@ -1541,15 +1546,17 @@ TEST_CASE("UBJSON") SECTION("eof after C byte") { std::vector v = {'C'}; - CHECK_THROWS_AS(json::from_ubjson(v), json::parse_error&); - CHECK_THROWS_WITH(json::from_ubjson(v), "[json.exception.parse_error.110] parse error at byte 2: syntax error while parsing UBJSON char: unexpected end of input"); + json _; + CHECK_THROWS_AS(_ = json::from_ubjson(v), json::parse_error&); + CHECK_THROWS_WITH(_ = json::from_ubjson(v), "[json.exception.parse_error.110] parse error at byte 2: syntax error while parsing UBJSON char: unexpected end of input"); } SECTION("byte out of range") { std::vector v = {'C', 130}; - CHECK_THROWS_AS(json::from_ubjson(v), json::parse_error&); - CHECK_THROWS_WITH(json::from_ubjson(v), "[json.exception.parse_error.113] parse error at byte 2: syntax error while parsing UBJSON char: byte after 'C' must be in range 0x00..0x7F; last byte: 0x82"); + json _; + CHECK_THROWS_AS(_ = json::from_ubjson(v), json::parse_error&); + CHECK_THROWS_WITH(_ = json::from_ubjson(v), "[json.exception.parse_error.113] parse error at byte 2: syntax error while parsing UBJSON char: byte after 'C' must be in range 0x00..0x7F; last byte: 0x82"); } } @@ -1558,15 +1565,17 @@ TEST_CASE("UBJSON") SECTION("eof after S byte") { std::vector v = {'S'}; - CHECK_THROWS_AS(json::from_ubjson(v), json::parse_error&); - CHECK_THROWS_WITH(json::from_ubjson(v), "[json.exception.parse_error.110] parse error at byte 2: syntax error while parsing UBJSON value: unexpected end of input"); + json _; + CHECK_THROWS_AS(_ = json::from_ubjson(v), json::parse_error&); + CHECK_THROWS_WITH(_ = json::from_ubjson(v), "[json.exception.parse_error.110] parse error at byte 2: syntax error while parsing UBJSON value: unexpected end of input"); } SECTION("invalid byte") { std::vector v = {'S', '1', 'a'}; - CHECK_THROWS_AS(json::from_ubjson(v), json::parse_error&); - CHECK_THROWS_WITH(json::from_ubjson(v), "[json.exception.parse_error.113] parse error at byte 2: syntax error while parsing UBJSON string: expected length type specification (U, i, I, l, L); last byte: 0x31"); + json _; + CHECK_THROWS_AS(_ = json::from_ubjson(v), json::parse_error&); + CHECK_THROWS_WITH(_ = json::from_ubjson(v), "[json.exception.parse_error.113] parse error at byte 2: syntax error while parsing UBJSON string: expected length type specification (U, i, I, l, L); last byte: 0x31"); } } @@ -1575,138 +1584,144 @@ TEST_CASE("UBJSON") SECTION("optimized array: no size following type") { std::vector v = {'[', '$', 'i', 2}; - CHECK_THROWS_AS(json::from_ubjson(v), json::parse_error&); - CHECK_THROWS_WITH(json::from_ubjson(v), "[json.exception.parse_error.112] parse error at byte 4: syntax error while parsing UBJSON size: expected '#' after type information; last byte: 0x02"); + json _; + CHECK_THROWS_AS(_ = json::from_ubjson(v), json::parse_error&); + CHECK_THROWS_WITH(_ = json::from_ubjson(v), "[json.exception.parse_error.112] parse error at byte 4: syntax error while parsing UBJSON size: expected '#' after type information; last byte: 0x02"); } } SECTION("strings") { std::vector vS = {'S'}; - CHECK_THROWS_AS(json::from_ubjson(vS), json::parse_error&); - CHECK_THROWS_WITH(json::from_ubjson(vS), "[json.exception.parse_error.110] parse error at byte 2: syntax error while parsing UBJSON value: unexpected end of input"); + json _; + CHECK_THROWS_AS(_ = json::from_ubjson(vS), json::parse_error&); + CHECK_THROWS_WITH(_ = json::from_ubjson(vS), "[json.exception.parse_error.110] parse error at byte 2: syntax error while parsing UBJSON value: unexpected end of input"); CHECK(json::from_ubjson(vS, true, false).is_discarded()); std::vector v = {'S', 'i', '2', 'a'}; - CHECK_THROWS_AS(json::from_ubjson(v), json::parse_error&); - CHECK_THROWS_WITH(json::from_ubjson(v), "[json.exception.parse_error.110] parse error at byte 5: syntax error while parsing UBJSON string: unexpected end of input"); + CHECK_THROWS_AS(_ = json::from_ubjson(v), json::parse_error&); + CHECK_THROWS_WITH(_ = json::from_ubjson(v), "[json.exception.parse_error.110] parse error at byte 5: syntax error while parsing UBJSON string: unexpected end of input"); CHECK(json::from_ubjson(v, true, false).is_discarded()); std::vector vC = {'C'}; - CHECK_THROWS_AS(json::from_ubjson(vC), json::parse_error&); - CHECK_THROWS_WITH(json::from_ubjson(vC), "[json.exception.parse_error.110] parse error at byte 2: syntax error while parsing UBJSON char: unexpected end of input"); + CHECK_THROWS_AS(_ = json::from_ubjson(vC), json::parse_error&); + CHECK_THROWS_WITH(_ = json::from_ubjson(vC), "[json.exception.parse_error.110] parse error at byte 2: syntax error while parsing UBJSON char: unexpected end of input"); CHECK(json::from_ubjson(vC, true, false).is_discarded()); } SECTION("sizes") { std::vector vU = {'[', '#', 'U'}; - CHECK_THROWS_AS(json::from_ubjson(vU), json::parse_error&); - CHECK_THROWS_WITH(json::from_ubjson(vU), "[json.exception.parse_error.110] parse error at byte 4: syntax error while parsing UBJSON number: unexpected end of input"); + json _; + CHECK_THROWS_AS(_ = json::from_ubjson(vU), json::parse_error&); + CHECK_THROWS_WITH(_ = json::from_ubjson(vU), "[json.exception.parse_error.110] parse error at byte 4: syntax error while parsing UBJSON number: unexpected end of input"); CHECK(json::from_ubjson(vU, true, false).is_discarded()); std::vector vi = {'[', '#', 'i'}; - CHECK_THROWS_AS(json::from_ubjson(vi), json::parse_error&); - CHECK_THROWS_WITH(json::from_ubjson(vi), "[json.exception.parse_error.110] parse error at byte 4: syntax error while parsing UBJSON number: unexpected end of input"); + CHECK_THROWS_AS(_ = json::from_ubjson(vi), json::parse_error&); + CHECK_THROWS_WITH(_ = json::from_ubjson(vi), "[json.exception.parse_error.110] parse error at byte 4: syntax error while parsing UBJSON number: unexpected end of input"); CHECK(json::from_ubjson(vi, true, false).is_discarded()); std::vector vI = {'[', '#', 'I'}; - CHECK_THROWS_AS(json::from_ubjson(vI), json::parse_error&); - CHECK_THROWS_WITH(json::from_ubjson(vI), "[json.exception.parse_error.110] parse error at byte 4: syntax error while parsing UBJSON number: unexpected end of input"); + CHECK_THROWS_AS(_ = json::from_ubjson(vI), json::parse_error&); + CHECK_THROWS_WITH(_ = json::from_ubjson(vI), "[json.exception.parse_error.110] parse error at byte 4: syntax error while parsing UBJSON number: unexpected end of input"); CHECK(json::from_ubjson(vI, true, false).is_discarded()); std::vector vl = {'[', '#', 'l'}; - CHECK_THROWS_AS(json::from_ubjson(vl), json::parse_error&); - CHECK_THROWS_WITH(json::from_ubjson(vl), "[json.exception.parse_error.110] parse error at byte 4: syntax error while parsing UBJSON number: unexpected end of input"); + CHECK_THROWS_AS(_ = json::from_ubjson(vl), json::parse_error&); + CHECK_THROWS_WITH(_ = json::from_ubjson(vl), "[json.exception.parse_error.110] parse error at byte 4: syntax error while parsing UBJSON number: unexpected end of input"); CHECK(json::from_ubjson(vl, true, false).is_discarded()); std::vector vL = {'[', '#', 'L'}; - CHECK_THROWS_AS(json::from_ubjson(vL), json::parse_error&); - CHECK_THROWS_WITH(json::from_ubjson(vL), "[json.exception.parse_error.110] parse error at byte 4: syntax error while parsing UBJSON number: unexpected end of input"); + CHECK_THROWS_AS(_ = json::from_ubjson(vL), json::parse_error&); + CHECK_THROWS_WITH(_ = json::from_ubjson(vL), "[json.exception.parse_error.110] parse error at byte 4: syntax error while parsing UBJSON number: unexpected end of input"); CHECK(json::from_ubjson(vL, true, false).is_discarded()); std::vector v0 = {'[', '#', 'T', ']'}; - CHECK_THROWS_AS(json::from_ubjson(v0), json::parse_error&); - CHECK_THROWS_WITH(json::from_ubjson(v0), "[json.exception.parse_error.113] parse error at byte 3: syntax error while parsing UBJSON size: expected length type specification (U, i, I, l, L) after '#'; last byte: 0x54"); + CHECK_THROWS_AS(_ = json::from_ubjson(v0), json::parse_error&); + CHECK_THROWS_WITH(_ = json::from_ubjson(v0), "[json.exception.parse_error.113] parse error at byte 3: syntax error while parsing UBJSON size: expected length type specification (U, i, I, l, L) after '#'; last byte: 0x54"); CHECK(json::from_ubjson(v0, true, false).is_discarded()); } SECTION("types") { std::vector v0 = {'[', '$'}; - CHECK_THROWS_AS(json::from_ubjson(v0), json::parse_error&); - CHECK_THROWS_WITH(json::from_ubjson(v0), "[json.exception.parse_error.110] parse error at byte 3: syntax error while parsing UBJSON type: unexpected end of input"); + json _; + CHECK_THROWS_AS(_ = json::from_ubjson(v0), json::parse_error&); + CHECK_THROWS_WITH(_ = json::from_ubjson(v0), "[json.exception.parse_error.110] parse error at byte 3: syntax error while parsing UBJSON type: unexpected end of input"); CHECK(json::from_ubjson(v0, true, false).is_discarded()); std::vector vi = {'[', '$', '#'}; - CHECK_THROWS_AS(json::from_ubjson(vi), json::parse_error&); - CHECK_THROWS_WITH(json::from_ubjson(vi), "[json.exception.parse_error.110] parse error at byte 4: syntax error while parsing UBJSON value: unexpected end of input"); + CHECK_THROWS_AS(_ = json::from_ubjson(vi), json::parse_error&); + CHECK_THROWS_WITH(_ = json::from_ubjson(vi), "[json.exception.parse_error.110] parse error at byte 4: syntax error while parsing UBJSON value: unexpected end of input"); CHECK(json::from_ubjson(vi, true, false).is_discarded()); std::vector vT = {'[', '$', 'T'}; - CHECK_THROWS_AS(json::from_ubjson(vT), json::parse_error&); - CHECK_THROWS_WITH(json::from_ubjson(vT), "[json.exception.parse_error.110] parse error at byte 4: syntax error while parsing UBJSON value: unexpected end of input"); + CHECK_THROWS_AS(_ = json::from_ubjson(vT), json::parse_error&); + CHECK_THROWS_WITH(_ = json::from_ubjson(vT), "[json.exception.parse_error.110] parse error at byte 4: syntax error while parsing UBJSON value: unexpected end of input"); CHECK(json::from_ubjson(vT, true, false).is_discarded()); } SECTION("arrays") { std::vector vST = {'[', '$', 'i', '#', 'i', 2, 1}; - CHECK_THROWS_AS(json::from_ubjson(vST), json::parse_error&); - CHECK_THROWS_WITH(json::from_ubjson(vST), "[json.exception.parse_error.110] parse error at byte 8: syntax error while parsing UBJSON number: unexpected end of input"); + json _; + CHECK_THROWS_AS(_ = json::from_ubjson(vST), json::parse_error&); + CHECK_THROWS_WITH(_ = json::from_ubjson(vST), "[json.exception.parse_error.110] parse error at byte 8: syntax error while parsing UBJSON number: unexpected end of input"); CHECK(json::from_ubjson(vST, true, false).is_discarded()); std::vector vS = {'[', '#', 'i', 2, 'i', 1}; - CHECK_THROWS_AS(json::from_ubjson(vS), json::parse_error&); - CHECK_THROWS_WITH(json::from_ubjson(vS), "[json.exception.parse_error.110] parse error at byte 7: syntax error while parsing UBJSON value: unexpected end of input"); + CHECK_THROWS_AS(_ = json::from_ubjson(vS), json::parse_error&); + CHECK_THROWS_WITH(_ = json::from_ubjson(vS), "[json.exception.parse_error.110] parse error at byte 7: syntax error while parsing UBJSON value: unexpected end of input"); CHECK(json::from_ubjson(vS, true, false).is_discarded()); std::vector v = {'[', 'i', 2, 'i', 1}; - CHECK_THROWS_AS(json::from_ubjson(v), json::parse_error&); - CHECK_THROWS_WITH(json::from_ubjson(v), "[json.exception.parse_error.110] parse error at byte 6: syntax error while parsing UBJSON value: unexpected end of input"); + CHECK_THROWS_AS(_ = json::from_ubjson(v), json::parse_error&); + CHECK_THROWS_WITH(_ = json::from_ubjson(v), "[json.exception.parse_error.110] parse error at byte 6: syntax error while parsing UBJSON value: unexpected end of input"); CHECK(json::from_ubjson(v, true, false).is_discarded()); } SECTION("objects") { std::vector vST = {'{', '$', 'i', '#', 'i', 2, 'i', 1, 'a', 1}; - CHECK_THROWS_AS(json::from_ubjson(vST), json::parse_error&); - CHECK_THROWS_WITH(json::from_ubjson(vST), "[json.exception.parse_error.110] parse error at byte 11: syntax error while parsing UBJSON value: unexpected end of input"); + json _; + CHECK_THROWS_AS(_ = json::from_ubjson(vST), json::parse_error&); + CHECK_THROWS_WITH(_ = json::from_ubjson(vST), "[json.exception.parse_error.110] parse error at byte 11: syntax error while parsing UBJSON value: unexpected end of input"); CHECK(json::from_ubjson(vST, true, false).is_discarded()); std::vector vT = {'{', '$', 'i', 'i', 1, 'a', 1}; - CHECK_THROWS_AS(json::from_ubjson(vT), json::parse_error&); - CHECK_THROWS_WITH(json::from_ubjson(vT), "[json.exception.parse_error.112] parse error at byte 4: syntax error while parsing UBJSON size: expected '#' after type information; last byte: 0x69"); + CHECK_THROWS_AS(_ = json::from_ubjson(vT), json::parse_error&); + CHECK_THROWS_WITH(_ = json::from_ubjson(vT), "[json.exception.parse_error.112] parse error at byte 4: syntax error while parsing UBJSON size: expected '#' after type information; last byte: 0x69"); CHECK(json::from_ubjson(vT, true, false).is_discarded()); std::vector vS = {'{', '#', 'i', 2, 'i', 1, 'a', 'i', 1}; - CHECK_THROWS_AS(json::from_ubjson(vS), json::parse_error&); - CHECK_THROWS_WITH(json::from_ubjson(vS), "[json.exception.parse_error.110] parse error at byte 10: syntax error while parsing UBJSON value: unexpected end of input"); + CHECK_THROWS_AS(_ = json::from_ubjson(vS), json::parse_error&); + CHECK_THROWS_WITH(_ = json::from_ubjson(vS), "[json.exception.parse_error.110] parse error at byte 10: syntax error while parsing UBJSON value: unexpected end of input"); CHECK(json::from_ubjson(vS, true, false).is_discarded()); std::vector v = {'{', 'i', 1, 'a', 'i', 1}; - CHECK_THROWS_AS(json::from_ubjson(v), json::parse_error&); - CHECK_THROWS_WITH(json::from_ubjson(v), "[json.exception.parse_error.110] parse error at byte 7: syntax error while parsing UBJSON value: unexpected end of input"); + CHECK_THROWS_AS(_ = json::from_ubjson(v), json::parse_error&); + CHECK_THROWS_WITH(_ = json::from_ubjson(v), "[json.exception.parse_error.110] parse error at byte 7: syntax error while parsing UBJSON value: unexpected end of input"); CHECK(json::from_ubjson(v, true, false).is_discarded()); std::vector v2 = {'{', 'i', 1, 'a', 'i', 1, 'i'}; - CHECK_THROWS_AS(json::from_ubjson(v2), json::parse_error&); - CHECK_THROWS_WITH(json::from_ubjson(v2), "[json.exception.parse_error.110] parse error at byte 8: syntax error while parsing UBJSON number: unexpected end of input"); + CHECK_THROWS_AS(_ = json::from_ubjson(v2), json::parse_error&); + CHECK_THROWS_WITH(_ = json::from_ubjson(v2), "[json.exception.parse_error.110] parse error at byte 8: syntax error while parsing UBJSON number: unexpected end of input"); CHECK(json::from_ubjson(v2, true, false).is_discarded()); std::vector v3 = {'{', 'i', 1, 'a'}; - CHECK_THROWS_AS(json::from_ubjson(v3), json::parse_error&); - CHECK_THROWS_WITH(json::from_ubjson(v3), "[json.exception.parse_error.110] parse error at byte 5: syntax error while parsing UBJSON value: unexpected end of input"); + CHECK_THROWS_AS(_ = json::from_ubjson(v3), json::parse_error&); + CHECK_THROWS_WITH(_ = json::from_ubjson(v3), "[json.exception.parse_error.110] parse error at byte 5: syntax error while parsing UBJSON value: unexpected end of input"); CHECK(json::from_ubjson(v3, true, false).is_discarded()); std::vector vST1 = {'{', '$', 'd', '#', 'i', 2, 'i', 1, 'a'}; - CHECK_THROWS_AS(json::from_ubjson(vST1), json::parse_error&); - CHECK_THROWS_WITH(json::from_ubjson(vST1), "[json.exception.parse_error.110] parse error at byte 10: syntax error while parsing UBJSON number: unexpected end of input"); + CHECK_THROWS_AS(_ = json::from_ubjson(vST1), json::parse_error&); + CHECK_THROWS_WITH(_ = json::from_ubjson(vST1), "[json.exception.parse_error.110] parse error at byte 10: syntax error while parsing UBJSON number: unexpected end of input"); CHECK(json::from_ubjson(vST1, true, false).is_discarded()); std::vector vST2 = {'{', '#', 'i', 2, 'i', 1, 'a'}; - CHECK_THROWS_AS(json::from_ubjson(vST2), json::parse_error&); - CHECK_THROWS_WITH(json::from_ubjson(vST2), "[json.exception.parse_error.110] parse error at byte 8: syntax error while parsing UBJSON value: unexpected end of input"); + CHECK_THROWS_AS(_ = json::from_ubjson(vST2), json::parse_error&); + CHECK_THROWS_WITH(_ = json::from_ubjson(vST2), "[json.exception.parse_error.110] parse error at byte 8: syntax error while parsing UBJSON value: unexpected end of input"); CHECK(json::from_ubjson(vST2, true, false).is_discarded()); } } diff --git a/test/src/unit-unicode.cpp b/test/src/unit-unicode.cpp index e69639f4..0f499c70 100644 --- a/test/src/unit-unicode.cpp +++ b/test/src/unit-unicode.cpp @@ -158,13 +158,14 @@ void check_utf8string(bool success_expected, int byte1, int byte2 = -1, int byte CAPTURE(json_string) + json _; if (success_expected) { - CHECK_NOTHROW(json::parse(json_string)); + CHECK_NOTHROW(_ = json::parse(json_string)); } else { - CHECK_THROWS_AS(json::parse(json_string), json::parse_error&); + CHECK_THROWS_AS(_ = json::parse(json_string), json::parse_error&); } } } @@ -1051,7 +1052,8 @@ TEST_CASE("Unicode" * doctest::skip()) json_text += "\""; CAPTURE(json_text) - CHECK_NOTHROW(json::parse(json_text)); + json _; + CHECK_NOTHROW(_ = json::parse(json_text)); } } @@ -1059,32 +1061,34 @@ TEST_CASE("Unicode" * doctest::skip()) { SECTION("incorrect surrogate values") { - CHECK_THROWS_AS(json::parse("\"\\uDC00\\uDC00\""), json::parse_error&); - CHECK_THROWS_WITH(json::parse("\"\\uDC00\\uDC00\""), + json _; + + CHECK_THROWS_AS(_ = json::parse("\"\\uDC00\\uDC00\""), json::parse_error&); + CHECK_THROWS_WITH(_ = json::parse("\"\\uDC00\\uDC00\""), "[json.exception.parse_error.101] parse error at line 1, column 7: syntax error while parsing value - invalid string: surrogate U+DC00..U+DFFF must follow U+D800..U+DBFF; last read: '\"\\uDC00'"); - CHECK_THROWS_AS(json::parse("\"\\uD7FF\\uDC00\""), json::parse_error&); - CHECK_THROWS_WITH(json::parse("\"\\uD7FF\\uDC00\""), + CHECK_THROWS_AS(_ = json::parse("\"\\uD7FF\\uDC00\""), json::parse_error&); + CHECK_THROWS_WITH(_ = json::parse("\"\\uD7FF\\uDC00\""), "[json.exception.parse_error.101] parse error at line 1, column 13: syntax error while parsing value - invalid string: surrogate U+DC00..U+DFFF must follow U+D800..U+DBFF; last read: '\"\\uD7FF\\uDC00'"); - CHECK_THROWS_AS(json::parse("\"\\uD800]\""), json::parse_error&); - CHECK_THROWS_WITH(json::parse("\"\\uD800]\""), + CHECK_THROWS_AS(_ = json::parse("\"\\uD800]\""), json::parse_error&); + CHECK_THROWS_WITH(_ = json::parse("\"\\uD800]\""), "[json.exception.parse_error.101] parse error at line 1, column 8: syntax error while parsing value - invalid string: surrogate U+DC00..U+DFFF must be followed by U+DC00..U+DFFF; last read: '\"\\uD800]'"); - CHECK_THROWS_AS(json::parse("\"\\uD800\\v\""), json::parse_error&); - CHECK_THROWS_WITH(json::parse("\"\\uD800\\v\""), + CHECK_THROWS_AS(_ = json::parse("\"\\uD800\\v\""), json::parse_error&); + CHECK_THROWS_WITH(_ = json::parse("\"\\uD800\\v\""), "[json.exception.parse_error.101] parse error at line 1, column 9: syntax error while parsing value - invalid string: surrogate U+DC00..U+DFFF must be followed by U+DC00..U+DFFF; last read: '\"\\uD800\\v'"); - CHECK_THROWS_AS(json::parse("\"\\uD800\\u123\""), json::parse_error&); - CHECK_THROWS_WITH(json::parse("\"\\uD800\\u123\""), + CHECK_THROWS_AS(_ = json::parse("\"\\uD800\\u123\""), json::parse_error&); + CHECK_THROWS_WITH(_ = json::parse("\"\\uD800\\u123\""), "[json.exception.parse_error.101] parse error at line 1, column 13: syntax error while parsing value - invalid string: '\\u' must be followed by 4 hex digits; last read: '\"\\uD800\\u123\"'"); - CHECK_THROWS_AS(json::parse("\"\\uD800\\uDBFF\""), json::parse_error&); - CHECK_THROWS_WITH(json::parse("\"\\uD800\\uDBFF\""), + CHECK_THROWS_AS(_ = json::parse("\"\\uD800\\uDBFF\""), json::parse_error&); + CHECK_THROWS_WITH(_ = json::parse("\"\\uD800\\uDBFF\""), "[json.exception.parse_error.101] parse error at line 1, column 13: syntax error while parsing value - invalid string: surrogate U+DC00..U+DFFF must be followed by U+DC00..U+DFFF; last read: '\"\\uD800\\uDBFF'"); - CHECK_THROWS_AS(json::parse("\"\\uD800\\uE000\""), json::parse_error&); - CHECK_THROWS_WITH(json::parse("\"\\uD800\\uE000\""), + CHECK_THROWS_AS(_ = json::parse("\"\\uD800\\uE000\""), json::parse_error&); + CHECK_THROWS_WITH(_ = json::parse("\"\\uD800\\uE000\""), "[json.exception.parse_error.101] parse error at line 1, column 13: syntax error while parsing value - invalid string: surrogate U+DC00..U+DFFF must be followed by U+DC00..U+DFFF; last read: '\"\\uD800\\uE000'"); } } @@ -1203,8 +1207,9 @@ TEST_CASE("Unicode" * doctest::skip()) SECTION("error for incomplete/wrong BOM") { - CHECK_THROWS_AS(json::parse("\xef\xbb"), json::parse_error&); - CHECK_THROWS_AS(json::parse("\xef\xbb\xbb"), json::parse_error&); + json _; + CHECK_THROWS_AS(_ = json::parse("\xef\xbb"), json::parse_error&); + CHECK_THROWS_AS(_ = json::parse("\xef\xbb\xbb"), json::parse_error&); } } @@ -1215,6 +1220,7 @@ void roundtrip(bool success_expected, const std::string& s); void roundtrip(bool success_expected, const std::string& s) { CAPTURE(s) + json _; // create JSON string value json j = s; @@ -1230,11 +1236,11 @@ void roundtrip(bool success_expected, const std::string& s) if (s[0] != '\0') { // parsing JSON text succeeds - CHECK_NOTHROW(json::parse(ps)); + CHECK_NOTHROW(_ = json::parse(ps)); } // roundtrip succeeds - CHECK_NOTHROW(json::parse(j.dump())); + CHECK_NOTHROW(_ = json::parse(j.dump())); // after roundtrip, the same string is stored json jr = json::parse(j.dump()); @@ -1246,7 +1252,7 @@ void roundtrip(bool success_expected, const std::string& s) CHECK_THROWS_AS(j.dump(), json::type_error&); // parsing JSON text fails - CHECK_THROWS_AS(json::parse(ps), json::parse_error&); + CHECK_THROWS_AS(_ = json::parse(ps), json::parse_error&); } } } diff --git a/test/src/unit-wstring.cpp b/test/src/unit-wstring.cpp index 85aa04db..59826533 100644 --- a/test/src/unit-wstring.cpp +++ b/test/src/unit-wstring.cpp @@ -70,7 +70,8 @@ TEST_CASE("wide strings") if (wstring_is_utf16()) { std::wstring w = L"\"\xDBFF"; - CHECK_THROWS_AS(json::parse(w), json::parse_error&); + json _; + CHECK_THROWS_AS(_ = json::parse(w), json::parse_error&); } } @@ -89,7 +90,8 @@ TEST_CASE("wide strings") if (wstring_is_utf16()) { std::u16string w = u"\"\xDBFF"; - CHECK_THROWS_AS(json::parse(w), json::parse_error&); + json _; + CHECK_THROWS_AS(_ = json::parse(w), json::parse_error&); } } @@ -108,7 +110,8 @@ TEST_CASE("wide strings") if (u32string_is_utf32()) { std::u32string w = U"\"\x110000"; - CHECK_THROWS_AS(json::parse(w), json::parse_error&); + json _; + CHECK_THROWS_AS(_ = json::parse(w), json::parse_error&); } } } From 24fa285edbca7689fa2a9f28a964d1e803a0a635 Mon Sep 17 00:00:00 2001 From: Niels Lohmann Date: Tue, 2 Jul 2019 21:15:52 +0200 Subject: [PATCH 093/106] :memo: remove HEDLEY annotation from documentation --- doc/Makefile | 2 ++ 1 file changed, 2 insertions(+) diff --git a/doc/Makefile b/doc/Makefile index c255f972..07e417c1 100644 --- a/doc/Makefile +++ b/doc/Makefile @@ -61,6 +61,8 @@ doxygen: create_output create_links $(SED) -i 's@template<template< typename U, typename V, typename... Args > class ObjectType = std::map, template< typename U, typename... Args > 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< typename U > class AllocatorType = std::allocator, template< typename T, typename SFINAE=void > class JSONSerializer = adl_serializer>@@g' html/*.html $(SED) -i 's@< ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer >@@g' html/*.html $(SED) -i 's@< ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer >@@g' html/*.html + $(SED) -i 's@JSON_HEDLEY_RETURNS_NON_NULL@@g' html/*.html + $(SED) -i 's@JSON_HEDLEY_WARN_UNUSED_RESULT@@g' html/*.html upload: clean doxygen check_output scripts/git-update-ghpages nlohmann/json html From b17440c12f9083d08f6d25d206a9e50aee1e869b Mon Sep 17 00:00:00 2001 From: Niels Lohmann Date: Fri, 12 Jul 2019 21:05:16 +0200 Subject: [PATCH 094/106] :rotating_light: fix compiler warnings --- .../nlohmann/detail/iterators/iter_impl.hpp | 15 +++++++++++- .../nlohmann/detail/output/binary_writer.hpp | 8 +++---- single_include/nlohmann/json.hpp | 23 +++++++++++++++---- test/src/unit-regression.cpp | 2 +- 4 files changed, 37 insertions(+), 11 deletions(-) diff --git a/include/nlohmann/detail/iterators/iter_impl.hpp b/include/nlohmann/detail/iterators/iter_impl.hpp index bc87de29..f365d181 100644 --- a/include/nlohmann/detail/iterators/iter_impl.hpp +++ b/include/nlohmann/detail/iterators/iter_impl.hpp @@ -128,6 +128,19 @@ class iter_impl iter_impl(const iter_impl& other) noexcept : m_object(other.m_object), m_it(other.m_it) {} + /*! + @brief converting assignment + @param[in] other const iterator to copy from + @return const/non-const iterator + @note It is not checked whether @a other is initialized. + */ + iter_impl& operator=(const iter_impl& other) noexcept + { + m_object = other.m_object; + m_it = other.m_it; + return *this; + } + /*! @brief converting constructor @param[in] other non-const iterator to copy from @@ -138,7 +151,7 @@ class iter_impl /*! @brief converting assignment - @param[in,out] other non-const iterator to copy from + @param[in] other non-const iterator to copy from @return const/non-const iterator @note It is not checked whether @a other is initialized. */ diff --git a/include/nlohmann/detail/output/binary_writer.hpp b/include/nlohmann/detail/output/binary_writer.hpp index a8fddfee..f52b7787 100644 --- a/include/nlohmann/detail/output/binary_writer.hpp +++ b/include/nlohmann/detail/output/binary_writer.hpp @@ -1204,19 +1204,19 @@ class binary_writer case value_t::number_unsigned: { - if (j.m_value.number_unsigned <= (std::numeric_limits::max)()) + if (j.m_value.number_unsigned <= static_cast((std::numeric_limits::max)())) { return 'i'; } - if (j.m_value.number_unsigned <= (std::numeric_limits::max)()) + if (j.m_value.number_unsigned <= static_cast((std::numeric_limits::max)())) { return 'U'; } - if (j.m_value.number_unsigned <= (std::numeric_limits::max)()) + if (j.m_value.number_unsigned <= static_cast((std::numeric_limits::max)())) { return 'I'; } - if (j.m_value.number_unsigned <= (std::numeric_limits::max)()) + if (j.m_value.number_unsigned <= static_cast((std::numeric_limits::max)())) { return 'l'; } diff --git a/single_include/nlohmann/json.hpp b/single_include/nlohmann/json.hpp index 65989e02..76ae3b1d 100644 --- a/single_include/nlohmann/json.hpp +++ b/single_include/nlohmann/json.hpp @@ -7831,6 +7831,19 @@ class iter_impl iter_impl(const iter_impl& other) noexcept : m_object(other.m_object), m_it(other.m_it) {} + /*! + @brief converting assignment + @param[in] other const iterator to copy from + @return const/non-const iterator + @note It is not checked whether @a other is initialized. + */ + iter_impl& operator=(const iter_impl& other) noexcept + { + m_object = other.m_object; + m_it = other.m_it; + return *this; + } + /*! @brief converting constructor @param[in] other non-const iterator to copy from @@ -7841,7 +7854,7 @@ class iter_impl /*! @brief converting assignment - @param[in,out] other non-const iterator to copy from + @param[in] other non-const iterator to copy from @return const/non-const iterator @note It is not checked whether @a other is initialized. */ @@ -10872,19 +10885,19 @@ class binary_writer case value_t::number_unsigned: { - if (j.m_value.number_unsigned <= (std::numeric_limits::max)()) + if (j.m_value.number_unsigned <= static_cast((std::numeric_limits::max)())) { return 'i'; } - if (j.m_value.number_unsigned <= (std::numeric_limits::max)()) + if (j.m_value.number_unsigned <= static_cast((std::numeric_limits::max)())) { return 'U'; } - if (j.m_value.number_unsigned <= (std::numeric_limits::max)()) + if (j.m_value.number_unsigned <= static_cast((std::numeric_limits::max)())) { return 'I'; } - if (j.m_value.number_unsigned <= (std::numeric_limits::max)()) + if (j.m_value.number_unsigned <= static_cast((std::numeric_limits::max)())) { return 'l'; } diff --git a/test/src/unit-regression.cpp b/test/src/unit-regression.cpp index 7836b656..4ac9e5ee 100644 --- a/test/src/unit-regression.cpp +++ b/test/src/unit-regression.cpp @@ -1808,4 +1808,4 @@ template class object {}; template class string {}; template class number_integer {}; template class number_unsigned {}; -template class number_float {}; \ No newline at end of file +template class number_float {}; From 6a3cdb281ec2c92b1481427e1789420335a80ad2 Mon Sep 17 00:00:00 2001 From: Konstantin Podsvirov Date: Fri, 12 Jul 2019 22:27:17 +0300 Subject: [PATCH 095/106] Package Manager: MSYS2 (pacman) Add a package installation instructions for MSYS2 software distro. --- README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.md b/README.md index 9ebd0789..3586ac78 100644 --- a/README.md +++ b/README.md @@ -172,6 +172,8 @@ If you are using [NuGet](https://www.nuget.org), you can use the package [nlohma If you are using [conda](https://conda.io/), you can use the package [nlohmann_json](https://github.com/conda-forge/nlohmann_json-feedstock) from [conda-forge](https://conda-forge.org) executing `conda install -c conda-forge nlohmann_json`. Please file issues [here](https://github.com/conda-forge/nlohmann_json-feedstock/issues). +If you are using [MSYS2](http://www.msys2.org/), your can use the [mingw-w64-nlohmann_json](https://packages.msys2.org/base/mingw-w64-nlohmann_json) package, just type `pacman -S mingw-w64-i686-nlohmann_json` or `pacman -S mingw-w64-x86_64-nlohmann_json` for installation. Please file issues [here](https://github.com/msys2/MINGW-packages/issues/new?title=%5Bnlohmann_json%5D) if you experience problems with the packages. + ## Examples Beside the examples below, you may want to check the [documentation](https://nlohmann.github.io/json/) where each function contains a separate code example (e.g., check out [`emplace()`](https://nlohmann.github.io/json/classnlohmann_1_1basic__json_a5338e282d1d02bed389d852dd670d98d.html#a5338e282d1d02bed389d852dd670d98d)). All [example files](https://github.com/nlohmann/json/tree/develop/doc/examples) can be compiled and executed on their own (e.g., file [emplace.cpp](https://github.com/nlohmann/json/blob/develop/doc/examples/emplace.cpp)). @@ -1259,6 +1261,7 @@ I deeply appreciate the help of the following people. - [Hani](https://github.com/hnkb) documented how to install the library with NuGet. - [Mark Beckwith](https://github.com/wythe) fixed a typo. - [yann-morin-1998](https://github.com/yann-morin-1998) helped reducing the CMake requirement to version 3.1. +- [Konstantin Podsvirov](https://github.com/podsvirov) maintains a package for the MSYS2 software distro. Thanks a lot for helping out! Please [let me know](mailto:mail@nlohmann.me) if I forgot someone. From cf8251eb544dcaba780b12a1da90afb791d31395 Mon Sep 17 00:00:00 2001 From: Niels Lohmann Date: Sun, 14 Jul 2019 21:19:55 +0200 Subject: [PATCH 096/106] :ambulance: fix compiler errors --- include/nlohmann/detail/iterators/iter_impl.hpp | 8 -------- include/nlohmann/detail/json_pointer.hpp | 4 ++-- single_include/nlohmann/json.hpp | 12 ++---------- 3 files changed, 4 insertions(+), 20 deletions(-) diff --git a/include/nlohmann/detail/iterators/iter_impl.hpp b/include/nlohmann/detail/iterators/iter_impl.hpp index 97d3cc9c..336aba1a 100644 --- a/include/nlohmann/detail/iterators/iter_impl.hpp +++ b/include/nlohmann/detail/iterators/iter_impl.hpp @@ -164,14 +164,6 @@ class iter_impl return *this; } - /// @copydoc operator=(const iter_impl::type>&) - iter_impl& operator=(const iter_impl& other) noexcept - { - m_object = other.m_object; - m_it = other.m_it; - return *this; - } - private: /*! @brief set the iterator to the first value diff --git a/include/nlohmann/detail/json_pointer.hpp b/include/nlohmann/detail/json_pointer.hpp index ec7d7f72..9076441c 100644 --- a/include/nlohmann/detail/json_pointer.hpp +++ b/include/nlohmann/detail/json_pointer.hpp @@ -718,14 +718,14 @@ class json_pointer case detail::value_t::array: { - if (JSON_UNLIKELY(reference_token == "-")) + if (JSON_HEDLEY_UNLIKELY(reference_token == "-")) { // "-" always fails the range check return false; } // error condition (cf. RFC 6901, Sect. 4) - if (JSON_UNLIKELY(reference_token.size() > 1 and reference_token[0] == '0')) + if (JSON_HEDLEY_UNLIKELY(reference_token.size() > 1 and reference_token[0] == '0')) { JSON_THROW(detail::parse_error::create(106, 0, "array index '" + reference_token + diff --git a/single_include/nlohmann/json.hpp b/single_include/nlohmann/json.hpp index b785314e..c2128dcc 100644 --- a/single_include/nlohmann/json.hpp +++ b/single_include/nlohmann/json.hpp @@ -9363,14 +9363,6 @@ class iter_impl return *this; } - /// @copydoc operator=(const iter_impl::type>&) - iter_impl& operator=(const iter_impl& other) noexcept - { - m_object = other.m_object; - m_it = other.m_it; - return *this; - } - private: /*! @brief set the iterator to the first value @@ -10693,14 +10685,14 @@ class json_pointer case detail::value_t::array: { - if (JSON_UNLIKELY(reference_token == "-")) + if (JSON_HEDLEY_UNLIKELY(reference_token == "-")) { // "-" always fails the range check return false; } // error condition (cf. RFC 6901, Sect. 4) - if (JSON_UNLIKELY(reference_token.size() > 1 and reference_token[0] == '0')) + if (JSON_HEDLEY_UNLIKELY(reference_token.size() > 1 and reference_token[0] == '0')) { JSON_THROW(detail::parse_error::create(106, 0, "array index '" + reference_token + From 3184e9bd8b5ba957f212399f3eb3c84213a18d62 Mon Sep 17 00:00:00 2001 From: Tommy Nguyen Date: Tue, 16 Jul 2019 11:44:32 -0400 Subject: [PATCH 097/106] Use GNUInstallDirs instead of hard-coded path. --- CMakeLists.txt | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 1b0bca9f..5796610f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -22,9 +22,11 @@ option(JSON_MultipleHeaders "Use non-amalgamated version of the library." OFF) ## ## CONFIGURATION ## +include(GNUInstallDirs) + set(NLOHMANN_JSON_TARGET_NAME ${PROJECT_NAME}) -set(NLOHMANN_JSON_CONFIG_INSTALL_DIR "lib/cmake/${PROJECT_NAME}" CACHE INTERNAL "") -set(NLOHMANN_JSON_INCLUDE_INSTALL_DIR "include") +set(NLOHMANN_JSON_CONFIG_INSTALL_DIR "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}" CACHE INTERNAL "") +set(NLOHMANN_JSON_INCLUDE_INSTALL_DIR "${CMAKE_INSTALL_INCLUDEDIR}") set(NLOHMANN_JSON_TARGETS_EXPORT_NAME "${PROJECT_NAME}Targets") set(NLOHMANN_JSON_CMAKE_CONFIG_TEMPLATE "cmake/config.cmake.in") set(NLOHMANN_JSON_CMAKE_CONFIG_DIR "${CMAKE_CURRENT_BINARY_DIR}") From 323cf95d8c0df889f60ba50a18ab50b1c2b238e0 Mon Sep 17 00:00:00 2001 From: Niels Lohmann Date: Sun, 21 Jul 2019 14:04:49 +0200 Subject: [PATCH 098/106] :rotating_light: fix linter warning --- include/nlohmann/detail/input/binary_reader.hpp | 11 +++-------- single_include/nlohmann/json.hpp | 11 +++-------- 2 files changed, 6 insertions(+), 16 deletions(-) diff --git a/include/nlohmann/detail/input/binary_reader.hpp b/include/nlohmann/detail/input/binary_reader.hpp index e44249ea..22dc55d8 100644 --- a/include/nlohmann/detail/input/binary_reader.hpp +++ b/include/nlohmann/detail/input/binary_reader.hpp @@ -1083,6 +1083,9 @@ class binary_reader case 0xBD: case 0xBE: case 0xBF: + case 0xD9: // str 8 + case 0xDA: // str 16 + case 0xDB: // str 32 { string_t s; return get_msgpack_string(s) and sax->string(s); @@ -1157,14 +1160,6 @@ class binary_reader return get_number(input_format_t::msgpack, number) and sax->number_integer(number); } - case 0xD9: // str 8 - case 0xDA: // str 16 - case 0xDB: // str 32 - { - string_t s; - return get_msgpack_string(s) and sax->string(s); - } - case 0xDC: // array 16 { std::uint16_t len; diff --git a/single_include/nlohmann/json.hpp b/single_include/nlohmann/json.hpp index c2128dcc..c19b43c7 100644 --- a/single_include/nlohmann/json.hpp +++ b/single_include/nlohmann/json.hpp @@ -6111,6 +6111,9 @@ class binary_reader case 0xBD: case 0xBE: case 0xBF: + case 0xD9: // str 8 + case 0xDA: // str 16 + case 0xDB: // str 32 { string_t s; return get_msgpack_string(s) and sax->string(s); @@ -6185,14 +6188,6 @@ class binary_reader return get_number(input_format_t::msgpack, number) and sax->number_integer(number); } - case 0xD9: // str 8 - case 0xDA: // str 16 - case 0xDB: // str 32 - { - string_t s; - return get_msgpack_string(s) and sax->string(s); - } - case 0xDC: // array 16 { std::uint16_t len; From 65e4b973bdc04420335f6e76950f53632ed903c2 Mon Sep 17 00:00:00 2001 From: Niels Lohmann Date: Sun, 21 Jul 2019 14:10:37 +0200 Subject: [PATCH 099/106] :fire: remove leftover file --- hedley.h | 1505 ------------------------------------------------------ 1 file changed, 1505 deletions(-) delete mode 100644 hedley.h diff --git a/hedley.h b/hedley.h deleted file mode 100644 index d20c2297..00000000 --- a/hedley.h +++ /dev/null @@ -1,1505 +0,0 @@ -/* Hedley - https://nemequ.github.io/hedley - * Created by Evan Nemerson - * - * To the extent possible under law, the author(s) have dedicated all - * copyright and related and neighboring rights to this software to - * the public domain worldwide. This software is distributed without - * any warranty. - * - * For details, see . - * SPDX-License-Identifier: CC0-1.0 - */ - -#if !defined(HEDLEY_VERSION) || (HEDLEY_VERSION < 9) -#if defined(HEDLEY_VERSION) -# undef HEDLEY_VERSION -#endif -#define HEDLEY_VERSION 9 - -#if defined(HEDLEY_STRINGIFY_EX) -# undef HEDLEY_STRINGIFY_EX -#endif -#define HEDLEY_STRINGIFY_EX(x) #x - -#if defined(HEDLEY_STRINGIFY) -# undef HEDLEY_STRINGIFY -#endif -#define HEDLEY_STRINGIFY(x) HEDLEY_STRINGIFY_EX(x) - -#if defined(HEDLEY_CONCAT_EX) -# undef HEDLEY_CONCAT_EX -#endif -#define HEDLEY_CONCAT_EX(a,b) a##b - -#if defined(HEDLEY_CONCAT) -# undef HEDLEY_CONCAT -#endif -#define HEDLEY_CONCAT(a,b) HEDLEY_CONCAT_EX(a,b) - -#if defined(HEDLEY_VERSION_ENCODE) -# undef HEDLEY_VERSION_ENCODE -#endif -#define HEDLEY_VERSION_ENCODE(major,minor,revision) (((major) * 1000000) + ((minor) * 1000) + (revision)) - -#if defined(HEDLEY_VERSION_DECODE_MAJOR) -# undef HEDLEY_VERSION_DECODE_MAJOR -#endif -#define HEDLEY_VERSION_DECODE_MAJOR(version) ((version) / 1000000) - -#if defined(HEDLEY_VERSION_DECODE_MINOR) -# undef HEDLEY_VERSION_DECODE_MINOR -#endif -#define HEDLEY_VERSION_DECODE_MINOR(version) (((version) % 1000000) / 1000) - -#if defined(HEDLEY_VERSION_DECODE_REVISION) -# undef HEDLEY_VERSION_DECODE_REVISION -#endif -#define HEDLEY_VERSION_DECODE_REVISION(version) ((version) % 1000) - -#if defined(HEDLEY_GNUC_VERSION) -# undef HEDLEY_GNUC_VERSION -#endif -#if defined(__GNUC__) && defined(__GNUC_PATCHLEVEL__) -# define HEDLEY_GNUC_VERSION HEDLEY_VERSION_ENCODE(__GNUC__, __GNUC_MINOR__, __GNUC_PATCHLEVEL__) -#elif defined(__GNUC__) -# define HEDLEY_GNUC_VERSION HEDLEY_VERSION_ENCODE(__GNUC__, __GNUC_MINOR__, 0) -#endif - -#if defined(HEDLEY_GNUC_VERSION_CHECK) -# undef HEDLEY_GNUC_VERSION_CHECK -#endif -#if defined(HEDLEY_GNUC_VERSION) -# define HEDLEY_GNUC_VERSION_CHECK(major,minor,patch) (HEDLEY_GNUC_VERSION >= HEDLEY_VERSION_ENCODE(major, minor, patch)) -#else -# define HEDLEY_GNUC_VERSION_CHECK(major,minor,patch) (0) -#endif - -#if defined(HEDLEY_MSVC_VERSION) -# undef HEDLEY_MSVC_VERSION -#endif -#if defined(_MSC_FULL_VER) && (_MSC_FULL_VER >= 140000000) -# define HEDLEY_MSVC_VERSION HEDLEY_VERSION_ENCODE(_MSC_FULL_VER / 10000000, (_MSC_FULL_VER % 10000000) / 100000, (_MSC_FULL_VER % 100000) / 100) -#elif defined(_MSC_FULL_VER) -# define HEDLEY_MSVC_VERSION HEDLEY_VERSION_ENCODE(_MSC_FULL_VER / 1000000, (_MSC_FULL_VER % 1000000) / 10000, (_MSC_FULL_VER % 10000) / 10) -#elif defined(_MSC_VER) -# define HEDLEY_MSVC_VERSION HEDLEY_VERSION_ENCODE(_MSC_VER / 100, _MSC_VER % 100, 0) -#endif - -#if defined(HEDLEY_MSVC_VERSION_CHECK) -# undef HEDLEY_MSVC_VERSION_CHECK -#endif -#if !defined(_MSC_VER) -# define HEDLEY_MSVC_VERSION_CHECK(major,minor,patch) (0) -#elif defined(_MSC_VER) && (_MSC_VER >= 1400) -# define HEDLEY_MSVC_VERSION_CHECK(major,minor,patch) (_MSC_FULL_VER >= ((major * 10000000) + (minor * 100000) + (patch))) -#elif defined(_MSC_VER) && (_MSC_VER >= 1200) -# define HEDLEY_MSVC_VERSION_CHECK(major,minor,patch) (_MSC_FULL_VER >= ((major * 1000000) + (minor * 10000) + (patch))) -#else -# define HEDLEY_MSVC_VERSION_CHECK(major,minor,patch) (_MSC_VER >= ((major * 100) + (minor))) -#endif - -#if defined(HEDLEY_INTEL_VERSION) -# undef HEDLEY_INTEL_VERSION -#endif -#if defined(__INTEL_COMPILER) && defined(__INTEL_COMPILER_UPDATE) -# define HEDLEY_INTEL_VERSION HEDLEY_VERSION_ENCODE(__INTEL_COMPILER / 100, __INTEL_COMPILER % 100, __INTEL_COMPILER_UPDATE) -#elif defined(__INTEL_COMPILER) -# define HEDLEY_INTEL_VERSION HEDLEY_VERSION_ENCODE(__INTEL_COMPILER / 100, __INTEL_COMPILER % 100, 0) -#endif - -#if defined(HEDLEY_INTEL_VERSION_CHECK) -# undef HEDLEY_INTEL_VERSION_CHECK -#endif -#if defined(HEDLEY_INTEL_VERSION) -# define HEDLEY_INTEL_VERSION_CHECK(major,minor,patch) (HEDLEY_INTEL_VERSION >= HEDLEY_VERSION_ENCODE(major, minor, patch)) -#else -# define HEDLEY_INTEL_VERSION_CHECK(major,minor,patch) (0) -#endif - -#if defined(HEDLEY_PGI_VERSION) -# undef HEDLEY_PGI_VERSION -#endif -#if defined(__PGI) && defined(__PGIC__) && defined(__PGIC_MINOR__) && defined(__PGIC_PATCHLEVEL__) -# define HEDLEY_PGI_VERSION HEDLEY_VERSION_ENCODE(__PGIC__, __PGIC_MINOR__, __PGIC_PATCHLEVEL__) -#endif - -#if defined(HEDLEY_PGI_VERSION_CHECK) -# undef HEDLEY_PGI_VERSION_CHECK -#endif -#if defined(HEDLEY_PGI_VERSION) -# define HEDLEY_PGI_VERSION_CHECK(major,minor,patch) (HEDLEY_PGI_VERSION >= HEDLEY_VERSION_ENCODE(major, minor, patch)) -#else -# define HEDLEY_PGI_VERSION_CHECK(major,minor,patch) (0) -#endif - -#if defined(HEDLEY_SUNPRO_VERSION) -# undef HEDLEY_SUNPRO_VERSION -#endif -#if defined(__SUNPRO_C) && (__SUNPRO_C > 0x1000) -# define HEDLEY_SUNPRO_VERSION HEDLEY_VERSION_ENCODE((((__SUNPRO_C >> 16) & 0xf) * 10) + ((__SUNPRO_C >> 12) & 0xf), (((__SUNPRO_C >> 8) & 0xf) * 10) + ((__SUNPRO_C >> 4) & 0xf), (__SUNPRO_C & 0xf) * 10) -#elif defined(__SUNPRO_C) -# define HEDLEY_SUNPRO_VERSION HEDLEY_VERSION_ENCODE((__SUNPRO_C >> 8) & 0xf, (__SUNPRO_C >> 4) & 0xf, (__SUNPRO_C) & 0xf) -#elif defined(__SUNPRO_CC) && (__SUNPRO_CC > 0x1000) -# define HEDLEY_SUNPRO_VERSION HEDLEY_VERSION_ENCODE((((__SUNPRO_CC >> 16) & 0xf) * 10) + ((__SUNPRO_CC >> 12) & 0xf), (((__SUNPRO_CC >> 8) & 0xf) * 10) + ((__SUNPRO_CC >> 4) & 0xf), (__SUNPRO_CC & 0xf) * 10) -#elif defined(__SUNPRO_CC) -# define HEDLEY_SUNPRO_VERSION HEDLEY_VERSION_ENCODE((__SUNPRO_CC >> 8) & 0xf, (__SUNPRO_CC >> 4) & 0xf, (__SUNPRO_CC) & 0xf) -#endif - -#if defined(HEDLEY_SUNPRO_VERSION_CHECK) -# undef HEDLEY_SUNPRO_VERSION_CHECK -#endif -#if defined(HEDLEY_SUNPRO_VERSION) -# define HEDLEY_SUNPRO_VERSION_CHECK(major,minor,patch) (HEDLEY_SUNPRO_VERSION >= HEDLEY_VERSION_ENCODE(major, minor, patch)) -#else -# define HEDLEY_SUNPRO_VERSION_CHECK(major,minor,patch) (0) -#endif - -#if defined(HEDLEY_EMSCRIPTEN_VERSION) -# undef HEDLEY_EMSCRIPTEN_VERSION -#endif -#if defined(__EMSCRIPTEN__) -# define HEDLEY_EMSCRIPTEN_VERSION HEDLEY_VERSION_ENCODE(__EMSCRIPTEN_major__, __EMSCRIPTEN_minor__, __EMSCRIPTEN_tiny__) -#endif - -#if defined(HEDLEY_EMSCRIPTEN_VERSION_CHECK) -# undef HEDLEY_EMSCRIPTEN_VERSION_CHECK -#endif -#if defined(HEDLEY_EMSCRIPTEN_VERSION) -# define HEDLEY_EMSCRIPTEN_VERSION_CHECK(major,minor,patch) (HEDLEY_EMSCRIPTEN_VERSION >= HEDLEY_VERSION_ENCODE(major, minor, patch)) -#else -# define HEDLEY_EMSCRIPTEN_VERSION_CHECK(major,minor,patch) (0) -#endif - -#if defined(HEDLEY_ARM_VERSION) -# undef HEDLEY_ARM_VERSION -#endif -#if defined(__CC_ARM) && defined(__ARMCOMPILER_VERSION) -# define HEDLEY_ARM_VERSION HEDLEY_VERSION_ENCODE(__ARMCOMPILER_VERSION / 1000000, (__ARMCOMPILER_VERSION % 1000000) / 10000, (__ARMCOMPILER_VERSION % 10000) / 100) -#elif defined(__CC_ARM) && defined(__ARMCC_VERSION) -# define HEDLEY_ARM_VERSION HEDLEY_VERSION_ENCODE(__ARMCC_VERSION / 1000000, (__ARMCC_VERSION % 1000000) / 10000, (__ARMCC_VERSION % 10000) / 100) -#endif - -#if defined(HEDLEY_ARM_VERSION_CHECK) -# undef HEDLEY_ARM_VERSION_CHECK -#endif -#if defined(HEDLEY_ARM_VERSION) -# define HEDLEY_ARM_VERSION_CHECK(major,minor,patch) (HEDLEY_ARM_VERSION >= HEDLEY_VERSION_ENCODE(major, minor, patch)) -#else -# define HEDLEY_ARM_VERSION_CHECK(major,minor,patch) (0) -#endif - -#if defined(HEDLEY_IBM_VERSION) -# undef HEDLEY_IBM_VERSION -#endif -#if defined(__ibmxl__) -# define HEDLEY_IBM_VERSION HEDLEY_VERSION_ENCODE(__ibmxl_version__, __ibmxl_release__, __ibmxl_modification__) -#elif defined(__xlC__) && defined(__xlC_ver__) -# define HEDLEY_IBM_VERSION HEDLEY_VERSION_ENCODE(__xlC__ >> 8, __xlC__ & 0xff, (__xlC_ver__ >> 8) & 0xff) -#elif defined(__xlC__) -# define HEDLEY_IBM_VERSION HEDLEY_VERSION_ENCODE(__xlC__ >> 8, __xlC__ & 0xff, 0) -#endif - -#if defined(HEDLEY_IBM_VERSION_CHECK) -# undef HEDLEY_IBM_VERSION_CHECK -#endif -#if defined(HEDLEY_IBM_VERSION) -# define HEDLEY_IBM_VERSION_CHECK(major,minor,patch) (HEDLEY_IBM_VERSION >= HEDLEY_VERSION_ENCODE(major, minor, patch)) -#else -# define HEDLEY_IBM_VERSION_CHECK(major,minor,patch) (0) -#endif - -#if defined(HEDLEY_TI_VERSION) -# undef HEDLEY_TI_VERSION -#endif -#if defined(__TI_COMPILER_VERSION__) -# define HEDLEY_TI_VERSION HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000)) -#endif - -#if defined(HEDLEY_TI_VERSION_CHECK) -# undef HEDLEY_TI_VERSION_CHECK -#endif -#if defined(HEDLEY_TI_VERSION) -# define HEDLEY_TI_VERSION_CHECK(major,minor,patch) (HEDLEY_TI_VERSION >= HEDLEY_VERSION_ENCODE(major, minor, patch)) -#else -# define HEDLEY_TI_VERSION_CHECK(major,minor,patch) (0) -#endif - -#if defined(HEDLEY_CRAY_VERSION) -# undef HEDLEY_CRAY_VERSION -#endif -#if defined(_CRAYC) -# if defined(_RELEASE_PATCHLEVEL) -# define HEDLEY_CRAY_VERSION HEDLEY_VERSION_ENCODE(_RELEASE_MAJOR, _RELEASE_MINOR, _RELEASE_PATCHLEVEL) -# else -# define HEDLEY_CRAY_VERSION HEDLEY_VERSION_ENCODE(_RELEASE_MAJOR, _RELEASE_MINOR, 0) -# endif -#endif - -#if defined(HEDLEY_CRAY_VERSION_CHECK) -# undef HEDLEY_CRAY_VERSION_CHECK -#endif -#if defined(HEDLEY_CRAY_VERSION) -# define HEDLEY_CRAY_VERSION_CHECK(major,minor,patch) (HEDLEY_CRAY_VERSION >= HEDLEY_VERSION_ENCODE(major, minor, patch)) -#else -# define HEDLEY_CRAY_VERSION_CHECK(major,minor,patch) (0) -#endif - -#if defined(HEDLEY_IAR_VERSION) -# undef HEDLEY_IAR_VERSION -#endif -#if defined(__IAR_SYSTEMS_ICC__) -# if __VER__ > 1000 -# define HEDLEY_IAR_VERSION HEDLEY_VERSION_ENCODE((__VER__ / 1000000), ((__VER__ / 1000) % 1000), (__VER__ % 1000)) -# else -# define HEDLEY_IAR_VERSION HEDLEY_VERSION_ENCODE(VER / 100, __VER__ % 100, 0) -# endif -#endif - -#if defined(HEDLEY_IAR_VERSION_CHECK) -# undef HEDLEY_IAR_VERSION_CHECK -#endif -#if defined(HEDLEY_IAR_VERSION) -# define HEDLEY_IAR_VERSION_CHECK(major,minor,patch) (HEDLEY_IAR_VERSION >= HEDLEY_VERSION_ENCODE(major, minor, patch)) -#else -# define HEDLEY_IAR_VERSION_CHECK(major,minor,patch) (0) -#endif - -#if defined(HEDLEY_TINYC_VERSION) -# undef HEDLEY_TINYC_VERSION -#endif -#if defined(__TINYC__) -# define HEDLEY_TINYC_VERSION HEDLEY_VERSION_ENCODE(__TINYC__ / 1000, (__TINYC__ / 100) % 10, __TINYC__ % 100) -#endif - -#if defined(HEDLEY_TINYC_VERSION_CHECK) -# undef HEDLEY_TINYC_VERSION_CHECK -#endif -#if defined(HEDLEY_TINYC_VERSION) -# define HEDLEY_TINYC_VERSION_CHECK(major,minor,patch) (HEDLEY_TINYC_VERSION >= HEDLEY_VERSION_ENCODE(major, minor, patch)) -#else -# define HEDLEY_TINYC_VERSION_CHECK(major,minor,patch) (0) -#endif - -#if defined(HEDLEY_DMC_VERSION) -# undef HEDLEY_DMC_VERSION -#endif -#if defined(__DMC__) -# define HEDLEY_DMC_VERSION HEDLEY_VERSION_ENCODE(__DMC__ >> 8, (__DMC__ >> 4) & 0xf, __DMC__ & 0xf) -#endif - -#if defined(HEDLEY_DMC_VERSION_CHECK) -# undef HEDLEY_DMC_VERSION_CHECK -#endif -#if defined(HEDLEY_DMC_VERSION) -# define HEDLEY_DMC_VERSION_CHECK(major,minor,patch) (HEDLEY_DMC_VERSION >= HEDLEY_VERSION_ENCODE(major, minor, patch)) -#else -# define HEDLEY_DMC_VERSION_CHECK(major,minor,patch) (0) -#endif - -#if defined(HEDLEY_COMPCERT_VERSION) -# undef HEDLEY_COMPCERT_VERSION -#endif -#if defined(__COMPCERT_VERSION__) -# define HEDLEY_COMPCERT_VERSION HEDLEY_VERSION_ENCODE(__COMPCERT_VERSION__ / 10000, (__COMPCERT_VERSION__ / 100) % 100, __COMPCERT_VERSION__ % 100) -#endif - -#if defined(HEDLEY_COMPCERT_VERSION_CHECK) -# undef HEDLEY_COMPCERT_VERSION_CHECK -#endif -#if defined(HEDLEY_COMPCERT_VERSION) -# define HEDLEY_COMPCERT_VERSION_CHECK(major,minor,patch) (HEDLEY_COMPCERT_VERSION >= HEDLEY_VERSION_ENCODE(major, minor, patch)) -#else -# define HEDLEY_COMPCERT_VERSION_CHECK(major,minor,patch) (0) -#endif - -#if defined(HEDLEY_PELLES_VERSION) -# undef HEDLEY_PELLES_VERSION -#endif -#if defined(__POCC__) -# define HEDLEY_PELLES_VERSION HEDLEY_VERSION_ENCODE(__POCC__ / 100, __POCC__ % 100, 0) -#endif - -#if defined(HEDLEY_PELLES_VERSION_CHECK) -# undef HEDLEY_PELLES_VERSION_CHECK -#endif -#if defined(HEDLEY_PELLES_VERSION) -# define HEDLEY_PELLES_VERSION_CHECK(major,minor,patch) (HEDLEY_PELLES_VERSION >= HEDLEY_VERSION_ENCODE(major, minor, patch)) -#else -# define HEDLEY_PELLES_VERSION_CHECK(major,minor,patch) (0) -#endif - -#if defined(HEDLEY_GCC_VERSION) -# undef HEDLEY_GCC_VERSION -#endif -#if \ - defined(HEDLEY_GNUC_VERSION) && \ - !defined(__clang__) && \ - !defined(HEDLEY_INTEL_VERSION) && \ - !defined(HEDLEY_PGI_VERSION) && \ - !defined(HEDLEY_ARM_VERSION) && \ - !defined(HEDLEY_TI_VERSION) && \ - !defined(__COMPCERT__) -# define HEDLEY_GCC_VERSION HEDLEY_GNUC_VERSION -#endif - -#if defined(HEDLEY_GCC_VERSION_CHECK) -# undef HEDLEY_GCC_VERSION_CHECK -#endif -#if defined(HEDLEY_GCC_VERSION) -# define HEDLEY_GCC_VERSION_CHECK(major,minor,patch) (HEDLEY_GCC_VERSION >= HEDLEY_VERSION_ENCODE(major, minor, patch)) -#else -# define HEDLEY_GCC_VERSION_CHECK(major,minor,patch) (0) -#endif - -#if defined(HEDLEY_HAS_ATTRIBUTE) -# undef HEDLEY_HAS_ATTRIBUTE -#endif -#if defined(__has_attribute) -# define HEDLEY_HAS_ATTRIBUTE(attribute) __has_attribute(attribute) -#else -# define HEDLEY_HAS_ATTRIBUTE(attribute) (0) -#endif - -#if defined(HEDLEY_GNUC_HAS_ATTRIBUTE) -# undef HEDLEY_GNUC_HAS_ATTRIBUTE -#endif -#if defined(__has_attribute) -# define HEDLEY_GNUC_HAS_ATTRIBUTE(attribute,major,minor,patch) __has_attribute(attribute) -#else -# define HEDLEY_GNUC_HAS_ATTRIBUTE(attribute,major,minor,patch) HEDLEY_GNUC_VERSION_CHECK(major,minor,patch) -#endif - -#if defined(HEDLEY_GCC_HAS_ATTRIBUTE) -# undef HEDLEY_GCC_HAS_ATTRIBUTE -#endif -#if defined(__has_attribute) -# define HEDLEY_GCC_HAS_ATTRIBUTE(attribute,major,minor,patch) __has_attribute(attribute) -#else -# define HEDLEY_GCC_HAS_ATTRIBUTE(attribute,major,minor,patch) HEDLEY_GCC_VERSION_CHECK(major,minor,patch) -#endif - -#if defined(HEDLEY_HAS_CPP_ATTRIBUTE) -# undef HEDLEY_HAS_CPP_ATTRIBUTE -#endif -#if defined(__has_cpp_attribute) && defined(__cplusplus) -# define HEDLEY_HAS_CPP_ATTRIBUTE(attribute) __has_cpp_attribute(attribute) -#else -# define HEDLEY_HAS_CPP_ATTRIBUTE(attribute) (0) -#endif - -#if defined(HEDLEY_GNUC_HAS_CPP_ATTRIBUTE) -# undef HEDLEY_GNUC_HAS_CPP_ATTRIBUTE -#endif -#if defined(__has_cpp_attribute) && defined(__cplusplus) -# define HEDLEY_GNUC_HAS_CPP_ATTRIBUTE(attribute,major,minor,patch) __has_cpp_attribute(attribute) -#else -# define HEDLEY_GNUC_HAS_CPP_ATTRIBUTE(attribute,major,minor,patch) HEDLEY_GNUC_VERSION_CHECK(major,minor,patch) -#endif - -#if defined(HEDLEY_GCC_HAS_CPP_ATTRIBUTE) -# undef HEDLEY_GCC_HAS_CPP_ATTRIBUTE -#endif -#if defined(__has_cpp_attribute) && defined(__cplusplus) -# define HEDLEY_GCC_HAS_CPP_ATTRIBUTE(attribute,major,minor,patch) __has_cpp_attribute(attribute) -#else -# define HEDLEY_GCC_HAS_CPP_ATTRIBUTE(attribute,major,minor,patch) HEDLEY_GCC_VERSION_CHECK(major,minor,patch) -#endif - -#if defined(HEDLEY_HAS_BUILTIN) -# undef HEDLEY_HAS_BUILTIN -#endif -#if defined(__has_builtin) -# define HEDLEY_HAS_BUILTIN(builtin) __has_builtin(builtin) -#else -# define HEDLEY_HAS_BUILTIN(builtin) (0) -#endif - -#if defined(HEDLEY_GNUC_HAS_BUILTIN) -# undef HEDLEY_GNUC_HAS_BUILTIN -#endif -#if defined(__has_builtin) -# define HEDLEY_GNUC_HAS_BUILTIN(builtin,major,minor,patch) __has_builtin(builtin) -#else -# define HEDLEY_GNUC_HAS_BUILTIN(builtin,major,minor,patch) HEDLEY_GNUC_VERSION_CHECK(major,minor,patch) -#endif - -#if defined(HEDLEY_GCC_HAS_BUILTIN) -# undef HEDLEY_GCC_HAS_BUILTIN -#endif -#if defined(__has_builtin) -# define HEDLEY_GCC_HAS_BUILTIN(builtin,major,minor,patch) __has_builtin(builtin) -#else -# define HEDLEY_GCC_HAS_BUILTIN(builtin,major,minor,patch) HEDLEY_GCC_VERSION_CHECK(major,minor,patch) -#endif - -#if defined(HEDLEY_HAS_FEATURE) -# undef HEDLEY_HAS_FEATURE -#endif -#if defined(__has_feature) -# define HEDLEY_HAS_FEATURE(feature) __has_feature(feature) -#else -# define HEDLEY_HAS_FEATURE(feature) (0) -#endif - -#if defined(HEDLEY_GNUC_HAS_FEATURE) -# undef HEDLEY_GNUC_HAS_FEATURE -#endif -#if defined(__has_feature) -# define HEDLEY_GNUC_HAS_FEATURE(feature,major,minor,patch) __has_feature(feature) -#else -# define HEDLEY_GNUC_HAS_FEATURE(feature,major,minor,patch) HEDLEY_GNUC_VERSION_CHECK(major,minor,patch) -#endif - -#if defined(HEDLEY_GCC_HAS_FEATURE) -# undef HEDLEY_GCC_HAS_FEATURE -#endif -#if defined(__has_feature) -# define HEDLEY_GCC_HAS_FEATURE(feature,major,minor,patch) __has_feature(feature) -#else -# define HEDLEY_GCC_HAS_FEATURE(feature,major,minor,patch) HEDLEY_GCC_VERSION_CHECK(major,minor,patch) -#endif - -#if defined(HEDLEY_HAS_EXTENSION) -# undef HEDLEY_HAS_EXTENSION -#endif -#if defined(__has_extension) -# define HEDLEY_HAS_EXTENSION(extension) __has_extension(extension) -#else -# define HEDLEY_HAS_EXTENSION(extension) (0) -#endif - -#if defined(HEDLEY_GNUC_HAS_EXTENSION) -# undef HEDLEY_GNUC_HAS_EXTENSION -#endif -#if defined(__has_extension) -# define HEDLEY_GNUC_HAS_EXTENSION(extension,major,minor,patch) __has_extension(extension) -#else -# define HEDLEY_GNUC_HAS_EXTENSION(extension,major,minor,patch) HEDLEY_GNUC_VERSION_CHECK(major,minor,patch) -#endif - -#if defined(HEDLEY_GCC_HAS_EXTENSION) -# undef HEDLEY_GCC_HAS_EXTENSION -#endif -#if defined(__has_extension) -# define HEDLEY_GCC_HAS_EXTENSION(extension,major,minor,patch) __has_extension(extension) -#else -# define HEDLEY_GCC_HAS_EXTENSION(extension,major,minor,patch) HEDLEY_GCC_VERSION_CHECK(major,minor,patch) -#endif - -#if defined(HEDLEY_HAS_DECLSPEC_ATTRIBUTE) -# undef HEDLEY_HAS_DECLSPEC_ATTRIBUTE -#endif -#if defined(__has_declspec_attribute) -# define HEDLEY_HAS_DECLSPEC_ATTRIBUTE(attribute) __has_declspec_attribute(attribute) -#else -# define HEDLEY_HAS_DECLSPEC_ATTRIBUTE(attribute) (0) -#endif - -#if defined(HEDLEY_GNUC_HAS_DECLSPEC_ATTRIBUTE) -# undef HEDLEY_GNUC_HAS_DECLSPEC_ATTRIBUTE -#endif -#if defined(__has_declspec_attribute) -# define HEDLEY_GNUC_HAS_DECLSPEC_ATTRIBUTE(attribute,major,minor,patch) __has_declspec_attribute(attribute) -#else -# define HEDLEY_GNUC_HAS_DECLSPEC_ATTRIBUTE(attribute,major,minor,patch) HEDLEY_GNUC_VERSION_CHECK(major,minor,patch) -#endif - -#if defined(HEDLEY_GCC_HAS_DECLSPEC_ATTRIBUTE) -# undef HEDLEY_GCC_HAS_DECLSPEC_ATTRIBUTE -#endif -#if defined(__has_declspec_attribute) -# define HEDLEY_GCC_HAS_DECLSPEC_ATTRIBUTE(attribute,major,minor,patch) __has_declspec_attribute(attribute) -#else -# define HEDLEY_GCC_HAS_DECLSPEC_ATTRIBUTE(attribute,major,minor,patch) HEDLEY_GCC_VERSION_CHECK(major,minor,patch) -#endif - -#if defined(HEDLEY_HAS_WARNING) -# undef HEDLEY_HAS_WARNING -#endif -#if defined(__has_warning) -# define HEDLEY_HAS_WARNING(warning) __has_warning(warning) -#else -# define HEDLEY_HAS_WARNING(warning) (0) -#endif - -#if defined(HEDLEY_GNUC_HAS_WARNING) -# undef HEDLEY_GNUC_HAS_WARNING -#endif -#if defined(__has_warning) -# define HEDLEY_GNUC_HAS_WARNING(warning,major,minor,patch) __has_warning(warning) -#else -# define HEDLEY_GNUC_HAS_WARNING(warning,major,minor,patch) HEDLEY_GNUC_VERSION_CHECK(major,minor,patch) -#endif - -#if defined(HEDLEY_GCC_HAS_WARNING) -# undef HEDLEY_GCC_HAS_WARNING -#endif -#if defined(__has_warning) -# define HEDLEY_GCC_HAS_WARNING(warning,major,minor,patch) __has_warning(warning) -#else -# define HEDLEY_GCC_HAS_WARNING(warning,major,minor,patch) HEDLEY_GCC_VERSION_CHECK(major,minor,patch) -#endif - -#if \ - (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)) || \ - defined(__clang__) || \ - HEDLEY_GCC_VERSION_CHECK(3,0,0) || \ - HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ - HEDLEY_IAR_VERSION_CHECK(8,0,0) || \ - HEDLEY_PGI_VERSION_CHECK(18,4,0) || \ - HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ - HEDLEY_TI_VERSION_CHECK(6,0,0) || \ - HEDLEY_CRAY_VERSION_CHECK(5,0,0) || \ - HEDLEY_TINYC_VERSION_CHECK(0,9,17) || \ - HEDLEY_SUNPRO_VERSION_CHECK(8,0,0) || \ - (HEDLEY_IBM_VERSION_CHECK(10,1,0) && defined(__C99_PRAGMA_OPERATOR)) -# define HEDLEY_PRAGMA(value) _Pragma(#value) -#elif HEDLEY_MSVC_VERSION_CHECK(15,0,0) -# define HEDLEY_PRAGMA(value) __pragma(value) -#else -# define HEDLEY_PRAGMA(value) -#endif - -#if defined(HEDLEY_DIAGNOSTIC_PUSH) -# undef HEDLEY_DIAGNOSTIC_PUSH -#endif -#if defined(HEDLEY_DIAGNOSTIC_POP) -# undef HEDLEY_DIAGNOSTIC_POP -#endif -#if defined(__clang__) -# define HEDLEY_DIAGNOSTIC_PUSH _Pragma("clang diagnostic push") -# define HEDLEY_DIAGNOSTIC_POP _Pragma("clang diagnostic pop") -#elif HEDLEY_INTEL_VERSION_CHECK(13,0,0) -# define HEDLEY_DIAGNOSTIC_PUSH _Pragma("warning(push)") -# define HEDLEY_DIAGNOSTIC_POP _Pragma("warning(pop)") -#elif HEDLEY_GCC_VERSION_CHECK(4,6,0) -# define HEDLEY_DIAGNOSTIC_PUSH _Pragma("GCC diagnostic push") -# define HEDLEY_DIAGNOSTIC_POP _Pragma("GCC diagnostic pop") -#elif HEDLEY_MSVC_VERSION_CHECK(15,0,0) -# define HEDLEY_DIAGNOSTIC_PUSH __pragma(warning(push)) -# define HEDLEY_DIAGNOSTIC_POP __pragma(warning(pop)) -#elif HEDLEY_ARM_VERSION_CHECK(5,6,0) -# define HEDLEY_DIAGNOSTIC_PUSH _Pragma("push") -# define HEDLEY_DIAGNOSTIC_POP _Pragma("pop") -#elif HEDLEY_TI_VERSION_CHECK(8,1,0) -# define HEDLEY_DIAGNOSTIC_PUSH _Pragma("diag_push") -# define HEDLEY_DIAGNOSTIC_POP _Pragma("diag_pop") -#elif HEDLEY_PELLES_VERSION_CHECK(2,90,0) -# define HEDLEY_DIAGNOSTIC_PUSH _Pragma("warning(push)") -# define HEDLEY_DIAGNOSTIC_POP _Pragma("warning(pop)") -#else -# define HEDLEY_DIAGNOSTIC_PUSH -# define HEDLEY_DIAGNOSTIC_POP -#endif - -#if defined(HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED) -# undef HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED -#endif -#if HEDLEY_HAS_WARNING("-Wdeprecated-declarations") -# define HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("clang diagnostic ignored \"-Wdeprecated-declarations\"") -#elif HEDLEY_INTEL_VERSION_CHECK(13,0,0) -# define HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("warning(disable:1478 1786)") -#elif HEDLEY_PGI_VERSION_CHECK(17,10,0) -# define HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("diag_suppress 1215,1444") -#elif HEDLEY_GCC_VERSION_CHECK(4,3,0) -# define HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"") -#elif HEDLEY_MSVC_VERSION_CHECK(15,0,0) -# define HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED __pragma(warning(disable:4996)) -#elif HEDLEY_TI_VERSION_CHECK(8,0,0) -# define HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("diag_suppress 1291,1718") -#elif HEDLEY_SUNPRO_VERSION_CHECK(5,13,0) && !defined(__cplusplus) -# define HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("error_messages(off,E_DEPRECATED_ATT,E_DEPRECATED_ATT_MESS)") -#elif HEDLEY_SUNPRO_VERSION_CHECK(5,13,0) && defined(__cplusplus) -# define HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("error_messages(off,symdeprecated,symdeprecated2)") -#elif HEDLEY_IAR_VERSION_CHECK(8,0,0) -# define HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("diag_suppress=Pe1444,Pe1215") -#elif HEDLEY_PELLES_VERSION_CHECK(2,90,0) -# define HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("warn(disable:2241)") -#else -# define HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED -#endif - -#if defined(HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS) -# undef HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS -#endif -#if HEDLEY_HAS_WARNING("-Wunknown-pragmas") -# define HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("clang diagnostic ignored \"-Wunknown-pragmas\"") -#elif HEDLEY_INTEL_VERSION_CHECK(13,0,0) -# define HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("warning(disable:161)") -#elif HEDLEY_PGI_VERSION_CHECK(17,10,0) -# define HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("diag_suppress 1675") -#elif HEDLEY_GCC_VERSION_CHECK(4,3,0) -# define HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("GCC diagnostic ignored \"-Wunknown-pragmas\"") -#elif HEDLEY_MSVC_VERSION_CHECK(15,0,0) -# define HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS __pragma(warning(disable:4068)) -#elif HEDLEY_TI_VERSION_CHECK(8,0,0) -# define HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("diag_suppress 163") -#elif HEDLEY_IAR_VERSION_CHECK(8,0,0) -# define HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("diag_suppress=Pe161") -#else -# define HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS -#endif - -#if defined(HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL) -# undef HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL -#endif -#if HEDLEY_HAS_WARNING("-Wcast-qual") -# define HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL _Pragma("clang diagnostic ignored \"-Wcast-qual\"") -#elif HEDLEY_INTEL_VERSION_CHECK(13,0,0) -# define HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL _Pragma("warning(disable:2203 2331)") -#elif HEDLEY_GCC_VERSION_CHECK(3,0,0) -# define HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL _Pragma("GCC diagnostic ignored \"-Wcast-qual\"") -#else -# define HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL -#endif - -#if defined(HEDLEY_DEPRECATED) -# undef HEDLEY_DEPRECATED -#endif -#if defined(HEDLEY_DEPRECATED_FOR) -# undef HEDLEY_DEPRECATED_FOR -#endif -#if defined(__cplusplus) && (__cplusplus >= 201402L) -# define HEDLEY_DEPRECATED(since) [[deprecated("Since " #since)]] -# define HEDLEY_DEPRECATED_FOR(since, replacement) [[deprecated("Since " #since "; use " #replacement)]] -#elif \ - HEDLEY_HAS_EXTENSION(attribute_deprecated_with_message) || \ - HEDLEY_GCC_VERSION_CHECK(4,5,0) || \ - HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ - HEDLEY_ARM_VERSION_CHECK(5,6,0) || \ - HEDLEY_SUNPRO_VERSION_CHECK(5,13,0) || \ - HEDLEY_PGI_VERSION_CHECK(17,10,0) || \ - HEDLEY_TI_VERSION_CHECK(8,3,0) -# define HEDLEY_DEPRECATED(since) __attribute__((__deprecated__("Since " #since))) -# define HEDLEY_DEPRECATED_FOR(since, replacement) __attribute__((__deprecated__("Since " #since "; use " #replacement))) -#elif \ - HEDLEY_HAS_ATTRIBUTE(deprecated) || \ - HEDLEY_GCC_VERSION_CHECK(3,1,0) || \ - HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ - HEDLEY_TI_VERSION_CHECK(8,0,0) || \ - (HEDLEY_TI_VERSION_CHECK(7,3,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) -# define HEDLEY_DEPRECATED(since) __attribute__((__deprecated__)) -# define HEDLEY_DEPRECATED_FOR(since, replacement) __attribute__((__deprecated__)) -#elif HEDLEY_MSVC_VERSION_CHECK(14,0,0) -# define HEDLEY_DEPRECATED(since) __declspec(deprecated("Since " # since)) -# define HEDLEY_DEPRECATED_FOR(since, replacement) __declspec(deprecated("Since " #since "; use " #replacement)) -#elif \ - HEDLEY_MSVC_VERSION_CHECK(13,10,0) || \ - HEDLEY_PELLES_VERSION_CHECK(6,50,0) -# define HEDLEY_DEPRECATED(since) _declspec(deprecated) -# define HEDLEY_DEPRECATED_FOR(since, replacement) __declspec(deprecated) -#elif HEDLEY_IAR_VERSION_CHECK(8,0,0) -# define HEDLEY_DEPRECATED(since) _Pragma("deprecated") -# define HEDLEY_DEPRECATED_FOR(since, replacement) _Pragma("deprecated") -#else -# define HEDLEY_DEPRECATED(since) -# define HEDLEY_DEPRECATED_FOR(since, replacement) -#endif - -#if defined(HEDLEY_UNAVAILABLE) -# undef HEDLEY_UNAVAILABLE -#endif -#if \ - HEDLEY_HAS_ATTRIBUTE(warning) || \ - HEDLEY_GCC_VERSION_CHECK(4,3,0) || \ - HEDLEY_INTEL_VERSION_CHECK(13,0,0) -# define HEDLEY_UNAVAILABLE(available_since) __attribute__((__warning__("Not available until " #available_since))) -#else -# define HEDLEY_UNAVAILABLE(available_since) -#endif - -#if defined(HEDLEY_WARN_UNUSED_RESULT) -# undef HEDLEY_WARN_UNUSED_RESULT -#endif -#if defined(__cplusplus) && (__cplusplus >= 201703L) -# define HEDLEY_WARN_UNUSED_RESULT [[nodiscard]] -#elif \ - HEDLEY_HAS_ATTRIBUTE(warn_unused_result) || \ - HEDLEY_GCC_VERSION_CHECK(3,4,0) || \ - HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ - HEDLEY_TI_VERSION_CHECK(8,0,0) || \ - (HEDLEY_TI_VERSION_CHECK(7,3,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ - (HEDLEY_SUNPRO_VERSION_CHECK(5,15,0) && defined(__cplusplus)) || \ - HEDLEY_PGI_VERSION_CHECK(17,10,0) -# define HEDLEY_WARN_UNUSED_RESULT __attribute__((__warn_unused_result__)) -#elif defined(_Check_return_) /* SAL */ -# define HEDLEY_WARN_UNUSED_RESULT _Check_return_ -#else -# define HEDLEY_WARN_UNUSED_RESULT -#endif - -#if defined(HEDLEY_SENTINEL) -# undef HEDLEY_SENTINEL -#endif -#if \ - HEDLEY_HAS_ATTRIBUTE(sentinel) || \ - HEDLEY_GCC_VERSION_CHECK(4,0,0) || \ - HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ - HEDLEY_ARM_VERSION_CHECK(5,4,0) -# define HEDLEY_SENTINEL(position) __attribute__((__sentinel__(position))) -#else -# define HEDLEY_SENTINEL(position) -#endif - -#if defined(HEDLEY_NO_RETURN) -# undef HEDLEY_NO_RETURN -#endif -#if HEDLEY_IAR_VERSION_CHECK(8,0,0) -# define HEDLEY_NO_RETURN __noreturn -#elif HEDLEY_INTEL_VERSION_CHECK(13,0,0) -# define HEDLEY_NO_RETURN __attribute__((__noreturn__)) -#elif defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L -# define HEDLEY_NO_RETURN _Noreturn -#elif defined(__cplusplus) && (__cplusplus >= 201103L) -# define HEDLEY_NO_RETURN [[noreturn]] -#elif \ - HEDLEY_HAS_ATTRIBUTE(noreturn) || \ - HEDLEY_GCC_VERSION_CHECK(3,2,0) || \ - HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \ - HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ - HEDLEY_IBM_VERSION_CHECK(10,1,0) || \ - HEDLEY_TI_VERSION_CHECK(18,0,0) || \ - (HEDLEY_TI_VERSION_CHECK(17,3,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) -# define HEDLEY_NO_RETURN __attribute__((__noreturn__)) -#elif HEDLEY_MSVC_VERSION_CHECK(13,10,0) -# define HEDLEY_NO_RETURN __declspec(noreturn) -#elif HEDLEY_TI_VERSION_CHECK(6,0,0) && defined(__cplusplus) -# define HEDLEY_NO_RETURN _Pragma("FUNC_NEVER_RETURNS;") -#elif HEDLEY_COMPCERT_VERSION_CHECK(3,2,0) -# define HEDLEY_NO_RETURN __attribute((noreturn)) -#elif HEDLEY_PELLES_VERSION_CHECK(9,0,0) -# define HEDLEY_NO_RETURN __declspec(noreturn) -#else -# define HEDLEY_NO_RETURN -#endif - -#if defined(HEDLEY_UNREACHABLE) -# undef HEDLEY_UNREACHABLE -#endif -#if defined(HEDLEY_UNREACHABLE_RETURN) -# undef HEDLEY_UNREACHABLE_RETURN -#endif -#if \ - (HEDLEY_HAS_BUILTIN(__builtin_unreachable) && (!defined(HEDLEY_ARM_VERSION))) || \ - HEDLEY_GCC_VERSION_CHECK(4,5,0) || \ - HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ - HEDLEY_IBM_VERSION_CHECK(13,1,5) -# define HEDLEY_UNREACHABLE() __builtin_unreachable() -#elif HEDLEY_MSVC_VERSION_CHECK(13,10,0) -# define HEDLEY_UNREACHABLE() __assume(0) -#elif HEDLEY_TI_VERSION_CHECK(6,0,0) -# if defined(__cplusplus) -# define HEDLEY_UNREACHABLE() std::_nassert(0) -# else -# define HEDLEY_UNREACHABLE() _nassert(0) -# endif -# define HEDLEY_UNREACHABLE_RETURN(value) return value -#elif defined(EXIT_FAILURE) -# define HEDLEY_UNREACHABLE() abort() -#else -# define HEDLEY_UNREACHABLE() -# define HEDLEY_UNREACHABLE_RETURN(value) return value -#endif -#if !defined(HEDLEY_UNREACHABLE_RETURN) -# define HEDLEY_UNREACHABLE_RETURN(value) HEDLEY_UNREACHABLE() -#endif - -#if defined(HEDLEY_ASSUME) -# undef HEDLEY_ASSUME -#endif -#if \ - HEDLEY_MSVC_VERSION_CHECK(13,10,0) || \ - HEDLEY_INTEL_VERSION_CHECK(13,0,0) -# define HEDLEY_ASSUME(expr) __assume(expr) -#elif HEDLEY_HAS_BUILTIN(__builtin_assume) -# define HEDLEY_ASSUME(expr) __builtin_assume(expr) -#elif HEDLEY_TI_VERSION_CHECK(6,0,0) -# if defined(__cplusplus) -# define HEDLEY_ASSUME(expr) std::_nassert(expr) -# else -# define HEDLEY_ASSUME(expr) _nassert(expr) -# endif -#elif \ - (HEDLEY_HAS_BUILTIN(__builtin_unreachable) && !defined(HEDLEY_ARM_VERSION)) || \ - HEDLEY_GCC_VERSION_CHECK(4,5,0) || \ - HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ - HEDLEY_IBM_VERSION_CHECK(13,1,5) -# define HEDLEY_ASSUME(expr) ((void) ((expr) ? 1 : (__builtin_unreachable(), 1))) -#else -# define HEDLEY_ASSUME(expr) ((void) (expr)) -#endif - - -HEDLEY_DIAGNOSTIC_PUSH -#if \ - HEDLEY_HAS_WARNING("-Wvariadic-macros") || \ - HEDLEY_GCC_VERSION_CHECK(4,0,0) -# if defined(__clang__) -# pragma clang diagnostic ignored "-Wvariadic-macros" -# elif defined(HEDLEY_GCC_VERSION) -# pragma GCC diagnostic ignored "-Wvariadic-macros" -# endif -#endif -#if defined(HEDLEY_NON_NULL) -# undef HEDLEY_NON_NULL -#endif -#if \ - HEDLEY_HAS_ATTRIBUTE(nonnull) || \ - HEDLEY_GCC_VERSION_CHECK(3,3,0) || \ - HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ - HEDLEY_ARM_VERSION_CHECK(4,1,0) -# define HEDLEY_NON_NULL(...) __attribute__((__nonnull__(__VA_ARGS__))) -#else -# define HEDLEY_NON_NULL(...) -#endif -HEDLEY_DIAGNOSTIC_POP - -#if defined(HEDLEY_PRINTF_FORMAT) -# undef HEDLEY_PRINTF_FORMAT -#endif -#if defined(__MINGW32__) && HEDLEY_GCC_HAS_ATTRIBUTE(format,4,4,0) && !defined(__USE_MINGW_ANSI_STDIO) -# define HEDLEY_PRINTF_FORMAT(string_idx,first_to_check) __attribute__((__format__(ms_printf, string_idx, first_to_check))) -#elif defined(__MINGW32__) && HEDLEY_GCC_HAS_ATTRIBUTE(format,4,4,0) && defined(__USE_MINGW_ANSI_STDIO) -# define HEDLEY_PRINTF_FORMAT(string_idx,first_to_check) __attribute__((__format__(gnu_printf, string_idx, first_to_check))) -#elif \ - HEDLEY_HAS_ATTRIBUTE(format) || \ - HEDLEY_GCC_VERSION_CHECK(3,1,0) || \ - HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ - HEDLEY_ARM_VERSION_CHECK(5,6,0) || \ - HEDLEY_IBM_VERSION_CHECK(10,1,0) || \ - HEDLEY_TI_VERSION_CHECK(8,0,0) || \ - (HEDLEY_TI_VERSION_CHECK(7,3,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) -# define HEDLEY_PRINTF_FORMAT(string_idx,first_to_check) __attribute__((__format__(__printf__, string_idx, first_to_check))) -#elif HEDLEY_PELLES_VERSION_CHECK(6,0,0) -# define HEDLEY_PRINTF_FORMAT(string_idx,first_to_check) __declspec(vaformat(printf,string_idx,first_to_check)) -#else -# define HEDLEY_PRINTF_FORMAT(string_idx,first_to_check) -#endif - -#if defined(HEDLEY_CONSTEXPR) -# undef HEDLEY_CONSTEXPR -#endif -#if defined(__cplusplus) -# if __cplusplus >= 201103L -# define HEDLEY_CONSTEXPR constexpr -# endif -#endif -#if !defined(HEDLEY_CONSTEXPR) -# define HEDLEY_CONSTEXPR -#endif - -#if defined(HEDLEY_PREDICT) -# undef HEDLEY_PREDICT -#endif -#if defined(HEDLEY_LIKELY) -# undef HEDLEY_LIKELY -#endif -#if defined(HEDLEY_UNLIKELY) -# undef HEDLEY_UNLIKELY -#endif -#if defined(HEDLEY_UNPREDICTABLE) -# undef HEDLEY_UNPREDICTABLE -#endif -#if HEDLEY_HAS_BUILTIN(__builtin_unpredictable) -# define HEDLEY_UNPREDICTABLE(expr) __builtin_unpredictable(!!(expr)) -#endif -#if \ - HEDLEY_HAS_BUILTIN(__builtin_expect_with_probability) || \ - HEDLEY_GCC_VERSION_CHECK(9,0,0) -# define HEDLEY_PREDICT(expr, value, probability) __builtin_expect_with_probability(expr, value, probability) -# define HEDLEY_PREDICT_TRUE(expr, probability) __builtin_expect_with_probability(!!(expr), 1, probability) -# define HEDLEY_PREDICT_FALSE(expr, probability) __builtin_expect_with_probability(!!(expr), 0, probability) -# define HEDLEY_LIKELY(expr) __builtin_expect(!!(expr), 1) -# define HEDLEY_UNLIKELY(expr) __builtin_expect(!!(expr), 0) -# if !defined(HEDLEY_BUILTIN_UNPREDICTABLE) -# define HEDLEY_BUILTIN_UNPREDICTABLE(expr) __builtin_expect_with_probability(!!(expr), 1, 0.5) -# endif -#elif \ - HEDLEY_HAS_BUILTIN(__builtin_expect) || \ - HEDLEY_GCC_VERSION_CHECK(3,0,0) || \ - HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ - (HEDLEY_SUNPRO_VERSION_CHECK(5,15,0) && defined(__cplusplus)) || \ - HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ - HEDLEY_IBM_VERSION_CHECK(10,1,0) || \ - HEDLEY_TI_VERSION_CHECK(6,1,0) || \ - HEDLEY_TINYC_VERSION_CHECK(0,9,27) -# define HEDLEY_PREDICT(expr, expected, probability) \ - (((probability) >= 0.9) ? __builtin_expect(!!(expr), (expected)) : (((void) (expected)), !!(expr))) -# define HEDLEY_PREDICT_TRUE(expr, probability) \ - (__extension__ ({ \ - HEDLEY_CONSTEXPR double hedley_probability_ = (probability); \ - ((hedley_probability_ >= 0.9) ? __builtin_expect(!!(expr), 1) : ((hedley_probability_ <= 0.1) ? __builtin_expect(!!(expr), 0) : !!(expr))); \ - })) -# define HEDLEY_PREDICT_FALSE(expr, probability) \ - (__extension__ ({ \ - HEDLEY_CONSTEXPR double hedley_probability_ = (probability); \ - ((hedley_probability_ >= 0.9) ? __builtin_expect(!!(expr), 0) : ((hedley_probability_ <= 0.1) ? __builtin_expect(!!(expr), 1) : !!(expr))); \ - })) -# define HEDLEY_LIKELY(expr) __builtin_expect(!!(expr), 1) -# define HEDLEY_UNLIKELY(expr) __builtin_expect(!!(expr), 0) -#else -# define HEDLEY_PREDICT(expr, expected, probability) (((void) (expected)), !!(expr)) -# define HEDLEY_PREDICT_TRUE(expr, probability) (!!(expr)) -# define HEDLEY_PREDICT_FALSE(expr, probability) (!!(expr)) -# define HEDLEY_LIKELY(expr) (!!(expr)) -# define HEDLEY_UNLIKELY(expr) (!!(expr)) -#endif -#if !defined(HEDLEY_UNPREDICTABLE) -# define HEDLEY_UNPREDICTABLE(expr) HEDLEY_PREDICT(expr, 1, 0.5) -#endif - -#if defined(HEDLEY_MALLOC) -# undef HEDLEY_MALLOC -#endif -#if \ - HEDLEY_HAS_ATTRIBUTE(malloc) || \ - HEDLEY_GCC_VERSION_CHECK(3,1,0) || \ - HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ - HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \ - HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ - HEDLEY_IBM_VERSION_CHECK(12,1,0) || \ - HEDLEY_TI_VERSION_CHECK(8,0,0) || \ - (HEDLEY_TI_VERSION_CHECK(7,3,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) -# define HEDLEY_MALLOC __attribute__((__malloc__)) -#elif HEDLEY_MSVC_VERSION_CHECK(14, 0, 0) -# define HEDLEY_MALLOC __declspec(restrict) -#else -# define HEDLEY_MALLOC -#endif - -#if defined(HEDLEY_PURE) -# undef HEDLEY_PURE -#endif -#if \ - HEDLEY_HAS_ATTRIBUTE(pure) || \ - HEDLEY_GCC_VERSION_CHECK(2,96,0) || \ - HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ - HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \ - HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ - HEDLEY_IBM_VERSION_CHECK(10,1,0) || \ - HEDLEY_TI_VERSION_CHECK(8,0,0) || \ - (HEDLEY_TI_VERSION_CHECK(7,3,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ - HEDLEY_PGI_VERSION_CHECK(17,10,0) -# define HEDLEY_PURE __attribute__((__pure__)) -#elif HEDLEY_TI_VERSION_CHECK(6,0,0) && defined(__cplusplus) -# define HEDLEY_PURE _Pragma("FUNC_IS_PURE;") -#else -# define HEDLEY_PURE -#endif - -#if defined(HEDLEY_CONST) -# undef HEDLEY_CONST -#endif -#if \ - HEDLEY_HAS_ATTRIBUTE(const) || \ - HEDLEY_GCC_VERSION_CHECK(2,5,0) || \ - HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ - HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \ - HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ - HEDLEY_IBM_VERSION_CHECK(10,1,0) || \ - HEDLEY_TI_VERSION_CHECK(8,0,0) || \ - (HEDLEY_TI_VERSION_CHECK(7,3,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ - HEDLEY_PGI_VERSION_CHECK(17,10,0) -# define HEDLEY_CONST __attribute__((__const__)) -#else -# define HEDLEY_CONST HEDLEY_PURE -#endif - -#if defined(HEDLEY_RESTRICT) -# undef HEDLEY_RESTRICT -#endif -#if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) && !defined(__cplusplus) -# define HEDLEY_RESTRICT restrict -#elif \ - HEDLEY_GCC_VERSION_CHECK(3,1,0) || \ - HEDLEY_MSVC_VERSION_CHECK(14,0,0) || \ - HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ - HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ - HEDLEY_IBM_VERSION_CHECK(10,1,0) || \ - HEDLEY_PGI_VERSION_CHECK(17,10,0) || \ - HEDLEY_TI_VERSION_CHECK(8,0,0) || \ - (HEDLEY_SUNPRO_VERSION_CHECK(5,14,0) && defined(__cplusplus)) || \ - HEDLEY_IAR_VERSION_CHECK(8,0,0) || \ - defined(__clang__) -# define HEDLEY_RESTRICT __restrict -#elif HEDLEY_SUNPRO_VERSION_CHECK(5,3,0) && !defined(__cplusplus) -# define HEDLEY_RESTRICT _Restrict -#else -# define HEDLEY_RESTRICT -#endif - -#if defined(HEDLEY_INLINE) -# undef HEDLEY_INLINE -#endif -#if \ - (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)) || \ - (defined(__cplusplus) && (__cplusplus >= 199711L)) -# define HEDLEY_INLINE inline -#elif \ - defined(HEDLEY_GCC_VERSION) || \ - HEDLEY_ARM_VERSION_CHECK(6,2,0) -# define HEDLEY_INLINE __inline__ -#elif \ - HEDLEY_MSVC_VERSION_CHECK(12,0,0) || \ - HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ - HEDLEY_TI_VERSION_CHECK(8,0,0) -# define HEDLEY_INLINE __inline -#else -# define HEDLEY_INLINE -#endif - -#if defined(HEDLEY_ALWAYS_INLINE) -# undef HEDLEY_ALWAYS_INLINE -#endif -#if \ - HEDLEY_HAS_ATTRIBUTE(always_inline) || \ - HEDLEY_GCC_VERSION_CHECK(4,0,0) || \ - HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ - HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \ - HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ - HEDLEY_IBM_VERSION_CHECK(10,1,0) || \ - HEDLEY_TI_VERSION_CHECK(8,0,0) || \ - (HEDLEY_TI_VERSION_CHECK(7,3,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) -# define HEDLEY_ALWAYS_INLINE __attribute__((__always_inline__)) HEDLEY_INLINE -#elif HEDLEY_MSVC_VERSION_CHECK(12,0,0) -# define HEDLEY_ALWAYS_INLINE __forceinline -#elif HEDLEY_TI_VERSION_CHECK(7,0,0) && defined(__cplusplus) -# define HEDLEY_ALWAYS_INLINE _Pragma("FUNC_ALWAYS_INLINE;") -#elif HEDLEY_IAR_VERSION_CHECK(8,0,0) -# define HEDLEY_ALWAYS_INLINE _Pragma("inline=forced") -#else -# define HEDLEY_ALWAYS_INLINE HEDLEY_INLINE -#endif - -#if defined(HEDLEY_NEVER_INLINE) -# undef HEDLEY_NEVER_INLINE -#endif -#if \ - HEDLEY_HAS_ATTRIBUTE(noinline) || \ - HEDLEY_GCC_VERSION_CHECK(4,0,0) || \ - HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ - HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \ - HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ - HEDLEY_IBM_VERSION_CHECK(10,1,0) || \ - HEDLEY_TI_VERSION_CHECK(8,0,0) || \ - (HEDLEY_TI_VERSION_CHECK(7,3,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) -# define HEDLEY_NEVER_INLINE __attribute__((__noinline__)) -#elif HEDLEY_MSVC_VERSION_CHECK(13,10,0) -# define HEDLEY_NEVER_INLINE __declspec(noinline) -#elif HEDLEY_PGI_VERSION_CHECK(10,2,0) -# define HEDLEY_NEVER_INLINE _Pragma("noinline") -#elif HEDLEY_TI_VERSION_CHECK(6,0,0) && defined(__cplusplus) -# define HEDLEY_NEVER_INLINE _Pragma("FUNC_CANNOT_INLINE;") -#elif HEDLEY_IAR_VERSION_CHECK(8,0,0) -# define HEDLEY_NEVER_INLINE _Pragma("inline=never") -#elif HEDLEY_COMPCERT_VERSION_CHECK(3,2,0) -# define HEDLEY_NEVER_INLINE __attribute((noinline)) -#elif HEDLEY_PELLES_VERSION_CHECK(9,0,0) -# define HEDLEY_NEVER_INLINE __declspec(noinline) -#else -# define HEDLEY_NEVER_INLINE -#endif - -#if defined(HEDLEY_PRIVATE) -# undef HEDLEY_PRIVATE -#endif -#if defined(HEDLEY_PUBLIC) -# undef HEDLEY_PUBLIC -#endif -#if defined(HEDLEY_IMPORT) -# undef HEDLEY_IMPORT -#endif -#if defined(_WIN32) || defined(__CYGWIN__) -# define HEDLEY_PRIVATE -# define HEDLEY_PUBLIC __declspec(dllexport) -# define HEDLEY_IMPORT __declspec(dllimport) -#else -# if \ - HEDLEY_HAS_ATTRIBUTE(visibility) || \ - HEDLEY_GCC_VERSION_CHECK(3,3,0) || \ - HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \ - HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ - HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ - HEDLEY_IBM_VERSION_CHECK(13,1,0) || \ - HEDLEY_TI_VERSION_CHECK(8,0,0) || \ - (HEDLEY_TI_VERSION_CHECK(7,3,0) && defined(__TI_EABI__) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) -# define HEDLEY_PRIVATE __attribute__((__visibility__("hidden"))) -# define HEDLEY_PUBLIC __attribute__((__visibility__("default"))) -# else -# define HEDLEY_PRIVATE -# define HEDLEY_PUBLIC -# endif -# define HEDLEY_IMPORT extern -#endif - -#if defined(HEDLEY_NO_THROW) -# undef HEDLEY_NO_THROW -#endif -#if \ - HEDLEY_HAS_ATTRIBUTE(nothrow) || \ - HEDLEY_GCC_VERSION_CHECK(3,3,0) || \ - HEDLEY_INTEL_VERSION_CHECK(13,0,0) -# define HEDLEY_NO_THROW __attribute__((__nothrow__)) -#elif \ - HEDLEY_MSVC_VERSION_CHECK(13,1,0) || \ - HEDLEY_ARM_VERSION_CHECK(4,1,0) -# define HEDLEY_NO_THROW __declspec(nothrow) -#else -# define HEDLEY_NO_THROW -#endif - -#if defined(HEDLEY_FALL_THROUGH) -# undef HEDLEY_FALL_THROUGH -#endif -#if \ - defined(__cplusplus) && \ - (!defined(HEDLEY_SUNPRO_VERSION) || HEDLEY_SUNPRO_VERSION_CHECK(5,15,0)) && \ - !defined(HEDLEY_PGI_VERSION) -# if \ - (__cplusplus >= 201703L) || \ - ((__cplusplus >= 201103L) && HEDLEY_HAS_CPP_ATTRIBUTE(fallthrough)) -# define HEDLEY_FALL_THROUGH [[fallthrough]] -# elif (__cplusplus >= 201103L) && HEDLEY_HAS_CPP_ATTRIBUTE(clang::fallthrough) -# define HEDLEY_FALL_THROUGH [[clang::fallthrough]] -# elif (__cplusplus >= 201103L) && HEDLEY_GCC_VERSION_CHECK(7,0,0) -# define HEDLEY_FALL_THROUGH [[gnu::fallthrough]] -# endif -#endif -#if !defined(HEDLEY_FALL_THROUGH) -# if HEDLEY_GNUC_HAS_ATTRIBUTE(fallthrough,7,0,0) && !defined(HEDLEY_PGI_VERSION) -# define HEDLEY_FALL_THROUGH __attribute__((__fallthrough__)) -# elif defined(__fallthrough) /* SAL */ -# define HEDLEY_FALL_THROUGH __fallthrough -# else -# define HEDLEY_FALL_THROUGH -# endif -#endif - -#if defined(HEDLEY_RETURNS_NON_NULL) -# undef HEDLEY_RETURNS_NON_NULL -#endif -#if \ - HEDLEY_HAS_ATTRIBUTE(returns_nonnull) || \ - HEDLEY_GCC_VERSION_CHECK(4,9,0) -# define HEDLEY_RETURNS_NON_NULL __attribute__((__returns_nonnull__)) -#elif defined(_Ret_notnull_) /* SAL */ -# define HEDLEY_RETURNS_NON_NULL _Ret_notnull_ -#else -# define HEDLEY_RETURNS_NON_NULL -#endif - -#if defined(HEDLEY_ARRAY_PARAM) -# undef HEDLEY_ARRAY_PARAM -#endif -#if \ - defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) && \ - !defined(__STDC_NO_VLA__) && \ - !defined(__cplusplus) && \ - !defined(HEDLEY_PGI_VERSION) && \ - !defined(HEDLEY_TINYC_VERSION) -# define HEDLEY_ARRAY_PARAM(name) (name) -#else -# define HEDLEY_ARRAY_PARAM(name) -#endif - -#if defined(HEDLEY_IS_CONSTANT) -# undef HEDLEY_IS_CONSTANT -#endif -#if defined(HEDLEY_REQUIRE_CONSTEXPR) -# undef HEDLEY_REQUIRE_CONSTEXPR -#endif -/* Note the double-underscore. For internal use only; no API - * guarantees! */ -#if defined(HEDLEY__IS_CONSTEXPR) -# undef HEDLEY__IS_CONSTEXPR -#endif - -#if \ - HEDLEY_HAS_BUILTIN(__builtin_constant_p) || \ - HEDLEY_GCC_VERSION_CHECK(3,4,0) || \ - HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ - HEDLEY_TINYC_VERSION_CHECK(0,9,19) || \ - HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ - HEDLEY_IBM_VERSION_CHECK(13,1,0) || \ - HEDLEY_TI_VERSION_CHECK(6,1,0) || \ - HEDLEY_SUNPRO_VERSION_CHECK(5,10,0) || \ - HEDLEY_CRAY_VERSION_CHECK(8,1,0) -# define HEDLEY_IS_CONSTANT(expr) __builtin_constant_p(expr) -#endif -#if !defined(__cplusplus) -# if \ - HEDLEY_HAS_BUILTIN(__builtin_types_compatible_p) || \ - HEDLEY_GCC_VERSION_CHECK(3,4,0) || \ - HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ - HEDLEY_IBM_VERSION_CHECK(13,1,0) || \ - HEDLEY_CRAY_VERSION_CHECK(8,1,0) || \ - HEDLEY_ARM_VERSION_CHECK(5,4,0) || \ - HEDLEY_TINYC_VERSION_CHECK(0,9,24) -# if defined(__INTPTR_TYPE__) -# define HEDLEY__IS_CONSTEXPR(expr) __builtin_types_compatible_p(__typeof__((1 ? (void*) ((__INTPTR_TYPE__) ((expr) * 0)) : (int*) 0)), int*) -# else -# include -# define HEDLEY__IS_CONSTEXPR(expr) __builtin_types_compatible_p(__typeof__((1 ? (void*) ((intptr_t) ((expr) * 0)) : (int*) 0)), int*) -# endif -# elif \ - (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 201112L) && !defined(HEDLEY_SUNPRO_VERSION) && !defined(HEDLEY_PGI_VERSION)) || \ - HEDLEY_HAS_EXTENSION(c_generic_selections) || \ - HEDLEY_GCC_VERSION_CHECK(4,9,0) || \ - HEDLEY_INTEL_VERSION_CHECK(17,0,0) || \ - HEDLEY_IBM_VERSION_CHECK(12,1,0) || \ - HEDLEY_ARM_VERSION_CHECK(5,3,0) -# if defined(__INTPTR_TYPE__) -# define HEDLEY__IS_CONSTEXPR(expr) _Generic((1 ? (void*) ((__INTPTR_TYPE__) ((expr) * 0)) : (int*) 0), int*: 1, void*: 0) -# else -# include -# define HEDLEY__IS_CONSTEXPR(expr) _Generic((1 ? (void*) ((intptr_t) * 0) : (int*) 0), int*: 1, void*: 0) -# endif -# elif \ - defined(HEDLEY_GCC_VERSION) || \ - defined(HEDLEY_INTEL_VERSION) || \ - defined(HEDLEY_TINYC_VERSION) || \ - defined(HEDLEY_TI_VERSION) || \ - defined(__clang__) -# define HEDLEY__IS_CONSTEXPR(expr) ( \ - sizeof(void) != \ - sizeof(*( \ - 1 ? \ - ((void*) ((expr) * 0L) ) : \ - ((struct { char v[sizeof(void) * 2]; } *) 1) \ - ) \ - ) \ - ) -# endif -#endif -#if defined(HEDLEY__IS_CONSTEXPR) -# if !defined(HEDLEY_IS_CONSTANT) -# define HEDLEY_IS_CONSTANT(expr) HEDLEY__IS_CONSTEXPR(expr) -# endif -# define HEDLEY_REQUIRE_CONSTEXPR(expr) (HEDLEY__IS_CONSTEXPR(expr) ? (expr) : (-1)) -#else -# if !defined(HEDLEY_IS_CONSTANT) -# define HEDLEY_IS_CONSTANT(expr) (0) -# endif -# define HEDLEY_REQUIRE_CONSTEXPR(expr) (expr) -#endif - -#if defined(HEDLEY_BEGIN_C_DECLS) -# undef HEDLEY_BEGIN_C_DECLS -#endif -#if defined(HEDLEY_END_C_DECLS) -# undef HEDLEY_END_C_DECLS -#endif -#if defined(HEDLEY_C_DECL) -# undef HEDLEY_C_DECL -#endif -#if defined(__cplusplus) -# define HEDLEY_BEGIN_C_DECLS extern "C" { -# define HEDLEY_END_C_DECLS } -# define HEDLEY_C_DECL extern "C" -#else -# define HEDLEY_BEGIN_C_DECLS -# define HEDLEY_END_C_DECLS -# define HEDLEY_C_DECL -#endif - -#if defined(HEDLEY_STATIC_ASSERT) -# undef HEDLEY_STATIC_ASSERT -#endif -#if \ - !defined(__cplusplus) && ( \ - (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 201112L)) || \ - HEDLEY_HAS_FEATURE(c_static_assert) || \ - HEDLEY_GCC_VERSION_CHECK(6,0,0) || \ - HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ - defined(_Static_assert) \ - ) -# define HEDLEY_STATIC_ASSERT(expr, message) _Static_assert(expr, message) -#elif \ - (defined(__cplusplus) && (__cplusplus >= 201703L)) || \ - HEDLEY_MSVC_VERSION_CHECK(16,0,0) || \ - (defined(__cplusplus) && HEDLEY_TI_VERSION_CHECK(8,3,0)) -# define HEDLEY_STATIC_ASSERT(expr, message) static_assert(expr, message) -#elif defined(__cplusplus) && (__cplusplus >= 201103L) -# define HEDLEY_STATIC_ASSERT(expr, message) static_assert(expr) -#else -# define HEDLEY_STATIC_ASSERT(expr, message) -#endif - -#if defined(HEDLEY_CONST_CAST) -# undef HEDLEY_CONST_CAST -#endif -#if defined(__cplusplus) -# define HEDLEY_CONST_CAST(T, expr) (const_cast(expr)) -#elif \ - HEDLEY_HAS_WARNING("-Wcast-qual") || \ - HEDLEY_GCC_VERSION_CHECK(4,6,0) || \ - HEDLEY_INTEL_VERSION_CHECK(13,0,0) -# define HEDLEY_CONST_CAST(T, expr) (__extension__ ({ \ - HEDLEY_DIAGNOSTIC_PUSH \ - HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL \ - ((T) (expr)); \ - HEDLEY_DIAGNOSTIC_POP \ - })) -#else -# define HEDLEY_CONST_CAST(T, expr) ((T) (expr)) -#endif - -#if defined(HEDLEY_REINTERPRET_CAST) -# undef HEDLEY_REINTERPRET_CAST -#endif -#if defined(__cplusplus) -# define HEDLEY_REINTERPRET_CAST(T, expr) (reinterpret_cast(expr)) -#else -# define HEDLEY_REINTERPRET_CAST(T, expr) (*((T*) &(expr))) -#endif - -#if defined(HEDLEY_STATIC_CAST) -# undef HEDLEY_STATIC_CAST -#endif -#if defined(__cplusplus) -# define HEDLEY_STATIC_CAST(T, expr) (static_cast(expr)) -#else -# define HEDLEY_STATIC_CAST(T, expr) ((T) (expr)) -#endif - -#if defined(HEDLEY_CPP_CAST) -# undef HEDLEY_CPP_CAST -#endif -#if defined(__cplusplus) -# define HEDLEY_CPP_CAST(T, expr) static_cast(expr) -#else -# define HEDLEY_CPP_CAST(T, expr) (expr) -#endif - -#if defined(HEDLEY_MESSAGE) -# undef HEDLEY_MESSAGE -#endif -#if HEDLEY_HAS_WARNING("-Wunknown-pragmas") -# define HEDLEY_MESSAGE(msg) \ - HEDLEY_DIAGNOSTIC_PUSH \ - HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS \ - HEDLEY_PRAGMA(message msg) \ - HEDLEY_DIAGNOSTIC_POP -#elif \ - HEDLEY_GCC_VERSION_CHECK(4,4,0) || \ - HEDLEY_INTEL_VERSION_CHECK(13,0,0) -# define HEDLEY_MESSAGE(msg) HEDLEY_PRAGMA(message msg) -#elif HEDLEY_CRAY_VERSION_CHECK(5,0,0) -# define HEDLEY_MESSAGE(msg) HEDLEY_PRAGMA(_CRI message msg) -#elif HEDLEY_IAR_VERSION_CHECK(8,0,0) -# define HEDLEY_MESSAGE(msg) HEDLEY_PRAGMA(message(msg)) -#elif HEDLEY_PELLES_VERSION_CHECK(2,0,0) -# define HEDLEY_MESSAGE(msg) HEDLEY_PRAGMA(message(msg)) -#else -# define HEDLEY_MESSAGE(msg) -#endif - -#if defined(HEDLEY_WARNING) -# undef HEDLEY_WARNING -#endif -#if HEDLEY_HAS_WARNING("-Wunknown-pragmas") -# define HEDLEY_WARNING(msg) \ - HEDLEY_DIAGNOSTIC_PUSH \ - HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS \ - HEDLEY_PRAGMA(clang warning msg) \ - HEDLEY_DIAGNOSTIC_POP -#elif \ - HEDLEY_GCC_VERSION_CHECK(4,8,0) || \ - HEDLEY_PGI_VERSION_CHECK(18,4,0) -# define HEDLEY_WARNING(msg) HEDLEY_PRAGMA(GCC warning msg) -#elif HEDLEY_MSVC_VERSION_CHECK(15,0,0) -# define HEDLEY_WARNING(msg) HEDLEY_PRAGMA(message(msg)) -#else -# define HEDLEY_WARNING(msg) HEDLEY_MESSAGE(msg) -#endif - -#if defined(HEDLEY_REQUIRE_MSG) -# undef HEDLEY_REQUIRE_MSG -#endif -#if HEDLEY_HAS_ATTRIBUTE(diagnose_if) -# if HEDLEY_HAS_WARNING("-Wgcc-compat") -# define HEDLEY_REQUIRE_MSG(expr, msg) \ - HEDLEY_DIAGNOSTIC_PUSH \ - _Pragma("clang diagnostic ignored \"-Wgcc-compat\"") \ - __attribute__((__diagnose_if__(!(expr), msg, "error"))) \ - HEDLEY_DIAGNOSTIC_POP -# else -# define HEDLEY_REQUIRE_MSG(expr, msg) __attribute__((__diagnose_if__(!(expr), msg, "error"))) -# endif -#else -# define HEDLEY_REQUIRE_MSG(expr, msg) -#endif - -#if defined(HEDLEY_REQUIRE) -# undef HEDLEY_REQUIRE -#endif -#define HEDLEY_REQUIRE(expr) HEDLEY_REQUIRE_MSG(expr, #expr) - -#if defined(HEDLEY_FLAGS) -# undef HEDLEY_FLAGS -#endif -#if HEDLEY_HAS_ATTRIBUTE(flag_enum) -# define HEDLEY_FLAGS __attribute__((__flag_enum__)) -#endif - -#if defined(HEDLEY_FLAGS_CAST) -# undef HEDLEY_FLAGS_CAST -#endif -#if HEDLEY_INTEL_VERSION_CHECK(19,0,0) -# define HEDLEY_FLAGS_CAST(T, expr) (__extension__ ({ \ - HEDLEY_DIAGNOSTIC_PUSH \ - _Pragma("warning(disable:188)") \ - ((T) (expr)); \ - HEDLEY_DIAGNOSTIC_POP \ - })) -#else -# define HEDLEY_FLAGS_CAST(T, expr) HEDLEY_STATIC_CAST(T, expr) -#endif - -/* Remaining macros are deprecated. */ - -#if defined(HEDLEY_GCC_NOT_CLANG_VERSION_CHECK) -# undef HEDLEY_GCC_NOT_CLANG_VERSION_CHECK -#endif -#if defined(__clang__) -# define HEDLEY_GCC_NOT_CLANG_VERSION_CHECK(major,minor,patch) (0) -#else -# define HEDLEY_GCC_NOT_CLANG_VERSION_CHECK(major,minor,patch) HEDLEY_GCC_VERSION_CHECK(major,minor,patch) -#endif - -#if defined(HEDLEY_CLANG_HAS_ATTRIBUTE) -# undef HEDLEY_CLANG_HAS_ATTRIBUTE -#endif -#define HEDLEY_CLANG_HAS_ATTRIBUTE(attribute) HEDLEY_HAS_ATTRIBUTE(attribute) - -#if defined(HEDLEY_CLANG_HAS_CPP_ATTRIBUTE) -# undef HEDLEY_CLANG_HAS_CPP_ATTRIBUTE -#endif -#define HEDLEY_CLANG_HAS_CPP_ATTRIBUTE(attribute) HEDLEY_HAS_CPP_ATTRIBUTE(attribute) - -#if defined(HEDLEY_CLANG_HAS_BUILTIN) -# undef HEDLEY_CLANG_HAS_BUILTIN -#endif -#define HEDLEY_CLANG_HAS_BUILTIN(builtin) HEDLEY_HAS_BUILTIN(builtin) - -#if defined(HEDLEY_CLANG_HAS_FEATURE) -# undef HEDLEY_CLANG_HAS_FEATURE -#endif -#define HEDLEY_CLANG_HAS_FEATURE(feature) HEDLEY_HAS_FEATURE(feature) - -#if defined(HEDLEY_CLANG_HAS_EXTENSION) -# undef HEDLEY_CLANG_HAS_EXTENSION -#endif -#define HEDLEY_CLANG_HAS_EXTENSION(extension) HEDLEY_HAS_EXTENSION(extension) - -#if defined(HEDLEY_CLANG_HAS_DECLSPEC_DECLSPEC_ATTRIBUTE) -# undef HEDLEY_CLANG_HAS_DECLSPEC_DECLSPEC_ATTRIBUTE -#endif -#define HEDLEY_CLANG_HAS_DECLSPEC_ATTRIBUTE(attribute) HEDLEY_HAS_DECLSPEC_ATTRIBUTE(attribute) - -#if defined(HEDLEY_CLANG_HAS_WARNING) -# undef HEDLEY_CLANG_HAS_WARNING -#endif -#define HEDLEY_CLANG_HAS_WARNING(warning) HEDLEY_HAS_WARNING(warning) - -#endif /* !defined(HEDLEY_VERSION) || (HEDLEY_VERSION < X) */ From 7bf8a86090fce8baf89a06ad0e63fd471ec3224f Mon Sep 17 00:00:00 2001 From: Niels Lohmann Date: Sun, 28 Jul 2019 14:30:17 +0200 Subject: [PATCH 100/106] :hammer: adjust paths --- Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index d64d42b2..0b29278c 100644 --- a/Makefile +++ b/Makefile @@ -117,7 +117,7 @@ doctest: # -Wno-switch-enum -Wno-covered-switch-default: pedantic/contradicting warnings about switches # -Wno-weak-vtables: exception class is defined inline, but has virtual method pedantic_clang: - $(MAKE) json_unit CXX=$(COMPILER_DIR)/clang++ CXXFLAGS=" \ + $(MAKE) json_unit CXX=c++ CXXFLAGS=" \ -std=c++11 -Wno-c++98-compat -Wno-c++98-compat-pedantic \ -Werror \ -Weverything \ @@ -134,7 +134,7 @@ pedantic_clang: # calling GCC with most warnings pedantic_gcc: - $(MAKE) json_unit CXX=$(COMPILER_DIR)/g++ CXXFLAGS=" \ + $(MAKE) json_unit CXX=/usr/local/bin/g++-9 CXXFLAGS=" \ -std=c++11 \ -Waddress \ -Waddress-of-packed-member \ From d80f8b09f5aeebe223a47870e4fa5ebbe8aa5276 Mon Sep 17 00:00:00 2001 From: Niels Lohmann Date: Sun, 28 Jul 2019 15:20:07 +0200 Subject: [PATCH 101/106] :hammer: adjust version --- doc/examples/meta.output | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/examples/meta.output b/doc/examples/meta.output index 9827f2b8..d8393ed2 100644 --- a/doc/examples/meta.output +++ b/doc/examples/meta.output @@ -2,7 +2,7 @@ "compiler": { "c++": "201103", "family": "clang", - "version": "10.0.0 (clang-1000.11.45.5)" + "version": "10.0.1 (clang-1001.0.46.4)" }, "copyright": "(C) 2013-2017 Niels Lohmann", "name": "JSON for Modern C++", From d4fd731f1f81234d5b9a7afd16c64d492facdf2a Mon Sep 17 00:00:00 2001 From: Niels Lohmann Date: Sun, 28 Jul 2019 17:55:01 +0200 Subject: [PATCH 102/106] :hammer: fix release target --- Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 0b29278c..628f8c78 100644 --- a/Makefile +++ b/Makefile @@ -588,13 +588,13 @@ ChangeLog.md: # Release files ########################################################################## -# Create the files for a release and add signatures and hashes. We use `--no-extra` to make the resulting ZIP file +# Create the files for a release and add signatures and hashes. We use `-X` to make the resulting ZIP file # reproducible, see . release: rm -fr release_files mkdir release_files - zip -9 --recurse-paths --no-extra include.zip $(SRCS) + zip -9 --recurse-paths -X include.zip $(SRCS) gpg --armor --detach-sig include.zip mv include.zip include.zip.asc release_files gpg --armor --detach-sig $(AMALGAMATED_FILE) From 66d63abe6d6c4cfc001c2b4a4d19344ec138d9ae Mon Sep 17 00:00:00 2001 From: Niels Lohmann Date: Sun, 28 Jul 2019 18:40:11 +0200 Subject: [PATCH 103/106] Update Makefile --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 628f8c78..abc97389 100644 --- a/Makefile +++ b/Makefile @@ -86,7 +86,7 @@ coverage: coverage-fast: rm -fr build_coverage mkdir build_coverage - cd build_coverage ; CXX=$(COMPILER_DIR)/g++ cmake .. -GNinja -DJSON_Coverage=ON -DJSON_MultipleHeaders=ON + cd build_coverage ; CXX=g++-9 cmake .. -GNinja -DJSON_Coverage=ON -DJSON_MultipleHeaders=ON cd build_coverage ; ninja cd build_coverage ; ctest -E '.*_default' -j10 cd build_coverage ; ninja fastcov_html From 48e1fe03b55b7a11483df894f3a17c65f98b1130 Mon Sep 17 00:00:00 2001 From: Niels Lohmann Date: Sun, 28 Jul 2019 20:20:41 +0200 Subject: [PATCH 104/106] :bookmark: set version to 3.7.0 --- CMakeLists.txt | 2 +- ChangeLog.md | 146 ++++++++++++++++++++++++- doc/Doxyfile | 2 +- doc/examples/README.link | 2 +- doc/examples/meta.output | 6 +- doc/index.md | 2 +- include/nlohmann/json.hpp | 8 +- meson.build | 2 +- single_include/nlohmann/json.hpp | 8 +- test/src/fuzzer-driver_afl.cpp | 2 +- test/src/fuzzer-parse_bson.cpp | 2 +- test/src/fuzzer-parse_cbor.cpp | 2 +- test/src/fuzzer-parse_json.cpp | 2 +- test/src/fuzzer-parse_msgpack.cpp | 2 +- test/src/fuzzer-parse_ubjson.cpp | 2 +- test/src/unit-algorithms.cpp | 2 +- test/src/unit-allocator.cpp | 2 +- test/src/unit-alt-string.cpp | 2 +- test/src/unit-bson.cpp | 2 +- test/src/unit-capacity.cpp | 2 +- test/src/unit-cbor.cpp | 2 +- test/src/unit-class_const_iterator.cpp | 2 +- test/src/unit-class_iterator.cpp | 2 +- test/src/unit-class_lexer.cpp | 2 +- test/src/unit-class_parser.cpp | 2 +- test/src/unit-comparison.cpp | 2 +- test/src/unit-concepts.cpp | 2 +- test/src/unit-constructor1.cpp | 2 +- test/src/unit-constructor2.cpp | 2 +- test/src/unit-convenience.cpp | 2 +- test/src/unit-conversions.cpp | 2 +- test/src/unit-deserialization.cpp | 2 +- test/src/unit-element_access1.cpp | 2 +- test/src/unit-element_access2.cpp | 2 +- test/src/unit-inspection.cpp | 2 +- test/src/unit-items.cpp | 2 +- test/src/unit-iterators1.cpp | 2 +- test/src/unit-iterators2.cpp | 2 +- test/src/unit-json_patch.cpp | 2 +- test/src/unit-json_pointer.cpp | 2 +- test/src/unit-merge_patch.cpp | 2 +- test/src/unit-meta.cpp | 8 +- test/src/unit-modifiers.cpp | 2 +- test/src/unit-msgpack.cpp | 2 +- test/src/unit-noexcept.cpp | 2 +- test/src/unit-pointer_access.cpp | 2 +- test/src/unit-readme.cpp | 2 +- test/src/unit-reference_access.cpp | 2 +- test/src/unit-regression.cpp | 2 +- test/src/unit-serialization.cpp | 2 +- test/src/unit-testsuites.cpp | 2 +- test/src/unit-to_chars.cpp | 2 +- test/src/unit-ubjson.cpp | 2 +- test/src/unit-udt.cpp | 2 +- test/src/unit-unicode.cpp | 2 +- test/src/unit-wstring.cpp | 2 +- test/src/unit.cpp | 2 +- 57 files changed, 212 insertions(+), 68 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 5796610f..f717ff46 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,7 +4,7 @@ cmake_minimum_required(VERSION 3.1) ## PROJECT ## name and version ## -project(nlohmann_json VERSION 3.6.1 LANGUAGES CXX) +project(nlohmann_json VERSION 3.7.0 LANGUAGES CXX) ## ## INCLUDE diff --git a/ChangeLog.md b/ChangeLog.md index 39bdb4a0..dffc858d 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -1,6 +1,150 @@ # Change Log All notable changes to this project will be documented in this file. This project adheres to [Semantic Versioning](http://semver.org/). +## [v3.7.0](https://github.com/nlohmann/json/releases/tag/v3.7.0) (2019-07-28) +[Full Changelog](https://github.com/nlohmann/json/compare/v3.6.1...v3.7.0) + +- How can I retrieve uknown strings from json file in my C++ program. [\#1684](https://github.com/nlohmann/json/issues/1684) +- contains\(\) is sometimes causing stack-based buffer overrun exceptions [\#1683](https://github.com/nlohmann/json/issues/1683) +- How to deserialize arrays from json [\#1681](https://github.com/nlohmann/json/issues/1681) +- Compilation failed in VS2015 [\#1678](https://github.com/nlohmann/json/issues/1678) +- Why the compiled object file is so huge? [\#1677](https://github.com/nlohmann/json/issues/1677) +- From Version 2.1.1 to 3.6.1 serialize std::set [\#1676](https://github.com/nlohmann/json/issues/1676) +- Qt deprecation model halting compiltion [\#1675](https://github.com/nlohmann/json/issues/1675) +- Build For Raspberry pi , Rapbery with new Compiler C++17 [\#1671](https://github.com/nlohmann/json/issues/1671) +- Build from Raspberry pi [\#1667](https://github.com/nlohmann/json/issues/1667) +- Can not translate map with integer key to dict string ? [\#1664](https://github.com/nlohmann/json/issues/1664) +- Double type converts to scientific notation [\#1661](https://github.com/nlohmann/json/issues/1661) +- Missing v3.6.1 tag on master branch [\#1657](https://github.com/nlohmann/json/issues/1657) +- Support Fleese Binary Data Format [\#1654](https://github.com/nlohmann/json/issues/1654) +- Suggestion: replace alternative tokens for !, && and || with their symbols [\#1652](https://github.com/nlohmann/json/issues/1652) +- Build failure test-allocator.vcxproj [\#1651](https://github.com/nlohmann/json/issues/1651) +- How to provide function json& to\_json\(\) which is similar as 'void to\_json\(json&j, const CObject& obj\)' ? [\#1650](https://github.com/nlohmann/json/issues/1650) +- Can't throw exception when starting file is a number [\#1649](https://github.com/nlohmann/json/issues/1649) +- to\_json / from\_json with nested type [\#1648](https://github.com/nlohmann/json/issues/1648) +- How to create a json object from a std::string, created by j.dump? [\#1645](https://github.com/nlohmann/json/issues/1645) +- Problem getting vector \(array\) of strings [\#1644](https://github.com/nlohmann/json/issues/1644) +- json.hpp compilation issue with other typedefs with same name [\#1642](https://github.com/nlohmann/json/issues/1642) +- nlohmann::adl\_serializer\::to\_json no matching overloaded function found [\#1641](https://github.com/nlohmann/json/issues/1641) +- overwrite adl\_serializer\ to change behaviour [\#1638](https://github.com/nlohmann/json/issues/1638) +- json.SelectToken\("Manufacturers.Products.Price"\); [\#1637](https://github.com/nlohmann/json/issues/1637) +- Add json type as value [\#1636](https://github.com/nlohmann/json/issues/1636) +- Unit conversion test error: conversion from 'nlohmann::json' to non-scalar type 'std::string\_view' requested [\#1634](https://github.com/nlohmann/json/issues/1634) +- nlohmann VS JsonCpp by C++17 [\#1633](https://github.com/nlohmann/json/issues/1633) +- To integrate an inline helper function that return type name as string [\#1632](https://github.com/nlohmann/json/issues/1632) +- Return JSON as reference [\#1631](https://github.com/nlohmann/json/issues/1631) +- Updating from an older version causes problems with assing a json object to a struct [\#1630](https://github.com/nlohmann/json/issues/1630) +- Can without default constructor function for user defined classes when only to\_json is needed? [\#1629](https://github.com/nlohmann/json/issues/1629) +- Compilation fails with clang 6.x-8.x in C++14 mode [\#1628](https://github.com/nlohmann/json/issues/1628) +- Treating floating point as string [\#1627](https://github.com/nlohmann/json/issues/1627) +- error parsing character Ã¥ [\#1626](https://github.com/nlohmann/json/issues/1626) +- \[Help\] How to Improve Json Output Performance with Large Json Arrays [\#1624](https://github.com/nlohmann/json/issues/1624) +- Suggested link changes for reporting new issues \[blob/develop/REAME.md and blob/develop/.github/CONTRIBUTING.md\] [\#1623](https://github.com/nlohmann/json/issues/1623) +- Broken link to issue template in CONTRIBUTING.md [\#1622](https://github.com/nlohmann/json/issues/1622) +- Missing word in README.md file [\#1621](https://github.com/nlohmann/json/issues/1621) +- Package manager instructions in README for brew is incorrect [\#1620](https://github.com/nlohmann/json/issues/1620) +- Building with Visual Studio 2019 [\#1619](https://github.com/nlohmann/json/issues/1619) +- Precedence of to\_json and builtin harmful [\#1617](https://github.com/nlohmann/json/issues/1617) +- The type json is missing from the html documentation [\#1616](https://github.com/nlohmann/json/issues/1616) +- variant is not support in Release 3.6.1? [\#1615](https://github.com/nlohmann/json/issues/1615) +- Replace assert with throw for const operator\[\] [\#1614](https://github.com/nlohmann/json/issues/1614) +- Memory Overhead is Too High \(10x or more\) [\#1613](https://github.com/nlohmann/json/issues/1613) +- program crash everytime, when other data type incomming in json stream as expected [\#1612](https://github.com/nlohmann/json/issues/1612) +- Improved Enum Support [\#1611](https://github.com/nlohmann/json/issues/1611) +- is it possible convert json object back to stl container ? [\#1610](https://github.com/nlohmann/json/issues/1610) +- Add C++17-like emplace.back\(\) for arrays. [\#1609](https://github.com/nlohmann/json/issues/1609) +- is\_nothrow\_copy\_constructible fails for json::const\_iterator on MSVC2015 x86 Debug build [\#1608](https://github.com/nlohmann/json/issues/1608) +- Reading and writing array elements [\#1607](https://github.com/nlohmann/json/issues/1607) +- Converting json::value to int [\#1605](https://github.com/nlohmann/json/issues/1605) +- I have a vector of keys and and a string of value and i want to create nested json array [\#1604](https://github.com/nlohmann/json/issues/1604) +- In compatible JSON object from nlohmann::json to nohman::json - unexpected end of input; expected '\[', '{', or a literal [\#1603](https://github.com/nlohmann/json/issues/1603) +- json parser crash if having a large number integer in message [\#1602](https://github.com/nlohmann/json/issues/1602) +- Value method with undocumented throwing 302 exception [\#1601](https://github.com/nlohmann/json/issues/1601) +- Accessing value with json pointer adds key if not existing [\#1600](https://github.com/nlohmann/json/issues/1600) +- README.md broken link to project documentation [\#1597](https://github.com/nlohmann/json/issues/1597) +- Random Kudos: Thanks for your work on this! [\#1596](https://github.com/nlohmann/json/issues/1596) +- json::parse return value and errors [\#1595](https://github.com/nlohmann/json/issues/1595) +- initializer list constructor makes curly brace initialization fragile [\#1594](https://github.com/nlohmann/json/issues/1594) +- trying to log message for missing keyword, difference between \["foo"\] and at\("foo"\) [\#1593](https://github.com/nlohmann/json/issues/1593) +- std::string and std::wstring `to\_json` [\#1592](https://github.com/nlohmann/json/issues/1592) +- I have a C structure which I need to convert to a JSON. How do I do it? Haven't found proper examples so far. [\#1591](https://github.com/nlohmann/json/issues/1591) +- dump\_escaped possible error ? [\#1589](https://github.com/nlohmann/json/issues/1589) +- json::parse\(\) into a vector\ results in unhandled exception [\#1587](https://github.com/nlohmann/json/issues/1587) +- push\_back\(\)/emplace\_back\(\) on array invalidates pointers to existing array items [\#1586](https://github.com/nlohmann/json/issues/1586) +- Getting nlohmann::detail::parse\_error on JSON generated by nlohmann::json not sure why [\#1583](https://github.com/nlohmann/json/issues/1583) +- getting error terminate called after throwing an instance of 'std::domain\_error' what\(\): cannot use at\(\) with string [\#1582](https://github.com/nlohmann/json/issues/1582) +- how i create json file [\#1581](https://github.com/nlohmann/json/issues/1581) +- prevent rounding of double datatype values [\#1580](https://github.com/nlohmann/json/issues/1580) +- Documentation Container Overview Doesn't Reference Const Methods [\#1579](https://github.com/nlohmann/json/issues/1579) +- Writing an array into a nlohmann::json object [\#1578](https://github.com/nlohmann/json/issues/1578) +- compilation error when using with another library [\#1577](https://github.com/nlohmann/json/issues/1577) +- Homebrew on OSX doesn't install cmake config file [\#1576](https://github.com/nlohmann/json/issues/1576) +- `unflatten` vs objects with number-ish keys [\#1575](https://github.com/nlohmann/json/issues/1575) +- JSON Parse Out of Range Error [\#1574](https://github.com/nlohmann/json/issues/1574) +- Integrating into existing CMake Project [\#1573](https://github.com/nlohmann/json/issues/1573) +- A "thinner" source code tar as part of release? [\#1572](https://github.com/nlohmann/json/issues/1572) +- conversion to std::string failed [\#1571](https://github.com/nlohmann/json/issues/1571) +- jPtr operation does not throw [\#1569](https://github.com/nlohmann/json/issues/1569) +- How to generate dll file for this project [\#1568](https://github.com/nlohmann/json/issues/1568) +- how to pass variable data to json in c [\#1567](https://github.com/nlohmann/json/issues/1567) +- I want to achieve an upgraded function. [\#1566](https://github.com/nlohmann/json/issues/1566) +- How to determine the type of elements read from a JSON array? [\#1564](https://github.com/nlohmann/json/issues/1564) +- try\_get\_to [\#1563](https://github.com/nlohmann/json/issues/1563) +- example code compile error [\#1562](https://github.com/nlohmann/json/issues/1562) +- How to iterate over nested json object [\#1561](https://github.com/nlohmann/json/issues/1561) +- Build Option/Separate Function to Allow to Throw on Duplicate Keys [\#1560](https://github.com/nlohmann/json/issues/1560) +- Compiler Switches -Weffc++ & -Wshadow are throwing errors [\#1558](https://github.com/nlohmann/json/issues/1558) +- warning: use of the 'nodiscard' attribute is a C++17 extension [\#1557](https://github.com/nlohmann/json/issues/1557) +- Import/Export compressed JSON files [\#1556](https://github.com/nlohmann/json/issues/1556) +- GDB renderers for json library [\#1554](https://github.com/nlohmann/json/issues/1554) +- Is it possible to construct a json string object from a binary buffer? [\#1553](https://github.com/nlohmann/json/issues/1553) +- json objects in list [\#1552](https://github.com/nlohmann/json/issues/1552) +- Matrix output [\#1550](https://github.com/nlohmann/json/issues/1550) +- Using json merge\_patch on ordered non-alphanumeric datasets [\#1549](https://github.com/nlohmann/json/issues/1549) +- Invalid parsed value for big integer [\#1548](https://github.com/nlohmann/json/issues/1548) +- Integrating with android ndk issues. [\#1547](https://github.com/nlohmann/json/issues/1547) +- add noexcept json::value\("key", default\) method variant? [\#1546](https://github.com/nlohmann/json/issues/1546) +- Thank you! 🙌 [\#1545](https://github.com/nlohmann/json/issues/1545) +- Output and input matrix [\#1544](https://github.com/nlohmann/json/issues/1544) +- Add regression tests for MSVC [\#1543](https://github.com/nlohmann/json/issues/1543) +- \[Help Needed!\] Season of Docs [\#1542](https://github.com/nlohmann/json/issues/1542) +- program still abort\(\) or exit\(\) with try catch [\#1541](https://github.com/nlohmann/json/issues/1541) +- Have a json::type\_error exception because of JSON object [\#1540](https://github.com/nlohmann/json/issues/1540) +- Using versioned namespaces [\#1539](https://github.com/nlohmann/json/issues/1539) +- Quoted numbers [\#1538](https://github.com/nlohmann/json/issues/1538) +- Reading a JSON file into an object [\#1537](https://github.com/nlohmann/json/issues/1537) +- Releases 3.6.0 and 3.6.1 don't build on conda / windows [\#1536](https://github.com/nlohmann/json/issues/1536) +- \[Clang\] warning: use of the 'nodiscard' attribute is a C++17 extension \[-Wc++17-extensions\] [\#1535](https://github.com/nlohmann/json/issues/1535) +- wchar\_t/std::wstring json can be created but not accessed [\#1533](https://github.com/nlohmann/json/issues/1533) +- json stringify [\#1532](https://github.com/nlohmann/json/issues/1532) +- How can I use std::string\_view as the json\_key to "operator \[\]" ? [\#1529](https://github.com/nlohmann/json/issues/1529) +- How can I use it from gcc on RPI [\#1528](https://github.com/nlohmann/json/issues/1528) +- std::pair treated as an array instead of key-value in `std::vector\\>` [\#1520](https://github.com/nlohmann/json/issues/1520) +- Excessive Memory Usage for Large Json File [\#1516](https://github.com/nlohmann/json/issues/1516) +- SAX dumper [\#1512](https://github.com/nlohmann/json/issues/1512) +- Conversion to user type containing a std::vector not working with documented approach [\#1511](https://github.com/nlohmann/json/issues/1511) +- How to get position info or parser context with custom from\_json\(\) that may throw exceptions? [\#1508](https://github.com/nlohmann/json/issues/1508) +- Inconsistent use of type alias. [\#1507](https://github.com/nlohmann/json/issues/1507) +- Is there a current way to represent strings as json int? [\#1503](https://github.com/nlohmann/json/issues/1503) +- Intermittent issues with loadJSON [\#1484](https://github.com/nlohmann/json/issues/1484) +- use json construct std::string [\#1462](https://github.com/nlohmann/json/issues/1462) +- JSON Creation [\#1461](https://github.com/nlohmann/json/issues/1461) +- Substantial performance penalty caused by polymorphic input adapter [\#1457](https://github.com/nlohmann/json/issues/1457) +- Null bytes in files are treated like EOF [\#1095](https://github.com/nlohmann/json/issues/1095) +- Feature: to\_string\(const json& j\); [\#916](https://github.com/nlohmann/json/issues/916) + +- Use GNUInstallDirs instead of hard-coded path. [\#1673](https://github.com/nlohmann/json/pull/1673) ([remyabel](https://github.com/remyabel)) +- Package Manager: MSYS2 \(pacman\) [\#1670](https://github.com/nlohmann/json/pull/1670) ([podsvirov](https://github.com/podsvirov)) +- Fix json.hpp compilation issue with other typedefs with same name \(Issue \#1642\) [\#1643](https://github.com/nlohmann/json/pull/1643) ([kevinlul](https://github.com/kevinlul)) +- Add explicit conversion from json to std::string\_view in conversion unit test [\#1639](https://github.com/nlohmann/json/pull/1639) ([taylorhoward92](https://github.com/taylorhoward92)) +- Minor fixes in docs [\#1625](https://github.com/nlohmann/json/pull/1625) ([nickaein](https://github.com/nickaein)) +- Fix broken links to documentation [\#1598](https://github.com/nlohmann/json/pull/1598) ([nickaein](https://github.com/nickaein)) +- Added to\_string and added basic tests [\#1585](https://github.com/nlohmann/json/pull/1585) ([Macr0Nerd](https://github.com/Macr0Nerd)) +- Regression tests for MSVC [\#1570](https://github.com/nlohmann/json/pull/1570) ([nickaein](https://github.com/nickaein)) +- Fix/1511 [\#1555](https://github.com/nlohmann/json/pull/1555) ([theodelrieu](https://github.com/theodelrieu)) +- Remove C++17 extension warning from clang; \#1535 [\#1551](https://github.com/nlohmann/json/pull/1551) ([heavywatal](https://github.com/heavywatal)) +- moved from Catch to doctest for unit tests [\#1439](https://github.com/nlohmann/json/pull/1439) ([onqtam](https://github.com/onqtam)) + ## [v3.6.1](https://github.com/nlohmann/json/releases/tag/v3.6.1) (2019-03-20) [Full Changelog](https://github.com/nlohmann/json/compare/v3.6.0...v3.6.1) @@ -201,7 +345,7 @@ All notable changes to this project will be documented in this file. This projec - Fix merge\_patch shadow warning [\#1346](https://github.com/nlohmann/json/pull/1346) ([ax3l](https://github.com/ax3l)) - Allow installation via Meson [\#1345](https://github.com/nlohmann/json/pull/1345) ([mpoquet](https://github.com/mpoquet)) - Set eofbit on exhausted input stream. [\#1343](https://github.com/nlohmann/json/pull/1343) ([mefyl](https://github.com/mefyl)) -- Add a SFINAE friendly iterator\_traits and use that instead. [\#1342](https://github.com/nlohmann/json/pull/1342) ([davedissian](https://github.com/davedissian)) +- Add a SFINAE friendly iterator\_traits and use that instead. [\#1342](https://github.com/nlohmann/json/pull/1342) ([dgavedissian](https://github.com/dgavedissian)) - Fix EOL Whitespaces & CMake Spelling [\#1329](https://github.com/nlohmann/json/pull/1329) ([ax3l](https://github.com/ax3l)) ## [v3.4.0](https://github.com/nlohmann/json/releases/tag/v3.4.0) (2018-10-30) diff --git a/doc/Doxyfile b/doc/Doxyfile index 12084402..a9c611b4 100644 --- a/doc/Doxyfile +++ b/doc/Doxyfile @@ -5,7 +5,7 @@ #--------------------------------------------------------------------------- DOXYFILE_ENCODING = UTF-8 PROJECT_NAME = "JSON for Modern C++" -PROJECT_NUMBER = 3.6.1 +PROJECT_NUMBER = 3.7.0 PROJECT_BRIEF = PROJECT_LOGO = OUTPUT_DIRECTORY = . diff --git a/doc/examples/README.link b/doc/examples/README.link index 354e7eb6..42cc413c 100644 --- a/doc/examples/README.link +++ b/doc/examples/README.link @@ -1 +1 @@ -online \ No newline at end of file +online \ No newline at end of file diff --git a/doc/examples/meta.output b/doc/examples/meta.output index d8393ed2..c3557c8d 100644 --- a/doc/examples/meta.output +++ b/doc/examples/meta.output @@ -10,8 +10,8 @@ "url": "https://github.com/nlohmann/json", "version": { "major": 3, - "minor": 6, - "patch": 1, - "string": "3.6.1" + "minor": 7, + "patch": 0, + "string": "3.7.0" } } diff --git a/doc/index.md b/doc/index.md index 9b2ca947..5efff7bb 100644 --- a/doc/index.md +++ b/doc/index.md @@ -329,4 +329,4 @@ Note that this table only lists those exceptions thrown due to the type. For ins @author [Niels Lohmann](http://nlohmann.me) @see https://github.com/nlohmann/json to download the source code -@version 3.6.1 +@version 3.7.0 diff --git a/include/nlohmann/json.hpp b/include/nlohmann/json.hpp index 1821a1ba..f5210a6b 100644 --- a/include/nlohmann/json.hpp +++ b/include/nlohmann/json.hpp @@ -1,7 +1,7 @@ /* __ _____ _____ _____ __| | __| | | | JSON for Modern C++ -| | |__ | | | | | | version 3.6.1 +| | |__ | | | | | | version 3.7.0 |_____|_____|_____|_|___| https://github.com/nlohmann/json Licensed under the MIT License . @@ -31,8 +31,8 @@ SOFTWARE. #define INCLUDE_NLOHMANN_JSON_HPP_ #define NLOHMANN_JSON_VERSION_MAJOR 3 -#define NLOHMANN_JSON_VERSION_MINOR 6 -#define NLOHMANN_JSON_VERSION_PATCH 1 +#define NLOHMANN_JSON_VERSION_MINOR 7 +#define NLOHMANN_JSON_VERSION_PATCH 0 #include // all_of, find, for_each #include // assert @@ -953,7 +953,7 @@ class basic_json object = nullptr; // silence warning, see #821 if (JSON_HEDLEY_UNLIKELY(t == value_t::null)) { - JSON_THROW(other_error::create(500, "961c151d2e87f2686a955a9be24d316f1362bf21 3.6.1")); // LCOV_EXCL_LINE + JSON_THROW(other_error::create(500, "961c151d2e87f2686a955a9be24d316f1362bf21 3.7.0")); // LCOV_EXCL_LINE } break; } diff --git a/meson.build b/meson.build index 9e1eb632..5f88dae1 100644 --- a/meson.build +++ b/meson.build @@ -1,6 +1,6 @@ project('nlohmann_json', 'cpp', - version : '3.6.1', + version : '3.7.0', license : 'MIT', ) diff --git a/single_include/nlohmann/json.hpp b/single_include/nlohmann/json.hpp index c19b43c7..2a32a829 100644 --- a/single_include/nlohmann/json.hpp +++ b/single_include/nlohmann/json.hpp @@ -1,7 +1,7 @@ /* __ _____ _____ _____ __| | __| | | | JSON for Modern C++ -| | |__ | | | | | | version 3.6.1 +| | |__ | | | | | | version 3.7.0 |_____|_____|_____|_|___| https://github.com/nlohmann/json Licensed under the MIT License . @@ -31,8 +31,8 @@ SOFTWARE. #define INCLUDE_NLOHMANN_JSON_HPP_ #define NLOHMANN_JSON_VERSION_MAJOR 3 -#define NLOHMANN_JSON_VERSION_MINOR 6 -#define NLOHMANN_JSON_VERSION_PATCH 1 +#define NLOHMANN_JSON_VERSION_MINOR 7 +#define NLOHMANN_JSON_VERSION_PATCH 0 #include // all_of, find, for_each #include // assert @@ -15359,7 +15359,7 @@ class basic_json object = nullptr; // silence warning, see #821 if (JSON_HEDLEY_UNLIKELY(t == value_t::null)) { - JSON_THROW(other_error::create(500, "961c151d2e87f2686a955a9be24d316f1362bf21 3.6.1")); // LCOV_EXCL_LINE + JSON_THROW(other_error::create(500, "961c151d2e87f2686a955a9be24d316f1362bf21 3.7.0")); // LCOV_EXCL_LINE } break; } diff --git a/test/src/fuzzer-driver_afl.cpp b/test/src/fuzzer-driver_afl.cpp index 7859d74f..9aa05abd 100644 --- a/test/src/fuzzer-driver_afl.cpp +++ b/test/src/fuzzer-driver_afl.cpp @@ -1,7 +1,7 @@ /* __ _____ _____ _____ __| | __| | | | JSON for Modern C++ (fuzz test support) -| | |__ | | | | | | version 3.6.1 +| | |__ | | | | | | version 3.7.0 |_____|_____|_____|_|___| https://github.com/nlohmann/json This file implements a driver for American Fuzzy Lop (afl-fuzz). It relies on diff --git a/test/src/fuzzer-parse_bson.cpp b/test/src/fuzzer-parse_bson.cpp index d0f291ea..54ceba37 100644 --- a/test/src/fuzzer-parse_bson.cpp +++ b/test/src/fuzzer-parse_bson.cpp @@ -1,7 +1,7 @@ /* __ _____ _____ _____ __| | __| | | | JSON for Modern C++ (fuzz test support) -| | |__ | | | | | | version 3.6.1 +| | |__ | | | | | | version 3.7.0 |_____|_____|_____|_|___| https://github.com/nlohmann/json This file implements a parser test suitable for fuzz testing. Given a byte diff --git a/test/src/fuzzer-parse_cbor.cpp b/test/src/fuzzer-parse_cbor.cpp index cf1bd1ae..3dbc7450 100644 --- a/test/src/fuzzer-parse_cbor.cpp +++ b/test/src/fuzzer-parse_cbor.cpp @@ -1,7 +1,7 @@ /* __ _____ _____ _____ __| | __| | | | JSON for Modern C++ (fuzz test support) -| | |__ | | | | | | version 3.6.1 +| | |__ | | | | | | version 3.7.0 |_____|_____|_____|_|___| https://github.com/nlohmann/json This file implements a parser test suitable for fuzz testing. Given a byte diff --git a/test/src/fuzzer-parse_json.cpp b/test/src/fuzzer-parse_json.cpp index 128ce2ce..fb32933d 100644 --- a/test/src/fuzzer-parse_json.cpp +++ b/test/src/fuzzer-parse_json.cpp @@ -1,7 +1,7 @@ /* __ _____ _____ _____ __| | __| | | | JSON for Modern C++ (fuzz test support) -| | |__ | | | | | | version 3.6.1 +| | |__ | | | | | | version 3.7.0 |_____|_____|_____|_|___| https://github.com/nlohmann/json This file implements a parser test suitable for fuzz testing. Given a byte diff --git a/test/src/fuzzer-parse_msgpack.cpp b/test/src/fuzzer-parse_msgpack.cpp index 904dd348..2f03ec8e 100644 --- a/test/src/fuzzer-parse_msgpack.cpp +++ b/test/src/fuzzer-parse_msgpack.cpp @@ -1,7 +1,7 @@ /* __ _____ _____ _____ __| | __| | | | JSON for Modern C++ (fuzz test support) -| | |__ | | | | | | version 3.6.1 +| | |__ | | | | | | version 3.7.0 |_____|_____|_____|_|___| https://github.com/nlohmann/json This file implements a parser test suitable for fuzz testing. Given a byte diff --git a/test/src/fuzzer-parse_ubjson.cpp b/test/src/fuzzer-parse_ubjson.cpp index 572fef08..178bc9a4 100644 --- a/test/src/fuzzer-parse_ubjson.cpp +++ b/test/src/fuzzer-parse_ubjson.cpp @@ -1,7 +1,7 @@ /* __ _____ _____ _____ __| | __| | | | JSON for Modern C++ (fuzz test support) -| | |__ | | | | | | version 3.6.1 +| | |__ | | | | | | version 3.7.0 |_____|_____|_____|_|___| https://github.com/nlohmann/json This file implements a parser test suitable for fuzz testing. Given a byte diff --git a/test/src/unit-algorithms.cpp b/test/src/unit-algorithms.cpp index dca22d41..14a55aa2 100644 --- a/test/src/unit-algorithms.cpp +++ b/test/src/unit-algorithms.cpp @@ -1,7 +1,7 @@ /* __ _____ _____ _____ __| | __| | | | JSON for Modern C++ (test suite) -| | |__ | | | | | | version 3.6.1 +| | |__ | | | | | | version 3.7.0 |_____|_____|_____|_|___| https://github.com/nlohmann/json Licensed under the MIT License . diff --git a/test/src/unit-allocator.cpp b/test/src/unit-allocator.cpp index c46afc59..f7e8b201 100644 --- a/test/src/unit-allocator.cpp +++ b/test/src/unit-allocator.cpp @@ -1,7 +1,7 @@ /* __ _____ _____ _____ __| | __| | | | JSON for Modern C++ (test suite) -| | |__ | | | | | | version 3.6.1 +| | |__ | | | | | | version 3.7.0 |_____|_____|_____|_|___| https://github.com/nlohmann/json Licensed under the MIT License . diff --git a/test/src/unit-alt-string.cpp b/test/src/unit-alt-string.cpp index 39206b65..6a9e36a3 100644 --- a/test/src/unit-alt-string.cpp +++ b/test/src/unit-alt-string.cpp @@ -1,7 +1,7 @@ /* __ _____ _____ _____ __| | __| | | | JSON for Modern C++ (test suite) -| | |__ | | | | | | version 3.6.1 +| | |__ | | | | | | version 3.7.0 |_____|_____|_____|_|___| https://github.com/nlohmann/json Licensed under the MIT License . diff --git a/test/src/unit-bson.cpp b/test/src/unit-bson.cpp index cc4b5a65..ee5bf06d 100644 --- a/test/src/unit-bson.cpp +++ b/test/src/unit-bson.cpp @@ -1,7 +1,7 @@ /* __ _____ _____ _____ __| | __| | | | JSON for Modern C++ (test suite) -| | |__ | | | | | | version 3.6.1 +| | |__ | | | | | | version 3.7.0 |_____|_____|_____|_|___| https://github.com/nlohmann/json Licensed under the MIT License . diff --git a/test/src/unit-capacity.cpp b/test/src/unit-capacity.cpp index 3c49a6e9..d01ddb4f 100644 --- a/test/src/unit-capacity.cpp +++ b/test/src/unit-capacity.cpp @@ -1,7 +1,7 @@ /* __ _____ _____ _____ __| | __| | | | JSON for Modern C++ (test suite) -| | |__ | | | | | | version 3.6.1 +| | |__ | | | | | | version 3.7.0 |_____|_____|_____|_|___| https://github.com/nlohmann/json Licensed under the MIT License . diff --git a/test/src/unit-cbor.cpp b/test/src/unit-cbor.cpp index 8b4a1707..399eed28 100644 --- a/test/src/unit-cbor.cpp +++ b/test/src/unit-cbor.cpp @@ -1,7 +1,7 @@ /* __ _____ _____ _____ __| | __| | | | JSON for Modern C++ (test suite) -| | |__ | | | | | | version 3.6.1 +| | |__ | | | | | | version 3.7.0 |_____|_____|_____|_|___| https://github.com/nlohmann/json Licensed under the MIT License . diff --git a/test/src/unit-class_const_iterator.cpp b/test/src/unit-class_const_iterator.cpp index 7853be11..6294de31 100644 --- a/test/src/unit-class_const_iterator.cpp +++ b/test/src/unit-class_const_iterator.cpp @@ -1,7 +1,7 @@ /* __ _____ _____ _____ __| | __| | | | JSON for Modern C++ (test suite) -| | |__ | | | | | | version 3.6.1 +| | |__ | | | | | | version 3.7.0 |_____|_____|_____|_|___| https://github.com/nlohmann/json Licensed under the MIT License . diff --git a/test/src/unit-class_iterator.cpp b/test/src/unit-class_iterator.cpp index f4ad075d..be9bcd97 100644 --- a/test/src/unit-class_iterator.cpp +++ b/test/src/unit-class_iterator.cpp @@ -1,7 +1,7 @@ /* __ _____ _____ _____ __| | __| | | | JSON for Modern C++ (test suite) -| | |__ | | | | | | version 3.6.1 +| | |__ | | | | | | version 3.7.0 |_____|_____|_____|_|___| https://github.com/nlohmann/json Licensed under the MIT License . diff --git a/test/src/unit-class_lexer.cpp b/test/src/unit-class_lexer.cpp index 64737b57..bdc1e2f2 100644 --- a/test/src/unit-class_lexer.cpp +++ b/test/src/unit-class_lexer.cpp @@ -1,7 +1,7 @@ /* __ _____ _____ _____ __| | __| | | | JSON for Modern C++ (test suite) -| | |__ | | | | | | version 3.6.1 +| | |__ | | | | | | version 3.7.0 |_____|_____|_____|_|___| https://github.com/nlohmann/json Licensed under the MIT License . diff --git a/test/src/unit-class_parser.cpp b/test/src/unit-class_parser.cpp index fa09c565..098920fd 100644 --- a/test/src/unit-class_parser.cpp +++ b/test/src/unit-class_parser.cpp @@ -1,7 +1,7 @@ /* __ _____ _____ _____ __| | __| | | | JSON for Modern C++ (test suite) -| | |__ | | | | | | version 3.6.1 +| | |__ | | | | | | version 3.7.0 |_____|_____|_____|_|___| https://github.com/nlohmann/json Licensed under the MIT License . diff --git a/test/src/unit-comparison.cpp b/test/src/unit-comparison.cpp index 6d02f581..655fd269 100644 --- a/test/src/unit-comparison.cpp +++ b/test/src/unit-comparison.cpp @@ -1,7 +1,7 @@ /* __ _____ _____ _____ __| | __| | | | JSON for Modern C++ (test suite) -| | |__ | | | | | | version 3.6.1 +| | |__ | | | | | | version 3.7.0 |_____|_____|_____|_|___| https://github.com/nlohmann/json Licensed under the MIT License . diff --git a/test/src/unit-concepts.cpp b/test/src/unit-concepts.cpp index f28f0432..4228e18a 100644 --- a/test/src/unit-concepts.cpp +++ b/test/src/unit-concepts.cpp @@ -1,7 +1,7 @@ /* __ _____ _____ _____ __| | __| | | | JSON for Modern C++ (test suite) -| | |__ | | | | | | version 3.6.1 +| | |__ | | | | | | version 3.7.0 |_____|_____|_____|_|___| https://github.com/nlohmann/json Licensed under the MIT License . diff --git a/test/src/unit-constructor1.cpp b/test/src/unit-constructor1.cpp index 93528d37..b66044ac 100644 --- a/test/src/unit-constructor1.cpp +++ b/test/src/unit-constructor1.cpp @@ -1,7 +1,7 @@ /* __ _____ _____ _____ __| | __| | | | JSON for Modern C++ (test suite) -| | |__ | | | | | | version 3.6.1 +| | |__ | | | | | | version 3.7.0 |_____|_____|_____|_|___| https://github.com/nlohmann/json Licensed under the MIT License . diff --git a/test/src/unit-constructor2.cpp b/test/src/unit-constructor2.cpp index 5d9649b2..e13b5c1c 100644 --- a/test/src/unit-constructor2.cpp +++ b/test/src/unit-constructor2.cpp @@ -1,7 +1,7 @@ /* __ _____ _____ _____ __| | __| | | | JSON for Modern C++ (test suite) -| | |__ | | | | | | version 3.6.1 +| | |__ | | | | | | version 3.7.0 |_____|_____|_____|_|___| https://github.com/nlohmann/json Licensed under the MIT License . diff --git a/test/src/unit-convenience.cpp b/test/src/unit-convenience.cpp index 030b04f6..e75261a9 100644 --- a/test/src/unit-convenience.cpp +++ b/test/src/unit-convenience.cpp @@ -1,7 +1,7 @@ /* __ _____ _____ _____ __| | __| | | | JSON for Modern C++ (test suite) -| | |__ | | | | | | version 3.6.1 +| | |__ | | | | | | version 3.7.0 |_____|_____|_____|_|___| https://github.com/nlohmann/json Licensed under the MIT License . diff --git a/test/src/unit-conversions.cpp b/test/src/unit-conversions.cpp index fa75428c..9d48e29d 100644 --- a/test/src/unit-conversions.cpp +++ b/test/src/unit-conversions.cpp @@ -1,7 +1,7 @@ /* __ _____ _____ _____ __| | __| | | | JSON for Modern C++ (test suite) -| | |__ | | | | | | version 3.6.1 +| | |__ | | | | | | version 3.7.0 |_____|_____|_____|_|___| https://github.com/nlohmann/json Licensed under the MIT License . diff --git a/test/src/unit-deserialization.cpp b/test/src/unit-deserialization.cpp index f49f1025..dcc20492 100644 --- a/test/src/unit-deserialization.cpp +++ b/test/src/unit-deserialization.cpp @@ -1,7 +1,7 @@ /* __ _____ _____ _____ __| | __| | | | JSON for Modern C++ (test suite) -| | |__ | | | | | | version 3.6.1 +| | |__ | | | | | | version 3.7.0 |_____|_____|_____|_|___| https://github.com/nlohmann/json Licensed under the MIT License . diff --git a/test/src/unit-element_access1.cpp b/test/src/unit-element_access1.cpp index 18c6c3d3..58f2d016 100644 --- a/test/src/unit-element_access1.cpp +++ b/test/src/unit-element_access1.cpp @@ -1,7 +1,7 @@ /* __ _____ _____ _____ __| | __| | | | JSON for Modern C++ (test suite) -| | |__ | | | | | | version 3.6.1 +| | |__ | | | | | | version 3.7.0 |_____|_____|_____|_|___| https://github.com/nlohmann/json Licensed under the MIT License . diff --git a/test/src/unit-element_access2.cpp b/test/src/unit-element_access2.cpp index 95dddd3b..43b1368b 100644 --- a/test/src/unit-element_access2.cpp +++ b/test/src/unit-element_access2.cpp @@ -1,7 +1,7 @@ /* __ _____ _____ _____ __| | __| | | | JSON for Modern C++ (test suite) -| | |__ | | | | | | version 3.6.1 +| | |__ | | | | | | version 3.7.0 |_____|_____|_____|_|___| https://github.com/nlohmann/json Licensed under the MIT License . diff --git a/test/src/unit-inspection.cpp b/test/src/unit-inspection.cpp index 68d69b83..d8577359 100644 --- a/test/src/unit-inspection.cpp +++ b/test/src/unit-inspection.cpp @@ -1,7 +1,7 @@ /* __ _____ _____ _____ __| | __| | | | JSON for Modern C++ (test suite) -| | |__ | | | | | | version 3.6.1 +| | |__ | | | | | | version 3.7.0 |_____|_____|_____|_|___| https://github.com/nlohmann/json Licensed under the MIT License . diff --git a/test/src/unit-items.cpp b/test/src/unit-items.cpp index 643c82f4..e94aa0ae 100644 --- a/test/src/unit-items.cpp +++ b/test/src/unit-items.cpp @@ -1,7 +1,7 @@ /* __ _____ _____ _____ __| | __| | | | JSON for Modern C++ (test suite) -| | |__ | | | | | | version 3.6.1 +| | |__ | | | | | | version 3.7.0 |_____|_____|_____|_|___| https://github.com/nlohmann/json Licensed under the MIT License . diff --git a/test/src/unit-iterators1.cpp b/test/src/unit-iterators1.cpp index ee5db45d..33634756 100644 --- a/test/src/unit-iterators1.cpp +++ b/test/src/unit-iterators1.cpp @@ -1,7 +1,7 @@ /* __ _____ _____ _____ __| | __| | | | JSON for Modern C++ (test suite) -| | |__ | | | | | | version 3.6.1 +| | |__ | | | | | | version 3.7.0 |_____|_____|_____|_|___| https://github.com/nlohmann/json Licensed under the MIT License . diff --git a/test/src/unit-iterators2.cpp b/test/src/unit-iterators2.cpp index 0f27f05d..de4f6ff9 100644 --- a/test/src/unit-iterators2.cpp +++ b/test/src/unit-iterators2.cpp @@ -1,7 +1,7 @@ /* __ _____ _____ _____ __| | __| | | | JSON for Modern C++ (test suite) -| | |__ | | | | | | version 3.6.1 +| | |__ | | | | | | version 3.7.0 |_____|_____|_____|_|___| https://github.com/nlohmann/json Licensed under the MIT License . diff --git a/test/src/unit-json_patch.cpp b/test/src/unit-json_patch.cpp index d8132ab5..7310db28 100644 --- a/test/src/unit-json_patch.cpp +++ b/test/src/unit-json_patch.cpp @@ -1,7 +1,7 @@ /* __ _____ _____ _____ __| | __| | | | JSON for Modern C++ (test suite) -| | |__ | | | | | | version 3.6.1 +| | |__ | | | | | | version 3.7.0 |_____|_____|_____|_|___| https://github.com/nlohmann/json Licensed under the MIT License . diff --git a/test/src/unit-json_pointer.cpp b/test/src/unit-json_pointer.cpp index 598f36b0..9746d80d 100644 --- a/test/src/unit-json_pointer.cpp +++ b/test/src/unit-json_pointer.cpp @@ -1,7 +1,7 @@ /* __ _____ _____ _____ __| | __| | | | JSON for Modern C++ (test suite) -| | |__ | | | | | | version 3.6.1 +| | |__ | | | | | | version 3.7.0 |_____|_____|_____|_|___| https://github.com/nlohmann/json Licensed under the MIT License . diff --git a/test/src/unit-merge_patch.cpp b/test/src/unit-merge_patch.cpp index cdc328c4..99840335 100644 --- a/test/src/unit-merge_patch.cpp +++ b/test/src/unit-merge_patch.cpp @@ -1,7 +1,7 @@ /* __ _____ _____ _____ __| | __| | | | JSON for Modern C++ (test suite) -| | |__ | | | | | | version 3.6.1 +| | |__ | | | | | | version 3.7.0 |_____|_____|_____|_|___| https://github.com/nlohmann/json Licensed under the MIT License . diff --git a/test/src/unit-meta.cpp b/test/src/unit-meta.cpp index 4f9e9652..a674060f 100644 --- a/test/src/unit-meta.cpp +++ b/test/src/unit-meta.cpp @@ -1,7 +1,7 @@ /* __ _____ _____ _____ __| | __| | | | JSON for Modern C++ (test suite) -| | |__ | | | | | | version 3.6.1 +| | |__ | | | | | | version 3.7.0 |_____|_____|_____|_|___| https://github.com/nlohmann/json Licensed under the MIT License . @@ -43,10 +43,10 @@ TEST_CASE("version information") CHECK(j["url"] == "https://github.com/nlohmann/json"); CHECK(j["version"] == json( { - {"string", "3.6.1"}, + {"string", "3.7.0"}, {"major", 3}, - {"minor", 6}, - {"patch", 1} + {"minor", 7}, + {"patch", 0} })); CHECK(j.find("platform") != j.end()); diff --git a/test/src/unit-modifiers.cpp b/test/src/unit-modifiers.cpp index cbfd09e4..cc04cc3b 100644 --- a/test/src/unit-modifiers.cpp +++ b/test/src/unit-modifiers.cpp @@ -1,7 +1,7 @@ /* __ _____ _____ _____ __| | __| | | | JSON for Modern C++ (test suite) -| | |__ | | | | | | version 3.6.1 +| | |__ | | | | | | version 3.7.0 |_____|_____|_____|_|___| https://github.com/nlohmann/json Licensed under the MIT License . diff --git a/test/src/unit-msgpack.cpp b/test/src/unit-msgpack.cpp index 7a095544..09ff7c51 100644 --- a/test/src/unit-msgpack.cpp +++ b/test/src/unit-msgpack.cpp @@ -1,7 +1,7 @@ /* __ _____ _____ _____ __| | __| | | | JSON for Modern C++ (test suite) -| | |__ | | | | | | version 3.6.1 +| | |__ | | | | | | version 3.7.0 |_____|_____|_____|_|___| https://github.com/nlohmann/json Licensed under the MIT License . diff --git a/test/src/unit-noexcept.cpp b/test/src/unit-noexcept.cpp index 89049bfe..8e46f325 100644 --- a/test/src/unit-noexcept.cpp +++ b/test/src/unit-noexcept.cpp @@ -1,7 +1,7 @@ /* __ _____ _____ _____ __| | __| | | | JSON for Modern C++ (test suite) -| | |__ | | | | | | version 3.6.1 +| | |__ | | | | | | version 3.7.0 |_____|_____|_____|_|___| https://github.com/nlohmann/json Licensed under the MIT License . diff --git a/test/src/unit-pointer_access.cpp b/test/src/unit-pointer_access.cpp index 30fa0c29..a35675e6 100644 --- a/test/src/unit-pointer_access.cpp +++ b/test/src/unit-pointer_access.cpp @@ -1,7 +1,7 @@ /* __ _____ _____ _____ __| | __| | | | JSON for Modern C++ (test suite) -| | |__ | | | | | | version 3.6.1 +| | |__ | | | | | | version 3.7.0 |_____|_____|_____|_|___| https://github.com/nlohmann/json Licensed under the MIT License . diff --git a/test/src/unit-readme.cpp b/test/src/unit-readme.cpp index 4af68449..5b925e32 100644 --- a/test/src/unit-readme.cpp +++ b/test/src/unit-readme.cpp @@ -1,7 +1,7 @@ /* __ _____ _____ _____ __| | __| | | | JSON for Modern C++ (test suite) -| | |__ | | | | | | version 3.6.1 +| | |__ | | | | | | version 3.7.0 |_____|_____|_____|_|___| https://github.com/nlohmann/json Licensed under the MIT License . diff --git a/test/src/unit-reference_access.cpp b/test/src/unit-reference_access.cpp index a9a0f6e5..bb7acda7 100644 --- a/test/src/unit-reference_access.cpp +++ b/test/src/unit-reference_access.cpp @@ -1,7 +1,7 @@ /* __ _____ _____ _____ __| | __| | | | JSON for Modern C++ (test suite) -| | |__ | | | | | | version 3.6.1 +| | |__ | | | | | | version 3.7.0 |_____|_____|_____|_|___| https://github.com/nlohmann/json Licensed under the MIT License . diff --git a/test/src/unit-regression.cpp b/test/src/unit-regression.cpp index 0cadd608..866a985b 100644 --- a/test/src/unit-regression.cpp +++ b/test/src/unit-regression.cpp @@ -1,7 +1,7 @@ /* __ _____ _____ _____ __| | __| | | | JSON for Modern C++ (test suite) -| | |__ | | | | | | version 3.6.1 +| | |__ | | | | | | version 3.7.0 |_____|_____|_____|_|___| https://github.com/nlohmann/json Licensed under the MIT License . diff --git a/test/src/unit-serialization.cpp b/test/src/unit-serialization.cpp index 7df2bf9c..3a0b28e4 100644 --- a/test/src/unit-serialization.cpp +++ b/test/src/unit-serialization.cpp @@ -1,7 +1,7 @@ /* __ _____ _____ _____ __| | __| | | | JSON for Modern C++ (test suite) -| | |__ | | | | | | version 3.6.1 +| | |__ | | | | | | version 3.7.0 |_____|_____|_____|_|___| https://github.com/nlohmann/json Licensed under the MIT License . diff --git a/test/src/unit-testsuites.cpp b/test/src/unit-testsuites.cpp index e65fb88e..7f612381 100644 --- a/test/src/unit-testsuites.cpp +++ b/test/src/unit-testsuites.cpp @@ -1,7 +1,7 @@ /* __ _____ _____ _____ __| | __| | | | JSON for Modern C++ (test suite) -| | |__ | | | | | | version 3.6.1 +| | |__ | | | | | | version 3.7.0 |_____|_____|_____|_|___| https://github.com/nlohmann/json Licensed under the MIT License . diff --git a/test/src/unit-to_chars.cpp b/test/src/unit-to_chars.cpp index dbd5e175..ae96ca45 100644 --- a/test/src/unit-to_chars.cpp +++ b/test/src/unit-to_chars.cpp @@ -1,7 +1,7 @@ /* __ _____ _____ _____ __| | __| | | | JSON for Modern C++ (test suite) -| | |__ | | | | | | version 3.6.1 +| | |__ | | | | | | version 3.7.0 |_____|_____|_____|_|___| https://github.com/nlohmann/json Licensed under the MIT License . diff --git a/test/src/unit-ubjson.cpp b/test/src/unit-ubjson.cpp index 46539dd6..f8220106 100644 --- a/test/src/unit-ubjson.cpp +++ b/test/src/unit-ubjson.cpp @@ -1,7 +1,7 @@ /* __ _____ _____ _____ __| | __| | | | JSON for Modern C++ (test suite) -| | |__ | | | | | | version 3.6.1 +| | |__ | | | | | | version 3.7.0 |_____|_____|_____|_|___| https://github.com/nlohmann/json Licensed under the MIT License . diff --git a/test/src/unit-udt.cpp b/test/src/unit-udt.cpp index 6e70af83..41c952e5 100644 --- a/test/src/unit-udt.cpp +++ b/test/src/unit-udt.cpp @@ -1,7 +1,7 @@ /* __ _____ _____ _____ __| | __| | | | JSON for Modern C++ (test suite) -| | |__ | | | | | | version 3.6.1 +| | |__ | | | | | | version 3.7.0 |_____|_____|_____|_|___| https://github.com/nlohmann/json Licensed under the MIT License . diff --git a/test/src/unit-unicode.cpp b/test/src/unit-unicode.cpp index 0f499c70..4663f9c8 100644 --- a/test/src/unit-unicode.cpp +++ b/test/src/unit-unicode.cpp @@ -1,7 +1,7 @@ /* __ _____ _____ _____ __| | __| | | | JSON for Modern C++ (test suite) -| | |__ | | | | | | version 3.6.1 +| | |__ | | | | | | version 3.7.0 |_____|_____|_____|_|___| https://github.com/nlohmann/json Licensed under the MIT License . diff --git a/test/src/unit-wstring.cpp b/test/src/unit-wstring.cpp index 59826533..ad207092 100644 --- a/test/src/unit-wstring.cpp +++ b/test/src/unit-wstring.cpp @@ -1,7 +1,7 @@ /* __ _____ _____ _____ __| | __| | | | JSON for Modern C++ (test suite) -| | |__ | | | | | | version 3.6.1 +| | |__ | | | | | | version 3.7.0 |_____|_____|_____|_|___| https://github.com/nlohmann/json Licensed under the MIT License . diff --git a/test/src/unit.cpp b/test/src/unit.cpp index 04495bb7..e6ebffb5 100644 --- a/test/src/unit.cpp +++ b/test/src/unit.cpp @@ -1,7 +1,7 @@ /* __ _____ _____ _____ __| | __| | | | JSON for Modern C++ (test suite) -| | |__ | | | | | | version 3.6.1 +| | |__ | | | | | | version 3.7.0 |_____|_____|_____|_|___| https://github.com/nlohmann/json Licensed under the MIT License . From ddb7f70a128f07bba371bc9c532759130aae0545 Mon Sep 17 00:00:00 2001 From: Niels Lohmann Date: Sun, 28 Jul 2019 20:53:18 +0200 Subject: [PATCH 105/106] :pencil: update documentation --- doc/json.gif | Bin 1703994 -> 1704013 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/doc/json.gif b/doc/json.gif index ebe2cf0884f16a4b3616002582aea8804abb8106..c3e37ed8e39999c405f42a17ec36be4c6313547a 100644 GIT binary patch delta 48823 zcmWJscQD+K6aCyd+?{s1XwiF*NF>PN^b)=IAP9mWBIFK-(|d^)z1Qe1IlcE@qj!QJ z(tLlvzjtPLcIUmFeKT*{Fiv9_r+90$&a<57$Q(Vz93$0iGtDe3-9mlEGDF2eGmUa{ zjUp43LTjB$Yn?1RqbvurY$wYqo9BgghE*>N3LH!;98C+HEi0TYY8?zezp}`7dy)3~ zWsdi&j5n_`{k^k4ysLD#EpWB1e{ECc<&f{=TI%zv(aXNY$Fb4Zxy9GH;hkICJCJL_ zHvyuqh`{a;pCnR{DnV&RT9O&)nQ>oI#9(Ul@WMBR;t7kt~EHzfm*Ov6RHqW&+th6`GeQ90$+Pc_WH{I2_ z-qpU*)0y-GBtkOOyE8t#H#K%JGm#_&zQ?omZF_tBcyIUQG93Q z_p7U`U)NXv{rBIW+n-4n^F{S!1Xf^BT-p>1e6d;QjNvb+9tjmEKtydu=|Hxc3(l3q zy`$QVERupqs2SUgOuB%vv1;Fs$0SFe$LXPq)qag6q~FV9ld4Hr(D_EpHk|-DkU34V zams=D%Ed?+L?W{eB2DjFmK6(DoQ3Zy_;nEZoriuD+=OM?)4XX3CSZui5b$9@6dMXG z;JV1ec?d(^MmLUD#}2}010ritU~3a(v_{zUY@d2$&~@0dlaw+PoOegR%EAze;XzhV zrFYrVk%CJ~MSegkw>bN3Fr%CnXR%m|%_-kO0l7OW zB&qB+7upXa zG4HP{O2_i!&&BD0x2JIYc_`PPFnad{!$k6XAbb)dIU93T>EpBdD9oBhFMZnmyV1GM zgsBqK6ZPjmvdy=WjL6yGn2VcB(KKKtO*IKaE-BO(A3)w>QA1BTDCThw3J?H+G@AiQ zQj}F5{(>M<3f=$!flf{cboLFT?@HSEf0@3d-{dUB#yaj52&hpKD}^)2C<#a5N#2JK z9_GVPZ$^_kMk1z?h!G?I56mFAKvPM#2o*#L97mI}bp4UQHVeV)NmQ5goRabXxm+lD zhzrgE3L8SBq%=xVNFM@jl{8E#AR+~ya^<) zAhbe2FOCp9ZB`F65Kc>e6_Jz$2&mOLK#Bp*Qvgz%JHmSvsX|k59wvu9f6}J{RD(Ko zq*0$J-V^!)(1)+6zaXIO{e*9TDozlo&j!FvWDTAC{N}t)w62DpD2N7>#Nk|cQcm;z zi4~K%?2jXa*^mty+)s7Q=q?t8C=-ZYTk>;$Pf9pq^O}ijvCYccjM4`g2iqupN(qN! zT-}E$St_i8DiGa~7`8e%d2Qvg5@3XAU>7Hb#%C1#0#5zv?~B7pH*iokOBr2KV|)p4 z-bf)%oZp^h9A7CAln(-0q2g|XaO&nrTlKn%uwgk{^a^4QYDdVarfINhJ;{=p4 zOTY@qMC`!4^TgnJ=N;or@RuXi6Du9_cjleJ_bBrwU7hIwQk@DW%KUMr&Z$?O1;{UB z#~t!dnnoU0v5L1u@KUy~yk*@aF&6v!|It_>+bBGpq6OW_fWY*2$}eKsYwf_sNb=;< zFO%q~&cpYelShP@a75=We*b;v?g)NK5aDzFb$Pe5+MG&g*#+8$FpkGJwKb|uHE#8N zola^e&C6N+NEHDu3XhEMap{N|$Qn7OG&26+(2gz{saDmXe3s=H-1_Fou$vC_)ryId zlevVc>)r1#Po7PHkiSDJDvag-J(B>$V(4bFpdP|K$C+b4XiynVOa4pEAf-yG#gC4O z{xqJ^g^eWkBFwU1j}TQxEgbUwcZmMxa-92LhT52)b%T>VES{KQ;>!HnzOkY{!vz%ecuTL&>72E`I((dG3iFW$> z2))Sz@QqR_3Wb*+Q`ZYx5irpRby&V5l@+T*=myyKMp7*w4pM*yNt;HXo*mWw2uFS@ z6`26}6GYYINR=<}`Y$5-FZTb)#--J8<_)dv4iM=!Lk4=`L8LAgeP@}J1sh#Je|Cih zC6S|)yV36_0}uzH?|A+pRyu4)f5s9vb+L4fFZ+}egT{aJ zOhBiGV@lq$1XcewO6zr|!~?UlQscFxDd4GifOvvT3em?lX7HPei_9KfwL(K(WyyL< z-B)Qj@K@&jD&kKIm8IJ_-9`K6{Ak_bI|KeeF5Q`&pVNf811^td$buFSVOay`6U(&S zG+i@GeN}Xi18Ow8elx!gETzP(xlk=kPzH^p(+4w@Md5RC4>S?ju_o|T|EAOcKjkvu zxa?iot*Se}G&+o4cF{SdEEO)j=h;F(-yXK=Czn0OF23ZkFb3D{nRlWT4zxYm zTQ1O`Qh%4xcZ|rn>xd>f4W!$AG5of9`0wH?mnAxrwV3@7jC2V&Z{_3LNe5m8miJ9? z09Ad~j5g&wh2KEL$El_hL;)@Hn>Y)jm%ni{^ zW;19yd1OeX{t+-5v-nRK(L84HzT7Fs5`mBZrdYB}IrU9k^`l(p6wjRp7weqo63H6x zbV%U0KFlHku)@6J(m^&~Sykxg`pvm`fdI75R9wx|wU(Jh$y~MCx#k!8YJu}&Ly>m} zB=Tl<6ropbRZxo_C0E--rUHgJTZ-hi=`qRFx_i643zT)64$ZSvd2@=q+alWQuH=9+ z`SQ=PQaaw*J0{RHkeZ~~wa_x$_>47=QFdX|cbBzmm;PpignjFHcVR5z{Xxq#Q^IO` z$-)<4$jWUI9CS!31^2JEIyhXl9zWQct72N48rYa!xkhg$AWY9N%d&_9xd1W| z1VJF_5;Vf+OV&g8av|NGcJfhKcbX6GqsW|fvbyy@&|_mJ_ouOxdt){(AEw)K5JVpq zU|$d(>wce35se~N`J+e0tZDJ%n`kmymgcjSzJ0yn5Nlb=O)GTs2h#L+*w^b`hUCBk z!^zk~0Nr}$Q8Y?Pf7g4FeWKL0IvTn?%DDmq9WgZlvD%b`6E@pcln-U*2QbsyjThjl zQ{A(>52F9RyObP2bY7a7(ziPKhG7wUeU>)^1m;J8@h)K_{u?{ZegouDTFYJvDFL-h&q?$dHLf~q=ahbhQiUN94!o4nw6)8%#v zLwDTTZ)~KUm`rIB4ho$Ys#rpE2%P0G$Bfk->yytf+LIJb94;W;rawMS5^3t+15^ z4!Na_BNr1PJr~~uVww3PQKkrn0b+j3FQkTgd!ruoR`AWt` zLPiFMdc|7Va-ocdM+W7FRaSi&hQ~(LmYpB^p6v4sW%ntpqZl@ZXF*QJ3bGiq)c$A^ z2g$A1l1l+5*}rZX6{QCZ5CxIZH%wEXZ$?JcUn;%BZwALvIGX)38L%}^v+^&$vkOSC z9JkBUqL>|=Ing2r3SbeGitJiS4)U9q4HP@JWj_mN zwfyaUG*@LkkYm}dUni<^ER==L#5k5Z5vUdg%t&diGLSG+eQlO5*<#wZ0`(B<+8RLnhA`l#!E6sk@b&S$NqL=p0e=_hv88 z#64S=>Tm|tNCv3&o#OP)TkgGeAuMBhyHlrf9}SUEWe?}_Dx=V6j4nYlUq7`;E}8Tf zEnm0Fi0@2ZrzS4~xH%{b{@ih}X^QupP~pWVP$C=*dG>fX(H7iQB!g)6u2#KrxB=R_ zD+14Ly%Sr$WRMZPbmg@t`lkvIvU;$AP~u*?C0F1FHXuPp%#T`fpJAFJh zu?Qm{C12_iFoe|8^{-(trc8WOpZo<<(Vd)_4Ffem@soKvq{t{xjsmxsWkr)LpO!yy zB7J_Jkk>-qdy3CV#d6>`_zAo2s08EKI~KKdpNEE*++dn8G!B$zv@|3SCP;zKWkR3~ zQl8f8iGrh6zr9V&MY|1EEyeR&Og_FWZgtFj-7nq#Lg^aD5T<_zw~@kF-m>T zOC!8YwHfz2l&?E3i_F;W(|KD2rkU%ArbzDXavI*f;`coa-{v3H16=j(;P_`^0R!F` z?j5I>30p)D(PCB75|6|R92kEU0DlGeU8843oDWwEPZ!0&(6~Y8+|EmrLePpR;(xknGCIFJ2Dicjb3QBuDrFeCnXR9%?G|KoG3q8o`;{4<5@f+R~S z;1U;#Ho5>(WN)f3wNc1Z+Lp2cSih)`9NQG zn}|`%QOxlhPz7ZlO#JAbf!J(BBEcVfXla1Pe!_mWo%c-gcXmd!QJq)}UcpSsjIMCi z)IO-N$A;)(i#)k+ykLF3>N!<&9uOVJW9mP&n-i>%CNs&!52I<pVIG_o2w=N%2H%YeBx@JA2agzs6i#JUI(YN~C9o#{H_% z4`{+rIO#*v377FVpXN|J?1WErg6U>+t-4ASP$r31HlB(x$!ZF;Tm7X%7o2rTFkzL; zcBa8Xv-{7=PU$0-hMQ&= zI^U+6v=GP@-KVK`>J%J3o;xK5-r#zUPHtt(NdC?Z8XM-&1!o;VQRXd?O?%<`EtL}iO(v=EV2Z$82!aAmVm8!9f39SO?-qiPM zL;NaE=?l~Lb@U0`sDA&v>JuX_KA%{_A(y;b_1@+lS_<=&c8fi!Mk+TmARD+>!DeU@Y%^()mFgJzK<=nK=8ZM8&W!g9Jjw;y_*Kd^Hkze|k zXOy@~tU6#C4ieV!nio73F@vIL&I0P1$iiAm{?~8+_)`~A?KaWv>}m|wr+h4Sd(y2` z{h^^^1@U^cl~>s_(r{JqfDzTk%umE}O<-}ymfzQ=HS}6RS%&glS(y7x#JR%wirV)p zuArG!)mSnKGhE9Rr$y*^AiG|Mp)&RjZQYrpkC$!eO<^OvO8_-`YoCKaKjwU*>m?uG zl|*iA-%0h6De*5KwTK`jK_W<0{qd`m$Hsd-+&q&pHBhI29q;h=q)`5>pI z)N`T0{$E|#(x9$K4!=(0#d)#sm$ac8KG}(~GyB{NU!n;#E*(Ng(ZASxtD(UxTd$B~ zT|2xg?}qmQuTZET=XY&YU`v)pm(%_;w{EQ}m3vB@@MtR_FG=*#X?6ZIlLTRS@4<-3^vtpoQ5D+ zgx2Jq%)PU_9Yu2;Y7qw>D8qy{ZSFgFj{bE^M%n{ zhE<`vvhFL7cQ>z4wsHmBx)k3tc_)9r9ahHHs-M&uxrh^}#5Jb3p*drr*tQkb?rh|< zgh9bru?HDjNJumkrwDZhDPj>~^d0;v{t*xLV}w?5L}==WpKoxjoE;x06%`(IeSZLr zD|ql~1;*9@WiNy)W_3O@@1|Mq&_q4qyXt)oQL^iLR%sF{yo%3Jh$23TAcEA3*mFc6 zX*yqVxIV0yRE=Mz-gdWx zCNA@-f@}dy4ON+^(;4Da`A8FbKN;q108LOtt0}w~{Mr_Q|I@!Y6Yq&!)9cYRImx*>$vW~q<#GmB?4JPa z@r!nYXvJhqRZqfG35|yxnd+wZ;GsfLmImdPcj{?~)@J(z(f}Nq85iDxOcPU!I3GlZ z=JuE32aA(qQGbVm{GJ7^4#BvF`@Kg8gy03Mk%l%S*jyB=B((hs)+Q<2NIio5Tkh36 zj9G~&6oOJmL+^|i%R)l>YiT0V3IxE+su4P41NpEA5THK_TC0KM%pYNz{hGh2$W^G^ z0l`QK!AH4pU!rkev-l!~o*h0OK=&BnepYB|+iMQaj-T#~HzjuKJRnUEfNE6Y?)83A z`!Tw(11**$GpvNKj%s%vM|4%e6w$|T=|>(8o~Bv0g= z595YWJH0|qFW|e(&^;{f4u!)ryi%w z3?yrsh_ihZ(+crx&qEK+1gERA&QQi4=qDq_n8$`=n938)boSWC*tv_I4Uyfq(8D_E zajpITz8!5^h0-_TMAl{nQ()r_@mr7qsPNoJ2K^Ae8Cr!X);>5zpnk9SjEOLmDtpGf zZ*H184Z7LR<{+_2BELcG1`Mi8mHz!^XJE<9Af}Y~4iuj%t+nmQ>(;30Z zI6rfuns_e~;v&>TD)eb_{#91QeI*6r)11un+3eftRGOKC6Szre@&S@a6mKlL5gc&W zw-7kD@L|jtO=uGEuM^lX4q`Du)0$xa8H?WPw?17A(lQBjSPa!F$HXj#?kj9mW{6P9o|9$7^V&U3_4XlyiMa zrXa%FG>_gFh=mZo2)c`i66)4|A5&26>PX+}=-leq+Um=P+7)gcWn?O8PRn=Y2Xo=O z3DvY&R;DwNE#03(*A_#&MH}Z9UMwe(M)PDxsA=I|c8+wVL}b&JNi-~pLJTMUBVJxF z1rL5jSJckOI9WEN7w>Z8c!bRW{8Zp8g9rwL&c9vTffi}E%hh7zzH6WL$*d}O;TZ;1 zHo9x{*D1+a7BQcvo|GT*&9};G^vdy9aNIFZk>gBgvL%3nO)79Ua!G*4GC@D zeT(uly$>`0)3?b?F8ibbx>gBqo9!b#8z@p`3m#nm_K&XYnvBqBekHhxPQ@{Q6L*1HX-b&o8MLDA2{3DG;| z)@t<^rwIpc(kwUI&y1?=9^2p^zrdO-c_t4f+E|b1!Z%Obb8c0bg)Jm1GfuTuI}Re` z2{)+=jSl@XXEN-Ap>k~~t*XvPaJ3$s>JsM%oF+H4zuw$EF!s`N6Qw-2@-Nbg5HP+? zk%|500N$~o+Y7o3B}M?>WQp`e&`^b}NTo2jkGapIJ+^=HZ^1(C({fE6?r`?m@J@%? zOg5X?4a*RlM(r^Ew8z5YRyb0wUDEev78dQ69k8bxFdwOfM|bM$G>)6;G;8j(12u>_ z;`s>qy~uk_ILY+{Cf2=BM<+6~P{PMiFv+DzK1(O}NT?O`MS&fR1HL4Qu6floJUK?j zbLPmK3UwpGNU)fO02`v!8^>x}`6Mw5`5J4Xc5Q-D@-dr(zh6o|70Wg`3_cjDY$?kC<_Kj%ycwYB(bli1s%8qbVO*0bnae7 zh<Zf;SId7qaBMdwlsivhmOECst>R^3FZBYf0Zw}2JT`F)5(krRx*vC`MGKY2cF@z=VoL) zUv6fRh>MWN_5`mz{{664CvvA0A!)!**&z?h?vy%WKS!YxA|SlD<2bb^1TL@l?{ig%CTTKM6%ga1>L8y_dNa4Z_LoZ!iD$aL*(ZQ~bE;SdfDi&Sr zr@D6O4sa%fmUciePnCGhL3oQ>Fk1<7*5MgTB)a!%=$uS3jp|Wa1Pd?J+S@Ve_LAe_ z{v(Rh#B{VfsbIwP@s!{~4Z#iJe=PQm^CBt}V?x&3nZhT;ey`nk+>7F0Fvp2*iFx*` zVw^u5L~F;gzg)BZcIET(XL)+aF$9wf3oX3k3q$((ILZ;3kzxo-g>CQ$1cVebY#4|i z1~3CGzkfCf|Isc-1{HOF&@5;Jq5Ut^jjY$_9|XNeS4>0O{6>7i{owjE80v*~HdOw1 zEBDjd&r%3vGUqVS_#F?$fJ-7A{~Ib&*@_nJNRU$nE?~=aCmh0d924h4UvR%V zttiETO--bCO_jEry7_V+JxwukTFRTD8FF+e|u zp%(g^_6We8@So8{sj^9HjCX(e?9*3 zJA727db~s>uz;5H8SYc_-!tCd{XBwHN~~_Zvp&h5>3ulXI7e5hz}(fRUwAO$ywJ1f z?^O&B68T)P4E8HO7oXJ_N)tl?fRS0y>3l=p1_Y6CJvh(n0SM_7DxDJ8!B|F0Ms&-8 zZZ3v6$Sm}7+6F%mPKI%FEn{=&6BK^g6aY}?Yi1C&t_B<+c_(w9Bv2kWU-4mx71D?Z z?InSkQoRxmnJ19~^Oa`JUZ;0Q*Mf_+b_0pRuWp2v8(bDXyS=LAoNi&Q67ymE>8@n0 zcf4`>M;A1oX7rKge5E#RCD=EC9Gz}9>tRixsW{}8`Sh#YAe#KZzvrm|^`ngvZvi4%$_PC)0*szJK);s$veRVKhqF>|w z@5#-H)l&+Ua^r)GGv#|aN^I-jf0i}Acei@-^5Ir*R2)^h+3$dfB@GqBVsy?gr}qzZ zc@|zvUi;26YyJwhe*UR-z{a8qW;lvQ_|qT*o>aX|{?Ibim>J~tZ^y!xu9yq?#s#)O zZLmyeNcu)(_%Ub9!(~6t*gNT?1CCH0t7N=hpUmD1B~T%KiU8_HlEaXxn`R@5_IHY{ z`Hy=JrUrevg*%E6ng^!n88!4f>SWxo7$UKFG@c|P({W6KM9af#o2g$e3U_={4^p3Dbgm+O+Vu@cE82Bd!Q1i+f8 z*wi4KQJLG^=*Hli!S{E|Dh31+d-uzql+i8ZNrED6Qq9+4_6EeU0tj@r{4WWfH1Jh< ziF?4=z2rI#g@ygP-h5hC%^_KMfo`eg6Oq>4jQ1jKhvjqI*#vBy2KhNpGHJy;Sv6i6 zX%`#t==_!MKQgOc#}?fg?2!qkd~J@5n9Y0wBTWj)D&tRK$!U_Ht8;5LX* z^+~5~QVx2o-}op9p4EjO;7Ort<`*6=EjU^ZcrY$~-0`5`tJjj44jy`ZIHcE@SeM25 zXsFhJ5b0YN;Mw(LF83`fe{z)yB`M1^D@azqLpFifpjf5qp5dUy2O-0y0e5DD5exs; z`y0%n7`Q@3naXg%w zLubX^&n}Sh0`!tG;K;=!QZTn0on3*(&U8mvzy+tA(BPGvUhaX%nKo#{*wo4|Pn9J! z?1>B)2X)z?lE@u*Tu;!pGG+e~&AOc_1=ag# zO-?j`#PC`%wf!7&(|t`k`(&{rR4P4tDHXdxXBh%rD~ddFRR5rsq~;qAoMTfzHQDJz ztzIz1b_^<{P(#rQJOEU9Rp0J$y4&Z5B9Xwu7OQtT5Sk=@AGR`U2ryU^4UXLUxXq); zOZ%?4@Gi89k=xiHXr|z=u3#A!CL2_5007=Ra*a6MmkP6y(GLW&I!6Asfpv?eURJUu z9H3G6P?*YT<=AQUV%Rp7-mdDj3gP5SGow0ykk6(j@U+7E=g~s#8DA~tpP=W`7#$%Vpxkn zck40giWM#DYcRrAa#NsWXUn_{vQ_TYDrl-8ZWy-O--ghw4r+>`?^fUKp!x6$t-KwX z{Od_c<31(Ed8lHGw!WoLglJexs|Of&bfD>$)C8YL()}P02kLes!}TjQJ1nk*X53Wi zTP5IxHx9srH_Nkv7b`P2g%wPoGp$M?+KG%k(0>k9A)=pE2quOE@wE=t&~y7}R>D%< zO;K&Eoh>f@R@y@f4qp7dCHn*2I`JXQS-b_m)544#u!dp7g+BvRZ4NXMVXC0z^Xkuj zeqBiZurOOa`+DY&>9;=xpDV3lZ0($}xB3&tIg5G3F*F1WPlWJyet@<- zYL6tuVd(ZsBEBFh<>}MHwh`|HQ8AKxkjh^Z;~%6N3dp`7xol=BU;r9iz2RbREkAGQ zif>vD60K;`8pbnW}7ENt-ePKcL{PE1}Td|mrm;{7A(h+l> z;IHNoY~nb#j8ARN7aHdfwzBMlLV~&VHf@tcZ^2@k87yGMxzlfavq7|yzx7s!?IzW^o%jP!eGPBIVSoRA4D(JqQ|zJuVEIYMS!x!}I=@Hzt-GkXrgjHl9Aphba{KT`>T zd`fQ5H9V~4f)ZD?(zv1oW|Jp&^2r{*`=X?r8ynsOXk*GX4aO<->@+$fe8EBt4==U_v!*+Qcxg+*DyS$*7fSsa)efVGGwqFb#)2t}eF{lIcY}q>EvfM-B^+PI z^>R%k+#wnFxU7C-zrr9IJj$4eB6G+~p$`Ti8Neks6*+6l!i~wPBLPl$GHp@uszcG$ z-_Vgl&OUfY>#g_;NfdC)wIh?DG-;-hRgxm7@|O$0n@wqx?!;A1{LUyU;c`#Wg3LAe zC5ES86dDy%-j{2;ZOWj{?NF*jgEW*?E(1b!eboe62KC_6_Vciu(NAt*e3pVrqs0Nc z8!lU7Tp+o~brSU*TIdZOQ>>+Ik`(xeCdx;$^Xn8&%QBMN7Li(L575=^nnuTlH-%O{ zoELb^@JV^vdKx9J$qn#f24VyNKI2R{#AO_XS=+y9EWeA^MVA6dMrrdWV@(8Hz|3(?UVTNEI>hlHhZ4K|g{0Ny#G<-2-JvNl4STiFl1W0oeb&2fm(Jt z%9raMp@VeN9sU)+HzG09=z~5ayPi(pnv9w@)ma=VY*We&-X9_xEB6;-&nQM3l=YZE z7Nv*2(?AydGp4IU>rlKN46zBCD#INUlTy8n{&%yA8}kj3PLWcOE)EpS*s1tmA>gm` z-+Lrq?Nksxt{M_i?GoCSdd50Bx|>$vaZ@ccDe;yqB)J^jNA?C0NawNB>oTUvyp3t#W$>Wa|q4w)2{@dNN zxHi>wsEEey*m~G=@moQ6BjKqw)s@~e`3ABEyJ}W55x^wl;hvyQFGZ=%(w-5qhp@X& zR*4~8b46WccvKq=H|zxl9hs$j`>(V>m?QZBx?F!$59~XTb^0^!9*JFqaQF^A`z>WlJ$6aX=uM0<~ zd&i5ocnP2wFoyjUxbsPi;3UP#MG{4<$rH6^a%*wFF7ypiA4QFr4>T!Bfa+SV#t0HT zqBRU^bhOf-8YOp-3l>RcD|;2MD>{t|+r zCGI;CGWqLTYm6vcVnuzk*Sph+7B7vy;CeymYNRI#!}8xpWy*P6T+8pDc-assurSoo zu6l_ueK+kbP{evlZHnL6DZP@yavO&?%hxHRk=Sklm3;%tM&=9t8QVEHAjZ)iY z??^Ec#UwiLUg_7p^3Nbr6@5n?q8dITL}(>($iANAz>jEQs%O}z8Uv|9d}pz001|yE zJFmZ{a zJHJX_CWczlX4j+bDXZSIKu8ky-hz@3f z+-L$l%tA;IDFA+qpPQ9;n$l+3@N&HN{{M@E!a?QQxVVqULqEMC1{GgQtJ`I z@OAG20&;U#$Y4xSYh2kKMi&S2{waQ|0KO9Gki>)RnF&U<1sQ-=y53{IOQVMQs2bzh zwYOjlF37P8#$>j2*o#IRGd=&LBnVMp)A`ZqsB2QVTTU2ETl!+sK6J4$`{S7WhN=Ah zlLv=#Ni@6wxYBR3C5fszm{wBY_|8NS!=p>0w5nXMjnz_-CDK_?H`43#?|<$Y*USti z(0Gk))#KNnaC#JI|0rhAK^FxK`f+V$I1#V5A`<)+RkQ3F%nsK(s~PR5*hYoMpPV;3wZuhSMhmlnhx&V^DWY z>Ilrg)FUwZDpvUkEz`@vqh1MCaSiaK$uM-`BMkMNU^0C{**_w*GW){d3Y;SF;x)67 zev1(wN#CdAsvLr?$uATV8yC#Ur|-oZk=P5Q@lKk>|IeaJPjl>s03t>!F@!z}$tBs$ z>(|e$Hr(O2FH#Cyx%rQoLYn?NuI5nrs{6vGIZzyp@&ONLJt(R*G2`R%sS+eoM7~-~ zeq!VePlYm~T7G|<*A>aw>o@UHbR8X7Xl1Vd{K^h?my{qnDpSsp#DD0Levp;}X{vAH$fY6G6m(=T(A{P$RQ8`1T zidD%f+(!G|Cs5jz)?yeRnhbQguZU@ccz}KcS-iTXI@aW}a2?WrTU;BmvY##0i+jKY zQXN|PIjhpro&UsX^-P&1$Ndd9=T+9n%N*O=4t#$e=JQstCAR{y+)i-d6-bs+pRwA8{YAuccFIQ zum!HH48!;re9>ewIhBf@NM&nQN`%9$)XqjQW0fXpE@k@hXj2q-dOF*lb#PER-5cq1 zxH+28G3p+hllVS!6AhVI`Z3{EuO0kFnyk@i)am$#I*#kh)ji|}U;T3~j8NH6Vi;}m z{Xw?P@^-13+yFM~rn{x|zAeG$KrP~NOg<1$r~W7tdTvKMJleyD$YkX!CMRMjP?b1` zem+S@GK`3c65_+{B=y8qq+ku?@p!$?gx?T4YEfF zc@;>L3z6p8u`%%h_3>E;s8AkK3eN9DjBK(1oe3esfgNK^wP5wr;zDpar;{SARY5>K z*Z>Ao4kqHOACR`zI}nIFu~!=nBE|C|BW0)sdVocZQus|!F=s==GEUNV(+G{Ds&PvPE#o*6O7=wg>);JD` zj5#R=O!s(HKnOPcy0D+-$d?1{v#UW{V9E<8RR#_IeIu9u*{$Mv@m6C4ug##Kcd6Zn z6f#~;@o|&w80oXc?KpXIQ+rlwBcLFRK#p%yjTT%y6tZ;X^q9aTwuvLvmFEESCT_D* z87a9%4@5+G`Eul3k0LN8Z@rD%f7{PH&jn$$4>aO5>4t6G*spQBFI>@U*ZOgP3E|Iy z;xRr0pvjO=FIX8>nv%BSa?Kz$-UM9TBes$*n_9vz7iW@9gQ7;%^+s`ZAK!Bk=-6Sm^h%^hl%4{SD{A6E07z2+^a zF0eZwL<0HZ6~^qAaXx4&jdh93)qY7PKB3K~ptcN-_u23d`9lun3_u-@QOSu(h1~k@ z#gOQ?zdxp)Kl>}od!(3G1;YGoofhlL`l&X)za z1UTVX*0}NhqI9iZ{iJ)U^HkF<_X@!z;%xs9ijGJq`jnd0 zUfV<_?Da4;K!l#Ow`AnE^?^*5vz<&O$85rpxP+fC)jO%mkbDEtj_S)0!& z2W0a+ut;*3U-zTBVRd2(!%Buc)fUMmB3DyC;6;HhbdqyNMf$IFo0$HCgU5wgzpW3um5WReki zra!RiJKY>FU-Wr67KS{h8Rj_LQS#WNe3ilh)RV#i2M(_A5g3+JD=o*@u9v>?0TM)! zk9v*fLB;q-ucE|SxHyhRN&0}WNt3r)(*$e@%rsFW9=!ps;|r&PK59Gh=48eek@VFq#+7H};+hO-A;!unh7H+&j#@l@>P zIu@1`5)bkATrc;TBmb4Ym9V*U3Z+`jMr+L;B{8l|@%{>6dqA8&9e&q3u9Q`jfHMcV!4EU|~Sy4c5K$T1~w#QmAlFyONbGLbT9Kxz#y1#ViUK!rEFu(LC9i-eK; z-*6c;rnMhsf)_vgLk2jF%+RPfaqU@wUc7HsLT$Y`){AyFZe?!7AJEV1P^{rb`S zsKn;>BldiTmmLmB)MbtJaxZn7IKHVR=Yo{5pH?64y1Z zR90^HpUFcwRB< z1kA}1ea$sb?(gI0oKT*ZD=~d)!JFz1x-HSXe02QZWR>eS4PI0%kv#&YzmjXP+(|28 z75rc?-Pd|v+5hL;7_Xnps`tu)*Z|T)%ALf)gO_@g3P&XF_6a(^rcW+ZG73~vQsMIU zqO&P0C>2Y-ezF?00_iwk#Z=6AUqG%i@pQ_5){p-8_rF6!?x!x5{Z5C z@VrZkqYGQ@;~zUuQ_iPN_Ja+sDxfhWF~~y&;~V5G2+se!haUVRbLxDDlU#ky%ci** z>Ac0KjZ@C|UDaIT1J9A?EB)@~bS39A5FRI*5vozfw$|=}4R5k;; z|M8%k?KaMh4_wYL&eJ>5DzlX|NdDgGRUIad z?X%#NOymgB7CIu#WjKsu>PCpqC9}{Ix69W7dfYm*od!Gcj~T%WH*w*R#0S>RUC(%&Xvxj7#|1m zw^$C%0Y32LuUdZo=*TXtD{eSs-2|K^L&+B(bh{dc=1|an-mO!{!$J5CY?rFa$rzs8 z1c?}|Ua9;}r?@4W#jnVA&Kns)`1~bDhDTC*CB0PlWu*I4e17$K7=HSdb*w^=9fHC4 zJc~-}++Se~z)WtqW+J*T*=j>*#%c8^+5P#LQl@Aox_NR+L#)Kv8F|jgyBp7|!)MPV z&I|a^R*vld_K+Nur(aHZ{Z;=5JwU?07cVg+MRFubvLutjp!BB5l5b&LXGB)0D=usk4m<|caret)h|PsoGCkl}lHaGh# zkuiNGCnK*zKIlO9&hkKym}JK7d?Lx7!k|zuCSIlyQ9^+Xz%@;BHfggqZF4sHg=L1S zt0;n0Tz{bg8&PPYjtz;B4F^CR5e_vo0!x}OC{zzYG-A7&Gbn(;H|P<*`fd)Fq>ci> z3QV&GDMB_`Vg{>EdoU6qI&mPh3o3oWX&h$$CaWp-zONMrDEEt1CZzHngTeuZ5+MxCA#j8Y_mY!z=aNQHDr ziFE$blY1C1Bc7veSac)cht9gGH8$-?vI;@|hXj8jpW^Kx+3m90LP;viD2-73d;tOaBEIqzAtp&qe?s-} za~%o8uVm%}?Poec$0587Nb{3bu+-kZ{?zVFNSL^>Js*#v?s6b*hz*;Q7wripYz8dV zj49J`c2o~DeW9NYV0JQPgK`Gd5^Oc|r++Yig3IDECLF~oF+wUIR3!AJPI)3>CbCGG zwOO6@S>wueWJD`-aEhkoY*>)%GHV8VE5Xn*L?=SqO2=3*6^@n>DV}jB@&_}4l|L2$ zInhJ*fT9g-;+*irP!FQM#6s1IRVLiiGnezZ5HBMZiF*E3VM1c43Ue?t<89&wOMfiz zn;J|cwkx+F>{k=a!5U_!v{I!uVq7uqPB(&xf~uIrGu`?xA$q6A$WEGssb44QL<*7} zF^O&nuAd6v3Ibsc8bEPoby(-3uKo@dS^23=%v4g0!tTlxC5#4M>rOp>V$zCG7_}2x zt@diMHfuR1VLXF~))H*;ZLfsU{eOl~&Q>ra$j&v-W*E=V-H@V~43z8?V8|ZkISf>V zsH-PdVF%mdZtsu0fFcWX2d7?!2vq@0#tC0}B4^I?x+;!Jw}+?ZEhJ`erLuznD08Y5 zf?kLspBh)3xD+Ai=5q-(idav0a7lkQB0T}%SNW_M6@xtbD!~XKM*UT33V-w8!1B#( zq8!CVSnYHo=&rJUb!|1GMz(5c8X{9Laj&5JG%rt_TZd5-CqG~mQ z)HYIU#dmzkw|uFBF-qfQH3I&SV2MIQf?qzD4MT5c34#Tc2QNzwYEfbo`W0%%)?5W- z&lsRn6T)@E7rvB6aSO*D0e?mFT*tzC<8dc7EC_U6Sa*AKqL{w0W2bX5iKdv?b#p;c zA>1MW+@k9eG}0QVLaj#oM8fWbHNk#00O@u?NRVF=HGk7@e=#^AL?~YMuXM}fZbN|p z`b{RzW-S+!BK8s?gl2cIWD8MZoL*6ANLTcfCh87%75A1uz(^-Qr+?iTbR!at&eYO- zbAolzcx*^7c0~s$-b71TB3pXYeC_y-@i>oDO;nb6E8*)oOeUY0GG_=YrB1O_Y+_9_ zLaKPR10w?^&L}5_YA8GYC{1p1LLwF=a#SZ=%yq|;p~fmCw&swp_gr-ljmGiI%#$co z?Q@T=++IbrW)LKE27eCymm)64srZC((5fkILN<#jsfr0w?-u|LIa6Xqm>jIiFxXvk zqRKoJ8~1UED&=dtdrG_huBBe-l+cqQ8IA}2ahCPKCPGU+?zBzYU}+3FZP z?G0(_3wSAVH)NM6{x*l;#_J}7C{gJ&B#If_R)}Ri0;kR>qT5y&MWS(###E1RBcv*X zPx(}Jd5kq8J%16UltX$umRcmvrd8}G6f(u5PNjbjLiHN=V3DQ3iY1jNVx}}=sE`vj zDc1|f;yVyx73#nWuE3MfHcMs)cOrVwvX{x+&t0rnQOOBq-xwtnAcuKk6bL|$(-d_R zy0bm|v#&N=1Yo;z8J~KyD)&s7_HGkHqOug(oju|vU4N%jTO_Pij|hkAJ-P*{vqUE9 zi3LEnqZYk{0@gHBULtBu_*ddBX+P6|6+%pDq$HL zKItU0ItXbXz4vFWTLe-JCBt~kL!5=Mw-MsHMmAh-p=BCOLBQnC0^7J|vdy0?cF zEMin>1b-@mNGZX}6ie>=M}g`SEp;R8hjgVXtQ7)Ajyu5Z3xM@EBk~C(tHX8$GCVJP z`L>oI1RAtee8pK@{upBcstkhjr~n8#;M6-9dlQptM1fr_INeqx0>r7enojTz88!_Z z*@mXvA{!AfWx}Lh6QZ9I;D9qoiB9o3n4F|*hkwQX6{~N#JUrRA+0%IsQzOnBBj~0P zEl=CTg|IqE>D(gB|9f&bLd~p+ektjFtCYj}Yl`d|&40YG0S>uUS97!|o>uxkR;pn< znkDQ`8uR`~8ixukx2srB>s%^Oln)RwbB8A~1@$r!yv=Yy3&Q;zJjKa!!*fDVm*cU2 zB!5c2wZ&z9)@fbpq_QeM5ReuiL+%^2nl~ZNk|UMVN@LrmRX8Lvg{_Z)JaiGl5(J|L zdbv?zYvjBX_oYunDwpIOJ=fW)DQG8rp`Mntt*3`Y_=CT7!gYYx2zl^R8bU`|S8@B8 zpm(XmqgXb$Qb)agN;4uI?TPehvCe1mDONG7D} zlK$Em}ac7jtUE}0K0<^|*k#9U> zBtqH#YklW=zUSS_@>E?T(D#2sLR@r_b%_w@32W(67QQB0Rqn!;DK0G+fv8qrqZNqd(0;5OnHTtezm!pK6R%IKNQ@sC&H z=5MZ(%;-$2JWACv`ND0&s9z@Tgn!9EGmPHmU8`BzC4RQG7=E}2Dkg7VA=K!f8BpYN z;&4XMV_HG8eg627Klx250QFNPzp-2k`y4XtO zOo#z|W~_5@fz44R2MkScaY2s3j}gOWpjXOOpmR%CqU04}u6De{YA*dl_l5ya^k0T@G=e zO^c0f!Yz3~aq(UoZRE&dRCN!dU_cfGek|N~^ zk&z9xN!Dk+3^o9a8I@_7Om;OzN0>BkTaVliTe``G^L?BWcLX>H7qy;k505^I{ zYN@84ifXE=uF7hwuD%Lutg;SOUP+@4RboN~fGEl>k<8w!kr#dbg7Nl=P zqp8_)LINC}S&a$3XlG=YQ562Hn^MtSx$C-XJS9@vOl3Th^?OKMr~1l21-~<(6NLxvPMB z3)s#k0k&;IKOT!O))w-aI6+!65HtXQP{gBErNiE%0Csm3dO~p%G$?aQ3RukC3L!9b ze^=-wYLhQgTX;LP#YTjHy$yvfz|Uwhz1H(dsuCbX(xX(;o3vRx`oJ3=bKu{qyHwav z7UyhG?}UwuJ&O7&aQFbczC6(J03+p!CNT+1200!?Vn&cwNR0rC0>IjiQH-JlU=)0^ zSBsKlJ+B06C*ql1LtN4Rqe8JpUsEy2e;i7Lz=JS{Aq%rgG4vIH5@yC<#u5pVL?^e4 zuWpQgISre@|v&Z;Ff5>!6 z3X8>%NRTJtCq)VQ85A9OjEGrpW>Z^NX3CZjyS2h|5#bWo1_Y4>6b~@VQ&vM%;kf~D z?=z3ONCCVs$-{k*kO}c4K|*o3h!`M)1}RhFkdjBR(Pnv>nvwww6C^)wMubd>$kj#> z!d_5?Qxwxz0*Xvl+zmLz4?qY1VKTkt{AIWg6cRw~3fd2)c424G3R94Mj%`D6eBX~c+} zkyvKYQl@~B%Y=N-qRXP0VGgvrO)5k>h@x6dx~PCrHpF7Pd*MakXA=Yde~*V^+MR16 zwgBt3BAiB%+{(Y8Kl7xWW@LF1DM&HOL;$b+fCen! z0DF6DS8jNKEB*u`6mzhGfA$b3Q-W;gfnBK(XJd0S4gsSt2vCfGB=l8X<+C7|{1R5S zQ@2EF^IB3%05Vu~AmS0^lLWBnEIV`&H3DNW20#D}>$i%e5%w5>s+2FRFqU-|q>BJ} zRx9+S+j()0Ai&U90i+o;KgJbjMJ%jB959MeSYdAnZOGmnG{LMve*}xG@mG{Gk~GI2 zN;FlnjN=^Zc*i`xafuUBu&(UYr#2}Y zkukQfHn{%yQU{n8e^(I@q_s^kAqEHpG5~S7ObO@#t7t_Xz-55uWhQF^cz}yJN##i; zsYC^kac0&E00-Ei4}EyRaV3^nn*ig-hgFGbhS+C?wE4{dBF)V-cAFp>AOV$Gz-_sk zTQ5AIN7u~E%L;IS_r%m7@SQ_3R#9Mu6f6)H3jkveYk(u$e<3 z1PliL(O-mKe<((A1%Ki5Hk)G(we##MKGnF#6tB3&FOKnyYuq-zVBEGFf;JqIMl1Nq z42>Z&fDM&H)toh<2zmlCcuvP0bZQRRcY$;TOr8Peov1Ev zI+??OJg1l@_OipP@oqErl7)4x@j9L4q9LkFitmEgjW4di_5c{*3J`~t#qPWD-0Ob# z{=DzKfA8rSipta-Fc%DRS5{Ggb1&&_g!!gHEGwo2%yJcbwG7!=^tRbM{xitti~$}1 z3o* zVle{%eyb4(>ozq9FnIpQFb^P8tMCBT*DSo2e|ODfH6pQIN9S$Iw=oQ000LkD4WM%I zvj78k01jYzpi?XaAc1?5eOI7=rZERWA^-}Ye8)u~tzZSqGd5)e097>J_2zKCz(&QSzP$AV;G7NA4$5j9dK#Z~YiNHT_-Uaqk6{;$vv>tkWE#c5i}bjOfx!Nae;}uT zTwsZkMTir!ii5Y29|@8nDUu^ek|hZz7hx~tqK+oXlEMLK1os@+w336!XJ<4-PS=t- zsgpa&lRfE^KM9mQDPR0j5JB@xL5Y;Ou{X|_lp;|f_Od)J*pyRAl~rk#SBaHbsg=0# zHs2&5TD6s7i6arAhGMBY`+|jJe=(D0$(C*DmTw7{aVeK^G*t}J5J7T+b9t3q#gteX zPT$lfh@_W;NtlIcn1_j&iRl^*6l7DTJBmq_8IzDbxi`0yH0KAInW>qZ$(fz$nI-us zb=M}s^qD&uPO5j6Eo3$g@e58=ny(3)u_>FgNt<-URaq19X9*F?sGv`!f0~ckmI3shGX)V~8KE1>p&ja>A1WM&bAE@@pdboWivpcy zxhM_O5Dj#SCJLi5Dx)*nq13fu7OD^)NuzXRB@6MEeE<ZVvJHMnO{lli8p;vq=Imbnu*e1em8>ZgASsDa9RU6eR{a-D)YD`C=?TX{Snf`e;` zsF5nElS-+Wvng-IRS{XKrm_m-_LkC_5C##P;JB%!YO1G-s;!bH&jM)rnW_cqAlGsr zYWk|RYOA-3tGSUPegHzwXHuH#CsS!zJy0jcF0o4=qvF{G~V3a|0{p;~tU=_;?E z=?mTVqW8+L{pzo@Nott&uiiO#y0WhWi?9i+u!q@>>bbD996A09c5tu{OR*Jeu@{T6 z8LP1y%ds8nu^$VvA+sT9h68_*N}zeo*KlO7LvdSs-PeO18-aZc$bbu;A=s{g42_Kp ze@)ntO%RV(48Onw7eEHSfK3Il*q?D*^#}w+Ad`|!+N<%|zz_uzU;!9F0-Lbeot+uj z1Pq6O0Tliq0feyGrLEh5(b&ZR42p085`Y02U;!2Y1)AO1rg7Sz&;oxLZ~+v60TVz8 zqrKbJoe_=Q3z%>L7BB%A;N9L`0+sL!$xRxMeG5=90TLhq6L0|+Faa8H3dKO))=l4! zT@0j90^i-<-|gH^a0~Jc+noK_y+8^1?cEcA;Ol(>B=Fz!P2Z#)*vRk;tUv<$-QEc9 z-0M97B{1ENZ4)xd3P68g0TOTl&i&oO9o;&B+z+nXj$I7Bumk)pn(@ZUot zle3KhBz^%I5Zxty;Ob2QPyh@7&f<~n;=YgsGtS@b9o*kt0*gQl^3B;0^b4pk0^RN1 zs}1G;LayHJEdh}53s#=wXl>Z#{n$M2%4}O-p|s1zg_a-Aw^s-s1`m z=cZuhXD-%??bweN;09selo03Lz1kUG;~0M6QGN)(Q02ey2qo~`7@z??-rmst-RZ5~ z79iv!;0hit=wOWunIH*t4&V-M6OH`~rceSD;OY7u+zMXf-YwiwjsZVl3L(Dd{LS9c zJ>n&v-rjB7?%jXgFVG9F-W8Os*r#sPGTGd$Ed`aZ3w4emf_+;PP68(`)tH|W$x?^@!7pi45!ctm0;zEF6}psO`GuDwLSxcun9-r z{_5o2+qdun;co7ZUgF9wj_TcZ!UlCt4-pIFy78y=(2qZia-P< zu<0#;kaQ<-s9qK;-cQ>B(Ce~o#EfT z0nQESfS&N5Et99P2tttG6ky}EEdid;@-E-gzAfwDP4hHw;v(P#kkAX*^b5d{228Kt z><#Bo&fb5Ze&Ru1@h2|aeh%F}9`rvB?zTgj#)$S&#=u-aJ9-=aS8Q2uV> zaF6=!9Rs=m48K72DevW~E$$l5-y6^hUH|wuJ@|jFFamt8=@(G>!9DS9ZsG8*^yaSY zVXo^AAM8Uv@#>BEv_I^|ZsP6@`=O2Lo$mV;FXRZ$`uaWTfnNMJJ>Zj2`5M6dCNAzJ z-t^G#@P01$-M!zM4-gmxVz?kd!UTdAFi^m7aDoI17X)6Q_)sFnf)fxD94L_>MTG$%QG(50pJ0Ce$17-N)i zMjC6h@kShT)Nw~1cR~h#m{vv@$S(vV3@kH&o{K0W!>F5xy9J;ABM-175hCv(3m`Da z#0Q&1@h>PXE2+c7jx>(4fhL%wn9zE3^G!J8lygox>$LMuJoD5ODYk%_}GppFizNIHm^gXknD8`^R@2qHjnLoP9DY)s7ziipvF&J+^y2hdvFb5&Mb zb@f$PW0iGQT5IjmC1ifl<%g6qkjt(MGRTXrjS55PF~d9xNw9__O!OdzIC`$qj}+4m zut6`N;8}wbwd_#oG;Hor!wxeAn6+$GcU^Ydb@yF(MA33*ozu}1aToRGaNBV!bVETyS;`z&$$WHSdU(g{yX;gV~|4@d1R7H_EEqz zx)TVvaZgGUv+y9>bh&=VCAQdq!;5&r@G$VO!HFa5c_2_3Bh`geO;&norki&9X{e)? znzglx>4gL|DXY1&EtA^_J&RYaEXn2&dwHR2yB;=L>MkRH>CvzC!fWD#MERx7sq@x* zZ@&BX`)|PIzJ@d>saXuN?aF!4z2B!@7%2C?I?GA_>yn%v5gSWnf! zOE>*=)Kgb|b=J)y9oOApDn?gcqr=E9Uk|4X=(R%(dv^*)vYO z6`^duB$B#v z2R(?N^0Dbh#b{qHQc(&|P{I+5I0PXC;RGV+KuExUO3A_&*Brxr&32I?QmGda#nhY$eb4}X=Z80HGnsOQ)*BQ8T8VK}s$%@9Efhgbw9 zK5+_vTKGa3>l5MmiUCGUW>S-zA2NEcyUrdJ%9%QUTG^O%IUP&I?MU!{BdA33Sx1;X=18r~+8jqJ5F$(wi-)CcZEbs7 z+oz#T$@!#JH;Ql|#FTS@*)) zeG>CY~<2diLehK+n=Bqv$P{Q)I` z^oyo^p7wKs(r;ty`Oi&^V`F=$%G}9}#Fpi$r@muHN@0hf(`uZjE>*6? z3=F9fBBG>qhb@B57judVTVYDDie8MD&#Pv2t6lx-pRlJFu5bd_P${>6kyf^FB`&mS zG5euHyLdxyO>+>nBOz;9%Xrm0BK|w^7(`fdwP6a;oJ9V$yAG&=C9vjpx4r%CS6j^$ zM7ZS~_ZiEcwzQSPzRZ|Zsm4OHGRsXIc9p7U5KRFl&DSzcY4_R2X6;f#YX%g7A7pS) zV_+35u`{?G{&0v#Jhvo&Tty6k?GYWmmBm)B3voO(qKR#pl_^nhcP9530-p(JP?UhC z@}*h?76!)JLC>-{qJd4p8P{G*R@SIX5mRhi;zK8T(T%QAtF6KX3)_HqzgpKo0Y|1K z{$wK|u0)ujYZV^m6qhR>a?S6N> z=iP%YvDzqBz_O+%s3Vf8rC|Ox#Z{05@ppo@nPf^5n3mo#kZIDR!0c(qMy>d{&jR&C zIp-vU@6v`72!+t~etOiWUiE+z&?-v6*HeDA*MABA&ee7pn`yXq4h!@fCDDqk`td>mo2bv(C&eQ%$eA0qNeurHC@dkUTq+l! z5($typb62Eni>}msR%Ui1*V!rOgu(pOh#plwe%r>hFc&6A%Q}$Lc_SRm~26q;M1%H zshC%SAf2if+rf*R{y~Yo!a|=}B2Sx;>iQBVv@hV1v_+#w%^5`P!ki<- zwT4`Ox&6Bi$r%AT7@el-N0nSjmZZU|DF#$1gJ|4AbW08`DZ*PC4*+rqlq>;$70(f4wR0sW54Mz4}f95yokUPJdWdeD+~~UGDrntn6Q=%OR*eF zy(1qsxrIe&0kqkpoYB85nHl~$6h7jrU5CmFak(BgI>6}jLOs|)e1(`(7;A%tOth$ylk=4A$g~@;q`^!;#ySIb3b+X0N zT9z=uv~H=kiMTfRIuMu2kThY4YBVZD`Nh<_6zu>4N}!_XtWEd_#r zQ#-v=@d2d*b1dUDMG^5mM?+GsNjNvGr{;{1M6R6DKjQLDCFq=n)2|c%hIhAT0$yq6l zAO#BkT2*ijS8%9zwTm`wmYzhWpxP>jFcY8| zwZ)0BV$@iqO6DLp%X`H|8TL$=66pwzs_d|X<+-CMquleGYnKyU%T=v2B80gxCe z{y*ZKJ@Uk(LYTzc3j@mtTso6Bq6p&gmq1E4T;!a3Gbdmz38w==p9+*|yhe&Bfg+#+ zL}-LXAcQ9%0p_5~u>DgueVOp^ABunk+0x9u?Oosf-Ti3QP-p^wl5k31av6{CEI6E5 z_(Mo*J17R+PMW-q2FWKW;aRsum=#r?O6v{?AdiS>tJ*XZOM93WKm=H@31P5=79gT! zDUnXe!Pff8Q0Rrb0bcygU;Wh&P+A2!7+D&^)a8JH){H(H10KX3j0W6ZVpY*P3O-YO zPhgWV%I%J7^RMoIbSTS^1YzI_P{10)o9y z5dm+(+Ci)sks>C%ct0upzT_*&_d~;jNtl!)t) z@WV058m`_MG+XPm<>;ro!d+dop`gW~1mTV%H9Q8PV7{Odyo!)NDgj$4idx`+_kFp& zGOewlh!LoN-=nQ$VlHN5ehN?;1vpreb&cKanp*JSnuGGb=y(<_*$hM>n1B9)ykEPe zI9uX#jOG&A4C(dA<2ceWOJAdi1(Dq$g&~gOD2N~UVii7Sd%kCU_KDU5gkvhgDMJrJ zvoaW^scUO2wPnP`NR%M{#qCTvBPu~nGskh^j`qWUxQ84U;%KLDVT7cp1mA&~!$d6% zcmq_++k8H0lt$^@8if=nr5Y0Gu9}}MJ1wA+-HDdej+8=q!eIRq8wPsc$Dm9qpsC3< z9G+FJ&Z&$cSc*cZ&1cpN2nhr_`_`1MYOA(qw(td0Xab*;IpWCZmzFFQGcDX{v%vc) ze}U?MZn=`nX;eft=t6y>{c8awK!i$=g(*IU_Wd`$q8_<)5`rOtyiN-KAy6%zv@a^t z02c@aS4cJ9y=usgY~XFZJGj>##0x=5(VUx~5PdCA+_{bf6q3@2=bN6qd>IlLfS!j-8j2@LXo_7>+g;SG`8fiAx-)6X4sPL|Y^!O7Kse{m@s$jS3wFvK zW`T<=s|#UG>vQxLC8ku+E*OFk0U!_rMgRp|cx*#3YPNMNh9GN!7;L3z>J_WW$hiYZ ze(d3%Z~7KjwrGV=IO8TciN%TQ@F2qH+Nm@`-iskVe-YDll?(5h!x@-@M9>6Tknfp) zu!P6UIT9O;Yx4_1cnV=CCw84N)#?CYj^z3-aT5>M`yK@&NX3*W{=Ahjt=jAh(%osJ zF(gkdE8W~J7*tl#uff@{>Om9BsS5~#U62Z4_%DN? zr4kI73qaZCp8DE)&xLs+a+A!HYFY#AH!toc=%twUzM;XaUXS1U> zfK-Ag1fB?jfpBh-FcpJ<0$XQ)^mC7Ri4Q~e_ytFx;ctcz6e$VL!f~69DI(Om3gy3H z5q8Y5cBn`MzCb<(KEZ=Hft`qgY~LXa2>6-k1ox{pf0}?JSP|Hnc%TpZ8B7;q00uJn zzUYKHJ5C&V&1VO->uamLoIHkwMciXXqsjvipH0gMQrrbrD zf}K!H-&+Vo@R4f44rl$j3y6V=rD~zid%eHDioXRO@aFy^ekTAL7ag8+OE5-Uka_Vd zC56{LZ4Wt;FodZ{1hSf=$XY9o)(P5lC{pDKE1s!i=|DIm0amEzy+3`_w>$PRg=j>l zKfH)_JR%z!f&Wmke&fvG5gC-J;# zM<`Cv30ydPj(B^W@OHPg&AiY6fH(xK7_wspk0DH`a3RBn4j)37%4``nT*gEuv>327 z5-3QJFhRlv3>TVWh??PP)T$GzI;{#sm`7eRnu5Kc6l>HA8lFy=K=oj@z?z6F>|Cc8T2v$o+c1%(tw0xMM67&eq;dI5rB47(}{i)G1Bkrp#3z7i{3ZS1pa>0XefS1eq@RfAC! z)YNd?#B-lgNPFRjW1*Qb}Ef9bXt|kX2crI7Cb>nj|vC3>5~40U;DEq7+jPE@&5rwqbzF zM7%_0L2DM!HW&t#P^1ZjRVgK7f{Brk%43iL*rbzBLK&r$Q&L%_l~-b!rIzmrh0HIM zl#t$dK4KV~bPrZF1Ct;LIV6K+)kPy#7D!?cE}$?X$Pj-bTzKGGV_8Cx5*J)ZUWaD> zMwSM=OtcG{tw|u^M8SwvRfiWK)?1<%Y;b7_nJl@bsH2ivs;Q@pMZyZc#WlgMiP37~M7v$+xBs=M#P8?U_c(p#^+_u?zxP-#>^>tfv5<{O!4 zUa-hXvV6-M28(rAZCWm>MJQZsrFE4E7)%8xMQ4OvZcIgGLOzPKDNf8?rcoP8u zu(REsRcvDDky85>zLq$EVd3(FO- zQaYmCF`>dq+~;7vZjAvC6v1+#bWLUGrjHB86{tkWq=?juRgpYVA!lOkql~iY7#0w^ z6eG0YgA-o3;fEuhxZ?66Q_L@|K!FrpxSG77RkxC*NlKb5*4k37!C5WEvc0^NpGA6z z2#bGUJO0%mRBWT|VO$c_IT4Xs%g9KOR0oG3UE~qGf-eLuUcB+gBcHtT%QN46Nsa&F z3Lqt5XxGeliCpf&7>IE5NN?GOlv-&iy)cFd4k?#h7-apTj+{{RM7hj%TPBSc7(&qu zSt)I8R8LUE7P3>%{JKS!#QXpl?(v@U8t8w(2SPA{5}Y6fodi8sjN%O2lUZMiB|9Qv z05^Im1PRR20?h>mWd&qkcd~{Zr97-+=t+=VRwj`Z$S^7w%aLq~R4xh_MuZYk!dyCs z6~Ij7Efr&*_Ow@(27Pc8?WrIYt7ye5Vlj(a+~V_o(Th<8q6WNz)Ab0GDXx7E1F?UY zNG<+KU?eJ3L=es@lV9fcM6^&0SCpHJg~r#E5^Ri&GfNs)9_GLQQDhJdN{WG)SQZ8{ zq$d%J7&NCt}4qE{w_$C=!2*Rr1hHXn_q2F#rULFrrd~s+tOqGm#eX24YPk z3#~Aa0zkOp7sMkaIm>CzbD}ey>O4)CfYFOp1i}a(EK4id);p*?MGWPi{ZI6GFK!Yg$ zFo#g|;ul?7CrexE(wD+CrZUZlP}~Vd7kJ2e^y3a$;3yI5?UJNmxg|s_vCyQ{QZW$q zO>YMCFb^)KZW5USQ#z(K8iwUkWAPOU0=PX|UBFhY0n$XM@G(}RsW3|j#VR;C)3?Gk zu5z6#T_f1IUi2aqZJ5(}{+3h!jw2j_KiWL|5L5kumY+Y+>+uPzcx4JFW zP`(%n8~~Fnn|8IDLHj&c|3!0kga=?Z0JKHI?;+Aa81A12N+-vnH_)ZSh}2owEoIzcYR^u zGelaDvh%30VlOfsXiEpuqd@c_YMb!uDL3tdUelSe>+DOt&|1u{SZrJYJiVALLgM(3zZgH*$Q7c z!yE2!#r0MdfB-`WO@_Naxd?R!%!;SYabI@6o(^r!x>3RYkI15Uf8 zBMa$tnO~DOq^^@)Z$pF!)XsR-(qlRmleDUKp=GszI0cHx!gqZf(};lKj|F%rJ^p^kSt@Up(U*@A${(hiI+{g&SxyF7Fu8+}@1~k)YB(@{q^Q z5vjzjm)U^K8fbE1z2sHRJ>yfqm4xw&Z6{(mifgn=-?QC5dPV7GUhas@-Ft?_!SlL!t zr|Fib41y%AQAHF%u{emUeM|LZ+P18SPLEv zMz&;DM3@zJF%$nS#1wdpZ8%s&F$Eh0TjD7l0~+BGB4H95UvIgB5g61Z4M`873mF|v z>-c|KRRGdO2!pWj)0})w->I0JsmJ>n%LHIlL?FYQsZh`P8o9O36W)#lppZmx0%BC$ z*i1wRDh#2-jC8<2YynOYD&Zg!Vj&u0vE3CV?A(iNjZjq^U0h6=g$`1&PvBGpC{zev zu!TX*8Q36;betc`oLVE2RDD52Ei8qI)f<1BT*x9F1+%pFpjW z2Jk^!3F09FV=xNiFxFO=AcHULMy^QA(8b7u#0+7`+*Q~@MIgfzxY5RC8P7%7*0@;& zgks4p#vDcjbe&B4VG?Qajcm|L&h1_GY}W-u!bA`QKl#$kbjS`MUO}WFG4f+S`s05; zW|2NN8yO6VteK1kbcn23lBR$ZcY(-7z(OI2fG^S9ci9HA%v)=`hL2Pkruc}oNW>s4 z6m8IowOoZkH3($I;9R7K1h|bv5Ce*QVN`%5M8HC?C`G3zB&S5hBMihZ0%TAM_bRj-xJBrfc;Dr<_UJ zeU1FFMG3HDkRU=KOd~~rf>e0WQ%r@C00#^V4^YzQiK1wVs%T}@lrOwMcN_^E@~7VP zm|f1^1=OHM=%M+zAm;f_f120%Y39*0S1r$O`2+M;W zh6e0On2rRj9D*_t#>|}Dk@$~~h*e-gg?4m=Fihk^iCR?=2g`{L z0Y%JwEyY+$#0-enj&Nd}SmjG91Tx%Ln>omkh6FAckcL=*`C-ammB1aC@#)RkvB&$S_XPLC(-T+KJk{PP) z4)0J6)?tc+Nf?LBDnlRxihK?Uv}{KN!9+DCR&@tdkbtx*Y|r}a&ko~I0D~%=CCKcJ z{(TuzwdC0lr>cKOg?TQPVoK+jwU4H3{w7$=EJF-}W|ENxh`@uD#koR+SpkgLbg4e| z%6jG0|8>ZrkikFzZQRQ3+!~>3R4H*r=j?zi`#fc5Q5aTSjJpZL8GYf&tr$Y(B6;ZG zLhO%-(Z#szjW|NYCjgV!a>Oen?JjLxU3?G)c!C0*E!}^L?&y*(BHoo81fPdY82fl@ zWm+r>w$;w8>L;fj?5sI5}6tVPD$}P;sMntr&4<>~y2H0*y2!jM-K)zx`FyJ3Y z`Nq=FPe*!443uc-mTvZH@Ad{5tc*Y_uFp=M)pBxN{fL_KN)?@TSd-ry#@~$%#u%`{ z=pG^6BJJqz#tEZQKpGLmjqXkbk(QQ5kQm)ci-e*et%6|dzCV8Nb$$Lm|D5YR&w0-M z-1kO|eX|xiI=r)rzIsEj2{(6{oOeP1Tc=s1uDDr+zxxq2izeg!H3MQ`^9QfvHXaJm z#(vCmo*yrGB>Y1&0Ah6N_l;Rd;AyzdetVd?^mcy2Og?G5L?j6R$_ zriS`0MgwMJe5k!P%x6$RS^H3XIR+tM96MSftSshGdop2yF0iLM+Q?bscgx4i zX;{p!$+@;Mgg4l4D25MjWwo{S5YzJYb_-1s_?7xsS-D_2JM+pqP2S~bT71CAlFho8 zW_kr1&#TisvWdu(&vUv^@#~|Q61LB35LvtxpOK!s;V50UXE&!c!S<(*@)I4sMV)a{ zG7PQ3Ptue))s$WaU*7H+jorr#oR{v;-ToMCIs_=PHOd)XXj{pDZAmpT2xbn!27DEM zW_+@U@%x<(MS9c83RFJerVcfPyz$go6^fHE&za_ix2i)jW+naYu}Kk0lv$*B)zQA{;u?xqifz2|H6|_p&KnW7u)%x-=f)kFVaX;tD&WD z${LrNZ<{y`%j%XpF3V{Ll#g3N`fd?5bjRrRMz3h+RR|)n4mo9 zaIofdIClZYh0H9l)Zs&Ab(&Jd%g*)PFrV&vWKDZIn0E~XhvnT=b=b@2xDk@XFd3#< zE9bgpPxF%?uT7f!eUC|A6Ux2E_fpm)lbpPU)YlaB*1U4?e$1U{>R;loYVT6{164fX z)|3^{dp1lYaRS4_zLt#scN2VmCKyq-zqb+Am!q{VPivGcND$|f7S)1jQNMCP*)O@? zduTO(^>T+wl|z;Pvo3fz1Nz3!=0sx^`1m$csEZe2rd;*ms>s#yuvN$!mW%iCoVh}x z(XTwKd)^nTEC%NcNy!r{Vtbo#lZ|J5h+$sd7%AK+GR@Vb6k{lrw!0T#i+TRApY9Ld zWKkhEBgCromYFMWRTsNboW1>udtvE}KI?^s@TBbv?R)uh5tS;x%~&gUc#Gr-8bKfE zK4F#!^4aYM0#eZfPTHKgyeqK8W-jtA9Yxqxi9aD$m#V?z(|ad$PNix^Jsw;Zc4ky9 z8oY5aq8;Eu_R&g;$QGJNBJ7jr9}NyHUXNqm8gYJB3c*ypv%C=1hTUBsfz-W)|vRdfKNW@7`YF^=uVVJ~@H0t1HUXK>lnMzQ;K9RaB zLiserFtd)oTd3u=3EPlBc-)N5Pgh902re^luRU}X}7Aw3O;eu6^^GnSeU(`JLU*1nqW1tUr&xdW`$4w zM-AP@@>nZ6^{dXcM{T_5*AEXDi__#unzD0s#EA)7*Y@apFOOX4YAHeX<#l4eIr;^> zzPEKdz?#>m{PsGAS%-}Otou*@W=R*}D|)RN3JoE#ltta3-KZFhI!JvmD_1O4tI0VT zys8F$?f>*q-l)l=)l~5gD}k6F*26veMe4<`#FX|AtT%eU=6JU^bBlG~nqhnNl{@pA zw`=Tof8O10_vmK3yV{u#zTNom8;7<_y(XjTf3A1vZ#<{N0iXk^QJJaY)BwpJ`lc}w z+cDB>V9W_+*{yu@`2YMB_?O7ivm;r0<@gCv9pmr7XdDd%HGCNxz?(qBiZ&(THOe5# z49u6|hvvLm>8x2m&`N{7jQeCpzWlvH{}>j5!UkUu3$73pUCjYYY!ae4|33*ITWOa><`>7Ek%dhT-C*hmJhj}z2Q!sacH;iZE!0(iPQab4 zmNOmW@@*uU1YJ<_)ei!NS&dLMp@df489k+c{S>nCMHV4U0>b;}do3wtze%s8{pG!_;F5l3?blz(b!*V6(pgsAoWt;SPt$<| z(`#JlR{m?JsDDgr_-LIy7CT*GoANK{PsV!Z+DPqOyuGGwflkWlNps3~N2wXUSC*y| z-1Iwl^pb^>B$qxaR8LM3Om5BvzM6r_wMmaM=txNoB5=Y+{O@yxXIVl^w&QKJ8JOS4 zF*y~zPvCmM`XNb>8P(_{UCwL7=^$@rff@U26o;utj%I0A02T2`%)ir?^*issk~?RY zr{_=Si!#TDh@Zmc|Knu5ZgW&X2#X z-Xui%s5ty859*D>5geuhUt7`5c)Uvat3DNz`3py4_-5&lF8dY+mU;I8VKmV-S9=;) z!g4hn-J^BYhUu|ZrtJ6L8&bH>2aFLhEF!$Iwo5Jq9`etRPo9u}e;Rxu((=F|-iV*} z+(!+;UWiA;wR5Q@%Wm~7xNfgBeUcZDcMvO7oghFZR_9Dsg*j-aYSrRjY;M zZD&(XAdT~qvxd-n(#a0SZrtag5{#s&I+o_k=ZhrC5DZ-qSpYL;1x?uwLiY zV>hp}jowZ0n22GfMs>(y)aM|>FT&&*zY5Vz594^$Q1!SXZ zXde5Z*0ug;fxy2DHE~0v^!Ei%$V!lglJ1_$-S*VfdG9IHGlPV@9+p>-?!xq5SRkDS zLk-U1AtBraVqq@W;)^dv`oVYZXUdlg?BVZi+;~T3 zem)exrcYdev&TP^coqG@^%}U@vQ_McbBA4o5W|x%B;MJF&THu;MM5qz%>vc8V%unknSLb=`J5y*A zH>CY_(K+gM!3;}LtnWRGq~XRHW=stK%9X&%^xOS^yQ9&TN4Fwei|=PgRNXNlLH)fi zCvh#(YzH~so)!G)JAQiIK2viww1_amY)NDmDA$SWSM>-XcNh(P@{P81Wxo5_AfUS? z9vfVoQzw7L_L=5u8+P)Y3}W9ShtnSBC)VJ@{8~1H7oLp}-2e(+ZV2M;633oQ;jh_S z%`I(AJEr~K@uHd_SX3m4iaV<`TjO)e|L|* zA9sCs?0R37Q9;5t@8n195UhMWpCz7pR}y*9eCd72qWNK&eV+OW5?(p~lY3q77SOi8Ftd)-zHe_CQPb) z$O7X1MXEof=^asMhoq19T0q7{+y}U16$G;3WH9MEExB5089<pky10SO-;WmcS@qxPS#QyKC3&gmmi#gOBrM8+P+9F0Ly;w2+U0?W0+ON)7GNNpXRd2nP@RYZyPQ(Kp3vuI0x8_O%96O93A95y$uhQo#O#)I=3<);By z{*%29owt>_y7`kQBiZt<&3U7*eF;d3nhQcf!l$<>at@)^84#lqYq0CKPIazjtc`tQ zzP(+Awj@*Q+DEfv!~1=3r#oV55bgeHv#Go^&IL`*p53&Iy zdm(<{2PBJ;4*QLjo9}EaGp|x6#93AG8$E9pt7uxfKP{2>G5~MI~1q36*JX)Q#sPp(hyI}tuO9&2;V0* zei&`ACMuBK8;0dSK|7~zJbMLQisgG-2IvI)8@&!O>;Ce4m8k?sC){6+rW~2_UMb=A zd&Dqe{h{(OsB3rHm&e9(Im<^V)z~GtYxr*#?_Opw$F1i26h2-Ta<@54M5SGX$4gV3 z3qqOFaZ2vQQ8t75M>Ou(sgVlb_4OTt=J#n$mj+>_i}P}_C(hY_=>ZDk@Xg$>PHsOJ z9CB>&w2<)UHNj#IPH4L3Z#ynV9p@CS7nR)%Wear{l}osPuG3M!Ugldv`Z#l77Iets zcg zyEaAP%eC1?KlQO&vt4pmymZD*_!eK6M_jx35d0uti$a+f9Yn|pv0+VZw@;-{d2S10 zOe0d70}%BxFlJ|QIMqp}-8V45pd?X6WX*}lYDvkI9JJcwN@lX_M&Fxp^+q*P{df9? za&3q?4a^;Pvzs-W(IGqgaK+Vcbq~ndC(-m`X}a*#mx*V-ylE5RkRuBop8X@br9R$a zV$5E?g2(bAVc(4u*VEz4H@`S}YN1zPm-pes05{>%y!+Kw(p*rVR299G!#OGg@NLe(A}mm=Y`%TQu+e9fq3cyJk2JNK(FnxMfawN>QNbu;{)DPcDr&W zoCcG%3!3|P`CWQs(Y@6I{Da_@g2-?y?Pt)}%dXdHw8?>C@%WTa;7X!GY?3pB+V_w7 z`OizP093ssnm#<;38|*Kr>6WDa{mtczCVGMy*Add*6b-ezcl!n`M%>2i(_=%%^@b+ z=u>bsfzEJyqa^*>7n?wF#&5`Dsnrn~g#+o{kn6-%%x~!jN^{~=Pi05l!G?IcBY=&< zr6N=cts4Ci^Sj)poTXqPE^+%5ub6FCts+Bs&)#w|(A+$;;>?rZZi^K>jg;EP}?QSL1N&EK4b;;<-+bVFyfJhPi) z$!KB1R?oHTKCtflCSgo83NWbyx)l=%u?t?wwND_wIvtbm|8FjaHo&>-I=~Vkj}mjYvUzI zRRNb@jmlmhX)yPXmgdkP6ET#XG)Vtfff+vp!au+3f&Qxkx<5Qfg%_bC4FEQpWse$SQhiUsK7|cy@d}+1mic+_ucbqbwkX%@M;Bw+7r{J6-}1{v%y~wjz|d!0 zMvGN0uU324jo3OWsVSz2@|)3hk%Silzc~P6`5uH5fb|L44qX}t0C3>apk>+)GX?s~ zTCiUCigWH$hER&e)JDnljbRc97_uQJ(lB#^I7u|VJD|TR00RlMN3^pY8bpzXLBL2p z7^JW{!lEX60?~VjHTxlGQ*l85x~t(hS&QJFvpFM<_Ki}3Hy_ZL&k&9$Ut*u#{n|VD zfgy5d=*HHHv+493KcS;-_}k4ZDbX}vai+u}ICx0wh!fy06C(0~aQ{etT!JvtpdOzf znzY8V33y|Wr8fZt_O%t}<^HB!ct72J&1n$VH3(@iYRgWD6AN#?Wxch{i!mNdVc&6oV0EkkZcDLxN#GZd? zEi9Y$S^k1+5Fl|q6Jew67`&eAFdIKESWS&k>WUqKufP4o@)xu@@X17Tda6&bWNR=Q z^AU9Uga=_|<~&e>tf`R&BV4{vY=iE<7XuH0^wsyKRCgb837(PxRy;`j2}qUzg8e60 z!v(;wp9yT+d$ejFe8_gdlPisX;XxyCd2ahzt}Qdo&0nQLe{TSrT!3lm;a!4o5{=#~ ze3d{-jrd7IauYefDGe8-dzfK->1EUt)|X-*xLE?1p?43bc)$GmfhKc_V3q2Jo5R!h z2ClG@2GhAsWx0V~H8F1D<+5K>ho|Rwgc!C4J-o;Q;OJe7>u+oxe7*VP%6)ELfLBqs z1u%MWnTrljVnHCDv#>t+IuY=sN5C^o`1jFxTV>)Pvr(%#Q`--8pnSvFmh zjD9pxBG`nCy~S8!&_n7zr4j9YZ0J6&`D2(xlazKpj&IeM? z55swY!u*-D+ep1o5fUqt0%aguI_yvT)QmkR;^zKfTEwCwSa3kDXki)0e#f4s%se=S zg20fGQ@dTcfTgA~*GL3-;XKd2cK=AykMx7Uw^e_oQ8P3zuGjDXDcNK)ob4~> zw`hb3>`q5Pn7y~7VM4XrF$jf&?O3byZ>eJC+o!8ekNdyb-FRZKYUjnGt;=>Z!b8{2 zue;0gw=NyE%-lEKAl- z0`6nFdT%=zGy!84i%=ju@MajgA3|b6L|@^~g<`77dAg=_Y|fUBXH`6p5Fht*P5-+Y zzf27Iez^aHNGW zp{rki?dlB%Y+7N5u*qdDfpclwjFMX_h zOQ~YSG9n0C2i{|bMrDhFpt%Et&gj%*a_l zHj6fsw^oYA(rL$U53wd~vs6p4_dQFO`>@99%AYw#?yOCx z{Hc?2yQFhR3X5%c>4Go;S5+F6C+kxs{!m<`_>YVVK?JEYARs`RfA0W6e6g#FLtT_! zzmxrm#h8Kb=vW*uy7GeOYp6sAmcUyP}a};kKRyt}MPc zj*Qa31LDrV=ltJ7cVOs3^A4z*4LmCO%NTE7LvJaDomQowcXP(#R#h;ut4S? zeKiq4LxqXv0zrf<&C64q{k|a_31K-&0yIQRDd`Z9LA|54{^4Y)VHMp4 zf@Dq;llQBvGmF~$kSsH~{s?Gk<0WN@0E|kVF}sVEhKNQymC@QTdp)ZOVw6r*PGkXj zA|Z4NV(yzCQeJkUbL35X2cam6{dH_f$a_O_RH!brzS<}iaGsT+ybYBimD4EdgP^Pl zT|F(LG7RCdqPJJ{?j6?K^=amGC{r8g3XK{f%HK-cBm+GRyC7;AF^zgd;sa$~expzB zn)E#tl>0Z#fftsS{+FsT^$wegG2@$+4u+Zv*C)pF-z1$ zK$r%AZoj)v?o741ARfn^q)+-&ld^0Y(SwZd7w>VNIs?{mBV1vJgun;`_H$N2ma}K! zw9+=aw+hD*O0uaxg11+3g?t1xp)c8~53L0Bsyr$uUv+@*SD6~x@Q*2;8B%PQHtM<$ zFiPsjtMnjSnYDW!=SiAuy)oNm5J((966ll^f7{7Wl{XFzNH6zT(^dJskd-0tKkdqV zb@ZdmpPU)0J7w`o_Fb1vJnbSa)RExkq;53DoTIq3ZclQc6hnLQ5TzDjBI-?iXBl0b z$0zATiM4Htc3Rp&hMj2h#)?3QfP-e5z+(VOq#1zeh+p>=zpnBv=bGT8aJ?Ln%CM?1 zP+`@En#_>2#!2cK$B>vD&r)?W?1CnO6j&noK7IC%GlJJ@$v7?;0h_0++b%=`6EbPb zrLGKR>ZIM*0Kcp}=m-O_(c+Y^IgksNyLvHSD?rkKSek3_PgM_LPW()wJaKnGlv16s z>!1@E*{O>kd>g`+grIY|A6bbZpAb7s)Q)+hxHGgo?pFo2LuYak(NIs{<7%0SbLHMo;dCh0=*E|j(D5?1NJGkCgiPFgwHISF0yd9Byr(IQ z3phP<4Hj0fmUCY1f}0fKs9TfdL01V^4-#)AST6`7AIdpfvqs)uGZAJ+MYkl~`EIWK zGq@CuhY-9@wPgYF{&4T$-g4CU?}ab|CH)myw#lO!xmMje&SvsvgXQR(FX)BjKjN0qxnuyHa! z!hx#$3xX)uuPzfv4lv{fG-%wC0XR_9@=mWSI7pb$PxQ5J0 zwGd6Pi1x1}us&#qJdlPXf6=Hql%Wpq*JFtf=BWy=QaKYTBu^=L;Rv-uNkWLM{{(W7 z37E1i{6Y;J)-m+E+kPuI)#bagB$C0nU`kfx6MDE5AZw3Y1V8><9e@ZFFrf};lF3|j zEo1^A%nl0bf0ZzzoP}b|P6a%b3f;_j+@=T{|UK~{pY=p9q6ehf-0Jf!XlN{1Qs3YO;!#ijgCuQsTLo(a8M7N~JR+JD6^ z%4Uk?r--?T3x}o*u%?cT)&T+ah#~H*p3<> zv)fKieM=7NR#{gLd(u}LPZZ2YnyklWDe4(48h-}50T6Ln;O9{3z-YcF!#Z7*6g<7n z8CK1MS!Jjmc>Q)xIRJY=%4*)G>4z#2@E2|ukdKkvn)UJn|v~E$6+C|Dk8G{Ax{X6ahm|jo*_vzo2Nq&ReLM*OG1NiF{(dAwV$`4{&nqK zQEZ5E$0ukhvxb`Si~KgSa@$>>*skfo!L>$&Ox3PtI9qnyDJ9U*-ax(JZXbkA74;Gp zy7E4#ZB(hb_r;68jTg9RVGqK4nx>X!Y*5*!2*l?d#Xm~$2U!kG?Ya^e7Qq%sDf8_p zX)2|8P$rbMXk3R`T7#o!d)VbW9KE}*E7=4ERWqTux~K>pDy%{^)Z8%} zvf)XpVhsQVa=5z6B~ZD`G93Cic3AYJ?MTE4f(_UkZJ(Go`jy|+4{twT8A_q*g^L&a z>Q_(5AYn4rTI+@6+mA>i3lg>U5_QzT{$!_uZ)3jEplUv2NbSgT>MID8+=C(>uLc_n zBV^_a($p`r+?jOMD})05zxDNXo!Sm6k7ou04+mAmdJzlwMkUlBH1#K>5S1PJJSE4VZpXCU!vvZ4M4W!jbp-pe_R+Qw9#jvhT;`5eAqBd5eqLk5yEskt$xL z;xf*Qq3)3F2@VjV9trbni5#tqGBlcCJ&U3avrJs;wqb3wy4?3wgoZUi8G>2h-;|7ZYxrK(L4iTIfY zK?!xybTmeA@^E)VV>&e9ub0gU>h4o_QMD=eo2#CLtrySJX4uY}&yK)9;h29hApTQm zR7gYI~@x)+zy&^oK?0BaQogB7@eePxj}M`oC*6rSEUjQZ*k5wcvvrDM4bh|@EhHa z0X>4OwM=_kL-N?@Z5JDrS5S~kq2U{GP!eZrr+-jt_u~y}BHC`9hCaYGK2ODRHIUI- zu4`-Sc~m76-<4e^j&GryJ8MRibAZZ9jOCxvCt{0@N9KA7o0}&uffh;jXhiUKN4)!} z(S22kV4(Bg=BvlZC>n$(k4Y<4r z4HK@_?iJP>TTvTVr=O}zpx(GXeDhVw!VopHKHR9SzjVgHy&`)(d{y=Bj(WzE4Ak(xKG@taZ#QyTWD}uk z&epK5u8h)(c!_hhsvdn={;)mx(Zq0XE8?t^&BA4W7RjVLEIjw>t=m$fzzD^vTZq^z z;#*T5A&-$NuVM+OO-Gcmk|jXNO%NFoWL)t7zz-Nk)O}7*G5LF4BGyt*=%#(!4r8_* z(aBIcYEg9(d6(>b9S%cy1Xo{NSEhYW$NfG)y(&NB5N$z)7`rS8mkZThLKMlR(CFSa zuFrK`uC~y^D9KMQjqY5W^^Gu+mLYOFn=~O%dtLn$;(U6sKf?m*J6oqDgauwk_c064 zQ-;!3h$Kz@o_bPcOJ%=Z#_sBPClFFGekbnnJAUY%<9V)Dh=4=t-l*}WhpSUD&8v77 zsvm-R{RaVtcE~vExwSMi>ltLdxgkw}hWX|S^nFz|?MsBjU>$Ak_Ex0-?6~?-=#coK zvPu;Q|H1Luw|@&p_~Qq!2<_{opTAo7so`Qa$-V~Qih_i zf!A2~A(#KNZ_b==5|5BmKW@B@Mh0@oflq<=i?X~?kE}MYm;Vw{yy~1lP7vfoC6-!K ziJadcKOUQiHM{fQ_Xn#<6FL`*6`!&q$G@L^GURF>S^nW@woJ-1Y$CV->ueK-CW&A( z9X^`RjI6urKzd}DBXXe zTv-%lp1x0A&L(H3ezd{iYE)NS`hVP}s8#Lbrzd!*PbAm3*1_JO7vO8Vv)*anW5NXh zK448I21?6t|MH0;hTuvC6;};EAr9N31Vv9g&Uo8E@O{q4%9fWyHgHCJaq6=&aC|w2 z-F!{DVi+XM#I88`v1T>~3ZRqL%03zc5P8St%Y>5gD%%WpNDY!qs(%`W7EM}1k!q7@ zRMnx8(pj1i7utm02qZ|SeIf;F&MLfbo=%Dry>Oiu0|#i>0 z(gwd34(5Jg+-;AU2A|Nf(r#)7B>3ZqY8%mm8pp%zxWEwvz$UmCE8 zp^+|&&cK4HJ@TC%h}5tm$k#;o3Y{a~Batdyr+_w%Fo_68|Avj_JK?m)HTg61j)b28 z+f!wNa!n_{*N{H*0=>X*6WYDu311}vb6clej5dZ^E%5<7MKYGVw^>4@u0y|fWOlLMD0S7>R6c$+*K7v#T6{*T zqe#VDN@d9K$l~))@Ua>Ik)G_n2EtiMJ}bcpx96%iHLY&bxthoV!aLvEy3{$ou?_)c z`KDUb?CDco#AqM0*xwM+K#P6lblHntSsxQ08f8MkMod_-)$?cf=a|Za>0^9UC~i93 zu^yjR%kOpT5S7J{oxPRySN@SV8Z6Jz(_OPhmBup_;-KvhWo|t&bzPn48|`cSQsatl z>DTt2yJcRdRC3SO6MCbM$QDT$H~(FxLBVZ=tjxsfURoINnZ2}|MR=Teps~M;MkoEhONm)qa4 zU7ezyl1_IroSVDuS?ev zs2x=+PQTe6%qH!H7V?S=e*7Xan95?^6ib7-!GF|5rp4iMktIJ9{7tm*V5a9-N`=b^ z0s6Shnr7`u?k`s+B5V{UjE_}X=0n$eL#6F6Dk@7Fb>u#n^Zv#spomGd1|07p4+{j+ z#Se)_LCzY?9tHi&ru;OF&f2=UwUzqG;S*U5A#30J1i`$CdT(adGeE^h3v-ym5!~AV zs;jXuQ&SHW%1%+ctUO>W;Bp|!$B=M0ueQ;Ue=cIvNTAt# z&11S8zCrOmyiu=~PvkCA(@D5UhIlCzFFi9S=TT23&eF#5q==-Lx}wUdH$~n0!)7lBZ!1 zCZ|?IfEsveI0A2INNrIZ@pq1>us;!ZW@fgwz{5hlsH@zYSm@VxppehbU%AsNDUxHxGu>y{^q zu{6BhkEY}q0K9>M)cDSzO%@LwDoeS2x~%{# zY>j2rYV%9~+~cspQUWVtCxCFHdc1&p8cQI6%TUa2e5*sKpIA#xpvH*KmfUgK*E(X) z_A0oCqIZNROE^7L9QzjI1N7vWwyuWst49B5`MEL^MAEZ}DN(o$LpBXGr-`4ERwBMD zw-F0nI7$Kx&4fL$TRkYulnMHn>eC2f)ndW-pp>k`g%T5H>858-&>cb z?#VCt&oBeRBv0Ph?P_iovkTieX7iyo6(oH`2M| z9X(h4#C2zlc}KEftg?;4CmRaEf@QZ7# zs+}aLaKCHP1PEmG&dVi(#kZ~fmG*Rxa~HE0TeZc;ZjXT=$UxJ=E%J$%UgY`;w?@e= z{WuBHMU8)p-Z!uJpJfJSNUn;>gtQetgv8(!yN=|97S?;q>Y&^?=qD7}BtQpNWV?S2C%d z)q!`xX<{UuZ@rEyoc8jGAT-{D@HWSq5)Vbsy$3lCwP*}K)^P@_2Qyn-+uvQYo?*h% zk+8Zv1J)|e;uAj6M1w};Ao30<_Nv@!E(?h#Ns#TU2wsIVscyyzv|Ga(#tMMU2~3YM zkGmb23SsTzx7uQUBEUtluBXtC+ihttWE?Q5(OFebVv@5O$Z3Kq3D`i=FP{QcFy&kY z6V^WU>S5`*J&{i&^PCqb1QHZrM2J58vusVE3QZlWDy>7&%nj~GKh=-R>)d#29_4b| z8X@Xo&;l5=lD~U=J0=B|*-cHzqqNVo@Ge-a6S~L|wz+i`RUGTt)8JOb56suav(X3N z>*)&~xfVB~m^Y$?Mn04l?x~b7(O}!F&?0BS4{nbfIu@(NreGcNJr|yJ0hrVI#tPy9 ze;e$J zyf~G9vYiIy8Y{gwComvFsWqyzOOdL($*zz(*1nkWv6jO6cLQg8lJ3ci*q>Fx9T^S+ zDjRjAN|<7uH#7LBE+GPx+BYo{P%?IHM|;kdsF1_`&y7*PckCmQ=yb{=AdYeIMVLSY z;)RJf#0&T@q>4929hMt&iJGbNy14tTmR9Q89gTHbQh$!+QXv4{{YM3wjqf&SfZ8$j z-Ko-xsV5M_t=lm5O$jx`bl0i8gZ44We!;{p5Kj6@BL{Aiz=!^jzk*zY6m2%xhMkQZU&wuv2 zu^OCAPMs0fGOx;1fmOxBPmC#5xu_X+o2sz&5J7DON4-4_FIve&oboIy1t4m>y_s2> z%!owjPK8M0IDtagY$mQ1yEao{Us>4_dw4NDCf&}7z+7FPOc6GSC>aY*O>zQE>xkNO zJ5ohBwLD0wV5@k&s~{F%RoU_C&*-ba%VwL82p#`Mi!8#4P&^=se?^8tsLY9!r{Fa4 z3aXYE<(4^$GpJNJ0DfGCZ6Slj!m;f@f>HocY`!%H7B6Ohna~8@XpE&aCsM%{{sRK@6~@WP?g(EnI3rQ=Lxd z#hx$h0P|2@OW}W+uC=j4B1Fw%@H8GRxX3{Zr9zrZ+Asch0A;vIq>{D*L=tqqy)x`vHX2(t zPDiRPFPnZ_HiNF1Gp$$%t`x2w!UYSfe!^blS}bZYZ?x-dbl7arcY17eg>H1mZ#>W6 zXrt|xkwBSW&SoYd5V7aWiRa6pOTd>!rFN+UuEqhE?`)CpW>er{SL$qD>tg!C&AQs%`h}-mwWn>Pw{3&FMS+h?mfzjN zK=0fD@4V2!f~Svae4Sq0b9(LPRQtfKBz3-v2f8{(+L{+Tn%=)@TI_CL>uFzV zZJ6up`q=koeXu+23?!{JKDaYAzB@a)KR>m#G=H!(cld5;`@`Dtht=(srS0`kC+i>2 zwmxlbZ5{6J9334U@9&-OY<}I}{dRnKd3Jhnaq;uw>+c`mvo^eF%U;t_+EakivKrbD zVp+0$6tB`|R+zJjMkyFydr(8E5YNtOjlr9(r9YzO0^@I3TBU{4GIOa|n)LyblXby4 zziAH|PuL+Vbs^2%@Y5>av^rW|ynrQ-V;4XVW zWQRnq1Hy4&>-c^yTc;C0?I=g-et&{@K7mTM7i5RfcvPSRlR)+MgYFpive|;t99Nt` zR`jwIE$g(?99tu3Ha{|j0^C*bw+Mn>v^Scnh#-Ccdg}05w2bXJ?afo`>AIP(&p}fA zN#GYSO6{uwwCeFNC|>w;v9K=xm?9)$Tlc4&P_09Eg) zhOp}7;;=SSSNbcsep7JRkuV`>dy*JsyD=LKk+?}_Lc`UzQ1}oa)tAv2-nIKsr#;lD z?zzg@+9p)AgWr#SJKu5;%0b8RE2MUY(Kv04j+d)OHn8Wt#vx`ZNsbM8cns@3i$?v9 zVfSUUNTufl^`&vqBYEm7luusA6F%r|vu9l)Pb_w&%$8dp=^A}4xHFe#L63w*oL_#C z$pYrHh-n0R1#&{3fnQv|E9`|B#-()c`~Ok`ibc}|nDjuH zG+!nhB?d;B*2knxc@E1?gEI@_EpRj@7A&PWnmdkEb_mG%0b;wuUNINp@h+q~jRUH3rCu4+-s$C+Hi#P9a)+g z6{bEM4L#2JEEM|tkC>0C zk@c_Uc**j{tKtYR*g|Lg3}FFCI>A?=00PEn{yPEDSGh@555*LsMPQ{!*v#+F5<<%n ztZRz=xNAuwn~@(jnduJd1)4h;`G0lJNpvmi!FCQir@2dA-`LI{Fh=EtF!jB8vd7rt zNOf_?k!FUf>^CBIscmx!n8|AAKBt}k+(nD%*5~Zn#&dVQtL|Q*t+fL}AhUNE61rEs zyXk7WD2!=<8oN)wJB0d5YGaCMov2{?Q2~N~m?bMI4M3h^18ELMtHGYewFO zOpJB%IR)+9ZTTJBag^J{0vhxb&c0D@FZiCAy_|vKDd+Bc^ee_+cmtri-l-HH!)r{{ zM+?xP@vU?z15~^23x^?)@Jg1plDqohnl(%-Iqs>UEdB|lEwrvOJZe1$h+6kH0n9KN zvD8{c^!>w8|Ll9i==uP!KVh7vrsT)aWZ97UvR9~e=i5aZ6l0HAM^@YNU{Y?6l*lj( zBm7^P$DnR6yVE0+y|D(dy5lz}eaPG-VNc1;BGqa42(Bhq zgD?(r8jNFF{XEJ58ifbHg@kw34I|ven6y>H)Q=E#$!}|e0lzio+SKocr&GS}S>;K*u-&blzZ4}}? zUv_HGzJ34gE!zLhS?-&Mm52wlP6#?Crb$OQFC%}o$Ja2#+*&2RYLtg@s%?ZkK@)DD z%|6HAKgm5Dc53Cwv&OjJX;&VKSgY|n$wySJg>)=4?pOH*>EyF9!fzP(eB!BvDI@5h z_m9>bDV^X``eicbv*_IpgN>Qhj9L6m#)(zMiRsrPbPY)o;ftI17<;*W$JWNPwKC?k zm}HM1iQ6H9YJ#OdAOh%|Cd#K*h5A|i=aFl*C(2$!u~&a7@HCv z@e@-zIN)*G1K^Ei9|?pHk8eOeQ$C$zvB8K$0*hmTo%6BkP)$v3%L1R=Y6L!)k@(oD z+k5m`*8Cz5QzG5NcQpv5d(YUy=h$ERRvL8Vz+KBdJL#RqCU*ep<0ow74VUrQ*5R6! zfQ})9C&9BHLT*B`-xa`{3m#F}1yf)`d1l8SJ?+64Bz}vXfy}-KV)B7nd!gcVC}MG9=o1D1`-$fAxZo8q zBm7b=u#A`S7jI;G&ODpiCIkDXK3zul%oE-MILAqjzr+f%ZI$P}S8LZ|d2MNk>L*W& zWy;wP+%M~d!$0IDFtXdNwS5SQ;a(Q(Tfa@SO;!t>nLyy`>`U)Y&~xH9(3yZK{V)Un zwnN^+`^9;%!7khK5+malxBE7=1*5rIpiK9s|JW|J``yK41>49^cSHCM3b{FUw$D)i9eR%sl>7$+&%G%`P)aXTcO(2ihU6Y2TBPku z&-T?ucl^gr-bT-SrU!UwPFIKaOvWQ^)EIZ{@ok0h>_<^dv!{5*;NxYEqe(@egM7ba zf{}&XY*c)7Jk=jvceAzt@x0rKc4nWY;S3&p!s;|IA$>TXKt^nkw@=FFmg|De?GI~X zmJYt1G8L!Ov>dMrjnVY&Cc2-#lE&ZjKA~R8`j@zQzx*R~WBU1%ZR+r|ox2;n{JTO> z)(HDIIvYn$bjSEKt>Ryrz$iJbHh3>1)>rRiNc25~hzt{FPi+$9w5`jpGVj1=*1 zMuq3_0?*Ac^aX&kzxUiO?BslB`3nSdb`pEo_axf4nm~q3>c0x}^<&!Dy}(^e5^$0DpEdk zV1Bti<=Fb+`)^@l){h^}`?*WJa9{d|HTqvRseWBQ%^f8_W3sqqzc|I5&H!ZgFwcIn z&FxXmPePc!@}TQI|HkX9_#}0kVf{$u7~x)^tFz7{cWR!10QJNc!Whr4_y*i;Ymq_t zk{iDA5dm8a(2I_sqT@PB)!$H$p<@+R<}lvG#<8?254Pbj8i~AWeAr~;(#Rxc%Jc+f zG-~*ns2x2#^Sn4Ak`zLFnmhbB2pQq}Og^6g~DG{i3}>>vgIhGFg%v`kaO-t09VO*_$q} zB8>TPZR=Z<`Q|s5$i~Xw-TI5FQCBRg=T|(J_#+!@J&`l7T!*#gJPze?GhHOkPxtr%o#?s!13=LDLZT8|wEa6tE$3#9XLy5Z>6pe@>VxEV?w|)lmArU7SYDey z7S*UNn1q$@%w?jj8u>?$jIJu&f32&WE1fVc^egdpB{~*&LG0;=AYbdt_n~I=74y7_ z!(yBj5#evv#>o=pl(z;OB^0iE(RU-*be+_)R&8hbF-Kltie1DTXtY~L*`@BB#OIaQSi>Qi?1)x zepE_UPO(BQRxU|G-ql`!|?k$leEIjZf;iYl>Wb+HV_@l)a@hN5P?snCGa=LnUBMnCM#WNuO4s;bzDtdE~~q$zFb>sDgN^X0AVKGOIl?c z^ZZmr^;4Dt;U{`fJOXPk)g^UVEZ<4G47xk3CDIi*Z?t^vGkAe%;w(tnN=Ckf`5iHiZ{gj@c(fg>xeMUJIwtNBJ$S%+O*qgS+z2q=?DXp^Uy4h#_LrT zXF`YxZK#lmDE?uwtLx9|(cisu-HBoPB3~Zsw8(F&r^6Hd$}xm@gAq#2-<}Bwj4h80 z@1=B+q8`f_=V^o0nR%s4V^;d1jCRgg=2=$Vom7$Zh@0#D-5qtL0){v!DOZR#}J-1Q_B zT`WuGmQ~1T3Zu$km<%TxN%=jsK}R@g43o!l>%s6X&8TS8BM8j;OCh}+gGk#^vEdQf z0$aqwAct;n)kxn*a4NyVZ;$clI*TwZ(`iap2SR_P3c`G;Bl12S?Op?c4E^Ft@;~vE zVPW^D@BvT1=5GaxC{K<}N~=V%d{Gqw8#iSkrEA~V`#k+H)wFP0)m5Ff0~e#z zBmtCZi)n1eOL-Af1;Rx&Ha%EHo|Xoq6tdI_pa~MLuH*_QyY-xoXfY~HP@RROCm}zX z5vY*2ND{i;tHhabKUE;`s}R{Ebtogh3B^5$A6@FrPJ8zxDq$iFdY45pSFu9_D2D4Q zTuDze?FJXy`=fN@OnJ-tA)4$#5X58^{}q*mTEA#-+fTW(u~Iwi&sFJ!!yCz3NyrRw zgJW0o*z%M->A?!#%Da{pDvYF;Nr~tbZlKC)cpz-y`gJ>^gtqq>@`K)q;#A)Bka#$ znZhRKFh3d5iQG~e$s2C(gW{^!HUhKw$Ar#3v$^fqT33c-_~rr`=2plV99xP1I8P9d zQ|&7EuL%gB)abG0!2j`~WLOG`p+gUB4yc71R|knnw5c{RD;I(;W%N%u8*}m2O5i}& zF<*~|H~5NKt_wK0X>+~eVWG6#u7sz^W0DzJ5SFe(bpA5V6zxoOrmmv`q*osYQ}+@b zvsDBQ&pktGhOqzkretFRONG=t8%9@<3d1_=+N&H2E~S&K&{MOPJOSE=uA@(GjxHoi zG77~;kI_78%EDJO&&^>)EZFe;!A%p%hlYbQW9x^Q{o$Rg{YL&3Nu3IR_5HYQEB>Gp zqAyi+lU!^dURq3Xz9_T>+qtp|7ZfETm>K#l6SFyB`4VD8*$%)`!|T4p`= z?P=Yg(Rb(FJ|%=%n^{&q#60D_&HpyElh*p0hE3OPc}lkhuhJ_9nPW2eR`{PrDx@K+8sR+9>H(iW;u02<{dUq9$9`ku#64trHSw?NG@4Um6MzQAx25-&qM(DXNp}PL9t0$$46%uI?ssIqT6NhXY4=9|&sxzRpOzTa zetn9z{aYUY?H^4qU?#d8+0|S@G4vQZbB9>icCF%mXX2Ucxj5-lBwc#ZvyB@N=zG`> zH>AoGviB8IJOG_$R>pV6r+j|@X7noro+q8Xc{5J7C7Rex@{me7Ywgu5%Eh(lzku#~ z6Up2}2uk_vb*JCk&fKC~wU8EQN8%BsdKOLv9;R-^+$-Kh?w3&IrC5t|0Qv@I+Q|o` z>X7zST+cTbq1b)(IAZ)OQ{}eXLLX(X7uWYBWy=^HLPf9A;+uY|CBCnT)*gsN*0bkB zPW57x)2FML_upg=Kr#AF90~)uxa&8s_W!u8-VicK$=o2O-&-WBhEsqr z4ECF1hs+Whn)YE990R-qBx6aj>ST4&zCuO6QfxNnt1h*YzWlWX-Xg0TB<=nLt9}v= z9sC)p&O@t)4GnUk26DoufMTbSN-r^2Z|6VjaQ`W z9?YoMuTVs9Lp)uS5*;;*M8{HBu3mBz6GqjZebFFQV78chtZb`7K4X}-OOmjpUPyzX z8Gd9IR$qKuwWMA<;)nX}eC}GP7B8jxi>X34!F(&7xF5sSKXk<#>2=J;=K{vd zbH*nYCMMV7s=%}s`)`S&!_QHW0Tirvt%K~HrPEH=$BgO(Iag7o zzKy}Y`5uanM8CE~T+Lrc18rlkQrZ&2@KF8<(xW3{9(I!9k$wY;sDd3CG8@aSH>@K{ z0wMbK_ov=ULLReBlSZ|su+tZ2M)wj7EN{SvT_A5tAy-gwjSDvyw+&)f#)oInwW5Zm z3Y|3G(}MDx$H{qxCRj05t&}6F{2vBss_a)wYO>IySHhsb%pl9ZlaE#Pb63XjUXMvd z_lU#!#M7p@zqYD}+T&j&AuqAYYz4*N(q}o#j4u@m8(&~Tn&V1?hu1I=ZHwGxWR03h<4-;b?PUT#j@sk38fN>AnuRtFzWyxq2%RUMjF6(W8;nz#REUj2K%p~x^IxyAB=sE9xA5Ez=CF-~Ck zJY9pHE7~_9$xg~Ij;`_G@{~!?R zI!RKZnp0+-Y-lsrt)zD)??*g6j*vQAeoD21XSKrfu0$L!Z_yG6YF1IaE0I1{5yufQ zgBTS@tEiwA{4*;eK8QpkyAmJ0LdaN&v72*He3$m*nn#VqYwg7o!TiD%OiBGR5zw|x zp#L?Oyu2N!MHT0}SW%q)jxER}ZsEoie+bUthFBR?9W@s@qj_fla-){`FbLAyIhN_8 zP{nI;?VFAzE2&5d!rTnY!rpWSMb(4YvP8|&-QKq>YL#Z-iMik6oYEnTi!+63ah}mL zZr>o!uWEy5-_cE2q-dK)-ZzdRypJqe)$MB1Q(TQ98j_GNf~APw*hxKo>HtMZiZZ5n zrXz2`_AxVIR_FtHPVvLMhTTH#5;BNnMK!ymrk-15Q?p_N6s=sj{vO)NTKSA96ZrlU zmA%A0Q~PFo+@QH_ZeV;J3(2s|LOIM9OtnTrA$|y$Zg$oeE3%GsS;ww_=${+fkgU&@ zHHqzA70zq%W`))B61OHa4_0g*@nT-NjaakB7e`4s^?{qZShLPPtbhCTZ>ZyzYyY-~ zP2|3`0WVRi`C}nso*xVCiGH4+@v(1?wArbqz;hjc@5#W2KM=^v_tJSYZ~CAcrKIM+ zA1hs&Xw4_GlnoyQIs6oYSv|93;*TG-qxz%P_E!VSOuf!`xuLx^FcLt&@MoAIlX$o6 zZ6U`edJWQY4cRUcV*AhbZHBDe7mtc!SS}f*sEJkFv)vwqr7g%xxL%#7s8fxQUw){>h@^bX4Cqj!?G`F!a5-tSC zzYBf*OD@s%pOTbq_n*-f7fqc%Tf4}0rQP1n zcC8yEEnN^**q~GgP}LaA^l_-=B?Q$S=kaZvo))(I!S<-kQS=FkOV!08zS72R>&_HJ zP@0%bHho8|k1PtgyR`rX#q51<+p3#%G$@7Ms*4-#axC!JZW#TbDYu)t?&S7zKMvo* zX<m3@yo8|nFVfP92eO&R65QhI8n(E5kWu884OJtjynlVsA#KJV2h8vgs4+9 z-IgYjoA>M44xOM;Sp)8lZ*G_E<0(MO-ua_$>T2-=>+WtW`5lj;1sZ$#!3%vuwRF4n zS=n}Z(!ErkW(knb9~nsz)~f?)xB}7jqA7O^Fig47h|iiM{L)Qn@?P}1%c(-Vk`R$h znu568&l)IB{G%q!D-EsZJ6sArRzIP*=+GG_i@mr`0(!mj?^A&@Wzm`Vy`8dyaM5?Z zmqe#2=;O=XE=?!uYEsL|-fHREzy8lj`vP?4I~k5{F(+&JMaMUzKIdld`&N>+6jvc|jS_;W% zcZZ}F60f_A0tVvur6G9o1N-!u-W+L?O{Q~?`w{yb6fOgyV>$XvzsIYV;2d@&PaSt% z7y|O}h=x!bNI5$u9-g1PD=f7KlnE_UEiOS`D?xtmbrV|?@BEALch%FcPbSN^|7Co2 z`4))%B05cP(M!kZ z4HKs{7v@5w0w?2~Esm42{lsX#;YQ*bFLPv?PNG{3Y@G@04n(w7Kqb9zgq6rr*ye>G z?BLIZ>%K27-iUrKN=<-$H6z;{=PlITtxUEf*_A`!54wb?{6Bf`JD}IuTRnk&X}#}z z^bWFFkK<{2Pd_G@U4A@r-M?2k9LM380Pb~9cu9OuH_D^QByxplOJ@HT+WNgXJF-BS z%Qyt)0*SKm!$zMC0akz~ZOnl0_abG_Fnt0IqKFC)1ZQ>zJp;vgmG>Dw9WM$AX5Hfk zPaUgV3$`lx@k%Y>eLz>;g^x3r&$ciTwcul%SB`E@rl%CE-ci34h#7`%b)eadYyKW1CxvjimrPm!sZd zox|4$T`GTH_?0SqYQYyey$go!`@q)8mZI3N2g|ShPRVM2etg-Re>H9S{d-|{eB!hW zKCRCd@}qp|sc-lav#-tMtc~Z(Vqq4LFZ3ExZ^lzY*Yb7qUG9i0L&1x|d~PD?dNzO6 z`Sm)*h$XmjRyTO8BhR(g)+>Ap)SdAp`r}A8aHbkK$Y2yAJ3BfshsspUg(E&Lh|hBN~D_SsGFG^J(eI> z?*?(mldOGbY_s9C%z8iloiz^W_UMrZMw)FActKfU{UR~cJa!?7Z=?J}XdTuD0W#xt zFV)w!;bcrJuj&x5uI>0GUef?m;(rnBLG`&D&|hVvY!}YhyQ}>-hq*4ZtKBLeucWcR z6p?aiycDZG*>3+_gzn9(za?pP_9ZIQO}`-6*P1Pd7)y?Eh>DbJC8(f&j91z=R&XRoX zq*iRs8X*M-&}L2kWbv*cy@eD#Kb26+h726W2dMmbdu!sqAPSVrX=@e>8&kas@Gx3w_ZH%N}%dt`KjYIZ{EJG z>yRPyuqVOiZiU7rOMTUg>ZiBxzM^2QV z%tK?dKarw*eK+#AT(#Je%VPZQz17*fNK5ZRn_OP4zFeVo*rFfpm;PM*C`~Sh`B$^*~4_hX@N{ z4ldD$K9$A#s1OdAGfJkX!ucsoIcqCpB2vwmUn5S4nKl#^D^O{FXLN;!xnn3g-U^u2{C3rImdkN&^W+d(p8a!xBEBu49mj7OG+ZV+V z{l~^pTbrNKLso{Q0O7%__4ki*%sdR3kN<6@fa<7E5gL0zhhWS|bEm2k4eo?o8Qau? z9oI{9Y{SJU#F$Nj2RUlK8i8zb(k%I~ao4ZEyxo}tH;#*Xau6;M@65>&s1)_o>=4R? z5u1KA_qy2$7x~14@$jRz%#>kWx^pZD2~T@73B%gW#B-_xo1oMNgJ3qX${*XRVMY84*f4%3W~(p)(J zVL|rjVyvoAB#pHCnp~l&CT?P##OfaO4$7E z&Qa|}7hO(PLPdET(=6#ObLVYoYD?2gwc5uI#uvK4 z10V#Jo>j4EB1HQZ@vTo;p%lS15@hs7e~Z?-E(@A??f;)miY8@uC@D8 z(LgrvZ7Sf{DoySQsl)%$<5+wu(m)x_XV;jKnZ-oi1!k1qNuDSCFfnVFx(y2w+q8?6 zT(`Kgqld&Vg=P%XYqGcu#bN1huyi-EU(chf3`%tWm{`%qPi@cO|5cEX@UeB|CRr{y z(w3#7+p;Bye@Ia(4H#h)?iu9=9yG_Tw=et4NhRHsfdTap&s?;|%%iF=X? z{au#TOTHuht%*rr!*6g>=#L&!_!$eO)v8QiNUz4#<_%U$^OdRaulB0PteniNDcbG+ zkMU18Rwt3`(@A8dwgD;MKU4ysMrvk?nqKc-@BnN|+M05yi^FHWy#RK0*#>nM%zQ;qg$x_GRDWLJ-~hZyt{4KYPG}2)nk&lo#Ys ziF^Ers=_S(*HE3;C(5*-tRE;29{eVgwdtSz5*f09tl@Lo25VWi7jk@pt2+tkKr0cu zk7U)q{W9Rl3L$6Nd^^fibzUY1$|Xa6A1={4Wc4Igqvcsmk?~jEOi?I@cNJOHEdXsluwqkv9zoX?%xh~8T!+oDQ(CMHpG$$VN^CP3MIQuYNihy#G+ zKC;zS6&{dLAUr-U#aq-<=LY?{)~gWsPJJBFR)>5(I`V(?U!0n@i%k_CE$aa zd>dDDP@WpJh9!oHPS}DrvkX`I5ub2YU`+b2n|PHFFerrYz(!jgSZDb}4MVZ2v$1cx zv~=jf?$R;OdP}?V-=hP|Bm%cFh+YaS%wB`$JvkE$%Ux`sD@CU8|JSNLo(uz~LG2Tx zcttD)_^v!+9)ue^Im@C}8+9Ld7iP=4@dPX%h_W#O%PUMx!;Qj}s4X4yoEO+0!eTx` zR?^mHv@^GSuBzslCP zWeK3@WQ(bhE(Bogh4nwr4vQ%H=t1>-wnFRdord^J3}OEUEXrsuhDZU}$;SjV=ESk~ zQm#kme2$a5j-?P?9RPp_-G(pj>m8%7FnY|I(GGsOYq3S1^~26=%{*fOi5yu*dqPkBQGP@VQQeSAhwB zQ*t0fhXl zM6bNmV(|>`zEZCQ&53}S@G>-fOd`pFK~}j$0gtdwT8hDUosN4onw#Bg*)lvV)xrbs zI0g|w%l-+f1r-fC zFsRQRd9yDj`qQ&7H?fWn+oU^Pr=pYMZmNR-j}BK0wU81Gu|0pSJ?IDB8(7NaV}_r& zyL9UL&S?%W=#BA#NkLIrfgV^Z=G*Yz5MAtSeN{OZc1Cxw&!!R-oHN}|gQv*(Y^=jv zAfJ*X?`kNiTd5RNO7@(Jj(^oJDLnTQ9a5`>BPXwQ>0M&MYxILa+h^yq(T5MTmJ@57 z*5W~SQkaTEWlpeG>2blJXd)AM*d&UV-&bDWXY%~`&-v)UoYrvXJrVQIXt3mG9{13$ z!Sj13VXB{PU^on}?!BfnoUlQfT|*>} zdgMO8wC+EXLF!vp05=v0yf1H6%_j3dx1^U6uyue>cN8%3Tpd2iP7YW-cq=8Re(&wc zQa()NcCM9859XB?PttMBr~avXcWmcx27|yd)W=NQ#^3Pwg|8ikFZhRD$O2|k8u@eI zb2X3IhDxIwdG$8Wds8+jUTL*ilQlO?Ir3uG7yEb+A1M_8N-8urLm~#p&eB)!K#-<3 z!tU0a7#^M19mz?|Yxwog8bPCEjG~_3JpT3#gVX=&O0CWt=+CMepb%T%?WWH+Z;E^|+bY6w^(u;^zS?9{LML7naqIndYX7Vv@CwjI% zwx6$t9ZdzT%VI7{VpaEAikP{#HS*Fk>Ngs+W=?LF8zLd2K%h&%b{YD|RjvDhnBJ?- za3c^q>v79{r5krG=d^a#d<;3{FmJTXJSx7n=-`3U2e;WbzqQHCx>c!0OoOl&e6&GM zW;s_*sbI`tbH;BBhj*Tjl6|m&6TpwM<`#pl+BqJkM*ZZFXraeQ(}S>Oy3NhD=(giSD+!e z%OOomXGHgbxZIQnT7j5*(@H*{E-MVgO)~TZ?`r;NjB8eDU1a+(xL_MNqS*AsqRQqy z8u`s*pze_$_?QiyEBlepA-F=v_CCh~ zK>JsLJ3k`mMp@1=U|4@&z-qXt*x)SuwQ45UiK-P^&)C$m{hG zN0bZyBr;%-+-hRllKiC-2F?z`upZB#?VBwm<1~BzSJ~(xMG5K%G$pu60(WMu3-*}V ze-kEL6CJf@BUkw_N`hrAlI{`qhgibixA!O`-l+I8jIBYwM3W@?xCZZPPgLihA3Z|_ z#C_AD;CR>NxLgRunz{Uv2&JCbFP^LuEcmG}yO>tRyUZkF z$H&v=;Hcq@MfKY9gC*5)fdh1in-&u~;jGJ?G$;|`70Y!J1kS_!c_h!16h}!d5vT|_ z?oRprWoL-`=~S=!OQr19Gm(uRI2y&Qob1>aZb1Ry+LHMRQe!*{;NIT#UK%F3smf6@ zOb`?iK&{P!ODU?3f*qzy5*X2dCCX`7KN#&yaFlnU79=o<492KAo!GVk9>(D%V8WZU=0f+?!8Ue5Gk41SZ z+2*l=2J+;h0X4WKGY#dl8-15X?W_s6saU4u_)MtAFw#wLzIIB_2o%rh!pdzO*_*wUZ#fi_Qcq zL&HCC!Pc|l@?A&-X{+l7#bgK!{DLN-GBSLcOPo$V#)NkJD#v+Vl@tkE3wN}K6+g_uCZjD#W24d3`)T7EvErgqB%Wg( zqv$iq{r(u|7qDRfj2dPCNWHp=pNg~hCbCp_yJ+{tt^8k#4}T6Ok(TuV-v(S4u4WV? z-QueGSz6=jUt->n0eVrF)1w8}=)&KX$TwWhMdr{&)Wt##y_+X+JdsY4TWvXDBTT0L z+_3?7te6!qfxob>da$dr3tyKL@9hEwXME10=2k~4O#}ZcwMa)oquKat?4da14R%=V zLYPoOdZ{aC?u0hzN2da&dd*y$pxdRgvREF$|7yM}q4=_`tRumCH^;N?-EN-$l=WUg zIoui)sXt{^lx!&_${~MCNz?*hmoM@NNEsMgi>BYdma}|05QQSJ+Ptgs=WMhw;Q(=% z=|+4K)RqBqm@N3w3HagtyH%=Bmy66e#Z@@nLBzVEyWAAP;@Z=6Rs12e{dbCas2)&x zrjQoXR8eGqSb9fY%n|PN1&2W0gUm()_pvotE?1we!~fr0fLQD0nW>TXbI^+vrgNQ6qvjydIY3y2Zy8yEH<|n>HLP;!r4he;jJb&fSL$af-(9zFoFO_ zRR|?xEnJwQM|;ha`qI|?w*j$Fx|llSYAA#`2r$b@t1JJF|Q%T?#? zfxpmxK@=Iiy5WjQx~daigfP4x`EtlHRWn*O09kD|u{0N)p{hhD+`Td_@%&bdn4^ zIA0cxg%q&S_P5Hjrr-AI$hh`z6WGx~DT1vF6dr3U#nwo9edsTvr)hxnlAmh3IsqkbjJ#n5XA>Rmyx5q+kokDf1i*z)q$xmNu*8#+B)kmLM zA5G^tDnBaQ<%5W;Susk3Fx`w{A;gZSLu6vi^LQs77tZPIVVwW_fO4^vxsTc=)o-LQ z>K->zH!dovb*k31OD0pyQI-@dzGh9(PnHYdZbK81SRE$J)PXsQ0Y549&L+X=BNJ)> z7)|jzAFs-7YiUtZ)c(-XW=qj|F}(7OuBQ_i?9)e$T(QniAcc@6;46-L; z1qE%x*RHjE9v+t&6>e*0)%N$*cOkSm_hdHF&%!FJKBqq+e~Plx6})7uB?>{OuE?_p zmXx((@8^t|d=DqB-wy8P=HjbDNPjX<*&%35vfQN8HR_z~Ex5wxHpkxnY z0f_Sp+egjRr#!N7iWeDW#vdGRwnfM>y`NsAUsJRWljr&wLepb8V$)XwsN^SHJPFfO zg_YKSZA@mnVjy7to!PfB!qlB@JFUB@3ZuY#S()v-ONDP}Yo_V{9di^aETo{_^l_8j zSNzfWccHDXdvl#nQ=cNAqjDrhEzVxWv;BeaNVT^#Zj#>&BP?wnIvS(iu{ zMyQs!i{lZ;<-H6`{hw1Q{KT;dn-)6Tnu(?*r;k+X{qHmM8*cKW`u9sI`qHOMP!Xtz zi70tG3MX|nce>W1X@csw`0DACL|Q;vESBEmz18mE$Gb5+9;55T0u^j7TQV#_&&*7B zdXQG|K8dyrH-EGGg|5N8NzHqcecvVhN&QL*D||R;H~!i#5~1D4Y8%d~jbSDzO0z{@+=BEgBqbm2oQdscckDm=1I;uPh=lC*M;Tf)3Pgp; zatNp7DHwbyiI{G@9W7fjnBHJRZ6L3`$!g_~%=G4V^Sgzm?ZbJ;IM1%FN4ZA4eVeIw z3fb&dnI3SIll1bYcoyNeS}U6Qmi?MP9;MTWGWdduFZ++7vwmy3i^K3XHduk9N6CNz z8#zKiLPt8fJESBHQUQU%2x&&Qba#pw8`2oX>gg z`w_rBIEKf&TOh6$f0oQ_5-|~rUCe;iGm98}%9(>Q)^7SE&62`1#V%s-G|G`HVd!T| zx-hDY#igQDiY0PL^4CK`2UgHxwTe1}S&?;5e!X z%MHO;WR!xbtYUDWVkoQd;~KBFx72(GX1R9|*cxE5Pmty;n;Uo2A_Bkr`K(kTZMn z-1XmYf1=E}X*oF!l{=Df8+v?-oJAh1>57TijmB2t6dGGqJ1BkxKaAimKtuD5#Rajm z6u}3K+;Z@KGD#!tV0P=*{?Au|H|;J+v1Vha8x0LiJOc15u!@Y3y^X#%I1giiiVjiU zbzGLfupJezrHl7>on)$2%#hd33DTt_u%A9-e+)InoaFNno3L5ZGzHXRicuihSE zMN*%dilNQjs}iNzHIn;oDMy=@SJ5j<#k`gZ;4AvHpek4JbPrG{YUS$X^VGD+RgS`D zF1Ac=lDa=+(Zv!DIL1>wO^XEGm9ll4zuUE6vWMw+Q)7jJr@=FEenvTm4v0abLD8Za zMv(L&@`cG2>7Qv9;@eoq&I8BfijQorz~VPoqm0EC%XZ-)Gu}&FS`$LQyfs8GOp}I& z2(8A!76#)U)~0c?p4sr27a2O=lsHa?-G|8i|AwCXW<}W7?$il!<5oxGS3lfcV_tdX z_?_TQpo~1;?|M-sb5IwqOD~x^Oq}=pU8joR18^G1g^Al)H=I2jE)-*CX@_vlSv1FZ z$Y>S}9j&na2XMP?+G$!zd0RH53yYfVx^#2&?#+oG9xPv62kENML=+kriKwrj_8_u~ zD+M8x;g>dhjy@8z+N1wxjbL}?EUDlMPRFBC@7$oUi`(;&ZU;0|m}CB0vNXfUukvjjNWbQusAzEP`yc?XH*d^yjS9-tHAK zOBWR?!o^NW*UWTi@=4>v+7Flm9>0R_gZq0ynqk*nd;(NeDU=yK{S|C!_a@oG2v~*-?Mb!Won5=HX0)v zW2(K=Q!W+YL(s3Z$gtj)7xCM-xj}mr9wUrR0VQYOi3i0=T2_JYgGdE}Q)9Ss`UMnY_eCk_M2y1uoXZ#e zV+~T^o#tyFopVqFg>{P`Pi5{*cWSODH@OO;&}fm6cleKVeuu99_cd_ay;tJ53?S#_ z0?HNtq0K-7k*-Q)->)&!`17P9s`doEFQe;KBg>*0{54h+5y6pimE@RDy(YV(t1QDf z?xB3&gb=rSRrcyIl?yL_ot4s>uiey23>6QkiFhZrjqCZ6Ecso~jAy@2@N+y*$S*P1 z`278Jh2?Q&P&&hMvT8QgPcJUr#Oj5QJ!wc+y*dX-tlrQh3l8M^nP??x30Rp;TSL)4 zp&Z)Y-GcIx=CjlFtk(pK-zaD*zVpeVgAbpL4STFG)UR*B*X1&zm2& z=#d_`h$lq@PSK(@Zr6mvx^$m(HP1VO2l|~wxQ9i=xg=9LzOpjNXTszti)P)RFw)y! z3j|a$Rm+LI{?a;j*(H4hw|f`U;4DvH2J9NcIjF1JKEQ^1350QHyfRUETkED0o6x91 z&~;@omX<9WFLl}ceo>4T+0lFFQDNrIMqJB2k@2!ORHM?>x=3q|^i<^9Fqg!!kRZd#CwT7N8|((ZeLT!Lmb+Y3$8I>VUUdUbB4Y&V0qDz{e=@Lbb(5sifS3a% zo{DVg?S>mlnNN{iWv0B63+I3>Vu^{@G1&P@VlvUr$3l<&ug2ub&(PyknZZ5`Dnvl< zF^-AcBRI(=Vt`${_~~@o^urOP(}VOGur-|(&7__AS|pL2{5vvzYhvN!3#S*YhE3x? z7w;xj^qktHor=W%q1C8!8!WtCKDsj36X75@H{XxC`{-93*ln|zQ8cqy(5kP2)eV$P zILaJzz=-`Bg}J^8gaO5$=*`5|c&fe&j(9ggmb%uN`QL#X(0Sy!Z?ZScRq`8?5K^}O zCznxCf6JqU{wRIM=*I@GUDA?}*>7L{1-ol}K(E=U4_!c+R0lGCN`x z$)WEr0F)0DDe{gtnY9G#<~eUTuYt1!VuC;-SwODpHd`wN85*AA`zzELz_^!5G|2c65B>f~U|cq|!Sue0wa28Rc{f zcK-gG7&mMlSB0b%fJ&e8>RW-9L)CWUB6k_5cx9dnuII(PX1g9Pb5CYwSH}1Av6V|N z{RC^b0mpK`>uW-0qQJ7-NaLT~7ZGCOEaW9Lpq3HDb>v-{H#U zdWlo+5DylzrBfrxex{p6*Oa41AznbsSel@1rweQUpyZ%$9Izf|+ z;SVEWV@?fRziBSR7kTMQJzq?i=IVrW|92|1X8azp#6%p0P_FZua0BG>yT|=9t@`YF(K0zJa`bI-3fZjdQ0VO>I7&E!ro50$Au+$Ng;bWL5 zLxJ*>H(PHNKJ=OXI7n~PDQXdF=IR+AC4JG)=C9z-VeI!Sf5I<*AOFf^S#+;xMhZU% zSeVKke`E36F%}?u|C^{OV7=RtLnG-@_C)~Dl^sfH934Yp4Apv;v?(yri<&JqAyhyw zJD44y9vU>87_+1mWr9spq~3!C3!w0U5N9;ms?i}k$_@}aV#0|XRiuhbRKKOl@adhh zYtl9B&fH))-$7jueF^5jr7UoY;^AcW+qB1;W~aCVv_b(I@6>(>Ye-$vve7WL3Sv$( zyu0{OU8drivwE=8-b@*+IYCqxSoR~C=1zCIXi{9Q=I)`v{}IbF=QdUs8#0r^U-dN2Xo z8Bb$S8D9MdEODk9>oq+tr%lMY`l zZab-u)p4OU<2!N<;?U(*mKu#!Asp&rqEK%F-xd3Pq9r3r0Kg?P0@vqE&NlHf%#`@# z1P#^a=>a$wA8P~4@FqjBQ4d-zQ4&E6wtwq^z^khvh`LT;jn{J;GCHAbgvUTsqbFa+hvAyzBuVc?19qW_ z*WgXK5A%QxV8&iH#gvu$Z@}elSoUFUW_HV=3fOlE*6aIl6_V#-;=sz7)05w*kO5lPw zN%*3Es>JCe*)5D6pyMH-G^K*}9;52pw6ub|Y2ymH+C`D@fw5}@94im|aT*&DN< z+HXb5VBymoNX6*}myp@n#$A3SeWw8f6qEvb1s*x905Y z)7MRBeaS}B=BKIREajYd_gzE>RnL7#H%dlFWQsy|&R}cP+B9%3kbDC8C_dQ65>+)% z0ItU-%>L3Y1)(yXNh3+Y7(-w-EF%{BN^g~0c*Z6`??cM2F`W7DqD0(cwOKWMOlCAkp^t65h@%ln`7@>$Tc>5F8U__#sRP(?#JWe) zRgkr4KdD!)5V-oeqmJ*Mv_rCAvmYUEeENqCHu(fMIvh4wKZh?|<&M#M7>4}%C9d$b zM7O|FXSvL#7GM~S1i1NYPif>5d|x)jTo$WbA_)Q3cIYj_K5INy9+^l_%~HGqH2h3$ zhp^CuvlM3Eq-n6sL_v6oPWNvnt6gx8Ba#zbnJh{CJF#Na(-4$6huz^FiYV2YKo2ZP zH1S*&lZa))<}jQm$;`1TMaMPAMvIPCc$|W6S0T^vWKK^l=zEmsnss) z9`L_lBX1{A3M4DbFF(tnufM`NIZmwxPHz=C+0UnYGLLN{j z1j?8KqhvwYz`c6%DH2$LiDT!!JF{8*s$)Z^s~M^7Et(v@jg@{pVVoAQ`3DrZ*z-Pf z}VySC-a15*5q+~Og2id>E_PWs05(dw+vUs!zC^X4Rx@y+HxE^zSStV^-kQ69_P zG5{clEOF_^`@9}R>@(u*B~6OULD_|fB)k8l?`UnDg3D$qblP`)c%zQ$^Xm&__3iBc zB>Mhls$z=2i>?TCV52MzI>E|1*njDB(oa8;^!=ITZ1(ox0b1xAt;|2%FVZFM=|5E5 z>PV@Dl)Iiy7AK!i-+6XYYD_Yv>Kv^IO(JTC;NcVTY*t0cX^5GfqA)SP$>gT@=0l-I z=Bp>^?LT~wM^VnF?Nzs30L&+x#gf~O+PiCpoE9&=7)0Wbo?fwk^mMOJwZ zbPOPCjKVKCM=k{b7@b3OEaX#0u3K^f z5QO{qVE{b_KtBUeWFR5{{tWAYigz52M-pHH1)N}DRTkYL!(c23fD`VEUJ__Afm~-* zybA{0xWpRas@jqj%rFq;)eb?A1MEXscta$hQE|v`2%0n`cs>gNA#xAb0_>@=qab%O z*d%;gTcP6{1-1zo`^3}a47o4>fKvg8Hi+Ef<DiP|yqO0M-SLF(N#g2oF9(_b@{hKf3H$pnk|lb(SZ_<^$ku z0813K4aZZ_27yNbpnd=bD&Q`8A)sRr?l=HI3;>u+Ai;nH-eH?0C|?VKq2-LHX(ol{ z0bvBBM4^%SDCpf8NCd|73DD=>Cj+D(K-3ZdH%T2rC%-#GwV4uPoOb;uzAoX0;j8&+90J^5p=r9F36WkJOD1}A(WWj z38_Qd<(%mvsQ~`*Oc{KZoNm@7?<~b7EM^c@R*|l>mo=lV&HRq<)7z}`ind>mmnf#T30T&Ih5(#^f$o$HyH>s_Dg>&LjL9!O32AU0CEVSAGN)r6`8l84bNAR&B0VZTair&UeW+Fu^K})X!4w zi&uH+fx9_SeZ!}Q=9yH}x+g`73p~oNp#&+AnIGqlbOpiwS(cJ&LmO)E7v{drbjDsP z4F4q-I9wB%sOsp3)5F&#Pu8XG*S-9tljDZlIj?&%Cz4v9+p#5RFrJsQUtbDuDA!Z2 zoU>gL%BNR$Ui3fK`T4a~?B$e}NNcp{~e=62Atk*P3 z?n{Eo1o8&ej{PdX^pS1vF6#Pt(;L0!d7q{|W~l0;$_1ZtcafN-z=##GmMy)Ohj3)u zHPaovvOsI@=!TZB@YZjA6%lVW2E|&3V8}gIfLmzm-~HDA3M)MC0e-;Sy3Y}>16&}D zZHTEhI&P?sEKQ&B^TQ}kZx-Kn&gAwb50G5pdS=X1hNvLpTO@&C3$lBkV($Ko>U;305m;9 zjJ3Ug@mGBi0GEmaauR^#K|@%}t(7%3*70>jHUY>&1inmN6?TS=sPW{bB1}wHSqMPR zvJc!*@Hxq)b;p%dK4i5CX!mdh5DB~%g*ZrMf8mVW`n&d0ZEZ(w4QsMq*SxkSx!gnm z0l%!U64p2|z*9%ihg3VQC3w|`jiuDpX*J+w)CZO;8?BPd&&Wq0bQut^y23NC!Qu=Y zlmtVVE@|z(N6&0;Ns#$G>kBx>#9U85QT zh!wL#d&#%$d~urt02^rAHn{!H(}*Ya7V_$q9ni%!i`A7WNg#0sZX0RTi-I`4TJK5S z3UGSQa~p^zo4|e2J_dbQdJ(ZSMuY_#t(iq`9XoC!opu78Ki)Ee37c%oepxw zW?tD7T8F1c?AqNz7R^BKwY-1BxRlC>tUX$rzO}8my59ZwBd^o8DitntWesoz7<2I; z{ndukl>>_}AiY zG`iRUnBK#k49Vr*bx@4c(I=<(oX%f%BEFp5{$l>>(;m}$PxFWF4;$>p2imt+Z+zLO zn_cQpCBu^lV8j>D8Q+n~2X2AO;FpKr0INV^8?=FXc$0?E9QY*vW#?G(tJ%Y?>4??H z+nXB?KYY2khHhI?dJZ&x{i*ioq`@$|t_`ZuwqA5`r4(}_Cw(-C`7HbJi`>JLK}V4B z5wv>sz1Pv6rSz8*wOxzI&s|I(@4sHxzVlQ6`Y|~ma#Q;%sFiwn>mfX8{W}kB7m&97 z%z4*6{cRf!;YD2InfZn``M%u0H}VDK?hH$s+2bdl?izmSz6IRA4QyOnVRHtGtbGB{ zXunF<_6}&L>XAS~8)6WEbolT1Uiwzde|t*&8=24F{yBsT5qDChx0lrRjM6uN55FnC zS|?jcAFqEo&TVg#G~V=S1TJ*Ydo*k9{|qJZvVL&vGj}p<0c&H z-2QL>;?6q%O5d|TAIPWNOei!M{uHA=6pMh#m<;&241r;6A}9l>zv~d?f;4J7VOEGf zhK|vxjew#{xjse}c3Ya;(a)E;@v6%9&Bv^+JMv^JysZ0JB;(S|k0E+SZiC4kC6n@r zL>l_|HUWQBKGw$|e8$JyvA&+lD4;h`_tSZ(H$u?|mybRgd>V4~+{}C7#B-)xJ6*(a z`PBPuy=AM%hvo0Si|sdF*Ep(h**P~UJ14yFQH<}2WiY>q3<$YCk;7vZiJp@oy@=;b zcYn&-{*69vAsNv{nA;fLTA1+D@qM2+AjHf@F7}QnXGZfro=BDI@U7f}X8z-!nkxq| z^jr>2<&au8WO;0Z<}N0ByRY%_7>YMh2&T8647RqggI#4axA52Iun+pCjdsiS*Wvc< zl6l_cz_oF;kEL-}rvFbs-B2Q?W8lR;i`?zD2W9t7+8$tN1gO9$3Sp{C!3^P~7@5hM z2^vYXN^t)1ZTS-e`8O7Uh6?Y4P7IZ{va@hqZzPNHL}oevdNf1rr{JlP@cTkAVOY(ZTdecz5t3j1)pVkvvdBg z{p}~;f7tsC=den;hhL7fV)S^)8iS-~$*@t=J@#LnmU2%K5S9shClz0l+@`Dpp#)u4 zOGLbBb+}-UOwA^;|8z+Z$_;T%67TuP;`%lOUe%+8o}eG2vG(hD|%SP&NI3hsqI~5 zvoer&pYM2FjeW{HyLOKh+11FKeJ{4LCC+Tl$|}EZ^={?fzuot_N5x?Ulvuc4SR&Oc zJ#stkhjr6WzAqGVZS1cZ_fc{Wb+rc3-6GX5MXK0%BKIyl@RiEXKY=s$a`b5HkUD53 zQhpp$-l*>JR2mq=RxF*LD)*MK%cl9;qptkNtI8w}-ieB@MlbGFvN*IW1br;JM+@Dp z%v;?(PVt{We{MIXzn{~qD3b4}lV~S!kSo5nN6SzglKKJn{@z{wr7WDRtlw1bAz#(X zP>7>FtIYLl7n#2qKqXC_B14E^5tC?yJ0_*!MSss<3TK~*wwS6q?3%d@%F`s!>`J*xi5RD+2P=pSB9fOx#J8>^c7SuhQ6nF&Y4SKapQvKA! z&h_uoca^+|eIXb)4b_c`(Lks_0R5HKU}I{B8v6;d_nm3WBrU38HB2*--Q9)w&PlJ! zh0!XL$qA?!QOYeb0Wnt66SmCg`EQ3pG$CG==7pWck*0Q23VA5cRRjQBXGCZ|I1$t# zXbB`@ra)hnQ}`G_b%^XJuna)spZYuD-*Y@`%~{+q=G?$b$Gq@O)yKO1(`1x8)($tt zdK5y(`OI%F_M6$-pw2{bQh2Ad;C7+YYB%morcvcb5}SuZ@1u0nkMR$N2U@Tpz zd7FRU3yxbFl4C_I$`LobG~aZ}SecAn{{4%`fBeB1B^VlV1Nlbh(RiLYeS%7|MnP5D z8*Bt9T?1WicHSe`eSpG6@{8I2vU?;o^0fTcy8tiah+pPq^puzSb+V@WN0vguSz%XpMVb9zjPR6sv^a&CFo%`tkJf5vm0LV0> zWlLbSuj3)y;;*}gF5v({y6R!t82RmL)|9p8c&>EYXoEgQ#;B&yO3%IBKLBl*b}ivS zMuRJ?>1mjldi*+E_VP(frSL6p!~1r7!i*PelNT&6opWS0iOU*7c+R6Lso6DC(jR#e z;)xf6E1_Z<&BkX%(+ny5P>d6~Q7 z>W>a*qGaC)t%T)ZIvbdlHoIk!^RETd+$yU>G)-cKMRdb|Ar{7zuB-@($~p50{-`N( z1dG}XB0SoP=0GXdPl30LrfALNsC)As)j>jy&H9t_{(%@ z_4g=mb!2Ib?ZP*&+XWvb^<1)fq4Lo`J;I?h_1gnXOaGPwjzQJP$I}XyRR8jfWj<*1 zMmGKMl*FNi{*+ZcNz4Ji=4^#cClyqVBuVGUErEDXPG9(X1Qvbxb3hD&%D|mV2-3>#OSvTH=PBHq~#Y(RKuO}imX>5-*FLy`_l`HyPpuT9cC{_ zry$A$@auJ4uPQ}?>kT9J%SdzV#)PfOmCuhRk5gm2R}QIpnw*SZIm@yds4?Km-t7(< z1N7}_Ex}V}Z!QJp=K(S_?RG1m)d>6i8*PbtGY@%Vx9aW8gmazh%o%pW1b*G#{gDq7ekPB7HTGzIYK1vtPv0oF>*d!M& zJ?i)?WK?b?a4YVU!zYzbmoHgo9$I!`dIUm*oYfXa4@}}^+p;g;5xJ=mJ1}{pdIi@T zCzNlXzNeBm`*nlz(ken!zyCn{LGMw-E;@6|9$F|pzccZO z_T^|#IoUMGRA-d0IwzNw{T9pq54x=*Pg@fiYJ10T%RT8j*(Esvhpyt&Nl>7i%jNy&eI9_&3}&*wc^4bb_xKxebm?Aak9)S)Vstr~{O8m4|89Z$*KWmA1GdBr_ml5FzQPjFB3M}+Jc;Y8 zOZ%400o%Bg8Pgxu*p;+fvbC4?-#FKB7XD8(AABH&g}M8$xH_w=!FYcYpsBE+Hv$=tm`^d{j z5LsPyu_g`ir$Z-;Qr6H|e$&jL^R(-M3UbQTEps{T*i>S!Lz}gy zwH;Tqoebc3IK4Fn%vuJOILSB8d`K1jP0nR zUX$4ShKmO6b~N*L7@BT|Jo(hg;99W5i(o8g*AYY?K#3bD>36Ab_T_!4Hzrj6NJx%@ zn9ar|m$I3kGPqQ|QpA6OD@`bzC5(lmv61Wd<$+iUq+KD(FdCYO241eas_A|${SS${ za`lTYM0PPlO;;y9c@&E;&MAuWI~6f#=9pr3tm$!IR zL-Wt&Y(+bK;SzSDOffFwQF8;z=2$WIT#QLx<_0YHza!0b-&{UwtTUl4rb2I6)nEkM z%^*upGe%P;{mHrrE_upQ2?DA?=9Oqga@oXifHI1e3)>M@{fsS?MZW5Dz3L}H0u~{hfO)?8A){c;oW?-=P$8cRsG5{8Di-}?BHSD)&xy@Vc5>4$d zpZ?j`@OG&=sH55wui~|owNRv^zg#z;!k-dTdVOx1{2-Y-qLTkvK;C3NegIT9pAEpE zSyz!pznYAH^NQU&jk}f*jR`I3!}R39Wxxin3j>9WRkQt?x;rzYqRYFy6SLO`6w|nw z(3$G+iOLl2wl1t3c2+F+G5@`ev<-o5h5ej398iAoC9C(y@0+Ha5wo5e2y0xl6*sLm zweT_dxPd=`wcu8Ra z=vwA+4PlELCy8=-j0J+5;Og2NiA?|&B?{T0#qk%9+M)UsrqRuS35Eu0_{GVnnHwEi z7$5Sk;P|3vboaN#a>Af#Z!JN&4$y%DmMC?h|MXet zs`2+ag$KEi2x=cFk#vZhe5N@H!^N%svG6Xj@|ka$^^cQDkd$2^B>D_S(ZbXV$tj%I zG^x*4B#u?nzS%1V9A0{Wkw!m!6}Wi(N{4&L%t#%}r=ap!esJTzV8e z0Aa1SiZ!%}%R#S%#Hpd07GretGtH$7we?|>{5w$XJ<-t4(sFRw4m^V;uAb$|wfB!Z zGEEAOD{+L4HKdq5TWPYj;HT<00&Oh2dWg+gbZ5iY8<WQBN0cji)}gb zm!b9jfWQ&$@)G;LW_#N2hZVP?5i%`{6!i&lWCN^h74f{xE2%# zJb8u)8XXrTRs6o9=8_5cOt>LuGDUYffcOqX_T*^4Aq6AY$q1wDxdVSuSZA4X%(kE84!76 z3qaJM^FdmRV0&DAt{0e`Y$7&2ZkrgPX$p}1ec$oa@cMVlbOyILB_*PXa=Gp3zu~e| zuo`g-rMXh{c4$IuVjQs@SK>P&SM06chhyOgV`nNgD!2ND)_rQ2LXIxus(Rv)cMA|P))y>I@n6H^b_6NgP|sDPEx^{DUc|4a=9u8*8IV;&CNY9WPr>a0h$q2&DK?kRzqp z=2eCA%VXB`I#ckTbSivvs23HzzE!+9=_ISH($fs)iavI9)LFgZ^kt`d5pCv0_ofNi z1|tFxu6DLUz_(BITug)|Iii(|o2qqn{~FsJ@;~3QKBSSuyWFv3x1RuPUcm%O%LnL| zRZ6l-7Jz?1weZXox+yy4Lxv28o$RDw z8WNyN{y-kfuh6#jeX}T=zc&s2Eu7Y#?DP46t0Fb&@ zEZJl{&aDi_Nz}cQ+52BeNz-ccB7M^HOqp=shUQVxr%8VIG(N@T{6EAWqu$w`Pbi zse&xT>>mQnX^8i#s?$KCD=s>6(vRwov_0=Z+-?!#OzMpnErN*D-DU?D;A{N&v^#LpFaIyJJt?}l4J^Tx7+gO3C8p%4(7+Z4*RRvD zot`P$h_ObQYupL8zVNEc8B(sPry|StNS6Qk-^RLz_QZMhq4~DK+v^M2QKa!i^nhho z=Nu97o~JOuR65BPu<+tx@+ciSF@h!m9HwPkuid?UVd6jrk_Fy%U)^UkEU2Xj$)#~` zCO6Z*mLb67Cj#O{H>JEt!Jv=~_4^y`L(q}z|@&)1_eRu^v`-a>)2FvZ#KozM` z9A|FCl!g{w8!Sc8%kJh+>&W~xZ(;<1w4iZLn0OuDc>6`Lx(#>C*p~2{ydQn0FZC=X z3%m-6^osW?h2L~O;N)e>j=~d@(2KYY7Z#ZR&=dt2BRO4o{eI7#D*-@yhjAe2Zcl1; zAyp5FX^YKjO>{^AkxLC;(~@~)izJFHUv>1iCK_U%EhLLgt9}hKPH=q$v%!Fi^Fav@ zTf^W*UAOsJyyDJp-k-S;@u)G&lrRylnO0@DI!#ZpUx&GrfucXB_j$;E$15^kmaxB- zfE$MiETXO#K%M%x3zAE0>tMD60KtJo?T~^`v}5}h2~0=e8;8sh`>nK?z-w+%;6x&l zJ3#c#Fed~HW$8V62!)vS7Z|;D0EqLa+Ls*nBrb_qZ7{9|*8JTQ0m5<a&t>L;9S;;32aOdIS&c0yl*;)i&=ZIh&$nNCt5$+rG%5=(K|h?p`aZM2%w>JBl}*ti_I=NYOm;Gd9YLvFAPy1t zUht+$t{^>vj$a{soDe^5E6nS*>wBC_>_f2YQ%OgSaf2z0iYc4=Li2fPx45`%UNt_C zRn0~Tlv{Vaf{EV@p*EEjj*y7F#U)MjPuZl2ZJ*g&miBSFNaQVrt}RN?gl2Kk&!BgR zk7~=@(gN=$+$tHww5Z;x(F;o3*fQ5YzJ8Wt72VF2v{86#8~7)fC+s;;JnUoU^ShVYQ1x60)-ic6p4C zf4aI!wV-3j9tzQ$Imt?e!lkaNUv_6QuvJ=dwr&N%)cZ<0p?FR1vt3?wrRAXvNddyP zD;5WoLFGxfeiXG;4tO*}Z|Gz~5#=rqt!;e{;%RCdX0dN-e<4_OP+|?#ghFO_a3Aa| z1o6Pi&x|4|M#SyK&HR6+2%4qmnwlq6Z)8L`|1Nnc^vPyMxxzgRY;+oDV$En8J%_1a zg7TNqXt;L{$w$kL9SlOnZ9@pTmA2svn!GZx*5#(^Q30Yqk^3IVi#Y9BAIhG{gYs3nLHQy?Bb7y3_rZt!(i(V(R5T&Zv zhP6_xEM_{PhHSgtska`eXKl^Tb9m%wuz@l{OY(1f)f=S++HP8cN2GX~Uv_^gjk(yj zTbbq5xA#KO4f*dAwDzhl{r^b0cR$B>lXZ=AdA)B1EtjtdPHK}AqhE-A7(!Lj(|a`M z+zQ3-MmYg5?k+K>c4z25ow;O_6tC}THyx_Jy-4I5>7Ic-=Y4a&_qlWJ+3&Bz{LlZK zOl2z*TAej2&rTlyDs~SZzCjQ$xo#K_BzhZS2#I^sE2kCt(O#diaRV87IO@RY2eNP2 z>y4zHIZg4Xf@%v<7lUjj#V+3Y>KO5g1V{>%`PU#JUba|((bsF3XKo_06{F3)uhSgD z&UEFWfVewyqrVPSXOAt;v$V@iC z_1G>UB-S;dYqTqL{O?P^Y7CRvnS8e~c zgzmhF`dNX+j9@^*S_z1+>&H~KV`NxT*efoZZ}K2+*@8(25xJth>3>_NMDVkaINV1Q z(3rN4+nU}(O(TkwFHB2~#b#cYqB9CM)5=9~y}MtWm0P$dNN?g^y!48zIZk!ry6JQk zxZe{SVfQ($T?o--7nNuYh*6($z-jXA&pgnOuNawNB}BF-5iu_Jmt&#lg(v;-CS%xy zeD@O(T3NJ9@it48EF+n2_)Wi%X@-R6_yn8CJ=C-6Yr448>F8&4L)5~m8>?Z^7Ve>H z-P=J{9Blx|0S0~@+ojG@B4*j>GvDZXsZrvaogm#TXuqEMitG6W+v6LVQ?d1FSwfz= zew=bYqaeDoMGsxq6S7EMq{`Y1L=p$fbib@S9arz3@+Be`8ALV<-=-_yF~G?uIsj2) zs##XzzDrZC3Y~?`}(8948*qz4X~t@yYTBse2dh z(%7%Jfl!JG#pEZdUecx2=7G2Uhd27xbRC9DyHn{+Q&kT9sPL?*OZz!snOX_SLzxh!A&|i0P z)0}VAAY3;!8A8P*P3V0ewp*3WdvdTN{b@w0395zeeV{NjkW;etr1%?nhm^4L2pfm; zx@%U|Vh_jZa)yW+D{QC>PAQZmW(;hA#7mD1zNmauPGlK+E4hY$=jbk@jyZ#-&?I6m zzbRamC)cXdD;k@s;gv-FpNy?@-Ik%*OR|khowQFh{Zyox&sl1Pw&XO5OhACy+#9Y1- zkSW1g6)c5ypmLC;^fi#fBS`;1O_C$%+GsSA{93e4Xyl;C7m-W3;eeTh5dK zU1|L8MX^nJ{P^1o?C9=8*E2+J+G>i|ZA_eac!p@B=9S~jQq>*B?MpsAK)ZK;_*`FD zP$ktA0wg_|A?VSBtS$p-mPF2ewdG^hDzX+@-j%5g8OO3c$==c#;aZc;*-E+y2FWNU zLd$Rpt@?d2SG~?;#J~Req(sEoBUMb05D?(41Ye8mh2UULTX?MXgyqXQo?FxP^R;^K}Z!JEkkQ6 z+-#YVUK;zpwCQ1_7b~LP{=duI0%ft)Gs}!=kQx8$>Q#d|m)5{y8!WOetU7D=`avv5 zDT~IG+TT2MAXA4>O#Y?7}0VPW>MLo#sykU0`HpRt0D*8u114uEERKk#+G zsT4p1{w@%qKs^Fz7Q40+TMn)xR{y1FT;326bQKhH?TO$NZZl~DyxJtuYpqZA5!1R+ zBOh|Ka1LWaYBLkPscGR($%~e{;7w->Ci;O7q%y>R^Z$za5Hx)OdKL0F>*8A#-}u&O z`Nh$xkQ234L692(zC{SIe)tDOJ?FoutYz9fj*T?_Tx~`+P%l+t5DkW`hsQy>OZ&73 z0?O7%BLWUjOCyM<8U!Mr%&)Dh zAa|lN>)Rk6F5dX^P;&YJ^!?J=d#@6DTwAOJ8wFa$IvIXVJZDUz=0$)rQ9g4-NweWt@HK*yokTshdC{AWXyk$z?#`O{%Q$X)9yeB0>Q-S}74ALkD^uPw+5 z+~%d-`AkOLis|h3dp&f_zZmrRjQ!&sTcwGVYiY5i-)MPXQ^~oKnObblWBq@0H4KCS z8_+axLV+YoQzAo`I%PF^~sMn=R9sXmB?pA!!IRf?#|LyvaE^vbKML2;~J%;C45bR3RC>$BrP1t zcza+0+*Co@c2vkUe)-3&UwCQRQ7>OYM3)WZpp**}zL;5m4Uew4)$l2-!}ESv!n>3q z`0TYMG(YAFhl_KP!I|y3S8W)H<)+LMiOu+wcJnp4-vlt(@0<*whkWBsb58m!!FXpZ z7Ywk})uJS`-%!A>2#iBrlg=&5!$t%TQqStM90cg;R~&S!-mIfG{_EPdA&zMx2OmW4_XPMp3TW`(9UuZq zPV;NSD^T8h?~>s>&w}vR%D8vHb~>Oj@XEs?ZSd89m~l8uIwiImn;sT4Ct5-t?9@nt#FPaOf=nX!mzX6X$10S$N%(Pq+3#%J`_T?<|&iP&L&J@6UF|{C~rKyau96&`!Cf8LRlIk|5 zvOSn1VQH#gNf~gjEE^|UG;tW`&k}LUa$_m9LG5Y^P7=oX->>IwayISR#kBT%5&3t2jyLPXc#X^IiTPE@qn<+Oi?RQiP;O~Fz%LGF8YWa?N7)dILGqRluUa4|`ne#RMzsX?(hFci4N0c;;Wc{3UE zDsm(=ZFqp*9e(U=1XqWLX_vMz>;8fM?nD}WUJeV3-=b%FJDNi|LTNm9aLEcDdgw)| z{=?-)i0ief&=#=Z#Q!TFt-*9ET@uLz5+?*K+ykai3yoI1h#o_{`bqo& zC2}p1UO;F~nv89j)UJmyP*btf&0+NXh|w|-3*>#U5(Vxt>GPWpy@1 z)Tm@&!z66Xpy-Kp<~t(aWrQl2@wYSPn3Honlbr`bh8y7 z@%Em&Ka(&1+=|TWU953{Yh(q-yF#^i&LDJiJ$9lRe~B7AQeQs;t*^YEZJ$kau2{&? zvEuKA(_00T|IH18<32^XZ9s~+61@poe>x}wfDoKIzzgg)RE2R!++bQQ5vlsOD4bh zY3-9ng5CVpg8`Olg>Dx4bzkycP@k^<2L5`p8fP%tDUq7WMQ$)C++cWnzuntGMD3dm z_^or2lcveU>Cym#qV+`8BmY9C^hqWz|qUi__XP0>w(KG!H!E=(zZDEYhk&9nUp zDQVT698I+=EiQoSVK=0zt_100?)hF#tc3ouDOjPaCGy_11>utP9{=tK> z<@yo=ujkGNp$K|@&eQ;un*g<5p^>4`cC~r6Ub%&PSGMqatKHfaX+0UARRlxz%+n;* zL1>qGrG+5}llWGPE5(@dFUHSny$=vPPZcd|=F7z_{z_V)*^Kk3n2>CaFSXo8BQpju zKLeIKo%8mVeYxvnSvwWj3)N&lnY=dx={IA-)X#=IYt$>rjoCu0RT0#AKYUa}SGuCU z@4d8D@pc;jR4DeaTk5Cz9!Ktitk6{oD2lnw4D<1*b=rj^FTEbhh(}Ag5r1mZb%ZcX zH=Khx3~DrG)-_^Y4(DKf^!UnbY+Mnf=9A`H*6ZetEe}6o==}F`XZhFo?_QoR+Exe@8F`sMMqaa{n>PD zRz2e@m+P(6aO!WvyP4$#u?lh-aj;cz#4cyq!u}!C8!PvxId5$4R5GzSIj{|g4zcPB zFC6Ai;wXe<=tfIjJ)C3UO3uN|3xC?oCg)xdpfpy#<%hFiD*V~*E!i4Yd%u>RTw(KG zm21)&qfVcGrK|L8wFWiqzhq(*WU=c!e)H(>UzST6{gwPJBDIQ@n&iWQiu%wsM&{YL zXTvNMbP4%t>1xPCFr4MgEyZrYZPS0EtN!hETkNa1pEX+YpXh1*)Z5FL*p(a!YBGH# zbZ-HHF+P3yN`>=s_Q^bQw7BNYSF*+Ah*D!ctgbA6a#-8Y$9`1bFr4yII?#Yd=wxOA z^Del12xy^CFi7g}&efP{B2%4lwAuA%YUnFg?c5dH@bev=veV{zOS7*(qAwv7u_EbH z*MGKvldLwd2wmttH%;ptljPR9-JtxB^K4G@>eI6Y!*~V!i#5CLZSeSnX`OO2#YgJe zT8!nFAK7&GSmiNy-k3FZ98ky#4eK;mfZ<}A^|H+bVWw7{4>nyV9fEIjudm$i`O?J6 zw?EbF^D|AaUr`Xlv;6#)$ zlR&Kb^=|830{$aspPZ+7rO)F?l9|e%ifTc|^ukAxd4+d+XM}|g)1JXydDV5HVvLIO z;~1V-<;GjkMt__A150%d@;h|A{L(hfg9{vXoKGExY9VgYYs zy>NqRiD3*lMr4w_Hsj84Nsd58V!GLfZ)uT{RppzdHTXonB0_Jtx*~1E(XC(3n&L|< z>Wc5^9zR(6aOLOfSl*v>lwl7EmLT1BxAcy2=h4h&F1=H+4CXu5>d|!U~mtJ#M;Gh<4#^jN(Wfo`7 zjjyY*k=7b)&Re4-x*0N+j^`RFf`njJHX(scb(Y0{uHC|u8A?D*UNOgGNyEI~6&N|3 z?vL*j6>^QJT$$w9Ykkp*@In)Qt8PAUsu)>W{&G3{R-%t2Va3Lls6AzNjOYzVj7kvn zA@eDp?3-hwn5{-xDV9GOJys zs+qe5Q?(v2C;0BOD0dWhDzQsH9c59 za`=gVGG^CFMBH^N;rNiqKhb>PuaEUh6&gF)In4Khr`?Kz0Y>bev zxw%8Nl_oO2`c8W?FGx^y=xxpq;lDCRYYpn~*VE{@8GE%&^c94|IYqXUtb|@?^C3z< zvn{;ET4`*_(NehPm)eKgI{tpg(*JY$o*$Av#WYw}cPeE?lKWiDoPMHOXu)t?A;O_8 z76|ckrP<>DRgO)XZP_=Z3G=aFW_m;y0I9;7zFRa9!PXe2IU`XHbR~cLSVtvtPgA_{ z$Cq*VXeLiD(7Z!#{tEv>!(5D!x<1py%RsnXRNx5$57|Woz7l7;JM*KjaGbgCn6%zy z=vMZPxmqDBm2B_u^;OU1Yg%a;^|tu_WNmYg<^3vCIXs5Ly!qV?y_Hz}6B9GI2ur(0 zQ{j?O=F5(6?rm-8ERim;a*gVd#+d7PGyd;a7>6iT=)rQ0ECm1J`OMeLJAvRXjTeQw z_C99M*q8qlQQxuRM&4Xl>fMug3V1f#$J?G`%WAH?Bh5f^Wy5DnseXyda+6hC2cb6?+cC5J$ z{h>^&Pi&IO&8hhe0o|u*gVreeO=IB>8Le-Go96+Ph5E<-D_Z#A89e7<~tJnFnS6H>YvjEwDcxn z@;W!ooe+DtFXB=E{>-u_`7fc+h%947o-sgo*-}dfaiQPb-KxMZ5zV_^J4dFtlZbYs zv2GY1auJOkudj$#qWIjQC%nNPo7&y>Il1kFrh?wnLyEwI=!A0vry7?ejx&u%uw>A2%+vYKATDckj|NyAq8P=w(Yafu9o0MIN4|{*#X zu{Y>CRJ(Ug&Etb1AB+P;QjF}T%Y;}bAUB>@WG5^0r%gS91$*^j!ktjk-rBdFX*GF%O z->$mMla!AUp?Ce$o~24~ zff|JxrhxZLLGwLLz3Yai<7PmE<(EC>yX6oF5rbgVay8fT%vn=}*4M@;e7+k__Yv=Z=NHOX=Y+21$;2S>SVjPVT5aF(UefPp zG#HYSI*w;l!6o^_QX{KOvd!F4BX$ZITPlIFtb8F#r`P2S!jklxL&%E*;OdS1g@_mr zyck0Ujjsa@U%3N8A7pI6v21dc$<&%?pp6le8u!Rm_s-VWo>Vs-Y-|>YS8}V$#gpjx zTBI`2Q#Ebl!<^H`pbs6J(d`un*iT?s$C)M%lV#9t%g}aij}I&s&SQ;}@BM?kURK`G znvnfx5Q+XGByU$bz&&<6c zDJ7p%$AweBNx0-7i*3gETx)(*lz3n8x#F33e=&z~Y5vmTns$i!Cn0$5D|`*ZOVt-o^+>KOyCmE1cU%uw zZ|+=Y3A$nVRV0R~xTG{&4^JRolN^+R+1?7j;(PO*?_h2FnLnkRUA$YakTHv;aVpHE zI-A8_+CQgaJ_Sr)F&rpu85W-xW|Au7po&sD6(KWwxd@T3FnRSTHSQe#XaRUAFw+x% zrky?JhEgW|ILiH0HE!{EejXO#dMzMy;e;W+3fowD`2N4w>COT(82nZ0k4i8dm+9&! za#TB!ALOgf7(eTFR2;~&e&Cb%90JZgE^9CF@YgkIR!4RCIqAurdJ2L;Z|^calFg4+ zTz&cLi0MG~=9&5}>{hnUM{A8&lAXsqLzYoOi@cS{Zr=SKY^YYI*A;iYyUSt}!v;5V z24PpD!R*?dnCD=rEkV2hj`2<2L*>=PXRJy85HS=Wga-zSbAkvFo-lsg>1lTt&vF@k zSxDr=;~=Xt40=&jvwMPi8H}RzmYO3gQPz8Rz6HlPl65eVGD-jCKmOhEjIoN{@iomJ zA$^TN)eL0ZBfuEhpvGGidbm60Zk{_PlEq^jr!lCOYaG{;((oJ;bM+%&u27ALd50tQ ztzRM%UCcsWqB(IFv1#!+(hW==@q&={0S1eUT{32%5a$L=3w(5Z`UF03zoVUb)K_Z3H7KPRpg)t85%Sxgl0^Ftbjga&*c4E@X~H!g{}*<|QMraXUtmq683LIq!=G40C#OgK3tRDPsk z!$)Dx3#xqAtJFQ&{~A3nMI)&L_5qs`iUAtzgTl9XbuSgz%@jjpBN~m@WfgsX!_#8A zoSsguNEglv-_I3-dQLQl81x^)IgJ9^=PQG_bII%zbZNTDy(bMD>kU*e5S>Zmy;k_W zK+wN5raw-wN7T`NR!>TPBykI<41lbog1c}axD&u$B2|wA!JL3vjD_*WN8BJt zvy{(b0Ob0mA^JCOk$7YDSA^{yY6Sv0JE{Xuyml{NKpFj}-N@~}#FR)_sK!Lcy+5gA z2KvQbVYKNPFYZ6-`SgqbCW91h1#tNgBJg`%gx)(GY8p|!Oisbhq?=+_*}sQ0bZ-uPE2M zC{57@0n$mO-{dR5h|}9I*st3V{=vX>p3$Ru0c_D=>Bz2ssDLp??iV0h?l&9&p18fY z#R2U8###-4=m`K40A0bga}7R!tH{Q`Io8BEWxdTJGRO)%9;40}ze?-_k^0m4`X3Pj_Rc&kU%7oH5f!+H1J!AA8WU-QHoHzYfQe@QP1NSKz$$2 zvkBIel=JHTaSVSqe!8?`IKJ3`JtQFqIeAl@ zsoroJ5KEEZZPgi0;K~-3$PLoz?X$M$h7)>qow*qaE5A1Y5iB~%9zX$aSX`#3A}!o{ zX>e-eAA6)AgkJB57GO>QX2)&UyCzshqAltz-<+L&JL)y`$`&tMm-n-$1N_-&^x)vE zz~H}OP5Dp>2F@VfcbAk;aFh#eS&$l+RMOKG!>7Fum9c(rXVi)P_qYsDgx-dyswtck z*Dl2b%Ka1=fcz^0V7$DZ!>q=?-CFy-YSz08DgnZ5xr=)((44@aJA4RkCPY*0zWQf~L;8Oec>4^9Pg@d!VW}hAyX>HY7B!uTn#EO=Y zn6cfdKk~~EI?j$#ax%4~<5`vdt6RsfRmRr}C$AD$*KBz;t^h`T`b6&jpgvWR0 zRe5l{fh1MywBsAQ(W}he-1|k8*b60Wf`HxR;&XlQj0X1uUpGmPXcaQ$4m$SJvtVsp zPlZ1QF9+kG**6rVz#}j1Sw+-$XyKU~labGeIE1?(vPM`M*Q1$TIl}p%+ z)9I~2zwus2?0HeIwF)=5^urJGigxkot@k{4uK;cTFksaWxBp>Ou3|C~oI1@V1JQ5> zA-nPB(xG@LEdYp*ZGpj%N6Ph*Ei}WAG3rP^ag*%vtO+}3H$rQreq232zxcS*PV{32 z%AQC8IzrvkyntjBEB;X3Z9L_t4O2A)M$N)&M-o3Dv}$FTcCku!9$H7Z%x1br$P8_E zdQ8QoDn_YUBm6dC{B}Y0GG<7AVQ{eifx;;bc-@Wh0~&9{C=50H)3ZI-C^QYt z#k&=BR_Az(&VDrW0|sxn`SZsQYlI87?G-4+UzGUl(gw+Bil5&8_50%c(fir{{(t`f zm;lDq3iLfmK(+_E>f~yjo(G|VX|dTdyc=P4U~tRNvk8ZWl-fqC%CXwIq_XDQ6C0MD z+=2~D1~@A49hq#B6f_^L)yhCYh?IcF0^5V{7(Oy#B$a{uTjDMqTn~)`%lC6CfF=& z8Uo{q{1ypO(e&^nP?CGQ`x{u?r<~HbM7mr7*AzYcvQE3^SQ?XeutZaH@5K0K4GD*LqA3 z0ssF#YB(e1s`3mAIz5Wk!OMH5bAz9bJ9cw@zjPi{)rqN(UwlLI3j`nLC9z)IXLiDx zl5+8|5X~x<>KJc$ZCp$ZytbM#+y`sVt%n0aoeKE8Y*M-DKBOFlz>ew^JdOkOhhPsF z?*fc#>7kSf6}-&`^uOt|P1)OuL6$P)-z_F{=i#k)Tr&S#5tnF>i~)@9l&!0vI@qea2wpS4l(SIhH;}5cC0y!ZNS5@ z717f;*0UC5ZLP=gp{jftvjNv_2)(e*XhQ1<^S~E31B^v*l&Ho4#8i_@K~^ekTQO;P za;J=Q1}$iBH6NzmKOOL358NUd&x92|yZD%8I~=4|A8Z2sK%LP#^6}|=A4&Co8$8=W z({n1fqNxe4h`H+w2;-n!B(%JX=}Ky!oZ!Q28Vbj6ueweDSks3-VEGuk#BhXskoQ*g zjU}D!1=Yi174`mAI*#8cd)vQ1;>gj60}X9-$u59Pn{w5b#zp}Q|y(V zh30tW6iKG)6-uw>7*VfM3f~*^P|h~iSAXg_YPGA((M|UuDhdJ{UxUAU#4iP#b ztxKJ>*EwS(XtGFDE)dk~u;Y8MiTSiH3@~f_6;mdF0|nkr$JP5`L0$xP{L7LtD2*Ex zsJR>{+D%tlrvoTUoHUS_O8KSv8#cso3b9XYAJ}-&;lY^_aZnv~nqg3QWC;i<&fw-h zoYqUHBd&9)n+ZgfnbAs#~0s zoF!Txn5e;XO-Jh$ui%G4iD%QmJ8iV96d`MDz+UWgHNeVWj@(Wu7Nl#{d&1_H1C@h= z&%!#KcrnH8DO{>oi~$O%8Du!>nmE-HbPV%WUidD*>Q;?TAPs~qd?_<@&pKV@Pk_P~ z5x5XliLvrseGKD|6hI_gFBpu;g;;-_1f!?7<+CegrN?#f(vtBS9;TRn@jVS1@#&SY zu^Ui~v*eN+T8)`dZVw!QL)_YkRtsq$LXGMnVFp0m!zc^VT7J$ar1O8MEk+QoQPQKb z*ee>cmBz_JeBnb~>pvR9UJE}>$r!>N;8cG-N$ERtC$c-0QX!Akx%LRLO|d0nel<%_ z_IB3hVZ32dRzXU&Ot*Mk;v|LL0hpu1pMpurz~z~#ErjVuAOa_OJZHBlGt4>}S#ci$=KF|T zzCmj+`VI0VMM3Xg$IJF;+?$^|xiD~v5ML=1{t1U65fa@S!pN`IdQ_mWIaz=h7}kLM z)9!m|0bv@daQJA|KL3-1=Ti<4o?X*nt@;#&~4lA)o5(h|~Dh zF6F*TT)5w)bB2rZWb3`OE4t?KtV2V16zO-q4f+flhCx2sHK1u=>mi1{4>EQkKyBQsGg(igZmwQNBIt^`u% z6nlO1Vl;8fOAdq~F+bu)nr5=-1(P+gmO^M#R!^W^aa?#7Rat?AWT&IVvf*SWs3kD; z_|;R4p%coohaS*-*nD@tj)1GU>;BV^?Lm1r5@5wU(e%TI^Mlng zA!pq8}C6N4Xz-HJe(465av4_YA%_{@1H}K?W$pv`;u62PoWE z2uIxFMR%e|;7OL0oFBgfl(}tw2MbSC=lbom-ij-r#wPjm<1y$rQ|_(7F6nNF5@e%4 z6#H<6o6OnbpnoXkZY`9p7rgNwl2*#RH}9I_9M8s3u~9hIOa+<|~Z*jcB8vZvcq6{3u2nrpmXA&q3i{ief{TktJ9C4s+|oY6qKj+QnWrxgq5Rzy0^}y3jnd+lz{RvdS zm_py*_x>E^BLF^dDP7y5>H{v9IT~dfg?Na*{yh*IO2>L$#_T=MqOz+Vrple<%>39H zWZlN>MDP~T&S*SA)}?z>j7J5{U5dylIMJYNRZ!HH&48v@%MUhA9*>7^VR$W1W!0NB zEfJ6mor4QH2*jP&VG$!JOSf}P ze`GA^DIB;Xz@CtwZ5@|rs>4uB7i6XuA!L?H(V|4_A5|Ea4}#Dsc;3z%_KdZP-i<*m zdZ3SQg!FiYD|euqc-`lj>^#Wy&h(|cAX#*s9QxRm|GS(B^T%XG*Szq24!&ST3Oak} zRuDqM@6m)LwFE!@XPiS7qdhDm3Czv8lkj9R%ncu=H~qXQofkNEEh?kn+xW=gk6@S( zwA&oFh-S@Y^hDoa3F6m4>jf4e<{3c#`bXRW6d=B9IVk0-+i!29?^p0%%eg^O@a$LT zvp?2imnF@{OXB4mWgaY}f`qI?XE7lz5qUzSEh?}VB^G~>A*6;cr58u5QOFo)G6F1I zF3bo4O=oUa{VmFh6C~4GNs>&KRDm~PjuI(F>EKTxN}`aUN2yzj`N!mXTN)7|XXs<^$sZK&wXPYz&9qogwuRlWR-+}UzPmJ8CFC(6@@BZ}qnA|}ucaNzc29Nwbx z<8A$T{0k%ISa-sjWxw1s}gr_p8&MRP*k%!46TyUnWpZOgmUIw zV2W5~b-P$Q_~dwc!J&!>Mo8#dP)-mzmMcf>52GX(T9`sPZkG8(16Jp-}B z{pLVL^jHxr*~jx#{3-$Z>LpYV;I849a8cFL%Lcigg83CPYRbx(1+$t+NHKQ!qh>rl zPr}crMyz<-NFJP@2dN;+qvZqXd-V+7u`)U)r6@CrmTS|uGOHkhNDaOceCHOw^4652P z>&weGA@r+_MyomNyXwr=j6Ph=kem?jC~-z0bz!^o$ zPN*j}Uz?O=C=^rFL(31E3g0l0(m}ftgNWTvAMSOj&gUs51Re1j(gX;D-TC7cI>FCl z0VfkpYjcmm&Vd%EC%O*G_$ah_CYM!a1Xw~uLmxfm+KLnh*dujSWS=vO#9B1VaVrf9 zZWNzs0)MLvZ~rzrtj=?>MMrn1jv_n1DWZ>}3hxU_b_{UpNh)b8Jcc`0YiQjEMSI@msI))zMPVWB+y6-l@(h zckRe27j!NKU3ru!x- z$Gr&OMkd6BtQkIg>}7$~q=Kpq`bJ(cca+1(vMa=Yl$H)(C9X5IOcVtQI-(NNB=f?;{^Y@UOjE)=&npH#GL z)4SY4HGx0uA}0TNw#@+-O~>-@2=Z(}+d@jZj*xZD-a-CQz7p1}4@$k!*}JxV8-+|l zlig1Cep)qm)kjCezeBk7U3 z8)0pOuEgX<>J7vkgV`r4+AZghY$ctlQ1v*;2K%>7Z_7Jg440KUba1CNEzP2~OhpgI zbp7VblF-i)i-}KB^GY)SMvNv36+~zYfedpP^7m2e)<4`Fdze~p1)ZV37w*>~$+hT= z7a3w>wso?4+nfprzj$>%?u^=MW9A+5gz3QPZ1)gu*~9CoMguD!f2lj@xt;d8Kn3$8 z^lP`r#pc?>s`T{IBDnEoDTfa-D(QVx^sj{R_r*(}F0)8GQIa2Fkab&B{pn?l6U}*} zFd>3Xbq_Q6ccx}qWBBJu$A-qsSv?qE8V9bQ;^Jzl-r~Qy5zNasg*3a=e_rFv; zy5PDO@$P2k+Jv|WC(|=%OJDX2cTS6aeY;viYKuhjem-C<7OJ}oF>H?5nh|u*+2|Z| z825r1qj0!&IrLR3!$AdfNnOF%yIX3P($I^&(RUl|T;#D^aDe8#aw@O_+`{qiGH3AM z!$tAeUt-<=5T#Kiu(A*VO1VotG6@EmL^k>FKAyHTf8l)}vl4CM^B@Y6&(G6=>LgD8% z+jsjDXxsm0)_i_Hu>5Z=&S6Zbcl}D=*_AZTrs0E^pOwqFK8bV8PJZ9OpVgD7OK0VY zn+CJ%8`AqA62Ni|&AS*^kJC5k!U9TJ^@xGMVOS)u7isn z1`8cCpO22;q3Pn&%_*NU*q;A=+5W=F;olD$E#x+N7?8nRbbL8(_Ss7My%E29uK#TD zyj{208K{5pdEI&s_hTP#qB}F{9#-;o8^Q=b6LmijLtiu6^R0EF-6{J5mF*sUMlZkqDBvuc=ABj^+&6WBtvalLcsNZeI+k4p* zqwLZuYgYT<+sH|cY34@smWBQeql-D6XErx$0vi9Za7p(E>H~NaN`Rm+fns-)79UWJ zLx3<&Ud97B6S^!mRcq(iMJqO65Wpz1NWPOA<1cjO5IRFwT$}5`B!UkxNE+83Vhu+EuqT0^ z@jy+jKw8bw=scjq|OQN@HODu2fF=lK~$?FCQ51>WLUdLrmO6XG)sQ^=!x8|)^+mThm`PlG9 z#n-TJiQKJynYH?7G?O`N(H6;d(v>o5!pqS`i{~Yc`BPt+-rrrWTi<@7lpw_^`m3@$ zVUU8P{BuriNx`js^GgXCd*q&=3%pDaSSc6R`ytfR)pJ`rmc^sPIsR&#oJ-<0d{u`_ z@^y=RRmR`OsuV2RaCLPW`_qqFblPrn8kSZA6>0K!NdzK-Utl1OU0;RG^(o%;%Sviw z#R8W5Df@V9RU}mM+CJb>YrmNolMtu+HKKp1;8^Vq>mM^qaJl)U)y?ogRE%xfU zhybpHPd}4JbS1rq7%&9|naXhQ z-$aqotN^k0nufD%@=-$D5p!5D8#cASU^n%ypW#Zf*Nlj$5Q|-OQslWZzHuq!sZkxH zvcO?}fulE*PX+i@h|g3bgOwjr?}nrnZr=Jc(w(mpcS~N- z^eEG$;)eU@``bLuMsvh=w@7?kfb07B+pwJ6`H>mSUE9K?OcRmyL~l%JCI_8+4r|S3 zRS?JNa$`PLQ1BNuU?>ImhU^!7e7$edrORpMRhDxUbE4pylGty$T*)x0t&HrT7N;>4 zvuxgteFw(9PdgwNT8<=fck0`-P-AO4Bq}@!H(ZRmTsxylbrJHay!cRq>YUjV{~M2k zY^Y0bcc!NAg>DYAaDFyxX5o-BXIow{;8RHDL8FXnLw(W9MXz4;nSbu>UtNA?@n zt_;oG6chDAdF?j`9X`9Pkp7w)R$Ra0QuD${a$Itz<0=Y zErwb5qgPWTuQQxMG_%fAZN}GeGDY+7LArdwYi?lN+^o$kGoKTg`IFu5+m5T8lm%b; zopt!1^=bxkasF%U33Blc*vH_lT`X{m&dqX9oT~>hh1CS(@Sk{J%{`NYp*7faXs8z| zEt8CdvN(76TwB>5@eg@VE+N)heKO)2r!Y(5mHV(v)5y#4^^CK#OmS?|MY*rZHg7!Z zwF3V6=mr&zDRa-t#YU=hJNm=1#~()rYCs}bbaEl4+f(JgwOKqYxa7XujN`!@b$*8L zHag~5XxHF8lJ|MZZ=Ts*wGc0jUmL2AQ~_~j{d9?fZ{}dk+b@i(*oete3a~#@&uj9h z?#8=G`l<4S*Q=$y`|WV_a_xAhaa-=ImtXKjqi~kN$Z&p_`zZoJBd*1fsY1`@%Tyky z*|?^UG`nz?8CY`yP{us&>EU*Zg^sSYT{JIh`|A?qWFi{#0ie`b_j0)=2s&A08T=;G zN%6C3O~ez^A7oHojJ4K7Jg}8A;*Gfz#Q7*>e-TDbw#eoogbNV>0f`@4;Ij5NU=R0?3D{FGhuiH*%mTk6XU+wXR&5N$vo`|Q69aUFW4wS+QJW1Kn);$ zZ#4zdHTBq46L*BRzPx$;nq$7R=9ONQUE%#8P2d^Cl^5r68+#illODYVsV!eC0fku3M}!ny)Vbtkhky-+PtiQ5BQ73E^V!= z6~nWR7jfQEB%Nv+GTH;`dgIz7T^3?g3hqKDM?PS^N~C`C41tjzZ5{$3KvRao4A!2W zkVI-t@JB7`!p1NJdGR>M18O|6gUL5(76%A@;>jLNNGYtfj6fVykz*)s@Q-4d3_6q! zy3?Qn1&19p;OYb?r)WH&LnufWvs#c5vjI%RlM{KrwPew82I}~L^D{|O zQ|sLQ&IG!MP0VkS{a*RC6;4G3jM@-3(#5z3i@#+ibQUo5Bl%B2FL&2vZ`j4Y)DfZE zNsMAudU%>@DK!LQ>;q0xRSxJ2T#>H+D4WO;;RwOoE{wY5okZ59)=$ZahlT7{L8Gii zh#PJql>Q0gc-6RBadl5l0$MT-SE0G(nxql)%tf_6AD8^`ggVb!m?lUr#>&8bdbtE^|o@r|GsL?2V+J-k=msrM8K} z;fbQ9i8l)giqo{5g56J-ka|>^S^8oP-?FAwQ!L$pFwUEw4i#-sK;sm`;zWzdAg*Fn zL{CXXW+MT%n+TnQ_pT`=s5N1UxM+cq_#pVjFDQ9iy}rpm?XgbZ6jD9hF6})?!$v97 zJ_i3-0X?2KH$`b)={JG+Y?CJSN5*)w47P}fLIM6u!ZyQH&$qdlJ|sd;^jry3=|Z*q zby;G*g+Ws4{~gfFed~X&r}1kF!FEI2sX}k2Ys{TfWAh}jPGA^iK=av4N2|WqvJLgI zWYW>RFIuNHts35ctiw7uRc=G2=wKMSe71D2yQ1 ztO}gYf&*g3oB%TK9G}meC@U$Y77Vijc6^bR`O&QHL=N|PQ5};eJ1WO!V_`3ogYjAD zstM0iTGwg{gf#9?m9*c@ad7je$Ba)E_`DQ@avO=nUun zhQ(6CjcM(Z9f5f+dsCCE{)E46^W>9QYI_3Zmgz5X7JZxoYWS-G531W>;&R+FC~g@Xw@eYY42fHY#x29*mMP Date: Sun, 28 Jul 2019 20:54:02 +0200 Subject: [PATCH 106/106] :pencil: update documentation --- README.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/README.md b/README.md index 8d2bb3c9..fa64fbe7 100644 --- a/README.md +++ b/README.md @@ -1264,6 +1264,11 @@ I deeply appreciate the help of the following people. - [Mark Beckwith](https://github.com/wythe) fixed a typo. - [yann-morin-1998](https://github.com/yann-morin-1998) helped reducing the CMake requirement to version 3.1. - [Konstantin Podsvirov](https://github.com/podsvirov) maintains a package for the MSYS2 software distro. +- [remyabel](https://github.com/remyabel) added GNUInstallDirs to the CMake files. +- [Taylor Howard](https://github.com/taylorhoward92) fixed a unit test. +- [Gabe Ron](https://github.com/Macr0Nerd) implemented the `to_string` method. +- [Watal M. Iwasaki](https://github.com/heavywatal) fixed a Clang warning. +- [Viktor Kirilov](https://github.com/onqtam) switched the unit tests from [Catch](https://github.com/philsquared/Catch) to [doctest](https://github.com/onqtam/doctest) Thanks a lot for helping out! Please [let me know](mailto:mail@nlohmann.me) if I forgot someone.