alternative to assert
[gtkD.git] / src / glib / DataList.d
blob7b516ed2afadf3fbd7fdcbfb0694d7ffa4e199a5
1 /*
2 * This file is part of duit.
4 * duit 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 2.1 of the License, or
7 * (at your option) any later version.
9 * duit 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.
14 * You should have received a copy of the GNU Lesser General Public License
15 * along with duit; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 // generated automatically - do not change
20 // find conversion definition on APILookup.txt
21 // implement new conversion functionalities on the wrap.utils pakage
24 * Conversion parameters:
25 * inFile = glib-Keyed-Data-Lists.html
26 * outPack = glib
27 * outFile = DataList
28 * strct = GData
29 * realStrct=
30 * ctorStrct=
31 * clss = DataList
32 * interf =
33 * class Code: No
34 * interface Code: No
35 * template for:
36 * extend =
37 * implements:
38 * prefixes:
39 * - g_datalist_
40 * omit structs:
41 * omit prefixes:
42 * omit code:
43 * imports:
44 * - glib.Quark
45 * - glib.Dataset
46 * structWrap:
47 * - GDataset* -> Dataset
48 * local aliases:
51 module glib.DataList;
53 private import glib.glibtypes;
55 private import lib.glib;
57 private import glib.Quark;
58 private import glib.Dataset;
60 /**
61 * Description
62 * Keyed data lists provide lists of arbitrary data elements which can be accessed
63 * either with a string or with a GQuark corresponding to the
64 * string.
65 * The GQuark methods are quicker, since the strings have to be converted to
66 * GQuarks anyway.
67 * Data lists are used for associating arbitrary data with
68 * GObjects, using g_object_set_data() and related functions.
69 * To create a datalist, use g_datalist_init().
70 * To add data elements to a datalist use g_datalist_id_set_data(),
71 * g_datalist_id_set_data_full(), g_datalist_set_data()
72 * and g_datalist_set_data_full().
73 * To get data elements from a datalist use g_datalist_id_get_data() and
74 * g_datalist_get_data().
75 * To iterate over all data elements in a datalist use g_datalist_foreach() (not thread-safe).
76 * To remove data elements from a datalist use g_datalist_id_remove_data() and
77 * g_datalist_remove_data().
78 * To remove all data elements from a datalist, use g_datalist_clear().
80 public class DataList
83 /** the main Gtk struct */
84 protected GData* gData;
87 public GData* getDataListStruct()
89 return gData;
93 /** the main Gtk struct as a void* */
94 protected void* getStruct()
96 return cast(void*)gData;
99 /**
100 * Sets our main struct and passes it to the parent class
102 public this (GData* gData)
104 this.gData = gData;
112 * Resets the datalist to NULL.
113 * It does not free any memory or call any destroy functions.
114 * datalist:
115 * a pointer to a pointer to a datalist.
117 public static void init(GData** datalist)
119 // void g_datalist_init (GData **datalist);
120 g_datalist_init(datalist);
125 * Sets the data corresponding to the given GQuark id, and the function to
126 * be called when the element is removed from the datalist.
127 * Any previous data with the same key is removed, and its
128 * destroy function is called.
129 * datalist:
130 * a datalist.
131 * key_id:
132 * the GQuark to identify the data element.
133 * data:
134 * the data element or NULL to remove any previous element
135 * corresponding to key_id.
136 * destroy_func:
137 * the function to call when the data element is removed. This
138 * function will be called with the data element and can be used to free any
139 * memory allocated for it. If data is NULL, then destroy_func must
140 * also be NULL.
142 public static void idSetDataFull(GData** datalist, GQuark keyId, void* data, GDestroyNotify destroyFunc)
144 // void g_datalist_id_set_data_full (GData **datalist, GQuark key_id, gpointer data, GDestroyNotify destroy_func);
145 g_datalist_id_set_data_full(datalist, keyId, data, destroyFunc);
149 * Retrieves the data element corresponding to key_id.
150 * datalist:
151 * a datalist.
152 * key_id:
153 * the GQuark identifying a data element.
154 * Returns:
155 * the data element, or NULL if it is not found.
157 public static void* idGetData(GData** datalist, GQuark keyId)
159 // gpointer g_datalist_id_get_data (GData **datalist, GQuark key_id);
160 return g_datalist_id_get_data(datalist, keyId);
165 * Removes an element, without calling its destroy notification function.
166 * datalist:
167 * a datalist.
168 * key_id:
169 * the GQuark identifying a data element.
170 * Returns:
171 * the data previously stored at key_id, or NULL if none.
173 public static void* idRemoveNoNotify(GData** datalist, GQuark keyId)
175 // gpointer g_datalist_id_remove_no_notify (GData **datalist, GQuark key_id);
176 return g_datalist_id_remove_no_notify(datalist, keyId);
185 * Calls the given function for each data element of the datalist.
186 * The function is called with each data element's GQuark id and data,
187 * together with the given user_data parameter.
188 * Note that this function is NOT thread-safe. So unless datalist
189 * can be protected from any modifications during invocation of this
190 * function, it should not be called.
191 * datalist:
192 * a datalist.
193 * func:
194 * the function to call for each data element.
195 * user_data:
196 * user data to pass to the function.
198 public static void foreac(GData** datalist, GDataForeachFunc func, void* userData)
200 // void g_datalist_foreach (GData **datalist, GDataForeachFunc func, gpointer user_data);
201 g_datalist_foreach(datalist, func, userData);
205 * Frees all the data elements of the datalist.
206 * The data elements' destroy functions are called if they have been set.
207 * datalist:
208 * a datalist.
210 public static void clear(GData** datalist)
212 // void g_datalist_clear (GData **datalist);
213 g_datalist_clear(datalist);
217 * Turns on flag values for a data list. This function is used
218 * to keep a small number of boolean flags in an object with
219 * a data list without using any additional space. It is
220 * not generally useful except in circumstances where space
221 * is very tight. (It is used in the base GObject type, for
222 * example.)
223 * datalist:
224 * pointer to the location that holds a list
225 * flags:
226 * the flags to turn on. The values of the flags are
227 * restricted by G_DATALIST_FLAGS_MASK (currently
228 * 3; giving two possible boolean flags).
229 * A value for flags that doesn't fit within the mask is
230 * an error.
231 * Since 2.8
233 public static void setFlags(GData** datalist, uint flags)
235 // void g_datalist_set_flags (GData **datalist, guint flags);
236 g_datalist_set_flags(datalist, flags);
240 * Turns off flag values for a data list. See g_datalist_unset_flags()
241 * datalist:
242 * pointer to the location that holds a list
243 * flags:
244 * the flags to turn off. The values of the flags are
245 * restricted by G_DATALIST_FLAGS_MASK (currently
246 * 3: giving two possible boolean flags).
247 * A value for flags that doesn't fit within the mask is
248 * an error.
249 * Since 2.8
251 public static void unsetFlags(GData** datalist, uint flags)
253 // void g_datalist_unset_flags (GData **datalist, guint flags);
254 g_datalist_unset_flags(datalist, flags);
258 * Gets flags values packed in together with the datalist.
259 * See g_datalist_set_flags().
260 * datalist:
261 * pointer to the location that holds a list
262 * Returns:
263 * the flags of the datalist
264 * Since 2.8
266 public static uint getFlags(GData** datalist)
268 // guint g_datalist_get_flags (GData **datalist);
269 return g_datalist_get_flags(datalist);