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

Classes

struct  ColumnAccess
 Everything the erased core needs to touch one column of a record: where it lives, what it is, and how its array elements stride. More...
class  ColumnRows
 The column-store row storage: one exact-width POD buffer per numeric column, one string vector per string-bearing column, one flags vector per LocString column — implementing both codec interfaces over them. More...
struct  ElementTraits
 Trait: the element type / extent of a member — unwraps std::array. More...
struct  ElementTraits< std::array< T, N > >
struct  FixedString
 A compile-time string NTTP (the column<"id">() spelling). More...
struct  IdSpec
 Stored form of id: the member is the table's primary key ($id$). More...
struct  LocstringTraits
 Trait: is T a LocString<N>? More...
struct  LocstringTraits< LocString< N > >
struct  NoninlineSpec
 Stored form of noninline: the member holds no bytes inside the record image — its values come from a satellite block (the WDC id list for ids, the relationship block for relations). More...
struct  RecordOps
 The one thing that stays per-record: a table of thunks over the record VECTOR (only they know sizeof(Record)) plus the access table above. More...
struct  RelationSpec
 Stored form of relation: the member is a relationship key referencing the parent table's id ($relation$). More...
struct  StringPool
 A writable string block resolving values to byte-perfect offsets: the journaled original offset while the value still matches, else an equal existing entry, else a fresh append. More...
struct  TypedMismatch
 The consteval-validation failure carrier: throwing it inside constant evaluation aborts compilation with the message in the diagnostic. More...

Enumerations

