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