alternative to assert
[gtkD.git] / gtkD / src / gobject / ValueArray.d
blob307cf1ec121b89fa1fd42ecb631166b9bac61207
1 /*
2 * This file is part of gtkD.
4 * gtkD is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation; either version 2.1 of the License, or
7 * (at your option) any later version.
9 * gtkD is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public License
15 * along with gtkD; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 // generated automatically - do not change
20 // find conversion definition on APILookup.txt
21 // implement new conversion functionalities on the wrap.utils pakage
24 * Conversion parameters:
25 * inFile = gobject-Value-arrays.html
26 * outPack = gobject
27 * outFile = ValueArray
28 * strct = GValueArray
29 * realStrct=
30 * ctorStrct=
31 * clss = ValueArray
32 * interf =
33 * class Code: No
34 * interface Code: No
35 * template for:
36 * extend =
37 * implements:
38 * prefixes:
39 * - g_value_array_
40 * omit structs:
41 * omit prefixes:
42 * omit code:
43 * imports:
44 * - gobject.Value
45 * - gobject.ValueArray
46 * structWrap:
47 * - GValue* -> Value
48 * - GValueArray* -> ValueArray
49 * module aliases:
50 * local aliases:
53 module gobject.ValueArray;
55 version(noAssert)
57 version(Tango)
59 import tango.io.Stdout; // use the tango loging?
63 private import gtkc.gobjecttypes;
65 private import gtkc.gobject;
68 private import gobject.Value;
69 private import gobject.ValueArray;
74 /**
75 * Description
76 * The prime purpose of a GValueArray is for it to be used as an object property
77 * that holds an array of values. A GValueArray wraps an array of GValue elements
78 * in order for it to be used as a boxed type through G_TYPE_VALUE_ARRAY.
80 public class ValueArray
83 /** the main Gtk struct */
84 protected GValueArray* gValueArray;
87 public GValueArray* getValueArrayStruct()
89 return gValueArray;
93 /** the main Gtk struct as a void* */
94 protected void* getStruct()
96 return cast(void*)gValueArray;
99 /**
100 * Sets our main struct and passes it to the parent class
102 public this (GValueArray* gValueArray)
104 version(noAssert)
106 if ( gValueArray is null )
108 int zero = 0;
109 version(Tango)
111 Stdout("struct gValueArray is null on constructor").newline;
113 else
115 printf("struct gValueArray is null on constructor");
117 zero = zero / zero;
120 else
122 assert(gValueArray !is null, "struct gValueArray is null on constructor");
124 this.gValueArray = gValueArray;
132 * Return a pointer to the value at index_ containd in value_array.
133 * value_array:
134 * GValueArray to get a value from
135 * index_:
136 * index of the value of interest
137 * Returns:
138 * pointer to a value at index_ in value_array
140 public Value getNth(uint index)
142 // GValue* g_value_array_get_nth (GValueArray *value_array, guint index_);
143 return new Value( g_value_array_get_nth(gValueArray, index) );
147 * Allocate and initialize a new GValueArray, optionally preserve space
148 * for n_prealloced elements. New arrays always contain 0 elements,
149 * regardless of the value of n_prealloced.
150 * n_prealloced:
151 * number of values to preallocate space for
152 * Returns:
153 * a newly allocated GValueArray with 0 values
155 public this (uint nPrealloced)
157 // GValueArray* g_value_array_new (guint n_prealloced);
158 this(cast(GValueArray*)g_value_array_new(nPrealloced) );
162 * Construct an exact copy of a GValueArray by duplicating all its
163 * contents.
164 * value_array:
165 * GValueArray to copy
166 * Returns:
167 * Newly allocated copy of GValueArray
169 public ValueArray copy()
171 // GValueArray* g_value_array_copy (const GValueArray *value_array);
172 return new ValueArray( g_value_array_copy(gValueArray) );
176 * Free a GValueArray including its contents.
177 * value_array:
178 * GValueArray to free
180 public void free()
182 // void g_value_array_free (GValueArray *value_array);
183 g_value_array_free(gValueArray);
187 * Insert a copy of value as last element of value_array.
188 * value_array:
189 * GValueArray to add an element to
190 * value:
191 * GValue to copy into GValueArray
192 * Returns:
193 * the GValueArray passed in as value_array
195 public ValueArray append(Value value)
197 // GValueArray* g_value_array_append (GValueArray *value_array, const GValue *value);
198 return new ValueArray( g_value_array_append(gValueArray, (value is null) ? null : value.getValueStruct()) );
202 * Insert a copy of value as first element of value_array.
203 * value_array:
204 * GValueArray to add an element to
205 * value:
206 * GValue to copy into GValueArray
207 * Returns:
208 * the GValueArray passed in as value_array
210 public ValueArray prepend(Value value)
212 // GValueArray* g_value_array_prepend (GValueArray *value_array, const GValue *value);
213 return new ValueArray( g_value_array_prepend(gValueArray, (value is null) ? null : value.getValueStruct()) );
217 * Insert a copy of value at specified position into value_array.
218 * value_array:
219 * GValueArray to add an element to
220 * index_:
221 * insertion position, must be <= value_array->n_values
222 * value:
223 * GValue to copy into GValueArray
224 * Returns:
225 * the GValueArray passed in as value_array
227 public ValueArray insert(uint index, Value value)
229 // GValueArray* g_value_array_insert (GValueArray *value_array, guint index_, const GValue *value);
230 return new ValueArray( g_value_array_insert(gValueArray, index, (value is null) ? null : value.getValueStruct()) );
234 * Remove the value at position index_ from value_array.
235 * value_array:
236 * GValueArray to remove an element from
237 * index_:
238 * position of value to remove, must be < value_array->n_values
239 * Returns:
240 * the GValueArray passed in as value_array
242 public ValueArray remove(uint index)
244 // GValueArray* g_value_array_remove (GValueArray *value_array, guint index_);
245 return new ValueArray( g_value_array_remove(gValueArray, index) );
249 * Sort value_array using compare_func to compare the elements accoring to
250 * the semantics of GCompareFunc.
251 * The current implementation uses Quick-Sort as sorting algorithm.
252 * value_array:
253 * GValueArray to sort
254 * compare_func:
255 * function to compare elements
256 * Returns:
257 * the GValueArray passed in as value_array
259 public ValueArray sort(GCompareFunc compareFunc)
261 // GValueArray* g_value_array_sort (GValueArray *value_array, GCompareFunc compare_func);
262 return new ValueArray( g_value_array_sort(gValueArray, compareFunc) );
266 * Sort value_array using compare_func to compare the elements accoring
267 * to the semantics of GCompareDataFunc.
268 * The current implementation uses Quick-Sort as sorting algorithm.
269 * value_array:
270 * GValueArray to sort
271 * compare_func:
272 * function to compare elements
273 * user_data:
274 * extra data argument provided for compare_func
275 * Returns:
276 * the GValueArray passed in as value_array
277 * See Also
278 * GValue, GParamSpecValueArray, g_param_spec_value_array()
280 public ValueArray sortWithData(GCompareDataFunc compareFunc, void* userData)
282 // GValueArray* g_value_array_sort_with_data (GValueArray *value_array, GCompareDataFunc compare_func, gpointer user_data);
283 return new ValueArray( g_value_array_sort_with_data(gValueArray, compareFunc, userData) );