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

The generic client-database table: schema resolved at runtime from the schema catalog, rows in a column store, format engine and preserved decode state inherited from TableBase (read/write/validate/strings/ encryptedSections all bind once, there). More...

#include <wowlib/db/dyn_table.hpp>

Inheritance diagram for wowlib::db::DynTable:

Public Member Functions

 DynTable ()=default
 An unwired table: every inherited operation reports InvalidEntityState until one is opened properly.
 DynTable (const DynTable &other)
DynTable & operator= (const DynTable &other)
 DynTable (DynTable &&other) noexcept
DynTable & operator= (DynTable &&other) noexcept
 ~DynTable ()=default
std::size_t rowCount () const
 The number of rows.
std::size_t columnCount () const
 The number of schema columns.
std::span< const Column > schema () const
ClientVersion version () const
 The client version the table serializes for.
std::string_view name () const
 The table name (WoWDBDefs identifier).
Result< Column > columnInfo (std::size_t column) const
 Column column's schema entry, by value (the welded metadata face of schema).
Result< std::size_t > columnIndex (std::string_view name) const
 The index of column name.
std::size_t appendRow ()
 Append a fresh zero/empty row.
Result< void > eraseRow (std::size_t row)
 Remove row row.
void clearRows ()
 Drop every row (schema and preserved decode state stay).
Result< std::size_t > findById (std::uint32_t id) const
 The first row whose $id$ equals id.
Result< std::int64_t > getInt (std::size_t row, std::size_t column, std::size_t element=0) const
 Read an integer element.
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.
Result< void > setFloat (std::size_t row, std::size_t column, float value, std::size_t element=0)
 Write a float element.
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 > setString (std::size_t row, std::size_t column, std::string_view value, std::size_t element=0)
 Write a string element.
Result< std::uint32_t > locstringFlags (std::size_t row, std::size_t column) const
 Read a LocString column's flags word.
Result< void > setLocstringFlags (std::size_t row, std::size_t column, std::uint32_t flags)
 Write a LocString column's flags word.
Result< PodColumnView > podColumn (std::size_t column) const
 The zero-copy view of numeric/float column column.
Public Member Functions inherited from wowlib::db::TableBase
Result< void > read (std::span< const std::byte > data)
 Decode a table file 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 to a file image; a loaded table re-emits the format it was read from.
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 .dbc/.db2 in the mixed eras.
const formats::StringBlock & strings () const
 The preserved string block the record string fields were decoded from; offsets never move, write() appends new strings past its end.
const std::vector< EncryptedSection > & encryptedSections () const
 The encrypted sections skipped on read: their records are not in records, but the file re-writes them verbatim.
bool fullyDecoded () const
 Whether the whole table decoded — false when encrypted sections were skipped.
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 build live record views off it).

Static Public Member Functions

static DynTable fromSchema (const TableSchema &schema, ClientVersion version)
 Open a table over an explicitly resolved schema — the caller guarantees the schema's backing catalog outlives the table (the embedded catalog does so trivially; a runtime-loaded one is the caller's to keep).

Additional Inherited Members

Protected Attributes inherited from wowlib::db::TableBase
TableCore _core

Detailed Description

The generic client-database table: schema resolved at runtime from the schema catalog, rows in a column store, format engine and preserved decode state inherited from TableBase (read/write/validate/strings/ encryptedSections all bind once, there).

Copy/move re-wire the inherited core at the new storage — the same contract every generated table honored.

Definition at line 147 of file dyn_table.hpp.

Constructor & Destructor Documentation

◆ DynTable() [1/3]

wowlib::db::DynTable::DynTable ( )
default

An unwired table: every inherited operation reports InvalidEntityState until one is opened properly.

References DynTable(), schema(), and version().

Referenced by DynTable(), DynTable(), DynTable(), fromSchema(), operator=(), and operator=().

◆ DynTable() [2/3]

wowlib::db::DynTable::DynTable ( const DynTable & other)

Definition at line 331 of file dyn_table.cpp.

References DynTable().

◆ DynTable() [3/3]

wowlib::db::DynTable::DynTable ( DynTable && other)
noexcept

Definition at line 347 of file dyn_table.cpp.

References DynTable().

◆ ~DynTable()

wowlib::db::DynTable::~DynTable ( )
default

Member Function Documentation

◆ appendRow()

std::size_t wowlib::db::DynTable::appendRow ( )
inline

Append a fresh zero/empty row.

