diff --git a/src/simplnx/Parameters/CreateColorMapParameter.hpp b/src/simplnx/Parameters/CreateColorMapParameter.hpp index 1f700a1737..76e3381e2a 100644 --- a/src/simplnx/Parameters/CreateColorMapParameter.hpp +++ b/src/simplnx/Parameters/CreateColorMapParameter.hpp @@ -4,8 +4,6 @@ #include "simplnx/Filter/ValueParameter.hpp" #include "simplnx/simplnx_export.hpp" -#include - #include namespace nx::core diff --git a/src/simplnx/Parameters/ReadHDF5DatasetParameter.cpp b/src/simplnx/Parameters/ReadHDF5DatasetParameter.cpp index 94ddb7c26f..89a84a5049 100644 --- a/src/simplnx/Parameters/ReadHDF5DatasetParameter.cpp +++ b/src/simplnx/Parameters/ReadHDF5DatasetParameter.cpp @@ -32,6 +32,8 @@ #include "simplnx/Utilities/SIMPLConversion.hpp" +#include + using namespace nx::core; namespace { @@ -42,6 +44,55 @@ constexpr StringLiteral k_ParentGroupKey = "parent_group"; namespace nx::core { +// ----------------------------------------------------------------------------- +Result ReadHDF5DatasetParameter::DatasetImportInfo::ReadJson(const nlohmann::json& json) +{ + DatasetImportInfo data; + if(!json.contains(k_DatasetPath_Key.view())) + { + return MakeErrorResult(-500, fmt::format("ImportHDF5DatasetParameter ValueType: Cannot find the key \"{}\" in the ValueType json object.", k_DatasetPath_Key)); + } + else if(!json[k_DatasetPath_Key.str()].is_string()) + { + return MakeErrorResult(-501, fmt::format("ImportHDF5DatasetParameter ValueType: 'Dataset Path' value is of type {} and is not a string.", json[k_DatasetPath_Key].type_name())); + } + data.dataSetPath = json[k_DatasetPath_Key.str()]; + + if(!json.contains(k_ComponentDimensions_Key.view())) + { + return MakeErrorResult(-502, fmt::format("ImportHDF5DatasetParameter ValueType: Cannot find the key \"{}\" in the ValueType json object.", k_ComponentDimensions_Key)); + } + else if(!json[k_ComponentDimensions_Key.str()].is_string()) + { + return MakeErrorResult( + -503, fmt::format("ImportHDF5DatasetParameter ValueType: 'Component Dimensions' value is of type {} and is not a string.", json[k_ComponentDimensions_Key].type_name())); + } + data.componentDimensions = json[k_ComponentDimensions_Key.str()]; + + if(!json.contains(k_TupleDimensions_Key.view())) + { + return MakeErrorResult(-502, fmt::format("ImportHDF5DatasetParameter ValueType: Cannot find the key \"{}\" in the ValueType json object.", k_TupleDimensions_Key)); + } + else if(!json[k_TupleDimensions_Key.str()].is_string()) + { + return MakeErrorResult( + -503, fmt::format("ImportHDF5DatasetParameter ValueType: 'Tuple Dimensions' value is of type {} and is not a string.", json[k_TupleDimensions_Key].type_name())); + } + data.tupleDimensions = json[k_TupleDimensions_Key.str()]; + + return {data}; +} + +// ----------------------------------------------------------------------------- +nlohmann::json ReadHDF5DatasetParameter::DatasetImportInfo::writeJson() const +{ + nlohmann::json json; + json[k_DatasetPath_Key.str()] = dataSetPath; + json[k_ComponentDimensions_Key.str()] = componentDimensions; + json[k_TupleDimensions_Key.str()] = tupleDimensions; + return json; +} + // ----------------------------------------------------------------------------- ReadHDF5DatasetParameter::ReadHDF5DatasetParameter(const std::string& name, const std::string& humanName, const std::string& helpText, const ValueType& defaultValue) : ValueParameter(name, humanName, helpText) diff --git a/src/simplnx/Parameters/ReadHDF5DatasetParameter.hpp b/src/simplnx/Parameters/ReadHDF5DatasetParameter.hpp index c7f56e88eb..ca0d74c6fa 100644 --- a/src/simplnx/Parameters/ReadHDF5DatasetParameter.hpp +++ b/src/simplnx/Parameters/ReadHDF5DatasetParameter.hpp @@ -37,8 +37,6 @@ #include "simplnx/Filter/ValueParameter.hpp" #include "simplnx/simplnx_export.hpp" -#include - #include #include @@ -47,7 +45,7 @@ namespace nx::core class SIMPLNX_EXPORT ReadHDF5DatasetParameter : public ValueParameter { public: - struct DatasetImportInfo + struct SIMPLNX_EXPORT DatasetImportInfo { std::string dataSetPath; std::string componentDimensions; @@ -57,53 +55,9 @@ class SIMPLNX_EXPORT ReadHDF5DatasetParameter : public ValueParameter static inline constexpr StringLiteral k_ComponentDimensions_Key = "component_dimensions"; static inline constexpr StringLiteral k_TupleDimensions_Key = "tuple_dimensions"; - static Result ReadJson(const nlohmann::json& json) - { - DatasetImportInfo data; - if(!json.contains(k_DatasetPath_Key.view())) - { - return MakeErrorResult(-500, fmt::format("ImportHDF5DatasetParameter ValueType: Cannot find the key \"{}\" in the ValueType json object.", k_DatasetPath_Key)); - } - else if(!json[k_DatasetPath_Key.str()].is_string()) - { - return MakeErrorResult(-501, - fmt::format("ImportHDF5DatasetParameter ValueType: 'Dataset Path' value is of type {} and is not a string.", json[k_DatasetPath_Key].type_name())); - } - data.dataSetPath = json[k_DatasetPath_Key.str()]; - - if(!json.contains(k_ComponentDimensions_Key.view())) - { - return MakeErrorResult(-502, fmt::format("ImportHDF5DatasetParameter ValueType: Cannot find the key \"{}\" in the ValueType json object.", k_ComponentDimensions_Key)); - } - else if(!json[k_ComponentDimensions_Key.str()].is_string()) - { - return MakeErrorResult( - -503, fmt::format("ImportHDF5DatasetParameter ValueType: 'Component Dimensions' value is of type {} and is not a string.", json[k_ComponentDimensions_Key].type_name())); - } - data.componentDimensions = json[k_ComponentDimensions_Key.str()]; - - if(!json.contains(k_TupleDimensions_Key.view())) - { - return MakeErrorResult(-502, fmt::format("ImportHDF5DatasetParameter ValueType: Cannot find the key \"{}\" in the ValueType json object.", k_TupleDimensions_Key)); - } - else if(!json[k_TupleDimensions_Key.str()].is_string()) - { - return MakeErrorResult( - -503, fmt::format("ImportHDF5DatasetParameter ValueType: 'Tuple Dimensions' value is of type {} and is not a string.", json[k_TupleDimensions_Key].type_name())); - } - data.tupleDimensions = json[k_TupleDimensions_Key.str()]; - - return {data}; - } - - nlohmann::json writeJson() const - { - nlohmann::json json; - json[k_DatasetPath_Key.str()] = dataSetPath; - json[k_ComponentDimensions_Key.str()] = componentDimensions; - json[k_TupleDimensions_Key.str()] = tupleDimensions; - return json; - } + static Result ReadJson(const nlohmann::json& json); + + nlohmann::json writeJson() const; }; using InputFile = std::string;