1// Package glib was automatically generated by github.com/bnema/puregotk DO NOT EDIT
2package glib
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/gobject/types"
12)
13
14// `GStrvBuilder` is a helper object to build a %NULL-terminated string arrays.
15//
16// The following example shows how to build a two element array:
17//
18// ```c
19//
20// g_autoptr(GStrvBuilder) builder = g_strv_builder_new ();
21// g_strv_builder_add (builder, "hello");
22// g_strv_builder_add (builder, "world");
23//
24// g_auto(GStrv) array = g_strv_builder_end (builder);
25//
26// g_assert_true (g_strv_equal (array, (const char *[]) { "hello", "world", NULL }));
27//
28// ```
29type StrvBuilder struct {
30 _ structs.HostLayout
31}
32
33var xStrvBuilderGLibType func() types.GType
34
35func StrvBuilderGLibType() types.GType {
36 return xStrvBuilderGLibType()
37}
38
39func (x *StrvBuilder) GoPointer() uintptr {
40 return uintptr(unsafe.Pointer(x))
41}
42
43var xNewStrvBuilder func() *StrvBuilder
44
45// Creates a new #GStrvBuilder with a reference count of 1.
46// Use g_strv_builder_unref() on the returned value when no longer needed.
47func NewStrvBuilder() *StrvBuilder {
48
49 cret := xNewStrvBuilder()
50 return cret
51}
52
53var xStrvBuilderAdd func(uintptr, string)
54
55// Add a string to the end of the array.
56//
57// Since 2.68
58func (x *StrvBuilder) Add(ValueVar string) {
59
60 xStrvBuilderAdd(x.GoPointer(), ValueVar)
61
62}
63
64var xStrvBuilderAddMany func(uintptr, ...interface{})
65
66// Appends all the given strings to the builder.
67//
68// Since 2.70
69func (x *StrvBuilder) AddMany(varArgs ...interface{}) {
70
71 xStrvBuilderAddMany(x.GoPointer(), varArgs...)
72
73}
74
75var xStrvBuilderAddv func(uintptr, []string)
76
77// Appends all the strings in the given vector to the builder.
78//
79// Since 2.70
80func (x *StrvBuilder) Addv(ValueVar []string) {
81
82 xStrvBuilderAddv(x.GoPointer(), ValueVar)
83
84}
85
86var xStrvBuilderEnd func(uintptr) []string
87
88// Ends the builder process and returns the constructed NULL-terminated string
89// array. The returned value should be freed with g_strfreev() when no longer
90// needed.
91func (x *StrvBuilder) End() []string {
92
93 cret := xStrvBuilderEnd(x.GoPointer())
94 return cret
95}
96
97var xStrvBuilderRef func(uintptr) *StrvBuilder
98
99// Atomically increments the reference count of @builder by one.
100// This function is thread-safe and may be called from any thread.
101func (x *StrvBuilder) Ref() *StrvBuilder {
102
103 cret := xStrvBuilderRef(x.GoPointer())
104 return cret
105}
106
107var xStrvBuilderTake func(uintptr, uintptr)
108
109// Add a string to the end of the array. After @value belongs to the
110// #GStrvBuilder and may no longer be modified by the caller.
111//
112// Since 2.80
113func (x *StrvBuilder) Take(ValueVar string) {
114
115 xStrvBuilderTake(x.GoPointer(), core.GStrdup(ValueVar))
116
117}
118
119var xStrvBuilderUnref func(uintptr)
120
121// Decreases the reference count on @builder.
122//
123// In the event that there are no more references, releases all memory
124// associated with the #GStrvBuilder.
125func (x *StrvBuilder) Unref() {
126
127 xStrvBuilderUnref(x.GoPointer())
128
129}
130
131var xStrvBuilderUnrefToStrv func(uintptr) []string
132
133// Decreases the reference count on the string vector builder, and returns
134// its contents as a `NULL`-terminated string array.
135//
136// This function is especially useful for cases where it's not possible
137// to use `g_autoptr()`.
138//
139// ```c
140// GStrvBuilder *builder = g_strv_builder_new ();
141// g_strv_builder_add (builder, "hello");
142// g_strv_builder_add (builder, "world");
143//
144// GStrv array = g_strv_builder_unref_to_strv (builder);
145//
146// g_assert_true (g_strv_equal (array, (const char *[]) { "hello", "world", NULL }));
147//
148// g_strfreev (array);
149// ```
150func (x *StrvBuilder) UnrefToStrv() []string {
151
152 cret := xStrvBuilderUnrefToStrv(x.GoPointer())
153 return cret
154}
155
156func init() {
157 core.SetPackageName("GLIB", "glib-2.0")
158 core.SetSharedLibraries("GLIB", []string{"libgobject-2.0.so.0", "libglib-2.0.so.0"})
159 var libs []uintptr
160 for _, libPath := range core.GetPaths("GLIB") {
161 lib, err := purego.Dlopen(libPath, purego.RTLD_NOW|purego.RTLD_GLOBAL)
162 if err != nil {
163 panic(err)
164 }
165 libs = append(libs, lib)
166 }
167
168 core.PuregoSafeRegister(&xStrvBuilderGLibType, libs, "g_strv_builder_get_type")
169
170 core.PuregoSafeRegister(&xNewStrvBuilder, libs, "g_strv_builder_new")
171
172 core.PuregoSafeRegister(&xStrvBuilderAdd, libs, "g_strv_builder_add")
173 core.PuregoSafeRegister(&xStrvBuilderAddMany, libs, "g_strv_builder_add_many")
174 core.PuregoSafeRegister(&xStrvBuilderAddv, libs, "g_strv_builder_addv")
175 core.PuregoSafeRegister(&xStrvBuilderEnd, libs, "g_strv_builder_end")
176 core.PuregoSafeRegister(&xStrvBuilderRef, libs, "g_strv_builder_ref")
177 core.PuregoSafeRegister(&xStrvBuilderTake, libs, "g_strv_builder_take")
178 core.PuregoSafeRegister(&xStrvBuilderUnref, libs, "g_strv_builder_unref")
179 core.PuregoSafeRegister(&xStrvBuilderUnrefToStrv, libs, "g_strv_builder_unref_to_strv")
180
181}