wowlib 0.0.0
Read & write World of Warcraft client files — a C++26 core
Loading...
Searching...
No Matches
wdbc.hpp
Go to the documentation of this file.
1#pragma once
2
12
13#include <cstddef>
14#include <cstdint>
15#include <span>
16#include <type_traits>
17
19#include <wowlib/core/error.hpp>
20#include <wowlib/db/codec.hpp>
22
23namespace wowlib::db {
25 inline constexpr std::uint32_t WdbcMagic = formats::fourcc("WDBC", formats::FourCCEndian::Forward);
26
28 struct WdbcHeader {
29 std::uint32_t magic = WdbcMagic;
30 std::uint32_t recordCount = 0;
31 std::uint32_t fieldCount = 0;
32 std::uint32_t recordSize = 0;
33 std::uint32_t stringBlockSize = 0;
34 };
35
36 static_assert(sizeof(WdbcHeader) == 20 && std::is_trivially_copyable_v<WdbcHeader>);
37
46 Result<void> readWdbc(const TableInfo& info, std::span<const std::byte> data, RecordSink& sink, TableState& state);
47
54 Result<FileBuffer> writeWdbc(const TableInfo& info, const RecordSource& source, const TableState& state);
55}
The owning byte buffer file contents are read into.
The decode target: the codecs build the record vector through this, one field at a time.
Definition codec.hpp:110
The encode source: the codecs read the record vector through this.
Definition codec.hpp:135
The type-erased boundary between the templated Table<Record> facade (table.hpp) and the per-format co...
The error-handling vocabulary: ErrorCode, Error and the Result<T> alias every fallible wowlib operati...
FourCC chunk identifiers: compile-time conversion of the four-letter codes to the host integers chunk...
constexpr std::uint32_t WdbcMagic
The WDBC magic as memcpy'd off the file front (the bytes "WDBC").
Definition wdbc.hpp:25
Result< FileBuffer > writeWdbc(const TableInfo &info, const RecordSource &source, const TableState &state)
Encode a WDBC image; the string block preserves decoded offsets and appends new/changed strings (byte...
Definition wdbc.cpp:58
Result< void > readWdbc(const TableInfo &info, std::span< const std::byte > data, RecordSink &sink, TableState &state)
Decode a WDBC image: 20-byte header, fixed-stride records, string block.
Definition wdbc.cpp:17
constexpr std::uint32_t fourcc(const char(&cc)[5], FourCCEndian endian=FourCCEndian::Reversed)
The host integer a scanned chunk id compares equal to for code cc.
Definition fourcc.hpp:33
@ Forward
The characters are stored as written: 'AFID' appears in the file as the bytes "AFID".
Definition fourcc.hpp:22
std::expected< T, Error > Result
Every fallible wowlib operation returns Result<T>; bindings translate the error branch into a target-...
Definition error.hpp:100
The per-table identity a codec needs beyond the record data: the client version (format selection,...
Definition codec.hpp:58
The preserved decode state a table carries between read() and write() so a WDBC/WDB2 write is byte-pe...
Definition codec.hpp:68
The 20-byte WDBC header (wowdev.wiki/DBC).
Definition wdbc.hpp:28
std::uint32_t fieldCount
Expanded on-disk field slots per record.
Definition wdbc.hpp:31
std::uint32_t recordSize
Record stride in bytes.
Definition wdbc.hpp:32
std::uint32_t stringBlockSize
String block bytes after the records.
Definition wdbc.hpp:33
std::uint32_t magic
"WDBC".
Definition wdbc.hpp:29
std::uint32_t recordCount
Records in the record block.
Definition wdbc.hpp:30