2021-03-20 15:29:31 +00:00
|
|
|
{{className}}Class::{{className}}Class() {}
|
|
|
|
|
|
|
|
} // NS DTO
|
|
|
|
|
|
|
|
namespace Support {
|
|
|
|
|
|
|
|
using {{className}} = Jellyfin::DTO::{{className}};
|
|
|
|
|
|
|
|
template <>
|
|
|
|
|
2021-03-28 02:00:00 +00:00
|
|
|
{{className}} fromJsonValue(const QJsonValue &source, convertType<{{className}}>) {
|
2021-03-20 15:29:31 +00:00
|
|
|
if (!source.isString()) return {{className}}::EnumNotSet;
|
|
|
|
|
|
|
|
QString str = source.toString();
|
|
|
|
|
|
|
|
{{#each values as |value|}}
|
|
|
|
if (str == QStringLiteral("{{value}}")) {
|
|
|
|
return {{className}}::{{value}};
|
|
|
|
}
|
|
|
|
|
|
|
|
{{/each}}
|
|
|
|
|
|
|
|
return {{className}}::EnumNotSet;
|
|
|
|
}
|
2021-03-28 02:00:00 +00:00
|
|
|
|
|
|
|
template <>
|
|
|
|
QJsonValue toJsonValue(const {{className}} &source, convertType<{{className}}>) {
|
|
|
|
switch(source) {
|
|
|
|
|
|
|
|
{{#each values as |value|}}
|
|
|
|
case {{className}}::{{value}}:
|
|
|
|
return QStringLiteral("{{value}}");
|
|
|
|
|
|
|
|
{{/each}}
|
|
|
|
|
|
|
|
case {{className}}::EnumNotSet: // Fallthrough
|
|
|
|
default:
|
|
|
|
return QJsonValue();
|
|
|
|
}
|
|
|
|
}
|