18#ifndef TRINITY_CHATCOMMANDHELPERS_H
19#define TRINITY_CHATCOMMANDHELPERS_H
24#include <fmt/printf.h>
40 template <
typename T,
typename =
void>
51 explicit operator bool()
const {
return !
token.empty(); }
59 if (
size_t delimPos = args.find(
COMMAND_DELIMITER); delimPos != std::string_view::npos)
61 result.
token = args.substr(0, delimPos);
62 if (
size_t tailPos = args.find_first_not_of(
COMMAND_DELIMITER, delimPos); tailPos != std::string_view::npos)
63 result.
tail = args.substr(tailPos);
97 std::string_view operator*()
const {
return std::get<std::string_view>(
_storage); }
105 std::variant<std::monostate, std::string_view, std::string>
_storage;
111 template <
typename... Ts>
TokenizeResult tokenize(std::string_view args) noexcept
static constexpr char COMMAND_DELIMITER
typename tag_base< T >::type tag_base_t
TC_GAME_API char const * GetTrinityString(ChatHandler const *handler, TrinityStrings which)
TC_GAME_API std::string FormatTrinityString(std::string_view messageFormat, fmt::printf_args messageFormatArgs)
TC_GAME_API void SendErrorMessageToHandler(ChatHandler *handler, std::string_view str)
ChatCommandResult(ChatCommandResult &&) noexcept=default
ChatCommandResult(ChatCommandResult const &)=delete
ChatCommandResult(std::string_view s) noexcept
bool IsSuccessful() const
ChatCommandResult & operator=(std::nullopt_t) noexcept
std::string const & GetErrorMessage() const &
bool HasErrorMessage() const
std::variant< std::monostate, std::string_view, std::string > _storage
std::string && GetErrorMessage() &&
ChatCommandResult(std::string &&s) noexcept
ChatCommandResult(std::nullopt_t) noexcept
ChatCommandResult & operator=(char const *c)
ChatCommandResult & operator=(std::string &&s) noexcept
ChatCommandResult(char const *c)
ChatCommandResult(std::string const &)=delete
ChatCommandResult & operator=(std::string_view s) noexcept