/*
* Copyright (C) 2023 Christopher J. Howard
*
* This file is part of Antkeeper source code.
*
* Antkeeper source code is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Antkeeper source code is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Antkeeper source code. If not, see .
*/
#include "resources/deserializer.hpp"
#include
template <>
void deserializer::deserialize(bool& value, deserialize_context& ctx)
{
std::uint8_t temp;
ctx.read8(reinterpret_cast(&temp), 1);
value = (temp) ? true : false;
};
template <>
void deserializer::deserialize(std::uint8_t& value, deserialize_context& ctx)
{
ctx.read8(reinterpret_cast(&value), 1);
};
template <>
void deserializer::deserialize(std::uint16_t& value, deserialize_context& ctx)
{
ctx.read16(reinterpret_cast(&value), 1);
};
template <>
void deserializer::deserialize(std::uint32_t& value, deserialize_context& ctx)
{
ctx.read32(reinterpret_cast(&value), 1);
};
template <>
void deserializer::deserialize(std::uint64_t& value, deserialize_context& ctx)
{
ctx.read64(reinterpret_cast(&value), 1);
};
template <>
void deserializer::deserialize(std::int8_t& value, deserialize_context& ctx)
{
ctx.read8(reinterpret_cast(&value), 1);
};
template <>
void deserializer::deserialize(std::int16_t& value, deserialize_context& ctx)
{
ctx.read16(reinterpret_cast(&value), 1);
};
template <>
void deserializer::deserialize(std::int32_t& value, deserialize_context& ctx)
{
ctx.read32(reinterpret_cast(&value), 1);
};
template <>
void deserializer::deserialize(std::int64_t& value, deserialize_context& ctx)
{
ctx.read64(reinterpret_cast(&value), 1);
};
template <>
void deserializer::deserialize(float& value, deserialize_context& ctx)
{
ctx.read32(reinterpret_cast(&value), 1);
};
template <>
void deserializer::deserialize(double& value, deserialize_context& ctx)
{
ctx.read64(reinterpret_cast(&value), 1);
};
template <>
void deserializer::deserialize(std::string& value, deserialize_context& ctx)
{
std::uint64_t length = 0;
ctx.read64(reinterpret_cast(&length), 1);
value.resize(static_cast(length));
ctx.read8(reinterpret_cast(value.data()), static_cast(length));
};
template <>
void deserializer::deserialize(std::u8string& value, deserialize_context& ctx)
{
std::uint64_t length = 0;
ctx.read64(reinterpret_cast(&length), 1);
value.resize(static_cast(length));
ctx.read8(reinterpret_cast(value.data()), static_cast(length));
};
template <>
void deserializer::deserialize(std::u16string& value, deserialize_context& ctx)
{
std::uint64_t length = 0;
ctx.read64(reinterpret_cast(&length), 1);
value.resize(static_cast(length));
ctx.read16(reinterpret_cast(value.data()), static_cast(length));
};
template <>
void deserializer::deserialize(std::u32string& value, deserialize_context& ctx)
{
std::uint64_t length = 0;
ctx.read64(reinterpret_cast(&length), 1);
value.resize(static_cast(length));
ctx.read32(reinterpret_cast(value.data()), static_cast(length));
};