55 void clear()
override;
56 void reserve(std::size_t n)
override;
57 std::size_t
add()
override;
59 std::size_t
size()
const override;
60 std::uint32_t
idOf(std::size_t record)
const override;
61 void setInt(std::size_t record, std::size_t column, std::size_t element, std::int64_t value)
override;
62 void setFloat(std::size_t record, std::size_t column, std::size_t element,
float value)
override;
63 void setString(std::size_t record, std::size_t column, std::size_t element, std::string_view value)
override;
64 void cloneWithId(std::size_t src, std::uint32_t newId)
override;
65 std::size_t
findById(std::uint32_t
id)
const override;
68 std::int64_t
getInt(std::size_t record, std::size_t column, std::size_t element)
const override;
69 std::uint32_t
getSlot(std::size_t record, std::size_t column, std::size_t element)
const override;
70 std::string_view
getString(std::size_t record, std::size_t column, std::size_t element)
const override;
77 std::string&
stringSlot(std::size_t record, std::size_t column, std::size_t element);
80 std::uint32_t&
flagsSlot(std::size_t record, std::size_t column);
81 std::uint32_t
flagsSlot(std::size_t record, std::size_t column)
const;
93 const Facts&
facts(std::size_t column)
const {
return _facts[column]; }
99 std::span<const std::byte>
podBytes(std::size_t column)
const {
100 return _cols[column].pod;
104 std::span<const Column>
schema()
const {
return _schema; }
109 std::vector<std::byte> pod;
110 std::vector<std::string> strs;
111 std::vector<std::uint32_t> flags;
115 std::byte* _podPtr(std::size_t record, std::size_t column, std::size_t element);
116 const std::byte* _podPtr(std::size_t record, std::size_t column, std::size_t element)
const;
118 std::span<const Column> _schema{};
119 std::vector<Facts> _facts{};
120 std::vector<Store> _cols{};
121 std::size_t _rows = 0;
122 std::size_t _idColumn = SIZE_MAX;
149 =welder::weld_as(
"Table"),
151 A client-database table with its schema resolved at RUNTIME from
152 WoWDBDefs data: open any table of any targeted client era, read its
153 rows, edit cells by (row, column, element), and write it back in the
154 era's own format. Cells are addressed by column index (see
155 column_index/column_info); scalar columns also expose zero-copy
163#if WOWLIB_DB_SCHEMA_EMBEDDED
170 [[=welder::doc(
"Open an empty table by name, with its schema resolved "
171 "for the given client version from the built-in WoWDBDefs "
173 =welder::returns(
"the empty, schema-bound table; raises for an unknown "
174 "table or an uncovered client era")]]
175 static Result<DynTable> open(std::string_view table [[=welder::doc(
"the table name, e.g. \"Map\"")]],
186 [[=welder::mark::exclude]]
196 [[=welder::getter, =welder::doc(
"The number of rows.")]]
197 std::size_t
rowCount()
const {
return _rows.size(); }
200 [[=welder::getter, =welder::doc(
"The number of schema columns.")]]
201 std::size_t
columnCount()
const {
return _rows.schema().size(); }
204 [[=welder::mark::exclude]]
205 std::span<const Column> schema()
const {
return _rows.schema(); }
208 [[=welder::getter, =welder::doc(
209 "The client version the table serializes for.")]]
213 [[=welder::getter, =welder::doc(
"The table name (WoWDBDefs identifier).")]]
214 std::string_view name()
const {
return _name; }
220 [[=welder::doc(
"The schema entry of one column: name, value class, "
221 "shape and key roles."),
222 =welder::returns(
"the column description; raises when out of range")]]
223 Result<Column> columnInfo(std::size_t column [[=welder::doc(
"the column index")]])
const;
230 [[=welder::doc(
"The index of the column with the given name: the "
231 "canonical snake_case spelling ('map_name'), or the verbatim "
232 "WoWDBDefs spelling ('MapName_lang') as an alias; case-sensitive "
234 =welder::returns(
"the column index; raises when no column matches")]]
239 [[=welder::doc(
"Append a fresh zero/empty row."),
240 =welder::returns(
"the new row's index")]]
241 std::size_t
appendRow() {
return _rows.add(); }
246 [[=welder::doc(
"Remove one row."),
247 =welder::returns(
"nothing; raises when the row is out of range")]]
252 "Drop every row (the schema and preserved decode state stay).")]]
259 [[=welder::doc(
"The first row whose $id$ column equals the given key."),
260 =welder::returns(
"the row index; raises when no row matches")]]
261 Result<std::size_t> findById(std::uint32_t
id [[=welder::doc(
"the primary key value")]])
const;
269 [[=welder::doc(
"Read an integer cell, sign-extended from the column's "
270 "exact width. LocString flags read via locstring_flags."),
271 =welder::returns(
"the value; raises on a non-Int column or an "
272 "out-of-range index")]]
274 std::size_t column [[=welder::doc(
"an Int column's index")]],
275 std::size_t element [[=welder::doc(
"the array element")]] = 0)
const;
280 [[=welder::doc(
"Write an integer cell (truncates to the column's exact "
281 "width, exactly as the typed member assignment did)."),
282 =welder::returns(
"nothing; raises on a non-Int column or an "
283 "out-of-range index")]]
284 Result<void> setInt(std::size_t row [[=welder::doc(
"the row index")]],
285 std::size_t column [[=welder::doc(
"an Int column's index")]],
286 std::int64_t value [[=welder::doc(
"the value to store")]],
287 std::size_t element [[=welder::doc(
"the array element")]] = 0);
290 [[=welder::doc(
"Read a float cell."),
291 =welder::returns(
"the value; raises on a non-Float column or an "
292 "out-of-range index")]]
293 Result<float> getFloat(std::size_t row [[=welder::doc(
"the row index")]],
294 std::size_t column [[=welder::doc(
"a Float column's index")]],
295 std::size_t element [[=welder::doc(
"the array element")]] = 0)
const;
297 [[=welder::doc(
"Write a float cell."),
298 =welder::returns(
"nothing; raises on a non-Float column or an "
299 "out-of-range index")]]
300 Result<void> setFloat(std::size_t row [[=welder::doc(
"the row index")]],
301 std::size_t column [[=welder::doc(
"a Float column's index")]],
302 float value [[=welder::doc(
"the value to store")]],
303 std::size_t element [[=welder::doc(
"the array element")]] = 0);
310 [[=welder::doc(
"Read a string cell (String columns: the array element; "
311 "LocString columns: the locale slot)."),
312 =welder::returns(
"the text; raises on a non-string column or an "
313 "out-of-range index")]]
315 std::size_t column [[=welder::doc(
"a String/LocString column's index")]],
316 std::size_t element [[=welder::doc(
"the array element / locale slot")]] = 0)
319 [[=welder::doc(
"Write a string cell (String columns: the array element; "
320 "LocString columns: the locale slot)."),
321 =welder::returns(
"nothing; raises on a non-string column or an "
322 "out-of-range index")]]
323 Result<void> setString(std::size_t row [[=welder::doc(
"the row index")]],
324 std::size_t column [[=welder::doc(
"a String/LocString column's index")]],
325 std::string_view value [[=welder::doc(
"the text to store")]],
326 std::size_t element [[=welder::doc(
"the array element / locale slot")]] = 0);
329 [[=welder::doc(
"Read a LocString column's flags word."),
330 =welder::returns(
"the flags; raises on a non-LocString column")]]
332 std::size_t column [[=welder::doc(
"a LocString column's index")]])
const;
334 [[=welder::doc(
"Write a LocString column's flags word."),
335 =welder::returns(
"nothing; raises on a non-LocString column")]]
336 Result<void> setLocstringFlags(std::size_t row [[=welder::doc(
"the row index")]],
337 std::size_t column [[=welder::doc(
"a LocString column's index")]],
338 std::uint32_t flags [[=welder::doc(
"the flags word")]]);
343 [[=welder::mark::exclude]]
349 _core.wire(&_rows, &_rows,
TableInfo{_version, _diskName, _rows.schema()});
358 detail::ColumnRows _rows{};
359 ClientVersion _version{};
360 std::string_view _name;
361 std::string_view _diskName;
Result< void > setString(std::size_t row, std::size_t column, std::string_view value, std::size_t element=0)
Write a string element.
Result< Column > columnInfo(std::size_t column) const
Column column's schema entry, by value (the welded metadata face of schema).
static DynTable fromSchema(const TableSchema &schema, ClientVersion version)
Open a table over an explicitly resolved schema — the caller guarantees the schema's backing catalog ...
Result< std::string_view > getString(std::size_t row, std::size_t column, std::size_t element=0) const
Read a string element (String columns: the array element; LocString columns: the locale slot).
Result< void > setFloat(std::size_t row, std::size_t column, float value, std::size_t element=0)
Write a float element.
std::size_t rowCount() const
The number of rows.
Result< PodColumnView > podColumn(std::size_t column) const
The zero-copy view of numeric/float column column.
Result< std::int64_t > getInt(std::size_t row, std::size_t column, std::size_t element=0) const
Read an integer element.
Result< std::uint32_t > locstringFlags(std::size_t row, std::size_t column) const
Read a LocString column's flags word.
std::string_view name() const
The table name (WoWDBDefs identifier).
Result< void > setLocstringFlags(std::size_t row, std::size_t column, std::uint32_t flags)
Write a LocString column's flags word.
DynTable()=default
An unwired table: every inherited operation reports InvalidEntityState until one is opened properly.
void clearRows()
Drop every row (schema and preserved decode state stay).
Result< void > eraseRow(std::size_t row)
Remove row row.
Result< void > setInt(std::size_t row, std::size_t column, std::int64_t value, std::size_t element=0)
Write an integer element (truncates to the column's exact width, as the typed member assignment did).
Result< float > getFloat(std::size_t row, std::size_t column, std::size_t element=0) const
Read a float element.
std::size_t columnCount() const
The number of schema columns.
DynTable & operator=(const DynTable &other)
std::span< const Column > schema() const
ClientVersion version() const
The client version the table serializes for.
std::size_t appendRow()
Append a fresh zero/empty row.
Result< std::size_t > columnIndex(std::string_view name) const
The index of column name.
Result< std::size_t > findById(std::uint32_t id) const
The first row whose $id$ equals id.
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,...
void wire(void *recordsVec, const detail::RecordOps *ops, TableInfo info)
Point the core at its owner's records vector and identity.
std::uint32_t getSlot(std::size_t record, std::size_t column, std::size_t element) const override
std::size_t size() const override
One override serves both interfaces (identical signatures).
std::size_t findById(std::uint32_t id) const override
The first record whose id equals id, or size() when none (copy source lookup).
void setInt(std::size_t record, std::size_t column, std::size_t element, std::int64_t value) override
std::int64_t getInt(std::size_t record, std::size_t column, std::size_t element) const override
std::string_view getString(std::size_t record, std::size_t column, std::size_t element) const override
std::uint32_t & flagsSlot(std::size_t record, std::size_t column)
The LocString flags of record in column.
std::span< const std::byte > podBytes(std::size_t column) const
The whole POD buffer of column column (row-major, exact width) — the zero-copy view the bindings expo...
void setFloat(std::size_t record, std::size_t column, std::size_t element, float value) override
const Facts & facts(std::size_t column) const
void cloneWithId(std::size_t src, std::uint32_t newId) override
Clone record src into a fresh record and set its id column to newId (WDC copy-table materialization).
void reserve(std::size_t n) override
void setString(std::size_t record, std::size_t column, std::size_t element, std::string_view value) override
std::uint32_t idOf(std::size_t record) const override
std::size_t add() override
std::span< const Column > schema() const
std::string & stringSlot(std::size_t record, std::size_t column, std::size_t element)
Mutable string slot access (the public setter's target).
void eraseRow(std::size_t record)
Remove row record (all columns' slices).
Client version identity, the flavor axis that separates a client's CONTENT version from the engine ge...
The error-handling vocabulary: ErrorCode, Error and the Result<T> alias every fallible wowlib operati...
AccessKind
The storage kind of one record member, as the erased accessors see it: exact width and signedness for...
ColumnType
The logical value class of a column.
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...
The runtime schema source of the generic ClientDB engine: table name + client version in,...
A scalar column's whole storage, for zero-copy array views: the raw exact-width buffer plus the facts...
std::span< const std::byte > bytes
The buffer, row-major.
bool isFloat
float32 elements.
bool isSigned
Integer signedness.
std::uint16_t elemsPerRow
Array length (1 = scalar).
std::uint8_t elemBytes
element width in bytes.
The per-table identity a codec needs beyond the record data: the client version (format selection,...
One resolved (table, client version) schema: what SchemaCatalog::lookup hands the engine.
The per-column access facts, derived from the schema at bind.
std::uint8_t elemBytes
POD element width; 0 for strings.
AccessKind kind
The element storage kind.
bool hasFlags
LocString: a flags word per row.
std::uint16_t strSlots
String slots per row.
std::uint16_t podSlots
POD elements per row (arrayLen).
TableCore + TableBase — the non-templated heart of every client-database table, and the ONE welded su...