1 /*
2  * This file is part of gtkD.
3  *
4  * gtkD is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU Lesser General Public License
6  * as published by the Free Software Foundation; either version 3
7  * of the License, or (at your option) any later version, with
8  * some exceptions, please read the COPYING file.
9  *
10  * gtkD is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public License
16  * along with gtkD; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA
18  */
19  
20 // generated automatically - do not change
21 // find conversion definition on APILookup.txt
22 // implement new conversion functionalities on the wrap.utils pakage
23 
24 /*
25  * Conversion parameters:
26  * inFile  = glib-Keyed-Data-Lists.html
27  * outPack = glib
28  * outFile = DataList
29  * strct   = GData
30  * realStrct=
31  * ctorStrct=
32  * clss    = DataList
33  * interf  = 
34  * class Code: No
35  * interface Code: No
36  * template for:
37  * extend  = 
38  * implements:
39  * prefixes:
40  * 	- g_datalist_
41  * omit structs:
42  * omit prefixes:
43  * omit code:
44  * omit signals:
45  * imports:
46  * structWrap:
47  * module aliases:
48  * local aliases:
49  * overrides:
50  */
51 
52 module glib.DataList;
53 
54 public  import gtkc.glibtypes;
55 
56 private import gtkc.glib;
57 private import glib.ConstructionException;
58 
59 
60 
61 
62 
63 
64 /**
65  * Description
66  * Keyed data lists provide lists of arbitrary data elements which can
67  * be accessed either with a string or with a GQuark corresponding to
68  * the string.
69  * The GQuark methods are quicker, since the strings have to be
70  * converted to GQuarks anyway.
71  * Data lists are used for associating arbitrary data with GObjects,
72  * using g_object_set_data() and related functions.
73  * To create a datalist, use g_datalist_init().
74  * To add data elements to a datalist use g_datalist_id_set_data(),
75  * g_datalist_id_set_data_full(), g_datalist_set_data() and
76  * g_datalist_set_data_full().
77  * To get data elements from a datalist use g_datalist_id_get_data()
78  * and g_datalist_get_data().
79  * To iterate over all data elements in a datalist use
80  * g_datalist_foreach() (not thread-safe).
81  * To remove data elements from a datalist use
82  * g_datalist_id_remove_data() and g_datalist_remove_data().
83  * To remove all data elements from a datalist, use g_datalist_clear().
84  */
85 public class DataList
86 {
87 	
88 	/** the main Gtk struct */
89 	protected GData* gData;
90 	
91 	
92 	public GData* getDataListStruct()
93 	{
94 		return gData;
95 	}
96 	
97 	
98 	/** the main Gtk struct as a void* */
99 	protected void* getStruct()
100 	{
101 		return cast(void*)gData;
102 	}
103 	
104 	/**
105 	 * Sets our main struct and passes it to the parent class
106 	 */
107 	public this (GData* gData)
108 	{
109 		this.gData = gData;
110 	}
111 	
112 	/**
113 	 */
114 	
115 	/**
116 	 * Resets the datalist to NULL. It does not free any memory or call
117 	 * any destroy functions.
118 	 * Params:
119 	 * datalist = a pointer to a pointer to a datalist.
120 	 */
121 	public static void init(GData** datalist)
122 	{
123 		// void g_datalist_init (GData **datalist);
124 		g_datalist_init(datalist);
125 	}
126 	
127 	/**
128 	 * Sets the data corresponding to the given GQuark id, and the
129 	 * function to be called when the element is removed from the datalist.
130 	 * Any previous data with the same key is removed, and its destroy
131 	 * function is called.
132 	 * Params:
133 	 * datalist = a datalist.
134 	 * keyId = the GQuark to identify the data element.
135 	 * data = the data element or NULL to remove any previous element
136 	 * corresponding to key_id.
137 	 * destroyFunc = the function to call when the data element is
138 	 * removed. This function will be called with the data
139 	 * element and can be used to free any memory allocated
140 	 * for it. If data is NULL, then destroy_func must
141 	 * also be NULL.
142 	 */
143 	public static void idSetDataFull(GData** datalist, GQuark keyId, void* data, GDestroyNotify destroyFunc)
144 	{
145 		// void g_datalist_id_set_data_full (GData **datalist,  GQuark key_id,  gpointer data,  GDestroyNotify destroy_func);
146 		g_datalist_id_set_data_full(datalist, keyId, data, destroyFunc);
147 	}
148 	
149 	/**
150 	 * Retrieves the data element corresponding to key_id.
151 	 * Params:
152 	 * datalist = a datalist.
153 	 * keyId = the GQuark identifying a data element.
154 	 * Returns: the data element, or NULL if it is not found.
155 	 */
156 	public static void* idGetData(GData** datalist, GQuark keyId)
157 	{
158 		// gpointer g_datalist_id_get_data (GData **datalist,  GQuark key_id);
159 		return g_datalist_id_get_data(datalist, keyId);
160 	}
161 	
162 	/**
163 	 * Removes an element, without calling its destroy notification
164 	 * function.
165 	 * Params:
166 	 * datalist = a datalist.
167 	 * keyId = the GQuark identifying a data element.
168 	 * Returns: the data previously stored at key_id, or NULL if none.
169 	 */
170 	public static void* idRemoveNoNotify(GData** datalist, GQuark keyId)
171 	{
172 		// gpointer g_datalist_id_remove_no_notify (GData **datalist,  GQuark key_id);
173 		return g_datalist_id_remove_no_notify(datalist, keyId);
174 	}
175 	
176 	/**
177 	 * Calls the given function for each data element of the datalist. The
178 	 * function is called with each data element's GQuark id and data,
179 	 * together with the given user_data parameter. Note that this
180 	 * function is NOT thread-safe. So unless datalist can be protected
181 	 * from any modifications during invocation of this function, it should
182 	 * not be called.
183 	 * Params:
184 	 * datalist = a datalist.
185 	 * func = the function to call for each data element.
186 	 * userData = user data to pass to the function.
187 	 */
188 	public static void foreac(GData** datalist, GDataForeachFunc func, void* userData)
189 	{
190 		// void g_datalist_foreach (GData **datalist,  GDataForeachFunc func,  gpointer user_data);
191 		g_datalist_foreach(datalist, func, userData);
192 	}
193 	
194 	/**
195 	 * Frees all the data elements of the datalist. The data elements'
196 	 * destroy functions are called if they have been set.
197 	 * Params:
198 	 * datalist = a datalist.
199 	 */
200 	public static void clear(GData** datalist)
201 	{
202 		// void g_datalist_clear (GData **datalist);
203 		g_datalist_clear(datalist);
204 	}
205 	
206 	/**
207 	 * Turns on flag values for a data list. This function is used
208 	 * to keep a small number of boolean flags in an object with
209 	 * a data list without using any additional space. It is
210 	 * not generally useful except in circumstances where space
211 	 * is very tight. (It is used in the base GObject type, for
212 	 * example.)
213 	 * Since 2.8
214 	 * Params:
215 	 * datalist = pointer to the location that holds a list
216 	 * flags = the flags to turn on. The values of the flags are
217 	 * restricted by G_DATALIST_FLAGS_MASK (currently
218 	 * 3; giving two possible boolean flags).
219 	 * A value for flags that doesn't fit within the mask is
220 	 * an error.
221 	 */
222 	public static void setFlags(GData** datalist, uint flags)
223 	{
224 		// void g_datalist_set_flags (GData **datalist,  guint flags);
225 		g_datalist_set_flags(datalist, flags);
226 	}
227 	
228 	/**
229 	 * Turns off flag values for a data list. See g_datalist_unset_flags()
230 	 * Since 2.8
231 	 * Params:
232 	 * datalist = pointer to the location that holds a list
233 	 * flags = the flags to turn off. The values of the flags are
234 	 * restricted by G_DATALIST_FLAGS_MASK (currently
235 	 * 3: giving two possible boolean flags).
236 	 * A value for flags that doesn't fit within the mask is
237 	 * an error.
238 	 */
239 	public static void unsetFlags(GData** datalist, uint flags)
240 	{
241 		// void g_datalist_unset_flags (GData **datalist,  guint flags);
242 		g_datalist_unset_flags(datalist, flags);
243 	}
244 	
245 	/**
246 	 * Gets flags values packed in together with the datalist.
247 	 * See g_datalist_set_flags().
248 	 * Since 2.8
249 	 * Params:
250 	 * datalist = pointer to the location that holds a list
251 	 * Returns: the flags of the datalist
252 	 */
253 	public static uint getFlags(GData** datalist)
254 	{
255 		// guint g_datalist_get_flags (GData **datalist);
256 		return g_datalist_get_flags(datalist);
257 	}
258 }