#pragma once #include "util/ConcurrentMap.hpp" #include #include #include #include #include #include namespace chatterino { struct Emote; using EmotePtr = std::shared_ptr; struct EmojiData { // actual byte-representation of the emoji (i.e. \154075\156150 which is // :male:) QString value; // i.e. 204e-50a2 QString unifiedCode; QString nonQualifiedCode; // i.e. thinking std::vector shortCodes; std::set capabilities; std::vector variations; EmotePtr emote; }; using EmojiMap = ConcurrentMap>; class Emojis { public: void initialize(); void load(); std::vector> parse(const QString &text); EmojiMap emojis; std::vector shortCodes; QString replaceShortCodes(const QString &text); private: void loadEmojis(); void sortEmojis(); void loadEmojiSet(); /// Emojis QRegularExpression findShortCodesRegex_{":([-+\\w]+):"}; // shortCodeToEmoji maps strings like "sunglasses" to its emoji QMap> emojiShortCodeToEmoji_; // Maps the first character of the emoji unicode string to a vector of // possible emojis QMap>> emojiFirstByte_; }; } // namespace chatterino