diff options
author | Martin Duffy <martin.duffy@kitware.com> | 2023-03-22 17:11:21 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2023-03-29 14:41:19 (GMT) |
commit | 19305afd8a2a46925b1a880de68f7be0ad1f3091 (patch) | |
tree | cdef4417cd852c2a5dd85886df4ff61d7fd2e653 /Source/cmCMakePresetsGraphReadJSONPackagePresets.cxx | |
parent | 6b08358e17f5b85ad04ab512e4b6e39e989cea35 (diff) | |
download | CMake-19305afd8a2a46925b1a880de68f7be0ad1f3091.zip CMake-19305afd8a2a46925b1a880de68f7be0ad1f3091.tar.gz CMake-19305afd8a2a46925b1a880de68f7be0ad1f3091.tar.bz2 |
presets: Improve JSON parser and error messages
Diffstat (limited to 'Source/cmCMakePresetsGraphReadJSONPackagePresets.cxx')
-rw-r--r-- | Source/cmCMakePresetsGraphReadJSONPackagePresets.cxx | 37 |
1 files changed, 17 insertions, 20 deletions
diff --git a/Source/cmCMakePresetsGraphReadJSONPackagePresets.cxx b/Source/cmCMakePresetsGraphReadJSONPackagePresets.cxx index 4ae51b1..7290d4d 100644 --- a/Source/cmCMakePresetsGraphReadJSONPackagePresets.cxx +++ b/Source/cmCMakePresetsGraphReadJSONPackagePresets.cxx @@ -12,34 +12,34 @@ #include <cm3p/json/value.h> +#include "cmCMakePresetErrors.h" #include "cmCMakePresetsGraph.h" #include "cmCMakePresetsGraphInternal.h" #include "cmJSONHelpers.h" +class cmJSONState; namespace { -using ReadFileResult = cmCMakePresetsGraph::ReadFileResult; using PackagePreset = cmCMakePresetsGraph::PackagePreset; auto const OutputHelper = - cmJSONHelperBuilder<ReadFileResult>::Object<PackagePreset>( - ReadFileResult::READ_OK, ReadFileResult::INVALID_PRESET, false) + cmJSONHelperBuilder::Object<PackagePreset>( + JsonErrors::INVALID_NAMED_OBJECT_KEY, false) .Bind("debug"_s, &PackagePreset::DebugOutput, cmCMakePresetsGraphInternal::PresetOptionalBoolHelper, false) .Bind("verbose"_s, &PackagePreset::VerboseOutput, cmCMakePresetsGraphInternal::PresetOptionalBoolHelper, false); -auto const VariableHelper = cmJSONHelperBuilder<ReadFileResult>::String( - ReadFileResult::READ_OK, ReadFileResult::INVALID_VARIABLE); +auto const VariableHelper = + cmJSONHelperBuilder::String(cmCMakePresetErrors::INVALID_VARIABLE); -auto const VariablesHelper = - cmJSONHelperBuilder<ReadFileResult>::Map<std::string>( - ReadFileResult::READ_OK, ReadFileResult::INVALID_PRESET, VariableHelper); +auto const VariablesHelper = cmJSONHelperBuilder::Map<std::string>( + cmCMakePresetErrors::INVALID_VARIABLE, VariableHelper); auto const PackagePresetHelper = - cmJSONHelperBuilder<ReadFileResult>::Object<PackagePreset>( - ReadFileResult::READ_OK, ReadFileResult::INVALID_PRESET, false) + cmJSONHelperBuilder::Object<PackagePreset>( + cmCMakePresetErrors::INVALID_PRESET_OBJECT, false) .Bind("name"_s, &PackagePreset::Name, - cmCMakePresetsGraphInternal::PresetStringHelper) + cmCMakePresetsGraphInternal::PresetNameHelper) .Bind("inherits"_s, &PackagePreset::Inherits, cmCMakePresetsGraphInternal::PresetVectorOneOrMoreStringHelper, false) @@ -47,7 +47,7 @@ auto const PackagePresetHelper = cmCMakePresetsGraphInternal::PresetBoolHelper, false) .Bind<std::nullptr_t>("vendor"_s, nullptr, cmCMakePresetsGraphInternal::VendorHelper( - ReadFileResult::INVALID_PRESET), + cmCMakePresetErrors::INVALID_PRESET), false) .Bind("displayName"_s, &PackagePreset::DisplayName, cmCMakePresetsGraphInternal::PresetStringHelper, false) @@ -81,15 +81,12 @@ auto const PackagePresetHelper = } namespace cmCMakePresetsGraphInternal { -cmCMakePresetsGraph::ReadFileResult PackagePresetsHelper( - std::vector<cmCMakePresetsGraph::PackagePreset>& out, - const Json::Value* value) +bool PackagePresetsHelper(std::vector<cmCMakePresetsGraph::PackagePreset>& out, + const Json::Value* value, cmJSONState* state) { - static auto const helper = - cmJSONHelperBuilder<ReadFileResult>::Vector<PackagePreset>( - ReadFileResult::READ_OK, ReadFileResult::INVALID_PRESETS, - PackagePresetHelper); + static auto const helper = cmJSONHelperBuilder::Vector<PackagePreset>( + cmCMakePresetErrors::INVALID_PRESETS, PackagePresetHelper); - return helper(out, value); + return helper(out, value, state); } } |