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