Replace boost::optional with std::optional (#4877)
This commit is contained in:
@@ -11,6 +11,7 @@
|
||||
#include "providers/seventv/SeventvAPI.hpp"
|
||||
#include "providers/twitch/TwitchChannel.hpp"
|
||||
#include "singletons/Settings.hpp"
|
||||
#include "util/Helpers.hpp"
|
||||
|
||||
#include <QJsonArray>
|
||||
#include <QJsonDocument>
|
||||
@@ -109,7 +110,7 @@ CreateEmoteResult createEmote(const QJsonObject &activeEmote,
|
||||
auto emote =
|
||||
Emote({emoteName, imageSet, tooltip,
|
||||
Url{EMOTE_LINK_FORMAT.arg(emoteId.string)}, zeroWidth, emoteId,
|
||||
author, boost::make_optional(aliasedName, baseEmoteName)});
|
||||
author, makeConditionedOptional(aliasedName, baseEmoteName)});
|
||||
|
||||
return {emote, emoteId, emoteName, !emote.images.getImage1()->isEmpty()};
|
||||
}
|
||||
@@ -162,7 +163,7 @@ EmotePtr createUpdatedEmote(const EmotePtr &oldEmote,
|
||||
bool toNonAliased = oldEmote->baseName.has_value() &&
|
||||
dispatch.emoteName == oldEmote->baseName->string;
|
||||
|
||||
auto baseName = oldEmote->baseName.get_value_or(oldEmote->name);
|
||||
auto baseName = oldEmote->baseName.value_or(oldEmote->name);
|
||||
auto emote = std::make_shared<const Emote>(Emote(
|
||||
{EmoteName{dispatch.emoteName}, oldEmote->images,
|
||||
toNonAliased
|
||||
@@ -170,7 +171,7 @@ EmotePtr createUpdatedEmote(const EmotePtr &oldEmote,
|
||||
: createAliasedTooltip(dispatch.emoteName, baseName.string,
|
||||
oldEmote->author.string, false),
|
||||
oldEmote->homePage, oldEmote->zeroWidth, oldEmote->id,
|
||||
oldEmote->author, boost::make_optional(!toNonAliased, baseName)}));
|
||||
oldEmote->author, makeConditionedOptional(!toNonAliased, baseName)}));
|
||||
return emote;
|
||||
}
|
||||
|
||||
@@ -191,15 +192,14 @@ std::shared_ptr<const EmoteMap> SeventvEmotes::globalEmotes() const
|
||||
return this->global_.get();
|
||||
}
|
||||
|
||||
boost::optional<EmotePtr> SeventvEmotes::globalEmote(
|
||||
const EmoteName &name) const
|
||||
std::optional<EmotePtr> SeventvEmotes::globalEmote(const EmoteName &name) const
|
||||
{
|
||||
auto emotes = this->global_.get();
|
||||
auto it = emotes->find(name);
|
||||
|
||||
if (it == emotes->end())
|
||||
{
|
||||
return boost::none;
|
||||
return std::nullopt;
|
||||
}
|
||||
return it->second;
|
||||
}
|
||||
@@ -328,7 +328,7 @@ void SeventvEmotes::loadChannelEmotes(
|
||||
});
|
||||
}
|
||||
|
||||
boost::optional<EmotePtr> SeventvEmotes::addEmote(
|
||||
std::optional<EmotePtr> SeventvEmotes::addEmote(
|
||||
Atomic<std::shared_ptr<const EmoteMap>> &map,
|
||||
const EmoteAddDispatch &dispatch)
|
||||
{
|
||||
@@ -336,7 +336,7 @@ boost::optional<EmotePtr> SeventvEmotes::addEmote(
|
||||
auto emoteData = dispatch.emoteJson["data"].toObject();
|
||||
if (emoteData.empty() || !checkEmoteVisibility(emoteData))
|
||||
{
|
||||
return boost::none;
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
// This copies the map.
|
||||
@@ -347,7 +347,7 @@ boost::optional<EmotePtr> SeventvEmotes::addEmote(
|
||||
// Incoming emote didn't contain any images, abort
|
||||
qCDebug(chatterinoSeventv)
|
||||
<< "Emote without images:" << dispatch.emoteJson;
|
||||
return boost::none;
|
||||
return std::nullopt;
|
||||
}
|
||||
auto emote = std::make_shared<const Emote>(std::move(result.emote));
|
||||
updatedMap[result.name] = emote;
|
||||
@@ -356,7 +356,7 @@ boost::optional<EmotePtr> SeventvEmotes::addEmote(
|
||||
return emote;
|
||||
}
|
||||
|
||||
boost::optional<EmotePtr> SeventvEmotes::updateEmote(
|
||||
std::optional<EmotePtr> SeventvEmotes::updateEmote(
|
||||
Atomic<std::shared_ptr<const EmoteMap>> &map,
|
||||
const EmoteUpdateDispatch &dispatch)
|
||||
{
|
||||
@@ -364,7 +364,7 @@ boost::optional<EmotePtr> SeventvEmotes::updateEmote(
|
||||
auto oldEmote = oldMap->findEmote(dispatch.emoteName, dispatch.emoteID);
|
||||
if (oldEmote == oldMap->end())
|
||||
{
|
||||
return boost::none;
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
// This copies the map.
|
||||
@@ -378,7 +378,7 @@ boost::optional<EmotePtr> SeventvEmotes::updateEmote(
|
||||
return emote;
|
||||
}
|
||||
|
||||
boost::optional<EmotePtr> SeventvEmotes::removeEmote(
|
||||
std::optional<EmotePtr> SeventvEmotes::removeEmote(
|
||||
Atomic<std::shared_ptr<const EmoteMap>> &map,
|
||||
const EmoteRemoveDispatch &dispatch)
|
||||
{
|
||||
@@ -389,7 +389,7 @@ boost::optional<EmotePtr> SeventvEmotes::removeEmote(
|
||||
{
|
||||
// We already copied the map at this point and are now discarding the copy.
|
||||
// This is fine, because this case should be really rare.
|
||||
return boost::none;
|
||||
return std::nullopt;
|
||||
}
|
||||
auto emote = it->second;
|
||||
updatedMap.erase(it);
|
||||
|
||||
Reference in New Issue
Block a user