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
50 module glib
.ByteArray
;
52 private import glib
.glibtypes
;
54 private import lib
.glib
;
56 private import glib
.ListG
;
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;
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++)
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');
80 * g_byte_array_free (gbarray, TRUE);
82 public class ByteArray
85 /** the main Gtk struct */
86 protected GByteArray
* gByteArray
;
89 public GByteArray
* getByteArrayStruct()
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.
116 * the new GByteArray.
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.
129 * number of bytes preallocated.
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.
145 * the byte data to be added.
147 * the number of bytes to add.
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.
163 * the byte data to be added.
165 * the number of bytes to add.
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.
181 * the index of the byte to remove.
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().
199 * the index of the byte to remove.
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.
215 * the index of the first byte to remove.
217 * the number of bytes to remove.
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
233 * If two array elements compare equal, their order in the sorted array is
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
252 * comparison function.
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.
267 * the new size of 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.
283 * if TRUE the actual byte data is freed as well.
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
);