wowlib 0.0.0
Read & write World of Warcraft client files — a C++26 core
Loading...
Searching...
No Matches
expansion.hpp
Go to the documentation of this file.
1#pragma once
2
7
8#include <array>
9#include <meta>
10#include <optional>
11
12#include <welder/vocabulary.hpp>
13
15
16namespace wowlib {
17 enum class [[
18 =welder::weld,
19 =welder::doc(R"(
20 The expansion a client belongs to, in release order. The enumerable
21 counterpart of a full ClientVersion: versioned format classes and
22 factories are keyed on it (each enumerator maps to the
23 last-minor-of-major release in the versions namespace).)")
29 Mop,
30 Wod,
31 Legion,
32 Bfa,
36 };
37
38 namespace detail {
41 inline constexpr std::array ExpansionVersions{
53 };
54
55 static_assert(ExpansionVersions.size() == std::meta::enumerators_of(^^Expansion).size(),
56 "expansion_versions must cover every Expansion enumerator");
57 }
58
59 [[=welder::weld,
60 =welder::doc(
61 "The last-minor-of-major client version wowlib targets for this "
62 "expansion (the versions constant)."),
63 =welder::returns("the matching versions constant")]]
64 constexpr ClientVersion toClientVersion(Expansion expansion [[=welder::doc("the expansion")]]) {
65 return detail::ExpansionVersions[static_cast<std::size_t>(expansion)];
66 }
67
68 [[=welder::weld,
69 =welder::doc(
70 "The expansion whose targeted release is exactly this version. "
71 "Never matches a Classic constant — Classic clients are not "
72 "expansion releases; pass version.format_lineage to ask which "
73 "expansion's FORMATS one uses."),
74 =welder::returns("the expansion, or None if the version is not one of the "
75 "versions constants")]]
76 constexpr std::optional<Expansion> toExpansion(ClientVersion version [[=welder::doc("a full client version")]]) {
77 for (std::size_t i = 0; i < detail::ExpansionVersions.size(); ++i)
78 if (detail::ExpansionVersions[i] == version) return static_cast<Expansion>(i);
79 return std::nullopt;
80 }
81
82 [[=welder::weld,
83 =welder::doc(R"(
84 The expansion a client version belongs to, by major version — works for
85 any build, not just the targeted releases.
86
87 This is the CONTENT axis: Cataclysm Classic 4.4.2 reports Cata, because
88 that is the game it is. It is NOT the format axis — that same client
89 writes War Within-era files. For formats, ask
90 to_expansion(version.format_lineage) instead.)"),
91 =welder::returns("the expansion, or None for unknown majors")]]
92 constexpr std::optional<Expansion> expansionOf(ClientVersion version [[=welder::doc("a full client version")]]) {
93 for (std::size_t i = 0; i < detail::ExpansionVersions.size(); ++i)
94 if (detail::ExpansionVersions[i].major == version.major) return static_cast<Expansion>(i);
95 return std::nullopt;
96 }
97}
Client version identity, the flavor axis that separates a client's CONTENT version from the engine ge...
constexpr std::array ExpansionVersions
The targeted ClientVersion of each Expansion, indexed by enumerator value.
Definition expansion.hpp:34
constexpr ClientVersion Shadowlands
constexpr ClientVersion Tww
constexpr ClientVersion Bfa
constexpr ClientVersion Mop
constexpr ClientVersion Wod
constexpr ClientVersion Tbc
constexpr ClientVersion Vanilla
constexpr ClientVersion Legion
constexpr ClientVersion Dragonflight
constexpr ClientVersion Cata
constexpr ClientVersion Wotlk
constexpr std::optional< Expansion > expansionOf(ClientVersion version)
Definition expansion.hpp:71
constexpr std::optional< Expansion > toExpansion(ClientVersion version)
The expansion whose targeted release is exactly this version.
Definition expansion.hpp:64
constexpr ClientVersion toClientVersion(Expansion expansion)
The last-minor-of-major client version wowlib targets for this expansion (the versions constant).
Definition expansion.hpp:56
std::uint16_t major
Expansion number, e.g.