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