From a38fb54d89c4c77fd56bff119fb76b0960165b5f Mon Sep 17 00:00:00 2001 From: Martijn Govers Date: Tue, 3 Dec 2024 08:29:27 +0100 Subject: [PATCH 1/3] fix error message when serializated file invalid Signed-off-by: Martijn Govers --- .../auxiliary/serialization/deserializer.hpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/power_grid_model_c/power_grid_model/include/power_grid_model/auxiliary/serialization/deserializer.hpp b/power_grid_model_c/power_grid_model/include/power_grid_model/auxiliary/serialization/deserializer.hpp index 00d02a04b..ba6cd8363 100644 --- a/power_grid_model_c/power_grid_model/include/power_grid_model/auxiliary/serialization/deserializer.hpp +++ b/power_grid_model_c/power_grid_model/include/power_grid_model/auxiliary/serialization/deserializer.hpp @@ -193,7 +193,7 @@ struct MapArrayVisitor : DefaultErrorVisitor> { static constexpr bool enable_array = std::same_as || std::same_as; static constexpr std::string_view static_err_msg = - enable_map ? (enable_array ? "Expect a map or array." : "Expect a map.") : "Expect an array."; + enable_map ? (enable_array ? "Expected a map or array." : "Expected a map.") : "Expected an array."; Idx size{}; bool is_map{}; @@ -226,7 +226,7 @@ struct MapArrayVisitor : DefaultErrorVisitor> { }; struct StringVisitor : DefaultErrorVisitor { - static constexpr std::string_view static_err_msg = "Expect a string."; + static constexpr std::string_view static_err_msg = "Expected a string."; std::string_view str{}; bool visit_str(const char* v, uint32_t size) { @@ -236,7 +236,7 @@ struct StringVisitor : DefaultErrorVisitor { }; struct BoolVisitor : DefaultErrorVisitor { - static constexpr std::string_view static_err_msg = "Expect a boolean."; + static constexpr std::string_view static_err_msg = "Expected a boolean."; bool value{}; bool visit_boolean(bool v) { @@ -248,7 +248,7 @@ struct BoolVisitor : DefaultErrorVisitor { template struct ValueVisitor; template struct ValueVisitor : DefaultErrorVisitor> { - static constexpr std::string_view static_err_msg = "Expect an interger."; + static constexpr std::string_view static_err_msg = "Expected an integer."; T& value; // NOLINT(cppcoreguidelines-avoid-const-or-ref-data-members) @@ -270,7 +270,7 @@ template struct ValueVisitor : DefaultErrorVisitor struct ValueVisitor : DefaultErrorVisitor> { - static constexpr std::string_view static_err_msg = "Expect a number."; + static constexpr std::string_view static_err_msg = "Expected a number."; double& value; // NOLINT(cppcoreguidelines-avoid-const-or-ref-data-members) @@ -294,7 +294,7 @@ template <> struct ValueVisitor : DefaultErrorVisitor struct ValueVisitor> : DefaultErrorVisitor>> { - static constexpr std::string_view static_err_msg = "Expect an array of 3 numbers."; + static constexpr std::string_view static_err_msg = "Expected an array of 3 numbers."; RealValue& value; // NOLINT(cppcoreguidelines-avoid-const-or-ref-data-members) Idx idx{}; From 20f82765a35ac93024b3fb48217fe1f332737a9e Mon Sep 17 00:00:00 2001 From: Martijn Govers Date: Tue, 3 Dec 2024 16:12:08 +0100 Subject: [PATCH 2/3] Update power_grid_model_c/power_grid_model/include/power_grid_model/auxiliary/serialization/deserializer.hpp Signed-off-by: Martijn Govers Signed-off-by: Martijn Govers --- .../power_grid_model/auxiliary/serialization/deserializer.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/power_grid_model_c/power_grid_model/include/power_grid_model/auxiliary/serialization/deserializer.hpp b/power_grid_model_c/power_grid_model/include/power_grid_model/auxiliary/serialization/deserializer.hpp index ba6cd8363..d1069bc6c 100644 --- a/power_grid_model_c/power_grid_model/include/power_grid_model/auxiliary/serialization/deserializer.hpp +++ b/power_grid_model_c/power_grid_model/include/power_grid_model/auxiliary/serialization/deserializer.hpp @@ -193,7 +193,7 @@ struct MapArrayVisitor : DefaultErrorVisitor> { static constexpr bool enable_array = std::same_as || std::same_as; static constexpr std::string_view static_err_msg = - enable_map ? (enable_array ? "Expected a map or array." : "Expected a map.") : "Expected an array."; + enable_map ? (enable_array ? "Expected a map or an array." : "Expected a map.") : "Expected an array."; Idx size{}; bool is_map{}; From a7b018529f9953cdee6e75dbad4a6912fdf4509c Mon Sep 17 00:00:00 2001 From: Martijn Govers Date: Wed, 4 Dec 2024 13:09:23 +0100 Subject: [PATCH 3/3] apply suggestions from code review Signed-off-by: Martijn Govers --- .../auxiliary/serialization/deserializer.hpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/power_grid_model_c/power_grid_model/include/power_grid_model/auxiliary/serialization/deserializer.hpp b/power_grid_model_c/power_grid_model/include/power_grid_model/auxiliary/serialization/deserializer.hpp index ba6cd8363..0c9c860ba 100644 --- a/power_grid_model_c/power_grid_model/include/power_grid_model/auxiliary/serialization/deserializer.hpp +++ b/power_grid_model_c/power_grid_model/include/power_grid_model/auxiliary/serialization/deserializer.hpp @@ -193,7 +193,7 @@ struct MapArrayVisitor : DefaultErrorVisitor> { static constexpr bool enable_array = std::same_as || std::same_as; static constexpr std::string_view static_err_msg = - enable_map ? (enable_array ? "Expected a map or array." : "Expected a map.") : "Expected an array."; + enable_map ? (enable_array ? "Map or array expected." : "Map expected.") : "Array expected."; Idx size{}; bool is_map{}; @@ -226,7 +226,7 @@ struct MapArrayVisitor : DefaultErrorVisitor> { }; struct StringVisitor : DefaultErrorVisitor { - static constexpr std::string_view static_err_msg = "Expected a string."; + static constexpr std::string_view static_err_msg = "String expected."; std::string_view str{}; bool visit_str(const char* v, uint32_t size) { @@ -236,7 +236,7 @@ struct StringVisitor : DefaultErrorVisitor { }; struct BoolVisitor : DefaultErrorVisitor { - static constexpr std::string_view static_err_msg = "Expected a boolean."; + static constexpr std::string_view static_err_msg = "Boolean expected."; bool value{}; bool visit_boolean(bool v) { @@ -248,7 +248,7 @@ struct BoolVisitor : DefaultErrorVisitor { template struct ValueVisitor; template struct ValueVisitor : DefaultErrorVisitor> { - static constexpr std::string_view static_err_msg = "Expected an integer."; + static constexpr std::string_view static_err_msg = "Integer expected."; T& value; // NOLINT(cppcoreguidelines-avoid-const-or-ref-data-members) @@ -270,7 +270,7 @@ template struct ValueVisitor : DefaultErrorVisitor struct ValueVisitor : DefaultErrorVisitor> { - static constexpr std::string_view static_err_msg = "Expected a number."; + static constexpr std::string_view static_err_msg = "Number expected."; double& value; // NOLINT(cppcoreguidelines-avoid-const-or-ref-data-members) @@ -294,7 +294,7 @@ template <> struct ValueVisitor : DefaultErrorVisitor struct ValueVisitor> : DefaultErrorVisitor>> { - static constexpr std::string_view static_err_msg = "Expected an array of 3 numbers."; + static constexpr std::string_view static_err_msg = "Array of 3 numbers expected."; RealValue& value; // NOLINT(cppcoreguidelines-avoid-const-or-ref-data-members) Idx idx{};