miqt/qt6/gen_qresource.go

224 lines
6.7 KiB
Go
Raw Normal View History

2024-10-20 18:21:03 +13:00
package qt6
/*
#include "gen_qresource.h"
#include <stdlib.h>
*/
import "C"
import (
"runtime"
"unsafe"
)
type QResource__Compression int
const (
QResource__NoCompression QResource__Compression = 0
QResource__ZlibCompression QResource__Compression = 1
QResource__ZstdCompression QResource__Compression = 2
)
type QResource struct {
h *C.QResource
2024-10-20 18:21:03 +13:00
}
func (this *QResource) cPointer() *C.QResource {
if this == nil {
return nil
}
return this.h
}
func (this *QResource) UnsafePointer() unsafe.Pointer {
if this == nil {
return nil
}
return unsafe.Pointer(this.h)
}
2024-11-19 19:29:06 +13:00
// newQResource constructs the type using only CGO pointers.
2024-10-20 18:21:03 +13:00
func newQResource(h *C.QResource) *QResource {
if h == nil {
return nil
}
2024-12-07 17:15:57 +13:00
2024-10-20 18:21:03 +13:00
return &QResource{h: h}
}
2024-11-19 19:29:06 +13:00
// UnsafeNewQResource constructs the type using only unsafe pointers.
2024-10-20 18:21:03 +13:00
func UnsafeNewQResource(h unsafe.Pointer) *QResource {
2024-12-07 17:15:57 +13:00
return newQResource((*C.QResource)(h))
2024-10-20 18:21:03 +13:00
}
// NewQResource constructs a new QResource object.
func NewQResource() *QResource {
2024-11-19 19:29:06 +13:00
return newQResource(C.QResource_new())
2024-10-20 18:21:03 +13:00
}
// NewQResource2 constructs a new QResource object.
func NewQResource2(file string) *QResource {
file_ms := C.struct_miqt_string{}
file_ms.data = C.CString(file)
file_ms.len = C.size_t(len(file))
defer C.free(unsafe.Pointer(file_ms.data))
2024-11-19 19:29:06 +13:00
return newQResource(C.QResource_new2(file_ms))
2024-10-20 18:21:03 +13:00
}
// NewQResource3 constructs a new QResource object.
func NewQResource3(file string, locale *QLocale) *QResource {
file_ms := C.struct_miqt_string{}
file_ms.data = C.CString(file)
file_ms.len = C.size_t(len(file))
defer C.free(unsafe.Pointer(file_ms.data))
2024-11-19 19:29:06 +13:00
return newQResource(C.QResource_new3(file_ms, locale.cPointer()))
2024-10-20 18:21:03 +13:00
}
func (this *QResource) SetFileName(file string) {
file_ms := C.struct_miqt_string{}
file_ms.data = C.CString(file)
file_ms.len = C.size_t(len(file))
defer C.free(unsafe.Pointer(file_ms.data))
2025-02-01 13:45:16 +13:00
C.QResource_setFileName(this.h, file_ms)
2024-10-20 18:21:03 +13:00
}
func (this *QResource) FileName() string {
2025-02-01 13:45:16 +13:00
var _ms C.struct_miqt_string = C.QResource_fileName(this.h)
2024-10-20 18:21:03 +13:00
_ret := C.GoStringN(_ms.data, C.int(int64(_ms.len)))
C.free(unsafe.Pointer(_ms.data))
return _ret
}
func (this *QResource) AbsoluteFilePath() string {
2025-02-01 13:45:16 +13:00
var _ms C.struct_miqt_string = C.QResource_absoluteFilePath(this.h)
2024-10-20 18:21:03 +13:00
_ret := C.GoStringN(_ms.data, C.int(int64(_ms.len)))
C.free(unsafe.Pointer(_ms.data))
return _ret
}
func (this *QResource) SetLocale(locale *QLocale) {
2025-02-01 13:45:16 +13:00
C.QResource_setLocale(this.h, locale.cPointer())
2024-10-20 18:21:03 +13:00
}
func (this *QResource) Locale() *QLocale {
2025-02-01 13:45:16 +13:00
_goptr := newQLocale(C.QResource_locale(this.h))
2024-10-20 18:21:03 +13:00
_goptr.GoGC() // Qt uses pass-by-value semantics for this type. Mimic with finalizer
return _goptr
}
func (this *QResource) IsValid() bool {
2025-02-01 13:45:16 +13:00
return (bool)(C.QResource_isValid(this.h))
2024-10-20 18:21:03 +13:00
}
func (this *QResource) CompressionAlgorithm() QResource__Compression {
2025-02-01 13:45:16 +13:00
return (QResource__Compression)(C.QResource_compressionAlgorithm(this.h))
2024-10-20 18:21:03 +13:00
}
func (this *QResource) Size() int64 {
2025-02-01 13:45:16 +13:00
return (int64)(C.QResource_size(this.h))
2024-10-20 18:21:03 +13:00
}
func (this *QResource) Data() *byte {
2025-02-01 13:45:16 +13:00
return (*byte)(unsafe.Pointer(C.QResource_data(this.h)))
2024-10-20 18:21:03 +13:00
}
func (this *QResource) UncompressedSize() int64 {
2025-02-01 13:45:16 +13:00
return (int64)(C.QResource_uncompressedSize(this.h))
2024-10-20 18:21:03 +13:00
}
func (this *QResource) UncompressedData() []byte {
2025-02-01 13:45:16 +13:00
var _bytearray C.struct_miqt_string = C.QResource_uncompressedData(this.h)
2024-10-20 18:21:03 +13:00
_ret := C.GoBytes(unsafe.Pointer(_bytearray.data), C.int(int64(_bytearray.len)))
C.free(unsafe.Pointer(_bytearray.data))
return _ret
}
func (this *QResource) LastModified() *QDateTime {
2025-02-01 13:45:16 +13:00
_goptr := newQDateTime(C.QResource_lastModified(this.h))
2024-10-20 18:21:03 +13:00
_goptr.GoGC() // Qt uses pass-by-value semantics for this type. Mimic with finalizer
return _goptr
}
func QResource_RegisterResource(rccFilename string) bool {
rccFilename_ms := C.struct_miqt_string{}
rccFilename_ms.data = C.CString(rccFilename)
rccFilename_ms.len = C.size_t(len(rccFilename))
defer C.free(unsafe.Pointer(rccFilename_ms.data))
2025-02-01 13:45:16 +13:00
return (bool)(C.QResource_registerResource(rccFilename_ms))
2024-10-20 18:21:03 +13:00
}
func QResource_UnregisterResource(rccFilename string) bool {
rccFilename_ms := C.struct_miqt_string{}
rccFilename_ms.data = C.CString(rccFilename)
rccFilename_ms.len = C.size_t(len(rccFilename))
defer C.free(unsafe.Pointer(rccFilename_ms.data))
2025-02-01 13:45:16 +13:00
return (bool)(C.QResource_unregisterResource(rccFilename_ms))
2024-10-20 18:21:03 +13:00
}
func QResource_RegisterResourceWithRccData(rccData *byte) bool {
2025-02-01 13:45:16 +13:00
return (bool)(C.QResource_registerResourceWithRccData((*C.uchar)(unsafe.Pointer(rccData))))
2024-10-20 18:21:03 +13:00
}
func QResource_UnregisterResourceWithRccData(rccData *byte) bool {
2025-02-01 13:45:16 +13:00
return (bool)(C.QResource_unregisterResourceWithRccData((*C.uchar)(unsafe.Pointer(rccData))))
2024-10-20 18:21:03 +13:00
}
func QResource_RegisterResource2(rccFilename string, resourceRoot string) bool {
rccFilename_ms := C.struct_miqt_string{}
rccFilename_ms.data = C.CString(rccFilename)
rccFilename_ms.len = C.size_t(len(rccFilename))
defer C.free(unsafe.Pointer(rccFilename_ms.data))
resourceRoot_ms := C.struct_miqt_string{}
resourceRoot_ms.data = C.CString(resourceRoot)
resourceRoot_ms.len = C.size_t(len(resourceRoot))
defer C.free(unsafe.Pointer(resourceRoot_ms.data))
2025-02-01 13:45:16 +13:00
return (bool)(C.QResource_registerResource2(rccFilename_ms, resourceRoot_ms))
2024-10-20 18:21:03 +13:00
}
func QResource_UnregisterResource2(rccFilename string, resourceRoot string) bool {
rccFilename_ms := C.struct_miqt_string{}
rccFilename_ms.data = C.CString(rccFilename)
rccFilename_ms.len = C.size_t(len(rccFilename))
defer C.free(unsafe.Pointer(rccFilename_ms.data))
resourceRoot_ms := C.struct_miqt_string{}
resourceRoot_ms.data = C.CString(resourceRoot)
resourceRoot_ms.len = C.size_t(len(resourceRoot))
defer C.free(unsafe.Pointer(resourceRoot_ms.data))
2025-02-01 13:45:16 +13:00
return (bool)(C.QResource_unregisterResource2(rccFilename_ms, resourceRoot_ms))
2024-10-20 18:21:03 +13:00
}
func QResource_RegisterResource22(rccData *byte, resourceRoot string) bool {
resourceRoot_ms := C.struct_miqt_string{}
resourceRoot_ms.data = C.CString(resourceRoot)
resourceRoot_ms.len = C.size_t(len(resourceRoot))
defer C.free(unsafe.Pointer(resourceRoot_ms.data))
2025-02-01 13:45:16 +13:00
return (bool)(C.QResource_registerResource22((*C.uchar)(unsafe.Pointer(rccData)), resourceRoot_ms))
2024-10-20 18:21:03 +13:00
}
func QResource_UnregisterResource22(rccData *byte, resourceRoot string) bool {
resourceRoot_ms := C.struct_miqt_string{}
resourceRoot_ms.data = C.CString(resourceRoot)
resourceRoot_ms.len = C.size_t(len(resourceRoot))
defer C.free(unsafe.Pointer(resourceRoot_ms.data))
2025-02-01 13:45:16 +13:00
return (bool)(C.QResource_unregisterResource22((*C.uchar)(unsafe.Pointer(rccData)), resourceRoot_ms))
2024-10-20 18:21:03 +13:00
}
// Delete this object from C++ memory.
func (this *QResource) Delete() {
2025-02-01 13:45:16 +13:00
C.QResource_delete(this.h)
2024-10-20 18:21:03 +13: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 *QResource) GoGC() {
runtime.SetFinalizer(this, func(this *QResource) {
this.Delete()
runtime.KeepAlive(this.h)
})
}