Bytes

GByteArray is a mutable array of bytes based on GArray, to provide arrays of bytes which grow automatically as elements are added.

To create a new GByteArray use g_byte_array_new(). To add elements to a GByteArray, use g_byte_array_append(), and g_byte_array_prepend().

To set the size of a GByteArray, use g_byte_array_set_size().

To free a GByteArray, use g_byte_array_free().

See GBytes if you are interested in an immutable object representing a sequence of bytes.

Constructors

this
this(GBytes* gBytes)

Sets our main struct and passes it to the parent class

this
this(void* data, gsize size)

Creates a new GBytes from data. data is copied. Since 2.32

this
this(void* data, gsize size, GDestroyNotify freeFunc, void* userData)

Creates a GBytes from data. When the last reference is dropped, free_func will be called with the user_data argument. data must not be modified after this call is made until free_func has been called to indicate that the bytes is no longer in use. Since 2.32

this
this(Bytes bytes, gsize offset, gsize length)

Creates a GBytes which is a subsection of another GBytes. The offset + length may not be longer than the size of bytes. A reference to bytes will be held by the newly created GBytes until the byte data is no longer needed. Since 2.32

Members

Functions

doref
Bytes doref()

Increase the reference count on bytes. Since 2.32

getBytesStruct
GBytes* getBytesStruct()

Get the main Gtk struct

getData
void[] getData()

Get the byte data in the GBytes. This data should not be modified. This function will always return the same pointer for a given GBytes. Since 2.32

getSize
gsize getSize()

Get the size of the byte data in the GBytes. This function will always return the same value for a given GBytes. Since 2.32

getStruct
void* getStruct()

the main Gtk struct as a void*

unref
void unref()

Releases a reference on bytes. This may result in the bytes being freed. Since 2.32

unrefToArray
ByteArray unrefToArray()

Unreferences the bytes, and returns a new mutable GByteArray containing the same byte data. As an optimization, the byte data is transferred to the array without copying if this was the last reference to bytes and bytes was created with g_bytes_new(), g_bytes_new_take() or g_byte_array_free_to_bytes(). In all other cases the data is copied. Since 2.32

unrefToData
void[] unrefToData()

Unreferences the bytes, and returns a pointer the same byte data contents. As an optimization, the byte data is returned without copying if this was the last reference to bytes and bytes was created with g_bytes_new(), g_bytes_new_take() or g_byte_array_free_to_bytes(). In all other cases the data is copied. Since 2.32

Static functions

compare
int compare(void* bytes1, void* bytes2)

Compares the two GBytes values. This function can be used to sort GBytes instances in lexographical order. Since 2.32

equal
int equal(void* bytes1, void* bytes2)

Compares the two GBytes values being pointed to and returns TRUE if they are equal. This function can be passed to g_hash_table_new() as the key_equal_func parameter, when using non-NULL GBytes pointers as keys in a GHashTable. Since 2.32

hash
uint hash(void* bytes)

Creates an integer hash code for the byte data in the GBytes. This function can be passed to g_hash_table_new() as the key_equal_func parameter, when using non-NULL GBytes pointers as keys in a GHashTable. Since 2.32

Variables

gBytes
GBytes* gBytes;

the main Gtk struct

Meta