Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ public Qt5CPPGenerator() {
//TODO binary should be mapped to byte array
// mapped to String as a workaround
typeMapping.put("binary", "QString");
typeMapping.put("ByteArray", "QByteArray");

importMapping = new HashMap<String, String>();

Expand All @@ -138,6 +139,7 @@ public Qt5CPPGenerator() {
systemIncludes.add("QMap");
systemIncludes.add("QDate");
systemIncludes.add("QDateTime");
systemIncludes.add("QByteArray");
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,27 @@ setValue(void* value, QJsonValue obj, QString type, QString complexType) {
qDebug() << "Can't set value because the target pointer is NULL";
}
}
else if (QStringLiteral("QByteArray").compare(type) == 0) {
QByteArray **val = static_cast<QByteArray**>(value);

if(val != NULL) {
if(!obj.isNull()) {
// create a new value and return
delete *val;

*val = new QByteArray(QByteArray::fromBase64(QByteArray::fromStdString(obj.toString().toStdString())));
return;
}
else {
// set target to NULL
delete *val;
*val = NULL;
}
}
else {
qDebug() << "Can't set value because the target pointer is NULL";
}
}
else if(type.startsWith("SWG") && obj.isObject()) {
// complex type
QJsonObject jsonObj = obj.toObject();
Expand Down Expand Up @@ -221,6 +242,10 @@ toJsonValue(QString name, void* value, QJsonObject* output, QString type) {
QDateTime* datetime = static_cast<QDateTime*>(value);
output->insert(name, QJsonValue(datetime->toString(Qt::ISODate)));
}
else if(QStringLiteral("QByteArray").compare(type) == 0) {
QByteArray* byteArray = static_cast<QByteArray*>(value);
output->insert(name, QJsonValue(QString(byteArray->toBase64())));
}
}

void
Expand Down