DataList

Keyed data lists provide lists of arbitrary data elements which can be accessed either with a string or with a GQuark corresponding to the string.

The GQuark methods are quicker, since the strings have to be converted to GQuarks anyway.

Data lists are used for associating arbitrary data with GObjects, using g_object_set_data() and related functions.

To create a datalist, use g_datalist_init().

To add data elements to a datalist use g_datalist_id_set_data(), g_datalist_id_set_data_full(), g_datalist_set_data() and g_datalist_set_data_full().

To get data elements from a datalist use g_datalist_id_get_data() and g_datalist_get_data().

To iterate over all data elements in a datalist use g_datalist_foreach() (not thread-safe).

To remove data elements from a datalist use g_datalist_id_remove_data() and g_datalist_remove_data().

To remove all data elements from a datalist, use g_datalist_clear().

Constructors

this
this(GData* gData)

Sets our main struct and passes it to the parent class

Members

Functions

getDataListStruct
GData* getDataListStruct()

Get the main Gtk struct

getStruct
void* getStruct()

the main Gtk struct as a void*

Static functions

clear
void clear(GData** datalist)

Frees all the data elements of the datalist. The data elements' destroy functions are called if they have been set.

foreac
void foreac(GData** datalist, GDataForeachFunc func, void* userData)

Calls the given function for each data element of the datalist. The function is called with each data element's GQuark id and data, together with the given user_data parameter. Note that this function is NOT thread-safe. So unless datalist can be protected from any modifications during invocation of this function, it should not be called.

getData
void* getData(GData** datalist, string key)

Gets a data element, using its string identifier. This is slower than g_datalist_id_get_data() because it compares strings.

getFlags
uint getFlags(GData** datalist)

Gets flags values packed in together with the datalist. See g_datalist_set_flags(). Since 2.8

idDupData
void* idDupData(GData** datalist, GQuark keyId, GDuplicateFunc dupFunc, void* userData)

This is a variant of g_datalist_id_get_data() which returns a 'duplicate' of the value. dup_func defines the meaning of 'duplicate' in this context, it could e.g. take a reference on a ref-counted object. If the key_id is not set in the datalist then dup_func will be called with a NULL argument. Note that dup_func is called while the datalist is locked, so it is not allowed to read or modify the datalist. This function can be useful to avoid races when multiple threads are using the same datalist and the same key. Since 2.34

idGetData
void* idGetData(GData** datalist, GQuark keyId)

Retrieves the data element corresponding to key_id.

idRemoveNoNotify
void* idRemoveNoNotify(GData** datalist, GQuark keyId)

Removes an element, without calling its destroy notification function.

idReplaceData
int idReplaceData(GData** datalist, GQuark keyId, void* oldval, void* newval, GDestroyNotify destroy, GDestroyNotify* oldDestroy)

Compares the member that is associated with key_id in datalist to oldval, and if they are the same, replace oldval with newval. This is like a typical atomic compare-and-exchange operation, for a member of datalist. If the previous value was replaced then ownership of the old value (oldval) is passed to the caller, including the registred destroy notify for it (passed out in old_destroy). Its up to the caller to free this as he wishes, which may or may not include using old_destroy as sometimes replacement should not destroy the object in the normal way. Return: TRUE if the existing value for key_id was replaced by newval, FALSE otherwise. Since 2.34

idSetDataFull
void idSetDataFull(GData** datalist, GQuark keyId, void* data, GDestroyNotify destroyFunc)

Sets the data corresponding to the given GQuark id, and the function to be called when the element is removed from the datalist. Any previous data with the same key is removed, and its destroy function is called.

init
void init(GData** datalist)

Resets the datalist to NULL. It does not free any memory or call any destroy functions.

setFlags
void setFlags(GData** datalist, uint flags)

Turns on flag values for a data list. This function is used to keep a small number of boolean flags in an object with a data list without using any additional space. It is not generally useful except in circumstances where space is very tight. (It is used in the base GObject type, for example.) Since 2.8

unsetFlags
void unsetFlags(GData** datalist, uint flags)

Turns off flag values for a data list. See g_datalist_unset_flags() Since 2.8

Variables

gData
GData* gData;

the main Gtk struct

Meta