20 #ifndef ANTKEEPER_RESOURCES_PHYSFS_DESERIALIZE_CONTEXT_HPP
21 #define ANTKEEPER_RESOURCES_PHYSFS_DESERIALIZE_CONTEXT_HPP
59 void open(const std::filesystem::
path&
path) noexcept(false);
64 void close() noexcept;
69 [[nodiscard]]
bool is_open() const noexcept;
71 [[nodiscard]] const std::filesystem::
path&
path() const noexcept override;
72 [[nodiscard]]
bool error() const noexcept override;
73 [[nodiscard]]
bool eof() const noexcept override;
74 [[nodiscard]] std::
size_t size() const noexcept override;
75 [[nodiscard]] std::
size_t tell() const override;
77 std::
size_t read8(std::
byte* data, std::
size_t count) noexcept(false) override;
78 std::
size_t read16_le(std::
byte* data, std::
size_t count) noexcept(false) override;
79 std::
size_t read16_be(std::
byte* data, std::
size_t count) noexcept(false) override;
80 std::
size_t read32_le(std::
byte* data, std::
size_t count) noexcept(false) override;
81 std::
size_t read32_be(std::
byte* data, std::
size_t count) noexcept(false) override;
82 std::
size_t read64_le(std::
byte* data, std::
size_t count) noexcept(false) override;
83 std::
size_t read64_be(std::
byte* data, std::
size_t count) noexcept(false) override;
86 PHYSFS_File* m_file{
nullptr};
87 std::filesystem::path m_path;
Deserialize context implementation using PhysicsFS.
physfs_deserialize_context() noexcept=default
Constructs a PhysicsFS deserialize context.
std::size_t read16_be(std::byte *data, std::size_t count) noexcept(false) override
Reads 16-bit (word) big-endian data.
void close() noexcept
Closes the associated file using PhysicsFS.
std::size_t read32_be(std::byte *data, std::size_t count) noexcept(false) override
Reads 32-bit (double word) big-endian data.
void open(const std::filesystem::path &path) noexcept(false)
Opens a file using PhysicsFS and associates it with the deserialize context.
const std::filesystem::path & path() const noexcept override
Returns the path associated with this deserialize context.
void seek(std::size_t offset) override
Seeks to a position in the file.
std::size_t tell() const override
Returns the offsets from the start of the file to the current position, in bytes.
std::size_t read8(std::byte *data, std::size_t count) noexcept(false) override
Reads 8-bit (byte) data.
std::size_t read32_le(std::byte *data, std::size_t count) noexcept(false) override
Reads 32-bit (double word) little-endian data.
std::size_t read64_le(std::byte *data, std::size_t count) noexcept(false) override
Reads 64-bit (quad word) little-endian data.
bool error() const noexcept override
Returns true if an error occured during a read operation or initialization, false otherwise.
bool eof() const noexcept override
Returns true if the end of a file was reached.
std::size_t size() const noexcept override
Returns the size of the file, in bytes.
std::size_t read16_le(std::byte *data, std::size_t count) noexcept(false) override
Reads 16-bit (word) little-endian data.
std::size_t read64_be(std::byte *data, std::size_t count) noexcept(false) override
Reads 64-bit (quad word) big-endian data.
bool is_open() const noexcept
Returns true if the PhysicsFS file associated with this deserialize context is open,...
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.