36#include <welder/vocabulary.hpp>
96 return _state.encrypted;
113 std::uint32_t _db2MagicForVersion()
const;
117 void* _vec =
nullptr;
133 =welder::doc(
"The common surface of every client-database table: decode "
134 "(read), encode (write), validation, and the preserved decode "
135 "state. Concrete tables add their typed records.")]]
TableBase {
137 [[=welder::doc(
"Decode a table file image."),
139 "nothing; raises on malformed input or a schema mismatch")]]
140 Result<void> read(std::span<const std::byte> data [[=welder::doc(
"the whole file content")]]) {
141 return _core.read(data);
144 [[=welder::doc(
"Load the table from a client filesystem."),
145 =welder::returns(
"nothing; raises when loading fails")]]
147 const FileKey& key [[=welder::doc(
"the file to read")]]) {
152 "Serialize the table to a file image; a loaded table re-emits "
153 "the format it was read from. `policy` decides how keyless "
154 "encrypted sections are handled."),
155 =welder::returns(
"the file bytes")]]
157 [[=welder::doc(
"keyless-section handling (WDC only)")]]
159 return _core.write(policy);
162 [[=welder::doc(
"Serialize the table into a client filesystem (project "
163 "overlay); the target path's extension picks .dbc/.db2 in "
165 =welder::returns(
"nothing; raises when saving fails")]]
167 const FileKey& key [[=welder::doc(
"the file to write")]],
169 [[=welder::doc(
"keyless-section handling (WDC only)")]]
171 return _core.write(
fs, key, policy);
176 "The preserved string block the record string fields were decoded "
177 "from; offsets never move, write() appends new strings past its "
183 "The encrypted sections skipped on read: their records are not "
184 "in records, but the file re-writes them verbatim.")]]
191 "Whether the whole table decoded — false when encrypted sections "
197 Check the logical integrity contracts the records must satisfy to
198 survive a write and load in the client: the primary key stays unique,
199 and no string holds an embedded NUL the string block would truncate.
200 write() never runs this.)"),
201 =welder::returns("every violated contract, in record order")]]
205 [[=welder::doc(
"Validate and raise on the first error instead of returning "
206 "a report — the assert-style face of validate()."),
207 =welder::returns(
"nothing; raises when validate() finds any error")]]
208 Result<void> ensureValid()
const {
return _core.ensureValid(); }
213 [[=welder::mark::exclude]]
214 const TableCore& core()
const {
return _core; }
The owning byte buffer file contents are read into.
The decode target: the codecs build the record vector through this, one field at a time.
The encode source: the codecs read the record vector through this.
The welded supertype of every generated table class: the whole table surface — decode,...
bool fullyDecoded() const
Whether the whole table decoded — false when encrypted sections were skipped.
const TableCore & core() const
The erased engine (bindings build live record views off it).
Result< void > read(fs::FileSystem &fs, const FileKey &key)
Load the table from a client filesystem.
formats::ValidationReport validate() const
const formats::StringBlock & strings() const
The preserved string block the record string fields were decoded from; offsets never move,...
Result< void > ensureValid() const
Validate and raise on the first error instead of returning a report — the assert-style face of valida...
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 ....
const std::vector< EncryptedSection > & encryptedSections() const
The encrypted sections skipped on read: their records are not in records, but the file re-writes them...
Result< void > read(std::span< const std::byte > data)
Decode a table file image.
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.
The erased engine of one table: identity + records access + preserved decode state,...
Result< FileBuffer > write(EncryptedPolicy policy) const
void wire(void *recordsVec, const detail::RecordOps *ops, TableInfo info)
Point the core at its owner's records vector and identity.
const TableInfo & info() const
The identity the codecs work from (empty-schema when unwired).
void * recordsVec() const
The owner's records vector + access facts (bindings use these to build live record views without re-t...
Result< void > read(std::span< const std::byte > data)
Result< void > ensureValid() const
const detail::RecordOps * ops() const
formats::ValidationReport validate() const
bool fullyDecoded() const
void rewire(RecordSink *sink, const RecordSource *source)
The external-wiring twin of rewire.
const std::vector< EncryptedSection > & encryptedSections() const
void rewire(void *recordsVec)
Re-point at the owner's vector after the owner was copied/moved (state and identity travel with the c...
void wire(RecordSink *sink, const RecordSource *source, TableInfo info)
Point the core at an EXTERNAL sink/source pair instead of a typed records vector — the generic column...
const formats::StringBlock & strings() const
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.
EncryptedPolicy
How write() treats a table that still holds keyless (undecryptable) encrypted sections.
@ Preserve
Re-emit the original image verbatim; edits are not applied.
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...
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,...
The one thing that stays per-record: a table of thunks over the record VECTOR (only they know sizeof(...
The validation vocabulary: the severity scale, the single finding and the report validate() fills.