1
0
Fork 0
mirror of https://github.com/HenkKalkwater/harbour-sailfin.git synced 2024-11-05 09:35:18 +00:00
harbour-sailfin/core/codegen/enum_header.hbs
Chris Josten 05f79197eb Extract OpenAPI writeflns to template files
With a few exceptions if the code would actually get larger
2021-03-19 23:01:29 +01:00

35 lines
593 B
Handlebars

class {{className}}Class {
Q_GADGET
public:
enum Value {
EnumNotSet,
{{#each values as |value|}}
{{value}},
{{/each}}
};
Q_ENUM(Value)
private:
explicit {{className}}Class();
};
typedef {{className}} Class::Value {{className}};
template <>
{{className}} fromJsonValue<{{className}}>(QJsonValue source) {
if (!source.isString()) return {{className}}Class::EnumNotSet;
QString str = source.toString();
{{#each values as |value|}}
if (str == QStringLiteral("{{value}}")) {
return {{className}}Class::{{value}};
}
{{/each}}
return {{className}}Class::EnumNotSet;
}