VoltMod
C++23 framework for CS2 server plugins
Loading...
Searching...
No Matches
CommandSyntax.hpp
Go to the documentation of this file.
1
#pragma once
2
3
#include <optional>
4
#include <string>
5
#include <string_view>
6
#include <vector>
7
8
namespace
VoltMod::CommandSyntax
9
{
10
11
/**
12
* @file CommandSyntax.hpp
13
* @brief How a chat line is spelled: the prefix, and splitting one into tokens.
14
*
15
* Pure text, no registrations and no engine, which is what keeps the whole dispatch path
16
* unit-testable. Separate from @ref CommandRouter because none of it depends on which commands
17
* happen to be registered.
18
*/
19
20
/** Split @p text on spaces. A `"quoted run"` is one token and `\"` is a literal quote. Repeated
21
* spaces produce no blank arguments; an explicit `""` is an empty argument. */
22
std::vector<std::string>
Tokenize
(std::string_view
text
);
23
24
/** @p message without its command prefix, or nullopt when it carries none. */
25
std::optional<std::string_view>
StripPrefix
(std::string_view
message
);
26
27
/** What starts a chat command, and what a chat usage line shows. */
28
inline
constexpr
std::string_view
ChatPrefix
=
"!"
;
29
30
}
// namespace VoltMod::CommandSyntax
VoltMod::CommandSyntax
Definition
CommandSyntax.cpp:4
VoltMod::CommandSyntax::StripPrefix
std::optional< std::string_view > StripPrefix(std::string_view message)
Definition
CommandSyntax.cpp:49
VoltMod::CommandSyntax::ChatPrefix
constexpr std::string_view ChatPrefix
Definition
CommandSyntax.hpp:28
VoltMod::CommandSyntax::Tokenize
std::vector< std::string > Tokenize(std::string_view text)
Definition
CommandSyntax.cpp:6
VoltMod::ReadFile
static std::string ReadFile(const std::filesystem::path &path)
Definition
Loader.cpp:56
src
Commands
CommandSyntax.hpp
Generated by
1.9.8