2021-03-20 15:29:31 +00:00
|
|
|
{{className}}::{{className}}() {}
|
2021-03-19 22:01:29 +00:00
|
|
|
|
|
|
|
|
2021-03-24 19:04:03 +00:00
|
|
|
{{className}}::{{className}}(const {{className}} &other) :
|
|
|
|
|
|
|
|
|
|
|
|
{{#each properties as |property|}}
|
|
|
|
{{property.memberName}}(other.{{property.memberName}})
|
|
|
|
{{#if property.isLast}}
|
|
|
|
{}
|
|
|
|
{{else}}
|
|
|
|
,
|
|
|
|
{{/if}}
|
|
|
|
|
|
|
|
{{/each}}
|
|
|
|
|
|
|
|
|
|
|
|
void {{className}}::replaceData({{className}} &other) {
|
|
|
|
|
|
|
|
{{#each properties as |property|}}
|
|
|
|
{{property.memberName}} = other.{{property.memberName}};
|
|
|
|
|
|
|
|
{{/each}}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-03-20 02:30:50 +00:00
|
|
|
{{className}} {{className}}::fromJson(QJsonObject source) {
|
2021-03-20 15:29:31 +00:00
|
|
|
|
2021-03-20 02:30:50 +00:00
|
|
|
{{className}} instance;
|
2021-03-20 15:29:31 +00:00
|
|
|
instance.setFromJson(source);
|
2021-03-19 22:01:29 +00:00
|
|
|
return instance;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-03-20 02:30:50 +00:00
|
|
|
void {{className}}::setFromJson(QJsonObject source) {
|
2021-03-19 22:01:29 +00:00
|
|
|
|
|
|
|
{{#each properties as |property|}}
|
2021-03-20 15:29:31 +00:00
|
|
|
{{property.memberName}} = {{supportNamespace}}::fromJsonValue<{{property.typeNameWithQualifiers}}>(source["{{property.originalName}}"]);
|
2021-03-19 22:01:29 +00:00
|
|
|
|
|
|
|
{{/each}}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2021-03-28 02:00:00 +00:00
|
|
|
QJsonObject {{className}}::toJson() const {
|
2021-03-19 22:01:29 +00:00
|
|
|
QJsonObject result;
|
|
|
|
|
|
|
|
{{#each properties as |property|}}
|
2021-03-20 15:29:31 +00:00
|
|
|
result["{{property.originalName}}"] = {{supportNamespace}}::toJsonValue<{{property.typeNameWithQualifiers}}>({{property.memberName}});
|
2021-03-19 22:01:29 +00:00
|
|
|
|
|
|
|
{{/each}}
|
|
|
|
|
|
|
|
return result;
|
2021-03-20 02:30:50 +00:00
|
|
|
}
|
2021-03-19 22:01:29 +00:00
|
|
|
|
|
|
|
|
|
|
|
{{#each properties as |property|}}
|
|
|
|
{{property.typeNameWithQualifiers}} {{className}}::{{property.name}}() const { return {{property.memberName}}; }
|
|
|
|
|
|
|
|
void {{className}}::set{{property.writeName}}({{property.typeNameWithQualifiers}} new{{property.writeName}}) {
|
|
|
|
|
|
|
|
{{property.memberName}} = new{{property.writeName}};
|
|
|
|
}
|
|
|
|
|
2021-03-20 02:30:50 +00:00
|
|
|
{{#if property.isNullable}}
|
2021-03-24 19:04:03 +00:00
|
|
|
bool {{className}}::{{property.name}}Null() const {
|
2021-03-20 02:30:50 +00:00
|
|
|
return {{property.nullableCheck}};
|
|
|
|
}
|
2021-03-19 22:01:29 +00:00
|
|
|
|
2021-03-24 19:04:03 +00:00
|
|
|
void {{className}}::set{{property.writeName}}Null() {
|
|
|
|
|
|
|
|
{{property.memberName}}{{property.nullableSetter}};
|
|
|
|
|
2021-03-20 02:30:50 +00:00
|
|
|
}
|
2021-03-24 19:04:03 +00:00
|
|
|
{{/if}}
|
|
|
|
|
2021-03-19 22:01:29 +00:00
|
|
|
{{/each}}
|
2021-03-20 15:29:31 +00:00
|
|
|
|
|
|
|
} // 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}}>) {
|
|
|
|
if (!source.isObject()) throw ParseException("Expected JSON Object");
|
2021-03-20 15:29:31 +00:00
|
|
|
return {{className}}::fromJson(source.toObject());
|
|
|
|
}
|
2021-03-28 02:00:00 +00:00
|
|
|
|
|
|
|
template<>
|
|
|
|
QJsonValue toJsonValue(const {{className}} &source, convertType<{{className}}>) {
|
|
|
|
return source.toJson();
|
|
|
|
}
|