28#include <welder/vocabulary.hpp>
50 template <TableRecord Record>
57 static constexpr std::string_view
TableName = Record::TableName;
59 [[=welder::mark::no_reassign,
60 =welder::doc(
"The decoded records, file order. Mutate in place; write() "
61 "serializes exactly this list.")]]
67 Table(
Table&& o) noexcept :
records{std::move(o.records)}, _core{std::move(o._core)} {
80 _core = std::move(o._core);
88 [[=welder::doc(
"Decode a table file image."),
90 "nothing; raises on malformed input or a schema mismatch")]]
91 Result<void> read(std::span<const std::byte> data [[=welder::doc(
"the whole file content")]]) {
92 return _core.read(data);
100 const FileKey& key [[=welder::doc(
"the file to read")]]) {
101 return _core.read(
fs, key);
110 "Serialize the table to a file image; a loaded table re-emits "
111 "the format it was read from. `policy` decides how keyless "
112 "encrypted sections are handled."),
113 =welder::returns(
"the file bytes")]]
115 [[=welder::doc(
"keyless-section handling (WDC only)")]]
117 return _core.write(policy);
126 const FileKey& key [[=welder::doc(
"the file to write")]],
128 [[=welder::doc(
"keyless-section handling (WDC only)")]]
130 return _core.write(
fs, key, policy);
137 "The preserved string block the record string fields were decoded "
138 "from; offsets never move, write() appends new strings past its "
147 "The encrypted sections skipped on read: their records are not "
148 "in records, but the file re-writes them verbatim.")]]
150 return _core.encryptedSections();
157 "Whether the whole table decoded — false when encrypted sections "
159 bool fullyDecoded()
const {
return _core.fullyDecoded(); }
168 Check the logical integrity contracts the records must satisfy to
169 survive a write and load in the client: the primary key stays unique,
170 and no string holds an embedded NUL the string block would truncate.
171 write() never runs this.)"),
172 =welder::returns("every violated contract, in record order")]]
176 [[=welder::doc(
"Validate and raise on the first error instead of returning "
177 "a report — the assert-style face of validate()."),
178 =welder::returns(
"nothing; raises when validate() finds any error")]]
182 const TableCore&
core()
const {
return _core; }
The owning byte buffer file contents are read into.
The erased engine of one table: identity + records access + preserved decode state,...
void wire(void *recordsVec, const detail::RecordOps *ops, TableInfo info)
Point the core at its owner's records vector and identity.
A client database table: the typed records of one DBFilesClient file.
const TableCore & core() const
The erased engine (bindings and tests reach the shared machinery here).
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).
Result< void > read(fs::FileSystem &fs, const FileKey &key)
Load the table from a client filesystem.
std::vector< Record > records
The decoded records, file order.
Result< void > read(std::span< const std::byte > data)
Decode a table image.
static constexpr ClientVersion Version
The client version the record schema belongs to.
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 valida...
const formats::StringBlock & strings() const
The preserved string block the record string fields were decoded from.
Table & operator=(const Table &o)
static constexpr std::string_view TableName
The WoWDBDefs table name (e.g.
bool fullyDecoded() const
Whether every record of the file was decoded (no encrypted sections).
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 ...
Table(Table &&o) noexcept
Table & operator=(Table &&o) noexcept
Client version identity, the flavor axis that separates a client's CONTENT version from the engine ge...
The type-erased boundary between the templated Table<Record> facade (table.hpp) and the per-format co...
The error-handling vocabulary: ErrorCode, Error and the Result<T> alias every fallible wowlib operati...
File identity types: the strong FileDataID and the FileKey a read request travels as.
The runtime facade over the static compositions — the primary welder binding surface of the fs layer.
constexpr RecordOps RecordOpsFor
The RecordOps instance of Record — the entire per-record residue.
EncryptedPolicy
How write() treats a table that still holds keyless (undecryptable) encrypted sections.
@ Preserve
Re-emit the original image verbatim; edits are not applied.
consteval auto schemaOf()
The column schema of record Record, derived by reflection: one Column per member, declaration order,...
std::expected< T, Error > Result
Every fallible wowlib operation returns Result<T>; bindings translate the error branch into a target-...
The record bridge: ErasedRecordSink / ErasedRecordSource implement the non-templated RecordSink / Rec...
Schema reflection over generated client-database record structs: the column list, record stride and f...
StringBlock — the decoded representation of a chunk of zero-terminated strings (MOTX,...
The per-table identity a codec needs beyond the record data: the client version (format selection,...
TableCore + TableBase — the non-templated heart of every client-database table, and the ONE welded su...
The validation vocabulary: the severity scale, the single finding and the report validate() fills.