2024-08-25 04:08:24 +00:00
|
|
|
#include <QByteArray>
|
2024-08-29 07:01:51 +00:00
|
|
|
#include <QFileInfo>
|
2024-08-25 04:08:24 +00:00
|
|
|
#include <QIODevice>
|
|
|
|
#include <QList>
|
|
|
|
#include <QMimeDatabase>
|
|
|
|
#include <QMimeType>
|
|
|
|
#include <QString>
|
2024-08-29 07:01:51 +00:00
|
|
|
#include <QByteArray>
|
|
|
|
#include <cstring>
|
2024-08-25 04:08:24 +00:00
|
|
|
#include <QUrl>
|
2024-08-29 07:01:51 +00:00
|
|
|
#include "qmimedatabase.h"
|
2024-08-25 04:08:24 +00:00
|
|
|
|
2024-08-29 07:01:51 +00:00
|
|
|
#include "gen_qmimedatabase.h"
|
2024-08-25 04:08:24 +00:00
|
|
|
|
|
|
|
extern "C" {
|
|
|
|
extern void miqt_exec_callback(void* cb, int argc, void* argv);
|
|
|
|
}
|
|
|
|
|
|
|
|
QMimeDatabase* QMimeDatabase_new() {
|
|
|
|
return new QMimeDatabase();
|
|
|
|
}
|
|
|
|
|
|
|
|
QMimeType* QMimeDatabase_MimeTypeForName(QMimeDatabase* self, const char* nameOrAlias, size_t nameOrAlias_Strlen) {
|
|
|
|
QString nameOrAlias_QString = QString::fromUtf8(nameOrAlias, nameOrAlias_Strlen);
|
2024-08-29 07:01:51 +00:00
|
|
|
QMimeType ret = const_cast<const QMimeDatabase*>(self)->mimeTypeForName(nameOrAlias_QString);
|
|
|
|
// Copy-construct value returned type into heap-allocated copy
|
|
|
|
return static_cast<QMimeType*>(new QMimeType(ret));
|
|
|
|
}
|
|
|
|
|
|
|
|
QMimeType* QMimeDatabase_MimeTypeForFile(QMimeDatabase* self, const char* fileName, size_t fileName_Strlen) {
|
|
|
|
QString fileName_QString = QString::fromUtf8(fileName, fileName_Strlen);
|
|
|
|
QMimeType ret = const_cast<const QMimeDatabase*>(self)->mimeTypeForFile(fileName_QString);
|
|
|
|
// Copy-construct value returned type into heap-allocated copy
|
|
|
|
return static_cast<QMimeType*>(new QMimeType(ret));
|
|
|
|
}
|
|
|
|
|
|
|
|
QMimeType* QMimeDatabase_MimeTypeForFileWithFileInfo(QMimeDatabase* self, QFileInfo* fileInfo) {
|
|
|
|
QMimeType ret = const_cast<const QMimeDatabase*>(self)->mimeTypeForFile(*fileInfo);
|
2024-08-25 04:08:24 +00:00
|
|
|
// Copy-construct value returned type into heap-allocated copy
|
|
|
|
return static_cast<QMimeType*>(new QMimeType(ret));
|
|
|
|
}
|
|
|
|
|
|
|
|
void QMimeDatabase_MimeTypesForFileName(QMimeDatabase* self, const char* fileName, size_t fileName_Strlen, QMimeType*** _out, size_t* _out_len) {
|
|
|
|
QString fileName_QString = QString::fromUtf8(fileName, fileName_Strlen);
|
2024-08-29 07:01:51 +00:00
|
|
|
QList<QMimeType> ret = const_cast<const QMimeDatabase*>(self)->mimeTypesForFileName(fileName_QString);
|
2024-08-25 04:08:24 +00:00
|
|
|
// Convert QList<> from C++ memory to manually-managed C memory of copy-constructed pointers
|
|
|
|
QMimeType** __out = static_cast<QMimeType**>(malloc(sizeof(QMimeType**) * ret.length()));
|
|
|
|
for (size_t i = 0, e = ret.length(); i < e; ++i) {
|
|
|
|
__out[i] = new QMimeType(ret[i]);
|
|
|
|
}
|
|
|
|
*_out = __out;
|
|
|
|
*_out_len = ret.length();
|
|
|
|
}
|
|
|
|
|
|
|
|
QMimeType* QMimeDatabase_MimeTypeForData(QMimeDatabase* self, QByteArray* data) {
|
2024-08-29 07:01:51 +00:00
|
|
|
QMimeType ret = const_cast<const QMimeDatabase*>(self)->mimeTypeForData(*data);
|
2024-08-25 04:08:24 +00:00
|
|
|
// Copy-construct value returned type into heap-allocated copy
|
|
|
|
return static_cast<QMimeType*>(new QMimeType(ret));
|
|
|
|
}
|
|
|
|
|
|
|
|
QMimeType* QMimeDatabase_MimeTypeForDataWithDevice(QMimeDatabase* self, QIODevice* device) {
|
2024-08-29 07:01:51 +00:00
|
|
|
QMimeType ret = const_cast<const QMimeDatabase*>(self)->mimeTypeForData(device);
|
2024-08-25 04:08:24 +00:00
|
|
|
// Copy-construct value returned type into heap-allocated copy
|
|
|
|
return static_cast<QMimeType*>(new QMimeType(ret));
|
|
|
|
}
|
|
|
|
|
|
|
|
QMimeType* QMimeDatabase_MimeTypeForUrl(QMimeDatabase* self, QUrl* url) {
|
2024-08-29 07:01:51 +00:00
|
|
|
QMimeType ret = const_cast<const QMimeDatabase*>(self)->mimeTypeForUrl(*url);
|
2024-08-25 04:08:24 +00:00
|
|
|
// Copy-construct value returned type into heap-allocated copy
|
|
|
|
return static_cast<QMimeType*>(new QMimeType(ret));
|
|
|
|
}
|
|
|
|
|
|
|
|
QMimeType* QMimeDatabase_MimeTypeForFileNameAndData(QMimeDatabase* self, const char* fileName, size_t fileName_Strlen, QIODevice* device) {
|
|
|
|
QString fileName_QString = QString::fromUtf8(fileName, fileName_Strlen);
|
2024-08-29 07:01:51 +00:00
|
|
|
QMimeType ret = const_cast<const QMimeDatabase*>(self)->mimeTypeForFileNameAndData(fileName_QString, device);
|
2024-08-25 04:08:24 +00:00
|
|
|
// Copy-construct value returned type into heap-allocated copy
|
|
|
|
return static_cast<QMimeType*>(new QMimeType(ret));
|
|
|
|
}
|
|
|
|
|
|
|
|
QMimeType* QMimeDatabase_MimeTypeForFileNameAndData2(QMimeDatabase* self, const char* fileName, size_t fileName_Strlen, QByteArray* data) {
|
|
|
|
QString fileName_QString = QString::fromUtf8(fileName, fileName_Strlen);
|
2024-08-29 07:01:51 +00:00
|
|
|
QMimeType ret = const_cast<const QMimeDatabase*>(self)->mimeTypeForFileNameAndData(fileName_QString, *data);
|
2024-08-25 04:08:24 +00:00
|
|
|
// Copy-construct value returned type into heap-allocated copy
|
|
|
|
return static_cast<QMimeType*>(new QMimeType(ret));
|
|
|
|
}
|
|
|
|
|
|
|
|
void QMimeDatabase_SuffixForFileName(QMimeDatabase* 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 QMimeDatabase*>(self)->suffixForFileName(fileName_QString);
|
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
|
|
|
|
QByteArray b = ret.toUtf8();
|
|
|
|
*_out = static_cast<char*>(malloc(b.length()));
|
|
|
|
memcpy(*_out, b.data(), b.length());
|
|
|
|
*_out_Strlen = b.length();
|
|
|
|
}
|
|
|
|
|
|
|
|
void QMimeDatabase_AllMimeTypes(QMimeDatabase* self, QMimeType*** _out, size_t* _out_len) {
|
2024-08-29 07:01:51 +00:00
|
|
|
QList<QMimeType> ret = const_cast<const QMimeDatabase*>(self)->allMimeTypes();
|
2024-08-25 04:08:24 +00:00
|
|
|
// Convert QList<> from C++ memory to manually-managed C memory of copy-constructed pointers
|
|
|
|
QMimeType** __out = static_cast<QMimeType**>(malloc(sizeof(QMimeType**) * ret.length()));
|
|
|
|
for (size_t i = 0, e = ret.length(); i < e; ++i) {
|
|
|
|
__out[i] = new QMimeType(ret[i]);
|
|
|
|
}
|
|
|
|
*_out = __out;
|
|
|
|
*_out_len = ret.length();
|
|
|
|
}
|
|
|
|
|
2024-08-29 07:01:51 +00:00
|
|
|
QMimeType* QMimeDatabase_MimeTypeForFile2(QMimeDatabase* self, const char* fileName, size_t fileName_Strlen, uintptr_t mode) {
|
|
|
|
QString fileName_QString = QString::fromUtf8(fileName, fileName_Strlen);
|
2024-09-07 03:31:00 +00:00
|
|
|
QMimeType ret = const_cast<const QMimeDatabase*>(self)->mimeTypeForFile(fileName_QString, static_cast<QMimeDatabase::MatchMode>(mode));
|
2024-08-29 07:01:51 +00:00
|
|
|
// Copy-construct value returned type into heap-allocated copy
|
|
|
|
return static_cast<QMimeType*>(new QMimeType(ret));
|
|
|
|
}
|
|
|
|
|
|
|
|
QMimeType* QMimeDatabase_MimeTypeForFile22(QMimeDatabase* self, QFileInfo* fileInfo, uintptr_t mode) {
|
2024-09-07 03:31:00 +00:00
|
|
|
QMimeType ret = const_cast<const QMimeDatabase*>(self)->mimeTypeForFile(*fileInfo, static_cast<QMimeDatabase::MatchMode>(mode));
|
2024-08-29 07:01:51 +00:00
|
|
|
// Copy-construct value returned type into heap-allocated copy
|
|
|
|
return static_cast<QMimeType*>(new QMimeType(ret));
|
|
|
|
}
|
|
|
|
|
2024-08-25 04:08:24 +00:00
|
|
|
void QMimeDatabase_Delete(QMimeDatabase* self) {
|
|
|
|
delete self;
|
|
|
|
}
|
|
|
|
|