1
0
Fork 0
mirror of https://github.com/HenkKalkwater/harbour-sailfin.git synced 2024-11-23 01:35:18 +00:00
harbour-sailfin/core/codegen/object_implementation.hbs

90 lines
1.9 KiB
Handlebars
Raw Normal View History

{{className}}::{{className}}() {}
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}}
}
{{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() {
QJsonObject result;
{{#each properties as |property|}}
result["{{property.originalName}}"] = {{supportNamespace}}::toJsonValue<{{property.typeNameWithQualifiers}}>({{property.memberName}});
{{/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}}
2021-03-24 19:04:03 +00:00
bool {{className}}::{{property.name}}Null() const {
return {{property.nullableCheck}};
}
2021-03-24 19:04:03 +00:00
void {{className}}::set{{property.writeName}}Null() {
{{property.memberName}}{{property.nullableSetter}};
}
2021-03-24 19:04:03 +00:00
{{/if}}
{{/each}}
} // NS DTO
namespace Support {
using {{className}} = Jellyfin::DTO::{{className}};
template <>
{{className}} fromJsonValue<{{className}}>(const QJsonValue &source) {
if (!source.isObject()) throw new ParseException("Expected JSON Object");
return {{className}}::fromJson(source.toObject());
}