wowlib
0.0.0
Read & write World of Warcraft client files — a C++26 core
Toggle main menu visibility
Loading...
Searching...
No Matches
version_range.hpp
Go to the documentation of this file.
1
#pragma once
2
27
28
#include <array>
29
#include <span>
30
#include <string>
31
#include <string_view>
32
33
#include <
wowlib/core/client_version.hpp
>
34
#include <
wowlib/core/expansion.hpp
>
35
#include <
wowlib/core/reflect.hpp
>
36
37
namespace
wowlib::formats
{
50
constexpr
ClientVersion
versionFloor
(
ClientVersion
v, std::span<const ClientVersion> pivots) {
51
const
ClientVersion
lineage = v.formatLineage();
52
ClientVersion
out{0, 0, 0, 0};
53
for
(
const
ClientVersion
& p : pivots)
54
if
(p <= lineage && out <= p) out = p;
55
return
out;
56
}
57
69
constexpr
ClientVersion
canonicalVersion
(
ClientVersion
v,
70
std::span<const ClientVersion> pivots,
71
std::span<const ClientVersion> grid) {
72
const
ClientVersion
floor =
versionFloor
(v, pivots);
73
for
(
const
ClientVersion
& g : grid)
74
if
(
versionFloor
(g, pivots) == floor)
return
g;
75
return
grid.front();
76
}
77
87
constexpr
std::string
rangeSuffix
(
ClientVersion
canonical,
88
std::span<const ClientVersion> pivots,
89
std::span<const ClientVersion> grid) {
90
const
ClientVersion
floor =
versionFloor
(canonical, pivots);
91
ClientVersion
last = canonical;
92
for
(
const
ClientVersion
& g : grid)
93
if
(g >= canonical &&
versionFloor
(g, pivots) == floor) last = g;
94
const
auto
name = [](
ClientVersion
v) {
95
return
std::string{
enumName
(*
toExpansion
(v))};
96
};
97
if
(last == canonical)
return
name(canonical);
98
if
(last == grid.back())
return
name(canonical) +
"Plus"
;
99
return
name(canonical) +
"To"
+ name(last);
100
}
101
104
struct
RangeRow
{
105
std::string_view
suffix
;
106
ClientVersion
version
{};
107
};
108
118
constexpr
bool
rangesValid
(std::span<const RangeRow> rows,
119
std::span<const ClientVersion> pivots,
120
std::span<const ClientVersion> grid) {
121
std::size_t row = 0;
122
for
(
const
ClientVersion
& g : grid) {
123
const
ClientVersion
canonical =
canonicalVersion
(g, pivots, grid);
124
if
(canonical == g) {
125
if
(row >= rows.size() || rows[row].version != g || rows[row].suffix !=
rangeSuffix
(g, pivots, grid))
return
126
false
;
127
++row;
128
}
129
}
130
return
row == rows.size();
131
}
132
}
client_version.hpp
Client version identity, the flavor axis that separates a client's CONTENT version from the engine ge...
expansion.hpp
The Expansion enum — the coarse, enumerable version axis the scripting bindings key on — and its mapp...
wowlib::formats
Definition
adt.hpp:68
wowlib::formats::versionFloor
constexpr ClientVersion versionFloor(ClientVersion v, std::span< const ClientVersion > pivots)
The latest pivot at or below v — the identity of v's range.
Definition
version_range.hpp:50
wowlib::formats::rangeSuffix
constexpr std::string rangeSuffix(ClientVersion canonical, std::span< const ClientVersion > pivots, std::span< const ClientVersion > grid)
The suffix naming canonical's range on grid: the plain expansion name for a single-version range ("Wo...
Definition
version_range.hpp:87
wowlib::formats::canonicalVersion
constexpr ClientVersion canonicalVersion(ClientVersion v, std::span< const ClientVersion > pivots, std::span< const ClientVersion > grid)
The canonical version v collapses to: the FIRST grid version in v's range.
Definition
version_range.hpp:69
wowlib::formats::rangesValid
constexpr bool rangesValid(std::span< const RangeRow > rows, std::span< const ClientVersion > pivots, std::span< const ClientVersion > grid)
Does rows exactly enumerate the family's ranges — ascending, one row per distinct canonical of grid,...
Definition
version_range.hpp:118
wowlib::toExpansion
constexpr std::optional< Expansion > toExpansion(ClientVersion version)
The expansion whose targeted release is exactly this version.
Definition
expansion.hpp:64
wowlib::enumName
constexpr std::string_view enumName(E value)
The enumerator name of value, straight from reflection — no handwritten stringification tables anywhe...
Definition
reflect.hpp:19
reflect.hpp
Internal C++26 reflection utilities (<meta> based).
wowlib::ClientVersion
Definition
client_version.hpp:33
wowlib::formats::RangeRow
One row of a family's welded range table: the alias suffix (stringized from the x-macro) and the rang...
Definition
version_range.hpp:104
wowlib::formats::RangeRow::suffix
std::string_view suffix
e.g.
Definition
version_range.hpp:105
wowlib::formats::RangeRow::version
ClientVersion version
the range's canonical grid version.
Definition
version_range.hpp:106
src
wowlib
formats
common
version_range.hpp
Generated by
1.17.0