Basics

Guides

API Reference

Menu

Basics

Guides

API Reference

class: GRelation

[34:7] extends: object

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 [func@GLib.Relation.new]. To specify which fields should be indexed, use [method@GLib.Relation.index]. Note that this must be called before any tuples are added to the GRelation. To add records to a GRelation use [method@GLib.Relation.insert]. To determine if a given record appears in a GRelation, use [method@GLib.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 [method@GLib.Relation.count]. To get all the records which have a particular value in a given field, use [method@GLib.Relation.select]. To access fields of the resulting records, use [method@GLib.Tuples.index]. To free the resulting records use [method@GLib.Tuples.destroy]. To delete all records which have a particular value in a given field, use [method@GLib.Relation.delete]. To destroy the GRelation, use [method@GLib.Relation.destroy]. To help debug GRelation objects, use [method@GLib.Relation.print]. GRelation has been marked as deprecated, since this API has never been fully implemented, is not very actively maintained and rarely used.

Members

  • handleObj
  • lib
  • retainedCallbacks
  • signalHandlerNames
  • signalSetterHandlers

Methods

  • GRelation (Handle = null)

    Creates a new Relation by wrapping a native handle or another wrapper.

    • @p Handle is the native handle or another wrapper whose handle to adopt.
  • toNativeHandle (Source)

    Normalizes a constructor argument into a raw pointer carrier. Accepts a raw NativeHandle, a raw NativeBuffer returned from fn.call(...), another generated wrapper exposing handle(), or null. Returns null when the argument carries no pointer.

    • @p Source is the raw handle, raw buffer, wrapper, or null.
    • @r A raw pointer carrier or null when no pointer is present.
  • getLib ()

    Returns the opened native library for this generated wrapper.

    • @r The opened native library.
  • handle ()

    Returns the wrapped NativeHandle.

    • @r The wrapped NativeHandle.
  • isNull ()

    Returns true when the wrapped handle is null.

    • @r A bool.
  • describe ()

    Returns a small string for debugging generated wrappers.

    • @r A string.
  • count (key, int field)

    Returns the number of tuples in a #GRelation that have the given value in the given field.

    • @p key is the value to compare with..
    • @p field is the field of each record to match..
    • @r the number of matches..
  • delete (key, int field)

    Deletes any records from a #GRelation that have the given key value in the given field.

    • @p key is the value to compare with..
    • @p field is the field of each record to match..
    • @r the number of records deleted..
  • destroy ()

    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.

    • @r None.
  • exists (list varargs)

    Returns %TRUE if a record with the given values exists in a #GRelation. Note that the values are compared directly, so that, for example, two copies of the same string will not match.

    • @p ... is the fields of the record to compare. The number must match the number of fields in the #GRelation..
    • @r %TRUE if a record matches..
  • index (int field, object hash_func, object key_equal_func)

    Creates an index on the given field. Note that this must be called before any records are added to the #GRelation.

    • @p field is the field to index, counting from 0..
    • @p hash_func is a function to produce a hash value from the field data..
    • @p key_equal_func is a function to compare two values of the given field..
    • @r None.
  • insert (list varargs)

    Inserts a record into a #GRelation.

    • @p ... is the fields of the record to add. These must match the number of fields in the #GRelation, and of type #gpointer or #gconstpointer..
    • @r None.
  • print ()

    Outputs information about all records in a #GRelation, as well as the indexes. It is for debugging.

    • @r None.
  • select (key, int field)

    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().

    • @p key is the value to compare with..
    • @p field is the field of each record to match..
    • @r the records (tuples) that matched..