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 change21 // find conversion definition on APILookup.txt22 // implement new conversion functionalities on the wrap.utils pakage23 24 /*
25 * Conversion parameters:
26 * inFile = glib-Byte-Arrays.html
27 * outPack = glib
28 * outFile = ByteArray
29 * strct = GByteArray
30 * realStrct=
31 * ctorStrct=
32 * clss = ByteArray
33 * interf =
34 * class Code: No
35 * interface Code: No
36 * template for:
37 * extend =
38 * implements:
39 * prefixes:
40 * - g_byte_array_
41 * omit structs:
42 * omit prefixes:
43 * omit code:
44 * omit signals:
45 * imports:
46 * structWrap:
47 * - GByteArray* -> ByteArray
48 * module aliases:
49 * local aliases:
50 * overrides:
51 */52 53 moduleglib.ByteArray;
54 55 publicimportgtkc.glibtypes;
56 57 privateimportgtkc.glib;
58 privateimportglib.ConstructionException;
59 60 61 62 63 64 65 /**
66 * Description
67 * GByteArray is based on GArray, to provide arrays of bytes which
68 * grow automatically as elements are added.
69 * To create a new GByteArray use g_byte_array_new().
70 * To add elements to a GByteArray, use g_byte_array_append(), and
71 * g_byte_array_prepend().
72 * To set the size of a GByteArray, use g_byte_array_set_size().
73 * To free a GByteArray, use g_byte_array_free().
74 * $(DDOC_COMMENT example)
75 */76 publicclassByteArray77 {
78 79 /** the main Gtk struct */80 protectedGByteArray* gByteArray;
81 82 83 publicGByteArray* getByteArrayStruct()
84 {
85 returngByteArray;
86 }
87 88 89 /** the main Gtk struct as a void* */90 protectedvoid* getStruct()
91 {
92 returncast(void*)gByteArray;
93 }
94 95 /**
96 * Sets our main struct and passes it to the parent class
97 */98 publicthis (GByteArray* gByteArray)
99 {
100 this.gByteArray = gByteArray;
101 }
102 103 /**
104 */105 106 /**
107 * Creates a new GByteArray with a reference count of 1.
108 * Throws: ConstructionException GTK+ fails to create the object.
109 */110 publicthis ()
111 {
112 // GByteArray * g_byte_array_new (void);113 autop = g_byte_array_new();
114 if(pisnull)
115 {
116 thrownewConstructionException("null returned by g_byte_array_new()");
117 }
118 this(cast(GByteArray*) p);
119 }
120 121 /**
122 * Creates a new GByteArray with reserved_size bytes preallocated.
123 * This avoids frequent reallocation, if you are going to add many
124 * bytes to the array. Note however that the size of the array is still
125 * 0.
126 * Params:
127 * reservedSize = number of bytes preallocated.
128 * Returns: the new GByteArray.
129 */130 publicstaticByteArraysizedNew(uintreservedSize)
131 {
132 // GByteArray * g_byte_array_sized_new (guint reserved_size);133 autop = g_byte_array_sized_new(reservedSize);
134 135 if(pisnull)
136 {
137 returnnull;
138 }
139 140 returnnewByteArray(cast(GByteArray*) p);
141 }
142 143 /**
144 * Atomically increments the reference count of array by one. This
145 * function is MT-safe and may be called from any thread.
146 * Since 2.22
147 * Returns: The passed in GByteArray.
148 */149 publicByteArraydoref()
150 {
151 // GByteArray * g_byte_array_ref (GByteArray *array);152 autop = g_byte_array_ref(gByteArray);
153 154 if(pisnull)
155 {
156 returnnull;
157 }
158 159 returnnewByteArray(cast(GByteArray*) p);
160 }
161 162 /**
163 * Atomically decrements the reference count of array by one. If the
164 * reference count drops to 0, all memory allocated by the array is
165 * released. This function is MT-safe and may be called from any
166 * thread.
167 * Since 2.22
168 */169 publicvoidunref()
170 {
171 // void g_byte_array_unref (GByteArray *array);172 g_byte_array_unref(gByteArray);
173 }
174 175 /**
176 * Adds the given bytes to the end of the GByteArray. The array will
177 * grow in size automatically if necessary.
178 * Params:
179 * data = the byte data to be added.
180 * Returns: the GByteArray.
181 */182 publicByteArrayappend(ubyte[] data)
183 {
184 // GByteArray * g_byte_array_append (GByteArray *array, const guint8 *data, guint len);185 autop = g_byte_array_append(gByteArray, data.ptr, cast(int) data.length);
186 187 if(pisnull)
188 {
189 returnnull;
190 }
191 192 returnnewByteArray(cast(GByteArray*) p);
193 }
194 195 /**
196 * Adds the given data to the start of the GByteArray. The array will
197 * grow in size automatically if necessary.
198 * Params:
199 * data = the byte data to be added.
200 * Returns: the GByteArray.
201 */202 publicByteArrayprepend(ubyte[] data)
203 {
204 // GByteArray * g_byte_array_prepend (GByteArray *array, const guint8 *data, guint len);205 autop = g_byte_array_prepend(gByteArray, data.ptr, cast(int) data.length);
206 207 if(pisnull)
208 {
209 returnnull;
210 }
211 212 returnnewByteArray(cast(GByteArray*) p);
213 }
214 215 /**
216 * Removes the byte at the given index from a GByteArray. The
217 * following bytes are moved down one place.
218 * Params:
219 * index = the index of the byte to remove.
220 * Returns: the GByteArray.
221 */222 publicByteArrayremoveIndex(uintindex)
223 {
224 // GByteArray * g_byte_array_remove_index (GByteArray *array, guint index_);225 autop = g_byte_array_remove_index(gByteArray, index);
226 227 if(pisnull)
228 {
229 returnnull;
230 }
231 232 returnnewByteArray(cast(GByteArray*) p);
233 }
234 235 /**
236 * Removes the byte at the given index from a GByteArray. The last
237 * element in the array is used to fill in the space, so this function
238 * does not preserve the order of the GByteArray. But it is faster
239 * than g_byte_array_remove_index().
240 * Params:
241 * index = the index of the byte to remove.
242 * Returns: the GByteArray.
243 */244 publicByteArrayremoveIndexFast(uintindex)
245 {
246 // GByteArray * g_byte_array_remove_index_fast (GByteArray *array, guint index_);247 autop = g_byte_array_remove_index_fast(gByteArray, index);
248 249 if(pisnull)
250 {
251 returnnull;
252 }
253 254 returnnewByteArray(cast(GByteArray*) p);
255 }
256 257 /**
258 * Removes the given number of bytes starting at the given index from a
259 * GByteArray. The following elements are moved to close the gap.
260 * Since 2.4
261 * Params:
262 * index = the index of the first byte to remove.
263 * length = the number of bytes to remove.
264 * Returns: the GByteArray.
265 */266 publicByteArrayremoveRange(uintindex, uintlength)
267 {
268 // GByteArray * g_byte_array_remove_range (GByteArray *array, guint index_, guint length);269 autop = g_byte_array_remove_range(gByteArray, index, length);
270 271 if(pisnull)
272 {
273 returnnull;
274 }
275 276 returnnewByteArray(cast(GByteArray*) p);
277 }
278 279 /**
280 * Sorts a byte array, using compare_func which should be a
281 * qsort()-style comparison function (returns less than zero for first
282 * arg is less than second arg, zero for equal, greater than zero if
283 * first arg is greater than second arg).
284 * If two array elements compare equal, their order in the sorted array
285 * is undefined.
286 * Params:
287 * compareFunc = comparison function.
288 */289 publicvoidsort(GCompareFunccompareFunc)
290 {
291 // void g_byte_array_sort (GByteArray *array, GCompareFunc compare_func);292 g_byte_array_sort(gByteArray, compareFunc);
293 }
294 295 /**
296 * Like g_byte_array_sort(), but the comparison function takes an extra
297 * user data argument.
298 * Params:
299 * compareFunc = comparison function.
300 * userData = data to pass to compare_func.
301 */302 publicvoidsortWithData(GCompareDataFunccompareFunc, void* userData)
303 {
304 // void g_byte_array_sort_with_data (GByteArray *array, GCompareDataFunc compare_func, gpointer user_data);305 g_byte_array_sort_with_data(gByteArray, compareFunc, userData);
306 }
307 308 /**
309 * Sets the size of the GByteArray, expanding it if necessary.
310 * Params:
311 * length = the new size of the GByteArray.
312 * Returns: the GByteArray.
313 */314 publicByteArraysetSize(uintlength)
315 {
316 // GByteArray * g_byte_array_set_size (GByteArray *array, guint length);317 autop = g_byte_array_set_size(gByteArray, length);
318 319 if(pisnull)
320 {
321 returnnull;
322 }
323 324 returnnewByteArray(cast(GByteArray*) p);
325 }
326 327 /**
328 * Frees the memory allocated by the GByteArray. If free_segment is
329 * TRUE it frees the actual byte data. If the reference count of
330 * array is greater than one, the GByteArray wrapper is preserved but
331 * the size of array will be set to zero.
332 * Params:
333 * freeSegment = if TRUE the actual byte data is freed as well.
334 * Returns: the element data if free_segment is FALSE, otherwise NULL. The element data should be freed using g_free().
335 */336 publicubyte* free(intfreeSegment)
337 {
338 // guint8 * g_byte_array_free (GByteArray *array, gboolean free_segment);339 returng_byte_array_free(gByteArray, freeSegment);
340 }
341 }