miqt/qt6/gen_qlockfile.cpp

71 lines
1.7 KiB
C++
Raw Permalink Normal View History

2024-10-20 05:21:03 +00:00
#include <QLockFile>
#include <QString>
#include <QByteArray>
#include <cstring>
#include <qlockfile.h>
#include "gen_qlockfile.h"
#include "_cgo_export.h"
2024-11-19 06:29:06 +00:00
void QLockFile_new(struct miqt_string fileName, QLockFile** outptr_QLockFile) {
2024-10-20 05:21:03 +00:00
QString fileName_QString = QString::fromUtf8(fileName.data, fileName.len);
2024-11-19 06:29:06 +00:00
QLockFile* ret = new QLockFile(fileName_QString);
*outptr_QLockFile = ret;
2024-10-20 05:21:03 +00:00
}
struct miqt_string QLockFile_FileName(const QLockFile* self) {
QString _ret = self->fileName();
// 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;
}
bool QLockFile_Lock(QLockFile* self) {
return self->lock();
}
bool QLockFile_TryLock(QLockFile* self) {
return self->tryLock();
}
void QLockFile_Unlock(QLockFile* self) {
self->unlock();
}
void QLockFile_SetStaleLockTime(QLockFile* self, int staleLockTime) {
self->setStaleLockTime(static_cast<int>(staleLockTime));
}
int QLockFile_StaleLockTime(const QLockFile* self) {
return self->staleLockTime();
}
bool QLockFile_IsLocked(const QLockFile* self) {
return self->isLocked();
}
bool QLockFile_RemoveStaleLockFile(QLockFile* self) {
return self->removeStaleLockFile();
}
int QLockFile_Error(const QLockFile* self) {
QLockFile::LockError _ret = self->error();
return static_cast<int>(_ret);
}
bool QLockFile_TryLock1(QLockFile* self, int timeout) {
return self->tryLock(static_cast<int>(timeout));
}
2024-11-19 06:29:06 +00:00
void QLockFile_Delete(QLockFile* self, bool isSubclass) {
if (isSubclass) {
delete dynamic_cast<QLockFile*>( self );
} else {
delete self;
}
2024-10-20 05:21:03 +00:00
}