Merge branch 'pboettch:main' into fix-multiple-of-float

This commit is contained in:
dhmemi 2023-11-14 14:27:44 +08:00 committed by GitHub
commit 7d84d546f9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 29 additions and 28 deletions

View File

@ -80,26 +80,28 @@ endif ()
]==============================================================================================] ]==============================================================================================]
set(fetch_packages "") set(fetch_packages "")
# Fetch/Find nlohmann_json if (NOT TARGET nlohmann_json)
# TODO: Remove when bumping cmake >= 3.24 # Fetch/Find nlohmann_json
if (CMAKE_VERSION VERSION_GREATER_EQUAL 3.24) # TODO: Remove when bumping cmake >= 3.24
FetchContent_Declare(nlohmann_json if (CMAKE_VERSION VERSION_GREATER_EQUAL 3.24)
GIT_REPOSITORY https://github.com/nlohmann/json FetchContent_Declare(nlohmann_json
GIT_TAG ${JSON_FETCH_VERSION} GIT_REPOSITORY https://github.com/nlohmann/json
FIND_PACKAGE_ARGS GIT_TAG ${JSON_FETCH_VERSION}
) FIND_PACKAGE_ARGS
list(APPEND fetch_packages nlohmann_json) )
else () list(APPEND fetch_packages nlohmann_json)
# Try to get system installed version else ()
find_package(nlohmann_json QUIET) # Try to get system installed version
if (NOT nlohmann_json_FOUND) find_package(nlohmann_json QUIET)
# If failed fetch the desired version if (NOT nlohmann_json_FOUND)
FetchContent_Declare(nlohmann_json # If failed fetch the desired version
GIT_REPOSITORY https://github.com/nlohmann/json FetchContent_Declare(nlohmann_json
GIT_TAG ${JSON_FETCH_VERSION} GIT_REPOSITORY https://github.com/nlohmann/json
) GIT_TAG ${JSON_FETCH_VERSION}
list(APPEND fetch_packages nlohmann_json) )
endif () list(APPEND fetch_packages nlohmann_json)
endif ()
endif ()
endif () endif ()
# Handle configure flags # Handle configure flags

View File

@ -74,7 +74,7 @@ types, depending on if the schema type is "integer" or "number". Bignum
This library is based on Niels Lohmann's JSON-library and thus has This library is based on Niels Lohmann's JSON-library and thus has
a build-dependency to it. a build-dependency to it.
Currently at least version **3.6.0** of NLohmann's JSON library Currently at least version **3.8.0** of NLohmann's JSON library
is required. is required.
Various methods using CMake can be used to build this project. Various methods using CMake can be used to build this project.

View File

@ -28,10 +28,13 @@ public:
json_patch &replace(const json::json_pointer &, json value); json_patch &replace(const json::json_pointer &, json value);
json_patch &remove(const json::json_pointer &); json_patch &remove(const json::json_pointer &);
json &get_json() { return j_; }
const json &get_json() const { return j_; }
operator json() const { return j_; } operator json() const { return j_; }
private: private:
json j_; json j_ = nlohmann::json::array();
static void validateJsonPatch(json const &patch); static void validateJsonPatch(json const &patch);
}; };

View File

@ -436,12 +436,12 @@ class logical_combination : public schema
for (auto &s : subschemata_) { for (auto &s : subschemata_) {
first_error_handler esub; first_error_handler esub;
json_patch old_patch(patch); auto oldPatchSize = patch.get_json().size();
s->validate(ptr, instance, patch, esub); s->validate(ptr, instance, patch, esub);
if (!esub) if (!esub)
count++; count++;
else else
patch = old_patch; patch.get_json().get_ref<nlohmann::json::array_t &>().resize(oldPatchSize);
if (is_validate_complete(instance, ptr, e, esub, count)) if (is_validate_complete(instance, ptr, e, esub, count))
return; return;

View File

@ -669,10 +669,6 @@ static const short _address_eof_trans[] = {
1278, 1279, 1280, 1281, 1282, 1283, 0}; 1278, 1279, 1280, 1281, 1282, 1283, 0};
static const int address_start = 1; static const int address_start = 1;
static const int address_first_final = 196;
static const int address_error = 0;
static const int address_en_main = 1;
bool is_address(const char *p, const char *pe) bool is_address(const char *p, const char *pe)
{ {