|
VoltMod
C++23 framework for CS2 server plugins
|
Collection of static string manipulation utilities. More...
#include <Strings.hpp>
Static Public Member Functions | |
| static std::string | ToLower (std::string_view str) |
| static std::string | Trim (std::string_view str) |
| static std::string | Join (const std::vector< std::string > &parts, std::string_view delimiter) |
| static std::string | JoinNonEmpty (const std::vector< std::string > &parts, std::string_view delimiter) |
| static bool | StartsWith (std::string_view str, std::string_view prefix) |
| static bool | ContainsIgnoreCase (std::string_view str, std::string_view substr) |
| static std::string | SubstituteTokens (std::string text, const Tokens &tokens) |
| static std::string | EscapeHtml (std::string_view text) |
| static std::string | QuoteConsoleArg (std::string_view value) |
| static std::string | TruncateUtf8 (std::string_view text, std::size_t maxBytes, std::string_view ellipsis="...") |
| static bool | IsNumeric (std::string_view str) |
| static void | CopyToBuffer (char *buffer, std::size_t size, std::string_view text) noexcept |
| static std::string | DisplayNameOr (int64_t id, std::string_view name, std::size_t maxBytes=20) |
Collection of static string manipulation utilities.
Definition at line 34 of file Strings.hpp.
|
static |
Definition at line 153 of file Strings.cpp.
References VoltMod::ReadFile(), and ToLower().
|
staticnoexcept |
Copy text into a caller's C error buffer of size bytes, cut to fit and NUL-terminated.
Definition at line 257 of file Strings.cpp.
References VoltMod::ReadFile().
Referenced by VoltMod::Internal::PluginModule::Attach(), and VoltMod_HostStart().
|
static |
Row display text, HTML-escaped: the (UTF-8-safely truncated) name, or id when unnamed.
Definition at line 269 of file Strings.cpp.
References EscapeHtml(), VoltMod::ReadFile(), and TruncateUtf8().
|
static |
Escape ‘& < > " ’` as HTML entities for safe embedding in center-HTML panels.
Definition at line 185 of file Strings.cpp.
References VoltMod::ReadFile().
Referenced by DisplayNameOr(), VoltMod::RenderCaptureOverlay(), VoltMod::RenderHeader(), VoltMod::RenderMenuHtml(), and VoltMod::RowText().
|
static |
Definition at line 248 of file Strings.cpp.
References VoltMod::ReadFile().
Referenced by VoltMod::BindDuration(), VoltMod::BindPlayerOrSteamId(), and VoltMod::BindSteamId().
|
static |
Definition at line 114 of file Strings.cpp.
References VoltMod::ReadFile().
Referenced by VoltMod::Bindings::Bind(), VoltMod::BindArgs(), and VoltMod::GameDataTable::GameDataTable().
|
static |
Join parts with delimiter, skipping empty ones.
For text assembled from optional pieces - a ban notice's reason, expiry and appeal link, say. Skipping is the point: a piece that is not configured must not leave a dangling delimiter or a bare label behind it.
Definition at line 130 of file Strings.cpp.
References VoltMod::ReadFile().
|
static |
Quote value as a single console-command argument: wrapped in "</tt>, with <tt>" and \ escaped.
The engine's command parser splits on whitespace and treats ; as a command separator, so an unquoted value containing either is truncated or runs a second command. A newline cannot be escaped by quoting at all - it always ends the line - which is why ConVars::ExecuteServerCommand rejects one outright rather than relying on this.
Definition at line 216 of file Strings.cpp.
References VoltMod::ReadFile().
Referenced by VoltMod::ConVars::SetByConsole().
|
static |
Definition at line 148 of file Strings.cpp.
References VoltMod::ReadFile().
Referenced by VoltMod::FilterPlayers(), and VoltMod::ParseTargetToken().
Replace each {key} occurrence in text with its mapped value.
Definition at line 176 of file Strings.cpp.
References VoltMod::ReadFile(), and VoltMod::ReplaceAll().
Referenced by VoltMod::Translations::Get(), and VoltMod::Json::SubstituteTokens().
|
static |
Definition at line 100 of file Strings.cpp.
References VoltMod::ReadFile().
Referenced by VoltMod::CommandRouter::Add(), ContainsIgnoreCase(), VoltMod::PluginLoader::Defer(), VoltMod::DriverName(), VoltMod::FilterPlayers(), VoltMod::CommandRouter::Find(), VoltMod::CommandRouter::IsForeign(), VoltMod::ChatColors::ParseNamed(), and VoltMod::ParseTargetToken().
|
static |
Definition at line 107 of file Strings.cpp.
References VoltMod::ReadFile().
Referenced by VoltMod::ConVars::ExecuteFile(), VoltMod::GameBuild(), and VoltMod::Validation::NormalizeTag().
|
static |
Truncate to at most maxBytes bytes plus ellipsis, cutting at a UTF-8 sequence boundary so multibyte text (e.g. Cyrillic) never renders a split character.
Definition at line 233 of file Strings.cpp.
References VoltMod::ReadFile().
Referenced by DisplayNameOr().