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

A client database table: the typed records of one DBFilesClient file. More...

#include <wowlib/db/table.hpp>

Public Member Functions

 Table ()
 Table (const Table &o)
 Table (Table &&o) noexcept
Table & operator= (const Table &o)
Table & operator= (Table &&o) noexcept
Result< void > read (std::span< const std::byte > data)
 Decode a table 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.
Result< void > write (fs::FileSystem &fs, const FileKey &key, EncryptedPolicy policy=EncryptedPolicy::Preserve) const
 Serialize the table into a client filesystem (project overlay).
const formats::StringBlock & strings () const
 The preserved string block the record string fields were decoded from.
const std::vector< EncryptedSection > & encryptedSections () const
 The encrypted sections skipped on the last read (empty when the file was fully decodable or is not a WDC format).
bool fullyDecoded () const
 Whether every record of the file was decoded (no encrypted sections).
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 and tests reach the shared machinery here).

Public Attributes

std::vector< Record > records
 The decoded records, file order.

Static Public Attributes

static constexpr ClientVersion Version = Record::Version
 The client version the record schema belongs to.
static constexpr std::string_view TableName = Record::TableName
 The WoWDBDefs table name (e.g.

Detailed Description

template<TableRecord Record>
class wowlib::db::Table< Record >

A client database table: the typed records of one DBFilesClient file.

A thin typed shell: the records vector and the identity are here, the engine is the shared TableCore. Copy/move re-_wire the core at the fresh records vector — the one obligation a core owner carries.

Template Parameters
Recordthe record type (generated, or hand-written per schema.hpp's TableRecord contract).

Definition at line 51 of file table.hpp.

Constructor & Destructor Documentation

◆ Table() [1/3]

template<TableRecord Record>
wowlib::db::Table< Record >::Table ( )
inline

Definition at line 62 of file table.hpp.

Referenced by operator=(), operator=(), Table(), and Table().

◆ Table() [2/3]

template<TableRecord Record>
wowlib::db::Table< Record >::Table ( const Table< Record > & o)
inline

Definition at line 63 of file table.hpp.

References records, and Table().

◆ Table() [3/3]

template<TableRecord Record>
wowlib::db::Table< Record >::Table ( Table< Record > && o)
inlinenoexcept

Definition at line 65 of file table.hpp.

References records, and Table().

Member Function Documentation

◆ core()

template<TableRecord Record>
const TableCore & wowlib::db::Table< Record >::core ( ) const
inline

The erased engine (bindings and tests reach the shared machinery here).

Definition at line 166 of file table.hpp.

◆ encryptedSections()

template<TableRecord Record>
const std::vector< EncryptedSection > & wowlib::db::Table< Record >::encryptedSections ( ) const
inline

The encrypted sections skipped on the last read (empty when the file was fully decodable or is not a WDC format).

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

Definition at line 140 of file table.hpp.

◆ ensureValid()

template<TableRecord Record>
Result< void > wowlib::db::Table< Record >::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 163 of file table.hpp.

References validate().

◆ fullyDecoded()

template<TableRecord Record>
bool wowlib::db::Table< Record >::fullyDecoded ( ) const
inline

Whether every record of the file was decoded (no encrypted sections).

Returns
true when records holds the whole table. Whether the whole table decoded — false when encrypted sections were skipped.

Definition at line 147 of file table.hpp.

◆ operator=() [1/2]

template<TableRecord Record>
Table & wowlib::db::Table< Record >::operator= ( const Table< Record > & o)
inline

Definition at line 69 of file table.hpp.

References records, and Table().

◆ operator=() [2/2]

template<TableRecord Record>
Table & wowlib::db::Table< Record >::operator= ( Table< Record > && o)
inlinenoexcept

Definition at line 76 of file table.hpp.

References records, and Table().

◆ read() [1/2]

template<TableRecord Record>
Result< void > wowlib::db::Table< Record >::read ( fs::FileSystem & fs,
const FileKey & key )
inline

Load the table from a client filesystem.

Parameters
fsthe filesystem gateway.
keythe file to read.
Returns
nothing, or why loading failed.
Parameters
fsthe filesystem gateway
keythe file to read

Definition at line 98 of file table.hpp.

◆ read() [2/2]

template<TableRecord Record>
Result< void > wowlib::db::Table< Record >::read ( std::span< const std::byte > data)
inline

Decode a table image.

Parameters
datathe whole file content.
Returns
nothing, or why the image does not decode. Decode a table file image.
nothing; raises on malformed input or a schema mismatch
Parameters
datathe whole file content

Definition at line 90 of file table.hpp.

◆ strings()

template<TableRecord Record>
const formats::StringBlock & wowlib::db::Table< Record >::strings ( ) const
inline

The preserved string block the record string fields were decoded from.

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

Definition at line 134 of file table.hpp.

◆ validate()

template<TableRecord Record>
formats::ValidationReport wowlib::db::Table< Record >::validate ( ) const
inlinenodiscard
Returns
every violated contract, in record order

Definition at line 156 of file table.hpp.

Referenced by ensureValid().

◆ write() [1/2]

template<TableRecord Record>
Result< FileBuffer > wowlib::db::Table< Record >::write ( EncryptedPolicy policy = EncryptedPolicy::Preserve) const
inline

Serialize the table.

A loaded table re-emits the magic it was read from; a fresh table uses its client version's canonical .dbc/.db2 format (write(fs, key) can override by the target path's extension).

Parameters
policyhow keyless encrypted sections are handled (WDC only).
Returns
the file image, or why encoding failed. 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.
the file bytes
Parameters
policykeyless-section handling (WDC only)

Definition at line 112 of file table.hpp.

References wowlib::db::Preserve.

◆ write() [2/2]

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

Serialize the table into a client filesystem (project overlay).

Parameters
fsthe filesystem gateway.
keythe file to write; needs a resolvable path.
policyhow keyless encrypted sections are handled (see write()).
Returns
nothing, or why saving failed.
Parameters
fsthe filesystem gateway
keythe file to write
policykeyless-section handling (WDC only)

Definition at line 123 of file table.hpp.

References wowlib::db::Preserve.

Member Data Documentation

◆ records

template<TableRecord Record>
std::vector<Record> wowlib::db::Table< Record >::records

The decoded records, file order.

Mutate in place; write() serializes exactly this list.

Definition at line 60 of file table.hpp.

Referenced by operator=(), operator=(), Table(), and Table().

◆ TableName

template<TableRecord Record>
std::string_view wowlib::db::Table< Record >::TableName = Record::TableName
staticconstexpr

The WoWDBDefs table name (e.g.

"Map").

Definition at line 57 of file table.hpp.

◆ Version

template<TableRecord Record>
ClientVersion wowlib::db::Table< Record >::Version = Record::Version
staticconstexpr

The client version the record schema belongs to.

Definition at line 54 of file table.hpp.


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