Replace boost::optional with std::optional (#4877)

This commit is contained in:
pajlada
2023-10-08 18:50:48 +02:00
committed by GitHub
parent fe4d6121a2
commit fec45889a8
88 changed files with 428 additions and 383 deletions
+15 -15
View File
@@ -228,8 +228,8 @@ MessagePtr TwitchMessageBuilder::build()
this->args.channelPointRewardId);
if (reward)
{
this->appendChannelPointRewardMessage(
reward.get(), this, this->channel->isMod(),
TwitchMessageBuilder::appendChannelPointRewardMessage(
*reward, this, this->channel->isMod(),
this->channel->isBroadcaster());
}
}
@@ -1069,7 +1069,7 @@ Outcome TwitchMessageBuilder::tryAppendEmote(const EmoteName &name)
const auto &globalSeventvEmotes = app->twitch->getSeventvEmotes();
auto flags = MessageElementFlags();
auto emote = boost::optional<EmotePtr>{};
auto emote = std::optional<EmotePtr>{};
bool zeroWidth = false;
// Emote order:
@@ -1115,7 +1115,7 @@ Outcome TwitchMessageBuilder::tryAppendEmote(const EmoteName &name)
!this->isEmpty())
{
// Attempt to merge current zero-width emote into any previous emotes
auto asEmote = dynamic_cast<EmoteElement *>(&this->back());
auto *asEmote = dynamic_cast<EmoteElement *>(&this->back());
if (asEmote)
{
// Make sure to access asEmote before taking ownership when releasing
@@ -1124,18 +1124,18 @@ Outcome TwitchMessageBuilder::tryAppendEmote(const EmoteName &name)
auto baseEmoteElement = this->releaseBack();
std::vector<LayeredEmoteElement::Emote> layers = {
{baseEmote, baseEmoteElement->getFlags()},
{emote.get(), flags}};
{baseEmote, baseEmoteElement->getFlags()}, {*emote, flags}};
this->emplace<LayeredEmoteElement>(
std::move(layers), baseEmoteElement->getFlags() | flags,
this->textColor_);
return Success;
}
auto asLayered = dynamic_cast<LayeredEmoteElement *>(&this->back());
auto *asLayered =
dynamic_cast<LayeredEmoteElement *>(&this->back());
if (asLayered)
{
asLayered->addEmoteLayer({emote.get(), flags});
asLayered->addEmoteLayer({*emote, flags});
asLayered->addFlags(flags);
return Success;
}
@@ -1143,15 +1143,15 @@ Outcome TwitchMessageBuilder::tryAppendEmote(const EmoteName &name)
// No emote to merge with, just show as regular emote
}
this->emplace<EmoteElement>(emote.get(), flags, this->textColor_);
this->emplace<EmoteElement>(*emote, flags, this->textColor_);
return Success;
}
return Failure;
}
boost::optional<EmotePtr> TwitchMessageBuilder::getTwitchBadge(
const Badge &badge)
std::optional<EmotePtr> TwitchMessageBuilder::getTwitchBadge(
const Badge &badge) const
{
if (auto channelBadge =
this->twitchChannel->twitchBadge(badge.key_, badge.value_))
@@ -1165,7 +1165,7 @@ boost::optional<EmotePtr> TwitchMessageBuilder::getTwitchBadge(
return globalBadge;
}
return boost::none;
return std::nullopt;
}
std::unordered_map<QString, QString> TwitchMessageBuilder::parseBadgeInfoTag(
@@ -1248,7 +1248,7 @@ void TwitchMessageBuilder::appendTwitchBadges()
if (auto customModBadge = this->twitchChannel->ffzCustomModBadge())
{
this->emplace<ModBadgeElement>(
customModBadge.get(),
*customModBadge,
MessageElementFlag::BadgeChannelAuthority)
->setTooltip((*customModBadge)->tooltip.string);
// early out, since we have to add a custom badge element here
@@ -1260,7 +1260,7 @@ void TwitchMessageBuilder::appendTwitchBadges()
if (auto customVipBadge = this->twitchChannel->ffzCustomVipBadge())
{
this->emplace<VipBadgeElement>(
customVipBadge.get(),
*customVipBadge,
MessageElementFlag::BadgeChannelAuthority)
->setTooltip((*customVipBadge)->tooltip.string);
// early out, since we have to add a custom badge element here
@@ -1302,7 +1302,7 @@ void TwitchMessageBuilder::appendTwitchBadges()
}
}
this->emplace<BadgeElement>(badgeEmote.get(), badge.flag_)
this->emplace<BadgeElement>(*badgeEmote, badge.flag_)
->setTooltip(tooltip);
}