Skip to content

Engine → Assets → asset_pack.h

pack_reader

Syntax

class CONJURE_API pack_reader

Constructors

AccessSignatureDescription
publicpack_reader();
publicpack_reader( pack_reader &&) noexcept = default;

Important

Copy constructor and assignment has been deleted.

Destructors

AccessSignatureDescription
public~pack_reader();

Variables

AccessNameTypeDefaultDescription
privatemBufferstd::vector<std::byte>{}
privatemDependenciesstd::vector<asset_id>{}
privatemFilestd::unique_ptr<core::vfs::file>nullptr
privatemFileSizeu640
privatemHeaderpack_header{}
privatemOpenboolfalse
privatemStringsstd::string{}
privatemTocstd::vector<pack_toc_entry>{}

Functions

Public

content_hash

[[nodiscard]] u64 content_hash() const noexcept;

dependencies_of

[[nodiscard]] std::span<const asset_id> dependencies_of(
    const pack_toc_entry &entry) const noexcept;

The dependencies of an entry.

find

[[nodiscard]] const pack_toc_entry *find(
    const asset_id &id) const noexcept;

Binary search over the sorted TOC.

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

[[nodiscard]] const pack_header &header() const noexcept;

is_open

[[nodiscard]] bool is_open() const noexcept;

name_of

[[nodiscard]] std::string_view name_of(
    const pack_toc_entry &entry) const noexcept;

The asset path recorded for an entry.

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

[[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

[[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

[[nodiscard]] std::span<const pack_toc_entry> toc() const noexcept;

Private

parse_tables

[[nodiscard]] core::result<void> parse_tables();

read_range

[[nodiscard]] core::result<void> read_range(
    u64 offset,
    std::span<std::byte> out) const;

Operator Overloads

Public

operator=

pack_reader &operator=(
    pack_reader &&) noexcept = default;