Skip to content

Instantly share code, notes, and snippets.

@manuc66
Last active June 19, 2017 12:45
Show Gist options
  • Save manuc66/730be9e25488450ebf99ba69196790db to your computer and use it in GitHub Desktop.
Save manuc66/730be9e25488450ebf99ba69196790db to your computer and use it in GitHub Desktop.
Result of generation for a model with additionalProperties to object
#include "SWGError.h"
#include "SWGHelpers.h"
#include <QJsonDocument>
#include <QJsonArray>
#include <QObject>
#include <QDebug>
namespace com {
SWGError::SWGError(QString* json) {
init();
this->fromJson(*json);
}
SWGError::SWGError() {
init();
}
SWGError::~SWGError() {
this->cleanup();
}
void
SWGError::init() {
_type = new QString("");
key = new QString("");
message = new QString("");
}
void
SWGError::cleanup() {
if(_type != nullptr) {
delete _type;
}
if(key != nullptr) {
delete key;
}
if(message != nullptr) {
delete message;
}
}
SWGError*
SWGError::fromJson(QString &json) {
QByteArray array (json.toStdString().c_str());
QJsonDocument doc = QJsonDocument::fromJson(array);
QJsonObject jsonObject = doc.object();
this->fromJsonObject(jsonObject);
return this;
}
void
SWGError::fromJsonObject(QJsonObject &pJson) {
::com::setValue(&_type, pJson["_type"], "QString", "QString");
::com::setValue(&key, pJson["key"], "QString", "QString");
::com::setValue(&message, pJson["message"], "QString", "QString");
}
QString
SWGError::asJson ()
{
QJsonObject* obj = this->asJsonObject();
QJsonDocument doc(*obj);
QByteArray bytes = doc.toJson();
return QString(bytes);
}
QJsonObject*
SWGError::asJsonObject() {
QJsonObject* obj = new QJsonObject();
toJsonValue(QString("_type"), _type, obj, QString("QString"));
toJsonValue(QString("key"), key, obj, QString("QString"));
toJsonValue(QString("message"), message, obj, QString("QString"));
return obj;
}
QString*
SWGError::getType() {
return _type;
}
void
SWGError::setType(QString* _type) {
this->_type = _type;
}
QString*
SWGError::getKey() {
return key;
}
void
SWGError::setKey(QString* key) {
this->key = key;
}
QString*
SWGError::getMessage() {
return message;
}
void
SWGError::setMessage(QString* message) {
this->message = message;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment