source: appstream-generator/build/girepo/glib/DataList.d @ 4841

Last change on this file since 4841 was 4841, checked in by Juanma, 2 years ago

Initial release

File size: 8.3 KB
Line 
1/*
2 * Licensed under the GNU Lesser General Public License Version 3
3 *
4 * This library is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation, either version 3 of the license, or
7 * (at your option) any later version.
8 *
9 * This software is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 * GNU Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public License
15 * along with this library.  If not, see <http://www.gnu.org/licenses/>.
16 */
17
18// generated automatically - do not change
19
20
21module glib.DataList;
22
23private import gi.glib;
24public  import gi.glibtypes;
25private import glib.Str;
26
27
28/** */
29public struct DataList
30{
31
32        /**
33         * Frees all the data elements of the datalist.
34         * The data elements' destroy functions are called
35         * if they have been set.
36         *
37         * Params:
38         *     datalist = a datalist.
39         */
40        public static void clear(GData** datalist)
41        {
42                g_datalist_clear(datalist);
43        }
44
45        /**
46         * Calls the given function for each data element of the datalist. The
47         * function is called with each data element's #GQuark id and data,
48         * together with the given @user_data parameter. Note that this
49         * function is NOT thread-safe. So unless @datalist can be protected
50         * from any modifications during invocation of this function, it should
51         * not be called.
52         *
53         * Params:
54         *     datalist = a datalist.
55         *     func = the function to call for each data element.
56         *     userData = user data to pass to the function.
57         */
58        public static void foreac(GData** datalist, GDataForeachFunc func, void* userData)
59        {
60                g_datalist_foreach(datalist, func, userData);
61        }
62
63        /**
64         * Gets a data element, using its string identifier. This is slower than
65         * g_datalist_id_get_data() because it compares strings.
66         *
67         * Params:
68         *     datalist = a datalist.
69         *     key = the string identifying a data element.
70         *
71         * Returns: the data element, or %NULL if it is not found.
72         */
73        public static void* getData(GData** datalist, string key)
74        {
75                return g_datalist_get_data(datalist, Str.toStringz(key));
76        }
77
78        /**
79         * Gets flags values packed in together with the datalist.
80         * See g_datalist_set_flags().
81         *
82         * Params:
83         *     datalist = pointer to the location that holds a list
84         *
85         * Returns: the flags of the datalist
86         *
87         * Since: 2.8
88         */
89        public static uint getFlags(GData** datalist)
90        {
91                return g_datalist_get_flags(datalist);
92        }
93
94        /**
95         * This is a variant of g_datalist_id_get_data() which
96         * returns a 'duplicate' of the value. @dup_func defines the
97         * meaning of 'duplicate' in this context, it could e.g.
98         * take a reference on a ref-counted object.
99         *
100         * If the @key_id is not set in the datalist then @dup_func
101         * will be called with a %NULL argument.
102         *
103         * Note that @dup_func is called while the datalist is locked, so it
104         * is not allowed to read or modify the datalist.
105         *
106         * This function can be useful to avoid races when multiple
107         * threads are using the same datalist and the same key.
108         *
109         * Params:
110         *     datalist = location of a datalist
111         *     keyId = the #GQuark identifying a data element
112         *     dupFunc = function to duplicate the old value
113         *     userData = passed as user_data to @dup_func
114         *
115         * Returns: the result of calling @dup_func on the value
116         *     associated with @key_id in @datalist, or %NULL if not set.
117         *     If @dup_func is %NULL, the value is returned unmodified.
118         *
119         * Since: 2.34
120         */
121        public static void* idDupData(GData** datalist, GQuark keyId, GDuplicateFunc dupFunc, void* userData)
122        {
123                return g_datalist_id_dup_data(datalist, keyId, dupFunc, userData);
124        }
125
126        /**
127         * Retrieves the data element corresponding to @key_id.
128         *
129         * Params:
130         *     datalist = a datalist.
131         *     keyId = the #GQuark identifying a data element.
132         *
133         * Returns: the data element, or %NULL if it is not found.
134         */
135        public static void* idGetData(GData** datalist, GQuark keyId)
136        {
137                return g_datalist_id_get_data(datalist, keyId);
138        }
139
140        /**
141         * Removes an element, without calling its destroy notification
142         * function.
143         *
144         * Params:
145         *     datalist = a datalist.
146         *     keyId = the #GQuark identifying a data element.
147         *
148         * Returns: the data previously stored at @key_id, or %NULL if none.
149         */
150        public static void* idRemoveNoNotify(GData** datalist, GQuark keyId)
151        {
152                return g_datalist_id_remove_no_notify(datalist, keyId);
153        }
154
155        /**
156         * Compares the member that is associated with @key_id in
157         * @datalist to @oldval, and if they are the same, replace
158         * @oldval with @newval.
159         *
160         * This is like a typical atomic compare-and-exchange
161         * operation, for a member of @datalist.
162         *
163         * If the previous value was replaced then ownership of the
164         * old value (@oldval) is passed to the caller, including
165         * the registred destroy notify for it (passed out in @old_destroy).
166         * Its up to the caller to free this as he wishes, which may
167         * or may not include using @old_destroy as sometimes replacement
168         * should not destroy the object in the normal way.
169         *
170         * Params:
171         *     datalist = location of a datalist
172         *     keyId = the #GQuark identifying a data element
173         *     oldval = the old value to compare against
174         *     newval = the new value to replace it with
175         *     destroy = destroy notify for the new value
176         *     oldDestroy = destroy notify for the existing value
177         *
178         * Returns: %TRUE if the existing value for @key_id was replaced
179         *     by @newval, %FALSE otherwise.
180         *
181         * Since: 2.34
182         */
183        public static bool idReplaceData(GData** datalist, GQuark keyId, void* oldval, void* newval, GDestroyNotify destroy, GDestroyNotify* oldDestroy)
184        {
185                return g_datalist_id_replace_data(datalist, keyId, oldval, newval, destroy, oldDestroy) != 0;
186        }
187
188        /**
189         * Sets the data corresponding to the given #GQuark id, and the
190         * function to be called when the element is removed from the datalist.
191         * Any previous data with the same key is removed, and its destroy
192         * function is called.
193         *
194         * Params:
195         *     datalist = a datalist.
196         *     keyId = the #GQuark to identify the data element.
197         *     data = the data element or %NULL to remove any previous element
198         *         corresponding to @key_id.
199         *     destroyFunc = the function to call when the data element is
200         *         removed. This function will be called with the data
201         *         element and can be used to free any memory allocated
202         *         for it. If @data is %NULL, then @destroy_func must
203         *         also be %NULL.
204         */
205        public static void idSetDataFull(GData** datalist, GQuark keyId, void* data, GDestroyNotify destroyFunc)
206        {
207                g_datalist_id_set_data_full(datalist, keyId, data, destroyFunc);
208        }
209
210        /**
211         * Resets the datalist to %NULL. It does not free any memory or call
212         * any destroy functions.
213         *
214         * Params:
215         *     datalist = a pointer to a pointer to a datalist.
216         */
217        public static void init(GData** datalist)
218        {
219                g_datalist_init(datalist);
220        }
221
222        /**
223         * Turns on flag values for a data list. This function is used
224         * to keep a small number of boolean flags in an object with
225         * a data list without using any additional space. It is
226         * not generally useful except in circumstances where space
227         * is very tight. (It is used in the base #GObject type, for
228         * example.)
229         *
230         * Params:
231         *     datalist = pointer to the location that holds a list
232         *     flags = the flags to turn on. The values of the flags are
233         *         restricted by %G_DATALIST_FLAGS_MASK (currently
234         *         3; giving two possible boolean flags).
235         *         A value for @flags that doesn't fit within the mask is
236         *         an error.
237         *
238         * Since: 2.8
239         */
240        public static void setFlags(GData** datalist, uint flags)
241        {
242                g_datalist_set_flags(datalist, flags);
243        }
244
245        /**
246         * Turns off flag values for a data list. See g_datalist_unset_flags()
247         *
248         * Params:
249         *     datalist = pointer to the location that holds a list
250         *     flags = the flags to turn off. The values of the flags are
251         *         restricted by %G_DATALIST_FLAGS_MASK (currently
252         *         3: giving two possible boolean flags).
253         *         A value for @flags that doesn't fit within the mask is
254         *         an error.
255         *
256         * Since: 2.8
257         */
258        public static void unsetFlags(GData** datalist, uint flags)
259        {
260                g_datalist_unset_flags(datalist, flags);
261        }
262}
Note: See TracBrowser for help on using the repository browser.