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