miqt/qt/gen_qtemporarydir.cpp

70 lines
2.2 KiB
C++
Raw Normal View History

#include <QString>
2024-08-29 07:01:51 +00:00
#include <QByteArray>
#include <cstring>
#include <QTemporaryDir>
2024-08-29 07:01:51 +00:00
#include "qtemporarydir.h"
2024-08-29 07:01:51 +00:00
#include "gen_qtemporarydir.h"
extern "C" {
extern void miqt_exec_callback(void* cb, int argc, void* argv);
}
QTemporaryDir* QTemporaryDir_new() {
return new QTemporaryDir();
}
QTemporaryDir* QTemporaryDir_new2(const char* templateName, size_t templateName_Strlen) {
QString templateName_QString = QString::fromUtf8(templateName, templateName_Strlen);
return new QTemporaryDir(templateName_QString);
}
bool QTemporaryDir_IsValid(QTemporaryDir* self) {
2024-08-29 07:01:51 +00:00
return const_cast<const QTemporaryDir*>(self)->isValid();
}
void QTemporaryDir_ErrorString(QTemporaryDir* self, char** _out, int* _out_Strlen) {
2024-08-29 07:01:51 +00:00
QString ret = const_cast<const QTemporaryDir*>(self)->errorString();
// Convert QString from UTF-16 in C++ RAII memory to UTF-8 in manually-managed C memory
QByteArray b = ret.toUtf8();
*_out = static_cast<char*>(malloc(b.length()));
memcpy(*_out, b.data(), b.length());
*_out_Strlen = b.length();
}
bool QTemporaryDir_AutoRemove(QTemporaryDir* self) {
2024-08-29 07:01:51 +00:00
return const_cast<const QTemporaryDir*>(self)->autoRemove();
}
void QTemporaryDir_SetAutoRemove(QTemporaryDir* self, bool b) {
self->setAutoRemove(b);
}
bool QTemporaryDir_Remove(QTemporaryDir* self) {
return self->remove();
}
void QTemporaryDir_Path(QTemporaryDir* self, char** _out, int* _out_Strlen) {
2024-08-29 07:01:51 +00:00
QString ret = const_cast<const QTemporaryDir*>(self)->path();
// Convert QString from UTF-16 in C++ RAII memory to UTF-8 in manually-managed C memory
QByteArray b = ret.toUtf8();
*_out = static_cast<char*>(malloc(b.length()));
memcpy(*_out, b.data(), b.length());
*_out_Strlen = b.length();
}
void QTemporaryDir_FilePath(QTemporaryDir* self, const char* fileName, size_t fileName_Strlen, char** _out, int* _out_Strlen) {
QString fileName_QString = QString::fromUtf8(fileName, fileName_Strlen);
2024-08-29 07:01:51 +00:00
QString ret = const_cast<const QTemporaryDir*>(self)->filePath(fileName_QString);
// Convert QString from UTF-16 in C++ RAII memory to UTF-8 in manually-managed C memory
QByteArray b = ret.toUtf8();
*_out = static_cast<char*>(malloc(b.length()));
memcpy(*_out, b.data(), b.length());
*_out_Strlen = b.length();
}
void QTemporaryDir_Delete(QTemporaryDir* self) {
delete self;
}