Update to latest settings library version
This commit is contained in:
@@ -5,7 +5,7 @@
|
||||
|
||||
#include <QRegularExpression>
|
||||
#include <QString>
|
||||
#include <pajlada/settings/serialize.hpp>
|
||||
#include <pajlada/serialize.hpp>
|
||||
|
||||
#include <memory>
|
||||
|
||||
@@ -68,42 +68,38 @@ private:
|
||||
} // namespace chatterino
|
||||
|
||||
namespace pajlada {
|
||||
namespace Settings {
|
||||
|
||||
template <>
|
||||
struct Serialize<chatterino::HighlightBlacklistUser> {
|
||||
static rapidjson::Value get(
|
||||
const chatterino::HighlightBlacklistUser &value,
|
||||
rapidjson::Document::AllocatorType &a)
|
||||
template <>
|
||||
struct Serialize<chatterino::HighlightBlacklistUser> {
|
||||
static rapidjson::Value get(const chatterino::HighlightBlacklistUser &value,
|
||||
rapidjson::Document::AllocatorType &a)
|
||||
{
|
||||
rapidjson::Value ret(rapidjson::kObjectType);
|
||||
|
||||
chatterino::rj::set(ret, "pattern", value.getPattern(), a);
|
||||
chatterino::rj::set(ret, "regex", value.isRegex(), a);
|
||||
|
||||
return ret;
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct Deserialize<chatterino::HighlightBlacklistUser> {
|
||||
static chatterino::HighlightBlacklistUser get(const rapidjson::Value &value)
|
||||
{
|
||||
QString pattern;
|
||||
bool isRegex = false;
|
||||
|
||||
if (!value.IsObject())
|
||||
{
|
||||
rapidjson::Value ret(rapidjson::kObjectType);
|
||||
|
||||
AddMember(ret, "pattern", value.getPattern(), a);
|
||||
AddMember(ret, "regex", value.isRegex(), a);
|
||||
|
||||
return ret;
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct Deserialize<chatterino::HighlightBlacklistUser> {
|
||||
static chatterino::HighlightBlacklistUser get(
|
||||
const rapidjson::Value &value)
|
||||
{
|
||||
QString pattern;
|
||||
bool isRegex = false;
|
||||
|
||||
if (!value.IsObject())
|
||||
{
|
||||
return chatterino::HighlightBlacklistUser(pattern, isRegex);
|
||||
}
|
||||
|
||||
chatterino::rj::getSafe(value, "pattern", pattern);
|
||||
chatterino::rj::getSafe(value, "regex", isRegex);
|
||||
|
||||
return chatterino::HighlightBlacklistUser(pattern, isRegex);
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace Settings
|
||||
chatterino::rj::getSafe(value, "pattern", pattern);
|
||||
chatterino::rj::getSafe(value, "regex", isRegex);
|
||||
|
||||
return chatterino::HighlightBlacklistUser(pattern, isRegex);
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace pajlada
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
#include <QRegularExpression>
|
||||
#include <QString>
|
||||
#include <pajlada/settings/serialize.hpp>
|
||||
#include <pajlada/serialize.hpp>
|
||||
|
||||
namespace chatterino {
|
||||
|
||||
@@ -70,48 +70,44 @@ private:
|
||||
} // namespace chatterino
|
||||
|
||||
namespace pajlada {
|
||||
namespace Settings {
|
||||
|
||||
template <>
|
||||
struct Serialize<chatterino::HighlightPhrase> {
|
||||
static rapidjson::Value get(const chatterino::HighlightPhrase &value,
|
||||
rapidjson::Document::AllocatorType &a)
|
||||
template <>
|
||||
struct Serialize<chatterino::HighlightPhrase> {
|
||||
static rapidjson::Value get(const chatterino::HighlightPhrase &value,
|
||||
rapidjson::Document::AllocatorType &a)
|
||||
{
|
||||
rapidjson::Value ret(rapidjson::kObjectType);
|
||||
|
||||
chatterino::rj::set(ret, "pattern", value.getPattern(), a);
|
||||
chatterino::rj::set(ret, "alert", value.getAlert(), a);
|
||||
chatterino::rj::set(ret, "sound", value.getSound(), a);
|
||||
chatterino::rj::set(ret, "regex", value.isRegex(), a);
|
||||
|
||||
return ret;
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct Deserialize<chatterino::HighlightPhrase> {
|
||||
static chatterino::HighlightPhrase get(const rapidjson::Value &value)
|
||||
{
|
||||
if (!value.IsObject())
|
||||
{
|
||||
rapidjson::Value ret(rapidjson::kObjectType);
|
||||
|
||||
AddMember(ret, "pattern", value.getPattern(), a);
|
||||
AddMember(ret, "alert", value.getAlert(), a);
|
||||
AddMember(ret, "sound", value.getSound(), a);
|
||||
AddMember(ret, "regex", value.isRegex(), a);
|
||||
|
||||
return ret;
|
||||
return chatterino::HighlightPhrase(QString(), true, false, false);
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct Deserialize<chatterino::HighlightPhrase> {
|
||||
static chatterino::HighlightPhrase get(const rapidjson::Value &value)
|
||||
{
|
||||
if (!value.IsObject())
|
||||
{
|
||||
return chatterino::HighlightPhrase(QString(), true, false,
|
||||
false);
|
||||
}
|
||||
QString _pattern;
|
||||
bool _alert = true;
|
||||
bool _sound = false;
|
||||
bool _isRegex = false;
|
||||
|
||||
QString _pattern;
|
||||
bool _alert = true;
|
||||
bool _sound = false;
|
||||
bool _isRegex = false;
|
||||
chatterino::rj::getSafe(value, "pattern", _pattern);
|
||||
chatterino::rj::getSafe(value, "alert", _alert);
|
||||
chatterino::rj::getSafe(value, "sound", _sound);
|
||||
chatterino::rj::getSafe(value, "regex", _isRegex);
|
||||
|
||||
chatterino::rj::getSafe(value, "pattern", _pattern);
|
||||
chatterino::rj::getSafe(value, "alert", _alert);
|
||||
chatterino::rj::getSafe(value, "sound", _sound);
|
||||
chatterino::rj::getSafe(value, "regex", _isRegex);
|
||||
return chatterino::HighlightPhrase(_pattern, _alert, _sound, _isRegex);
|
||||
}
|
||||
};
|
||||
|
||||
return chatterino::HighlightPhrase(_pattern, _alert, _sound,
|
||||
_isRegex);
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace Settings
|
||||
} // namespace pajlada
|
||||
|
||||
Reference in New Issue
Block a user