AzerothCore 3.3.5a
OpenSource WoW Emulator
Loading...
Searching...
No Matches
Acore::Impl::ChatCommands::MultiConsumer< Tuple, Optional< NestedNextType >, offset > Struct Template Reference

#include "ChatCommand.h"

Static Public Member Functions

static ChatCommandResult TryConsumeTo (Tuple &tuple, ChatHandler const *handler, std::string_view args)
 

Detailed Description

template<typename Tuple, typename NestedNextType, std::size_t offset>
struct Acore::Impl::ChatCommands::MultiConsumer< Tuple, Optional< NestedNextType >, offset >

Member Function Documentation

◆ TryConsumeTo()

template<typename Tuple , typename NestedNextType , std::size_t offset>
static ChatCommandResult Acore::Impl::ChatCommands::MultiConsumer< Tuple, Optional< NestedNextType >, offset >::TryConsumeTo ( Tuple &  tuple,
ChatHandler const *  handler,
std::string_view  args 
)
inlinestatic
75 {
76 // try with the argument
77 auto& myArg = std::get<offset>(tuple);
78 myArg.emplace();
79
80 ChatCommandResult result1 = ArgInfo<NestedNextType>::TryConsume(myArg.value(), handler, args);
81 if (result1)
82 if ((result1 = ConsumeFromOffset<Tuple, offset + 1>(tuple, handler, *result1)))
83 return result1;
84 // try again omitting the argument
85 myArg = std::nullopt;
86 ChatCommandResult result2 = ConsumeFromOffset<Tuple, offset + 1>(tuple, handler, args);
87 if (result2)
88 return result2;
89 if (result1.HasErrorMessage() && result2.HasErrorMessage())
90 {
91 return Acore::StringFormat("{} \"{}\"\n{} \"{}\"",
94 }
95 else if (result1.HasErrorMessage())
96 return result1;
97 else
98 return result2;
99 }
@ LANG_CMDPARSER_EITHER
Definition: Language.h:991
@ LANG_CMDPARSER_OR
Definition: Language.h:992
std::string StringFormat(FormatString< Args... > fmt, Args &&... args)
Default AC string format function.
Definition: StringFormat.h:34
AC_GAME_API char const * GetAcoreString(ChatHandler const *handler, AcoreStrings which)
Definition: ChatCommandHelpers.cpp:27
Definition: ChatCommandHelpers.h:100
bool HasErrorMessage() const
Definition: ChatCommandHelpers.h:115
std::string const & GetErrorMessage() const
Definition: ChatCommandHelpers.h:116

References Acore::Impl::ChatCommands::GetAcoreString(), Acore::Impl::ChatCommands::ChatCommandResult::GetErrorMessage(), Acore::Impl::ChatCommands::ChatCommandResult::HasErrorMessage(), LANG_CMDPARSER_EITHER, LANG_CMDPARSER_OR, and Acore::StringFormat().