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

The welded supertype of every generated table class: the whole table surface — decode, encode, validation, the preserved-state getters — bound ONCE and inherited, in every language, by all ~4200 generated (table x era) classes. More...

#include <wowlib/db/table_core.hpp>

Inheritance diagram for wowlib::db::TableBase:

Public Member Functions

Result< void > read (std::span< const std::byte > data)
 Decode a table file image.
Result< void > read (fs::FileSystem &fs, const FileKey &key)
 Load the table from a client filesystem.
Result< FileBuffer > write (EncryptedPolicy policy=EncryptedPolicy::Preserve) const
 Serialize the table to a file image; a loaded table re-emits the format it was read from.
Result< void > write (fs::FileSystem &fs, const FileKey &key, EncryptedPolicy policy=EncryptedPolicy::Preserve) const
 Serialize the table into a client filesystem (project overlay); the target path's extension picks .dbc/.db2 in the mixed eras.
const formats::StringBlock & strings () const
 The preserved string block the record string fields were decoded from; offsets never move, write() appends new strings past its end.
const std::vector< EncryptedSection > & encryptedSections () const
 The encrypted sections skipped on read: their records are not in records, but the file re-writes them verbatim.
bool fullyDecoded () const
 Whether the whole table decoded — false when encrypted sections were skipped.
formats::ValidationReport validate () const
Result< void > ensureValid () const
 Validate and raise on the first error instead of returning a report — the assert-style face of validate().
const TableCore & core () const
 The erased engine (bindings build live record views off it).

Protected Attributes

TableCore _core

Detailed Description

The welded supertype of every generated table class: the whole table surface — decode, encode, validation, the preserved-state getters — bound ONCE and inherited, in every language, by all ~4200 generated (table x era) classes.

Family bases (the per-table supertypes dbdgen emits) derive this; the per-era classes derive those and wire the protected core with their typed records vector at construction. The common surface of every client-database table: decode (read), encode (write), validation, and the preserved decode state. Concrete tables add their typed records.

Definition at line 132 of file table_core.hpp.

Member Function Documentation

◆ core()

const TableCore & wowlib::db::TableBase::core ( ) const
inline

The erased engine (bindings build live record views off it).

Excluded from every binding: TableCore is deliberately not welded — the bound face IS this class.

Definition at line 198 of file table_core.hpp.

References _core.

◆ encryptedSections()

const std::vector< EncryptedSection > & wowlib::db::TableBase::encryptedSections ( ) const
inline

The encrypted sections skipped on read: their records are not in records, but the file re-writes them verbatim.

Definition at line 177 of file table_core.hpp.

References _core.

◆ ensureValid()

Result< void > wowlib::db::TableBase::ensureValid ( ) const
inlinenodiscard

Validate and raise on the first error instead of returning a report — the assert-style face of validate().

Returns
nothing; raises when validate() finds any error

Definition at line 193 of file table_core.hpp.

References _core.

◆ fullyDecoded()

bool wowlib::db::TableBase::fullyDecoded ( ) const
inline

Whether the whole table decoded — false when encrypted sections were skipped.

Definition at line 182 of file table_core.hpp.

References _core.

◆ read() [1/2]

Result< void > wowlib::db::TableBase::read ( fs::FileSystem & fs,
const FileKey & key )
inline

Load the table from a client filesystem.

Returns
nothing; raises when loading fails
Parameters
fsthe filesystem gateway
keythe file to read

Definition at line 146 of file table_core.hpp.

References _core.

◆ read() [2/2]

Result< void > wowlib::db::TableBase::read ( std::span< const std::byte > data)
inline

Decode a table file image.

Returns
nothing; raises on malformed input or a schema mismatch
Parameters
datathe whole file content

Definition at line 138 of file table_core.hpp.

References _core.

◆ strings()

const formats::StringBlock & wowlib::db::TableBase::strings ( ) const
inline

The preserved string block the record string fields were decoded from; offsets never move, write() appends new strings past its end.

Definition at line 174 of file table_core.hpp.

References _core.

◆ validate()

formats::ValidationReport wowlib::db::TableBase::validate ( ) const
inlinenodiscard
Returns
every violated contract, in record order

Definition at line 186 of file table_core.hpp.

References _core.

◆ write() [1/2]

Result< FileBuffer > wowlib::db::TableBase::write ( EncryptedPolicy policy = EncryptedPolicy::Preserve) const
inline

Serialize the table to a file image; a loaded table re-emits the format it was read from.

policy decides how keyless encrypted sections are handled.

Returns
the file bytes
Parameters
policykeyless-section handling (WDC only)

Definition at line 155 of file table_core.hpp.

References _core, and wowlib::db::Preserve.

◆ write() [2/2]

Result< void > wowlib::db::TableBase::write ( fs::FileSystem & fs,
const FileKey & key,
EncryptedPolicy policy = EncryptedPolicy::Preserve ) const
inline

Serialize the table into a client filesystem (project overlay); the target path's extension picks .dbc/.db2 in the mixed eras.

Returns
nothing; raises when saving fails
Parameters
fsthe filesystem gateway
keythe file to write
policykeyless-section handling (WDC only)

Definition at line 165 of file table_core.hpp.

References _core, and wowlib::db::Preserve.

Member Data Documentation

◆ _core

TableCore wowlib::db::TableBase::_core
protected

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