VoltMod
C++23 framework for CS2 server plugins
Loading...
Searching...
No Matches
KeyValues.hpp
Go to the documentation of this file.
1#pragma once
2
5#include <string_view>
6
7namespace VoltMod
8{
9
10/**
11 * @brief Spawn keyvalues such as "origin", "spawnflags" or "effect_name".
12 *
13 * Owns the engine object until a spawn takes it; one that never spawns frees it.
14 */
16{
17public:
18 KeyValues();
19 ~KeyValues();
20 KeyValues(const KeyValues&) = delete;
21 KeyValues& operator=(const KeyValues&) = delete;
22
23 KeyValues& Set(std::string_view key, std::string_view value);
24
25 /** Without this a string literal picks the bool overload and sets "true". */
26 KeyValues& Set(std::string_view key, const char* value)
27 {
28 return Set(key, value ? std::string_view(value) : std::string_view{});
29 }
30
31 KeyValues& Set(std::string_view key, int value);
32 KeyValues& Set(std::string_view key, float value);
33 KeyValues& Set(std::string_view key, bool value);
34 KeyValues& Set(std::string_view key, const Vector& value);
35 KeyValues& Set(std::string_view key, const QAngle& value);
36 KeyValues& Set(std::string_view key, const Color& value);
37
38 /** The wrapped object; nullptr after Detach(). */
39 CEntityKeyValues* Raw() const { return _kv; }
40
41 /** Hand the object to the engine's spawn, which frees it. */
43
44private:
46};
47
48} // namespace VoltMod
Spawn keyvalues such as "origin", "spawnflags" or "effect_name".
Definition KeyValues.hpp:16
KeyValues & operator=(const KeyValues &)=delete
KeyValues & Set(std::string_view key, const char *value)
Definition KeyValues.hpp:26
KeyValues & Set(std::string_view key, std::string_view value)
Definition KeyValues.cpp:24
CEntityKeyValues * Raw() const
Definition KeyValues.hpp:39
KeyValues(const KeyValues &)=delete
CEntityKeyValues * Detach()
Definition KeyValues.cpp:87
static std::string ReadFile(const std::filesystem::path &path)
Definition Loader.cpp:56
::QAngle QAngle
Definition Math.hpp:14
::Vector Vector
Definition Math.hpp:11
An RGBA color in the engine's byte order, as m_clrRender and glow colors hold it.
Definition Color.hpp:15