Engine → Assets → asset_pack.h
pack_reader
| Type | Class |
| Namespace | conjure::assets |
| Include File Path | engine/include/conjure/assets/asset_pack.h |
| Source File Path | engine/src/assets/asset_pack.cpp |
| API ↗ | Cooking, caches and packs, Assets |
Syntax
Constructors
| Access | Signature | Description |
|---|---|---|
| public | pack_reader(); | |
| public | pack_reader(
pack_reader &&) noexcept = default; |
Important
Copy constructor and assignment has been deleted.
Destructors
| Access | Signature | Description |
|---|---|---|
| public | ~pack_reader(); |
Variables
| Access | Name | Type | Default | Description |
|---|---|---|---|---|
| private | mBuffer | std::vector<std::byte> | {} | |
| private | m | std::vector<asset_id> | {} | |
| private | mFile | std:: | nullptr | |
| private | mFileSize | u64 | 0 | |
| private | mHeader | pack_header | {} | |
| private | mOpen | bool | false | |
| private | mStrings | std::string | {} | |
| private | mToc | std:: | {} |
Functions
Public
content_hash
content_hash[[nodiscard]] u64 content_hash() const noexcept;dependencies_of
dependencies_of[[nodiscard]] std::span<const asset_id> dependencies_of(
const pack_toc_entry &entry) const noexcept;The dependencies of an entry.
find
find[[nodiscard]] const pack_toc_entry *find(
const asset_id &id) const noexcept;Binary search over the sorted TOC.
find_by_name
find_by_name[[nodiscard]] const pack_toc_entry *find_by_name(
std::string_view assetPath) const noexcept;The entry whose recorded asset path equals assetPath, or nullptr.
header
header[[nodiscard]] const pack_header &header() const noexcept;is_open
is_open[[nodiscard]] bool is_open() const noexcept;name_of
name_of[[nodiscard]] std::string_view name_of(
const pack_toc_entry &entry) const noexcept;The asset path recorded for an entry.
open
open[[nodiscard]] core::result<void> open(
core::vfs::file_system &fileSystem,
std::string_view packPath);Opens and validates a pack: magic, format version, table bounds, TOC order and the content hash of everything after the header. PACK_CORRUPT on any failure, NOT_FOUND (assets) when the file is missing.
open_bytes
open_bytes[[nodiscard]] core::result<void> open_bytes(
std::vector<std::byte> bytes);Parses an in-memory pack the same way; payloads are then served from the buffer.
read
read[[nodiscard]] core::result<cooked_blob> read(
const pack_toc_entry &entry) const;Reads an entry's payload and rebuilds the blob (header fields the pack does not store are zero). PACK_CORRUPT when the payload hash does not match.
toc
toc[[nodiscard]] std::span<const pack_toc_entry> toc() const noexcept;Private
parse_tables
parse_tables[[nodiscard]] core::result<void> parse_tables();read_range
read_range[[nodiscard]] core::result<void> read_range(
u64 offset,
std::span<std::byte> out) const;Operator Overloads
Public
operator=
operator=pack_reader &operator=(
pack_reader &&) noexcept = default;