2018-08-02 14:23:27 +02:00
|
|
|
#pragma once
|
|
|
|
|
2022-12-31 15:41:01 +01:00
|
|
|
#include "common/Aliases.hpp"
|
2018-08-02 14:23:27 +02:00
|
|
|
#include "messages/ImageSet.hpp"
|
|
|
|
|
2022-11-13 12:07:41 +01:00
|
|
|
#include <boost/optional.hpp>
|
Sort and force grouping of includes (#4172)
This change enforces strict include grouping using IncludeCategories
In addition to adding this to the .clang-format file and applying it in the tests/src and src directories, I also did the following small changes:
In ChatterSet.hpp, I changed lrucache to a <>include
In Irc2.hpp, I change common/SignalVector.hpp to a "project-include"
In AttachedWindow.cpp, NativeMessaging.cpp, WindowsHelper.hpp, BaseWindow.cpp, and StreamerMode.cpp, I disabled clang-format for the windows-includes
In WindowDescriptors.hpp, I added the missing vector include. It was previously not needed because the include was handled by another file that was previously included first.
clang-format minimum version has been bumped, so Ubuntu version used in the check-formatting job has been bumped to 22.04 (which is the latest LTS)
2022-11-27 19:32:53 +01:00
|
|
|
|
2018-08-02 14:23:27 +02:00
|
|
|
#include <functional>
|
|
|
|
#include <memory>
|
2022-12-31 15:41:01 +01:00
|
|
|
#include <mutex>
|
2018-08-02 14:23:27 +02:00
|
|
|
#include <unordered_map>
|
|
|
|
|
|
|
|
namespace chatterino {
|
|
|
|
|
|
|
|
struct Emote {
|
|
|
|
EmoteName name;
|
|
|
|
ImageSet images;
|
|
|
|
Tooltip tooltip;
|
|
|
|
Url homePage;
|
2022-10-16 13:22:17 +02:00
|
|
|
bool zeroWidth;
|
2022-11-13 12:07:41 +01:00
|
|
|
EmoteId id;
|
|
|
|
EmoteAuthor author;
|
|
|
|
/**
|
|
|
|
* If this emote is aliased, this contains
|
|
|
|
* the original (base) name of the emote.
|
|
|
|
*/
|
|
|
|
boost::optional<EmoteName> baseName;
|
2018-08-02 14:23:27 +02:00
|
|
|
|
|
|
|
// FOURTF: no solution yet, to be refactored later
|
|
|
|
const QString &getCopyString() const
|
|
|
|
{
|
|
|
|
return name.string;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
bool operator==(const Emote &a, const Emote &b);
|
|
|
|
bool operator!=(const Emote &a, const Emote &b);
|
|
|
|
|
|
|
|
using EmotePtr = std::shared_ptr<const Emote>;
|
|
|
|
|
|
|
|
class EmoteMap : public std::unordered_map<EmoteName, EmotePtr>
|
|
|
|
{
|
2022-11-13 12:07:41 +01:00
|
|
|
public:
|
|
|
|
/**
|
|
|
|
* Finds an emote by it's id with a hint to it's name.
|
|
|
|
*
|
|
|
|
* 1. Searches by name for the emote, checking if the ids match (fast-path).
|
|
|
|
* 2. Searches through the map for an emote with the `emoteID` (slow-path).
|
|
|
|
*
|
|
|
|
* @param emoteNameHint A hint to the name of the searched emote,
|
|
|
|
* may be empty.
|
|
|
|
* @param emoteID The emote id to search for.
|
|
|
|
* @return An iterator to the found emote (possibly this->end()).
|
|
|
|
*/
|
|
|
|
EmoteMap::const_iterator findEmote(const QString &emoteNameHint,
|
|
|
|
const QString &emoteID) const;
|
2018-08-02 14:23:27 +02:00
|
|
|
};
|
|
|
|
|
2022-08-28 12:20:47 +02:00
|
|
|
static const std::shared_ptr<const EmoteMap> EMPTY_EMOTE_MAP = std::make_shared<
|
|
|
|
const EmoteMap>(); // NOLINT(cert-err58-cpp) -- assume this doesn't throw an exception
|
|
|
|
|
2018-08-11 14:20:53 +02:00
|
|
|
EmotePtr cachedOrMakeEmotePtr(Emote &&emote, const EmoteMap &cache);
|
2018-08-11 17:15:17 +02:00
|
|
|
EmotePtr cachedOrMakeEmotePtr(
|
|
|
|
Emote &&emote,
|
|
|
|
std::unordered_map<EmoteId, std::weak_ptr<const Emote>> &cache,
|
|
|
|
std::mutex &mutex, const EmoteId &id);
|
2018-08-11 14:20:53 +02:00
|
|
|
|
2018-08-02 14:23:27 +02:00
|
|
|
} // namespace chatterino
|