2024-10-20 05:21:03 +00:00
|
|
|
package qt6
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
|
|
|
#include "gen_qmimedatabase.h"
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
|
|
|
*/
|
|
|
|
import "C"
|
|
|
|
|
|
|
|
import (
|
|
|
|
"runtime"
|
|
|
|
"unsafe"
|
|
|
|
)
|
|
|
|
|
|
|
|
type QMimeDatabase__MatchMode int
|
|
|
|
|
|
|
|
const (
|
|
|
|
QMimeDatabase__MatchDefault QMimeDatabase__MatchMode = 0
|
|
|
|
QMimeDatabase__MatchExtension QMimeDatabase__MatchMode = 1
|
|
|
|
QMimeDatabase__MatchContent QMimeDatabase__MatchMode = 2
|
|
|
|
)
|
|
|
|
|
|
|
|
type QMimeDatabase struct {
|
2024-11-19 06:29:06 +00:00
|
|
|
h *C.QMimeDatabase
|
|
|
|
isSubclass bool
|
2024-10-20 05:21:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (this *QMimeDatabase) cPointer() *C.QMimeDatabase {
|
|
|
|
if this == nil {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
return this.h
|
|
|
|
}
|
|
|
|
|
|
|
|
func (this *QMimeDatabase) UnsafePointer() unsafe.Pointer {
|
|
|
|
if this == nil {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
return unsafe.Pointer(this.h)
|
|
|
|
}
|
|
|
|
|
2024-11-19 06:29:06 +00:00
|
|
|
// newQMimeDatabase constructs the type using only CGO pointers.
|
2024-10-20 05:21:03 +00:00
|
|
|
func newQMimeDatabase(h *C.QMimeDatabase) *QMimeDatabase {
|
|
|
|
if h == nil {
|
|
|
|
return nil
|
|
|
|
}
|
2024-12-07 04:15:57 +00:00
|
|
|
|
2024-10-20 05:21:03 +00:00
|
|
|
return &QMimeDatabase{h: h}
|
|
|
|
}
|
|
|
|
|
2024-11-19 06:29:06 +00:00
|
|
|
// UnsafeNewQMimeDatabase constructs the type using only unsafe pointers.
|
2024-10-20 05:21:03 +00:00
|
|
|
func UnsafeNewQMimeDatabase(h unsafe.Pointer) *QMimeDatabase {
|
2024-12-07 04:15:57 +00:00
|
|
|
return newQMimeDatabase((*C.QMimeDatabase)(h))
|
2024-10-20 05:21:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// NewQMimeDatabase constructs a new QMimeDatabase object.
|
|
|
|
func NewQMimeDatabase() *QMimeDatabase {
|
2024-11-19 06:29:06 +00:00
|
|
|
|
2024-12-07 04:15:57 +00:00
|
|
|
ret := newQMimeDatabase(C.QMimeDatabase_new())
|
2024-11-19 06:29:06 +00:00
|
|
|
ret.isSubclass = true
|
|
|
|
return ret
|
2024-10-20 05:21:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (this *QMimeDatabase) MimeTypeForName(nameOrAlias string) *QMimeType {
|
|
|
|
nameOrAlias_ms := C.struct_miqt_string{}
|
|
|
|
nameOrAlias_ms.data = C.CString(nameOrAlias)
|
|
|
|
nameOrAlias_ms.len = C.size_t(len(nameOrAlias))
|
|
|
|
defer C.free(unsafe.Pointer(nameOrAlias_ms.data))
|
2024-12-07 02:02:06 +00:00
|
|
|
_goptr := newQMimeType(C.QMimeDatabase_MimeTypeForName(this.h, nameOrAlias_ms))
|
2024-10-20 05:21:03 +00:00
|
|
|
_goptr.GoGC() // Qt uses pass-by-value semantics for this type. Mimic with finalizer
|
|
|
|
return _goptr
|
|
|
|
}
|
|
|
|
|
|
|
|
func (this *QMimeDatabase) MimeTypeForFile(fileName string) *QMimeType {
|
|
|
|
fileName_ms := C.struct_miqt_string{}
|
|
|
|
fileName_ms.data = C.CString(fileName)
|
|
|
|
fileName_ms.len = C.size_t(len(fileName))
|
|
|
|
defer C.free(unsafe.Pointer(fileName_ms.data))
|
2024-12-07 02:02:06 +00:00
|
|
|
_goptr := newQMimeType(C.QMimeDatabase_MimeTypeForFile(this.h, fileName_ms))
|
2024-10-20 05:21:03 +00:00
|
|
|
_goptr.GoGC() // Qt uses pass-by-value semantics for this type. Mimic with finalizer
|
|
|
|
return _goptr
|
|
|
|
}
|
|
|
|
|
|
|
|
func (this *QMimeDatabase) MimeTypeForFileWithFileInfo(fileInfo *QFileInfo) *QMimeType {
|
2024-12-07 02:02:06 +00:00
|
|
|
_goptr := newQMimeType(C.QMimeDatabase_MimeTypeForFileWithFileInfo(this.h, fileInfo.cPointer()))
|
2024-10-20 05:21:03 +00:00
|
|
|
_goptr.GoGC() // Qt uses pass-by-value semantics for this type. Mimic with finalizer
|
|
|
|
return _goptr
|
|
|
|
}
|
|
|
|
|
|
|
|
func (this *QMimeDatabase) MimeTypesForFileName(fileName string) []QMimeType {
|
|
|
|
fileName_ms := C.struct_miqt_string{}
|
|
|
|
fileName_ms.data = C.CString(fileName)
|
|
|
|
fileName_ms.len = C.size_t(len(fileName))
|
|
|
|
defer C.free(unsafe.Pointer(fileName_ms.data))
|
2024-11-04 07:18:27 +00:00
|
|
|
var _ma C.struct_miqt_array = C.QMimeDatabase_MimeTypesForFileName(this.h, fileName_ms)
|
2024-10-20 05:21:03 +00:00
|
|
|
_ret := make([]QMimeType, int(_ma.len))
|
|
|
|
_outCast := (*[0xffff]*C.QMimeType)(unsafe.Pointer(_ma.data)) // hey ya
|
|
|
|
for i := 0; i < int(_ma.len); i++ {
|
2024-12-07 02:02:06 +00:00
|
|
|
_lv_goptr := newQMimeType(_outCast[i])
|
2024-10-20 05:21:03 +00:00
|
|
|
_lv_goptr.GoGC() // Qt uses pass-by-value semantics for this type. Mimic with finalizer
|
|
|
|
_ret[i] = *_lv_goptr
|
|
|
|
}
|
|
|
|
return _ret
|
|
|
|
}
|
|
|
|
|
|
|
|
func (this *QMimeDatabase) MimeTypeForData(data []byte) *QMimeType {
|
|
|
|
data_alias := C.struct_miqt_string{}
|
|
|
|
data_alias.data = (*C.char)(unsafe.Pointer(&data[0]))
|
|
|
|
data_alias.len = C.size_t(len(data))
|
2024-12-07 02:02:06 +00:00
|
|
|
_goptr := newQMimeType(C.QMimeDatabase_MimeTypeForData(this.h, data_alias))
|
2024-10-20 05:21:03 +00:00
|
|
|
_goptr.GoGC() // Qt uses pass-by-value semantics for this type. Mimic with finalizer
|
|
|
|
return _goptr
|
|
|
|
}
|
|
|
|
|
|
|
|
func (this *QMimeDatabase) MimeTypeForDataWithDevice(device *QIODevice) *QMimeType {
|
2024-12-07 02:02:06 +00:00
|
|
|
_goptr := newQMimeType(C.QMimeDatabase_MimeTypeForDataWithDevice(this.h, device.cPointer()))
|
2024-10-20 05:21:03 +00:00
|
|
|
_goptr.GoGC() // Qt uses pass-by-value semantics for this type. Mimic with finalizer
|
|
|
|
return _goptr
|
|
|
|
}
|
|
|
|
|
|
|
|
func (this *QMimeDatabase) MimeTypeForUrl(url *QUrl) *QMimeType {
|
2024-12-07 02:02:06 +00:00
|
|
|
_goptr := newQMimeType(C.QMimeDatabase_MimeTypeForUrl(this.h, url.cPointer()))
|
2024-10-20 05:21:03 +00:00
|
|
|
_goptr.GoGC() // Qt uses pass-by-value semantics for this type. Mimic with finalizer
|
|
|
|
return _goptr
|
|
|
|
}
|
|
|
|
|
|
|
|
func (this *QMimeDatabase) MimeTypeForFileNameAndData(fileName string, device *QIODevice) *QMimeType {
|
|
|
|
fileName_ms := C.struct_miqt_string{}
|
|
|
|
fileName_ms.data = C.CString(fileName)
|
|
|
|
fileName_ms.len = C.size_t(len(fileName))
|
|
|
|
defer C.free(unsafe.Pointer(fileName_ms.data))
|
2024-12-07 02:02:06 +00:00
|
|
|
_goptr := newQMimeType(C.QMimeDatabase_MimeTypeForFileNameAndData(this.h, fileName_ms, device.cPointer()))
|
2024-10-20 05:21:03 +00:00
|
|
|
_goptr.GoGC() // Qt uses pass-by-value semantics for this type. Mimic with finalizer
|
|
|
|
return _goptr
|
|
|
|
}
|
|
|
|
|
|
|
|
func (this *QMimeDatabase) MimeTypeForFileNameAndData2(fileName string, data []byte) *QMimeType {
|
|
|
|
fileName_ms := C.struct_miqt_string{}
|
|
|
|
fileName_ms.data = C.CString(fileName)
|
|
|
|
fileName_ms.len = C.size_t(len(fileName))
|
|
|
|
defer C.free(unsafe.Pointer(fileName_ms.data))
|
|
|
|
data_alias := C.struct_miqt_string{}
|
|
|
|
data_alias.data = (*C.char)(unsafe.Pointer(&data[0]))
|
|
|
|
data_alias.len = C.size_t(len(data))
|
2024-12-07 02:02:06 +00:00
|
|
|
_goptr := newQMimeType(C.QMimeDatabase_MimeTypeForFileNameAndData2(this.h, fileName_ms, data_alias))
|
2024-10-20 05:21:03 +00:00
|
|
|
_goptr.GoGC() // Qt uses pass-by-value semantics for this type. Mimic with finalizer
|
|
|
|
return _goptr
|
|
|
|
}
|
|
|
|
|
|
|
|
func (this *QMimeDatabase) SuffixForFileName(fileName string) string {
|
|
|
|
fileName_ms := C.struct_miqt_string{}
|
|
|
|
fileName_ms.data = C.CString(fileName)
|
|
|
|
fileName_ms.len = C.size_t(len(fileName))
|
|
|
|
defer C.free(unsafe.Pointer(fileName_ms.data))
|
|
|
|
var _ms C.struct_miqt_string = C.QMimeDatabase_SuffixForFileName(this.h, fileName_ms)
|
|
|
|
_ret := C.GoStringN(_ms.data, C.int(int64(_ms.len)))
|
|
|
|
C.free(unsafe.Pointer(_ms.data))
|
|
|
|
return _ret
|
|
|
|
}
|
|
|
|
|
|
|
|
func (this *QMimeDatabase) AllMimeTypes() []QMimeType {
|
2024-11-04 07:18:27 +00:00
|
|
|
var _ma C.struct_miqt_array = C.QMimeDatabase_AllMimeTypes(this.h)
|
2024-10-20 05:21:03 +00:00
|
|
|
_ret := make([]QMimeType, int(_ma.len))
|
|
|
|
_outCast := (*[0xffff]*C.QMimeType)(unsafe.Pointer(_ma.data)) // hey ya
|
|
|
|
for i := 0; i < int(_ma.len); i++ {
|
2024-12-07 02:02:06 +00:00
|
|
|
_lv_goptr := newQMimeType(_outCast[i])
|
2024-10-20 05:21:03 +00:00
|
|
|
_lv_goptr.GoGC() // Qt uses pass-by-value semantics for this type. Mimic with finalizer
|
|
|
|
_ret[i] = *_lv_goptr
|
|
|
|
}
|
|
|
|
return _ret
|
|
|
|
}
|
|
|
|
|
|
|
|
func (this *QMimeDatabase) MimeTypeForFile2(fileName string, mode QMimeDatabase__MatchMode) *QMimeType {
|
|
|
|
fileName_ms := C.struct_miqt_string{}
|
|
|
|
fileName_ms.data = C.CString(fileName)
|
|
|
|
fileName_ms.len = C.size_t(len(fileName))
|
|
|
|
defer C.free(unsafe.Pointer(fileName_ms.data))
|
2024-12-07 02:02:06 +00:00
|
|
|
_goptr := newQMimeType(C.QMimeDatabase_MimeTypeForFile2(this.h, fileName_ms, (C.int)(mode)))
|
2024-10-20 05:21:03 +00:00
|
|
|
_goptr.GoGC() // Qt uses pass-by-value semantics for this type. Mimic with finalizer
|
|
|
|
return _goptr
|
|
|
|
}
|
|
|
|
|
|
|
|
func (this *QMimeDatabase) MimeTypeForFile22(fileInfo *QFileInfo, mode QMimeDatabase__MatchMode) *QMimeType {
|
2024-12-07 02:02:06 +00:00
|
|
|
_goptr := newQMimeType(C.QMimeDatabase_MimeTypeForFile22(this.h, fileInfo.cPointer(), (C.int)(mode)))
|
2024-10-20 05:21:03 +00:00
|
|
|
_goptr.GoGC() // Qt uses pass-by-value semantics for this type. Mimic with finalizer
|
|
|
|
return _goptr
|
|
|
|
}
|
|
|
|
|
|
|
|
// Delete this object from C++ memory.
|
|
|
|
func (this *QMimeDatabase) Delete() {
|
2024-11-19 06:29:06 +00:00
|
|
|
C.QMimeDatabase_Delete(this.h, C.bool(this.isSubclass))
|
2024-10-20 05:21:03 +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)
|
|
|
|
})
|
|
|
|
}
|