Add support for non-highlight channel point rewards (#1809)

This commit is contained in:
Jonas Schmitt
2020-08-08 15:37:22 +02:00
committed by GitHub
parent 1bd3d10eef
commit 11b8948290
23 changed files with 498 additions and 25 deletions
+17
View File
@@ -28,5 +28,22 @@ namespace rj {
return std::string(buffer.GetString());
}
bool getSafeObject(rapidjson::Value &obj, const char *key,
rapidjson::Value &out)
{
if (!checkJsonValue(obj, key))
{
return false;
}
out = obj[key].Move();
return true;
}
bool checkJsonValue(const rapidjson::Value &obj, const char *key)
{
return obj.IsObject() && !obj.IsNull() && obj.HasMember(key);
}
} // namespace rj
} // namespace chatterino
+6 -11
View File
@@ -67,20 +67,12 @@ namespace rj {
arr.PushBack(pajlada::Serialize<Type>::get(value, a), a);
}
bool checkJsonValue(const rapidjson::Value &obj, const char *key);
template <typename Type>
bool getSafe(const rapidjson::Value &obj, const char *key, Type &out)
{
if (!obj.IsObject())
{
return false;
}
if (!obj.HasMember(key))
{
return false;
}
if (obj.IsNull())
if (!checkJsonValue(obj, key))
{
return false;
}
@@ -100,6 +92,9 @@ namespace rj {
return !error;
}
bool getSafeObject(rapidjson::Value &obj, const char *key,
rapidjson::Value &out);
std::string stringify(const rapidjson::Value &value);
} // namespace rj