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