AzerothCore 3.3.5a
OpenSource WoW Emulator
Loading...
Searching...
No Matches
Acore::ChatCommands::ExactSequence< chars > Struct Template Reference

#include "ChatCommandTags.h"

Inheritance diagram for Acore::ChatCommands::ExactSequence< chars >:
Acore::Impl::ChatCommands::ContainerTag

Public Types

using value_type = void
 
- Public Types inherited from Acore::Impl::ChatCommands::ContainerTag
using ChatCommandResult = Acore::Impl::ChatCommands::ChatCommandResult
 

Public Member Functions

ChatCommandResult TryConsume (ChatHandler const *handler, std::string_view args) const
 

Static Private Attributes

static constexpr std::array< char, sizeof...(chars)> _storage = { chars... }
 
static constexpr std::string_view _string = { _storage.data(), std::string_view::traits_type::length(_storage.data()) }
 

Detailed Description

template<char... chars>
struct Acore::ChatCommands::ExactSequence< chars >

Member Typedef Documentation

◆ value_type

template<char... chars>
using Acore::ChatCommands::ExactSequence< chars >::value_type = void

Member Function Documentation

◆ TryConsume()

template<char... chars>
ChatCommandResult Acore::ChatCommands::ExactSequence< chars >::TryConsume ( ChatHandler const *  handler,
std::string_view  args 
) const
inline
89 {
90 if (args.empty())
91 return std::nullopt;
92 std::string_view start = args.substr(0, _string.length());
93 if (StringEqualI(start, _string))
94 {
95 auto [remainingToken, tail] = Acore::Impl::ChatCommands::tokenize(args.substr(_string.length()));
96 if (remainingToken.empty()) // if this is not empty, then we did not consume the full token
97 return tail;
98 start = args.substr(0, _string.length() + remainingToken.length());
99 }
101 }
bool StringEqualI(std::string_view a, std::string_view b)
Definition: Util.cpp:592
@ LANG_CMDPARSER_EXACT_SEQ_MISMATCH
Definition: Language.h:1006
std::string FormatAcoreString(ChatHandler const *handler, AcoreStrings which, Ts &&... args)
Definition: ChatCommandHelpers.h:125
TokenizeResult tokenize(std::string_view args)
Definition: ChatCommandHelpers.h:54
static constexpr std::string_view _string
Definition: ChatCommandTags.h:106

References Acore::ChatCommands::ExactSequence< chars >::_string, Acore::Impl::ChatCommands::FormatAcoreString(), LANG_CMDPARSER_EXACT_SEQ_MISMATCH, StringEqualI(), and Acore::Impl::ChatCommands::tokenize().

Member Data Documentation

◆ _storage

template<char... chars>
constexpr std::array<char, sizeof...(chars)> Acore::ChatCommands::ExactSequence< chars >::_storage = { chars... }
staticconstexprprivate

◆ _string

template<char... chars>
constexpr std::string_view Acore::ChatCommands::ExactSequence< chars >::_string = { _storage.data(), std::string_view::traits_type::length(_storage.data()) }
staticconstexprprivate