mirror of
https://github.com/mappu/miqt.git
synced 2024-12-22 17:08:38 +00:00
144 lines
3.7 KiB
Go
144 lines
3.7 KiB
Go
package network
|
|
|
|
/*
|
|
|
|
#include "gen_qtcpsocket.h"
|
|
#include <stdlib.h>
|
|
|
|
*/
|
|
import "C"
|
|
|
|
import (
|
|
"github.com/mappu/miqt/qt"
|
|
"runtime"
|
|
"unsafe"
|
|
)
|
|
|
|
type QTcpSocket struct {
|
|
h *C.QTcpSocket
|
|
*QAbstractSocket
|
|
}
|
|
|
|
func (this *QTcpSocket) cPointer() *C.QTcpSocket {
|
|
if this == nil {
|
|
return nil
|
|
}
|
|
return this.h
|
|
}
|
|
|
|
func (this *QTcpSocket) UnsafePointer() unsafe.Pointer {
|
|
if this == nil {
|
|
return nil
|
|
}
|
|
return unsafe.Pointer(this.h)
|
|
}
|
|
|
|
func newQTcpSocket(h *C.QTcpSocket) *QTcpSocket {
|
|
if h == nil {
|
|
return nil
|
|
}
|
|
return &QTcpSocket{h: h, QAbstractSocket: UnsafeNewQAbstractSocket(unsafe.Pointer(h))}
|
|
}
|
|
|
|
func UnsafeNewQTcpSocket(h unsafe.Pointer) *QTcpSocket {
|
|
return newQTcpSocket((*C.QTcpSocket)(h))
|
|
}
|
|
|
|
// NewQTcpSocket constructs a new QTcpSocket object.
|
|
func NewQTcpSocket() *QTcpSocket {
|
|
ret := C.QTcpSocket_new()
|
|
return newQTcpSocket(ret)
|
|
}
|
|
|
|
// NewQTcpSocket2 constructs a new QTcpSocket object.
|
|
func NewQTcpSocket2(parent *qt.QObject) *QTcpSocket {
|
|
ret := C.QTcpSocket_new2((*C.QObject)(parent.UnsafePointer()))
|
|
return newQTcpSocket(ret)
|
|
}
|
|
|
|
func (this *QTcpSocket) MetaObject() *qt.QMetaObject {
|
|
return qt.UnsafeNewQMetaObject(unsafe.Pointer(C.QTcpSocket_MetaObject(this.h)))
|
|
}
|
|
|
|
func (this *QTcpSocket) Metacast(param1 string) unsafe.Pointer {
|
|
param1_Cstring := C.CString(param1)
|
|
defer C.free(unsafe.Pointer(param1_Cstring))
|
|
return (unsafe.Pointer)(C.QTcpSocket_Metacast(this.h, param1_Cstring))
|
|
}
|
|
|
|
func QTcpSocket_Tr(s string) string {
|
|
s_Cstring := C.CString(s)
|
|
defer C.free(unsafe.Pointer(s_Cstring))
|
|
var _ms C.struct_miqt_string = C.QTcpSocket_Tr(s_Cstring)
|
|
_ret := C.GoStringN(_ms.data, C.int(int64(_ms.len)))
|
|
C.free(unsafe.Pointer(_ms.data))
|
|
return _ret
|
|
}
|
|
|
|
func QTcpSocket_TrUtf8(s string) string {
|
|
s_Cstring := C.CString(s)
|
|
defer C.free(unsafe.Pointer(s_Cstring))
|
|
var _ms C.struct_miqt_string = C.QTcpSocket_TrUtf8(s_Cstring)
|
|
_ret := C.GoStringN(_ms.data, C.int(int64(_ms.len)))
|
|
C.free(unsafe.Pointer(_ms.data))
|
|
return _ret
|
|
}
|
|
|
|
func QTcpSocket_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))
|
|
var _ms C.struct_miqt_string = C.QTcpSocket_Tr2(s_Cstring, c_Cstring)
|
|
_ret := C.GoStringN(_ms.data, C.int(int64(_ms.len)))
|
|
C.free(unsafe.Pointer(_ms.data))
|
|
return _ret
|
|
}
|
|
|
|
func QTcpSocket_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))
|
|
var _ms C.struct_miqt_string = C.QTcpSocket_Tr3(s_Cstring, c_Cstring, (C.int)(n))
|
|
_ret := C.GoStringN(_ms.data, C.int(int64(_ms.len)))
|
|
C.free(unsafe.Pointer(_ms.data))
|
|
return _ret
|
|
}
|
|
|
|
func QTcpSocket_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))
|
|
var _ms C.struct_miqt_string = C.QTcpSocket_TrUtf82(s_Cstring, c_Cstring)
|
|
_ret := C.GoStringN(_ms.data, C.int(int64(_ms.len)))
|
|
C.free(unsafe.Pointer(_ms.data))
|
|
return _ret
|
|
}
|
|
|
|
func QTcpSocket_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))
|
|
var _ms C.struct_miqt_string = C.QTcpSocket_TrUtf83(s_Cstring, c_Cstring, (C.int)(n))
|
|
_ret := C.GoStringN(_ms.data, C.int(int64(_ms.len)))
|
|
C.free(unsafe.Pointer(_ms.data))
|
|
return _ret
|
|
}
|
|
|
|
// Delete this object from C++ memory.
|
|
func (this *QTcpSocket) Delete() {
|
|
C.QTcpSocket_Delete(this.h)
|
|
}
|
|
|
|
// 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 *QTcpSocket) GoGC() {
|
|
runtime.SetFinalizer(this, func(this *QTcpSocket) {
|
|
this.Delete()
|
|
runtime.KeepAlive(this.h)
|
|
})
|
|
}
|