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 gobject.ValueArray; 26 27 private import glib.ConstructionException; 28 private import gobject.ObjectG; 29 private import gobject.Value; 30 private import gtkc.gobject; 31 public import gtkc.gobjecttypes; 32 33 34 /** 35 * A #GValueArray contains an array of #GValue elements. 36 */ 37 public class ValueArray 38 { 39 /** the main Gtk struct */ 40 protected GValueArray* gValueArray; 41 protected bool ownedRef; 42 43 /** Get the main Gtk struct */ 44 public GValueArray* getValueArrayStruct() 45 { 46 return gValueArray; 47 } 48 49 /** the main Gtk struct as a void* */ 50 protected void* getStruct() 51 { 52 return cast(void*)gValueArray; 53 } 54 55 /** 56 * Sets our main struct and passes it to the parent class. 57 */ 58 public this (GValueArray* gValueArray, bool ownedRef = false) 59 { 60 this.gValueArray = gValueArray; 61 this.ownedRef = ownedRef; 62 } 63 64 65 /** */ 66 public static GType getType() 67 { 68 return g_value_array_get_type(); 69 } 70 71 /** 72 * Allocate and initialize a new #GValueArray, optionally preserve space 73 * for @n_prealloced elements. New arrays always contain 0 elements, 74 * regardless of the value of @n_prealloced. 75 * 76 * Deprecated: Use #GArray and g_array_sized_new() instead. 77 * 78 * Params: 79 * nPrealloced = number of values to preallocate space for 80 * 81 * Return: a newly allocated #GValueArray with 0 values 82 * 83 * Throws: ConstructionException GTK+ fails to create the object. 84 */ 85 public this(uint nPrealloced) 86 { 87 auto p = g_value_array_new(nPrealloced); 88 89 if(p is null) 90 { 91 throw new ConstructionException("null returned by new"); 92 } 93 94 this(cast(GValueArray*) p); 95 } 96 97 /** 98 * Insert a copy of @value as last element of @value_array. If @value is 99 * %NULL, an uninitialized value is appended. 100 * 101 * Deprecated: Use #GArray and g_array_append_val() instead. 102 * 103 * Params: 104 * value = #GValue to copy into #GValueArray, or %NULL 105 * 106 * Return: the #GValueArray passed in as @value_array 107 */ 108 public ValueArray append(Value value) 109 { 110 auto p = g_value_array_append(gValueArray, (value is null) ? null : value.getValueStruct()); 111 112 if(p is null) 113 { 114 return null; 115 } 116 117 return ObjectG.getDObject!(ValueArray)(cast(GValueArray*) p); 118 } 119 120 /** 121 * Construct an exact copy of a #GValueArray by duplicating all its 122 * contents. 123 * 124 * Deprecated: Use #GArray and g_array_ref() instead. 125 * 126 * Return: Newly allocated copy of #GValueArray 127 */ 128 public ValueArray copy() 129 { 130 auto p = g_value_array_copy(gValueArray); 131 132 if(p is null) 133 { 134 return null; 135 } 136 137 return ObjectG.getDObject!(ValueArray)(cast(GValueArray*) p, true); 138 } 139 140 /** 141 * Free a #GValueArray including its contents. 142 * 143 * Deprecated: Use #GArray and g_array_unref() instead. 144 */ 145 public void free() 146 { 147 g_value_array_free(gValueArray); 148 } 149 150 /** 151 * Return a pointer to the value at @index_ containd in @value_array. 152 * 153 * Deprecated: Use g_array_index() instead. 154 * 155 * Params: 156 * index = index of the value of interest 157 * 158 * Return: pointer to a value at @index_ in @value_array 159 */ 160 public Value getNth(uint index) 161 { 162 auto p = g_value_array_get_nth(gValueArray, index); 163 164 if(p is null) 165 { 166 return null; 167 } 168 169 return ObjectG.getDObject!(Value)(cast(GValue*) p); 170 } 171 172 /** 173 * Insert a copy of @value at specified position into @value_array. If @value 174 * is %NULL, an uninitialized value is inserted. 175 * 176 * Deprecated: Use #GArray and g_array_insert_val() instead. 177 * 178 * Params: 179 * index = insertion position, must be <= value_array->;n_values 180 * value = #GValue to copy into #GValueArray, or %NULL 181 * 182 * Return: the #GValueArray passed in as @value_array 183 */ 184 public ValueArray insert(uint index, Value value) 185 { 186 auto p = g_value_array_insert(gValueArray, index, (value is null) ? null : value.getValueStruct()); 187 188 if(p is null) 189 { 190 return null; 191 } 192 193 return ObjectG.getDObject!(ValueArray)(cast(GValueArray*) p); 194 } 195 196 /** 197 * Insert a copy of @value as first element of @value_array. If @value is 198 * %NULL, an uninitialized value is prepended. 199 * 200 * Deprecated: Use #GArray and g_array_prepend_val() instead. 201 * 202 * Params: 203 * value = #GValue to copy into #GValueArray, or %NULL 204 * 205 * Return: the #GValueArray passed in as @value_array 206 */ 207 public ValueArray prepend(Value value) 208 { 209 auto p = g_value_array_prepend(gValueArray, (value is null) ? null : value.getValueStruct()); 210 211 if(p is null) 212 { 213 return null; 214 } 215 216 return ObjectG.getDObject!(ValueArray)(cast(GValueArray*) p); 217 } 218 219 /** 220 * Remove the value at position @index_ from @value_array. 221 * 222 * Deprecated: Use #GArray and g_array_remove_index() instead. 223 * 224 * Params: 225 * index = position of value to remove, which must be less than 226 * @value_array->n_values 227 * 228 * Return: the #GValueArray passed in as @value_array 229 */ 230 public ValueArray remove(uint index) 231 { 232 auto p = g_value_array_remove(gValueArray, index); 233 234 if(p is null) 235 { 236 return null; 237 } 238 239 return ObjectG.getDObject!(ValueArray)(cast(GValueArray*) p); 240 } 241 242 /** 243 * Sort @value_array using @compare_func to compare the elements according to 244 * the semantics of #GCompareFunc. 245 * 246 * The current implementation uses the same sorting algorithm as standard 247 * C qsort() function. 248 * 249 * Deprecated: Use #GArray and g_array_sort(). 250 * 251 * Params: 252 * compareFunc = function to compare elements 253 * 254 * Return: the #GValueArray passed in as @value_array 255 */ 256 public ValueArray sort(GCompareFunc compareFunc) 257 { 258 auto p = g_value_array_sort(gValueArray, compareFunc); 259 260 if(p is null) 261 { 262 return null; 263 } 264 265 return ObjectG.getDObject!(ValueArray)(cast(GValueArray*) p); 266 } 267 268 /** 269 * Sort @value_array using @compare_func to compare the elements according 270 * to the semantics of #GCompareDataFunc. 271 * 272 * The current implementation uses the same sorting algorithm as standard 273 * C qsort() function. 274 * 275 * Deprecated: Use #GArray and g_array_sort_with_data(). 276 * 277 * Params: 278 * compareFunc = function to compare elements 279 * userData = extra data argument provided for @compare_func 280 * 281 * Return: the #GValueArray passed in as @value_array 282 */ 283 public ValueArray sortWithData(GCompareDataFunc compareFunc, void* userData) 284 { 285 auto p = g_value_array_sort_with_data(gValueArray, compareFunc, userData); 286 287 if(p is null) 288 { 289 return null; 290 } 291 292 return ObjectG.getDObject!(ValueArray)(cast(GValueArray*) p); 293 } 294 }