2024-08-25 04:08:24 +00:00
|
|
|
#include <QByteArray>
|
|
|
|
#include <QJsonArray>
|
|
|
|
#include <QJsonDocument>
|
|
|
|
#include <QJsonObject>
|
|
|
|
#include <QJsonParseError>
|
|
|
|
#include <QJsonValue>
|
|
|
|
#include <QString>
|
2024-08-29 07:01:51 +00:00
|
|
|
#include <QByteArray>
|
|
|
|
#include <cstring>
|
2024-08-25 04:08:24 +00:00
|
|
|
#include <QVariant>
|
2024-08-29 07:01:51 +00:00
|
|
|
#include "qjsondocument.h"
|
|
|
|
#include "gen_qjsondocument.h"
|
2024-09-14 22:29:05 +00:00
|
|
|
#include "_cgo_export.h"
|
2024-08-25 04:08:24 +00:00
|
|
|
|
2024-09-14 22:29:05 +00:00
|
|
|
struct miqt_string* QJsonParseError_ErrorString(const QJsonParseError* self) {
|
|
|
|
QString _ret = self->errorString();
|
2024-08-25 04:08:24 +00:00
|
|
|
// Convert QString from UTF-16 in C++ RAII memory to UTF-8 in manually-managed C memory
|
2024-09-14 22:29:05 +00:00
|
|
|
QByteArray _b = _ret.toUtf8();
|
|
|
|
return miqt_strdup(_b.data(), _b.length());
|
2024-08-25 04:08:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void QJsonParseError_Delete(QJsonParseError* self) {
|
|
|
|
delete self;
|
|
|
|
}
|
|
|
|
|
|
|
|
QJsonDocument* QJsonDocument_new() {
|
|
|
|
return new QJsonDocument();
|
|
|
|
}
|
|
|
|
|
|
|
|
QJsonDocument* QJsonDocument_new2(QJsonObject* object) {
|
|
|
|
return new QJsonDocument(*object);
|
|
|
|
}
|
|
|
|
|
|
|
|
QJsonDocument* QJsonDocument_new3(QJsonArray* array) {
|
|
|
|
return new QJsonDocument(*array);
|
|
|
|
}
|
|
|
|
|
|
|
|
QJsonDocument* QJsonDocument_new4(QJsonDocument* other) {
|
|
|
|
return new QJsonDocument(*other);
|
|
|
|
}
|
|
|
|
|
|
|
|
void QJsonDocument_OperatorAssign(QJsonDocument* self, QJsonDocument* other) {
|
|
|
|
self->operator=(*other);
|
|
|
|
}
|
|
|
|
|
|
|
|
void QJsonDocument_Swap(QJsonDocument* self, QJsonDocument* other) {
|
|
|
|
self->swap(*other);
|
|
|
|
}
|
|
|
|
|
2024-08-29 07:01:51 +00:00
|
|
|
QJsonDocument* QJsonDocument_FromRawData(const char* data, int size) {
|
2024-09-17 06:29:11 +00:00
|
|
|
return new QJsonDocument(QJsonDocument::fromRawData(data, static_cast<int>(size)));
|
2024-08-29 07:01:51 +00:00
|
|
|
}
|
|
|
|
|
2024-09-11 05:41:09 +00:00
|
|
|
const char* QJsonDocument_RawData(const QJsonDocument* self, int* size) {
|
|
|
|
return (const char*) self->rawData(static_cast<int*>(size));
|
2024-08-29 07:01:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
QJsonDocument* QJsonDocument_FromBinaryData(QByteArray* data) {
|
2024-09-17 06:29:11 +00:00
|
|
|
return new QJsonDocument(QJsonDocument::fromBinaryData(*data));
|
2024-08-25 04:08:24 +00:00
|
|
|
}
|
|
|
|
|
2024-09-11 05:41:09 +00:00
|
|
|
QByteArray* QJsonDocument_ToBinaryData(const QJsonDocument* self) {
|
2024-09-17 06:29:11 +00:00
|
|
|
return new QByteArray(self->toBinaryData());
|
2024-08-25 04:08:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
QJsonDocument* QJsonDocument_FromVariant(QVariant* variant) {
|
2024-09-17 06:29:11 +00:00
|
|
|
return new QJsonDocument(QJsonDocument::fromVariant(*variant));
|
2024-08-25 04:08:24 +00:00
|
|
|
}
|
|
|
|
|
2024-09-11 05:41:09 +00:00
|
|
|
QVariant* QJsonDocument_ToVariant(const QJsonDocument* self) {
|
2024-09-17 06:29:11 +00:00
|
|
|
return new QVariant(self->toVariant());
|
2024-08-25 04:08:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
QJsonDocument* QJsonDocument_FromJson(QByteArray* json) {
|
2024-09-17 06:29:11 +00:00
|
|
|
return new QJsonDocument(QJsonDocument::fromJson(*json));
|
2024-08-25 04:08:24 +00:00
|
|
|
}
|
|
|
|
|
2024-09-11 05:41:09 +00:00
|
|
|
QByteArray* QJsonDocument_ToJson(const QJsonDocument* self) {
|
2024-09-17 06:29:11 +00:00
|
|
|
return new QByteArray(self->toJson());
|
2024-08-29 07:01:51 +00:00
|
|
|
}
|
|
|
|
|
2024-09-18 00:12:02 +00:00
|
|
|
QByteArray* QJsonDocument_ToJsonWithFormat(const QJsonDocument* self, int format) {
|
2024-09-17 06:29:11 +00:00
|
|
|
return new QByteArray(self->toJson(static_cast<QJsonDocument::JsonFormat>(format)));
|
2024-08-25 04:08:24 +00:00
|
|
|
}
|
|
|
|
|
2024-09-11 05:41:09 +00:00
|
|
|
bool QJsonDocument_IsEmpty(const QJsonDocument* self) {
|
|
|
|
return self->isEmpty();
|
2024-08-25 04:08:24 +00:00
|
|
|
}
|
|
|
|
|
2024-09-11 05:41:09 +00:00
|
|
|
bool QJsonDocument_IsArray(const QJsonDocument* self) {
|
|
|
|
return self->isArray();
|
2024-08-25 04:08:24 +00:00
|
|
|
}
|
|
|
|
|
2024-09-11 05:41:09 +00:00
|
|
|
bool QJsonDocument_IsObject(const QJsonDocument* self) {
|
|
|
|
return self->isObject();
|
2024-08-25 04:08:24 +00:00
|
|
|
}
|
|
|
|
|
2024-09-11 05:41:09 +00:00
|
|
|
QJsonObject* QJsonDocument_Object(const QJsonDocument* self) {
|
2024-09-17 06:29:11 +00:00
|
|
|
return new QJsonObject(self->object());
|
2024-08-25 04:08:24 +00:00
|
|
|
}
|
|
|
|
|
2024-09-11 05:41:09 +00:00
|
|
|
QJsonArray* QJsonDocument_Array(const QJsonDocument* self) {
|
2024-09-17 06:29:11 +00:00
|
|
|
return new QJsonArray(self->array());
|
2024-08-25 04:08:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void QJsonDocument_SetObject(QJsonDocument* self, QJsonObject* object) {
|
|
|
|
self->setObject(*object);
|
|
|
|
}
|
|
|
|
|
|
|
|
void QJsonDocument_SetArray(QJsonDocument* self, QJsonArray* array) {
|
|
|
|
self->setArray(*array);
|
|
|
|
}
|
|
|
|
|
2024-09-14 22:29:05 +00:00
|
|
|
QJsonValue* QJsonDocument_OperatorSubscript(const QJsonDocument* self, struct miqt_string* key) {
|
|
|
|
QString key_QString = QString::fromUtf8(&key->data, key->len);
|
2024-09-17 06:29:11 +00:00
|
|
|
return new QJsonValue(self->operator[](key_QString));
|
2024-08-25 04:08:24 +00:00
|
|
|
}
|
|
|
|
|
2024-09-11 05:41:09 +00:00
|
|
|
QJsonValue* QJsonDocument_OperatorSubscriptWithInt(const QJsonDocument* self, int i) {
|
2024-09-17 06:29:11 +00:00
|
|
|
return new QJsonValue(self->operator[](static_cast<int>(i)));
|
2024-08-25 04:08:24 +00:00
|
|
|
}
|
|
|
|
|
2024-09-11 05:41:09 +00:00
|
|
|
bool QJsonDocument_OperatorEqual(const QJsonDocument* self, QJsonDocument* other) {
|
|
|
|
return self->operator==(*other);
|
2024-08-25 04:08:24 +00:00
|
|
|
}
|
|
|
|
|
2024-09-11 05:41:09 +00:00
|
|
|
bool QJsonDocument_OperatorNotEqual(const QJsonDocument* self, QJsonDocument* other) {
|
|
|
|
return self->operator!=(*other);
|
2024-08-25 04:08:24 +00:00
|
|
|
}
|
|
|
|
|
2024-09-11 05:41:09 +00:00
|
|
|
bool QJsonDocument_IsNull(const QJsonDocument* self) {
|
|
|
|
return self->isNull();
|
2024-08-29 07:01:51 +00:00
|
|
|
}
|
|
|
|
|
2024-09-18 00:12:02 +00:00
|
|
|
QJsonDocument* QJsonDocument_FromRawData3(const char* data, int size, int validation) {
|
2024-09-17 06:29:11 +00:00
|
|
|
return new QJsonDocument(QJsonDocument::fromRawData(data, static_cast<int>(size), static_cast<QJsonDocument::DataValidation>(validation)));
|
2024-08-29 07:01:51 +00:00
|
|
|
}
|
|
|
|
|
2024-09-18 00:12:02 +00:00
|
|
|
QJsonDocument* QJsonDocument_FromBinaryData2(QByteArray* data, int validation) {
|
2024-09-17 06:29:11 +00:00
|
|
|
return new QJsonDocument(QJsonDocument::fromBinaryData(*data, static_cast<QJsonDocument::DataValidation>(validation)));
|
2024-08-25 04:08:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
QJsonDocument* QJsonDocument_FromJson2(QByteArray* json, QJsonParseError* error) {
|
2024-09-17 06:29:11 +00:00
|
|
|
return new QJsonDocument(QJsonDocument::fromJson(*json, error));
|
2024-08-25 04:08:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void QJsonDocument_Delete(QJsonDocument* self) {
|
|
|
|
delete self;
|
|
|
|
}
|
|
|
|
|