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-Datasets.html 27 * outPack = glib 28 * outFile = Dataset 29 * strct = 30 * realStrct= 31 * ctorStrct= 32 * clss = Dataset 33 * interf = 34 * class Code: No 35 * interface Code: No 36 * template for: 37 * extend = 38 * implements: 39 * prefixes: 40 * - g_dataset_ 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.Dataset; 53 54 public import gtkc.glibtypes; 55 56 private import gtkc.glib; 57 private import glib.ConstructionException; 58 59 60 61 62 /** 63 * Datasets associate groups of data elements with particular memory 64 * locations. These are useful if you need to associate data with a 65 * structure returned from an external library. Since you cannot modify 66 * the structure, you use its location in memory as the key into a 67 * dataset, where you can associate any number of data elements with it. 68 * 69 * There are two forms of most of the dataset functions. The first form 70 * uses strings to identify the data elements associated with a 71 * location. The second form uses GQuark identifiers, which are 72 * created with a call to g_quark_from_string() or 73 * g_quark_from_static_string(). The second form is quicker, since it 74 * does not require looking up the string in the hash table of GQuark 75 * identifiers. 76 * 77 * There is no function to create a dataset. It is automatically 78 * created as soon as you add elements to it. 79 * 80 * To add data elements to a dataset use g_dataset_id_set_data(), 81 * g_dataset_id_set_data_full(), g_dataset_set_data() and 82 * g_dataset_set_data_full(). 83 * 84 * To get data elements from a dataset use g_dataset_id_get_data() and 85 * g_dataset_get_data(). 86 * 87 * To iterate over all data elements in a dataset use 88 * g_dataset_foreach() (not thread-safe). 89 * 90 * To remove data elements from a dataset use 91 * g_dataset_id_remove_data() and g_dataset_remove_data(). 92 * 93 * To destroy a dataset, use g_dataset_destroy(). 94 */ 95 public class Dataset 96 { 97 98 /** 99 */ 100 101 /** 102 * Sets the data element associated with the given GQuark id, and also 103 * the function to call when the data element is destroyed. Any 104 * previous data with the same key is removed, and its destroy function 105 * is called. 106 * Params: 107 * datasetLocation = the location identifying the dataset. 108 * keyId = the GQuark id to identify the data element. 109 * data = the data element. 110 * destroyFunc = the function to call when the data element is 111 * removed. This function will be called with the data 112 * element and can be used to free any memory allocated 113 * for it. 114 */ 115 public static void idSetDataFull(void* datasetLocation, GQuark keyId, void* data, GDestroyNotify destroyFunc) 116 { 117 // void g_dataset_id_set_data_full (gconstpointer dataset_location, GQuark key_id, gpointer data, GDestroyNotify destroy_func); 118 g_dataset_id_set_data_full(datasetLocation, keyId, data, destroyFunc); 119 } 120 121 /** 122 * Gets the data element corresponding to a GQuark. 123 * Params: 124 * datasetLocation = the location identifying the dataset. 125 * keyId = the GQuark id to identify the data element. 126 * Returns: the data element corresponding to the GQuark, or NULL if it is not found. 127 */ 128 public static void* idGetData(void* datasetLocation, GQuark keyId) 129 { 130 // gpointer g_dataset_id_get_data (gconstpointer dataset_location, GQuark key_id); 131 return g_dataset_id_get_data(datasetLocation, keyId); 132 } 133 134 /** 135 * Removes an element, without calling its destroy notification 136 * function. 137 * Params: 138 * datasetLocation = the location identifying the dataset. 139 * keyId = the GQuark ID identifying the data element. 140 * Returns: the data previously stored at key_id, or NULL if none. 141 */ 142 public static void* idRemoveNoNotify(void* datasetLocation, GQuark keyId) 143 { 144 // gpointer g_dataset_id_remove_no_notify (gconstpointer dataset_location, GQuark key_id); 145 return g_dataset_id_remove_no_notify(datasetLocation, keyId); 146 } 147 148 /** 149 * Calls the given function for each data element which is associated 150 * with the given location. Note that this function is NOT thread-safe. 151 * So unless datalist can be protected from any modifications during 152 * invocation of this function, it should not be called. 153 * Params: 154 * datasetLocation = the location identifying the dataset. 155 * func = the function to call for each data element. 156 * userData = user data to pass to the function. 157 */ 158 public static void foreac(void* datasetLocation, GDataForeachFunc func, void* userData) 159 { 160 // void g_dataset_foreach (gconstpointer dataset_location, GDataForeachFunc func, gpointer user_data); 161 g_dataset_foreach(datasetLocation, func, userData); 162 } 163 164 /** 165 * Destroys the dataset, freeing all memory allocated, and calling any 166 * destroy functions set for data elements. 167 * Params: 168 * datasetLocation = the location identifying the dataset. 169 */ 170 public static void destroy(void* datasetLocation) 171 { 172 // void g_dataset_destroy (gconstpointer dataset_location); 173 g_dataset_destroy(datasetLocation); 174 } 175 }