Replace boost::optional with std::optional (#4877)
This commit is contained in:
@@ -69,7 +69,7 @@ void NetworkConfigurationProvider::applyFromEnv(const Env &env)
|
||||
{
|
||||
if (env.proxyUrl)
|
||||
{
|
||||
applyProxy(env.proxyUrl.get());
|
||||
applyProxy(*env.proxyUrl);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -179,13 +179,16 @@ std::shared_ptr<const EmoteMap> BttvEmotes::emotes() const
|
||||
return this->global_.get();
|
||||
}
|
||||
|
||||
boost::optional<EmotePtr> BttvEmotes::emote(const EmoteName &name) const
|
||||
std::optional<EmotePtr> BttvEmotes::emote(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;
|
||||
}
|
||||
|
||||
@@ -203,8 +206,10 @@ void BttvEmotes::loadEmotes()
|
||||
auto emotes = this->global_.get();
|
||||
auto pair = parseGlobalEmotes(result.parseJsonArray(), *emotes);
|
||||
if (pair.first)
|
||||
{
|
||||
this->setEmotes(
|
||||
std::make_shared<EmoteMap>(std::move(pair.second)));
|
||||
}
|
||||
return pair.first;
|
||||
})
|
||||
.execute();
|
||||
@@ -251,13 +256,18 @@ void BttvEmotes::loadChannel(std::weak_ptr<Channel> channel,
|
||||
.onError([channelId, channel, manualRefresh](auto result) {
|
||||
auto shared = channel.lock();
|
||||
if (!shared)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (result.status() == 404)
|
||||
{
|
||||
// User does not have any BTTV emotes
|
||||
if (manualRefresh)
|
||||
{
|
||||
shared->addMessage(
|
||||
makeSystemMessage(CHANNEL_HAS_NO_EMOTES));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -291,7 +301,7 @@ EmotePtr BttvEmotes::addEmote(
|
||||
return emote;
|
||||
}
|
||||
|
||||
boost::optional<std::pair<EmotePtr, EmotePtr>> BttvEmotes::updateEmote(
|
||||
std::optional<std::pair<EmotePtr, EmotePtr>> BttvEmotes::updateEmote(
|
||||
const QString &channelDisplayName,
|
||||
Atomic<std::shared_ptr<const EmoteMap>> &channelEmoteMap,
|
||||
const BttvLiveUpdateEmoteUpdateAddMessage &message)
|
||||
@@ -305,7 +315,7 @@ boost::optional<std::pair<EmotePtr, EmotePtr>> BttvEmotes::updateEmote(
|
||||
{
|
||||
// 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 oldEmotePtr = it->second;
|
||||
// copy the existing emote, to not change the original one
|
||||
@@ -316,7 +326,7 @@ boost::optional<std::pair<EmotePtr, EmotePtr>> BttvEmotes::updateEmote(
|
||||
if (!updateChannelEmote(emote, channelDisplayName, message.jsonEmote))
|
||||
{
|
||||
// The emote wasn't actually updated
|
||||
return boost::none;
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
auto name = emote.name;
|
||||
@@ -327,7 +337,7 @@ boost::optional<std::pair<EmotePtr, EmotePtr>> BttvEmotes::updateEmote(
|
||||
return std::make_pair(oldEmotePtr, emotePtr);
|
||||
}
|
||||
|
||||
boost::optional<EmotePtr> BttvEmotes::removeEmote(
|
||||
std::optional<EmotePtr> BttvEmotes::removeEmote(
|
||||
Atomic<std::shared_ptr<const EmoteMap>> &channelEmoteMap,
|
||||
const BttvLiveUpdateEmoteRemoveMessage &message)
|
||||
{
|
||||
@@ -338,7 +348,7 @@ boost::optional<EmotePtr> BttvEmotes::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);
|
||||
|
||||
@@ -3,9 +3,8 @@
|
||||
#include "common/Aliases.hpp"
|
||||
#include "common/Atomic.hpp"
|
||||
|
||||
#include <boost/optional.hpp>
|
||||
|
||||
#include <memory>
|
||||
#include <optional>
|
||||
|
||||
namespace chatterino {
|
||||
|
||||
@@ -27,7 +26,7 @@ public:
|
||||
BttvEmotes();
|
||||
|
||||
std::shared_ptr<const EmoteMap> emotes() const;
|
||||
boost::optional<EmotePtr> emote(const EmoteName &name) const;
|
||||
std::optional<EmotePtr> emote(const EmoteName &name) const;
|
||||
void loadEmotes();
|
||||
void setEmotes(std::shared_ptr<const EmoteMap> emotes);
|
||||
static void loadChannel(std::weak_ptr<Channel> channel,
|
||||
@@ -55,7 +54,7 @@ public:
|
||||
*
|
||||
* @return pair<old emote, new emote> if any emote was updated.
|
||||
*/
|
||||
static boost::optional<std::pair<EmotePtr, EmotePtr>> updateEmote(
|
||||
static std::optional<std::pair<EmotePtr, EmotePtr>> updateEmote(
|
||||
const QString &channelDisplayName,
|
||||
Atomic<std::shared_ptr<const EmoteMap>> &channelEmoteMap,
|
||||
const BttvLiveUpdateEmoteUpdateAddMessage &message);
|
||||
@@ -67,7 +66,7 @@ public:
|
||||
*
|
||||
* @return The removed emote if any emote was removed.
|
||||
*/
|
||||
static boost::optional<EmotePtr> removeEmote(
|
||||
static std::optional<EmotePtr> removeEmote(
|
||||
Atomic<std::shared_ptr<const EmoteMap>> &channelEmoteMap,
|
||||
const BttvLiveUpdateEmoteRemoveMessage &message);
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@ ChatterinoBadges::ChatterinoBadges()
|
||||
{
|
||||
}
|
||||
|
||||
boost::optional<EmotePtr> ChatterinoBadges::getBadge(const UserId &id)
|
||||
std::optional<EmotePtr> ChatterinoBadges::getBadge(const UserId &id)
|
||||
{
|
||||
std::shared_lock lock(this->mutex_);
|
||||
|
||||
@@ -30,7 +30,7 @@ boost::optional<EmotePtr> ChatterinoBadges::getBadge(const UserId &id)
|
||||
{
|
||||
return emotes[it->second];
|
||||
}
|
||||
return boost::none;
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
void ChatterinoBadges::loadChatterinoBadges()
|
||||
|
||||
@@ -4,9 +4,8 @@
|
||||
#include "common/Singleton.hpp"
|
||||
#include "util/QStringHash.hpp"
|
||||
|
||||
#include <boost/optional.hpp>
|
||||
|
||||
#include <memory>
|
||||
#include <optional>
|
||||
#include <shared_mutex>
|
||||
#include <unordered_map>
|
||||
#include <vector>
|
||||
@@ -22,7 +21,7 @@ public:
|
||||
virtual void initialize(Settings &settings, Paths &paths) override;
|
||||
ChatterinoBadges();
|
||||
|
||||
boost::optional<EmotePtr> getBadge(const UserId &id);
|
||||
std::optional<EmotePtr> getBadge(const UserId &id);
|
||||
|
||||
private:
|
||||
void loadChatterinoBadges();
|
||||
|
||||
@@ -43,7 +43,7 @@ std::vector<FfzBadges::Badge> FfzBadges::getUserBadges(const UserId &id)
|
||||
return badges;
|
||||
}
|
||||
|
||||
boost::optional<FfzBadges::Badge> FfzBadges::getBadge(const int badgeID)
|
||||
std::optional<FfzBadges::Badge> FfzBadges::getBadge(const int badgeID)
|
||||
{
|
||||
auto it = this->badges.find(badgeID);
|
||||
if (it != this->badges.end())
|
||||
@@ -51,7 +51,7 @@ boost::optional<FfzBadges::Badge> FfzBadges::getBadge(const int badgeID)
|
||||
return it->second;
|
||||
}
|
||||
|
||||
return boost::none;
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
void FfzBadges::load()
|
||||
|
||||
@@ -4,10 +4,10 @@
|
||||
#include "common/Singleton.hpp"
|
||||
#include "util/QStringHash.hpp"
|
||||
|
||||
#include <boost/optional.hpp>
|
||||
#include <QColor>
|
||||
|
||||
#include <memory>
|
||||
#include <optional>
|
||||
#include <set>
|
||||
#include <shared_mutex>
|
||||
#include <unordered_map>
|
||||
@@ -32,7 +32,7 @@ public:
|
||||
std::vector<Badge> getUserBadges(const UserId &id);
|
||||
|
||||
private:
|
||||
boost::optional<Badge> getBadge(int badgeID);
|
||||
std::optional<Badge> getBadge(int badgeID);
|
||||
|
||||
void load();
|
||||
|
||||
|
||||
@@ -119,10 +119,10 @@ namespace {
|
||||
return emotes;
|
||||
}
|
||||
|
||||
boost::optional<EmotePtr> parseAuthorityBadge(const QJsonObject &badgeUrls,
|
||||
const QString &tooltip)
|
||||
std::optional<EmotePtr> parseAuthorityBadge(const QJsonObject &badgeUrls,
|
||||
const QString &tooltip)
|
||||
{
|
||||
boost::optional<EmotePtr> authorityBadge;
|
||||
std::optional<EmotePtr> authorityBadge;
|
||||
|
||||
if (!badgeUrls.isEmpty())
|
||||
{
|
||||
@@ -173,7 +173,7 @@ std::shared_ptr<const EmoteMap> FfzEmotes::emotes() const
|
||||
return this->global_.get();
|
||||
}
|
||||
|
||||
boost::optional<EmotePtr> FfzEmotes::emote(const EmoteName &name) const
|
||||
std::optional<EmotePtr> FfzEmotes::emote(const EmoteName &name) const
|
||||
{
|
||||
auto emotes = this->global_.get();
|
||||
auto it = emotes->find(name);
|
||||
@@ -181,7 +181,7 @@ boost::optional<EmotePtr> FfzEmotes::emote(const EmoteName &name) const
|
||||
{
|
||||
return it->second;
|
||||
}
|
||||
return boost::none;
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
void FfzEmotes::loadEmotes()
|
||||
@@ -214,8 +214,8 @@ void FfzEmotes::setEmotes(std::shared_ptr<const EmoteMap> emotes)
|
||||
void FfzEmotes::loadChannel(
|
||||
std::weak_ptr<Channel> channel, const QString &channelID,
|
||||
std::function<void(EmoteMap &&)> emoteCallback,
|
||||
std::function<void(boost::optional<EmotePtr>)> modBadgeCallback,
|
||||
std::function<void(boost::optional<EmotePtr>)> vipBadgeCallback,
|
||||
std::function<void(std::optional<EmotePtr>)> modBadgeCallback,
|
||||
std::function<void(std::optional<EmotePtr>)> vipBadgeCallback,
|
||||
bool manualRefresh)
|
||||
{
|
||||
qCDebug(chatterinoFfzemotes)
|
||||
|
||||
@@ -3,9 +3,8 @@
|
||||
#include "common/Aliases.hpp"
|
||||
#include "common/Atomic.hpp"
|
||||
|
||||
#include <boost/optional.hpp>
|
||||
|
||||
#include <memory>
|
||||
#include <optional>
|
||||
|
||||
namespace chatterino {
|
||||
|
||||
@@ -20,14 +19,14 @@ public:
|
||||
FfzEmotes();
|
||||
|
||||
std::shared_ptr<const EmoteMap> emotes() const;
|
||||
boost::optional<EmotePtr> emote(const EmoteName &name) const;
|
||||
std::optional<EmotePtr> emote(const EmoteName &name) const;
|
||||
void loadEmotes();
|
||||
void setEmotes(std::shared_ptr<const EmoteMap> emotes);
|
||||
static void loadChannel(
|
||||
std::weak_ptr<Channel> channel, const QString &channelId,
|
||||
std::function<void(EmoteMap &&)> emoteCallback,
|
||||
std::function<void(boost::optional<EmotePtr>)> modBadgeCallback,
|
||||
std::function<void(boost::optional<EmotePtr>)> vipBadgeCallback,
|
||||
std::function<void(std::optional<EmotePtr>)> modBadgeCallback,
|
||||
std::function<void(std::optional<EmotePtr>)> vipBadgeCallback,
|
||||
bool manualRefresh);
|
||||
|
||||
private:
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
|
||||
namespace chatterino {
|
||||
|
||||
boost::optional<EmotePtr> SeventvBadges::getBadge(const UserId &id) const
|
||||
std::optional<EmotePtr> SeventvBadges::getBadge(const UserId &id) const
|
||||
{
|
||||
std::shared_lock lock(this->mutex_);
|
||||
|
||||
@@ -22,7 +22,7 @@ boost::optional<EmotePtr> SeventvBadges::getBadge(const UserId &id) const
|
||||
{
|
||||
return it->second;
|
||||
}
|
||||
return boost::none;
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
void SeventvBadges::assignBadgeToUser(const QString &badgeID,
|
||||
|
||||
@@ -4,10 +4,10 @@
|
||||
#include "common/Singleton.hpp"
|
||||
#include "util/QStringHash.hpp"
|
||||
|
||||
#include <boost/optional.hpp>
|
||||
#include <QJsonObject>
|
||||
|
||||
#include <memory>
|
||||
#include <optional>
|
||||
#include <shared_mutex>
|
||||
#include <unordered_map>
|
||||
|
||||
@@ -20,7 +20,7 @@ class SeventvBadges : public Singleton
|
||||
{
|
||||
public:
|
||||
// Return the badge, if any, that is assigned to the user
|
||||
boost::optional<EmotePtr> getBadge(const UserId &id) const;
|
||||
std::optional<EmotePtr> getBadge(const UserId &id) const;
|
||||
|
||||
// Assign the given badge to the user
|
||||
void assignBadgeToUser(const QString &badgeID, const UserId &userID);
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
#pragma once
|
||||
|
||||
#include "boost/optional.hpp"
|
||||
#include "common/Aliases.hpp"
|
||||
#include "common/Atomic.hpp"
|
||||
#include "common/FlagsEnum.hpp"
|
||||
@@ -8,6 +7,7 @@
|
||||
#include <QJsonObject>
|
||||
|
||||
#include <memory>
|
||||
#include <optional>
|
||||
|
||||
namespace chatterino {
|
||||
|
||||
@@ -89,7 +89,7 @@ public:
|
||||
SeventvEmotes();
|
||||
|
||||
std::shared_ptr<const EmoteMap> globalEmotes() const;
|
||||
boost::optional<EmotePtr> globalEmote(const EmoteName &name) const;
|
||||
std::optional<EmotePtr> globalEmote(const EmoteName &name) const;
|
||||
void loadGlobalEmotes();
|
||||
void setGlobalEmotes(std::shared_ptr<const EmoteMap> emotes);
|
||||
static void loadChannelEmotes(
|
||||
@@ -104,7 +104,7 @@ public:
|
||||
*
|
||||
* @return The added emote if an emote was added.
|
||||
*/
|
||||
static boost::optional<EmotePtr> addEmote(
|
||||
static std::optional<EmotePtr> addEmote(
|
||||
Atomic<std::shared_ptr<const EmoteMap>> &map,
|
||||
const seventv::eventapi::EmoteAddDispatch &dispatch);
|
||||
|
||||
@@ -115,7 +115,7 @@ public:
|
||||
*
|
||||
* @return The updated emote if any emote was updated.
|
||||
*/
|
||||
static boost::optional<EmotePtr> updateEmote(
|
||||
static std::optional<EmotePtr> updateEmote(
|
||||
Atomic<std::shared_ptr<const EmoteMap>> &map,
|
||||
const seventv::eventapi::EmoteUpdateDispatch &dispatch);
|
||||
|
||||
@@ -126,7 +126,7 @@ public:
|
||||
*
|
||||
* @return The removed emote if any emote was removed.
|
||||
*/
|
||||
static boost::optional<EmotePtr> removeEmote(
|
||||
static std::optional<EmotePtr> removeEmote(
|
||||
Atomic<std::shared_ptr<const EmoteMap>> &map,
|
||||
const seventv::eventapi::EmoteRemoveDispatch &dispatch);
|
||||
|
||||
|
||||
@@ -2,12 +2,13 @@
|
||||
|
||||
#include "providers/seventv/eventapi/Subscription.hpp"
|
||||
|
||||
#include <boost/optional.hpp>
|
||||
#include <magic_enum.hpp>
|
||||
#include <QJsonDocument>
|
||||
#include <QJsonObject>
|
||||
#include <QString>
|
||||
|
||||
#include <optional>
|
||||
|
||||
namespace chatterino::seventv::eventapi {
|
||||
|
||||
struct Message {
|
||||
@@ -18,22 +19,22 @@ struct Message {
|
||||
Message(QJsonObject _json);
|
||||
|
||||
template <class InnerClass>
|
||||
boost::optional<InnerClass> toInner();
|
||||
std::optional<InnerClass> toInner();
|
||||
};
|
||||
|
||||
template <class InnerClass>
|
||||
boost::optional<InnerClass> Message::toInner()
|
||||
std::optional<InnerClass> Message::toInner()
|
||||
{
|
||||
return InnerClass{this->data};
|
||||
}
|
||||
|
||||
static boost::optional<Message> parseBaseMessage(const QString &blob)
|
||||
static std::optional<Message> parseBaseMessage(const QString &blob)
|
||||
{
|
||||
QJsonDocument jsonDoc(QJsonDocument::fromJson(blob.toUtf8()));
|
||||
|
||||
if (jsonDoc.isNull())
|
||||
{
|
||||
return boost::none;
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
return Message(jsonDoc.object());
|
||||
|
||||
@@ -914,7 +914,7 @@ void IrcMessageHandler::handleWhisperMessage(Communi::IrcMessage *message)
|
||||
|
||||
c->addMessage(_message);
|
||||
|
||||
auto overrideFlags = boost::optional<MessageFlags>(_message->flags);
|
||||
auto overrideFlags = std::optional<MessageFlags>(_message->flags);
|
||||
overrideFlags->set(MessageFlag::DoNotTriggerNotification);
|
||||
overrideFlags->set(MessageFlag::DoNotLog);
|
||||
|
||||
|
||||
@@ -727,14 +727,14 @@ void PubSub::registerNonce(QString nonce, NonceInfo info)
|
||||
this->nonces_[nonce] = std::move(info);
|
||||
}
|
||||
|
||||
boost::optional<PubSub::NonceInfo> PubSub::findNonceInfo(QString nonce)
|
||||
std::optional<PubSub::NonceInfo> PubSub::findNonceInfo(QString nonce)
|
||||
{
|
||||
// TODO: This should also DELETE the nonceinfo from the map
|
||||
auto it = this->nonces_.find(nonce);
|
||||
|
||||
if (it == this->nonces_.end())
|
||||
{
|
||||
return boost::none;
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
return it->second;
|
||||
|
||||
@@ -5,7 +5,6 @@
|
||||
#include "util/ExponentialBackoff.hpp"
|
||||
#include "util/QStringHash.hpp"
|
||||
|
||||
#include <boost/optional.hpp>
|
||||
#include <pajlada/signals/signal.hpp>
|
||||
#include <QJsonObject>
|
||||
#include <QString>
|
||||
@@ -15,6 +14,7 @@
|
||||
#include <chrono>
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <optional>
|
||||
#include <thread>
|
||||
#include <unordered_map>
|
||||
#include <vector>
|
||||
@@ -188,7 +188,7 @@ private:
|
||||
void registerNonce(QString nonce, NonceInfo nonceInfo);
|
||||
|
||||
// Find client associated with a nonce
|
||||
boost::optional<NonceInfo> findNonceInfo(QString nonce);
|
||||
std::optional<NonceInfo> findNonceInfo(QString nonce);
|
||||
|
||||
std::unordered_map<QString, NonceInfo> nonces_;
|
||||
|
||||
|
||||
@@ -149,8 +149,8 @@ void TwitchBadges::loaded()
|
||||
}
|
||||
}
|
||||
|
||||
boost::optional<EmotePtr> TwitchBadges::badge(const QString &set,
|
||||
const QString &version) const
|
||||
std::optional<EmotePtr> TwitchBadges::badge(const QString &set,
|
||||
const QString &version) const
|
||||
{
|
||||
auto badgeSets = this->badgeSets_.access();
|
||||
auto it = badgeSets->find(set);
|
||||
@@ -162,10 +162,10 @@ boost::optional<EmotePtr> TwitchBadges::badge(const QString &set,
|
||||
return it2->second;
|
||||
}
|
||||
}
|
||||
return boost::none;
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
boost::optional<EmotePtr> TwitchBadges::badge(const QString &set) const
|
||||
std::optional<EmotePtr> TwitchBadges::badge(const QString &set) const
|
||||
{
|
||||
auto badgeSets = this->badgeSets_.access();
|
||||
auto it = badgeSets->find(set);
|
||||
@@ -176,7 +176,7 @@ boost::optional<EmotePtr> TwitchBadges::badge(const QString &set) const
|
||||
return it->second.begin()->second;
|
||||
}
|
||||
}
|
||||
return boost::none;
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
void TwitchBadges::getBadgeIcon(const QString &name, BadgeIconCallback callback)
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
#include "common/UniqueAccess.hpp"
|
||||
#include "util/QStringHash.hpp"
|
||||
|
||||
#include <boost/optional.hpp>
|
||||
#include <pajlada/signals/signal.hpp>
|
||||
#include <QIcon>
|
||||
#include <QJsonObject>
|
||||
@@ -11,6 +10,7 @@
|
||||
#include <QString>
|
||||
|
||||
#include <memory>
|
||||
#include <optional>
|
||||
#include <queue>
|
||||
#include <shared_mutex>
|
||||
#include <unordered_map>
|
||||
@@ -35,10 +35,10 @@ public:
|
||||
static TwitchBadges *instance();
|
||||
|
||||
// Get badge from name and version
|
||||
boost::optional<EmotePtr> badge(const QString &set,
|
||||
const QString &version) const;
|
||||
std::optional<EmotePtr> badge(const QString &set,
|
||||
const QString &version) const;
|
||||
// Get first matching badge with name, regardless of version
|
||||
boost::optional<EmotePtr> badge(const QString &set) const;
|
||||
std::optional<EmotePtr> badge(const QString &set) const;
|
||||
|
||||
void getBadgeIcon(const QString &name, BadgeIconCallback callback);
|
||||
void getBadgeIcon(const DisplayBadge &badge, BadgeIconCallback callback);
|
||||
|
||||
@@ -35,6 +35,7 @@
|
||||
#include "singletons/Settings.hpp"
|
||||
#include "singletons/Toasts.hpp"
|
||||
#include "singletons/WindowManager.hpp"
|
||||
#include "util/Helpers.hpp"
|
||||
#include "util/PostToThread.hpp"
|
||||
#include "util/QStringHash.hpp"
|
||||
#include "widgets/Window.hpp"
|
||||
@@ -396,14 +397,14 @@ bool TwitchChannel::isChannelPointRewardKnown(const QString &rewardId)
|
||||
return it != pointRewards->end();
|
||||
}
|
||||
|
||||
boost::optional<ChannelPointReward> TwitchChannel::channelPointReward(
|
||||
std::optional<ChannelPointReward> TwitchChannel::channelPointReward(
|
||||
const QString &rewardId) const
|
||||
{
|
||||
auto rewards = this->channelPointRewards_.accessConst();
|
||||
auto it = rewards->find(rewardId);
|
||||
|
||||
if (it == rewards->end())
|
||||
return boost::none;
|
||||
return std::nullopt;
|
||||
return it->second;
|
||||
}
|
||||
|
||||
@@ -751,35 +752,34 @@ SharedAccessGuard<const TwitchChannel::StreamStatus>
|
||||
return this->streamStatus_.accessConst();
|
||||
}
|
||||
|
||||
boost::optional<EmotePtr> TwitchChannel::bttvEmote(const EmoteName &name) const
|
||||
std::optional<EmotePtr> TwitchChannel::bttvEmote(const EmoteName &name) const
|
||||
{
|
||||
auto emotes = this->bttvEmotes_.get();
|
||||
auto it = emotes->find(name);
|
||||
|
||||
if (it == emotes->end())
|
||||
return boost::none;
|
||||
return std::nullopt;
|
||||
return it->second;
|
||||
}
|
||||
|
||||
boost::optional<EmotePtr> TwitchChannel::ffzEmote(const EmoteName &name) const
|
||||
std::optional<EmotePtr> TwitchChannel::ffzEmote(const EmoteName &name) const
|
||||
{
|
||||
auto emotes = this->ffzEmotes_.get();
|
||||
auto it = emotes->find(name);
|
||||
|
||||
if (it == emotes->end())
|
||||
return boost::none;
|
||||
return std::nullopt;
|
||||
return it->second;
|
||||
}
|
||||
|
||||
boost::optional<EmotePtr> TwitchChannel::seventvEmote(
|
||||
const EmoteName &name) const
|
||||
std::optional<EmotePtr> TwitchChannel::seventvEmote(const EmoteName &name) const
|
||||
{
|
||||
auto emotes = this->seventvEmotes_.get();
|
||||
auto it = emotes->find(name);
|
||||
|
||||
if (it == emotes->end())
|
||||
{
|
||||
return boost::none;
|
||||
return std::nullopt;
|
||||
}
|
||||
return it->second;
|
||||
}
|
||||
@@ -865,7 +865,7 @@ void TwitchChannel::removeBttvEmote(
|
||||
}
|
||||
|
||||
this->addOrReplaceLiveUpdatesAddRemove(false, "BTTV", QString() /*actor*/,
|
||||
removed.get()->name.string);
|
||||
(*removed)->name.string);
|
||||
}
|
||||
|
||||
void TwitchChannel::addSeventvEmote(
|
||||
@@ -904,7 +904,7 @@ void TwitchChannel::removeSeventvEmote(
|
||||
}
|
||||
|
||||
this->addOrReplaceLiveUpdatesAddRemove(false, "7TV", dispatch.actorName,
|
||||
removed.get()->name.string);
|
||||
(*removed)->name.string);
|
||||
}
|
||||
|
||||
void TwitchChannel::updateSeventvUser(
|
||||
@@ -955,13 +955,13 @@ void TwitchChannel::updateSeventvData(const QString &newUserID,
|
||||
return;
|
||||
}
|
||||
|
||||
boost::optional<QString> oldUserID = boost::make_optional(
|
||||
const auto oldUserID = makeConditionedOptional(
|
||||
!this->seventvUserID_.isEmpty() && this->seventvUserID_ != newUserID,
|
||||
this->seventvUserID_);
|
||||
boost::optional<QString> oldEmoteSetID =
|
||||
boost::make_optional(!this->seventvEmoteSetID_.isEmpty() &&
|
||||
this->seventvEmoteSetID_ != newEmoteSetID,
|
||||
this->seventvEmoteSetID_);
|
||||
const auto oldEmoteSetID =
|
||||
makeConditionedOptional(!this->seventvEmoteSetID_.isEmpty() &&
|
||||
this->seventvEmoteSetID_ != newEmoteSetID,
|
||||
this->seventvEmoteSetID_);
|
||||
|
||||
this->seventvUserID_ = newUserID;
|
||||
this->seventvEmoteSetID_ = newEmoteSetID;
|
||||
@@ -974,8 +974,8 @@ void TwitchChannel::updateSeventvData(const QString &newUserID,
|
||||
if (oldUserID || oldEmoteSetID)
|
||||
{
|
||||
getApp()->twitch->dropSeventvChannel(
|
||||
oldUserID.get_value_or(QString()),
|
||||
oldEmoteSetID.get_value_or(QString()));
|
||||
oldUserID.value_or(QString()),
|
||||
oldEmoteSetID.value_or(QString()));
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -1538,8 +1538,8 @@ void TwitchChannel::createClip()
|
||||
});
|
||||
}
|
||||
|
||||
boost::optional<EmotePtr> TwitchChannel::twitchBadge(
|
||||
const QString &set, const QString &version) const
|
||||
std::optional<EmotePtr> TwitchChannel::twitchBadge(const QString &set,
|
||||
const QString &version) const
|
||||
{
|
||||
auto badgeSets = this->badgeSets_.access();
|
||||
auto it = badgeSets->find(set);
|
||||
@@ -1551,20 +1551,20 @@ boost::optional<EmotePtr> TwitchChannel::twitchBadge(
|
||||
return it2->second;
|
||||
}
|
||||
}
|
||||
return boost::none;
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
boost::optional<EmotePtr> TwitchChannel::ffzCustomModBadge() const
|
||||
std::optional<EmotePtr> TwitchChannel::ffzCustomModBadge() const
|
||||
{
|
||||
return this->ffzCustomModBadge_.get();
|
||||
}
|
||||
|
||||
boost::optional<EmotePtr> TwitchChannel::ffzCustomVipBadge() const
|
||||
std::optional<EmotePtr> TwitchChannel::ffzCustomVipBadge() const
|
||||
{
|
||||
return this->ffzCustomVipBadge_.get();
|
||||
}
|
||||
|
||||
boost::optional<CheerEmote> TwitchChannel::cheerEmote(const QString &string)
|
||||
std::optional<CheerEmote> TwitchChannel::cheerEmote(const QString &string)
|
||||
{
|
||||
auto sets = this->cheerEmoteSets_.access();
|
||||
for (const auto &set : *sets)
|
||||
@@ -1590,7 +1590,7 @@ boost::optional<CheerEmote> TwitchChannel::cheerEmote(const QString &string)
|
||||
}
|
||||
}
|
||||
}
|
||||
return boost::none;
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
void TwitchChannel::updateSevenTVActivity()
|
||||
|
||||
@@ -9,7 +9,6 @@
|
||||
#include "providers/twitch/TwitchEmotes.hpp"
|
||||
#include "util/QStringHash.hpp"
|
||||
|
||||
#include <boost/optional.hpp>
|
||||
#include <boost/signals2.hpp>
|
||||
#include <pajlada/signals/signalholder.hpp>
|
||||
#include <QColor>
|
||||
@@ -134,9 +133,9 @@ public:
|
||||
SharedAccessGuard<const StreamStatus> accessStreamStatus() const;
|
||||
|
||||
// Emotes
|
||||
boost::optional<EmotePtr> bttvEmote(const EmoteName &name) const;
|
||||
boost::optional<EmotePtr> ffzEmote(const EmoteName &name) const;
|
||||
boost::optional<EmotePtr> seventvEmote(const EmoteName &name) const;
|
||||
std::optional<EmotePtr> bttvEmote(const EmoteName &name) const;
|
||||
std::optional<EmotePtr> ffzEmote(const EmoteName &name) const;
|
||||
std::optional<EmotePtr> seventvEmote(const EmoteName &name) const;
|
||||
std::shared_ptr<const EmoteMap> bttvEmotes() const;
|
||||
std::shared_ptr<const EmoteMap> ffzEmotes() const;
|
||||
std::shared_ptr<const EmoteMap> seventvEmotes() const;
|
||||
@@ -172,13 +171,13 @@ public:
|
||||
const QString &newEmoteSetID);
|
||||
|
||||
// Badges
|
||||
boost::optional<EmotePtr> ffzCustomModBadge() const;
|
||||
boost::optional<EmotePtr> ffzCustomVipBadge() const;
|
||||
boost::optional<EmotePtr> twitchBadge(const QString &set,
|
||||
const QString &version) const;
|
||||
std::optional<EmotePtr> ffzCustomModBadge() const;
|
||||
std::optional<EmotePtr> ffzCustomVipBadge() const;
|
||||
std::optional<EmotePtr> twitchBadge(const QString &set,
|
||||
const QString &version) const;
|
||||
|
||||
// Cheers
|
||||
boost::optional<CheerEmote> cheerEmote(const QString &string);
|
||||
std::optional<CheerEmote> cheerEmote(const QString &string);
|
||||
|
||||
// Replies
|
||||
/**
|
||||
@@ -217,7 +216,7 @@ public:
|
||||
channelPointRewardAdded;
|
||||
void addChannelPointReward(const ChannelPointReward &reward);
|
||||
bool isChannelPointRewardKnown(const QString &rewardId);
|
||||
boost::optional<ChannelPointReward> channelPointReward(
|
||||
std::optional<ChannelPointReward> channelPointReward(
|
||||
const QString &rewardId) const;
|
||||
|
||||
// Live status
|
||||
@@ -342,8 +341,8 @@ protected:
|
||||
Atomic<std::shared_ptr<const EmoteMap>> bttvEmotes_;
|
||||
Atomic<std::shared_ptr<const EmoteMap>> ffzEmotes_;
|
||||
Atomic<std::shared_ptr<const EmoteMap>> seventvEmotes_;
|
||||
Atomic<boost::optional<EmotePtr>> ffzCustomModBadge_;
|
||||
Atomic<boost::optional<EmotePtr>> ffzCustomVipBadge_;
|
||||
Atomic<std::optional<EmotePtr>> ffzCustomModBadge_;
|
||||
Atomic<std::optional<EmotePtr>> ffzCustomVipBadge_;
|
||||
|
||||
private:
|
||||
// Badges
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -4,11 +4,11 @@
|
||||
#include "common/Outcome.hpp"
|
||||
#include "messages/SharedMessageBuilder.hpp"
|
||||
|
||||
#include <boost/optional.hpp>
|
||||
#include <IrcMessage>
|
||||
#include <QString>
|
||||
#include <QVariant>
|
||||
|
||||
#include <optional>
|
||||
#include <unordered_map>
|
||||
|
||||
namespace chatterino {
|
||||
@@ -108,7 +108,7 @@ private:
|
||||
|
||||
void runIgnoreReplaces(std::vector<TwitchEmoteOccurrence> &twitchEmotes);
|
||||
|
||||
boost::optional<EmotePtr> getTwitchBadge(const Badge &badge);
|
||||
std::optional<EmotePtr> getTwitchBadge(const Badge &badge) const;
|
||||
Outcome tryAppendEmote(const EmoteName &name) override;
|
||||
|
||||
void addWords(const QStringList &words,
|
||||
|
||||
@@ -1741,7 +1741,7 @@ void Helix::updateEmoteMode(
|
||||
|
||||
void Helix::updateFollowerMode(
|
||||
QString broadcasterID, QString moderatorID,
|
||||
boost::optional<int> followerModeDuration,
|
||||
std::optional<int> followerModeDuration,
|
||||
ResultCallback<HelixChatSettings> successCallback,
|
||||
FailureCallback<HelixUpdateChatSettingsError, QString> failureCallback)
|
||||
{
|
||||
@@ -1758,7 +1758,7 @@ void Helix::updateFollowerMode(
|
||||
|
||||
void Helix::updateNonModeratorChatDelay(
|
||||
QString broadcasterID, QString moderatorID,
|
||||
boost::optional<int> nonModeratorChatDelayDuration,
|
||||
std::optional<int> nonModeratorChatDelayDuration,
|
||||
ResultCallback<HelixChatSettings> successCallback,
|
||||
FailureCallback<HelixUpdateChatSettingsError, QString> failureCallback)
|
||||
{
|
||||
@@ -1777,7 +1777,7 @@ void Helix::updateNonModeratorChatDelay(
|
||||
|
||||
void Helix::updateSlowMode(
|
||||
QString broadcasterID, QString moderatorID,
|
||||
boost::optional<int> slowModeWaitTime,
|
||||
std::optional<int> slowModeWaitTime,
|
||||
ResultCallback<HelixChatSettings> successCallback,
|
||||
FailureCallback<HelixUpdateChatSettingsError, QString> failureCallback)
|
||||
{
|
||||
@@ -2138,7 +2138,7 @@ void Helix::fetchModerators(
|
||||
// Ban/timeout a user
|
||||
// https://dev.twitch.tv/docs/api/reference#ban-user
|
||||
void Helix::banUser(QString broadcasterID, QString moderatorID, QString userID,
|
||||
boost::optional<int> duration, QString reason,
|
||||
std::optional<int> duration, QString reason,
|
||||
ResultCallback<> successCallback,
|
||||
FailureCallback<HelixBanUserError, QString> failureCallback)
|
||||
{
|
||||
@@ -2890,14 +2890,14 @@ NetworkRequest Helix::makeRequest(const QString &url, const QUrlQuery &urlQuery,
|
||||
{
|
||||
qCDebug(chatterinoTwitch)
|
||||
<< "Helix::makeRequest called without a client ID set BabyRage";
|
||||
// return boost::none;
|
||||
// return std::nullopt;
|
||||
}
|
||||
|
||||
if (this->oauthToken.isEmpty())
|
||||
{
|
||||
qCDebug(chatterinoTwitch)
|
||||
<< "Helix::makeRequest called without an oauth token set BabyRage";
|
||||
// return boost::none;
|
||||
// return std::nullopt;
|
||||
}
|
||||
|
||||
const QString baseUrl("https://api.twitch.tv/helix/");
|
||||
|
||||
@@ -3,9 +3,9 @@
|
||||
#include "common/Aliases.hpp"
|
||||
#include "common/NetworkRequest.hpp"
|
||||
#include "providers/twitch/TwitchEmotes.hpp"
|
||||
#include "util/Helpers.hpp"
|
||||
#include "util/QStringHash.hpp"
|
||||
|
||||
#include <boost/optional.hpp>
|
||||
#include <QDateTime>
|
||||
#include <QJsonArray>
|
||||
#include <QJsonObject>
|
||||
@@ -15,6 +15,7 @@
|
||||
#include <QUrlQuery>
|
||||
|
||||
#include <functional>
|
||||
#include <optional>
|
||||
#include <unordered_set>
|
||||
#include <vector>
|
||||
|
||||
@@ -277,24 +278,23 @@ struct HelixChannelEmote {
|
||||
struct HelixChatSettings {
|
||||
const QString broadcasterId;
|
||||
const bool emoteMode;
|
||||
// boost::none if disabled
|
||||
const boost::optional<int> followerModeDuration; // time in minutes
|
||||
const boost::optional<int>
|
||||
nonModeratorChatDelayDuration; // time in seconds
|
||||
const boost::optional<int> slowModeWaitTime; // time in seconds
|
||||
// std::nullopt if disabled
|
||||
const std::optional<int> followerModeDuration; // time in minutes
|
||||
const std::optional<int> nonModeratorChatDelayDuration; // time in seconds
|
||||
const std::optional<int> slowModeWaitTime; // time in seconds
|
||||
const bool subscriberMode;
|
||||
const bool uniqueChatMode;
|
||||
|
||||
explicit HelixChatSettings(QJsonObject jsonObject)
|
||||
: broadcasterId(jsonObject.value("broadcaster_id").toString())
|
||||
, emoteMode(jsonObject.value("emote_mode").toBool())
|
||||
, followerModeDuration(boost::make_optional(
|
||||
, followerModeDuration(makeConditionedOptional(
|
||||
jsonObject.value("follower_mode").toBool(),
|
||||
jsonObject.value("follower_mode_duration").toInt()))
|
||||
, nonModeratorChatDelayDuration(boost::make_optional(
|
||||
, nonModeratorChatDelayDuration(makeConditionedOptional(
|
||||
jsonObject.value("non_moderator_chat_delay").toBool(),
|
||||
jsonObject.value("non_moderator_chat_delay_duration").toInt()))
|
||||
, slowModeWaitTime(boost::make_optional(
|
||||
, slowModeWaitTime(makeConditionedOptional(
|
||||
jsonObject.value("slow_mode").toBool(),
|
||||
jsonObject.value("slow_mode_wait_time").toInt()))
|
||||
, subscriberMode(jsonObject.value("subscriber_mode").toBool())
|
||||
@@ -908,7 +908,7 @@ public:
|
||||
// https://dev.twitch.tv/docs/api/reference#update-chat-settings
|
||||
virtual void updateFollowerMode(
|
||||
QString broadcasterID, QString moderatorID,
|
||||
boost::optional<int> followerModeDuration,
|
||||
std::optional<int> followerModeDuration,
|
||||
ResultCallback<HelixChatSettings> successCallback,
|
||||
FailureCallback<HelixUpdateChatSettingsError, QString>
|
||||
failureCallback) = 0;
|
||||
@@ -917,7 +917,7 @@ public:
|
||||
// https://dev.twitch.tv/docs/api/reference#update-chat-settings
|
||||
virtual void updateNonModeratorChatDelay(
|
||||
QString broadcasterID, QString moderatorID,
|
||||
boost::optional<int> nonModeratorChatDelayDuration,
|
||||
std::optional<int> nonModeratorChatDelayDuration,
|
||||
ResultCallback<HelixChatSettings> successCallback,
|
||||
FailureCallback<HelixUpdateChatSettingsError, QString>
|
||||
failureCallback) = 0;
|
||||
@@ -926,7 +926,7 @@ public:
|
||||
// https://dev.twitch.tv/docs/api/reference#update-chat-settings
|
||||
virtual void updateSlowMode(
|
||||
QString broadcasterID, QString moderatorID,
|
||||
boost::optional<int> slowModeWaitTime,
|
||||
std::optional<int> slowModeWaitTime,
|
||||
ResultCallback<HelixChatSettings> successCallback,
|
||||
FailureCallback<HelixUpdateChatSettingsError, QString>
|
||||
failureCallback) = 0;
|
||||
@@ -951,7 +951,7 @@ public:
|
||||
// https://dev.twitch.tv/docs/api/reference#ban-user
|
||||
virtual void banUser(
|
||||
QString broadcasterID, QString moderatorID, QString userID,
|
||||
boost::optional<int> duration, QString reason,
|
||||
std::optional<int> duration, QString reason,
|
||||
ResultCallback<> successCallback,
|
||||
FailureCallback<HelixBanUserError, QString> failureCallback) = 0;
|
||||
|
||||
@@ -1224,7 +1224,7 @@ public:
|
||||
// https://dev.twitch.tv/docs/api/reference#update-chat-settings
|
||||
void updateFollowerMode(
|
||||
QString broadcasterID, QString moderatorID,
|
||||
boost::optional<int> followerModeDuration,
|
||||
std::optional<int> followerModeDuration,
|
||||
ResultCallback<HelixChatSettings> successCallback,
|
||||
FailureCallback<HelixUpdateChatSettingsError, QString> failureCallback)
|
||||
final;
|
||||
@@ -1233,7 +1233,7 @@ public:
|
||||
// https://dev.twitch.tv/docs/api/reference#update-chat-settings
|
||||
void updateNonModeratorChatDelay(
|
||||
QString broadcasterID, QString moderatorID,
|
||||
boost::optional<int> nonModeratorChatDelayDuration,
|
||||
std::optional<int> nonModeratorChatDelayDuration,
|
||||
ResultCallback<HelixChatSettings> successCallback,
|
||||
FailureCallback<HelixUpdateChatSettingsError, QString> failureCallback)
|
||||
final;
|
||||
@@ -1241,7 +1241,7 @@ public:
|
||||
// Updates the slow mode using
|
||||
// https://dev.twitch.tv/docs/api/reference#update-chat-settings
|
||||
void updateSlowMode(QString broadcasterID, QString moderatorID,
|
||||
boost::optional<int> slowModeWaitTime,
|
||||
std::optional<int> slowModeWaitTime,
|
||||
ResultCallback<HelixChatSettings> successCallback,
|
||||
FailureCallback<HelixUpdateChatSettingsError, QString>
|
||||
failureCallback) final;
|
||||
@@ -1266,7 +1266,7 @@ public:
|
||||
// https://dev.twitch.tv/docs/api/reference#ban-user
|
||||
void banUser(
|
||||
QString broadcasterID, QString moderatorID, QString userID,
|
||||
boost::optional<int> duration, QString reason,
|
||||
std::optional<int> duration, QString reason,
|
||||
ResultCallback<> successCallback,
|
||||
FailureCallback<HelixBanUserError, QString> failureCallback) final;
|
||||
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
#pragma once
|
||||
|
||||
#include <boost/optional.hpp>
|
||||
#include <magic_enum.hpp>
|
||||
#include <QJsonDocument>
|
||||
#include <QJsonObject>
|
||||
#include <QString>
|
||||
|
||||
#include <optional>
|
||||
|
||||
namespace chatterino {
|
||||
|
||||
struct PubSubMessage {
|
||||
@@ -27,16 +28,16 @@ struct PubSubMessage {
|
||||
PubSubMessage(QJsonObject _object);
|
||||
|
||||
template <class InnerClass>
|
||||
boost::optional<InnerClass> toInner();
|
||||
std::optional<InnerClass> toInner();
|
||||
};
|
||||
|
||||
template <class InnerClass>
|
||||
boost::optional<InnerClass> PubSubMessage::toInner()
|
||||
std::optional<InnerClass> PubSubMessage::toInner()
|
||||
{
|
||||
auto dataValue = this->object.value("data");
|
||||
if (!dataValue.isObject())
|
||||
{
|
||||
return boost::none;
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
auto data = dataValue.toObject();
|
||||
@@ -44,14 +45,13 @@ boost::optional<InnerClass> PubSubMessage::toInner()
|
||||
return InnerClass{this->nonce, data};
|
||||
}
|
||||
|
||||
static boost::optional<PubSubMessage> parsePubSubBaseMessage(
|
||||
const QString &blob)
|
||||
static std::optional<PubSubMessage> parsePubSubBaseMessage(const QString &blob)
|
||||
{
|
||||
QJsonDocument jsonDoc(QJsonDocument::fromJson(blob.toUtf8()));
|
||||
|
||||
if (jsonDoc.isNull())
|
||||
{
|
||||
return boost::none;
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
return PubSubMessage(jsonDoc.object());
|
||||
|
||||
@@ -2,11 +2,12 @@
|
||||
|
||||
#include "common/QLogging.hpp"
|
||||
|
||||
#include <boost/optional.hpp>
|
||||
#include <QJsonDocument>
|
||||
#include <QJsonObject>
|
||||
#include <QString>
|
||||
|
||||
#include <optional>
|
||||
|
||||
namespace chatterino {
|
||||
|
||||
struct PubSubMessageMessage {
|
||||
@@ -42,15 +43,15 @@ struct PubSubMessageMessage {
|
||||
}
|
||||
|
||||
template <class InnerClass>
|
||||
boost::optional<InnerClass> toInner() const;
|
||||
std::optional<InnerClass> toInner() const;
|
||||
};
|
||||
|
||||
template <class InnerClass>
|
||||
boost::optional<InnerClass> PubSubMessageMessage::toInner() const
|
||||
std::optional<InnerClass> PubSubMessageMessage::toInner() const
|
||||
{
|
||||
if (this->messageObject.empty())
|
||||
{
|
||||
return boost::none;
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
return InnerClass{this->messageObject};
|
||||
|
||||
Reference in New Issue
Block a user