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