50 inline constexpr std::uint32_t
Magic = 0x53424457u;
113 if (_bytes.size() != need ||
strpoolSize() == 0)
return false;
115 return _bytes[_bytes.size() - 1] == 0u;
119 constexpr std::size_t
eraCount()
const {
return _bytes[24]; }
123 constexpr std::size_t
rangeCount()
const {
return _u32(12); }
134 return ClientVersion{_u16(at), _u16(at + 2), _u16(at + 4), _u32(at + 8)};
141 const std::size_t at = _tablesOff() + i *
TableBytes;
142 return TableEntry{_u32(at), _u32(at + 4), _u32(at + 8), _u32(at + 12)};
149 const std::size_t at = _rangesOff() + i *
RangeBytes;
150 return RangeEntry{_u32(at), _u16(at + 4), _u16(at + 6)};
157 const std::size_t at = _columnsOff() + i *
ColumnBytes;
158 const std::uint8_t flags = _bytes[at + 6];
162 out.
bits = _bytes[at + 5];
164 out.
isId = (flags & 2u) != 0;
177 std::string_view
stringAt(std::uint32_t off)
const {
178 const char* base =
reinterpret_cast<const char*
>(_bytes.data()) + _strpoolOff() + off;
179 return std::string_view{base};
188 for (std::size_t at = _strpoolOff() + off; _bytes[at] != 0u; ++at) out +=
static_cast<char>(_bytes[at]);
195 constexpr std::optional<std::size_t>
200 const std::size_t mid = lo + (hi - lo) / 2;
201 const int cmp = _comparePool(
table(mid).nameOff, name);
202 if (cmp == 0)
return mid;
203 if (cmp < 0) lo = mid + 1;
210 constexpr std::span<const unsigned char>
bytes()
const {
return _bytes; }
214 constexpr std::uint16_t _u16(std::size_t at)
const {
215 return static_cast<std::uint16_t
>(_bytes[at] | (std::uint16_t{_bytes[at + 1]} << 8));
219 constexpr std::uint32_t _u32(std::size_t at)
const {
220 return _bytes[at] | (std::uint32_t{_bytes[at + 1]} << 8) | (std::uint32_t{_bytes[at + 2]} << 16) | (std::uint32_t{
226 constexpr std::size_t _tablesOff()
const {
230 constexpr std::size_t _rangesOff()
const {
234 constexpr std::size_t _columnsOff()
const {
238 constexpr std::size_t _strpoolOff()
const {
245 constexpr int _comparePool(std::uint32_t off, std::string_view name)
const {
246 std::size_t at = _strpoolOff() + off;
247 for (
const char c : name) {
248 const unsigned char p = _bytes[at];
249 if (p == 0u || p <
static_cast<unsigned char>(c))
return -1;
250 if (p >
static_cast<unsigned char>(c))
return 1;
253 return _bytes[at] == 0u ? 0 : 1;
256 std::span<const unsigned char> _bytes;
constexpr ColumnEntry column(std::size_t i) const
The column entry i (blob-global index).
constexpr std::size_t tableCount() const
constexpr TableEntry table(std::size_t i) const
The directory entry of table i (name-sorted order).
constexpr std::optional< std::size_t > findTable(std::string_view name) const
Binary-search the (name-sorted) table directory for name.
constexpr std::size_t eraCount() const
std::string_view stringAt(std::uint32_t off) const
The pool string at off as a view into the blob (runtime only — the pointer cast out of the byte pool ...
constexpr std::span< const unsigned char > bytes() const
constexpr ClientVersion era(std::size_t i) const
The client version of era slot i.
constexpr std::size_t columnCount() const
constexpr RangeEntry range(std::size_t i) const
The range entry i (blob-global index).
constexpr bool valid() const
Whether the bytes are a structurally valid WDBS v2 blob: magic, version, and every section (plus the ...
constexpr std::string copyStringAt(std::uint32_t off) const
The pool string at off, copied byte by byte — the consteval-safe twin of stringAt.
constexpr std::size_t strpoolSize() const
constexpr View(std::span< const unsigned char > bytes)
Bind the view to bytes (unvalidated — call valid).
constexpr std::size_t rangeCount() const
Client version identity, the flavor axis that separates a client's CONTENT version from the engine ge...
constexpr std::uint32_t FormatVersion
The one format version this reader understands.
constexpr std::size_t EraBytes
constexpr std::size_t RangeBytes
constexpr std::size_t TableBytes
constexpr std::size_t ColumnBytes
constexpr std::size_t HeaderBytes
Section entry sizes (bytes), fixed by the format.
constexpr std::uint32_t Magic
The WDBS magic ('WDBS' little-endian).
ColumnType
The logical value class of a column.
@ Int
An integer column; Column::bits / Column::isSigned give the shape.
Schema reflection over generated client-database record structs: the column list, record stride and f...
One column, decoded to the raw blob facts (the catalog turns this into a wowlib::db::Column with an i...
std::uint16_t arrayLen
element count; 1 for scalars.
bool isRelation
flags & 4.
std::uint32_t dbdNameOff
The verbatim WoWDBDefs spelling's pool offset (0 = none).
std::uint32_t nameOff
The column name's pool offset.
std::uint8_t localeCount
LocString language slots; 0 otherwise.
ColumnType type
The logical value class.
std::uint8_t bits
Integer element width in bits.
One schema range: a run of columns valid for the eras in the mask.
std::uint32_t firstColumn
Index of the range's first column.
std::uint16_t eraMask
Bit i set = valid for the blob's era i.
std::uint16_t columnCount
Number of consecutive columns.
One table's directory entry, decoded.
std::uint32_t rangeCount
Number of consecutive ranges.
std::uint32_t diskNameOff
The on-disk table name's pool offset.
std::uint32_t nameOff
The identifier name's pool offset.
std::uint32_t firstRange
Index of the table's first range.