ByteArray

Contains the public fields of a GByteArray.

Constructors

this
this(GByteArray* gByteArray, bool ownedRef)

Sets our main struct and passes it to the parent class.

this
this()

Creates a new glib.ByteArray with a reference count of 1.

this
this(ubyte[] data)

Create byte array containing the data. The data will be owned by the array and will be freed with g_free(), i.e. it could be allocated using g_strdup().

Members

Functions

append
ByteArray append(ubyte* data, uint len)

Adds the given bytes to the end of the glib.ByteArray The array will grow in size automatically if necessary.

free
ubyte* free(bool freeSegment)

Frees the memory allocated by the glib.ByteArray If free_segment is TRUE it frees the actual byte data. If the reference count of array is greater than one, the glib.ByteArray wrapper is preserved but the size of array will be set to zero.

freeToBytes
Bytes freeToBytes()

Transfers the data from the glib.ByteArray into a new immutable glib.Bytes

getByteArrayStruct
GByteArray* getByteArrayStruct(bool transferOwnership)

Get the main Gtk struct

getStruct
void* getStruct()

the main Gtk struct as a void*

prepend
ByteArray prepend(ubyte* data, uint len)

Adds the given data to the start of the glib.ByteArray The array will grow in size automatically if necessary.

ref_
ByteArray ref_()

Atomically increments the reference count of array by one. This function is thread-safe and may be called from any thread.

removeIndex
ByteArray removeIndex(uint index)

Removes the byte at the given index from a glib.ByteArray The following bytes are moved down one place.

removeIndexFast
ByteArray removeIndexFast(uint index)

Removes the byte at the given index from a glib.ByteArray The last element in the array is used to fill in the space, so this function does not preserve the order of the glib.ByteArray But it is faster than ByteArray.removeIndex.

removeRange
ByteArray removeRange(uint index, uint length)

Removes the given number of bytes starting at the given index from a glib.ByteArray The following elements are moved to close the gap.

setSize
ByteArray setSize(uint length)

Sets the size of the glib.ByteArray, expanding it if necessary.

sort
void sort(GCompareFunc compareFunc)

Sorts a byte array, using compare_func which should be a qsort()-style comparison function (returns less than zero for first arg is less than second arg, zero for equal, greater than zero if first arg is greater than second arg).

sortWithData
void sortWithData(GCompareDataFunc compareFunc, void* userData)

Like ByteArray.sort, but the comparison function takes an extra user data argument.

steal
ubyte* steal(size_t len)

Frees the data in the array and resets the size to zero, while the underlying array is preserved for use elsewhere and returned to the caller.

unref
void unref()

Atomically decrements the reference count of array by one. If the reference count drops to 0, all memory allocated by the array is released. This function is thread-safe and may be called from any thread.

Static functions

sizedNew
ByteArray sizedNew(uint reservedSize)

Creates a new glib.ByteArray with reserved_size bytes preallocated. This avoids frequent reallocation, if you are going to add many bytes to the array. Note however that the size of the array is still 0.

Variables

gByteArray
GByteArray* gByteArray;

the main Gtk struct