AzerothCore 3.3.5a
OpenSource WoW Emulator
Loading...
Searching...
No Matches
Acore::ChatCommands::AccountIdentifier Struct Reference

#include "ChatCommandTags.h"

Inheritance diagram for Acore::ChatCommands::AccountIdentifier:
Acore::Impl::ChatCommands::ContainerTag

Public Types

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

Public Member Functions

 operator uint32 () const
 
 operator std::string const & () const
 
 operator std::string_view () const
 
uint32 GetID () const
 
std::string const & GetName () const
 
ChatCommandResult TryConsume (ChatHandler const *handler, std::string_view args)
 

Private Attributes

uint32 _id
 
std::string _name
 

Detailed Description

Member Typedef Documentation

◆ value_type

Member Function Documentation

◆ GetID()

uint32 Acore::ChatCommands::AccountIdentifier::GetID ( ) const
inline

◆ GetName()

std::string const & Acore::ChatCommands::AccountIdentifier::GetName ( ) const
inline

◆ operator std::string const &()

Acore::ChatCommands::AccountIdentifier::operator std::string const & ( ) const
inline
155{ return _name; }

◆ operator std::string_view()

Acore::ChatCommands::AccountIdentifier::operator std::string_view ( ) const
inline
156{ return { _name }; }

◆ operator uint32()

Acore::ChatCommands::AccountIdentifier::operator uint32 ( ) const
inline
154{ return _id; }

◆ TryConsume()

ChatCommandResult Acore::ChatCommands::AccountIdentifier::TryConsume ( ChatHandler const *  handler,
std::string_view  args 
)
62{
63 std::string_view text;
65 if (!next)
66 return next;
67
68 // first try parsing as account name
69 _name.assign(text);
72
74 if (_id) // account with name exists, we are done
75 return next;
76
77 // try parsing as account id instead
78 Optional<uint32> id = Acore::StringTo<uint32>(text, 10);
79 if (!id)
81
82 _id = *id;
83
85 return next;
86 else
88}
#define STRING_VIEW_FMT_ARG(str)
Definition: Define.h:101
std::optional< T > Optional
Optional helper class to wrap optional values within.
Definition: Optional.h:24
bool Utf8ToUpperOnlyLatin(std::string &utf8String)
Definition: Util.cpp:527
@ LANG_CMDPARSER_ACCOUNT_NAME_NO_EXIST
Definition: Language.h:1014
@ LANG_CMDPARSER_ACCOUNT_ID_NO_EXIST
Definition: Language.h:1015
@ LANG_CMDPARSER_INVALID_UTF8
Definition: Language.h:1012
uint32 GetId(std::string const &username)
Definition: AccountMgr.cpp:200
bool GetName(uint32 accountId, std::string &name)
Definition: AccountMgr.cpp:228
std::string FormatAcoreString(ChatHandler const *handler, AcoreStrings which, Ts &&... args)
Definition: ChatCommandHelpers.h:126
AC_GAME_API char const * GetAcoreString(ChatHandler const *handler, AcoreStrings which)
Definition: ChatCommandHelpers.cpp:28
Definition: ChatCommandArgs.h:50
Definition: ChatCommandHelpers.h:101

References Acore::Impl::ChatCommands::FormatAcoreString(), Acore::Impl::ChatCommands::GetAcoreString(), AccountMgr::GetId(), AccountMgr::GetName(), LANG_CMDPARSER_ACCOUNT_ID_NO_EXIST, LANG_CMDPARSER_ACCOUNT_NAME_NO_EXIST, LANG_CMDPARSER_INVALID_UTF8, STRING_VIEW_FMT_ARG, and Utf8ToUpperOnlyLatin().

Member Data Documentation

◆ _id

uint32 Acore::ChatCommands::AccountIdentifier::_id
private

◆ _name

std::string Acore::ChatCommands::AccountIdentifier::_name
private