wowlib 0.0.0
Read & write World of Warcraft client files — a C++26 core
Loading...
Searching...
No Matches
wowlib::db::blob::View Class Reference

A structural view over one WDBS blob. More...

#include <wowlib/db/schema_blob.hpp>

Public Member Functions

constexpr View (std::span< const unsigned char > bytes)
 Bind the view to bytes (unvalidated — call valid).
constexpr bool valid () const
 Whether the bytes are a structurally valid WDBS v2 blob: magic, version, and every section (plus the string pool's terminating NUL discipline at the section level) inside bounds.
constexpr std::size_t eraCount () const
constexpr std::size_t tableCount () const
constexpr std::size_t rangeCount () const
constexpr std::size_t columnCount () const
constexpr std::size_t strpoolSize () const
constexpr ClientVersion era (std::size_t i) const
 The client version of era slot i.
constexpr TableEntry table (std::size_t i) const
 The directory entry of table i (name-sorted order).
constexpr RangeEntry range (std::size_t i) const
 The range entry i (blob-global index).
constexpr ColumnEntry column (std::size_t i) const
 The column entry i (blob-global index).
std::string_view stringAt (std::uint32_t off) const
 The pool string at off as a view into the blob (runtime only — the pointer cast out of the byte pool is not a constant expression).
constexpr std::string copyStringAt (std::uint32_t off) const
 The pool string at off, copied byte by byte — the consteval-safe twin of stringAt.
constexpr std::optional< std::size_t > findTable (std::string_view name) const
 Binary-search the (name-sorted) table directory for name.
constexpr std::span< const unsigned char > bytes () const

Detailed Description

A structural view over one WDBS blob.

Construction never throws and never reads out of bounds: valid reports whether the bytes are a well-formed blob, and every accessor presumes it returned true.

The view neither owns nor copies — the caller keeps the bytes alive (the embedded blob has static storage; the catalog owns its file buffer).

Definition at line 99 of file schema_blob.hpp.

Constructor & Destructor Documentation

◆ View()

wowlib::db::blob::View::View ( std::span< const unsigned char > bytes)
inlineexplicitconstexpr

Bind the view to bytes (unvalidated — call valid).

Parameters
bytesthe complete blob.

Definition at line 103 of file schema_blob.hpp.

References bytes().

Member Function Documentation

◆ bytes()

std::span< const unsigned char > wowlib::db::blob::View::bytes ( ) const
inlineconstexpr
Returns
the raw bytes the view was constructed over.

Definition at line 210 of file schema_blob.hpp.

Referenced by View().

◆ column()

◆ columnCount()

std::size_t wowlib::db::blob::View::columnCount ( ) const
inlineconstexpr
Returns
the blob-global column entry count.

Definition at line 125 of file schema_blob.hpp.

Referenced by valid().

◆ copyStringAt()

std::string wowlib::db::blob::View::copyStringAt ( std::uint32_t off) const
inlineconstexpr

The pool string at off, copied byte by byte — the consteval-safe twin of stringAt.

Parameters
offthe pool offset.
Returns
the string, as an owned copy.

Definition at line 186 of file schema_blob.hpp.

Referenced by wowlib::db::detail::typedColumnIndex().

◆ era()

ClientVersion wowlib::db::blob::View::era ( std::size_t i) const
inlineconstexpr

The client version of era slot i.

Parameters
ithe era index (< eraCount()).
Returns
the decoded version tuple.

Definition at line 132 of file schema_blob.hpp.

References wowlib::db::blob::EraBytes, and wowlib::db::blob::HeaderBytes.

Referenced by wowlib::db::detail::typedRangeOf().

◆ eraCount()

std::size_t wowlib::db::blob::View::eraCount ( ) const
inlineconstexpr
Returns
the number of era slots the blob's masks index.

Definition at line 119 of file schema_blob.hpp.

Referenced by wowlib::db::detail::typedRangeOf(), and valid().

◆ findTable()

std::optional< std::size_t > wowlib::db::blob::View::findTable ( std::string_view name) const
inlineconstexpr

Binary-search the (name-sorted) table directory for name.

Parameters
namethe table identifier (case-sensitive, e.g. "Map").
Returns
the table index, or nullopt when absent.

Definition at line 196 of file schema_blob.hpp.

References table(), and tableCount().

Referenced by wowlib::db::detail::typedRangeOf().

◆ range()

RangeEntry wowlib::db::blob::View::range ( std::size_t i) const
inlineconstexpr

The range entry i (blob-global index).

Parameters
ithe range index (< rangeCount()).
Returns
the decoded entry.

Definition at line 148 of file schema_blob.hpp.

References wowlib::db::blob::RangeBytes.

Referenced by wowlib::db::detail::typedRangeOf().

◆ rangeCount()

std::size_t wowlib::db::blob::View::rangeCount ( ) const
inlineconstexpr
Returns
the blob-global range entry count.

Definition at line 123 of file schema_blob.hpp.

Referenced by valid().

◆ stringAt()

std::string_view wowlib::db::blob::View::stringAt ( std::uint32_t off) const
inline

The pool string at off as a view into the blob (runtime only — the pointer cast out of the byte pool is not a constant expression).

Parameters
offthe pool offset (a *_off field).
Returns
the NUL-terminated string, as a view.

Definition at line 177 of file schema_blob.hpp.

◆ strpoolSize()

std::size_t wowlib::db::blob::View::strpoolSize ( ) const
inlineconstexpr
Returns
the string pool size in bytes.

Definition at line 127 of file schema_blob.hpp.

Referenced by valid().

◆ table()

TableEntry wowlib::db::blob::View::table ( std::size_t i) const
inlineconstexpr

The directory entry of table i (name-sorted order).

Parameters
ithe table index (< tableCount()).
Returns
the decoded entry.

Definition at line 140 of file schema_blob.hpp.

References wowlib::db::blob::TableBytes.

Referenced by findTable(), and wowlib::db::detail::typedRangeOf().

◆ tableCount()

std::size_t wowlib::db::blob::View::tableCount ( ) const
inlineconstexpr
Returns
the number of tables (sorted by identifier name).

Definition at line 121 of file schema_blob.hpp.

Referenced by findTable(), and valid().

◆ valid()

bool wowlib::db::blob::View::valid ( ) const
inlineconstexpr

Whether the bytes are a structurally valid WDBS v2 blob: magic, version, and every section (plus the string pool's terminating NUL discipline at the section level) inside bounds.

Returns
true when every accessor below is safe to call.

Definition at line 109 of file schema_blob.hpp.

References wowlib::db::blob::ColumnBytes, columnCount(), wowlib::db::blob::EraBytes, eraCount(), wowlib::db::blob::FormatVersion, wowlib::db::blob::HeaderBytes, wowlib::db::blob::Magic, wowlib::db::blob::RangeBytes, rangeCount(), strpoolSize(), wowlib::db::blob::TableBytes, and tableCount().


The documentation for this class was generated from the following file: