1
0
Fork 0
mirror of https://github.com/HenkKalkwater/harbour-sailfin.git synced 2024-05-19 04:12:43 +00:00
harbour-sailfin/core/codegen/object_implementation.hbs

49 lines
1.2 KiB
Handlebars

{{className}}::{{className}}(QObject *parent) {}
{{className}} {{className}}::fromJson(QJsonObject source) {
{{className}} instance;
instance->setFromJson(source, false);
return instance;
}
void {{className}}::setFromJson(QJsonObject source) {
{{#each properties as |property|}}
{{property.memberName}} = fromJsonValue<{{property.typeNameWithQualifiers}}>(source["{{property.originalName}}"]);
{{/each}}
}
QJsonObject {{className}}::toJson() {
QJsonObject result;
{{#each properties as |property|}}
result["{{property.originalName}}"] = 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}}
bool {{className}}::is{{property.writeName}}Null() const {
return {{property.nullableCheck}};
}
void {{className}}::setNull() {
{{property.nullableSetter}};
}
{{/each}}