Returns
the new row's index. Append a fresh zero/empty row.
the new row's index

Definition at line 229 of file dyn_table.hpp.

◆ clearRows()

void wowlib::db::DynTable::clearRows ( )
inline

Drop every row (schema and preserved decode state stay).

Drop every row (the schema and preserved decode state stay).

Definition at line 242 of file dyn_table.hpp.

◆ columnCount()

std::size_t wowlib::db::DynTable::columnCount ( ) const
inline

The number of schema columns.

Returns
the number of schema columns.

Definition at line 189 of file dyn_table.hpp.

◆ columnIndex()

Result< std::size_t > wowlib::db::DynTable::columnIndex ( std::string_view name) const

The index of column name.

Parameters
namethe column name — the canonical snake_case spelling ("map_name") or the verbatim WoWDBDefs spelling ("MapName_lang") as an alias; case-sensitive either way.
Returns
the index, or TableUnknown when the schema has no such column. The index of the column with the given name: the canonical snake_case spelling ('map_name'), or the verbatim WoWDBDefs spelling ('MapName_lang') as an alias; case-sensitive either way.
the column index; raises when no column matches
Parameters
namethe column name, case-sensitive

Definition at line 375 of file dyn_table.cpp.

References wowlib::makeError(), name(), schema(), and wowlib::TableUnknown.

◆ columnInfo()

Result< Column > wowlib::db::DynTable::columnInfo ( std::size_t column) const

Column column's schema entry, by value (the welded metadata face of schema).

Parameters
columnthe column index.
Returns
the Column, or OffsetOutOfBounds. The schema entry of one column: name, value class, shape and key roles.
the column description; raises when out of range
Parameters
columnthe column index

Definition at line 367 of file dyn_table.cpp.

References wowlib::makeError(), wowlib::OffsetOutOfBounds, and schema().

◆ eraseRow()

Result< void > wowlib::db::DynTable::eraseRow ( std::size_t row)

Remove row row.

Parameters
rowthe row index.
Returns
nothing; OffsetOutOfBounds when row is out of range. Remove one row.
nothing; raises when the row is out of range
Parameters
rowthe row index

Definition at line 387 of file dyn_table.cpp.

References wowlib::makeError(), and wowlib::OffsetOutOfBounds.

◆ findById()

Result< std::size_t > wowlib::db::DynTable::findById ( std::uint32_t id) const

The first row whose $id$ equals id.

Parameters
idthe primary key value.
Returns
the row index; TableUnknown when no row matches or the schema has no $id$ column. The first row whose $id$ column equals the given key.
the row index; raises when no row matches
Parameters
idthe primary key value

Definition at line 395 of file dyn_table.cpp.

References wowlib::makeError(), and wowlib::TableUnknown.

◆ fromSchema()

DynTable wowlib::db::DynTable::fromSchema ( const TableSchema & schema,
ClientVersion version )
static

Open a table over an explicitly resolved schema — the caller guarantees the schema's backing catalog outlives the table (the embedded catalog does so trivially; a runtime-loaded one is the caller's to keep).

Parameters
schemathe resolved schema views.
versionthe client version the table serializes for.
Returns
the empty, schema-bound table.

Definition at line 321 of file dyn_table.cpp.

References DynTable(), schema(), and version().

◆ getFloat()

Result< float > wowlib::db::DynTable::getFloat ( std::size_t row,
std::size_t column,
std::size_t element = 0 ) const

Read a float element.

Read a float cell.

Returns
the value; raises on a non-Float column or an out-of-range index
Parameters
rowthe row index
columna Float column's index
elementthe array element

Definition at line 437 of file dyn_table.cpp.

References wowlib::db::Float.

◆ getInt()

Result< std::int64_t > wowlib::db::DynTable::getInt ( std::size_t row,
std::size_t column,
std::size_t element = 0 ) const

Read an integer element.

LocString columns answer their FLAGS word through locstringFlags, not here.

Parameters
rowthe row index.
columnan Int column's index.
elementthe array element (0 for scalars).
Returns
the value, sign-extended from the column's exact width. Read an integer cell, sign-extended from the column's exact width. LocString flags read via locstring_flags.
the value; raises on a non-Int column or an out-of-range index
Parameters
rowthe row index
columnan Int column's index
elementthe array element

Definition at line 425 of file dyn_table.cpp.

References wowlib::db::Int.

◆ getString()

Result< std::string_view > wowlib::db::DynTable::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).

The view is valid until the cell mutates.

