created base for all the list based settings
This commit is contained in:
@@ -1,87 +1,87 @@
|
||||
#pragma once
|
||||
//#pragma once
|
||||
|
||||
#include "util/serialize-custom.hpp"
|
||||
//#include "util/serialize-custom.hpp"
|
||||
|
||||
#include <QString>
|
||||
#include <pajlada/settings/serialize.hpp>
|
||||
//#include <QString>
|
||||
//#include <pajlada/settings/serialize.hpp>
|
||||
|
||||
namespace chatterino {
|
||||
namespace messages {
|
||||
//namespace chatterino {
|
||||
//namespace messages {
|
||||
|
||||
struct HighlightPhrase {
|
||||
QString key;
|
||||
bool alert;
|
||||
bool sound;
|
||||
bool regex;
|
||||
//struct HighlightPhrase {
|
||||
// QString key;
|
||||
// bool alert;
|
||||
// bool sound;
|
||||
// bool regex;
|
||||
|
||||
bool operator==(const HighlightPhrase &other) const
|
||||
{
|
||||
return std::tie(this->key, this->sound, this->alert, this->regex) ==
|
||||
std::tie(other.key, other.sound, other.alert, other.regex);
|
||||
}
|
||||
};
|
||||
} // namespace messages
|
||||
} // namespace chatterino
|
||||
// bool operator==(const HighlightPhrase &other) const
|
||||
// {
|
||||
// return std::tie(this->key, this->sound, this->alert, this->regex) ==
|
||||
// std::tie(other.key, other.sound, other.alert, other.regex);
|
||||
// }
|
||||
//};
|
||||
//} // namespace messages
|
||||
//} // namespace chatterino
|
||||
|
||||
namespace pajlada {
|
||||
namespace Settings {
|
||||
//namespace pajlada {
|
||||
//namespace Settings {
|
||||
|
||||
template <>
|
||||
struct Serialize<chatterino::messages::HighlightPhrase> {
|
||||
static rapidjson::Value get(const chatterino::messages::HighlightPhrase &value,
|
||||
rapidjson::Document::AllocatorType &a)
|
||||
{
|
||||
rapidjson::Value ret(rapidjson::kObjectType);
|
||||
//template <>
|
||||
//struct Serialize<chatterino::messages::HighlightPhrase> {
|
||||
// static rapidjson::Value get(const chatterino::messages::HighlightPhrase &value,
|
||||
// rapidjson::Document::AllocatorType &a)
|
||||
// {
|
||||
// rapidjson::Value ret(rapidjson::kObjectType);
|
||||
|
||||
AddMember(ret, "key", value.key, a);
|
||||
AddMember(ret, "alert", value.alert, a);
|
||||
AddMember(ret, "sound", value.sound, a);
|
||||
AddMember(ret, "regex", value.regex, a);
|
||||
// AddMember(ret, "key", value.key, a);
|
||||
// AddMember(ret, "alert", value.alert, a);
|
||||
// AddMember(ret, "sound", value.sound, a);
|
||||
// AddMember(ret, "regex", value.regex, a);
|
||||
|
||||
return ret;
|
||||
}
|
||||
};
|
||||
// return ret;
|
||||
// }
|
||||
//};
|
||||
|
||||
template <>
|
||||
struct Deserialize<chatterino::messages::HighlightPhrase> {
|
||||
static chatterino::messages::HighlightPhrase get(const rapidjson::Value &value)
|
||||
{
|
||||
chatterino::messages::HighlightPhrase ret;
|
||||
if (!value.IsObject()) {
|
||||
return ret;
|
||||
}
|
||||
//template <>
|
||||
//struct Deserialize<chatterino::messages::HighlightPhrase> {
|
||||
// static chatterino::messages::HighlightPhrase get(const rapidjson::Value &value)
|
||||
// {
|
||||
// chatterino::messages::HighlightPhrase ret;
|
||||
// if (!value.IsObject()) {
|
||||
// return ret;
|
||||
// }
|
||||
|
||||
if (value.HasMember("key")) {
|
||||
const rapidjson::Value &key = value["key"];
|
||||
if (key.IsString()) {
|
||||
ret.key = key.GetString();
|
||||
}
|
||||
}
|
||||
// if (value.HasMember("key")) {
|
||||
// const rapidjson::Value &key = value["key"];
|
||||
// if (key.IsString()) {
|
||||
// ret.key = key.GetString();
|
||||
// }
|
||||
// }
|
||||
|
||||
if (value.HasMember("alert")) {
|
||||
const rapidjson::Value &alert = value["alert"];
|
||||
if (alert.IsBool()) {
|
||||
ret.alert = alert.GetBool();
|
||||
}
|
||||
}
|
||||
// if (value.HasMember("alert")) {
|
||||
// const rapidjson::Value &alert = value["alert"];
|
||||
// if (alert.IsBool()) {
|
||||
// ret.alert = alert.GetBool();
|
||||
// }
|
||||
// }
|
||||
|
||||
if (value.HasMember("sound")) {
|
||||
const rapidjson::Value &sound = value["sound"];
|
||||
if (sound.IsBool()) {
|
||||
ret.sound = sound.GetBool();
|
||||
}
|
||||
}
|
||||
// if (value.HasMember("sound")) {
|
||||
// const rapidjson::Value &sound = value["sound"];
|
||||
// if (sound.IsBool()) {
|
||||
// ret.sound = sound.GetBool();
|
||||
// }
|
||||
// }
|
||||
|
||||
if (value.HasMember("regex")) {
|
||||
const rapidjson::Value ®ex = value["regex"];
|
||||
if (regex.IsBool()) {
|
||||
ret.regex = regex.GetBool();
|
||||
}
|
||||
}
|
||||
// if (value.HasMember("regex")) {
|
||||
// const rapidjson::Value ®ex = value["regex"];
|
||||
// if (regex.IsBool()) {
|
||||
// ret.regex = regex.GetBool();
|
||||
// }
|
||||
// }
|
||||
|
||||
return ret;
|
||||
}
|
||||
};
|
||||
// return ret;
|
||||
// }
|
||||
//};
|
||||
|
||||
} // namespace Settings
|
||||
} // namespace pajlada
|
||||
//} // namespace Settings
|
||||
//} // namespace pajlada
|
||||
|
||||
Reference in New Issue
Block a user