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

A parsed WDC-family file: the (normalized) header, shared tables, and located sections. More...

#include <wowlib/db/wdc/image.hpp>

Public Member Functions

bool idIsNoninline () const
 Whether the id comes from the idList rather than a record field (flag 0x04); when false, the idIndex'th inline field is the id.
bool isSparse () const
 Whether this file uses the sparse offset-map layout (flag 0x01).
std::vector< std::uint32_t > fieldAdditionalOffsets () const
 The byte offset into palletData / commonData where each field's additional data begins (accumulated in field order).
std::uint64_t fieldRaw (std::size_t field, std::uint32_t element, std::uint32_t arrayCount, std::span< const std::byte > recordBytes, std::uint32_t id, const std::vector< std::uint32_t > &additional) const
 Decode array element element of inline field field for one record.
std::size_t elemBitWidth (std::size_t field, std::uint32_t arrayCount) const
 The bit width of one element of inline field field: for the inline kinds, the field's total width divided across arrayCount elements; for pallet/common the natural 32.
bool fieldIsSigned (std::size_t field) const
 Whether field field's storage is the signed bitpacked kind (after WDC1 normalization).

Static Public Member Functions

static Result< WdcImage > parse (std::span< const std::byte > data)
 Parse and structurally validate data as a WDC-family file, sniffing the flavor off the magic.

Public Attributes

std::uint32_t magic = 0
 The flavor actually parsed.
Wdc3Header header {}
 WDC1 header fields are mapped onto this.
Wdc5HeaderPrefix wdc5 {}
 Valid when magic == Wdc5Magic.
StringRefMode stringMode = StringRefMode::FieldRelative
std::span< const std::byte > file
std::vector< WdcFieldStructure > fieldStructure
std::vector< WdcFieldStorage > fieldStorage
std::span< const std::byte > palletData
std::span< const std::byte > commonData
std::vector< WdcSection > sections
std::vector< std::byte > ownedOffsetMap
 Owned backing for WDC1's normalized sparse map (filtered entries + the ids the dense map only implied).
std::vector< std::uint32_t > ownedOffsetMapIds

Detailed Description

A parsed WDC-family file: the (normalized) header, shared tables, and located sections.

The raw file span is retained so string references — which resolve to absolute file offsets — can be chased.

Definition at line 61 of file image.hpp.

Member Function Documentation

◆ elemBitWidth()

std::size_t wowlib::db::wdc::WdcImage::elemBitWidth ( std::size_t field,
std::uint32_t arrayCount ) const

The bit width of one element of inline field field: for the inline kinds, the field's total width divided across arrayCount elements; for pallet/common the natural 32.

Parameters
fieldthe field index.
arrayCountthe column's element count.
Returns
the element width in bits.

Definition at line 308 of file image.cpp.

References wowlib::db::wdc::Bitpacked, wowlib::db::wdc::BitpackedSigned, fieldStorage, and wowlib::db::wdc::None.

Referenced by fieldRaw().

◆ fieldAdditionalOffsets()

std::vector< std::uint32_t > wowlib::db::wdc::WdcImage::fieldAdditionalOffsets ( ) const

The byte offset into palletData / commonData where each field's additional data begins (accumulated in field order).

Sized like fieldStorage; entries for non-pallet/common fields are unused.

Returns
one base offset per field.

Definition at line 256 of file image.cpp.

References wowlib::db::wdc::CommonData, fieldStorage, wowlib::db::wdc::Pallet, and wowlib::db::wdc::PalletArray.

◆ fieldIsSigned()

bool wowlib::db::wdc::WdcImage::fieldIsSigned ( std::size_t field) const
inline

Whether field field's storage is the signed bitpacked kind (after WDC1 normalization).

Parameters
fieldthe field index.
Returns
true when decoded values must be sign-extended.

Definition at line 130 of file image.hpp.

References wowlib::db::wdc::BitpackedSigned, and fieldStorage.

◆ fieldRaw()

std::uint64_t wowlib::db::wdc::WdcImage::fieldRaw ( std::size_t field,
std::uint32_t element,
std::uint32_t arrayCount,
std::span< const std::byte > recordBytes,
std::uint32_t id,
const std::vector< std::uint32_t > & additional ) const

Decode array element element of inline field field for one record.

