I've no idea here...
[gtkD.git] / src / glib / ByteArray.d
blob546a4ef428a7570dbeed2f40e687a8a4df4ac328
1 /*
2 * This file is part of duit.
4 * duit 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 * duit 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 duit; 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 = glib-Byte-Arrays.html
26 * outPack = glib
27 * outFile = ByteArray
28 * strct = GByteArray
29 * realStrct=
30 * ctorStrct=
31 * clss = ByteArray
32 * interf =
33 * class Code: No
34 * interface Code: No
35 * template for:
36 * extend =
37 * implements:
38 * prefixes:
39 * - g_byte_array_
40 * omit structs:
41 * omit prefixes:
42 * omit code:
43 * imports:
44 * - glib.ListG
45 * structWrap:
46 * - GList* -> ListG
47 * local aliases:
50 module glib.ByteArray;
52 private import glib.glibtypes;
54 private import lib.glib;
56 private import glib.ListG;
58 /**
59 * Description
60 * GByteArray is based on GArray, to provide arrays of bytes which grow
61 * automatically as elements are added.
62 * To create a new GByteArray use g_byte_array_new().
63 * To add elements to a GByteArray, use g_byte_array_append(), and
64 * g_byte_array_prepend().
65 * To set the size of a GByteArray, use g_byte_array_set_size().
66 * To free a GByteArray, use g_byte_array_free().
67 * Example8.Using a GByteArray
68 * GByteArray *gbarray;
69 * gint i;
70 * gbarray = g_byte_array_new ();
71 * for (i = 0; i < 10000; i++)
72 * g_byte_array_append (gbarray, (guint8*) "abcd", 4);
73 * for (i = 0; i < 10000; i++)
74 * {
75 * g_assert (gbarray->data[4*i] == 'a');
76 * g_assert (gbarray->data[4*i+1] == 'b');
77 * g_assert (gbarray->data[4*i+2] == 'c');
78 * g_assert (gbarray->data[4*i+3] == 'd');
79 * }
80 * g_byte_array_free (gbarray, TRUE);
82 public class ByteArray
85 /** the main Gtk struct */
86 protected GByteArray* gByteArray;
89 public GByteArray* getByteArrayStruct()
91 return gByteArray;
95 /** the main Gtk struct as a void* */
96 protected void* getStruct()
98 return cast(void*)gByteArray;
102 * Sets our main struct and passes it to the parent class
104 public this (GByteArray* gByteArray)
106 this.gByteArray = gByteArray;
114 * Creates a new GByteArray.
115 * Returns:
116 * the new GByteArray.
118 public this ()
120 // GByteArray* g_byte_array_new (void);
121 this(cast(GByteArray*)g_byte_array_new() );
125 * Creates a new GByteArray with reserved_size bytes preallocated. This
126 * avoids frequent reallocation, if you are going to add many bytes to
127 * the array. Note however that the size of the array is still 0.
128 * reserved_size:
129 * number of bytes preallocated.
130 * Returns:
131 * the new GByteArray.
133 public static GByteArray* sizedNew(uint reservedSize)
135 // GByteArray* g_byte_array_sized_new (guint reserved_size);
136 return g_byte_array_sized_new(reservedSize);
140 * Adds the given bytes to the end of the GByteArray.
141 * The array will grow in size automatically if necessary.
142 * array:
143 * a GByteArray.
144 * data:
145 * the byte data to be added.
146 * len:
147 * the number of bytes to add.
148 * Returns:
149 * the GByteArray.
151 public GByteArray* append(byte* data, uint len)
153 // GByteArray* g_byte_array_append (GByteArray *array, const guint8 *data, guint len);
154 return g_byte_array_append(gByteArray, data, len);
158 * Adds the given data to the start of the GByteArray.
159 * The array will grow in size automatically if necessary.
160 * array:
161 * a GByteArray.
162 * data:
163 * the byte data to be added.
164 * len:
165 * the number of bytes to add.
166 * Returns:
167 * the GByteArray.
169 public GByteArray* prepend(byte* data, uint len)
171 // GByteArray* g_byte_array_prepend (GByteArray *array, const guint8 *data, guint len);
172 return g_byte_array_prepend(gByteArray, data, len);
176 * Removes the byte at the given index from a GByteArray.
177 * The following bytes are moved down one place.
178 * array:
179 * a GByteArray.
180 * index_:
181 * the index of the byte to remove.
182 * Returns:
183 * the GByteArray.
185 public GByteArray* removeIndex(uint index)
187 // GByteArray* g_byte_array_remove_index (GByteArray *array, guint index_);
188 return g_byte_array_remove_index(gByteArray, index);
192 * Removes the byte at the given index from a GByteArray.
193 * The last element in the array is used to fill in the space, so this function
194 * does not preserve the order of the GByteArray. But it is faster than
195 * g_byte_array_remove_index().
196 * array:
197 * a GByteArray.
198 * index_:
199 * the index of the byte to remove.
200 * Returns:
201 * the GByteArray.
203 public GByteArray* removeIndexFast(uint index)
205 // GByteArray* g_byte_array_remove_index_fast (GByteArray *array, guint index_);
206 return g_byte_array_remove_index_fast(gByteArray, index);
210 * Removes the given number of bytes starting at the given index from a
211 * GByteArray. The following elements are moved to close the gap.
212 * array:
213 * a GByteArray.
214 * index_:
215 * the index of the first byte to remove.
216 * length:
217 * the number of bytes to remove.
218 * Returns:
219 * the GByteArray.
220 * Since 2.4
222 public GByteArray* removeRange(uint index, uint length)
224 // GByteArray* g_byte_array_remove_range (GByteArray *array, guint index_, guint length);
225 return g_byte_array_remove_range(gByteArray, index, length);
229 * Sorts a byte array, using compare_func which should be a qsort()-style
230 * comparison function (returns less than zero for first arg is less than second
231 * arg, zero for equal, greater than zero if first arg is greater than second
232 * arg).
233 * If two array elements compare equal, their order in the sorted array is
234 * undefined.
235 * array:
236 * a GByteArray.
237 * compare_func:
238 * comparison function.
240 public void sort(GCompareFunc compareFunc)
242 // void g_byte_array_sort (GByteArray *array, GCompareFunc compare_func);
243 g_byte_array_sort(gByteArray, compareFunc);
247 * Like g_byte_array_sort(), but the comparison function takes an extra user data
248 * argument.
249 * array:
250 * a GByteArray.
251 * compare_func:
252 * comparison function.
253 * user_data:
254 * data to pass to compare_func.
256 public void sortWithData(GCompareDataFunc compareFunc, void* userData)
258 // void g_byte_array_sort_with_data (GByteArray *array, GCompareDataFunc compare_func, gpointer user_data);
259 g_byte_array_sort_with_data(gByteArray, compareFunc, userData);
263 * Sets the size of the GByteArray, expanding it if necessary.
264 * array:
265 * a GByteArray.
266 * length:
267 * the new size of the GByteArray.
268 * Returns:
269 * the GByteArray.
271 public GByteArray* setSize(uint length)
273 // GByteArray* g_byte_array_set_size (GByteArray *array, guint length);
274 return g_byte_array_set_size(gByteArray, length);
278 * Frees the memory allocated by the GByteArray.
279 * If free_segment is TRUE it frees the actual byte data.
280 * array:
281 * a GByteArray.
282 * free_segment:
283 * if TRUE the actual byte data is freed as well.
284 * Returns:
285 * the element data if free_segment is FALSE, otherwise NULL
287 public byte* free(int freeSegment)
289 // guint8* g_byte_array_free (GByteArray *array, gboolean free_segment);
290 return g_byte_array_free(gByteArray, freeSegment);