From 07716595e0c26ba6d19ee6c498280508ca5aa6c2 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Tue, 16 Jan 2024 07:59:59 +0100 Subject: a --- serialize/corrade-array.hpp | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 serialize/corrade-array.hpp (limited to 'serialize/corrade-array.hpp') diff --git a/serialize/corrade-array.hpp b/serialize/corrade-array.hpp new file mode 100644 index 00000000..ea450870 --- /dev/null +++ b/serialize/corrade-array.hpp @@ -0,0 +1,28 @@ +#pragma once +#include "compat/exception.hpp" +#include +#include + +namespace nlohmann { + +template +struct adl_serializer> +{ + static void to_json(json& j, const Corrade::Containers::Array& array) + { + j.clear(); + for (const T& x : array) + j.push_back(x); + } + + static void from_json(const json& j, Corrade::Containers::Array& array) + { + fm_soft_assert(j.is_array()); + auto size = (uint32_t)j.size(); + array = Corrade::Containers::Array{size}; + for (uint32_t i = 0; i < size; i++) + array[i] = j[i]; + } +}; + +} // namespace nlohmann -- cgit v1.2.3