41 std::uint32_t size =
static_cast<std::uint32_t
>(
map.size());
42 ctx.
write32<std::endian::little>(
reinterpret_cast<const std::byte*
>(&size), 1);
45 for (
const auto& [key, value]:
map)
48 ctx.
write32<std::endian::little>(
reinterpret_cast<const std::byte*
>(&key), 1);
51 std::uint32_t
length =
static_cast<std::uint32_t
>(value.length());
52 ctx.
write32<std::endian::little>(
reinterpret_cast<const std::byte*
>(&
length), 1);
55 ctx.
write8(
reinterpret_cast<const std::byte*
>(value.data()),
length);
73 std::uint32_t size = 0;
74 ctx.
read32<std::endian::little>(
reinterpret_cast<std::byte*
>(&size), 1);
77 for (std::uint32_t i = 0; i < size; ++i)
81 ctx.
read32<std::endian::little>(
reinterpret_cast<std::byte*
>(&key), 1);
85 ctx.
read32<std::endian::little>(
reinterpret_cast<std::byte*
>(&
length), 1);
88 auto [iterator, inserted] =
map.emplace
90 std::piecewise_construct,
91 std::forward_as_tuple(key),
92 std::forward_as_tuple(
static_cast<std::size_t
>(
length),
'\0')
96 ctx.
read8(
reinterpret_cast<std::byte*
>(iterator->second.data()),
length);
103 auto resource = std::make_unique<i18n::string_map>();
static std::unique_ptr< T > load(::resource_manager &resource_manager, deserialize_context &ctx)
Loads a resource.
Manages the loading, caching, and saving of resources.
std::unordered_map< hash::fnv1a32_t, std::string > string_map
Maps 32-bit keys to strings.
T length(const quaternion< T > &q)
Calculates the length of a quaternion.
constexpr T map(T x, T from_min, T from_max, T to_min, T to_max) noexcept
Remaps a number from one range to another.
Provides access to a deserialization state.
std::size_t read32(std::byte *data, std::size_t count) noexcept(false)
Reads 32-bit (double word) data.
virtual std::size_t read8(std::byte *data, std::size_t count) noexcept(false)=0
Reads 8-bit (byte) data.
Specializations of deserializer define the deserialization process for a given type.
void deserialize(T &value, deserialize_context &ctx)
Deserializes a value.
32-bit FNV-1a hash value.
Provides access to a serialization state.
virtual std::size_t write8(const std::byte *data, std::size_t count) noexcept(false)=0
Writes 8-bit (byte) data.
std::size_t write32(const std::byte *data, std::size_t count) noexcept(false)
Writes 32-bit (double word) data.
void serialize(const T &value, serialize_context &ctx)
Serializes a value.