Update to latest settings library version

This commit is contained in:
Rasmus Karlsson
2018-11-03 13:00:07 +01:00
parent 9ced50e94e
commit ac4a496a06
36 changed files with 373 additions and 374 deletions
+34 -41
View File
@@ -4,7 +4,7 @@
#include <rapidjson/document.h>
#include <QString>
#include <pajlada/settings/serialize.hpp>
#include <pajlada/serialize.hpp>
#include <cassert>
@@ -32,49 +32,42 @@ struct TwitchUser {
} // namespace chatterino
namespace pajlada {
namespace Settings {
template <>
struct Deserialize<chatterino::TwitchUser> {
static chatterino::TwitchUser get(const rapidjson::Value &value,
bool *error = nullptr)
template <>
struct Deserialize<chatterino::TwitchUser> {
static chatterino::TwitchUser get(const rapidjson::Value &value,
bool *error = nullptr)
{
using namespace chatterino;
TwitchUser user;
if (!value.IsObject())
{
using namespace chatterino;
TwitchUser user;
if (!value.IsObject())
{
PAJLADA_REPORT_ERROR(error)
PAJLADA_THROW_EXCEPTION(
"Deserialized rapidjson::Value is wrong type");
return user;
}
if (!rj::getSafe(value, "_id", user.id))
{
PAJLADA_REPORT_ERROR(error)
PAJLADA_THROW_EXCEPTION("Missing ID key");
return user;
}
if (!rj::getSafe(value, "name", user.name))
{
PAJLADA_REPORT_ERROR(error)
PAJLADA_THROW_EXCEPTION("Missing name key");
return user;
}
if (!rj::getSafe(value, "display_name", user.displayName))
{
PAJLADA_REPORT_ERROR(error)
PAJLADA_THROW_EXCEPTION("Missing display name key");
return user;
}
PAJLADA_REPORT_ERROR(error)
return user;
}
};
} // namespace Settings
if (!rj::getSafe(value, "_id", user.id))
{
PAJLADA_REPORT_ERROR(error)
return user;
}
if (!rj::getSafe(value, "name", user.name))
{
PAJLADA_REPORT_ERROR(error)
return user;
}
if (!rj::getSafe(value, "display_name", user.displayName))
{
PAJLADA_REPORT_ERROR(error)
return user;
}
return user;
}
};
} // namespace pajlada