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