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