wowlib 0.0.0
Read & write World of Warcraft client files — a C++26 core
Loading...
Searching...
No Matches
write.cpp File Reference

The WDC-family canonical encoder (entry point declared in wdc.hpp). More...

#include <wowlib/db/wdc/wdc.hpp>
#include <algorithm>
#include <cstring>
#include <format>
#include <limits>
#include <string>
#include <unordered_map>
#include <utility>
#include <vector>
#include <wowlib/core/client_builds.hpp>
#include <wowlib/db/schema.hpp>
#include <wowlib/formats/common/string_block.hpp>
Include dependency graph for write.cpp:

Go to the source code of this file.

Namespaces

namespace  wowlib
namespace  wowlib::db
namespace  wowlib::db::wdc

Functions

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.

Detailed Description

The WDC-family canonical encoder (entry point declared in wdc.hpp).

One Writer serves WDC1/WDC3/WDC4/WDC5: the compression planning, copy-table and common-data derivation and record bit-packing are flavor-independent; only the header/block framing and the string-reference convention differ, and those branch at emit time.

The write is a canonical re-encode, not a byte-perfect one: integer columns are bitpacked to the minimum width their values need, and the original file's pallet/common column kinds (TableState::wdcKinds) are reproduced so the output stays within Blizzard's size ballpark. The guarantee is semantic — write -> re-read decodes to the identical record set (see the round-trip policy in table.hpp).

Definition in file write.cpp.