| 9 | namespace engine::io { |
| 10 | |
| 11 | class BinaryBlob { |
| 12 | public: |
| 13 | BinaryBlob() = default; |
| 14 | ~BinaryBlob(); |
| 15 | |
| 16 | BinaryBlob(const BinaryBlob &) = delete; |
| 17 | BinaryBlob & operator=(const BinaryBlob &) = delete; |
| 18 | BinaryBlob(BinaryBlob && other) noexcept; |
| 19 | BinaryBlob & operator=(BinaryBlob && other) noexcept; |
| 20 | |
| 21 | [[nodiscard]] const std::byte * data() const noexcept; |
| 22 | [[nodiscard]] size_t size() const noexcept; |
| 23 | [[nodiscard]] bool empty() const noexcept; |
| 24 | void discard_range(size_t offset, size_t size) const noexcept; |
| 25 | |
| 26 | private: |
| 27 | friend BinaryBlob read_binary_blob(const std::filesystem::path & path); |
| 28 | |
| 29 | explicit BinaryBlob(std::vector<std::byte> owned) noexcept; |
| 30 | BinaryBlob(const std::byte * mapped, size_t size) noexcept; |
| 31 | void reset() noexcept; |
| 32 | |
| 33 | std::vector<std::byte> owned_; |
| 34 | const std::byte * mapped_ = nullptr; |
| 35 | size_t size_ = 0; |
| 36 | }; |
| 37 | |
| 38 | BinaryBlob read_binary_blob(const std::filesystem::path & path); |
| 39 | std::vector<std::byte> read_binary_file(const std::filesystem::path & path); |
no outgoing calls
no test coverage detected