2018-01-04 01:52:37 +01:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <QString>
|
|
|
|
#include <pajlada/settings/serialize.hpp>
|
|
|
|
|
|
|
|
namespace pajlada {
|
|
|
|
namespace Settings {
|
|
|
|
|
|
|
|
template <>
|
|
|
|
struct Serialize<QString> {
|
|
|
|
static rapidjson::Value get(const QString &value, rapidjson::Document::AllocatorType &a)
|
|
|
|
{
|
|
|
|
rapidjson::Value ret(qPrintable(value), a);
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
template <>
|
|
|
|
struct Deserialize<QString> {
|
|
|
|
static QString get(const rapidjson::Value &value)
|
|
|
|
{
|
|
|
|
if (!value.IsString()) {
|
|
|
|
throw std::runtime_error("Deserialized rapidjson::Value is not a string");
|
|
|
|
}
|
|
|
|
|
2018-06-06 11:42:01 +02:00
|
|
|
try {
|
|
|
|
const char *str = value.GetString();
|
|
|
|
auto strLen = value.GetStringLength();
|
|
|
|
|
|
|
|
return QString::fromUtf8(str, strLen);
|
|
|
|
} catch (const std::exception &e) {
|
|
|
|
int x = 5;
|
|
|
|
} catch (...) {
|
|
|
|
int y = 5;
|
|
|
|
}
|
|
|
|
|
|
|
|
return QString();
|
2018-01-04 01:52:37 +01:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace Settings
|
|
|
|
} // namespace pajlada
|