2024-08-25 04:08:24 +00:00
|
|
|
package qt
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
|
|
|
#include "gen_qsharedmemory.h"
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
|
|
|
*/
|
|
|
|
import "C"
|
|
|
|
|
|
|
|
import (
|
2024-09-14 22:29:05 +00:00
|
|
|
"runtime"
|
2024-08-25 04:08:24 +00:00
|
|
|
"unsafe"
|
|
|
|
)
|
|
|
|
|
2024-09-04 06:54:22 +00:00
|
|
|
type QSharedMemory__AccessMode int
|
|
|
|
|
|
|
|
const (
|
|
|
|
QSharedMemory__AccessMode__ReadOnly QSharedMemory__AccessMode = 0
|
|
|
|
QSharedMemory__AccessMode__ReadWrite QSharedMemory__AccessMode = 1
|
|
|
|
)
|
|
|
|
|
|
|
|
type QSharedMemory__SharedMemoryError int
|
|
|
|
|
|
|
|
const (
|
|
|
|
QSharedMemory__SharedMemoryError__NoError QSharedMemory__SharedMemoryError = 0
|
|
|
|
QSharedMemory__SharedMemoryError__PermissionDenied QSharedMemory__SharedMemoryError = 1
|
|
|
|
QSharedMemory__SharedMemoryError__InvalidSize QSharedMemory__SharedMemoryError = 2
|
|
|
|
QSharedMemory__SharedMemoryError__KeyError QSharedMemory__SharedMemoryError = 3
|
|
|
|
QSharedMemory__SharedMemoryError__AlreadyExists QSharedMemory__SharedMemoryError = 4
|
|
|
|
QSharedMemory__SharedMemoryError__NotFound QSharedMemory__SharedMemoryError = 5
|
|
|
|
QSharedMemory__SharedMemoryError__LockError QSharedMemory__SharedMemoryError = 6
|
|
|
|
QSharedMemory__SharedMemoryError__OutOfResources QSharedMemory__SharedMemoryError = 7
|
|
|
|
QSharedMemory__SharedMemoryError__UnknownError QSharedMemory__SharedMemoryError = 8
|
|
|
|
)
|
|
|
|
|
2024-08-25 04:08:24 +00:00
|
|
|
type QSharedMemory struct {
|
|
|
|
h *C.QSharedMemory
|
|
|
|
*QObject
|
|
|
|
}
|
|
|
|
|
|
|
|
func (this *QSharedMemory) cPointer() *C.QSharedMemory {
|
|
|
|
if this == nil {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
return this.h
|
|
|
|
}
|
|
|
|
|
|
|
|
func newQSharedMemory(h *C.QSharedMemory) *QSharedMemory {
|
2024-09-01 02:23:55 +00:00
|
|
|
if h == nil {
|
|
|
|
return nil
|
|
|
|
}
|
2024-08-25 04:08:24 +00:00
|
|
|
return &QSharedMemory{h: h, QObject: newQObject_U(unsafe.Pointer(h))}
|
|
|
|
}
|
|
|
|
|
|
|
|
func newQSharedMemory_U(h unsafe.Pointer) *QSharedMemory {
|
|
|
|
return newQSharedMemory((*C.QSharedMemory)(h))
|
|
|
|
}
|
|
|
|
|
|
|
|
// NewQSharedMemory constructs a new QSharedMemory object.
|
|
|
|
func NewQSharedMemory() *QSharedMemory {
|
|
|
|
ret := C.QSharedMemory_new()
|
|
|
|
return newQSharedMemory(ret)
|
|
|
|
}
|
|
|
|
|
|
|
|
// NewQSharedMemory2 constructs a new QSharedMemory object.
|
|
|
|
func NewQSharedMemory2(key string) *QSharedMemory {
|
2024-09-14 22:29:05 +00:00
|
|
|
key_ms := miqt_strdupg(key)
|
|
|
|
defer C.free(key_ms)
|
|
|
|
ret := C.QSharedMemory_new2((*C.struct_miqt_string)(key_ms))
|
2024-08-25 04:08:24 +00:00
|
|
|
return newQSharedMemory(ret)
|
|
|
|
}
|
|
|
|
|
|
|
|
// NewQSharedMemory3 constructs a new QSharedMemory object.
|
|
|
|
func NewQSharedMemory3(parent *QObject) *QSharedMemory {
|
|
|
|
ret := C.QSharedMemory_new3(parent.cPointer())
|
|
|
|
return newQSharedMemory(ret)
|
|
|
|
}
|
|
|
|
|
|
|
|
// NewQSharedMemory4 constructs a new QSharedMemory object.
|
|
|
|
func NewQSharedMemory4(key string, parent *QObject) *QSharedMemory {
|
2024-09-14 22:29:05 +00:00
|
|
|
key_ms := miqt_strdupg(key)
|
|
|
|
defer C.free(key_ms)
|
|
|
|
ret := C.QSharedMemory_new4((*C.struct_miqt_string)(key_ms), parent.cPointer())
|
2024-08-25 04:08:24 +00:00
|
|
|
return newQSharedMemory(ret)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (this *QSharedMemory) MetaObject() *QMetaObject {
|
2024-09-14 22:29:05 +00:00
|
|
|
_ret := C.QSharedMemory_MetaObject(this.h)
|
|
|
|
return newQMetaObject_U(unsafe.Pointer(_ret))
|
2024-08-25 04:08:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func QSharedMemory_Tr(s string) string {
|
|
|
|
s_Cstring := C.CString(s)
|
|
|
|
defer C.free(unsafe.Pointer(s_Cstring))
|
2024-09-14 22:29:05 +00:00
|
|
|
var _ms *C.struct_miqt_string = C.QSharedMemory_Tr(s_Cstring)
|
|
|
|
_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 QSharedMemory_TrUtf8(s string) string {
|
|
|
|
s_Cstring := C.CString(s)
|
|
|
|
defer C.free(unsafe.Pointer(s_Cstring))
|
2024-09-14 22:29:05 +00:00
|
|
|
var _ms *C.struct_miqt_string = C.QSharedMemory_TrUtf8(s_Cstring)
|
|
|
|
_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 *QSharedMemory) SetKey(key string) {
|
2024-09-14 22:29:05 +00:00
|
|
|
key_ms := miqt_strdupg(key)
|
|
|
|
defer C.free(key_ms)
|
|
|
|
C.QSharedMemory_SetKey(this.h, (*C.struct_miqt_string)(key_ms))
|
2024-08-25 04:08:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (this *QSharedMemory) Key() string {
|
2024-09-14 22:29:05 +00:00
|
|
|
var _ms *C.struct_miqt_string = C.QSharedMemory_Key(this.h)
|
|
|
|
_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 *QSharedMemory) SetNativeKey(key string) {
|
2024-09-14 22:29:05 +00:00
|
|
|
key_ms := miqt_strdupg(key)
|
|
|
|
defer C.free(key_ms)
|
|
|
|
C.QSharedMemory_SetNativeKey(this.h, (*C.struct_miqt_string)(key_ms))
|
2024-08-25 04:08:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (this *QSharedMemory) NativeKey() string {
|
2024-09-14 22:29:05 +00:00
|
|
|
var _ms *C.struct_miqt_string = C.QSharedMemory_NativeKey(this.h)
|
|
|
|
_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
|
|
|
}
|
|
|
|
|
2024-08-29 07:01:51 +00:00
|
|
|
func (this *QSharedMemory) Create(size int) bool {
|
2024-09-14 22:29:05 +00:00
|
|
|
_ret := C.QSharedMemory_Create(this.h, (C.int)(size))
|
|
|
|
return (bool)(_ret)
|
2024-08-29 07:01:51 +00:00
|
|
|
}
|
|
|
|
|
2024-08-25 04:08:24 +00:00
|
|
|
func (this *QSharedMemory) Size() int {
|
2024-09-14 22:29:05 +00:00
|
|
|
_ret := C.QSharedMemory_Size(this.h)
|
|
|
|
return (int)(_ret)
|
2024-08-25 04:08:24 +00:00
|
|
|
}
|
|
|
|
|
2024-08-29 07:01:51 +00:00
|
|
|
func (this *QSharedMemory) Attach() bool {
|
2024-09-14 22:29:05 +00:00
|
|
|
_ret := C.QSharedMemory_Attach(this.h)
|
|
|
|
return (bool)(_ret)
|
2024-08-29 07:01:51 +00:00
|
|
|
}
|
|
|
|
|
2024-08-25 04:08:24 +00:00
|
|
|
func (this *QSharedMemory) IsAttached() bool {
|
2024-09-14 22:29:05 +00:00
|
|
|
_ret := C.QSharedMemory_IsAttached(this.h)
|
|
|
|
return (bool)(_ret)
|
2024-08-25 04:08:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (this *QSharedMemory) Detach() bool {
|
2024-09-14 22:29:05 +00:00
|
|
|
_ret := C.QSharedMemory_Detach(this.h)
|
|
|
|
return (bool)(_ret)
|
2024-08-25 04:08:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (this *QSharedMemory) Lock() bool {
|
2024-09-14 22:29:05 +00:00
|
|
|
_ret := C.QSharedMemory_Lock(this.h)
|
|
|
|
return (bool)(_ret)
|
2024-08-25 04:08:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (this *QSharedMemory) Unlock() bool {
|
2024-09-14 22:29:05 +00:00
|
|
|
_ret := C.QSharedMemory_Unlock(this.h)
|
|
|
|
return (bool)(_ret)
|
2024-08-25 04:08:24 +00:00
|
|
|
}
|
|
|
|
|
2024-09-04 06:54:22 +00:00
|
|
|
func (this *QSharedMemory) Error() QSharedMemory__SharedMemoryError {
|
2024-09-14 22:29:05 +00:00
|
|
|
_ret := C.QSharedMemory_Error(this.h)
|
|
|
|
return (QSharedMemory__SharedMemoryError)(_ret)
|
2024-08-29 07:01:51 +00:00
|
|
|
}
|
|
|
|
|
2024-08-25 04:08:24 +00:00
|
|
|
func (this *QSharedMemory) ErrorString() string {
|
2024-09-14 22:29:05 +00:00
|
|
|
var _ms *C.struct_miqt_string = C.QSharedMemory_ErrorString(this.h)
|
|
|
|
_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 QSharedMemory_Tr2(s string, c string) string {
|
|
|
|
s_Cstring := C.CString(s)
|
|
|
|
defer C.free(unsafe.Pointer(s_Cstring))
|
|
|
|
c_Cstring := C.CString(c)
|
|
|
|
defer C.free(unsafe.Pointer(c_Cstring))
|
2024-09-14 22:29:05 +00:00
|
|
|
var _ms *C.struct_miqt_string = C.QSharedMemory_Tr2(s_Cstring, c_Cstring)
|
|
|
|
_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 QSharedMemory_Tr3(s string, c string, n int) string {
|
|
|
|
s_Cstring := C.CString(s)
|
|
|
|
defer C.free(unsafe.Pointer(s_Cstring))
|
|
|
|
c_Cstring := C.CString(c)
|
|
|
|
defer C.free(unsafe.Pointer(c_Cstring))
|
2024-09-14 22:29:05 +00:00
|
|
|
var _ms *C.struct_miqt_string = C.QSharedMemory_Tr3(s_Cstring, c_Cstring, (C.int)(n))
|
|
|
|
_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 QSharedMemory_TrUtf82(s string, c string) string {
|
|
|
|
s_Cstring := C.CString(s)
|
|
|
|
defer C.free(unsafe.Pointer(s_Cstring))
|
|
|
|
c_Cstring := C.CString(c)
|
|
|
|
defer C.free(unsafe.Pointer(c_Cstring))
|
2024-09-14 22:29:05 +00:00
|
|
|
var _ms *C.struct_miqt_string = C.QSharedMemory_TrUtf82(s_Cstring, c_Cstring)
|
|
|
|
_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 QSharedMemory_TrUtf83(s string, c string, n int) string {
|
|
|
|
s_Cstring := C.CString(s)
|
|
|
|
defer C.free(unsafe.Pointer(s_Cstring))
|
|
|
|
c_Cstring := C.CString(c)
|
|
|
|
defer C.free(unsafe.Pointer(c_Cstring))
|
2024-09-14 22:29:05 +00:00
|
|
|
var _ms *C.struct_miqt_string = C.QSharedMemory_TrUtf83(s_Cstring, c_Cstring, (C.int)(n))
|
|
|
|
_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
|
|
|
}
|
|
|
|
|
2024-09-04 06:54:22 +00:00
|
|
|
func (this *QSharedMemory) Create2(size int, mode QSharedMemory__AccessMode) bool {
|
2024-09-14 22:29:05 +00:00
|
|
|
_ret := C.QSharedMemory_Create2(this.h, (C.int)(size), (C.uintptr_t)(mode))
|
|
|
|
return (bool)(_ret)
|
2024-08-29 07:01:51 +00:00
|
|
|
}
|
|
|
|
|
2024-09-04 06:54:22 +00:00
|
|
|
func (this *QSharedMemory) Attach1(mode QSharedMemory__AccessMode) bool {
|
2024-09-14 22:29:05 +00:00
|
|
|
_ret := C.QSharedMemory_Attach1(this.h, (C.uintptr_t)(mode))
|
|
|
|
return (bool)(_ret)
|
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 *QSharedMemory) Delete() {
|
|
|
|
C.QSharedMemory_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 *QSharedMemory) GoGC() {
|
|
|
|
runtime.SetFinalizer(this, func(this *QSharedMemory) {
|
|
|
|
this.Delete()
|
|
|
|
runtime.KeepAlive(this.h)
|
|
|
|
})
|
|
|
|
}
|