2024-08-25 04:08:24 +00:00
|
|
|
#include <QByteArray>
|
|
|
|
#include <QIODevice>
|
|
|
|
#include <QList>
|
|
|
|
#include <QString>
|
2024-08-29 07:01:51 +00:00
|
|
|
#include <QByteArray>
|
|
|
|
#include <cstring>
|
2024-08-25 04:08:24 +00:00
|
|
|
#include <QTextCodec>
|
|
|
|
#include <QTextDocument>
|
|
|
|
#include <QTextDocumentFragment>
|
|
|
|
#include <QTextDocumentWriter>
|
2024-10-16 05:07:56 +00:00
|
|
|
#include <qtextdocumentwriter.h>
|
2024-08-29 07:01:51 +00:00
|
|
|
#include "gen_qtextdocumentwriter.h"
|
2024-09-14 22:29:05 +00:00
|
|
|
#include "_cgo_export.h"
|
2024-08-25 04:08:24 +00:00
|
|
|
|
|
|
|
QTextDocumentWriter* QTextDocumentWriter_new() {
|
|
|
|
return new QTextDocumentWriter();
|
|
|
|
}
|
|
|
|
|
2024-10-18 23:53:33 +00:00
|
|
|
QTextDocumentWriter* QTextDocumentWriter_new2(QIODevice* device, struct miqt_string format) {
|
|
|
|
QByteArray format_QByteArray(format.data, format.len);
|
|
|
|
return new QTextDocumentWriter(device, format_QByteArray);
|
2024-08-25 04:08:24 +00:00
|
|
|
}
|
|
|
|
|
2024-10-18 23:53:33 +00:00
|
|
|
QTextDocumentWriter* QTextDocumentWriter_new3(struct miqt_string fileName) {
|
|
|
|
QString fileName_QString = QString::fromUtf8(fileName.data, fileName.len);
|
2024-08-25 04:08:24 +00:00
|
|
|
return new QTextDocumentWriter(fileName_QString);
|
|
|
|
}
|
|
|
|
|
2024-10-18 23:53:33 +00:00
|
|
|
QTextDocumentWriter* QTextDocumentWriter_new4(struct miqt_string fileName, struct miqt_string format) {
|
|
|
|
QString fileName_QString = QString::fromUtf8(fileName.data, fileName.len);
|
|
|
|
QByteArray format_QByteArray(format.data, format.len);
|
|
|
|
return new QTextDocumentWriter(fileName_QString, format_QByteArray);
|
2024-08-25 04:08:24 +00:00
|
|
|
}
|
|
|
|
|
2024-10-18 23:53:33 +00:00
|
|
|
void QTextDocumentWriter_SetFormat(QTextDocumentWriter* self, struct miqt_string format) {
|
|
|
|
QByteArray format_QByteArray(format.data, format.len);
|
|
|
|
self->setFormat(format_QByteArray);
|
2024-08-25 04:08:24 +00:00
|
|
|
}
|
|
|
|
|
2024-10-18 23:53:33 +00:00
|
|
|
struct miqt_string QTextDocumentWriter_Format(const QTextDocumentWriter* self) {
|
|
|
|
QByteArray _qb = self->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;
|
2024-08-25 04:08:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void QTextDocumentWriter_SetDevice(QTextDocumentWriter* self, QIODevice* device) {
|
|
|
|
self->setDevice(device);
|
|
|
|
}
|
|
|
|
|
2024-09-11 05:41:09 +00:00
|
|
|
QIODevice* QTextDocumentWriter_Device(const QTextDocumentWriter* self) {
|
|
|
|
return self->device();
|
2024-08-25 04:08:24 +00:00
|
|
|
}
|
|
|
|
|
2024-10-18 23:53:33 +00:00
|
|
|
void QTextDocumentWriter_SetFileName(QTextDocumentWriter* self, struct miqt_string fileName) {
|
|
|
|
QString fileName_QString = QString::fromUtf8(fileName.data, fileName.len);
|
2024-08-25 04:08:24 +00:00
|
|
|
self->setFileName(fileName_QString);
|
|
|
|
}
|
|
|
|
|
2024-10-18 23:53:33 +00:00
|
|
|
struct miqt_string QTextDocumentWriter_FileName(const QTextDocumentWriter* self) {
|
2024-09-14 22:29:05 +00:00
|
|
|
QString _ret = self->fileName();
|
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();
|
2024-10-18 23:53:33 +00:00
|
|
|
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;
|
2024-08-25 04:08:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool QTextDocumentWriter_Write(QTextDocumentWriter* self, QTextDocument* document) {
|
|
|
|
return self->write(document);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool QTextDocumentWriter_WriteWithFragment(QTextDocumentWriter* self, QTextDocumentFragment* fragment) {
|
|
|
|
return self->write(*fragment);
|
|
|
|
}
|
|
|
|
|
|
|
|
void QTextDocumentWriter_SetCodec(QTextDocumentWriter* self, QTextCodec* codec) {
|
|
|
|
self->setCodec(codec);
|
|
|
|
}
|
|
|
|
|
2024-09-11 05:41:09 +00:00
|
|
|
QTextCodec* QTextDocumentWriter_Codec(const QTextDocumentWriter* self) {
|
|
|
|
return self->codec();
|
2024-08-25 04:08:24 +00:00
|
|
|
}
|
|
|
|
|
2024-11-04 07:18:27 +00:00
|
|
|
struct miqt_array QTextDocumentWriter_SupportedDocumentFormats() {
|
2024-09-14 22:29:05 +00:00
|
|
|
QList<QByteArray> _ret = QTextDocumentWriter::supportedDocumentFormats();
|
2024-09-17 06:29:11 +00:00
|
|
|
// Convert QList<> from C++ memory to manually-managed C memory
|
2024-10-18 23:53:33 +00:00
|
|
|
struct miqt_string* _arr = static_cast<struct miqt_string*>(malloc(sizeof(struct miqt_string) * _ret.length()));
|
2024-09-14 22:29:05 +00:00
|
|
|
for (size_t i = 0, e = _ret.length(); i < e; ++i) {
|
2024-10-18 23:53:33 +00:00
|
|
|
QByteArray _lv_qb = _ret[i];
|
|
|
|
struct miqt_string _lv_ms;
|
|
|
|
_lv_ms.len = _lv_qb.length();
|
|
|
|
_lv_ms.data = static_cast<char*>(malloc(_lv_ms.len));
|
|
|
|
memcpy(_lv_ms.data, _lv_qb.data(), _lv_ms.len);
|
|
|
|
_arr[i] = _lv_ms;
|
2024-08-25 04:08:24 +00:00
|
|
|
}
|
2024-11-04 07:18:27 +00:00
|
|
|
struct miqt_array _out;
|
|
|
|
_out.len = _ret.length();
|
|
|
|
_out.data = static_cast<void*>(_arr);
|
2024-09-14 22:29:05 +00:00
|
|
|
return _out;
|
2024-08-25 04:08:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void QTextDocumentWriter_Delete(QTextDocumentWriter* self) {
|
|
|
|
delete self;
|
|
|
|
}
|
|
|
|
|