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"
13 "github.com/bnema/puregotk/v4/gobject/types"
14)
15
16type BufferedOutputStreamClass struct {
17 _ structs.HostLayout
18
19 ParentClass FilterOutputStreamClass
20
21 xGReserved1 uintptr
22
23 xGReserved2 uintptr
24}
25
26func (x *BufferedOutputStreamClass) GoPointer() uintptr {
27 return uintptr(unsafe.Pointer(x))
28}
29
30// OverrideGReserved1 sets the "_g_reserved1" callback function.
31func (x *BufferedOutputStreamClass) OverrideGReserved1(cb func()) {
32 if cb == nil {
33 x.xGReserved1 = 0
34 } else {
35 x.xGReserved1 = purego.NewCallback(func() {
36 cb()
37 })
38 }
39}
40
41// GetGReserved1 gets the "_g_reserved1" callback function.
42func (x *BufferedOutputStreamClass) GetGReserved1() func() {
43 if x.xGReserved1 == 0 {
44 return nil
45 }
46 var rawCallback func()
47 purego.RegisterFunc(&rawCallback, x.xGReserved1)
48 return func() {
49 rawCallback()
50 }
51}
52
53// OverrideGReserved2 sets the "_g_reserved2" callback function.
54func (x *BufferedOutputStreamClass) OverrideGReserved2(cb func()) {
55 if cb == nil {
56 x.xGReserved2 = 0
57 } else {
58 x.xGReserved2 = purego.NewCallback(func() {
59 cb()
60 })
61 }
62}
63
64// GetGReserved2 gets the "_g_reserved2" callback function.
65func (x *BufferedOutputStreamClass) GetGReserved2() func() {
66 if x.xGReserved2 == 0 {
67 return nil
68 }
69 var rawCallback func()
70 purego.RegisterFunc(&rawCallback, x.xGReserved2)
71 return func() {
72 rawCallback()
73 }
74}
75
76type BufferedOutputStreamPrivate struct {
77 _ structs.HostLayout
78}
79
80func (x *BufferedOutputStreamPrivate) GoPointer() uintptr {
81 return uintptr(unsafe.Pointer(x))
82}
83
84// Buffered output stream implements [class@Gio.FilterOutputStream] and provides
85// for buffered writes.
86//
87// By default, `GBufferedOutputStream`'s buffer size is set at 4 kilobytes.
88//
89// To create a buffered output stream, use [ctor@Gio.BufferedOutputStream.new],
90// or [ctor@Gio.BufferedOutputStream.new_sized] to specify the buffer's size
91// at construction.
92//
93// To get the size of a buffer within a buffered input stream, use
94// [method@Gio.BufferedOutputStream.get_buffer_size]. To change the size of a
95// buffered output stream's buffer, use [method@Gio.BufferedOutputStream.set_buffer_size].
96// Note that the buffer's size cannot be reduced below the size of the data within the buffer.
97type BufferedOutputStream struct {
98 FilterOutputStream
99}
100
101var xBufferedOutputStreamGLibType func() types.GType
102
103func BufferedOutputStreamGLibType() types.GType {
104 return xBufferedOutputStreamGLibType()
105}
106
107func BufferedOutputStreamNewFromInternalPtr(ptr uintptr) *BufferedOutputStream {
108 cls := &BufferedOutputStream{}
109 cls.Ptr = ptr
110 return cls
111}
112
113var xNewBufferedOutputStream func(uintptr) uintptr
114
115// Creates a new buffered output stream for a base stream.
116func NewBufferedOutputStream(BaseStreamVar *OutputStream) *BufferedOutputStream {
117 var cls *BufferedOutputStream
118
119 cret := xNewBufferedOutputStream(BaseStreamVar.GoPointer())
120
121 if cret == 0 {
122 return nil
123 }
124 cls = &BufferedOutputStream{}
125 cls.Ptr = cret
126 return cls
127}
128
129var xNewBufferedOutputStreamSized func(uintptr, uint) uintptr
130
131// Creates a new buffered output stream with a given buffer size.
132func NewBufferedOutputStreamSized(BaseStreamVar *OutputStream, SizeVar uint) *BufferedOutputStream {
133 var cls *BufferedOutputStream
134
135 cret := xNewBufferedOutputStreamSized(BaseStreamVar.GoPointer(), SizeVar)
136
137 if cret == 0 {
138 return nil
139 }
140 cls = &BufferedOutputStream{}
141 cls.Ptr = cret
142 return cls
143}
144
145var xBufferedOutputStreamGetAutoGrow func(uintptr) bool
146
147// Checks if the buffer automatically grows as data is added.
148func (x *BufferedOutputStream) GetAutoGrow() bool {
149
150 cret := xBufferedOutputStreamGetAutoGrow(x.GoPointer())
151 return cret
152}
153
154var xBufferedOutputStreamGetBufferSize func(uintptr) uint
155
156// Gets the size of the buffer in the @stream.
157func (x *BufferedOutputStream) GetBufferSize() uint {
158
159 cret := xBufferedOutputStreamGetBufferSize(x.GoPointer())
160 return cret
161}
162
163var xBufferedOutputStreamSetAutoGrow func(uintptr, bool)
164
165// Sets whether or not the @stream's buffer should automatically grow.
166// If @auto_grow is true, then each write will just make the buffer
167// larger, and you must manually flush the buffer to actually write out
168// the data to the underlying stream.
169func (x *BufferedOutputStream) SetAutoGrow(AutoGrowVar bool) {
170
171 xBufferedOutputStreamSetAutoGrow(x.GoPointer(), AutoGrowVar)
172
173}
174
175var xBufferedOutputStreamSetBufferSize func(uintptr, uint)
176
177// Sets the size of the internal buffer to @size.
178func (x *BufferedOutputStream) SetBufferSize(SizeVar uint) {
179
180 xBufferedOutputStreamSetBufferSize(x.GoPointer(), SizeVar)
181
182}
183
184func (c *BufferedOutputStream) GoPointer() uintptr {
185 if c == nil {
186 return 0
187 }
188 return c.Ptr
189}
190
191func (c *BufferedOutputStream) SetGoPointer(ptr uintptr) {
192 c.Ptr = ptr
193}
194
195// SetPropertyAutoGrow sets the "auto-grow" property.
196// Whether the buffer should automatically grow.
197func (x *BufferedOutputStream) SetPropertyAutoGrow(value bool) {
198 var v gobject.Value
199 v.Init(gobject.TypeBooleanVal)
200 v.SetBoolean(value)
201 x.SetProperty("auto-grow", &v)
202}
203
204// GetPropertyAutoGrow gets the "auto-grow" property.
205// Whether the buffer should automatically grow.
206func (x *BufferedOutputStream) GetPropertyAutoGrow() bool {
207 var v gobject.Value
208 x.GetProperty("auto-grow", &v)
209 return v.GetBoolean()
210}
211
212// SetPropertyBufferSize sets the "buffer-size" property.
213// The size of the backend buffer, in bytes.
214func (x *BufferedOutputStream) SetPropertyBufferSize(value uint) {
215 var v gobject.Value
216 v.Init(gobject.TypeUintVal)
217 v.SetUint(value)
218 x.SetProperty("buffer-size", &v)
219}
220
221// GetPropertyBufferSize gets the "buffer-size" property.
222// The size of the backend buffer, in bytes.
223func (x *BufferedOutputStream) GetPropertyBufferSize() uint {
224 var v gobject.Value
225 x.GetProperty("buffer-size", &v)
226 return v.GetUint()
227}
228
229// Tests if the stream supports the #GSeekableIface.
230func (x *BufferedOutputStream) CanSeek() bool {
231
232 cret := XGSeekableCanSeek(x.GoPointer())
233 return cret
234}
235
236// Tests if the length of the stream can be adjusted with
237// g_seekable_truncate().
238func (x *BufferedOutputStream) CanTruncate() bool {
239
240 cret := XGSeekableCanTruncate(x.GoPointer())
241 return cret
242}
243
244// Seeks in the stream by the given @offset, modified by @type.
245//
246// Attempting to seek past the end of the stream will have different
247// results depending on if the stream is fixed-sized or resizable. If
248// the stream is resizable then seeking past the end and then writing
249// will result in zeros filling the empty space. Seeking past the end
250// of a resizable stream and reading will result in EOF. Seeking past
251// the end of a fixed-sized stream will fail.
252//
253// Any operation that would result in a negative offset will fail.
254//
255// If @cancellable is not %NULL, then the operation can be cancelled by
256// triggering the cancellable object from another thread. If the operation
257// was cancelled, the error %G_IO_ERROR_CANCELLED will be returned.
258func (x *BufferedOutputStream) Seek(OffsetVar int64, TypeVar glib.SeekType, CancellableVar *Cancellable) (bool, error) {
259 var cerr *glib.Error
260
261 cret := XGSeekableSeek(x.GoPointer(), OffsetVar, TypeVar, CancellableVar.GoPointer(), &cerr)
262 if cerr == nil {
263 return cret, nil
264 }
265 return cret, cerr
266
267}
268
269// Tells the current position within the stream.
270func (x *BufferedOutputStream) Tell() int64 {
271
272 cret := XGSeekableTell(x.GoPointer())
273 return cret
274}
275
276// Sets the length of the stream to @offset. If the stream was previously
277// larger than @offset, the extra data is discarded. If the stream was
278// previously shorter than @offset, it is extended with NUL ('\0') bytes.
279//
280// If @cancellable is not %NULL, then the operation can be cancelled by
281// triggering the cancellable object from another thread. If the operation
282// was cancelled, the error %G_IO_ERROR_CANCELLED will be returned. If an
283// operation was partially finished when the operation was cancelled the
284// partial result will be returned, without an error.
285func (x *BufferedOutputStream) Truncate(OffsetVar int64, CancellableVar *Cancellable) (bool, error) {
286 var cerr *glib.Error
287
288 cret := XGSeekableTruncate(x.GoPointer(), OffsetVar, CancellableVar.GoPointer(), &cerr)
289 if cerr == nil {
290 return cret, nil
291 }
292 return cret, cerr
293
294}
295
296func init() {
297 core.SetPackageName("GIO", "gio-2.0")
298 core.SetSharedLibraries("GIO", []string{"libgio-2.0.so.0"})
299 var libs []uintptr
300 for _, libPath := range core.GetPaths("GIO") {
301 lib, err := purego.Dlopen(libPath, purego.RTLD_NOW|purego.RTLD_GLOBAL)
302 if err != nil {
303 panic(err)
304 }
305 libs = append(libs, lib)
306 }
307
308 core.PuregoSafeRegister(&xBufferedOutputStreamGLibType, libs, "g_buffered_output_stream_get_type")
309
310 core.PuregoSafeRegister(&xNewBufferedOutputStream, libs, "g_buffered_output_stream_new")
311 core.PuregoSafeRegister(&xNewBufferedOutputStreamSized, libs, "g_buffered_output_stream_new_sized")
312
313 core.PuregoSafeRegister(&xBufferedOutputStreamGetAutoGrow, libs, "g_buffered_output_stream_get_auto_grow")
314 core.PuregoSafeRegister(&xBufferedOutputStreamGetBufferSize, libs, "g_buffered_output_stream_get_buffer_size")
315 core.PuregoSafeRegister(&xBufferedOutputStreamSetAutoGrow, libs, "g_buffered_output_stream_set_auto_grow")
316 core.PuregoSafeRegister(&xBufferedOutputStreamSetBufferSize, libs, "g_buffered_output_stream_set_buffer_size")
317
318}