miqt/qt6/gen_qjsondocument.cpp

150 lines
3.9 KiB
C++
Raw Normal View History

2024-10-20 18:21:03 +13:00
#include <QByteArray>
#include <QJsonArray>
#include <QJsonDocument>
#include <QJsonObject>
#include <QJsonParseError>
#include <QJsonValue>
#include <QString>
#include <QByteArray>
#include <cstring>
#include <QVariant>
#include <qjsondocument.h>
#include "gen_qjsondocument.h"
#ifdef __cplusplus
extern "C" {
#endif
#ifdef __cplusplus
} /* extern C */
#endif
2024-10-20 18:21:03 +13:00
2025-02-01 13:45:16 +13:00
struct miqt_string QJsonParseError_errorString(const QJsonParseError* self) {
2024-10-20 18:21:03 +13:00
QString _ret = self->errorString();
// Convert QString from UTF-16 in C++ RAII memory to UTF-8 in manually-managed C memory
QByteArray _b = _ret.toUtf8();
struct miqt_string _ms;
_ms.len = _b.length();
_ms.data = static_cast<char*>(malloc(_ms.len));
memcpy(_ms.data, _b.data(), _ms.len);
return _ms;
}
2025-02-01 13:45:16 +13:00
void QJsonParseError_delete(QJsonParseError* self) {
delete self;
2024-10-20 18:21:03 +13:00
}
2024-12-07 17:15:57 +13:00
QJsonDocument* QJsonDocument_new() {
return new QJsonDocument();
2024-10-20 18:21:03 +13:00
}
2024-12-07 17:15:57 +13:00
QJsonDocument* QJsonDocument_new2(QJsonObject* object) {
return new QJsonDocument(*object);
2024-10-20 18:21:03 +13:00
}
2024-12-07 17:15:57 +13:00
QJsonDocument* QJsonDocument_new3(QJsonArray* array) {
return new QJsonDocument(*array);
2024-10-20 18:21:03 +13:00
}
2024-12-07 17:15:57 +13:00
QJsonDocument* QJsonDocument_new4(QJsonDocument* other) {
return new QJsonDocument(*other);
2024-10-20 18:21:03 +13:00
}
2025-02-01 13:45:16 +13:00
void QJsonDocument_operatorAssign(QJsonDocument* self, QJsonDocument* other) {
2024-10-20 18:21:03 +13:00
self->operator=(*other);
}
2025-02-01 13:45:16 +13:00
void QJsonDocument_swap(QJsonDocument* self, QJsonDocument* other) {
2024-10-20 18:21:03 +13:00
self->swap(*other);
}
2025-02-01 13:45:16 +13:00
QJsonDocument* QJsonDocument_fromVariant(QVariant* variant) {
2024-10-20 18:21:03 +13:00
return new QJsonDocument(QJsonDocument::fromVariant(*variant));
}
2025-02-01 13:45:16 +13:00
QVariant* QJsonDocument_toVariant(const QJsonDocument* self) {
2024-10-20 18:21:03 +13:00
return new QVariant(self->toVariant());
}
2025-02-01 13:45:16 +13:00
QJsonDocument* QJsonDocument_fromJson(struct miqt_string json) {
2024-10-20 18:21:03 +13:00
QByteArray json_QByteArray(json.data, json.len);
return new QJsonDocument(QJsonDocument::fromJson(json_QByteArray));
}
2025-02-01 13:45:16 +13:00
struct miqt_string QJsonDocument_toJson(const QJsonDocument* self) {
2024-10-20 18:21:03 +13:00
QByteArray _qb = self->toJson();
struct miqt_string _ms;
_ms.len = _qb.length();
_ms.data = static_cast<char*>(malloc(_ms.len));
memcpy(_ms.data, _qb.data(), _ms.len);
return _ms;
}
2025-02-01 13:45:16 +13:00
bool QJsonDocument_isEmpty(const QJsonDocument* self) {
2024-10-20 18:21:03 +13:00
return self->isEmpty();
}
2025-02-01 13:45:16 +13:00
bool QJsonDocument_isArray(const QJsonDocument* self) {
2024-10-20 18:21:03 +13:00
return self->isArray();
}
2025-02-01 13:45:16 +13:00
bool QJsonDocument_isObject(const QJsonDocument* self) {
2024-10-20 18:21:03 +13:00
return self->isObject();
}
2025-02-01 13:45:16 +13:00
QJsonObject* QJsonDocument_object(const QJsonDocument* self) {
2024-10-20 18:21:03 +13:00
return new QJsonObject(self->object());
}
2025-02-01 13:45:16 +13:00
QJsonArray* QJsonDocument_array(const QJsonDocument* self) {
2024-10-20 18:21:03 +13:00
return new QJsonArray(self->array());
}
2025-02-01 13:45:16 +13:00
void QJsonDocument_setObject(QJsonDocument* self, QJsonObject* object) {
2024-10-20 18:21:03 +13:00
self->setObject(*object);
}
2025-02-01 13:45:16 +13:00
void QJsonDocument_setArray(QJsonDocument* self, QJsonArray* array) {
2024-10-20 18:21:03 +13:00
self->setArray(*array);
}
2025-02-01 13:45:16 +13:00
QJsonValue* QJsonDocument_operatorSubscript(const QJsonDocument* self, struct miqt_string key) {
2024-10-20 18:21:03 +13:00
QString key_QString = QString::fromUtf8(key.data, key.len);
return new QJsonValue(self->operator[](key_QString));
}
2025-02-01 13:45:16 +13:00
QJsonValue* QJsonDocument_operatorSubscriptWithQsizetype(const QJsonDocument* self, ptrdiff_t i) {
2024-10-20 18:21:03 +13:00
return new QJsonValue(self->operator[]((qsizetype)(i)));
}
2025-02-01 13:45:16 +13:00
bool QJsonDocument_operatorEqual(const QJsonDocument* self, QJsonDocument* other) {
return (*self == *other);
2024-10-20 18:21:03 +13:00
}
2025-02-01 13:45:16 +13:00
bool QJsonDocument_operatorNotEqual(const QJsonDocument* self, QJsonDocument* other) {
return (*self != *other);
2024-10-20 18:21:03 +13:00
}
2025-02-01 13:45:16 +13:00
bool QJsonDocument_isNull(const QJsonDocument* self) {
2024-10-20 18:21:03 +13:00
return self->isNull();
}
2025-02-01 13:45:16 +13:00
QJsonDocument* QJsonDocument_fromJson2(struct miqt_string json, QJsonParseError* error) {
2024-10-20 18:21:03 +13:00
QByteArray json_QByteArray(json.data, json.len);
return new QJsonDocument(QJsonDocument::fromJson(json_QByteArray, error));
}
2025-02-01 13:45:16 +13:00
struct miqt_string QJsonDocument_toJson1(const QJsonDocument* self, int format) {
2024-10-20 18:21:03 +13:00
QByteArray _qb = self->toJson(static_cast<QJsonDocument::JsonFormat>(format));
struct miqt_string _ms;
_ms.len = _qb.length();
_ms.data = static_cast<char*>(malloc(_ms.len));
memcpy(_ms.data, _qb.data(), _ms.len);
return _ms;
}
2025-02-01 13:45:16 +13:00
void QJsonDocument_delete(QJsonDocument* self) {
delete self;
2024-10-20 18:21:03 +13:00
}