forked from loafle/openapi-generator-original
* Corrects issue #3410 when trying to create Arrays of primitive types * Use c++11 nullptr keyword and various indentation issues resolved * ran petstore on new mustaches
31 lines
712 B
Plaintext
31 lines
712 B
Plaintext
{{>licenseInfo}}
|
|
#ifndef ModelFactory_H_
|
|
#define ModelFactory_H_
|
|
|
|
{{#models}}{{#model}}
|
|
#include "{{classname}}.h"{{/model}}{{/models}}
|
|
|
|
namespace Swagger {
|
|
inline void* create(QString type) {
|
|
{{#models}}{{#model}}if(QString("{{classname}}").compare(type) == 0) {
|
|
return new {{classname}}();
|
|
}
|
|
{{/model}}{{/models}}
|
|
return nullptr;
|
|
}
|
|
|
|
inline void* create(QString json, QString type) {
|
|
void* val = create(type);
|
|
if(val != nullptr) {
|
|
SWGObject* obj = static_cast<SWGObject*>(val);
|
|
return obj->fromJson(json);
|
|
}
|
|
if(type.startsWith("QString")) {
|
|
return new QString();
|
|
}
|
|
return nullptr;
|
|
}
|
|
} /* namespace Swagger */
|
|
|
|
#endif /* ModelFactory_H_ */
|