2024-08-25 04:08:24 +00:00
|
|
|
package qt
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
|
|
|
#include "gen_qmimedatabase.h"
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
|
|
|
*/
|
|
|
|
import "C"
|
|
|
|
|
|
|
|
import (
|
|
|
|
"runtime"
|
|
|
|
"unsafe"
|
|
|
|
)
|
|
|
|
|
2024-09-04 06:54:22 +00:00
|
|
|
type QMimeDatabase__MatchMode int
|
|
|
|
|
|
|
|
const (
|
2024-09-20 07:13:26 +00:00
|
|
|
QMimeDatabase__MatchDefault QMimeDatabase__MatchMode = 0
|
|
|
|
QMimeDatabase__MatchExtension QMimeDatabase__MatchMode = 1
|
|
|
|
QMimeDatabase__MatchContent QMimeDatabase__MatchMode = 2
|
2024-09-04 06:54:22 +00:00
|
|
|
)
|
|
|
|
|
2024-08-25 04:08:24 +00:00
|
|
|
type QMimeDatabase struct {
|
|
|
|
h *C.QMimeDatabase
|
|
|
|
}
|
|
|
|
|
|
|
|
func (this *QMimeDatabase) cPointer() *C.QMimeDatabase {
|
|
|
|
if this == nil {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
return this.h
|
|
|
|
}
|
|
|
|
|
|
|
|
func newQMimeDatabase(h *C.QMimeDatabase) *QMimeDatabase {
|
2024-09-01 02:23:55 +00:00
|
|
|
if h == nil {
|
|
|
|
return nil
|
|
|
|
}
|
2024-08-25 04:08:24 +00:00
|
|
|
return &QMimeDatabase{h: h}
|
|
|
|
}
|
|
|
|
|
|
|
|
func newQMimeDatabase_U(h unsafe.Pointer) *QMimeDatabase {
|
|
|
|
return newQMimeDatabase((*C.QMimeDatabase)(h))
|
|
|
|
}
|
|
|
|
|
|
|
|
// NewQMimeDatabase constructs a new QMimeDatabase object.
|
|
|
|
func NewQMimeDatabase() *QMimeDatabase {
|
|
|
|
ret := C.QMimeDatabase_new()
|
|
|
|
return newQMimeDatabase(ret)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (this *QMimeDatabase) MimeTypeForName(nameOrAlias string) *QMimeType {
|
2024-09-14 22:29:05 +00:00
|
|
|
nameOrAlias_ms := miqt_strdupg(nameOrAlias)
|
|
|
|
defer C.free(nameOrAlias_ms)
|
|
|
|
_ret := C.QMimeDatabase_MimeTypeForName(this.h, (*C.struct_miqt_string)(nameOrAlias_ms))
|
|
|
|
_goptr := newQMimeType(_ret)
|
|
|
|
_goptr.GoGC() // Qt uses pass-by-value semantics for this type. Mimic with finalizer
|
|
|
|
return _goptr
|
2024-08-25 04:08:24 +00:00
|
|
|
}
|
|
|
|
|
2024-08-29 07:01:51 +00:00
|
|
|
func (this *QMimeDatabase) MimeTypeForFile(fileName string) *QMimeType {
|
2024-09-14 22:29:05 +00:00
|
|
|
fileName_ms := miqt_strdupg(fileName)
|
|
|
|
defer C.free(fileName_ms)
|
|
|
|
_ret := C.QMimeDatabase_MimeTypeForFile(this.h, (*C.struct_miqt_string)(fileName_ms))
|
|
|
|
_goptr := newQMimeType(_ret)
|
|
|
|
_goptr.GoGC() // Qt uses pass-by-value semantics for this type. Mimic with finalizer
|
|
|
|
return _goptr
|
2024-08-29 07:01:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (this *QMimeDatabase) MimeTypeForFileWithFileInfo(fileInfo *QFileInfo) *QMimeType {
|
2024-09-14 22:29:05 +00:00
|
|
|
_ret := C.QMimeDatabase_MimeTypeForFileWithFileInfo(this.h, fileInfo.cPointer())
|
|
|
|
_goptr := newQMimeType(_ret)
|
|
|
|
_goptr.GoGC() // Qt uses pass-by-value semantics for this type. Mimic with finalizer
|
|
|
|
return _goptr
|
2024-08-29 07:01:51 +00:00
|
|
|
}
|
|
|
|
|
2024-08-25 04:08:24 +00:00
|
|
|
func (this *QMimeDatabase) MimeTypesForFileName(fileName string) []QMimeType {
|
2024-09-14 22:29:05 +00:00
|
|
|
fileName_ms := miqt_strdupg(fileName)
|
|
|
|
defer C.free(fileName_ms)
|
|
|
|
var _ma *C.struct_miqt_array = C.QMimeDatabase_MimeTypesForFileName(this.h, (*C.struct_miqt_string)(fileName_ms))
|
|
|
|
_ret := make([]QMimeType, int(_ma.len))
|
2024-09-17 07:30:27 +00:00
|
|
|
_outCast := (*[0xffff]*C.QMimeType)(unsafe.Pointer(_ma.data)) // hey ya
|
2024-09-14 22:29:05 +00:00
|
|
|
for i := 0; i < int(_ma.len); i++ {
|
2024-09-17 07:30:27 +00:00
|
|
|
_lv_ret := _outCast[i]
|
|
|
|
_lv_goptr := newQMimeType(_lv_ret)
|
|
|
|
_lv_goptr.GoGC() // Qt uses pass-by-value semantics for this type. Mimic with finalizer
|
|
|
|
_ret[i] = *_lv_goptr
|
2024-08-25 04:08:24 +00:00
|
|
|
}
|
2024-09-14 22:29:05 +00:00
|
|
|
C.free(unsafe.Pointer(_ma))
|
|
|
|
return _ret
|
2024-08-25 04:08:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (this *QMimeDatabase) MimeTypeForData(data *QByteArray) *QMimeType {
|
2024-09-14 22:29:05 +00:00
|
|
|
_ret := C.QMimeDatabase_MimeTypeForData(this.h, data.cPointer())
|
|
|
|
_goptr := newQMimeType(_ret)
|
|
|
|
_goptr.GoGC() // Qt uses pass-by-value semantics for this type. Mimic with finalizer
|
|
|
|
return _goptr
|
2024-08-25 04:08:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (this *QMimeDatabase) MimeTypeForDataWithDevice(device *QIODevice) *QMimeType {
|
2024-09-14 22:29:05 +00:00
|
|
|
_ret := C.QMimeDatabase_MimeTypeForDataWithDevice(this.h, device.cPointer())
|
|
|
|
_goptr := newQMimeType(_ret)
|
|
|
|
_goptr.GoGC() // Qt uses pass-by-value semantics for this type. Mimic with finalizer
|
|
|
|
return _goptr
|
2024-08-25 04:08:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (this *QMimeDatabase) MimeTypeForUrl(url *QUrl) *QMimeType {
|
2024-09-14 22:29:05 +00:00
|
|
|
_ret := C.QMimeDatabase_MimeTypeForUrl(this.h, url.cPointer())
|
|
|
|
_goptr := newQMimeType(_ret)
|
|
|
|
_goptr.GoGC() // Qt uses pass-by-value semantics for this type. Mimic with finalizer
|
|
|
|
return _goptr
|
2024-08-25 04:08:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (this *QMimeDatabase) MimeTypeForFileNameAndData(fileName string, device *QIODevice) *QMimeType {
|
2024-09-14 22:29:05 +00:00
|
|
|
fileName_ms := miqt_strdupg(fileName)
|
|
|
|
defer C.free(fileName_ms)
|
|
|
|
_ret := C.QMimeDatabase_MimeTypeForFileNameAndData(this.h, (*C.struct_miqt_string)(fileName_ms), device.cPointer())
|
|
|
|
_goptr := newQMimeType(_ret)
|
|
|
|
_goptr.GoGC() // Qt uses pass-by-value semantics for this type. Mimic with finalizer
|
|
|
|
return _goptr
|
2024-08-25 04:08:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (this *QMimeDatabase) MimeTypeForFileNameAndData2(fileName string, data *QByteArray) *QMimeType {
|
2024-09-14 22:29:05 +00:00
|
|
|
fileName_ms := miqt_strdupg(fileName)
|
|
|
|
defer C.free(fileName_ms)
|
|
|
|
_ret := C.QMimeDatabase_MimeTypeForFileNameAndData2(this.h, (*C.struct_miqt_string)(fileName_ms), data.cPointer())
|
|
|
|
_goptr := newQMimeType(_ret)
|
|
|
|
_goptr.GoGC() // Qt uses pass-by-value semantics for this type. Mimic with finalizer
|
|
|
|
return _goptr
|
2024-08-25 04:08:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (this *QMimeDatabase) SuffixForFileName(fileName string) string {
|
2024-09-14 22:29:05 +00:00
|
|
|
fileName_ms := miqt_strdupg(fileName)
|
|
|
|
defer C.free(fileName_ms)
|
|
|
|
var _ms *C.struct_miqt_string = C.QMimeDatabase_SuffixForFileName(this.h, (*C.struct_miqt_string)(fileName_ms))
|
|
|
|
_ret := C.GoStringN(&_ms.data, C.int(int64(_ms.len)))
|
|
|
|
C.free(unsafe.Pointer(_ms))
|
|
|
|
return _ret
|
2024-08-25 04:08:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (this *QMimeDatabase) AllMimeTypes() []QMimeType {
|
2024-09-14 22:29:05 +00:00
|
|
|
var _ma *C.struct_miqt_array = C.QMimeDatabase_AllMimeTypes(this.h)
|
|
|
|
_ret := make([]QMimeType, int(_ma.len))
|
2024-09-17 07:30:27 +00:00
|
|
|
_outCast := (*[0xffff]*C.QMimeType)(unsafe.Pointer(_ma.data)) // hey ya
|
2024-09-14 22:29:05 +00:00
|
|
|
for i := 0; i < int(_ma.len); i++ {
|
2024-09-17 07:30:27 +00:00
|
|
|
_lv_ret := _outCast[i]
|
|
|
|
_lv_goptr := newQMimeType(_lv_ret)
|
|
|
|
_lv_goptr.GoGC() // Qt uses pass-by-value semantics for this type. Mimic with finalizer
|
|
|
|
_ret[i] = *_lv_goptr
|
2024-08-25 04:08:24 +00:00
|
|
|
}
|
2024-09-14 22:29:05 +00:00
|
|
|
C.free(unsafe.Pointer(_ma))
|
|
|
|
return _ret
|
2024-08-25 04:08:24 +00:00
|
|
|
}
|
|
|
|
|
2024-09-04 06:54:22 +00:00
|
|
|
func (this *QMimeDatabase) MimeTypeForFile2(fileName string, mode QMimeDatabase__MatchMode) *QMimeType {
|
2024-09-14 22:29:05 +00:00
|
|
|
fileName_ms := miqt_strdupg(fileName)
|
|
|
|
defer C.free(fileName_ms)
|
2024-09-18 00:12:02 +00:00
|
|
|
_ret := C.QMimeDatabase_MimeTypeForFile2(this.h, (*C.struct_miqt_string)(fileName_ms), (C.int)(mode))
|
2024-09-14 22:29:05 +00:00
|
|
|
_goptr := newQMimeType(_ret)
|
|
|
|
_goptr.GoGC() // Qt uses pass-by-value semantics for this type. Mimic with finalizer
|
|
|
|
return _goptr
|
2024-08-29 07:01:51 +00:00
|
|
|
}
|
|
|
|
|
2024-09-04 06:54:22 +00:00
|
|
|
func (this *QMimeDatabase) MimeTypeForFile22(fileInfo *QFileInfo, mode QMimeDatabase__MatchMode) *QMimeType {
|
2024-09-18 00:12:02 +00:00
|
|
|
_ret := C.QMimeDatabase_MimeTypeForFile22(this.h, fileInfo.cPointer(), (C.int)(mode))
|
2024-09-14 22:29:05 +00:00
|
|
|
_goptr := newQMimeType(_ret)
|
|
|
|
_goptr.GoGC() // Qt uses pass-by-value semantics for this type. Mimic with finalizer
|
|
|
|
return _goptr
|
2024-08-29 07:01:51 +00:00
|
|
|
}
|
|
|
|
|
2024-09-14 22:29:05 +00:00
|
|
|
// Delete this object from C++ memory.
|
2024-08-25 04:08:24 +00:00
|
|
|
func (this *QMimeDatabase) Delete() {
|
|
|
|
C.QMimeDatabase_Delete(this.h)
|
|
|
|
}
|
2024-09-14 22:29:05 +00:00
|
|
|
|
|
|
|
// GoGC adds a Go Finalizer to this pointer, so that it will be deleted
|
|
|
|
// from C++ memory once it is unreachable from Go memory.
|
|
|
|
func (this *QMimeDatabase) GoGC() {
|
|
|
|
runtime.SetFinalizer(this, func(this *QMimeDatabase) {
|
|
|
|
this.Delete()
|
|
|
|
runtime.KeepAlive(this.h)
|
|
|
|
})
|
|
|
|
}
|