20 #ifndef ANTKEEPER_RESOURCES_DESERIALIZE_CONTEXT_HPP
21 #define ANTKEEPER_RESOURCES_DESERIALIZE_CONTEXT_HPP
36 [[nodiscard]]
virtual const std::filesystem::path&
path() const noexcept = 0;
41 [[nodiscard]] virtual
bool error() const noexcept = 0;
46 [[nodiscard]] virtual
bool eof() const noexcept = 0;
51 [[nodiscard]] virtual std::
size_t size() const noexcept = 0;
58 [[nodiscard]] virtual std::
size_t tell() const = 0;
79 virtual std::
size_t read8(std::
byte* data, std::
size_t count) noexcept(false) = 0;
91 virtual std::
size_t read16_le(std::
byte* data, std::
size_t count) noexcept(false) = 0;
103 virtual std::
size_t read16_be(std::
byte* data, std::
size_t count) noexcept(false) = 0;
117 template <std::endian Endian>
118 inline std::
size_t read16(std::
byte* data, std::
size_t count) noexcept(false)
120 if constexpr (Endian == std::endian::little)
140 virtual std::size_t
read32_le(std::byte* data, std::size_t
count) noexcept(
false) = 0;
152 virtual std::size_t
read32_be(std::byte* data, std::size_t
count) noexcept(
false) = 0;
166 template <std::endian Endian>
167 inline std::size_t
read32(std::byte* data, std::size_t
count) noexcept(
false)
169 if constexpr (Endian == std::endian::little)
189 virtual std::size_t
read64_le(std::byte* data, std::size_t
count) noexcept(
false) = 0;
201 virtual std::size_t
read64_be(std::byte* data, std::size_t
count) noexcept(
false) = 0;
215 template <std::endian Endian>
216 inline std::size_t
read64(std::byte* data, std::size_t
count) noexcept(
false)
218 if constexpr (Endian == std::endian::little)
constexpr int count(T x) noexcept
Returns the number of set bits in a value, known as a population count or Hamming weight.
T offset(T longitude)
Calculates the UTC offset at a given longitude.
Provides access to a deserialization state.
virtual std::size_t read16_be(std::byte *data, std::size_t count) noexcept(false)=0
Reads 16-bit (word) big-endian data.
virtual bool eof() const noexcept=0
Returns true if the end of a file was reached.
virtual std::size_t read32_le(std::byte *data, std::size_t count) noexcept(false)=0
Reads 32-bit (double word) little-endian data.
virtual std::size_t read64_be(std::byte *data, std::size_t count) noexcept(false)=0
Reads 64-bit (quad word) big-endian data.
std::size_t read16(std::byte *data, std::size_t count) noexcept(false)
Reads 16-bit (word) data.
virtual std::size_t read16_le(std::byte *data, std::size_t count) noexcept(false)=0
Reads 16-bit (word) little-endian data.
std::size_t read32(std::byte *data, std::size_t count) noexcept(false)
Reads 32-bit (double word) data.
virtual std::size_t tell() const =0
Returns the offsets from the start of the file to the current position, in bytes.
virtual void seek(std::size_t offset)=0
Seeks to a position in the file.
virtual bool error() const noexcept=0
Returns true if an error occured during a read operation or initialization, false otherwise.
virtual const std::filesystem::path & path() const noexcept=0
Returns the path associated with this deserialize context.
virtual std::size_t size() const noexcept=0
Returns the size of the file, in bytes.
virtual std::size_t read8(std::byte *data, std::size_t count) noexcept(false)=0
Reads 8-bit (byte) data.
virtual std::size_t read64_le(std::byte *data, std::size_t count) noexcept(false)=0
Reads 64-bit (quad word) little-endian data.
std::size_t read64(std::byte *data, std::size_t count) noexcept(false)
Reads 64-bit (quad word) data.
virtual std::size_t read32_be(std::byte *data, std::size_t count) noexcept(false)=0
Reads 32-bit (double word) big-endian data.