32inline uint8 toHex(
char c) {
return (c >=
'0' && c <=
'9') ? c -
'0' + 0x10 : (c >=
'a' && c <=
'f') ? c -
'a' + 0x1a : 0x00; }
38 std::string_view data;
39 std::string_view text;
42 if (str.substr(0, 2) !=
"|c")
49 for (
uint8 i = 0; i < 8; ++i)
52 color = (color << 4) | (hex & 0xf);
58 if (str.substr(0, 2) !=
"|H")
63 if (
size_t delimPos = str.find(
'|'); delimPos != std::string_view::npos)
65 tag = str.substr(0, delimPos);
66 str.remove_prefix(delimPos+1);
72 if (
size_t dataStart = tag.find(
':'); dataStart != std::string_view::npos)
74 data = tag.substr(dataStart+1);
75 tag = tag.substr(0, dataStart);
79 if (str.substr(0, 1) !=
"h")
83 if (
size_t end = str.find(
'|'); end != std::string_view::npos)
86 if (str.substr(end, 4) !=
"|h|r")
89 if ((str[0] !=
'[') || (str[end - 1] !=
']'))
91 text = str.substr(1, end - 2);
93 str = str.substr(end + 4);
99 return { str, color, tag, data, text };
105 static bool IsTextValid(
typename T::value_type, std::string_view) {
return true; }
135 std::array<char const*, 16>
const* randomSuffixes =
nullptr;
142 randomSuffixes =
nullptr;
153 std::string_view randomSuffix((*randomSuffixes)[i]);
155 (!randomSuffix.empty()) &&
156 (text.length() == (name.length() + 1 + randomSuffix.length())) &&
157 (text.substr(0, name.length()) == name) &&
158 (text[name.length()] ==
' ') &&
159 (text.substr(name.length() + 1) == randomSuffix)
163 else if (text == name)
196 if (!name.empty() && (text == name))
237 if (bounds.first == bounds.second)
240 for (
auto pair = bounds.first; pair != bounds.second; ++pair)
248 std::string_view skillName = skill->
DisplayName[i];
249 std::string_view spellName = info->
SpellName[i];
251 if ((text.length() == (skillName.length() + 2 + spellName.length())) &&
252 (text.substr(0, skillName.length()) == skillName) &&
253 (text.substr(skillName.length(), 2) ==
": ") &&
254 (text.substr(skillName.length() + 2) == spellName))
316template <
typename TAG>
319 std::decay_t<typename TAG::value_type> t;
320 if (!TAG::StoreTo(t, info.
data))
337#define TryValidateAs(T) do { if (info.tag == T::tag()) return ValidateAs<T>(info); } while (0);
341 using namespace LinkTags;
371 std::string_view::size_type pos = 0;
372 while ((pos = str.find(
'|', pos)) != std::string::npos)
375 if (pos == str.length())
377 char next = str[pos];
378 if (next ==
'H' || next ==
'h' || next ==
'c' || next ==
'r' || next ==
'|')
392 std::string::size_type pos;
393 while ((pos = str.find(
'|')) != std::string::npos)
395 if (str[pos + 1] ==
'|')
397 str = str.substr(pos + 2);
DBCStorage< SkillLineEntry > sSkillLineStore(SkillLinefmt)
static bool ValidateAs(HyperlinkInfo const &info)
static bool ValidateLinkInfo(HyperlinkInfo const &info)
uint32 constexpr ItemQualityColors[MAX_ITEM_QUALITY]
@ CHAT_LINK_COLOR_ACHIEVEMENT
@ CHAT_LINK_COLOR_ENCHANT
uint32 constexpr QuestDifficultyColors[MAX_QUEST_DIFFICULTY]
size_t constexpr MAX_QUEST_DIFFICULTY
std::pair< SkillLineAbilityMap::const_iterator, SkillLineAbilityMap::const_iterator > SkillLineAbilityMapBounds
static std::string_view GetLocaleString(std::vector< std::string > const &data, size_t locale)
uint32 GetQuestId() const
std::string const & GetTitle() const
std::array< char const *, 16 > SpellName
@ CONFIG_CHAT_STRICT_LINK_CHECKING_SEVERITY
bool TC_GAME_API CheckAllLinks(std::string_view str)
HyperlinkInfo TC_GAME_API ParseSingleHyperlink(std::string_view str)
std::array< char const *, 16 > Title
std::vector< std::string > Name
std::array< char const *, 16 > Name
std::array< char const *, 16 > Name
static bool IsTextValid(typename T::value_type, std::string_view)
static bool IsColorValid(typename T::value_type, HyperlinkColor)
std::vector< std::string > Title
char const * DisplayName[16]
std::array< uint32, MAX_TALENT_RANK > SpellRank
AchievementEntry const * Achievement
GlyphPropertiesEntry const * Glyph
std::string_view const data
std::string_view const text
std::string_view const tail
HyperlinkColor const color
ItemRandomSuffixEntry const * RandomSuffix
ItemRandomPropertiesEntry const * RandomProperty
ItemTemplate const * Item
TalentEntry const * Talent