enum class  AccessKind : std::uint8_t {
  I8 , U8 , I16 , U16 ,
  I32 , U32 , I64 , U64 ,
  F32 , Str , LocStr
}
 The storage kind of one record member, as the erased accessors see it: exact width and signedness for integers (the store must truncate the codec's int64 exactly as the typed member assignment did), float, std::string, or LocString. More...

Functions

std::size_t recordStride (std::span< const Column > schema)
 The fixed record stride (WDBC/WDB2) of schema.
std::uint32_t fieldSlotCount (std::span< const Column > schema)
 The expanded on-disk field-slot count of schema (WDBC/WDB2 fieldCount).
std::size_t stringSlotCount (std::span< const Column > schema)
 The per-record string-reference count of schema (the offset journal width).
std::size_t inlineColumnCount (std::span< const Column > schema)
 The number of INLINE columns (everything not $noninline$).
bool idIsNoninline (std::span< const Column > schema)
 Whether the id column is stored outside the record ($noninline$ id).
std::uint16_t idFieldIndex (std::span< const Column > schema)
 The inline field index of an inline id column (0 when non-inline).
std::int64_t readInt (std::span< const std::byte > image, std::size_t &pos, std::size_t bytes, bool isSigned)
 Read a little-endian integer of bytes bytes at pos, sign-extended when isSigned, advancing pos.
void writeInt (FileBuffer &out, std::int64_t value, std::size_t bytes)
 Append value's low bytes bytes (little-endian) to out.
void decodeInlineRecord (std::span< const Column > schema, std::size_t record, std::span< const std::byte > image, RecordSink &sink, TableState &state)
 Decode one fixed-stride record's inline fields into sink and journal its string offsets (record then schema then element order).
void encodeInlineRecord (std::span< const Column > schema, const RecordSource &source, std::size_t record, FileBuffer &out, StringPool &pool, const TableState &state, std::size_t &cursor)
 Encode one fixed-stride record's inline fields from source, appending to out and resolving strings through pool (cursor tracks the journal).
template<typename E>
consteval AccessKind accessKindOf ()
 The AccessKind of element type E (consteval; bool is rejected by classifyMember long before this runs).
template<typename Struct>
consteval std::uint32_t memberOffset (std::string_view name)
 The byte offset of Struct's member named name (consteval).
template<typename Record>
consteval auto columnAccessOf ()
 The per-column access table of Record: one ColumnAccess per member, declaration order — the same 1:1 correspondence schemaOf() rests on.
template<typename Record>
consteval std::size_t idColumnOf ()
 The $id$ column index of Record (consteval), or SIZE_MAX.
bool allZero (std::span< const std::byte > bytes)
 Whether every byte of bytes is zero (an empty span counts as zero).
template<typename Spec, std::meta::info M>
consteval std::optional< Spec > annotation ()
 The first annotation of type Spec on reflected member M, if any.
template<typename Member>
consteval Column classifyMember ()
 The physical column shape of a record member of type Member — the name and the annotation-carried roles are the caller's to fill in.
template<typename Record>
consteval auto recordMembers ()
 The reflected non-static data members of record Record, declaration order.
consteval blob::RangeEntry typedRangeOf (std::string_view table, ClientVersion version)
 The blob's column list for (table, version)'s era, as blob-global column indexes [first, first+count), or a thrown TypedMismatch.
consteval std::size_t typedColumnIndex (std::string_view table, ClientVersion version, std::string_view name)
 The era-schema column index whose name is name, or a thrown TypedMismatch.
template<typename Record>
consteval bool typedValidate ()
 Validate Record against the blob (see the file note for the rules); also the projection builder's precondition.
template<typename Record>
consteval auto typedProjection ()
 The projection map of Record: member position -> era-schema column index, as a static (never-dangling) array.

Variables

template<typename Record>
constexpr RecordOps RecordOpsFor
 The RecordOps instance of Record — the entire per-record residue.
constexpr unsigned char TypedSchemaBlob []
 The blob, again, for CONSTANT EVALUATION in consumer TUs (the runtime catalog's copy lives inside schema_catalog.cpp).

Enumeration Type Documentation

◆ AccessKind

enum class wowlib::db::detail::AccessKind : std::uint8_t
strong

The storage kind of one record member, as the erased accessors see it: exact width and signedness for integers (the store must truncate the codec's int64 exactly as the typed member assignment did), float, std::string, or LocString.

Enumerator
I8 
U8 
I16 
U16 
I32 
U32 
I64 
U64 

Integer elements, by shape.

F32 

A float element.

Str 

A std::string element.

LocStr 

A LocString<N>: strings at offset, flags on the side.

Definition at line 45 of file record_bridge.hpp.

Function Documentation

◆ accessKindOf()

template<typename E>
AccessKind wowlib::db::detail::accessKindOf ( )
consteval

The AccessKind of element type E (consteval; bool is rejected by classifyMember long before this runs).

Definition at line 72 of file record_bridge.hpp.

References F32, I16, I32, I64, I8, Str, U16, U32, U64, and U8.

Referenced by columnAccessOf().

◆ allZero()

bool wowlib::db::detail::allZero ( std::span< const std::byte > bytes)
inline

Whether every byte of bytes is zero (an empty span counts as zero).

Parameters
bytesthe span to test.
Returns
true when all bytes are zero.

Definition at line 154 of file schema.hpp.

◆ annotation()

template<typename Spec, std::meta::info M>
std::optional< Spec > wowlib::db::detail::annotation ( )
consteval

The first annotation of type Spec on reflected member M, if any.

Template Parameters
Specthe annotation payload type (a *_spec struct).
Mthe reflected member.
Returns
the payload, or nullopt when the member is unannotated.

Definition at line 165 of file schema.hpp.

Referenced by wowlib::db::schemaOf().

◆ classifyMember()

template<typename Member>
Column wowlib::db::detail::classifyMember ( )
consteval

The physical column shape of a record member of type Member — the name and the annotation-carried roles are the caller's to fill in.

Template Parameters
Memberthe member's declared type.
Returns
the partially-filled Column.

Definition at line 176 of file schema.hpp.

References wowlib::db::Column::arrayLen, wowlib::db::Column::bits, wowlib::db::detail::ElementTraits< T >::Extent, wowlib::db::Float, wowlib::db::Int, wowlib::db::Column::isSigned, wowlib::db::Column::localeCount, wowlib::db::LocString, wowlib::db::String, wowlib::db::Column::type, and wowlib::db::detail::LocstringTraits< T >::Value.

Referenced by wowlib::db::schemaOf().

◆ columnAccessOf()

template<typename Record>
auto wowlib::db::detail::columnAccessOf ( )
consteval

◆ decodeInlineRecord()

void wowlib::db::detail::decodeInlineRecord ( std::span< const Column > schema,
std::size_t record,
std::span< const std::byte > image,
RecordSink & sink,
TableState & state )

◆ encodeInlineRecord()

void wowlib::db::detail::encodeInlineRecord ( std::span< const Column > schema,
const RecordSource & source,
std::size_t record,
FileBuffer & out,
StringPool & pool,
const TableState & state,
std::size_t & cursor )

Encode one fixed-stride record's inline fields from source, appending to out and resolving strings through pool (cursor tracks the journal).

Definition at line 105 of file codec_common.cpp.

References wowlib::db::Float, wowlib::db::RecordSource::getInt(), wowlib::db::RecordSource::getSlot(), wowlib::db::RecordSource::getString(), wowlib::db::Int, wowlib::db::LocString, wowlib::db::detail::StringPool::resolve(), wowlib::db::String, wowlib::db::TableState::stringOffsets, and writeInt().

Referenced by wowlib::db::writeWdb2(), and wowlib::db::writeWdbc().

◆ fieldSlotCount()

std::uint32_t wowlib::db::detail::fieldSlotCount ( std::span< const Column > schema)
inline

The expanded on-disk field-slot count of schema (WDBC/WDB2 fieldCount).

Definition at line 154 of file codec.hpp.

Referenced by wowlib::db::writeWdb2(), and wowlib::db::writeWdbc().

◆ idColumnOf()

template<typename Record>
std::size_t wowlib::db::detail::idColumnOf ( )
consteval

The $id$ column index of Record (consteval), or SIZE_MAX.

Definition at line 150 of file record_bridge.hpp.

References wowlib::db::schemaOf().

◆ idFieldIndex()

std::uint16_t wowlib::db::detail::idFieldIndex ( std::span< const Column > schema)
inline

The inline field index of an inline id column (0 when non-inline).

Definition at line 182 of file codec.hpp.

◆ idIsNoninline()

bool wowlib::db::detail::idIsNoninline ( std::span< const Column > schema)
inline

Whether the id column is stored outside the record ($noninline$ id).

Definition at line 175 of file codec.hpp.

◆ inlineColumnCount()

std::size_t wowlib::db::detail::inlineColumnCount ( std::span< const Column > schema)
inline

The number of INLINE columns (everything not $noninline$).

Definition at line 168 of file codec.hpp.

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

◆ memberOffset()

template<typename Struct>
std::uint32_t wowlib::db::detail::memberOffset ( std::string_view name)
consteval

The byte offset of Struct's member named name (consteval).

Definition at line 95 of file record_bridge.hpp.

Referenced by columnAccessOf().

◆ readInt()

std::int64_t wowlib::db::detail::readInt ( std::span< const std::byte > image,
std::size_t & pos,
std::size_t bytes,
bool isSigned )

Read a little-endian integer of bytes bytes at pos, sign-extended when isSigned, advancing pos.

Definition at line 12 of file codec_common.cpp.

Referenced by decodeInlineRecord().

◆ recordMembers()

template<typename Record>
auto wowlib::db::detail::recordMembers ( )
consteval

The reflected non-static data members of record Record, declaration order.

Generated records are flat structs — no base flattening.

Template Parameters
Recordthe record type.
Returns
a static array of the reflected members.

Definition at line 207 of file schema.hpp.

Referenced by wowlib::db::TypedTable< Record >::column(), columnAccessOf(), and wowlib::db::schemaOf().

◆ recordStride()

std::size_t wowlib::db::detail::recordStride ( std::span< const Column > schema)
inline

The fixed record stride (WDBC/WDB2) of schema.

Definition at line 147 of file codec.hpp.

Referenced by wowlib::db::readWdb2(), wowlib::db::readWdbc(), wowlib::db::writeWdb2(), and wowlib::db::writeWdbc().

◆ stringSlotCount()

std::size_t wowlib::db::detail::stringSlotCount ( std::span< const Column > schema)
inline

The per-record string-reference count of schema (the offset journal width).

Definition at line 161 of file codec.hpp.

Referenced by wowlib::db::readWdb2(), and wowlib::db::readWdbc().

◆ typedColumnIndex()

std::size_t wowlib::db::detail::typedColumnIndex ( std::string_view table,
ClientVersion version,
std::string_view name )
consteval

◆ typedProjection()

template<typename Record>
auto wowlib::db::detail::typedProjection ( )
consteval

The projection map of Record: member position -> era-schema column index, as a static (never-dangling) array.

Definition at line 132 of file typed.hpp.

References wowlib::db::schemaOf(), and typedColumnIndex().

Referenced by wowlib::db::TypedTable< Record >::column(), wowlib::db::TypedTable< Record >::load(), and wowlib::db::TypedTable< Record >::writeBack().

◆ typedRangeOf()

blob::RangeEntry wowlib::db::detail::typedRangeOf ( std::string_view table,
ClientVersion version )
consteval

◆ typedValidate()

template<typename Record>
bool wowlib::db::detail::typedValidate ( )
consteval

◆ writeInt()

void wowlib::db::detail::writeInt ( FileBuffer & out,
std::int64_t value,
std::size_t bytes )

Append value's low bytes bytes (little-endian) to out.

Definition at line 23 of file codec_common.cpp.

Referenced by encodeInlineRecord().

Variable Documentation

◆ RecordOpsFor

template<typename Record>
RecordOps wowlib::db::detail::RecordOpsFor
inlineconstexpr

The RecordOps instance of Record — the entire per-record residue.

Definition at line 161 of file record_bridge.hpp.

◆ TypedSchemaBlob

unsigned char wowlib::db::detail::TypedSchemaBlob[]
inlineconstexpr
Initial value:
= {
}

The blob, again, for CONSTANT EVALUATION in consumer TUs (the runtime catalog's copy lives inside schema_catalog.cpp).

Same file, same bytes; consteval-only use.

Definition at line 66 of file typed.hpp.

Referenced by typedColumnIndex(), typedRangeOf(), and typedValidate().