wowlib
0.0.0
Read & write World of Warcraft client files — a C++26 core
Toggle main menu visibility
Loading...
Searching...
No Matches
client_version.cpp
Go to the documentation of this file.
1
#include <
wowlib/core/client_version.hpp
>
2
3
#include <array>
4
#include <ostream>
5
#include <utility>
6
7
#include <
wowlib/core/reflect.hpp
>
8
9
namespace
wowlib
{
10
std::ostream&
operator<<
(std::ostream& out,
const
ClientVersion
& version) {
11
out << version.
major
<<
'.'
<< version.
minor
<<
'.'
<< version.
patch
<<
'.'
<< version.
build
;
12
if
(version.isClassic()) out <<
" ("
<<
enumName
(version.flavor) <<
')'
;
13
return
out;
14
}
15
16
namespace
{
17
// CASC_LOCALE_* values from CascLib (CascPort.h); kept here so the public header
18
// does not include CascLib.
19
constexpr
std::array<std::pair<std::string_view, std::uint32_t>, 12> LocaleTable{
20
{
21
{
"enUS"
, 0x00000002},
22
{
"koKR"
, 0x00000004},
23
{
"frFR"
, 0x00000010},
24
{
"deDE"
, 0x00000020},
25
{
"zhCN"
, 0x00000040},
26
{
"esES"
, 0x00000080},
27
{
"zhTW"
, 0x00000100},
28
{
"enGB"
, 0x00000200},
29
{
"esMX"
, 0x00001000},
30
{
"ruRU"
, 0x00002000},
31
{
"ptBR"
, 0x00004000},
32
{
"itIT"
, 0x00008000},
33
}
34
};
35
36
constexpr
std::size_t localeIndex(
Locale
locale) {
37
switch
(locale) {
38
case
Locale::enUS
:
return
0;
39
case
Locale::koKR
:
return
1;
40
case
Locale::frFR
:
return
2;
41
case
Locale::deDE
:
return
3;
42
case
Locale::zhCN
:
return
4;
43
case
Locale::esES
:
return
5;
44
case
Locale::zhTW
:
return
6;
45
case
Locale::enGB
:
return
7;
46
case
Locale::esMX
:
return
8;
47
case
Locale::ruRU
:
return
9;
48
case
Locale::ptBR
:
return
10;
49
case
Locale::itIT
:
return
11;
50
}
51
std::unreachable();
52
}
53
}
54
55
std::string_view
localeCode
(
Locale
locale) {
56
return
LocaleTable[localeIndex(locale)].first;
57
}
58
59
std::optional<Locale>
localeFromCode
(std::string_view code) {
60
constexpr
std::array locales{
61
Locale::enUS
,
62
Locale::koKR
,
63
Locale::frFR
,
64
Locale::deDE
,
65
Locale::zhCN
,
66
Locale::esES
,
67
Locale::zhTW
,
68
Locale::enGB
,
69
Locale::esMX
,
70
Locale::ruRU
,
71
Locale::ptBR
,
72
Locale::itIT
73
};
74
for
(std::size_t i = 0; i < LocaleTable.size(); ++i)
75
if
(LocaleTable[i].first == code)
return
locales[i];
76
return
std::nullopt;
77
}
78
79
std::uint32_t
cascLocaleFlag
(
Locale
locale) {
80
return
LocaleTable[localeIndex(locale)].second;
81
}
82
}
client_version.hpp
Client version identity, the flavor axis that separates a client's CONTENT version from the engine ge...
wowlib
Definition
detail.hpp:29
wowlib::localeCode
std::string_view localeCode(Locale locale)
The four-letter code of locale ("enUS", ...) as used in MPQ locale directory and archive names.
Definition
client_version.cpp:55
wowlib::Locale
Locale
Definition
client_version.hpp:285
wowlib::Locale::itIT
@ itIT
Definition
client_version.hpp:297
wowlib::Locale::deDE
@ deDE
Definition
client_version.hpp:288
wowlib::Locale::ruRU
@ ruRU
Definition
client_version.hpp:290
wowlib::Locale::frFR
@ frFR
Definition
client_version.hpp:289
wowlib::Locale::koKR
@ koKR
Definition
client_version.hpp:293
wowlib::Locale::zhCN
@ zhCN
Definition
client_version.hpp:294
wowlib::Locale::zhTW
@ zhTW
Definition
client_version.hpp:295
wowlib::Locale::enGB
@ enGB
Definition
client_version.hpp:287
wowlib::Locale::esMX
@ esMX
Definition
client_version.hpp:292
wowlib::Locale::esES
@ esES
Definition
client_version.hpp:291
wowlib::Locale::ptBR
@ ptBR
Definition
client_version.hpp:296
wowlib::Locale::enUS
@ enUS
Definition
client_version.hpp:286
wowlib::localeFromCode
std::optional< Locale > localeFromCode(std::string_view code)
Parse a four-letter locale code.
Definition
client_version.cpp:59
wowlib::cascLocaleFlag
std::uint32_t cascLocaleFlag(Locale locale)
The CASC_LOCALE_* bit of locale for CascOpenStorage/CascOpenFile locale masks.
Definition
client_version.cpp:79
wowlib::operator<<
std::ostream & operator<<(std::ostream &out, const ClientVersion &version)
render version as "major.minor.patch.build", with the flavor appended when it is not Retail ("1....
Definition
client_version.cpp:10
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::ClientVersion::patch
std::uint16_t patch
Patch version within the minor release.
Definition
client_version.hpp:41
wowlib::ClientVersion::build
std::uint32_t build
Exact client build number, e.g.
Definition
client_version.hpp:44
wowlib::ClientVersion::major
std::uint16_t major
Expansion number, e.g.
Definition
client_version.hpp:35
wowlib::ClientVersion::minor
std::uint16_t minor
Minor version within the expansion.
Definition
client_version.hpp:38
src
wowlib
core
client_version.cpp
Generated by
1.17.0