diff options
-rw-r--r-- | serialize/magnum-color.cpp | 33 | ||||
-rw-r--r-- | serialize/magnum-color.hpp | 27 | ||||
-rw-r--r-- | serialize/wall-atlas.cpp | 1 |
3 files changed, 7 insertions, 54 deletions
diff --git a/serialize/magnum-color.cpp b/serialize/magnum-color.cpp deleted file mode 100644 index 390ce1f3..00000000 --- a/serialize/magnum-color.cpp +++ /dev/null @@ -1,33 +0,0 @@ -#include "magnum-color.hpp" -#include <array> -#include <Magnum/Math/Color.h> -#include <nlohmann/json.hpp> - -namespace floormat { - -namespace { - -using c3_proxy = std::array<float, 3>; -using c4_proxy = std::array<float, 4>; -using c3ub_proxy = std::array<uint8_t, 3>; -using c4ub_proxy = std::array<uint8_t, 4>; - -} // namespace - -} // namespace floormat - -namespace nlohmann { - -using namespace floormat; - -void adl_serializer<Color3>::to_json(json& val, const Color3& p) { val = c3_proxy { p[0], p[1], p[2] }; } -void adl_serializer<Color3ub>::to_json(json& val, const Color3ub& p) { val = c3ub_proxy{ p[0], p[1], p[2] }; } -void adl_serializer<Color4>::to_json(json& val, const Color4& p) { val = c4_proxy { p[0], p[1], p[2], p[3] }; } -void adl_serializer<Color4ub>::to_json(json& val, const Color4ub& p) { val = c4ub_proxy{ p[0], p[1], p[2], p[3] }; } - -void adl_serializer<Color3>::from_json(const json& j, Color3& val) { auto p = c3_proxy{j}; val = { p[0], p[1], p[2] }; } -void adl_serializer<Color3ub>::from_json(const json& j, Color3ub& val) { auto p = c3ub_proxy{j}; val = { p[0], p[1], p[2] }; } -void adl_serializer<Color4>::from_json(const json& j, Color4& val) { auto p = c4_proxy{j}; val = { p[0], p[1], p[2], p[3] }; } -void adl_serializer<Color4ub>::from_json(const json& j, Color4ub& val) { auto p = c4ub_proxy{j}; val = { p[0], p[1], p[2], p[3] }; } - -} // namespace nlohmann diff --git a/serialize/magnum-color.hpp b/serialize/magnum-color.hpp index 863eb711..0b94e421 100644 --- a/serialize/magnum-color.hpp +++ b/serialize/magnum-color.hpp @@ -1,27 +1,14 @@ #pragma once +#include "magnum-vector.hpp" #include <Magnum/Math/Math.h> #include <nlohmann/json_fwd.hpp> -template<> -struct nlohmann::adl_serializer<Magnum::Color3> { - static void to_json(json& j, const Magnum::Color3& val); - static void from_json(const json& j, Magnum::Color3& val); -}; +namespace nlohmann { -template<> -struct nlohmann::adl_serializer<Magnum::Color4> { - static void to_json(json& j, const Magnum::Color4& val); - static void from_json(const json& j, Magnum::Color4& val); -}; +template<> struct adl_serializer<Magnum::Color3> : nlohmann::adl_serializer<Magnum::Math::Vector<3, float>> {}; +template<> struct adl_serializer<Magnum::Color4> : nlohmann::adl_serializer<Magnum::Math::Vector<4, float>> {}; -template<> -struct nlohmann::adl_serializer<Magnum::Color3ub> { - static void to_json(json& j, const Magnum::Color3ub& val); - static void from_json(const json& j, Magnum::Color3ub& val); -}; +template<> struct adl_serializer<Magnum::Color3ub> : nlohmann::adl_serializer<Magnum::Math::Vector<3, std::uint8_t>> {}; +template<> struct adl_serializer<Magnum::Color4ub> : nlohmann::adl_serializer<Magnum::Math::Vector<4, std::uint8_t>> {}; -template<> -struct nlohmann::adl_serializer<Magnum::Color4ub> { - static void to_json(json& j, const Magnum::Color4ub& val); - static void from_json(const json& j, Magnum::Color4ub& val); -}; +} // namespace nlohmann diff --git a/serialize/wall-atlas.cpp b/serialize/wall-atlas.cpp index df656057..65a76126 100644 --- a/serialize/wall-atlas.cpp +++ b/serialize/wall-atlas.cpp @@ -6,7 +6,6 @@ #include "loader/loader.hpp" #include "pass-mode.hpp" #include "json-helper.hpp" -#include "magnum-color.hpp" #include <utility> #include <string_view> #include <Corrade/Containers/PairStl.h> |