wowlib
0.0.0
Read & write World of Warcraft client files — a C++26 core
Toggle main menu visibility
Loading...
Searching...
No Matches
listfile.hpp
Go to the documentation of this file.
1
#pragma once
2
6
7
#include <concepts>
8
#include <optional>
9
#include <string>
10
#include <string_view>
11
12
#include <
wowlib/core/error.hpp
>
13
#include <
wowlib/core/file_key.hpp
>
14
15
namespace
wowlib::fs
{
23
template
<
typename
L>
concept
ListfileProvider
=
requires
(L l,
const
L cl, std::string_view path,
FileDataID
id) {
24
{ cl.pathToFdid(path) } -> std::same_as<std::optional<FileDataID>>; {
25
cl.fdidToPath(
id
)
26
} -> std::same_as<std::optional<std::string>>; { l.registerPath(path) } -> std::same_as<Result<FileDataID>>; {
27
cl.contains(path)
28
} -> std::same_as<bool>;
29
};
30
33
struct
NullListfile
{
35
std::optional<FileDataID>
pathToFdid
(std::string_view)
const
{
36
return
std::nullopt;
37
}
38
40
std::optional<std::string>
fdidToPath
(
FileDataID
)
const
{
41
return
std::nullopt;
42
}
43
45
Result<FileDataID>
registerPath
(std::string_view) {
46
return
makeError
(
ErrorCode::NotSupported
,
47
"NullListfile cannot register paths; this client has no "
"FileDataID space"
);
48
}
49
51
bool
contains
(std::string_view)
const
{
return
false
; }
52
};
53
54
static_assert
(ListfileProvider<NullListfile>);
55
}
wowlib::fs::ListfileProvider
The pluggable path<->FileDataID database contract (CSV today, SQL later).
Definition
listfile.hpp:23
error.hpp
The error-handling vocabulary: ErrorCode, Error and the Result<T> alias every fallible wowlib operati...
file_key.hpp
File identity types: the strong FileDataID and the FileKey a read request travels as.
wowlib::fs
Definition
table_core.hpp:46
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
wowlib::makeError
std::unexpected< Error > makeError(ErrorCode code, std::string message, std::uint32_t nativeError=0)
Shorthand for constructing the error branch of a Result.
Definition
error.hpp:107
wowlib::ErrorCode::NotSupported
@ NotSupported
Operation not supported by this backend/provider.
Definition
error.hpp:32
wowlib::FileDataID
Definition
file_key.hpp:19
wowlib::fs::NullListfile
The no-database provider for clients that need none (MPQ-era).
Definition
listfile.hpp:33
wowlib::fs::NullListfile::registerPath
Result< FileDataID > registerPath(std::string_view)
Never supported.
Definition
listfile.hpp:45
wowlib::fs::NullListfile::contains
bool contains(std::string_view) const
Never contained.
Definition
listfile.hpp:51
wowlib::fs::NullListfile::fdidToPath
std::optional< std::string > fdidToPath(FileDataID) const
Always misses.
Definition
listfile.hpp:40
wowlib::fs::NullListfile::pathToFdid
std::optional< FileDataID > pathToFdid(std::string_view) const
Always misses.
Definition
listfile.hpp:35
src
wowlib
fs
listfile.hpp
Generated by
1.17.0