2024-11-04 09:24:09 +00:00
|
|
|
package cbor
|
2024-08-25 04:08:24 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
|
|
|
|
#include "gen_qcborstreamwriter.h"
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
|
|
|
*/
|
|
|
|
import "C"
|
|
|
|
|
|
|
|
import (
|
2024-11-04 09:24:09 +00:00
|
|
|
"github.com/mappu/miqt/qt6"
|
2024-09-14 22:29:05 +00:00
|
|
|
"runtime"
|
2024-08-25 04:08:24 +00:00
|
|
|
"unsafe"
|
|
|
|
)
|
|
|
|
|
|
|
|
type QCborStreamWriter struct {
|
|
|
|
h *C.QCborStreamWriter
|
|
|
|
}
|
|
|
|
|
|
|
|
func (this *QCborStreamWriter) cPointer() *C.QCborStreamWriter {
|
|
|
|
if this == nil {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
return this.h
|
|
|
|
}
|
|
|
|
|
2024-10-16 05:07:56 +00:00
|
|
|
func (this *QCborStreamWriter) UnsafePointer() unsafe.Pointer {
|
|
|
|
if this == nil {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
return unsafe.Pointer(this.h)
|
|
|
|
}
|
|
|
|
|
2024-08-25 04:08:24 +00:00
|
|
|
func newQCborStreamWriter(h *C.QCborStreamWriter) *QCborStreamWriter {
|
2024-09-01 02:23:55 +00:00
|
|
|
if h == nil {
|
|
|
|
return nil
|
|
|
|
}
|
2024-08-25 04:08:24 +00:00
|
|
|
return &QCborStreamWriter{h: h}
|
|
|
|
}
|
|
|
|
|
2024-10-16 05:07:56 +00:00
|
|
|
func UnsafeNewQCborStreamWriter(h unsafe.Pointer) *QCborStreamWriter {
|
2024-08-25 04:08:24 +00:00
|
|
|
return newQCborStreamWriter((*C.QCborStreamWriter)(h))
|
|
|
|
}
|
|
|
|
|
|
|
|
// NewQCborStreamWriter constructs a new QCborStreamWriter object.
|
2024-11-04 09:24:09 +00:00
|
|
|
func NewQCborStreamWriter(device *qt6.QIODevice) *QCborStreamWriter {
|
|
|
|
ret := C.QCborStreamWriter_new((*C.QIODevice)(device.UnsafePointer()))
|
2024-08-25 04:08:24 +00:00
|
|
|
return newQCborStreamWriter(ret)
|
|
|
|
}
|
|
|
|
|
2024-11-04 09:24:09 +00:00
|
|
|
func (this *QCborStreamWriter) SetDevice(device *qt6.QIODevice) {
|
|
|
|
C.QCborStreamWriter_SetDevice(this.h, (*C.QIODevice)(device.UnsafePointer()))
|
2024-08-25 04:08:24 +00:00
|
|
|
}
|
|
|
|
|
2024-11-04 09:24:09 +00:00
|
|
|
func (this *QCborStreamWriter) Device() *qt6.QIODevice {
|
|
|
|
return qt6.UnsafeNewQIODevice(unsafe.Pointer(C.QCborStreamWriter_Device(this.h)))
|
2024-08-25 04:08:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (this *QCborStreamWriter) Append(u uint64) {
|
2024-08-29 07:01:51 +00:00
|
|
|
C.QCborStreamWriter_Append(this.h, (C.ulonglong)(u))
|
2024-08-25 04:08:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (this *QCborStreamWriter) AppendWithQint64(i int64) {
|
2024-08-29 07:01:51 +00:00
|
|
|
C.QCborStreamWriter_AppendWithQint64(this.h, (C.longlong)(i))
|
2024-08-25 04:08:24 +00:00
|
|
|
}
|
|
|
|
|
2024-09-16 07:04:28 +00:00
|
|
|
func (this *QCborStreamWriter) AppendWithQCborNegativeInteger(n QCborNegativeInteger) {
|
2024-09-18 00:12:02 +00:00
|
|
|
C.QCborStreamWriter_AppendWithQCborNegativeInteger(this.h, (C.uint64_t)(n))
|
2024-09-16 07:04:28 +00:00
|
|
|
}
|
|
|
|
|
2024-10-18 23:53:33 +00:00
|
|
|
func (this *QCborStreamWriter) AppendWithBa(ba []byte) {
|
|
|
|
ba_alias := C.struct_miqt_string{}
|
|
|
|
ba_alias.data = (*C.char)(unsafe.Pointer(&ba[0]))
|
|
|
|
ba_alias.len = C.size_t(len(ba))
|
|
|
|
C.QCborStreamWriter_AppendWithBa(this.h, ba_alias)
|
2024-08-25 04:08:24 +00:00
|
|
|
}
|
|
|
|
|
2024-09-16 07:04:28 +00:00
|
|
|
func (this *QCborStreamWriter) AppendWithTag(tag QCborTag) {
|
2024-09-18 00:12:02 +00:00
|
|
|
C.QCborStreamWriter_AppendWithTag(this.h, (C.uint64_t)(tag))
|
2024-09-16 07:04:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (this *QCborStreamWriter) Append3(tag QCborKnownTags) {
|
2024-09-18 00:12:02 +00:00
|
|
|
C.QCborStreamWriter_Append3(this.h, (C.int)(tag))
|
2024-09-16 07:04:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (this *QCborStreamWriter) AppendWithSt(st QCborSimpleType) {
|
2024-09-18 00:12:02 +00:00
|
|
|
C.QCborStreamWriter_AppendWithSt(this.h, (C.uint8_t)(st))
|
2024-09-16 07:04:28 +00:00
|
|
|
}
|
|
|
|
|
2024-08-25 04:08:24 +00:00
|
|
|
func (this *QCborStreamWriter) AppendWithFloat(f float32) {
|
|
|
|
C.QCborStreamWriter_AppendWithFloat(this.h, (C.float)(f))
|
|
|
|
}
|
|
|
|
|
|
|
|
func (this *QCborStreamWriter) AppendWithDouble(d float64) {
|
|
|
|
C.QCborStreamWriter_AppendWithDouble(this.h, (C.double)(d))
|
|
|
|
}
|
|
|
|
|
2024-10-11 05:43:04 +00:00
|
|
|
func (this *QCborStreamWriter) AppendByteString(data string, lenVal int64) {
|
2024-08-25 04:08:24 +00:00
|
|
|
data_Cstring := C.CString(data)
|
|
|
|
defer C.free(unsafe.Pointer(data_Cstring))
|
2024-10-11 05:43:04 +00:00
|
|
|
C.QCborStreamWriter_AppendByteString(this.h, data_Cstring, (C.ptrdiff_t)(lenVal))
|
2024-08-25 04:08:24 +00:00
|
|
|
}
|
|
|
|
|
2024-10-11 05:43:04 +00:00
|
|
|
func (this *QCborStreamWriter) AppendTextString(utf8 string, lenVal int64) {
|
2024-08-25 04:08:24 +00:00
|
|
|
utf8_Cstring := C.CString(utf8)
|
|
|
|
defer C.free(unsafe.Pointer(utf8_Cstring))
|
2024-10-11 05:43:04 +00:00
|
|
|
C.QCborStreamWriter_AppendTextString(this.h, utf8_Cstring, (C.ptrdiff_t)(lenVal))
|
2024-08-25 04:08:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (this *QCborStreamWriter) AppendWithBool(b bool) {
|
|
|
|
C.QCborStreamWriter_AppendWithBool(this.h, (C.bool)(b))
|
|
|
|
}
|
|
|
|
|
|
|
|
func (this *QCborStreamWriter) AppendNull() {
|
|
|
|
C.QCborStreamWriter_AppendNull(this.h)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (this *QCborStreamWriter) AppendUndefined() {
|
|
|
|
C.QCborStreamWriter_AppendUndefined(this.h)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (this *QCborStreamWriter) AppendWithInt(i int) {
|
|
|
|
C.QCborStreamWriter_AppendWithInt(this.h, (C.int)(i))
|
|
|
|
}
|
|
|
|
|
|
|
|
func (this *QCborStreamWriter) AppendWithUint(u uint) {
|
|
|
|
C.QCborStreamWriter_AppendWithUint(this.h, (C.uint)(u))
|
|
|
|
}
|
|
|
|
|
2024-08-29 07:01:51 +00:00
|
|
|
func (this *QCborStreamWriter) Append4(str string) {
|
2024-08-25 04:08:24 +00:00
|
|
|
str_Cstring := C.CString(str)
|
|
|
|
defer C.free(unsafe.Pointer(str_Cstring))
|
2024-08-29 07:01:51 +00:00
|
|
|
C.QCborStreamWriter_Append4(this.h, str_Cstring)
|
2024-08-25 04:08:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (this *QCborStreamWriter) StartArray() {
|
|
|
|
C.QCborStreamWriter_StartArray(this.h)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (this *QCborStreamWriter) StartArrayWithCount(count uint64) {
|
2024-08-29 07:01:51 +00:00
|
|
|
C.QCborStreamWriter_StartArrayWithCount(this.h, (C.ulonglong)(count))
|
2024-08-25 04:08:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (this *QCborStreamWriter) EndArray() bool {
|
2024-09-17 07:30:27 +00:00
|
|
|
return (bool)(C.QCborStreamWriter_EndArray(this.h))
|
2024-08-25 04:08:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (this *QCborStreamWriter) StartMap() {
|
|
|
|
C.QCborStreamWriter_StartMap(this.h)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (this *QCborStreamWriter) StartMapWithCount(count uint64) {
|
2024-08-29 07:01:51 +00:00
|
|
|
C.QCborStreamWriter_StartMapWithCount(this.h, (C.ulonglong)(count))
|
2024-08-25 04:08:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (this *QCborStreamWriter) EndMap() bool {
|
2024-09-17 07:30:27 +00:00
|
|
|
return (bool)(C.QCborStreamWriter_EndMap(this.h))
|
2024-08-25 04:08:24 +00:00
|
|
|
}
|
|
|
|
|
2024-10-11 05:43:04 +00:00
|
|
|
func (this *QCborStreamWriter) Append22(str string, size int64) {
|
2024-08-25 04:08:24 +00:00
|
|
|
str_Cstring := C.CString(str)
|
|
|
|
defer C.free(unsafe.Pointer(str_Cstring))
|
2024-10-11 05:43:04 +00:00
|
|
|
C.QCborStreamWriter_Append22(this.h, str_Cstring, (C.ptrdiff_t)(size))
|
2024-08-25 04:08:24 +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 *QCborStreamWriter) Delete() {
|
|
|
|
C.QCborStreamWriter_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 *QCborStreamWriter) GoGC() {
|
|
|
|
runtime.SetFinalizer(this, func(this *QCborStreamWriter) {
|
|
|
|
this.Delete()
|
|
|
|
runtime.KeepAlive(this.h)
|
|
|
|
})
|
|
|
|
}
|