Parameters
rowthe row index.
columna String/LocString column's index.
elementthe array element / locale slot. Read a string cell (String columns: the array element; LocString columns: the locale slot).
Returns
the text; raises on a non-string column or an out-of-range index
Parameters
rowthe row index
columna String/LocString column's index
elementthe array element / locale slot

Definition at line 452 of file dyn_table.cpp.

References wowlib::db::LocString, and wowlib::db::String.

◆ locstringFlags()

Result< std::uint32_t > wowlib::db::DynTable::locstringFlags ( std::size_t row,
std::size_t column ) const

Read a LocString column's flags word.

Read a LocString column's flags word.

Returns
the flags; raises on a non-LocString column
Parameters
rowthe row index
columna LocString column's index

Definition at line 472 of file dyn_table.cpp.

References wowlib::db::LocString.

◆ name()

std::string_view wowlib::db::DynTable::name ( ) const
inline

The table name (WoWDBDefs identifier).

Returns
the identifier name the table was opened as.

Definition at line 200 of file dyn_table.hpp.

Referenced by columnIndex().

◆ operator=() [1/2]

DynTable & wowlib::db::DynTable::operator= ( const DynTable & other)

Definition at line 336 of file dyn_table.cpp.

References DynTable().

◆ operator=() [2/2]

DynTable & wowlib::db::DynTable::operator= ( DynTable && other)
noexcept

Definition at line 356 of file dyn_table.cpp.

References DynTable().

◆ podColumn()

◆ rowCount()

std::size_t wowlib::db::DynTable::rowCount ( ) const
inline

The number of rows.

Returns
the number of rows.

Definition at line 185 of file dyn_table.hpp.

◆ schema()

std::span< const Column > wowlib::db::DynTable::schema ( ) const
inline
Returns
the resolved schema (owner-guaranteed lifetime).

Definition at line 192 of file dyn_table.hpp.

Referenced by columnIndex(), columnInfo(), DynTable(), fromSchema(), and podColumn().

◆ setFloat()

Result< void > wowlib::db::DynTable::setFloat ( std::size_t row,
std::size_t column,
float value,
std::size_t element = 0 )

Write a float element.

Write a float cell.

Returns
nothing; raises on a non-Float column or an out-of-range index
Parameters
rowthe row index
columna Float column's index
valuethe value to store
elementthe array element

Definition at line 446 of file dyn_table.cpp.

References wowlib::db::Float.

◆ setInt()

Result< void > wowlib::db::DynTable::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).

LocString columns answer their FLAGS word through locstringFlags, not here.

Parameters
rowthe row index.
columnan Int column's index.
elementthe array element (0 for scalars).
Returns
the value, sign-extended from the column's exact width. Read an integer cell, sign-extended from the column's exact width. LocString flags read via locstring_flags.
the value; raises on a non-Int column or an out-of-range index
Parameters
rowthe row index
columnan Int column's index
elementthe array element Write an integer cell (truncates to the column's exact width, exactly as the typed member assignment did).
Returns
nothing; raises on a non-Int column or an out-of-range index
Parameters
rowthe row index
columnan Int column's index
valuethe value to store
elementthe array element

Definition at line 431 of file dyn_table.cpp.

References wowlib::db::Int.

◆ setLocstringFlags()

Result< void > wowlib::db::DynTable::setLocstringFlags ( std::size_t row,
std::size_t column,
std::uint32_t flags )

Write a LocString column's flags word.

Write a LocString column's flags word.

Returns
nothing; raises on a non-LocString column
Parameters
rowthe row index
columna LocString column's index
flagsthe flags word

Definition at line 478 of file dyn_table.cpp.

References wowlib::db::LocString.

◆ setString()

Result< void > wowlib::db::DynTable::setString ( std::size_t row,
std::size_t column,
std::string_view value,
std::size_t element = 0 )

Write a string element.

Write a string cell (String columns: the array element; LocString columns: the locale slot).

Returns
nothing; raises on a non-string column or an out-of-range index
Parameters
rowthe row index
columna String/LocString column's index
valuethe text to store
elementthe array element / locale slot

Definition at line 461 of file dyn_table.cpp.

References wowlib::db::LocString, and wowlib::db::String.

◆ version()

ClientVersion wowlib::db::DynTable::version ( ) const
inline

The client version the table serializes for.

Returns
the client version the table serializes for.

Definition at line 196 of file dyn_table.hpp.

Referenced by DynTable(), and fromSchema().


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