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  * Conversion parameters:
26  * inFile  = gobject-Value-arrays.html
27  * outPack = gobject
28  * outFile = ValueArray
29  * strct   = GValueArray
30  * realStrct=
31  * ctorStrct=
32  * clss    = ValueArray
33  * interf  = 
34  * class Code: No
35  * interface Code: No
36  * template for:
37  * extend  = 
38  * implements:
39  * prefixes:
40  * 	- g_value_array_
41  * omit structs:
42  * omit prefixes:
43  * omit code:
44  * omit signals:
45  * imports:
46  * 	- gobject.Value
47  * structWrap:
48  * 	- GValue* -> Value
49  * 	- GValueArray* -> ValueArray
50  * module aliases:
51  * local aliases:
52  * overrides:
53  */
54 
55 module gobject.ValueArray;
56 
57 public  import gtkc.gobjecttypes;
58 
59 private import gtkc.gobject;
60 private import glib.ConstructionException;
61 private import gobject.ObjectG;
62 
63 
64 private import gobject.Value;
65 
66 
67 
68 
69 /**
70  * The prime purpose of a GValueArray is for it to be used as an
71  * object property that holds an array of values. A GValueArray wraps
72  * an array of GValue elements in order for it to be used as a boxed
73  * type through G_TYPE_VALUE_ARRAY.
74  *
75  * GValueArray is deprecated in favour of GArray since GLib 2.32. It
76  * is possible to create a GArray that behaves like a GValueArray by
77  * using the size of GValue as the element size, and by setting
78  * g_value_unset() as the clear function using g_array_set_clear_func(),
79  * for instance, the following code:
80  *
81  * $(DDOC_COMMENT example)
82  *
83  * can be replaced by:
84  *
85  * $(DDOC_COMMENT example)
86  */
87 public class ValueArray
88 {
89 	
90 	/** the main Gtk struct */
91 	protected GValueArray* gValueArray;
92 	
93 	
94 	public GValueArray* getValueArrayStruct()
95 	{
96 		return gValueArray;
97 	}
98 	
99 	
100 	/** the main Gtk struct as a void* */
101 	protected void* getStruct()
102 	{
103 		return cast(void*)gValueArray;
104 	}
105 	
106 	/**
107 	 * Sets our main struct and passes it to the parent class
108 	 */
109 	public this (GValueArray* gValueArray)
110 	{
111 		this.gValueArray = gValueArray;
112 	}
113 	
114 	/**
115 	 */
116 	
117 	/**
118 	 * Warning
119 	 * g_value_array_get_nth has been deprecated since version 2.32 and should not be used in newly-written code. Use g_array_index() instead.
120 	 * Return a pointer to the value at index_ containd in value_array.
121 	 * Params:
122 	 * index = index of the value of interest
123 	 * Returns: pointer to a value at index_ in value_array. [transfer none]
124 	 */
125 	public Value getNth(uint index)
126 	{
127 		// GValue * g_value_array_get_nth (GValueArray *value_array,  guint index_);
128 		auto p = g_value_array_get_nth(gValueArray, index);
129 		
130 		if(p is null)
131 		{
132 			return null;
133 		}
134 		
135 		return ObjectG.getDObject!(Value)(cast(GValue*) p);
136 	}
137 	
138 	/**
139 	 * Warning
140 	 * g_value_array_new has been deprecated since version 2.32 and should not be used in newly-written code. Use GArray and g_array_sized_new() instead.
141 	 * Allocate and initialize a new GValueArray, optionally preserve space
142 	 * for n_prealloced elements. New arrays always contain 0 elements,
143 	 * regardless of the value of n_prealloced.
144 	 * Params:
145 	 * nPrealloced = number of values to preallocate space for
146 	 * Throws: ConstructionException GTK+ fails to create the object.
147 	 */
148 	public this (uint nPrealloced)
149 	{
150 		// GValueArray * g_value_array_new (guint n_prealloced);
151 		auto p = g_value_array_new(nPrealloced);
152 		if(p is null)
153 		{
154 			throw new ConstructionException("null returned by g_value_array_new(nPrealloced)");
155 		}
156 		this(cast(GValueArray*) p);
157 	}
158 	
159 	/**
160 	 * Warning
161 	 * g_value_array_copy has been deprecated since version 2.32 and should not be used in newly-written code. Use GArray and g_array_ref() instead.
162 	 * Construct an exact copy of a GValueArray by duplicating all its
163 	 * contents.
164 	 * Returns: Newly allocated copy of GValueArray. [transfer full]
165 	 */
166 	public ValueArray copy()
167 	{
168 		// GValueArray * g_value_array_copy (const GValueArray *value_array);
169 		auto p = g_value_array_copy(gValueArray);
170 		
171 		if(p is null)
172 		{
173 			return null;
174 		}
175 		
176 		return ObjectG.getDObject!(ValueArray)(cast(GValueArray*) p);
177 	}
178 	
179 	/**
180 	 * Warning
181 	 * g_value_array_free has been deprecated since version 2.32 and should not be used in newly-written code. Use GArray and g_array_unref() instead.
182 	 * Free a GValueArray including its contents.
183 	 */
184 	public void free()
185 	{
186 		// void g_value_array_free (GValueArray *value_array);
187 		g_value_array_free(gValueArray);
188 	}
189 	
190 	/**
191 	 * Warning
192 	 * g_value_array_append has been deprecated since version 2.32 and should not be used in newly-written code. Use GArray and g_array_append_val() instead.
193 	 * Insert a copy of value as last element of value_array. If value is
194 	 * NULL, an uninitialized value is appended.
195 	 * Params:
196 	 * value = GValue to copy into GValueArray, or NULL. [allow-none]
197 	 * Returns: the GValueArray passed in as value_array. [transfer none]
198 	 */
199 	public ValueArray append(Value value)
200 	{
201 		// GValueArray * g_value_array_append (GValueArray *value_array,  const GValue *value);
202 		auto p = g_value_array_append(gValueArray, (value is null) ? null : value.getValueStruct());
203 		
204 		if(p is null)
205 		{
206 			return null;
207 		}
208 		
209 		return ObjectG.getDObject!(ValueArray)(cast(GValueArray*) p);
210 	}
211 	
212 	/**
213 	 * Warning
214 	 * g_value_array_prepend has been deprecated since version 2.32 and should not be used in newly-written code. Use GArray and g_array_prepend_val() instead.
215 	 * Insert a copy of value as first element of value_array. If value is
216 	 * NULL, an uninitialized value is prepended.
217 	 * Params:
218 	 * value = GValue to copy into GValueArray, or NULL. [allow-none]
219 	 * Returns: the GValueArray passed in as value_array. [transfer none]
220 	 */
221 	public ValueArray prepend(Value value)
222 	{
223 		// GValueArray * g_value_array_prepend (GValueArray *value_array,  const GValue *value);
224 		auto p = g_value_array_prepend(gValueArray, (value is null) ? null : value.getValueStruct());
225 		
226 		if(p is null)
227 		{
228 			return null;
229 		}
230 		
231 		return ObjectG.getDObject!(ValueArray)(cast(GValueArray*) p);
232 	}
233 	
234 	/**
235 	 * Warning
236 	 * g_value_array_insert has been deprecated since version 2.32 and should not be used in newly-written code. Use GArray and g_array_insert_val() instead.
237 	 * Insert a copy of value at specified position into value_array. If value
238 	 * is NULL, an uninitialized value is inserted.
239 	 * Params:
240 	 * index = insertion position, must be <= value_array->n_values
241 	 * value = GValue to copy into GValueArray, or NULL. [allow-none]
242 	 * Returns: the GValueArray passed in as value_array. [transfer none]
243 	 */
244 	public ValueArray insert(uint index, Value value)
245 	{
246 		// GValueArray * g_value_array_insert (GValueArray *value_array,  guint index_,  const GValue *value);
247 		auto p = g_value_array_insert(gValueArray, index, (value is null) ? null : value.getValueStruct());
248 		
249 		if(p is null)
250 		{
251 			return null;
252 		}
253 		
254 		return ObjectG.getDObject!(ValueArray)(cast(GValueArray*) p);
255 	}
256 	
257 	/**
258 	 * Warning
259 	 * g_value_array_remove has been deprecated since version 2.32 and should not be used in newly-written code. Use GArray and g_array_remove_index() instead.
260 	 * Remove the value at position index_ from value_array.
261 	 * Params:
262 	 * index = position of value to remove, which must be less than
263 	 * value_array->n_values
264 	 * Returns: the GValueArray passed in as value_array. [transfer none]
265 	 */
266 	public ValueArray remove(uint index)
267 	{
268 		// GValueArray * g_value_array_remove (GValueArray *value_array,  guint index_);
269 		auto p = g_value_array_remove(gValueArray, index);
270 		
271 		if(p is null)
272 		{
273 			return null;
274 		}
275 		
276 		return ObjectG.getDObject!(ValueArray)(cast(GValueArray*) p);
277 	}
278 	
279 	/**
280 	 * Warning
281 	 * g_value_array_sort has been deprecated since version 2.32 and should not be used in newly-written code. Use GArray and g_array_sort().
282 	 * Sort value_array using compare_func to compare the elements according to
283 	 * the semantics of GCompareFunc.
284 	 * The current implementation uses the same sorting algorithm as standard
285 	 * C qsort() function.
286 	 * Params:
287 	 * compareFunc = function to compare elements. [scope call]
288 	 * Returns: the GValueArray passed in as value_array. [transfer none]
289 	 */
290 	public ValueArray sort(GCompareFunc compareFunc)
291 	{
292 		// GValueArray * g_value_array_sort (GValueArray *value_array,  GCompareFunc compare_func);
293 		auto p = g_value_array_sort(gValueArray, compareFunc);
294 		
295 		if(p is null)
296 		{
297 			return null;
298 		}
299 		
300 		return ObjectG.getDObject!(ValueArray)(cast(GValueArray*) p);
301 	}
302 	
303 	/**
304 	 * Warning
305 	 * g_value_array_sort_with_data has been deprecated since version 2.32 and should not be used in newly-written code. Use GArray and g_array_sort_with_data().
306 	 * Sort value_array using compare_func to compare the elements according
307 	 * to the semantics of GCompareDataFunc.
308 	 * The current implementation uses the same sorting algorithm as standard
309 	 * C qsort() function.
310 	 * Rename to: g_value_array_sort
311 	 * Params:
312 	 * compareFunc = function to compare elements. [scope call]
313 	 * userData = extra data argument provided for compare_func. [closure]
314 	 * Returns: the GValueArray passed in as value_array. [transfer none]
315 	 */
316 	public ValueArray sortWithData(GCompareDataFunc compareFunc, void* userData)
317 	{
318 		// GValueArray * g_value_array_sort_with_data (GValueArray *value_array,  GCompareDataFunc compare_func,  gpointer user_data);
319 		auto p = g_value_array_sort_with_data(gValueArray, compareFunc, userData);
320 		
321 		if(p is null)
322 		{
323 			return null;
324 		}
325 		
326 		return ObjectG.getDObject!(ValueArray)(cast(GValueArray*) p);
327 	}
328 }