Relation

A GRelation is a table of data which can be indexed on any number of fields, rather like simple database tables. A GRelation contains a number of records, called tuples. Each record contains a number of fields. Records are not ordered, so it is not possible to find the record at a particular index.

Note that GRelation tables are currently limited to 2 fields.

To create a GRelation, use g_relation_new().

To specify which fields should be indexed, use g_relation_index(). Note that this must be called before any tuples are added to the GRelation.

To add records to a GRelation use g_relation_insert().

To determine if a given record appears in a GRelation, use g_relation_exists(). Note that fields are compared directly, so pointers must point to the exact same position (i.e. different copies of the same string will not match.)

To count the number of records which have a particular value in a given field, use g_relation_count().

To get all the records which have a particular value in a given field, use g_relation_select(). To access fields of the resulting records, use g_tuples_index(). To free the resulting records use g_tuples_destroy().

To delete all records which have a particular value in a given field, use g_relation_delete().

To destroy the GRelation, use g_relation_destroy().

To help debug GRelation objects, use g_relation_print().

GRelation has been marked as deprecated, since this API has never been fully implemented, is not very actively maintained and rarely used.

Constructors

this
this(GRelation* gRelation)

Sets our main struct and passes it to the parent class

this
this(int fields)

Warning g_relation_new has been deprecated since version 2.26 and should not be used in newly-written code. Rarely used API Creates a new GRelation with the given number of fields. Note that currently the number of fields must be 2.

Members

Functions

count
int count(void* key, int field)

Warning g_relation_count has been deprecated since version 2.26 and should not be used in newly-written code. Rarely used API Returns the number of tuples in a GRelation that have the given value in the given field.

delet
int delet(void* key, int field)

Warning g_relation_delete has been deprecated since version 2.26 and should not be used in newly-written code. Rarely used API Deletes any records from a GRelation that have the given key value in the given field.

destroy
void destroy()

Warning g_relation_destroy has been deprecated since version 2.26 and should not be used in newly-written code. Rarely used API Destroys the GRelation, freeing all memory allocated. However, it does not free memory allocated for the tuple data, so you should free that first if appropriate.

getRelationStruct
GRelation* getRelationStruct()

Get the main Gtk struct

getStruct
void* getStruct()

the main Gtk struct as a void*

index
void index(int field, GHashFunc hashFunc, GEqualFunc keyEqualFunc)

Warning g_relation_index has been deprecated since version 2.26 and should not be used in newly-written code. Rarely used API Creates an index on the given field. Note that this must be called before any records are added to the GRelation.

print
void print()

Warning g_relation_print has been deprecated since version 2.26 and should not be used in newly-written code. Rarely used API Outputs information about all records in a GRelation, as well as the indexes. It is for debugging.

select
Tuples select(void* key, int field)

Warning g_relation_select has been deprecated since version 2.26 and should not be used in newly-written code. Rarely used API Returns all of the tuples which have the given key in the given field. Use g_tuples_index() to access the returned records. The returned records should be freed with g_tuples_destroy().

Variables

gRelation
GRelation* gRelation;

the main Gtk struct

Meta