Parameters
fieldthe column index into fieldStorage.
elementthe array element (0 for scalars).
arrayCountthe column's element count (1 for scalars) — for the inline kinds fieldSizeBits is the field's TOTAL width, split evenly across elements.
recordBytesthe record's byte span (fieldOffsetBits is relative to its start).
idthe record's id (common-data lookups key on it).
additionalfieldAdditionalOffsets() (pallet/common bases).
Returns
the raw field bits, zero-extended; the caller sign-extends signed columns using elemBitWidth().

Definition at line 273 of file image.cpp.

References wowlib::db::wdc::Bitpacked, wowlib::db::wdc::BitpackedSigned, wowlib::db::wdc::CommonData, elemBitWidth(), fieldStorage, wowlib::db::wdc::None, wowlib::db::wdc::Pallet, wowlib::db::wdc::PalletArray, and wowlib::db::wdc::BitReader::read().

◆ idIsNoninline()

bool wowlib::db::wdc::WdcImage::idIsNoninline ( ) const
inline

Whether the id comes from the idList rather than a record field (flag 0x04); when false, the idIndex'th inline field is the id.

Definition at line 85 of file image.hpp.

References header, and wowlib::db::wdc::WdcFlagNoninlineId.

◆ isSparse()

bool wowlib::db::wdc::WdcImage::isSparse ( ) const
inline

Whether this file uses the sparse offset-map layout (flag 0x01).

Definition at line 90 of file image.hpp.

References header, and wowlib::db::wdc::WdcFlagSparse.

◆ parse()

Result< WdcImage > wowlib::db::wdc::WdcImage::parse ( std::span< const std::byte > data)
static

Parse and structurally validate data as a WDC-family file, sniffing the flavor off the magic.

Parameters
datathe whole file content.
Returns
the located image, or why the structure does not close.

Definition at line 28 of file image.cpp.

References magic, wowlib::makeError(), wowlib::TableMagicUnknown, wowlib::db::wdc::Wdc1Magic, wowlib::db::wdc::Wdc3Magic, wowlib::db::wdc::Wdc4Magic, and wowlib::db::wdc::Wdc5Magic.

Referenced by wowlib::db::wdc::readWdc().

Member Data Documentation

◆ commonData

std::span<const std::byte> wowlib::db::wdc::WdcImage::commonData

Definition at line 70 of file image.hpp.

◆ fieldStorage

std::vector<WdcFieldStorage> wowlib::db::wdc::WdcImage::fieldStorage

◆ fieldStructure

std::vector<WdcFieldStructure> wowlib::db::wdc::WdcImage::fieldStructure

Definition at line 67 of file image.hpp.

◆ file

std::span<const std::byte> wowlib::db::wdc::WdcImage::file

Definition at line 66 of file image.hpp.

◆ header

Wdc3Header wowlib::db::wdc::WdcImage::header {}

WDC1 header fields are mapped onto this.

Definition at line 63 of file image.hpp.

Referenced by idIsNoninline(), isSparse(), and wowlib::db::wdc::readWdc().

◆ magic

std::uint32_t wowlib::db::wdc::WdcImage::magic = 0

The flavor actually parsed.

Definition at line 62 of file image.hpp.

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

◆ ownedOffsetMap

std::vector<std::byte> wowlib::db::wdc::WdcImage::ownedOffsetMap

Owned backing for WDC1's normalized sparse map (filtered entries + the ids the dense map only implied).

sections[0] spans alias into these.

Definition at line 74 of file image.hpp.

◆ ownedOffsetMapIds

std::vector<std::uint32_t> wowlib::db::wdc::WdcImage::ownedOffsetMapIds

Definition at line 75 of file image.hpp.

◆ palletData

std::span<const std::byte> wowlib::db::wdc::WdcImage::palletData

Definition at line 69 of file image.hpp.

◆ sections

std::vector<WdcSection> wowlib::db::wdc::WdcImage::sections

Definition at line 71 of file image.hpp.

◆ stringMode

StringRefMode wowlib::db::wdc::WdcImage::stringMode = StringRefMode::FieldRelative

Definition at line 65 of file image.hpp.

◆ wdc5

Wdc5HeaderPrefix wowlib::db::wdc::WdcImage::wdc5 {}

Valid when magic == Wdc5Magic.

Definition at line 64 of file image.hpp.

Referenced by wowlib::db::wdc::readWdc().


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