mirror of
https://github.com/HenkKalkwater/harbour-sailfin.git
synced 2025-09-04 01:42:44 +00:00
Extract OpenAPI writeflns to template files
With a few exceptions if the code would actually get larger
This commit is contained in:
parent
96e19548d7
commit
05f79197eb
4 changed files with 166 additions and 133 deletions
34
core/codegen/enum_header.hbs
Normal file
34
core/codegen/enum_header.hbs
Normal file
|
@ -0,0 +1,34 @@
|
|||
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;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue