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