wowlib
0.0.0
Read & write World of Warcraft client files — a C++26 core
Toggle main menu visibility
Loading...
Searching...
No Matches
file_key.hpp
Go to the documentation of this file.
1
#pragma once
2
6
7
#include <compare>
8
#include <cstdint>
9
#include <functional>
10
#include <optional>
11
#include <string>
12
#include <string_view>
13
14
#include <welder/vocabulary.hpp>
15
16
#include <
wowlib/core/path.hpp
>
17
18
namespace
wowlib
{
19
struct
[[
20
=welder::weld,
21
=welder::doc(R
"(
22
A strongly-typed FileDataID — the numeric file identifier used by CASC-era
23
clients (u32, matching the client's root manifest and DB2 references).)")
24
]]
FileDataID
{
25
[[=welder::doc(
"The raw numeric identifier."
)]]
26
std::uint32_t value = 0;
27
28
constexpr
auto
operator<=>(
const
FileDataID
&)
const
=
default
;
29
};
30
31
struct
[[
32
=welder::weld,
33
=welder::doc(R
"(
34
A file request: by client-internal path, by FileDataID, or both. The
35
generic file identity for version-independent tools — code that handles
36
any client generation operates on FileKeys without caring which half is
37
available (on pre-CASC clients the FileDataID is simply absent); the
38
storage backend uses the half it needs and FileSystem.resolve fills gaps
39
through the listfile. The stored path is always in canonical form.)")
40
]]
FileKey
{
41
[[=welder::doc(
"The numeric identifier, if known."
)]]
42
std::optional<FileDataID>
fdid
;
43
44
[[=welder::doc(
"The canonical client-internal path, if known."
)]]
45
std::optional<std::string>
path
;
46
47
FileKey
() =
default
;
48
49
[[=welder::doc(R
"(
50
A path-only key; the path is canonicalized here and may use any accepted
51
spelling.)")]]
52
FileKey(
53
std::string_view filePath [[=welder::doc(
"the client-internal file path"
)
54
]])
55
: path(
normalizePath
(filePath)) {}
56
57
[[=welder::doc(
"An id-only key."
)]]
58
FileKey(FileDataID fileId [[=welder::doc(
"the numeric file identifier"
)]])
59
: fdid(fileId) {}
60
61
[[=welder::doc(
"A key carrying both identities of one file."
)]]
62
FileKey(
63
std::string_view filePath [[=welder::doc(
"the client-internal file path"
)
64
]],
65
FileDataID fileId [[=welder::doc(
"the numeric file identifier"
)]])
66
: fdid(fileId), path(
normalizePath
(filePath)) {}
67
};
68
}
69
70
template
<>
71
struct
std::hash<
wowlib
::FileDataID> {
72
std::size_t operator()(
const
wowlib::FileDataID&
id
)
const
noexcept
{
73
return
std::hash<std::uint32_t>{}(
id
.value);
74
}
75
};
wowlib
Definition
detail.hpp:29
wowlib::normalizePath
std::string normalizePath(std::string_view path)
Canonicalize a client-internal file path.
Definition
path.cpp:4
path.hpp
Client-internal path canonicalization.
std::hash< wowlib::FileDataID >::operator()
std::size_t operator()(const wowlib::FileDataID &id) const noexcept
Definition
file_key.hpp:53
wowlib::FileDataID
Definition
file_key.hpp:19
wowlib::FileDataID::value
std::uint32_t value
The raw numeric identifier.
Definition
file_key.hpp:21
wowlib::FileDataID::operator<=>
constexpr auto operator<=>(const FileDataID &) const =default
wowlib::FileKey::FileKey
FileKey(std::string_view filePath, FileDataID fileId)
A key carrying both identities of one file.
Definition
file_key.hpp:44
wowlib::FileKey::FileKey
FileKey(std::string_view filePath)
Definition
file_key.hpp:35
wowlib::FileKey::fdid
std::optional< FileDataID > fdid
The numeric identifier, if known.
Definition
file_key.hpp:28
wowlib::FileKey::path
std::optional< std::string > path
The canonical client-internal path, if known.
Definition
file_key.hpp:31
wowlib::FileKey::FileKey
FileKey(FileDataID fileId)
An id-only key.
Definition
file_key.hpp:40
wowlib::FileKey::FileKey
FileKey()=default
src
wowlib
core
file_key.hpp
Generated by
1.17.0