2024-08-25 04:08:24 +00:00
|
|
|
#include <QChar>
|
|
|
|
#include <QString>
|
2024-08-29 07:01:51 +00:00
|
|
|
#include <QByteArray>
|
|
|
|
#include <cstring>
|
2024-08-25 04:08:24 +00:00
|
|
|
#include <QStringMatcher>
|
2024-08-29 07:01:51 +00:00
|
|
|
#include "qstringmatcher.h"
|
2024-08-25 04:08:24 +00:00
|
|
|
|
2024-08-29 07:01:51 +00:00
|
|
|
#include "gen_qstringmatcher.h"
|
2024-08-25 04:08:24 +00:00
|
|
|
|
|
|
|
extern "C" {
|
|
|
|
extern void miqt_exec_callback(void* cb, int argc, void* argv);
|
|
|
|
}
|
|
|
|
|
|
|
|
QStringMatcher* QStringMatcher_new() {
|
|
|
|
return new QStringMatcher();
|
|
|
|
}
|
|
|
|
|
2024-08-29 07:01:51 +00:00
|
|
|
QStringMatcher* QStringMatcher_new2(const char* pattern, size_t pattern_Strlen) {
|
|
|
|
QString pattern_QString = QString::fromUtf8(pattern, pattern_Strlen);
|
|
|
|
return new QStringMatcher(pattern_QString);
|
|
|
|
}
|
|
|
|
|
|
|
|
QStringMatcher* QStringMatcher_new3(QChar* uc, int lenVal) {
|
|
|
|
return new QStringMatcher(uc, static_cast<int>(lenVal));
|
|
|
|
}
|
|
|
|
|
|
|
|
QStringMatcher* QStringMatcher_new4(QStringMatcher* other) {
|
2024-08-25 04:08:24 +00:00
|
|
|
return new QStringMatcher(*other);
|
|
|
|
}
|
|
|
|
|
2024-08-29 07:01:51 +00:00
|
|
|
QStringMatcher* QStringMatcher_new5(const char* pattern, size_t pattern_Strlen, uintptr_t cs) {
|
|
|
|
QString pattern_QString = QString::fromUtf8(pattern, pattern_Strlen);
|
|
|
|
return new QStringMatcher(pattern_QString, static_cast<Qt::CaseSensitivity>(cs));
|
|
|
|
}
|
|
|
|
|
|
|
|
QStringMatcher* QStringMatcher_new6(QChar* uc, int lenVal, uintptr_t cs) {
|
|
|
|
return new QStringMatcher(uc, static_cast<int>(lenVal), static_cast<Qt::CaseSensitivity>(cs));
|
|
|
|
}
|
|
|
|
|
2024-08-25 04:08:24 +00:00
|
|
|
void QStringMatcher_OperatorAssign(QStringMatcher* self, QStringMatcher* other) {
|
|
|
|
self->operator=(*other);
|
|
|
|
}
|
|
|
|
|
|
|
|
void QStringMatcher_SetPattern(QStringMatcher* self, const char* pattern, size_t pattern_Strlen) {
|
|
|
|
QString pattern_QString = QString::fromUtf8(pattern, pattern_Strlen);
|
|
|
|
self->setPattern(pattern_QString);
|
|
|
|
}
|
|
|
|
|
2024-08-29 07:01:51 +00:00
|
|
|
void QStringMatcher_SetCaseSensitivity(QStringMatcher* self, uintptr_t cs) {
|
|
|
|
self->setCaseSensitivity(static_cast<Qt::CaseSensitivity>(cs));
|
|
|
|
}
|
|
|
|
|
2024-08-25 04:08:24 +00:00
|
|
|
int QStringMatcher_IndexIn(QStringMatcher* self, const char* str, size_t str_Strlen) {
|
|
|
|
QString str_QString = QString::fromUtf8(str, str_Strlen);
|
2024-08-29 07:01:51 +00:00
|
|
|
return const_cast<const QStringMatcher*>(self)->indexIn(str_QString);
|
2024-08-25 04:08:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int QStringMatcher_IndexIn2(QStringMatcher* self, QChar* str, int length) {
|
2024-08-29 07:01:51 +00:00
|
|
|
return const_cast<const QStringMatcher*>(self)->indexIn(str, static_cast<int>(length));
|
2024-08-25 04:08:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void QStringMatcher_Pattern(QStringMatcher* self, char** _out, int* _out_Strlen) {
|
2024-08-29 07:01:51 +00:00
|
|
|
QString ret = const_cast<const QStringMatcher*>(self)->pattern();
|
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();
|
|
|
|
}
|
|
|
|
|
2024-08-29 07:01:51 +00:00
|
|
|
uintptr_t QStringMatcher_CaseSensitivity(QStringMatcher* self) {
|
|
|
|
Qt::CaseSensitivity ret = const_cast<const QStringMatcher*>(self)->caseSensitivity();
|
|
|
|
return static_cast<uintptr_t>(ret);
|
|
|
|
}
|
|
|
|
|
2024-08-25 04:08:24 +00:00
|
|
|
int QStringMatcher_IndexIn22(QStringMatcher* self, const char* str, size_t str_Strlen, int from) {
|
|
|
|
QString str_QString = QString::fromUtf8(str, str_Strlen);
|
|
|
|
return self->indexIn(str_QString, static_cast<int>(from));
|
|
|
|
}
|
|
|
|
|
|
|
|
int QStringMatcher_IndexIn3(QStringMatcher* self, QChar* str, int length, int from) {
|
|
|
|
return self->indexIn(str, static_cast<int>(length), static_cast<int>(from));
|
|
|
|
}
|
|
|
|
|
|
|
|
void QStringMatcher_Delete(QStringMatcher* self) {
|
|
|
|
delete self;
|
|
|
|
}
|
|
|
|
|