diff options
Diffstat (limited to 'serialize')
-rw-r--r-- | serialize/json-helper.hpp | 2 | ||||
-rw-r--r-- | serialize/magnum-vector.hpp | 7 | ||||
-rw-r--r-- | serialize/magnum-vector2i.hpp | 4 |
3 files changed, 8 insertions, 5 deletions
diff --git a/serialize/json-helper.hpp b/serialize/json-helper.hpp index 6be7f74c..b8e290b7 100644 --- a/serialize/json-helper.hpp +++ b/serialize/json-helper.hpp @@ -9,7 +9,7 @@ struct json_helper final { template<typename t> [[nodiscard]] - static std::tuple<t, bool> from_json(const std::filesystem::path& pathname); + static std::tuple<t, bool> from_json(const std::filesystem::path& pathname); template<typename t> [[nodiscard]] diff --git a/serialize/magnum-vector.hpp b/serialize/magnum-vector.hpp index 8ea5e13a..61e127b1 100644 --- a/serialize/magnum-vector.hpp +++ b/serialize/magnum-vector.hpp @@ -22,13 +22,16 @@ void adl_serializer<Magnum::Math::Vector<N, T>>::to_json(json& j, const vec& val std::array<T, N> array{}; for (std::size_t i = 0; i < N; i++) array[i] = val[i]; - j = array; + using nlohmann::to_json; + to_json(j, array); } template <std::size_t N, typename T> void adl_serializer<Magnum::Math::Vector<N, T>>::from_json(const json& j, vec& val) { - std::array<T, N> array = j; + std::array<T, N> array{}; + using nlohmann::from_json; + from_json(j, array); for (std::size_t i = 0; i < N; i++) val[i] = array[i]; } diff --git a/serialize/magnum-vector2i.hpp b/serialize/magnum-vector2i.hpp index eb445e21..c8c52e7e 100644 --- a/serialize/magnum-vector2i.hpp +++ b/serialize/magnum-vector2i.hpp @@ -27,12 +27,12 @@ struct adl_serializer<Magnum::Math::Vector2<t>> final { type x = 0, y = 0; int n = 0; int ret = std::sscanf(str.c_str(), format_string, &x, &y, &n); - if (ret != 2 || (std::size_t)n != str.size() || x != (type)x || y != (type)y) + if (ret != 2 || (std::size_t)n != str.size() || x != (t)x || y != (t)y) { std::string msg; msg.reserve(128); msg += "failed to parse string '"; msg += str; - msg += "' as Magnum::Vector2i"; + msg += "' as Magnum::Vector2"; throw std::invalid_argument(msg); } val = { (t)x, (t)y }; |