mirror of
https://github.com/HenkKalkwater/harbour-sailfin.git
synced 2025-09-05 10:12:46 +00:00
WIP: logic rewrite
WIP: adding loaders
This commit is contained in:
parent
b9b08ab384
commit
2360b261f7
1769 changed files with 124903 additions and 1963 deletions
17
core/codegen/loader_header.hbs
Normal file
17
core/codegen/loader_header.hbs
Normal file
|
@ -0,0 +1,17 @@
|
|||
{{#if endpoint.hasSuccessResponse}}
|
||||
{{#if endpoint.description.length > 0}}
|
||||
/**
|
||||
* @brief {{endpoint.description}}
|
||||
|
||||
*/
|
||||
{{/if}}
|
||||
|
||||
class {{className}} : public {{supportNamespace}}::HttpLoader<{{dtoNamespace}}::{{endpoint.resultType}}, {{endpoint.parameterType}}> {
|
||||
public:
|
||||
explicit {{className}}(ApiClient *apiClient);
|
||||
|
||||
protected:
|
||||
QString url(const {{endpoint.parameterType}}& parameters) const override;
|
||||
QUrlQuery query(const {{endpoint.parameterType}}& parameters) const override;
|
||||
};
|
||||
{{/if}}
|
2
core/codegen/loader_implementation.hbs
Normal file
2
core/codegen/loader_implementation.hbs
Normal file
|
@ -0,0 +1,2 @@
|
|||
{{className}}::{{className}}(ApiClient *apiClient)
|
||||
: Loader<>(apiClient) {}
|
55
core/codegen/loader_types_header.hbs
Normal file
55
core/codegen/loader_types_header.hbs
Normal file
|
@ -0,0 +1,55 @@
|
|||
using namespace {{dtoNamespace}};
|
||||
|
||||
{{#each endpoints as |e|}}
|
||||
class {{e.name}} {
|
||||
public:
|
||||
|
||||
{{#each e.parameters as |param|}}
|
||||
/**
|
||||
* @brief {{param.description}}
|
||||
|
||||
*/
|
||||
|
||||
{{param.type.typeNameWithQualifiers}} {{param.type.name}}() const;
|
||||
void set{{param.type.writeName}}({{param.type.typeNameWithQualifiers}} new{{param.type.writeName}}) const;
|
||||
|
||||
|
||||
{{/each}}
|
||||
|
||||
private:
|
||||
// Required path parameters
|
||||
|
||||
{{#each e.requiredPathParameters as |param|}}
|
||||
{{param.type.typeNameWithQualifiers}} {{param.type.memberName}};
|
||||
|
||||
{{/each}}
|
||||
|
||||
// Required query parameters
|
||||
|
||||
{{#each e.requiredQueryParameters as |param|}}
|
||||
{{param.type.typeNameWithQualifiers}} {{param.type.memberName}};
|
||||
|
||||
{{/each}}
|
||||
|
||||
// Optional path parameters
|
||||
|
||||
{{#each e.optionalPathParameters as |param|}}
|
||||
{{param.type.typeNameWithQualifiers}} {{param.type.memberName}};
|
||||
|
||||
{{/each}}
|
||||
|
||||
// Optional query parameters
|
||||
|
||||
{{#each e.optionalQueryParameters as |param|}}
|
||||
{{#if param.type.defaultInitializer.length > 0}}
|
||||
{{param.type.typeNameWithQualifiers}} {{param.type.memberName}} = {{param.type.defaultInitializer}};
|
||||
{{else}}
|
||||
{{param.type.typeNameWithQualifiers}} {{param.type.memberName}};
|
||||
{{/if}}
|
||||
|
||||
{{/each}}
|
||||
|
||||
};
|
||||
|
||||
|
||||
{{/each}}
|
7
core/codegen/loader_types_header_getters_setters.hbs
Normal file
7
core/codegen/loader_types_header_getters_setters.hbs
Normal file
|
@ -0,0 +1,7 @@
|
|||
/**
|
||||
* @brief {{description}}
|
||||
|
||||
*/
|
||||
|
||||
{{typeNameWithQualifiers}} {{name}}() const;
|
||||
void set{{writeName}}({{typeNameWithQualifiers}} new{{writeName}}) const;
|
|
@ -7,7 +7,16 @@ class {{className}};
|
|||
|
||||
class {{className}} {
|
||||
public:
|
||||
explicit {{className}}();
|
||||
|
||||
{{className}}();
|
||||
|
||||
{{className}}(const {{className}} &other);
|
||||
|
||||
/**
|
||||
* Replaces the data being hold by this class with that of the other.
|
||||
*/
|
||||
void replaceData({{className}} &other);
|
||||
|
||||
static {{className}} fromJson(QJsonObject source);
|
||||
void setFromJson(QJsonObject source);
|
||||
QJsonObject toJson();
|
||||
|
@ -34,9 +43,11 @@ public:
|
|||
void set{{p.writeName}}({{p.typeNameWithQualifiers}} new{{p.writeName}});
|
||||
|
||||
{{#if p.isNullable}}
|
||||
bool is{{p.writeName}}Null() const;
|
||||
bool {{p.name}}Null() const;
|
||||
void set{{p.writeName}}Null();
|
||||
|
||||
{{/if}}
|
||||
|
||||
{{/each}}
|
||||
|
||||
protected:
|
||||
|
|
|
@ -1,6 +1,29 @@
|
|||
{{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;
|
||||
|
@ -39,13 +62,17 @@ void {{className}}::set{{property.writeName}}({{property.typeNameWithQualifiers}
|
|||
}
|
||||
|
||||
{{#if property.isNullable}}
|
||||
bool {{className}}::is{{property.writeName}}Null() const {
|
||||
bool {{className}}::{{property.name}}Null() const {
|
||||
return {{property.nullableCheck}};
|
||||
}
|
||||
|
||||
void {{className}}::setNull() {
|
||||
{{property.nullableSetter}};
|
||||
void {{className}}::set{{property.writeName}}Null() {
|
||||
|
||||
{{property.memberName}}{{property.nullableSetter}};
|
||||
|
||||
}
|
||||
{{/if}}
|
||||
|
||||
{{/each}}
|
||||
|
||||
} // NS DTO
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue