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

Classes

class  BitReader
 A bounds-guarded little-endian bit reader over a record's byte span. More...
class  BitWriter
 A little-endian bit writer over a record buffer — the encode counterpart of BitReader. More...
struct  Wdc1Header
 The 84-byte WDC1 top header. More...
struct  Wdc3Header
 The 72-byte WDC3 top header (WDC4 reuses it verbatim; WDC5 prepends Wdc5HeaderPrefix in front of the fields after magic). More...
struct  Wdc3SectionHeader
 The 40-byte per-section header of WDC3/WDC4/WDC5. More...
struct  Wdc5HeaderPrefix
 The 132 bytes WDC5 splices between magic and recordCount: a numeric schema version and a zero-padded schema-name string (e.g. More...
struct  WdcFieldStorage
 The 24-byte field_storage_info entry: how one column is stored. More...
struct  WdcFieldStructure
 The 4-byte fieldStructure entry: (32 - size) / 8 is the field's storage byte width, position its byte offset in a record. More...
struct  WdcImage
 A parsed WDC-family file: the (normalized) header, shared tables, and located sections. More...
struct  WdcSection
 A located, structurally-validated section. More...

Enumerations

enum  WdcFlags : std::uint16_t { WdcFlagSparse = 0x01 , WdcFlagSecondary = 0x02 , WdcFlagNoninlineId = 0x04 }
 WDC header flag bits (shared by the whole family). More...
enum class  WdcCompression : std::uint32_t {
  None = 0 , Bitpacked = 1 , CommonData = 2 , Pallet = 3 ,
  PalletArray = 4 , BitpackedSigned = 5
}
 How a column is packed (field_storage_info.storageType). More...
enum class  StringRefMode : std::uint8_t { BlockRelative , FieldRelative }
 How a record's string-reference fields address the string data. More...

Functions

constexpr bool isWdcMagic (std::uint32_t magic)
 Whether magic names a format of the WDC family this codec speaks.
Result< void > readWdc (const TableInfo &info, std::span< const std::byte > data, RecordSink &sink, TableState &state)
 Decode a WDC-family image onto the schema: every unencrypted section's records (inline fields via their compression kind, the id from the idList / an inline column / the sparse offset map, strings via the flavor's reference convention), relationship-map values onto the non-inline relation column, and copy-table rows as id-cloned records.
Result< FileBuffer > writeWdc (std::uint32_t magic, const TableInfo &info, const RecordSource &source, const TableState &state, EncryptedPolicy policy)
 Encode a canonical image of flavor magic: one unencrypted section, integers bitpacked to their minimum width, floats/string references byte-aligned, pallet/common reproduced from the original compression, a re-derived copy table, and a relationship map when the schema carries a non-inline relation column.

Variables

constexpr std::uint32_t Wdc1Magic = formats::fourcc("WDC1", formats::FourCCEndian::Forward)
 The WDC1 magic as memcpy'd off the file front (the bytes "WDC1").
constexpr std::uint32_t Wdc3Magic = formats::fourcc("WDC3", formats::FourCCEndian::Forward)
 The WDC3 magic as memcpy'd off the file front (the bytes "WDC3").
constexpr std::uint32_t Wdc4Magic = formats::fourcc("WDC4", formats::FourCCEndian::Forward)
 The WDC4 magic as memcpy'd off the file front (the bytes "WDC4").
constexpr std::uint32_t Wdc5Magic = formats::fourcc("WDC5", formats::FourCCEndian::Forward)
 The WDC5 magic as memcpy'd off the file front (the bytes "WDC5").

Enumeration Type Documentation

◆ StringRefMode

enum class wowlib::db::wdc::StringRefMode : std::uint8_t
strong

How a record's string-reference fields address the string data.

Enumerator
BlockRelative 

WDC1: offset from the string block's first byte.

FieldRelative 

WDC2+: offset from the referencing field's own position.

Definition at line 35 of file image.hpp.

◆ WdcCompression

enum class wowlib::db::wdc::WdcCompression : std::uint32_t
strong

How a column is packed (field_storage_info.storageType).

Enumerator
None 

Stored inline at a byte offset, fieldSizeBits wide.

Bitpacked 

Bit-addressed unsigned value (signed in WDC1 when the entry's flags word carries bit 0x01).

CommonData 

Sparse per-id override table; default when an id is absent.

Pallet 

Bit-addressed index into palletData (one value per slot).

PalletArray 

Bit-addressed index into palletData (array per slot).

BitpackedSigned 

Bit-addressed signed value, sign-extended (WDC2+ only; WDC1 spells it Bitpacked + flags 0x01).

Definition at line 152 of file binary.hpp.

◆ WdcFlags

enum wowlib::db::wdc::WdcFlags : std::uint16_t

WDC header flag bits (shared by the whole family).

Enumerator
WdcFlagSparse 

Offset-map layout + inline null-terminated strings.

WdcFlagSecondary 

Secondary-key data; in WDC4+ also reorders the sparse id list ahead of the relationship block.

WdcFlagNoninlineId 

The id lives in the idList, not the record.

Definition at line 52 of file binary.hpp.

Function Documentation

◆ isWdcMagic()

bool wowlib::db::wdc::isWdcMagic ( std::uint32_t magic)
constexpr

Whether magic names a format of the WDC family this codec speaks.

Parameters
magicthe file's leading four bytes.
Returns
true for WDC1/WDC3/WDC4/WDC5 (WDC2 is a BfA-beta intermediate no supported client ships).

Definition at line 47 of file binary.hpp.

References Wdc1Magic, Wdc3Magic, Wdc4Magic, and Wdc5Magic.

Referenced by wowlib::db::TableCore::read().

◆ readWdc()

Result< void > wowlib::db::wdc::readWdc ( const TableInfo & info,
std::span< const std::byte > data,
RecordSink & sink,
TableState & state )

Decode a WDC-family image onto the schema: every unencrypted section's records (inline fields via their compression kind, the id from the idList / an inline column / the sparse offset map, strings via the flavor's reference convention), relationship-map values onto the non-inline relation column, and copy-table rows as id-cloned records.

