wowlib
0.0.0
Read & write World of Warcraft client files — a C++26 core
Toggle main menu visibility
Loading...
Searching...
No Matches
schema_catalog.hpp
Go to the documentation of this file.
1
#pragma once
2
20
21
#include <cstddef>
22
#include <cstdint>
23
#include <filesystem>
24
#include <span>
25
#include <string_view>
26
#include <vector>
27
28
#include <
wowlib/core/client_version.hpp
>
29
#include <
wowlib/core/error.hpp
>
30
#include <
wowlib/db/schema.hpp
>
31
32
#ifndef WOWLIB_DB_SCHEMA_EMBEDDED
33
#define WOWLIB_DB_SCHEMA_EMBEDDED 1
34
#endif
35
#ifndef WOWLIB_DB_SCHEMA_RUNTIME
36
#define WOWLIB_DB_SCHEMA_RUNTIME 1
37
#endif
38
39
namespace
wowlib::db
{
42
struct
TableSchema
{
43
std::string_view
name
;
44
std::string_view
diskName
;
45
std::span<const Column>
columns
;
46
};
47
50
class
SchemaCatalog
{
51
public
:
52
#if WOWLIB_DB_SCHEMA_EMBEDDED
55
static
const
SchemaCatalog
& embedded();
56
#endif
57
58
#if WOWLIB_DB_SCHEMA_RUNTIME
62
static
Result<SchemaCatalog>
fromBlob(std::vector<unsigned char> bytes);
63
67
static
Result<SchemaCatalog>
fromBlobFile(
const
std::filesystem::path& path);
68
80
static
Result<SchemaCatalog>
fromDbdDir(
const
std::filesystem::path& definitions);
81
#endif
82
83
SchemaCatalog
(
SchemaCatalog
&&) noexcept = default;
84
SchemaCatalog
& operator=(
SchemaCatalog
&&) noexcept = default;
85
SchemaCatalog
(const
SchemaCatalog
&) = delete;
86
SchemaCatalog
& operator=(const
SchemaCatalog
&) = delete;
87
94
Result
<
TableSchema
>
lookup
(std::string_view table,
ClientVersion
version) const;
95
97
std::
size_t
tableCount
()
const
{
return
_tables.size(); }
98
103
std::string_view
tableName
(std::size_t i)
const
{
return
_tables[i].name; }
104
107
std::span<const ClientVersion>
eras
()
const
{
return
_eras; }
108
109
private
:
110
SchemaCatalog
() =
default
;
111
113
struct
RangeIndex {
114
std::uint32_t firstColumn = 0;
115
std::uint32_t columnCount = 0;
116
std::uint16_t eraMask = 0;
117
};
118
120
struct
TableIndex {
121
std::string_view name;
122
std::string_view diskName;
123
std::uint32_t firstRange = 0;
124
std::uint32_t rangeCount = 0;
125
};
126
130
static
SchemaCatalog
_materialize(std::span<const unsigned char> bytes, std::vector<unsigned char> owned);
131
133
Result<std::size_t>
_eraIndexOf(ClientVersion version)
const
;
134
135
std::vector<unsigned char> _owned;
136
std::vector<ClientVersion> _eras;
137
std::vector<TableIndex> _tables;
138
std::vector<RangeIndex> _ranges;
139
std::vector<Column> _columns;
140
};
141
}
wowlib::db::SchemaCatalog::tableName
std::string_view tableName(std::size_t i) const
The identifier name of table i (name-sorted order) — enumeration for tooling and the bindings' listin...
Definition
schema_catalog.hpp:103
wowlib::db::SchemaCatalog::tableCount
std::size_t tableCount() const
Definition
schema_catalog.hpp:97
wowlib::db::SchemaCatalog::eras
std::span< const ClientVersion > eras() const
The era table the blob was built against (index = mask bit).
Definition
schema_catalog.hpp:107
wowlib::db::SchemaCatalog::SchemaCatalog
SchemaCatalog(SchemaCatalog &&) noexcept=default
wowlib::db::SchemaCatalog::lookup
Result< TableSchema > lookup(std::string_view table, ClientVersion version) const
Resolve the schema of table for client version.
Definition
schema_catalog.cpp:82
client_version.hpp
Client version identity, the flavor axis that separates a client's CONTENT version from the engine ge...
error.hpp
The error-handling vocabulary: ErrorCode, Error and the Result<T> alias every fallible wowlib operati...
wowlib::db
Definition
annotations.hpp:31
wowlib::Result
std::expected< T, Error > Result
Every fallible wowlib operation returns Result<T>; bindings translate the error branch into a target-...
Definition
error.hpp:100
schema.hpp
Schema reflection over generated client-database record structs: the column list, record stride and f...
wowlib::ClientVersion
Definition
client_version.hpp:33
wowlib::db::TableSchema
One resolved (table, client version) schema: what SchemaCatalog::lookup hands the engine.
Definition
schema_catalog.hpp:42
wowlib::db::TableSchema::name
std::string_view name
The identifier name ("ItemSparseLegacy").
Definition
schema_catalog.hpp:43
wowlib::db::TableSchema::columns
std::span< const Column > columns
The era's column list, WoWDBDefs order.
Definition
schema_catalog.hpp:45
wowlib::db::TableSchema::diskName
std::string_view diskName
The on-disk truth ("Item-sparse").
Definition
schema_catalog.hpp:44
src
wowlib
db
schema_catalog.hpp
Generated by
1.17.0