VoltMod
C++23 framework for CS2 server plugins
Loading...
Searching...
No Matches
LanguageTable.hpp
Go to the documentation of this file.
1#pragma once
2
6#include <string>
7#include <string_view>
8
9namespace VoltMod
10{
11
12/** The host's @ref IPluginLanguages. @ref PluginRegistry resets a slot on connect and after disconnect. */
14{
15public:
16 std::string_view Language(int slot) const override
17 {
18 return IsValidSlot(slot) ? std::string_view(_languages[slot]) : std::string_view{};
19 }
20
21 void SetLanguage(int slot, std::string_view lang) override
22 {
23 if (IsValidSlot(slot))
24 {
25 _languages[slot] = lang;
26 }
27 }
28
29 void Reset(int slot) { _languages.Reset(slot); }
30
31private:
32 PerSlot<std::string> _languages;
33};
34
35} // namespace VoltMod
std::string_view Language(int slot) const override
void SetLanguage(int slot, std::string_view lang) override
Per-player-slot value store that never leaks state across occupants.
Definition PerSlot.hpp:25
void Reset(int slot)
Definition PerSlot.hpp:48
static std::string ReadFile(const std::filesystem::path &path)
Definition Loader.cpp:56
constexpr bool IsValidSlot(int slot)
Definition Slot.hpp:13