VoltMod
C++23 framework for CS2 server plugins
Loading...
Searching...
No Matches
GameDataTable.hpp
Go to the documentation of this file.
1#pragma once
2
5
8#include <memory>
9#include <string>
10#include <string_view>
11
12namespace VoltMod
13{
14
15/** The process's one gamedata resolution, made at host load and served to every plugin. What
16 * did not bind is logged here once; each plugin's services report it again as unavailable. */
18{
19public:
20 /** Read and resolve @p path. @p originalOf reads a slot another module already hooked. */
21 explicit GameDataTable(std::string_view path, const OriginalSlotLookup& originalOf = {},
22 const ScriptBindingLookup& scriptOf = {});
23
24 /** False when the file could not be read. */
25 bool Ready() const { return _scanner != nullptr; }
26
27 GameDataLocation Lookup(GameDataSection sections, std::string_view key) override;
28
29private:
30 /** An entry that did not bind, keeping @p reason until the next lookup. */
31 GameDataLocation NotBound(std::string reason);
32
33 // The scanner keeps a reference to the document, so the two live and die together.
34 std::unique_ptr<GameDataDocument> _file;
35 std::unique_ptr<GameDataScanner> _scanner;
36 OriginalSlotLookup _originalOf;
37 ScriptBindingLookup _scriptOf;
38 std::string _reason;
39};
40
41} // namespace VoltMod
GameDataLocation Lookup(GameDataSection sections, std::string_view key) override
std::function< Result< ScriptTarget >(void *classTable, std::string_view name)> ScriptBindingLookup
static std::string ReadFile(const std::filesystem::path &path)
Definition Loader.cpp:56
std::function< const void *(void **vtable, int index)> OriginalSlotLookup