GLib.Relation¶
record (struct)
:::warning Deprecated since 2.26 This API is deprecated. :::
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 Relation.new.
To specify which fields should be indexed, use Relation.index.
Note that this must be called before any tuples are added to the
GRelation.
To add records to a GRelation use Relation.insert.
To determine if a given record appears in a GRelation, use
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 Relation.count.
To get all the records which have a particular value in a given
field, use Relation.select. To access fields of the resulting
records, use Tuples.index. To free the resulting records use
Tuples.destroy.
To delete all records which have a particular value in a given
field, use Relation.delete.
To destroy the GRelation, use Relation.destroy.
To help debug GRelation objects, use Relation.print.
GRelation has been marked as deprecated, since this API has never
been fully implemented, is not very actively maintained and rarely
used.
Methods¶
count¶
:::warning Deprecated since 2.26 This API is deprecated. :::
Returns the number of tuples in a Relation that have the given
value in the given field.
Parameters:
key— the value to compare with.field— the field of each record to match.
delete¶
:::warning Deprecated since 2.26 This API is deprecated. :::
Deletes any records from a Relation that have the given key value
in the given field.
Parameters:
key— the value to compare with.field— the field of each record to match.
destroy¶
:::warning Deprecated since 2.26 This API is deprecated. :::
Destroys the Relation, freeing all memory allocated. However, it
does not free memory allocated for the tuple data, so you should
free that first if appropriate.
print¶
:::warning Deprecated since 2.26 This API is deprecated. :::
Outputs information about all records in a Relation, as well as
the indexes. It is for debugging.