mirror of
https://github.com/HenkKalkwater/harbour-sailfin.git
synced 2024-11-22 17:25:17 +00:00
357ac89330
Due to some errors within DeviceProfile and how nullables were serialized, an invalid request was made and the /Sessions/Capabilities/Full would give an 400 response back. Besides that, ApiClient would generate a DeviceProfile before all properties from QML were read. This has been fixed by implementing QQmlParserStatus and only generating the device profile after all properties are set.
104 lines
2.3 KiB
Handlebars
104 lines
2.3 KiB
Handlebars
{{className}}::{{className}}() {}
|
|
|
|
|
|
{{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}}
|
|
}
|
|
|
|
|
|
{{className}} {{className}}::fromJson(QJsonObject source) {
|
|
|
|
{{className}} instance;
|
|
instance.setFromJson(source);
|
|
return instance;
|
|
}
|
|
|
|
|
|
void {{className}}::setFromJson(QJsonObject source) {
|
|
|
|
{{#each properties as |property|}}
|
|
{{property.memberName}} = {{supportNamespace}}::fromJsonValue<{{property.typeNameWithQualifiers}}>(source["{{property.originalName}}"]);
|
|
|
|
{{/each}}
|
|
|
|
}
|
|
|
|
QJsonObject {{className}}::toJson() const {
|
|
QJsonObject result;
|
|
|
|
{{#each properties as |property|}}
|
|
{{#if property.isNullable}}
|
|
|
|
|
|
if (!({{property.nullableCheck}})) {
|
|
result["{{property.originalName}}"] = {{supportNamespace}}::toJsonValue<{{property.typeNameWithQualifiers}}>({{property.memberName}});
|
|
}
|
|
|
|
{{#else}}
|
|
|
|
result["{{property.originalName}}"] = {{supportNamespace}}::toJsonValue<{{property.typeNameWithQualifiers}}>({{property.memberName}});
|
|
{{/if}}
|
|
{{/each}}
|
|
|
|
return result;
|
|
}
|
|
|
|
|
|
{{#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}};
|
|
}
|
|
|
|
{{#if property.isNullable}}
|
|
bool {{className}}::{{property.name}}Null() const {
|
|
return {{property.nullableCheck}};
|
|
}
|
|
|
|
void {{className}}::set{{property.writeName}}Null() {
|
|
|
|
{{property.memberName}}{{property.nullableSetter}};
|
|
|
|
}
|
|
{{/if}}
|
|
|
|
{{/each}}
|
|
|
|
} // NS DTO
|
|
|
|
namespace Support {
|
|
|
|
using {{className}} = Jellyfin::DTO::{{className}};
|
|
|
|
template <>
|
|
|
|
{{className}} fromJsonValue(const QJsonValue &source, convertType<{{className}}>) {
|
|
if (!source.isObject()) throw ParseException("Expected JSON Object");
|
|
return {{className}}::fromJson(source.toObject());
|
|
}
|
|
|
|
template<>
|
|
QJsonValue toJsonValue(const {{className}} &source, convertType<{{className}}>) {
|
|
return source.toJson();
|
|
}
|