VoltMod
C++23 framework for CS2 server plugins
Loading...
Searching...
No Matches
CommandNames.cpp
Go to the documentation of this file.
1
#include "
Host/Plugins/CommandNames.hpp
"
2
3
#include <algorithm>
4
5
namespace
VoltMod
6
{
7
8
bool
CommandNames::Register
(
OwnerId
owner
, std::string_view
ownerName
, std::string_view name)
9
{
10
if
(name.empty())
11
{
12
return
false
;
13
}
14
15
const
auto
found
= std::ranges::find(_entries, name, &Entry::Name);
16
if
(
found
!= _entries.end())
17
{
18
return
found
->Owner ==
owner
;
19
}
20
21
_entries.push_back({.Name = std::string(name), .Owner =
owner
, .OwnerName = std::string(
ownerName
)});
22
return
true
;
23
}
24
25
void
CommandNames::Reserve
(std::string_view name)
26
{
27
if
(!name.empty() && std::ranges::find(_entries, name, &Entry::Name) == _entries.end())
28
{
29
_entries.push_back({.Name = std::string(name), .Owner =
nullptr
, .OwnerName =
"the host"
});
30
}
31
}
32
33
std::string_view
CommandNames::OwnerOf
(std::string_view name)
const
34
{
35
const
auto
found
= std::ranges::find(_entries, name, &Entry::Name);
36
return
found
!= _entries.end() ? std::string_view(
found
->OwnerName) : std::string_view();
37
}
38
39
void
CommandNames::RemoveAll
(
OwnerId
owner
)
40
{
41
std::erase_if(_entries, [
owner
](
const
Entry&
entry
) {
return
entry
.Owner ==
owner
; });
42
}
43
44
}
// namespace VoltMod
CommandNames.hpp
VoltMod::CommandNames::OwnerId
const void * OwnerId
Definition
CommandNames.hpp:15
VoltMod::CommandNames::RemoveAll
void RemoveAll(OwnerId owner)
Definition
CommandNames.cpp:39
VoltMod::CommandNames::Register
bool Register(OwnerId owner, std::string_view ownerName, std::string_view name)
Definition
CommandNames.cpp:8
VoltMod::CommandNames::Reserve
void Reserve(std::string_view name)
Definition
CommandNames.cpp:25
VoltMod::CommandNames::OwnerOf
std::string_view OwnerOf(std::string_view name) const
Definition
CommandNames.cpp:33
VoltMod
Definition
Options.hpp:13
VoltMod::ReadFile
static std::string ReadFile(const std::filesystem::path &path)
Definition
Loader.cpp:56
src
Host
Plugins
CommandNames.cpp
Generated by
1.9.8