Encrypted sections are reported (state.encrypted) but not decoded, and the raw image is kept for a verbatim re-emit.

Parameters
infothe table identity + schema.
datathe whole file content (any WDC flavor; the magic decides).
sinkthe decode target.
statethe preserved-state store.
Returns
nothing, or why the image does not decode.

Definition at line 390 of file read.cpp.

References wowlib::builds::Cata, wowlib::db::RecordSink::clear(), wowlib::db::TableState::encrypted, wowlib::db::wdc::Wdc3Header::fieldCount, wowlib::db::wdc::WdcImage::fieldStorage, wowlib::db::wdc::WdcImage::header, wowlib::db::detail::inlineColumnCount(), wowlib::db::wdc::Wdc3Header::layoutHash, wowlib::db::wdc::Wdc3Header::locale, wowlib::db::wdc::WdcImage::magic, wowlib::ClientVersion::major, wowlib::makeError(), wowlib::ClientVersion::minor, wowlib::db::TableInfo::name, None, wowlib::db::wdc::WdcImage::parse(), wowlib::db::TableState::reset(), wowlib::db::TableInfo::schema, wowlib::SchemaMismatch, wowlib::db::TableState::sourceMagic, wowlib::db::wdc::Wdc3Header::tableHash, wowlib::TableMagicUnknown, wowlib::db::TableInfo::version, wowlib::db::wdc::WdcImage::wdc5, Wdc5Magic, wowlib::db::TableState::wdc5Prefix, wowlib::db::TableState::wdcKinds, wowlib::db::TableState::wdcLayoutHash, wowlib::db::TableState::wdcLocale, wowlib::db::TableState::wdcOriginal, and wowlib::db::TableState::wdcTableHash.

Referenced by wowlib::db::TableCore::read().

◆ writeWdc()

Result< FileBuffer > wowlib::db::wdc::writeWdc ( std::uint32_t magic,
const TableInfo & info,
const RecordSource & source,
const TableState & state,
EncryptedPolicy policy )

Encode a canonical image of flavor magic: one unencrypted section, integers bitpacked to their minimum width, floats/string references byte-aligned, pallet/common reproduced from the original compression, a re-derived copy table, and a relationship map when the schema carries a non-inline relation column.

Semantic round-trip (write -> re-read decodes to identical values), not byte-perfect. A table still holding keyless sections is re-emitted verbatim under EncryptedPolicy::Preserve, or written as decoded plaintext under Drop.

Parameters
magicthe flavor to emit (a loaded table passes its source magic, a fresh one its version's canonical flavor).
infothe table identity + schema.
sourcethe records to encode.
statethe preserved-state store.
policykeyless-section handling.
Returns
the file bytes, or why encoding failed.

Definition at line 664 of file write.cpp.

References wowlib::builds::Cata, wowlib::db::TableState::encrypted, wowlib::InvalidEntityState, wowlib::makeError(), wowlib::db::TableInfo::name, wowlib::NotSupported, wowlib::db::Preserve, wowlib::db::TableInfo::version, and wowlib::db::TableState::wdcOriginal.

Variable Documentation

◆ Wdc1Magic

std::uint32_t wowlib::db::wdc::Wdc1Magic = formats::fourcc("WDC1", formats::FourCCEndian::Forward)
inlineconstexpr

The WDC1 magic as memcpy'd off the file front (the bytes "WDC1").

Definition at line 32 of file binary.hpp.

Referenced by isWdcMagic(), and wowlib::db::wdc::WdcImage::parse().

◆ Wdc3Magic

std::uint32_t wowlib::db::wdc::Wdc3Magic = formats::fourcc("WDC3", formats::FourCCEndian::Forward)
inlineconstexpr

The WDC3 magic as memcpy'd off the file front (the bytes "WDC3").

Definition at line 35 of file binary.hpp.

Referenced by isWdcMagic(), and wowlib::db::wdc::WdcImage::parse().

◆ Wdc4Magic

std::uint32_t wowlib::db::wdc::Wdc4Magic = formats::fourcc("WDC4", formats::FourCCEndian::Forward)
inlineconstexpr

The WDC4 magic as memcpy'd off the file front (the bytes "WDC4").

Definition at line 38 of file binary.hpp.

Referenced by isWdcMagic(), and wowlib::db::wdc::WdcImage::parse().

◆ Wdc5Magic

std::uint32_t wowlib::db::wdc::Wdc5Magic = formats::fourcc("WDC5", formats::FourCCEndian::Forward)
inlineconstexpr

The WDC5 magic as memcpy'd off the file front (the bytes "WDC5").

Definition at line 41 of file binary.hpp.

Referenced by isWdcMagic(), wowlib::db::wdc::WdcImage::parse(), and readWdc().