1// Package gio was automatically generated by github.com/bnema/puregotk DO NOT EDIT
2package gio
3
4import (
5 "structs"
6 "unsafe"
7
8 "github.com/ebitengine/purego"
9
10 "github.com/bnema/puregotk/pkg/core"
11 "github.com/bnema/puregotk/v4/glib"
12 "github.com/bnema/puregotk/v4/gobject/types"
13)
14
15type DataOutputStreamClass struct {
16 _ structs.HostLayout
17
18 ParentClass FilterOutputStreamClass
19
20 xGReserved1 uintptr
21
22 xGReserved2 uintptr
23
24 xGReserved3 uintptr
25
26 xGReserved4 uintptr
27
28 xGReserved5 uintptr
29}
30
31func (x *DataOutputStreamClass) GoPointer() uintptr {
32 return uintptr(unsafe.Pointer(x))
33}
34
35// OverrideGReserved1 sets the "_g_reserved1" callback function.
36func (x *DataOutputStreamClass) OverrideGReserved1(cb func()) {
37 if cb == nil {
38 x.xGReserved1 = 0
39 } else {
40 x.xGReserved1 = purego.NewCallback(func() {
41 cb()
42 })
43 }
44}
45
46// GetGReserved1 gets the "_g_reserved1" callback function.
47func (x *DataOutputStreamClass) GetGReserved1() func() {
48 if x.xGReserved1 == 0 {
49 return nil
50 }
51 var rawCallback func()
52 purego.RegisterFunc(&rawCallback, x.xGReserved1)
53 return func() {
54 rawCallback()
55 }
56}
57
58// OverrideGReserved2 sets the "_g_reserved2" callback function.
59func (x *DataOutputStreamClass) OverrideGReserved2(cb func()) {
60 if cb == nil {
61 x.xGReserved2 = 0
62 } else {
63 x.xGReserved2 = purego.NewCallback(func() {
64 cb()
65 })
66 }
67}
68
69// GetGReserved2 gets the "_g_reserved2" callback function.
70func (x *DataOutputStreamClass) GetGReserved2() func() {
71 if x.xGReserved2 == 0 {
72 return nil
73 }
74 var rawCallback func()
75 purego.RegisterFunc(&rawCallback, x.xGReserved2)
76 return func() {
77 rawCallback()
78 }
79}
80
81// OverrideGReserved3 sets the "_g_reserved3" callback function.
82func (x *DataOutputStreamClass) OverrideGReserved3(cb func()) {
83 if cb == nil {
84 x.xGReserved3 = 0
85 } else {
86 x.xGReserved3 = purego.NewCallback(func() {
87 cb()
88 })
89 }
90}
91
92// GetGReserved3 gets the "_g_reserved3" callback function.
93func (x *DataOutputStreamClass) GetGReserved3() func() {
94 if x.xGReserved3 == 0 {
95 return nil
96 }
97 var rawCallback func()
98 purego.RegisterFunc(&rawCallback, x.xGReserved3)
99 return func() {
100 rawCallback()
101 }
102}
103
104// OverrideGReserved4 sets the "_g_reserved4" callback function.
105func (x *DataOutputStreamClass) OverrideGReserved4(cb func()) {
106 if cb == nil {
107 x.xGReserved4 = 0
108 } else {
109 x.xGReserved4 = purego.NewCallback(func() {
110 cb()
111 })
112 }
113}
114
115// GetGReserved4 gets the "_g_reserved4" callback function.
116func (x *DataOutputStreamClass) GetGReserved4() func() {
117 if x.xGReserved4 == 0 {
118 return nil
119 }
120 var rawCallback func()
121 purego.RegisterFunc(&rawCallback, x.xGReserved4)
122 return func() {
123 rawCallback()
124 }
125}
126
127// OverrideGReserved5 sets the "_g_reserved5" callback function.
128func (x *DataOutputStreamClass) OverrideGReserved5(cb func()) {
129 if cb == nil {
130 x.xGReserved5 = 0
131 } else {
132 x.xGReserved5 = purego.NewCallback(func() {
133 cb()
134 })
135 }
136}
137
138// GetGReserved5 gets the "_g_reserved5" callback function.
139func (x *DataOutputStreamClass) GetGReserved5() func() {
140 if x.xGReserved5 == 0 {
141 return nil
142 }
143 var rawCallback func()
144 purego.RegisterFunc(&rawCallback, x.xGReserved5)
145 return func() {
146 rawCallback()
147 }
148}
149
150type DataOutputStreamPrivate struct {
151 _ structs.HostLayout
152}
153
154func (x *DataOutputStreamPrivate) GoPointer() uintptr {
155 return uintptr(unsafe.Pointer(x))
156}
157
158// Data output stream implements [class@Gio.OutputStream] and includes functions
159// for writing data directly to an output stream.
160type DataOutputStream struct {
161 FilterOutputStream
162}
163
164var xDataOutputStreamGLibType func() types.GType
165
166func DataOutputStreamGLibType() types.GType {
167 return xDataOutputStreamGLibType()
168}
169
170func DataOutputStreamNewFromInternalPtr(ptr uintptr) *DataOutputStream {
171 cls := &DataOutputStream{}
172 cls.Ptr = ptr
173 return cls
174}
175
176var xNewDataOutputStream func(uintptr) uintptr
177
178// Creates a new data output stream for @base_stream.
179func NewDataOutputStream(BaseStreamVar *OutputStream) *DataOutputStream {
180 var cls *DataOutputStream
181
182 cret := xNewDataOutputStream(BaseStreamVar.GoPointer())
183
184 if cret == 0 {
185 return nil
186 }
187 cls = &DataOutputStream{}
188 cls.Ptr = cret
189 return cls
190}
191
192var xDataOutputStreamGetByteOrder func(uintptr) DataStreamByteOrder
193
194// Gets the byte order for the stream.
195func (x *DataOutputStream) GetByteOrder() DataStreamByteOrder {
196
197 cret := xDataOutputStreamGetByteOrder(x.GoPointer())
198 return cret
199}
200
201var xDataOutputStreamPutByte func(uintptr, byte, uintptr, **glib.Error) bool
202
203// Puts a byte into the output stream.
204func (x *DataOutputStream) PutByte(DataVar byte, CancellableVar *Cancellable) (bool, error) {
205 var cerr *glib.Error
206
207 cret := xDataOutputStreamPutByte(x.GoPointer(), DataVar, CancellableVar.GoPointer(), &cerr)
208 if cerr == nil {
209 return cret, nil
210 }
211 return cret, cerr
212
213}
214
215var xDataOutputStreamPutInt16 func(uintptr, int16, uintptr, **glib.Error) bool
216
217// Puts a signed 16-bit integer into the output stream.
218func (x *DataOutputStream) PutInt16(DataVar int16, CancellableVar *Cancellable) (bool, error) {
219 var cerr *glib.Error
220
221 cret := xDataOutputStreamPutInt16(x.GoPointer(), DataVar, CancellableVar.GoPointer(), &cerr)
222 if cerr == nil {
223 return cret, nil
224 }
225 return cret, cerr
226
227}
228
229var xDataOutputStreamPutInt32 func(uintptr, int32, uintptr, **glib.Error) bool
230
231// Puts a signed 32-bit integer into the output stream.
232func (x *DataOutputStream) PutInt32(DataVar int32, CancellableVar *Cancellable) (bool, error) {
233 var cerr *glib.Error
234
235 cret := xDataOutputStreamPutInt32(x.GoPointer(), DataVar, CancellableVar.GoPointer(), &cerr)
236 if cerr == nil {
237 return cret, nil
238 }
239 return cret, cerr
240
241}
242
243var xDataOutputStreamPutInt64 func(uintptr, int64, uintptr, **glib.Error) bool
244
245// Puts a signed 64-bit integer into the stream.
246func (x *DataOutputStream) PutInt64(DataVar int64, CancellableVar *Cancellable) (bool, error) {
247 var cerr *glib.Error
248
249 cret := xDataOutputStreamPutInt64(x.GoPointer(), DataVar, CancellableVar.GoPointer(), &cerr)
250 if cerr == nil {
251 return cret, nil
252 }
253 return cret, cerr
254
255}
256
257var xDataOutputStreamPutString func(uintptr, string, uintptr, **glib.Error) bool
258
259// Puts a string into the output stream.
260func (x *DataOutputStream) PutString(StrVar string, CancellableVar *Cancellable) (bool, error) {
261 var cerr *glib.Error
262
263 cret := xDataOutputStreamPutString(x.GoPointer(), StrVar, CancellableVar.GoPointer(), &cerr)
264 if cerr == nil {
265 return cret, nil
266 }
267 return cret, cerr
268
269}
270
271var xDataOutputStreamPutUint16 func(uintptr, uint16, uintptr, **glib.Error) bool
272
273// Puts an unsigned 16-bit integer into the output stream.
274func (x *DataOutputStream) PutUint16(DataVar uint16, CancellableVar *Cancellable) (bool, error) {
275 var cerr *glib.Error
276
277 cret := xDataOutputStreamPutUint16(x.GoPointer(), DataVar, CancellableVar.GoPointer(), &cerr)
278 if cerr == nil {
279 return cret, nil
280 }
281 return cret, cerr
282
283}
284
285var xDataOutputStreamPutUint32 func(uintptr, uint32, uintptr, **glib.Error) bool
286
287// Puts an unsigned 32-bit integer into the stream.
288func (x *DataOutputStream) PutUint32(DataVar uint32, CancellableVar *Cancellable) (bool, error) {
289 var cerr *glib.Error
290
291 cret := xDataOutputStreamPutUint32(x.GoPointer(), DataVar, CancellableVar.GoPointer(), &cerr)
292 if cerr == nil {
293 return cret, nil
294 }
295 return cret, cerr
296
297}
298
299var xDataOutputStreamPutUint64 func(uintptr, uint64, uintptr, **glib.Error) bool
300
301// Puts an unsigned 64-bit integer into the stream.
302func (x *DataOutputStream) PutUint64(DataVar uint64, CancellableVar *Cancellable) (bool, error) {
303 var cerr *glib.Error
304
305 cret := xDataOutputStreamPutUint64(x.GoPointer(), DataVar, CancellableVar.GoPointer(), &cerr)
306 if cerr == nil {
307 return cret, nil
308 }
309 return cret, cerr
310
311}
312
313var xDataOutputStreamSetByteOrder func(uintptr, DataStreamByteOrder)
314
315// Sets the byte order of the data output stream to @order.
316func (x *DataOutputStream) SetByteOrder(OrderVar DataStreamByteOrder) {
317
318 xDataOutputStreamSetByteOrder(x.GoPointer(), OrderVar)
319
320}
321
322func (c *DataOutputStream) GoPointer() uintptr {
323 if c == nil {
324 return 0
325 }
326 return c.Ptr
327}
328
329func (c *DataOutputStream) SetGoPointer(ptr uintptr) {
330 c.Ptr = ptr
331}
332
333// Tests if the stream supports the #GSeekableIface.
334func (x *DataOutputStream) CanSeek() bool {
335
336 cret := XGSeekableCanSeek(x.GoPointer())
337 return cret
338}
339
340// Tests if the length of the stream can be adjusted with
341// g_seekable_truncate().
342func (x *DataOutputStream) CanTruncate() bool {
343
344 cret := XGSeekableCanTruncate(x.GoPointer())
345 return cret
346}
347
348// Seeks in the stream by the given @offset, modified by @type.
349//
350// Attempting to seek past the end of the stream will have different
351// results depending on if the stream is fixed-sized or resizable. If
352// the stream is resizable then seeking past the end and then writing
353// will result in zeros filling the empty space. Seeking past the end
354// of a resizable stream and reading will result in EOF. Seeking past
355// the end of a fixed-sized stream will fail.
356//
357// Any operation that would result in a negative offset will fail.
358//
359// If @cancellable is not %NULL, then the operation can be cancelled by
360// triggering the cancellable object from another thread. If the operation
361// was cancelled, the error %G_IO_ERROR_CANCELLED will be returned.
362func (x *DataOutputStream) Seek(OffsetVar int64, TypeVar glib.SeekType, CancellableVar *Cancellable) (bool, error) {
363 var cerr *glib.Error
364
365 cret := XGSeekableSeek(x.GoPointer(), OffsetVar, TypeVar, CancellableVar.GoPointer(), &cerr)
366 if cerr == nil {
367 return cret, nil
368 }
369 return cret, cerr
370
371}
372
373// Tells the current position within the stream.
374func (x *DataOutputStream) Tell() int64 {
375
376 cret := XGSeekableTell(x.GoPointer())
377 return cret
378}
379
380// Sets the length of the stream to @offset. If the stream was previously
381// larger than @offset, the extra data is discarded. If the stream was
382// previously shorter than @offset, it is extended with NUL ('\0') bytes.
383//
384// If @cancellable is not %NULL, then the operation can be cancelled by
385// triggering the cancellable object from another thread. If the operation
386// was cancelled, the error %G_IO_ERROR_CANCELLED will be returned. If an
387// operation was partially finished when the operation was cancelled the
388// partial result will be returned, without an error.
389func (x *DataOutputStream) Truncate(OffsetVar int64, CancellableVar *Cancellable) (bool, error) {
390 var cerr *glib.Error
391
392 cret := XGSeekableTruncate(x.GoPointer(), OffsetVar, CancellableVar.GoPointer(), &cerr)
393 if cerr == nil {
394 return cret, nil
395 }
396 return cret, cerr
397
398}
399
400func init() {
401 core.SetPackageName("GIO", "gio-2.0")
402 core.SetSharedLibraries("GIO", []string{"libgio-2.0.so.0"})
403 var libs []uintptr
404 for _, libPath := range core.GetPaths("GIO") {
405 lib, err := purego.Dlopen(libPath, purego.RTLD_NOW|purego.RTLD_GLOBAL)
406 if err != nil {
407 panic(err)
408 }
409 libs = append(libs, lib)
410 }
411
412 core.PuregoSafeRegister(&xDataOutputStreamGLibType, libs, "g_data_output_stream_get_type")
413
414 core.PuregoSafeRegister(&xNewDataOutputStream, libs, "g_data_output_stream_new")
415
416 core.PuregoSafeRegister(&xDataOutputStreamGetByteOrder, libs, "g_data_output_stream_get_byte_order")
417 core.PuregoSafeRegister(&xDataOutputStreamPutByte, libs, "g_data_output_stream_put_byte")
418 core.PuregoSafeRegister(&xDataOutputStreamPutInt16, libs, "g_data_output_stream_put_int16")
419 core.PuregoSafeRegister(&xDataOutputStreamPutInt32, libs, "g_data_output_stream_put_int32")
420 core.PuregoSafeRegister(&xDataOutputStreamPutInt64, libs, "g_data_output_stream_put_int64")
421 core.PuregoSafeRegister(&xDataOutputStreamPutString, libs, "g_data_output_stream_put_string")
422 core.PuregoSafeRegister(&xDataOutputStreamPutUint16, libs, "g_data_output_stream_put_uint16")
423 core.PuregoSafeRegister(&xDataOutputStreamPutUint32, libs, "g_data_output_stream_put_uint32")
424 core.PuregoSafeRegister(&xDataOutputStreamPutUint64, libs, "g_data_output_stream_put_uint64")
425 core.PuregoSafeRegister(&xDataOutputStreamSetByteOrder, libs, "g_data_output_stream_set_byte_order")
426
427}