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

#include "ChatCommandTags.h"

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

Public Types

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

Public Member Functions

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

Detailed Description

Member Typedef Documentation

◆ value_type

Member Function Documentation

◆ TryConsume()

ChatCommandResult Acore::ChatCommands::QuotedString::TryConsume ( ChatHandler const *  handler,
std::string_view  args 
)
29{
30 if (args.empty())
31 return std::nullopt;
32
33 if ((args[0] != '"') && (args[0] != '\''))
34 return ArgInfo<std::string>::TryConsume(*this, handler, args);
35
36 char const QUOTE = args[0];
37 for (size_t i = 1; i < args.length(); ++i)
38 {
39 if (args[i] == QUOTE)
40 {
41 auto [remainingToken, tail] = tokenize(args.substr(i + 1));
42 if (remainingToken.empty()) // if this is not empty, then we did not consume the full token
43 return tail;
44 else
45 return std::nullopt;
46 }
47
48 if (args[i] == '\\')
49 {
50 ++i;
51 if (!(i < args.length()))
52 break;
53 }
54 std::string::push_back(args[i]);
55 }
56
57 // if we reach this, we did not find a closing quote
58 return std::nullopt;
59}
TokenizeResult tokenize(std::string_view args)
Definition: ChatCommandHelpers.h:55
Definition: ChatCommandArgs.h:50

References Acore::Impl::ChatCommands::tokenize().