Replace boost::optional with std::optional (#4877)
This commit is contained in:
@@ -3,11 +3,12 @@
|
||||
#include "util/RapidjsonHelpers.hpp"
|
||||
#include "util/RapidJsonSerializeQString.hpp"
|
||||
|
||||
#include <boost/optional.hpp>
|
||||
#include <pajlada/serialize.hpp>
|
||||
#include <QColor>
|
||||
#include <QString>
|
||||
|
||||
#include <optional>
|
||||
|
||||
namespace chatterino {
|
||||
|
||||
// UserData defines a set of data that is defined for a unique user
|
||||
@@ -15,7 +16,7 @@ namespace chatterino {
|
||||
// or a user note that should be displayed with the user
|
||||
// Replacement fields should be optional, where none denotes that the field should not be updated for the user
|
||||
struct UserData {
|
||||
boost::optional<QColor> color{boost::none};
|
||||
std::optional<QColor> color{std::nullopt};
|
||||
|
||||
// TODO: User note?
|
||||
};
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
#include "singletons/Paths.hpp"
|
||||
#include "util/CombinePath.hpp"
|
||||
#include "util/Helpers.hpp"
|
||||
|
||||
namespace {
|
||||
|
||||
@@ -42,15 +43,14 @@ void UserDataController::save()
|
||||
this->sm->save();
|
||||
}
|
||||
|
||||
boost::optional<UserData> UserDataController::getUser(
|
||||
const QString &userID) const
|
||||
std::optional<UserData> UserDataController::getUser(const QString &userID) const
|
||||
{
|
||||
std::shared_lock lock(this->usersMutex);
|
||||
auto it = this->users.find(userID);
|
||||
|
||||
if (it == this->users.end())
|
||||
{
|
||||
return boost::none;
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
return it->second;
|
||||
@@ -67,8 +67,8 @@ void UserDataController::setUserColor(const QString &userID,
|
||||
{
|
||||
auto c = this->getUsers();
|
||||
auto it = c.find(userID);
|
||||
boost::optional<QColor> finalColor =
|
||||
boost::make_optional(!colorString.isEmpty(), QColor(colorString));
|
||||
std::optional<QColor> finalColor =
|
||||
makeConditionedOptional(!colorString.isEmpty(), QColor(colorString));
|
||||
if (it == c.end())
|
||||
{
|
||||
if (!finalColor)
|
||||
|
||||
@@ -7,11 +7,11 @@
|
||||
#include "util/RapidJsonSerializeQString.hpp"
|
||||
#include "util/serialize/Container.hpp"
|
||||
|
||||
#include <boost/optional.hpp>
|
||||
#include <pajlada/settings.hpp>
|
||||
#include <QColor>
|
||||
#include <QString>
|
||||
|
||||
#include <optional>
|
||||
#include <shared_mutex>
|
||||
#include <unordered_map>
|
||||
|
||||
@@ -22,7 +22,7 @@ class IUserDataController
|
||||
public:
|
||||
virtual ~IUserDataController() = default;
|
||||
|
||||
virtual boost::optional<UserData> getUser(const QString &userID) const = 0;
|
||||
virtual std::optional<UserData> getUser(const QString &userID) const = 0;
|
||||
|
||||
virtual void setUserColor(const QString &userID,
|
||||
const QString &colorString) = 0;
|
||||
@@ -35,7 +35,7 @@ public:
|
||||
|
||||
// Get extra data about a user
|
||||
// If the user does not have any extra data, return none
|
||||
boost::optional<UserData> getUser(const QString &userID) const override;
|
||||
std::optional<UserData> getUser(const QString &userID) const override;
|
||||
|
||||
// Update or insert extra data for the user's color override
|
||||
void setUserColor(const QString &userID,
|
||||
|
||||
Reference in New Issue
Block a user