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

A typed, consteval-validated face over one DynTable: the table itself stays fully generic (every column decodes, byte-perfect round-trip holds); this projects rows into Record values, copies edits back, and hands out zero-copy typed column spans. More...

#include <wowlib/db/typed.hpp>

Public Member Functions

DynTable & table ()
 The generic table under this face — decode/encode/validation and the generic cell accessors all live there; this class only TYPES rows.
const DynTable & table () const
 The generic table under this face — decode/encode/validation and the generic cell accessors all live there; this class only TYPES rows.
Result< void > read (std::span< const std::byte > data)
 Decode a table file image (sugar for table().read).
Result< FileBuffer > write (EncryptedPolicy policy=EncryptedPolicy::Preserve) const
 Serialize (sugar for table().write).
std::vector< Record > load () const
 Materialize every row as a Record — the projection copies only the declared columns, row-major and contiguous (the hot-loop shape).
void writeBack (const std::vector< Record > &records)
 Replace the table's rows from records.
template<detail::FixedString Name>
auto column () const
 The zero-copy typed span of scalar column Name (rows x 1; array and string columns read through load or the generic view).

Static Public Member Functions

static Result< TypedTable > open ()
 Open the era-resolved generic table with an empty row set.

Detailed Description

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

A typed, consteval-validated face over one DynTable: the table itself stays fully generic (every column decodes, byte-perfect round-trip holds); this projects rows into Record values, copies edits back, and hands out zero-copy typed column spans.

Template Parameters
Recorda TableRecord -shaped struct whose members name a subset of the table's era columns.

Definition at line 155 of file typed.hpp.

Member Function Documentation

◆ column()

template<TableRecord Record>
template<detail::FixedString Name>
auto wowlib::db::TypedTable< Record >::column ( ) const
inline

The zero-copy typed span of scalar column Name (rows x 1; array and string columns read through load or the generic view).

Valid until rows are added or removed.

Template Parameters
Namethe member's name, e.g. column<"id">().
Returns
the live, read-only column span.

Definition at line 219 of file typed.hpp.

References wowlib::db::detail::recordMembers(), and wowlib::db::detail::typedProjection().

◆ load()

template<TableRecord Record>
std::vector< Record > wowlib::db::TypedTable< Record >::load ( ) const
inline

Materialize every row as a Record — the projection copies only the declared columns, row-major and contiguous (the hot-loop shape).

Returns
the rows.

Definition at line 188 of file typed.hpp.

References wowlib::db::schemaOf(), and wowlib::db::detail::typedProjection().

◆ open()

template<TableRecord Record>
Result< TypedTable > wowlib::db::TypedTable< Record >::open ( )
inlinestatic

Open the era-resolved generic table with an empty row set.

Returns
the typed face, or the catalog's resolution error.

Definition at line 161 of file typed.hpp.

References table().

◆ read()

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

Decode a table file image (sugar for table().read).

Definition at line 176 of file typed.hpp.

◆ table() [1/2]

template<TableRecord Record>
DynTable & wowlib::db::TypedTable< Record >::table ( )
inline

The generic table under this face — decode/encode/validation and the generic cell accessors all live there; this class only TYPES rows.

Definition at line 171 of file typed.hpp.

Referenced by open().

◆ table() [2/2]

template<TableRecord Record>
const DynTable & wowlib::db::TypedTable< Record >::table ( ) const
inline

The generic table under this face — decode/encode/validation and the generic cell accessors all live there; this class only TYPES rows.

Definition at line 173 of file typed.hpp.

◆ write()

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

Serialize (sugar for table().write).

Definition at line 181 of file typed.hpp.

References wowlib::db::Preserve.

◆ writeBack()

template<TableRecord Record>
void wowlib::db::TypedTable< Record >::writeBack ( const std::vector< Record > & records)
inline

Replace the table's rows from records.

Consteval-gated to FULL column coverage: a projection cannot author a lossless table.

Parameters
recordsthe complete new row set.

Definition at line 201 of file typed.hpp.

References wowlib::db::schemaOf(), and wowlib::db::detail::typedProjection().


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