gi-glib-2.0.29: GLib bindings

Copyright | Will Thompson and Iñaki García Etxebarria
License | LGPL-2.1
Maintainer | Iñaki García Etxebarria
Safe Haskell | Safe-Inferred
Language | Haskell2010

GI.GLib.Structs.Relation

Contents

- Exported types
- Methods
  - count
  - delete
  - destroy
  - print

Description

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 `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 `relationCount`.

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 `tuplesIndex`. To free the resulting records use `tuplesDestroy`.

To delete all records which have a particular value in a given field, use `relationDelete`.

To destroy the `GRelation`, use `relationDestroy`.

To help debug `GRelation` objects, use `relationPrint`.

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

Synopsis

- newtype Relation = Relation (ManagedPtr Relation)
- relationCount :: (HasCallStack, MonadIO m) => Relation -> Ptr () -> Int32 -> m Int32
- relationDelete :: (HasCallStack, MonadIO m) => Relation -> Ptr () -> Int32 -> m Int32
- relationDestroy :: (HasCallStack, MonadIO m) => Relation -> m ()
- relationPrint :: (HasCallStack, MonadIO m) => Relation -> m ()

# Exported types

newtype Relation Source #

Memory-managed wrapper type.

Constructors

Relation (ManagedPtr Relation) |

#### Instances

Instances details

Eq Relation Source # |
Instance details Defined in GI.GLib.Structs.Relation Methods (==) :: Relation -> Relation -> Bool Source # (/=) :: Relation -> Relation -> Bool Source #
BoxedPtr Relation Source # |
Instance details Defined in GI.GLib.Structs.Relation Methods boxedPtrCopy :: Relation -> IO Relation Source # boxedPtrFree :: Relation -> IO () Source #
ManagedPtrNewtype Relation Source # |
Instance details Defined in GI.GLib.Structs.Relation Methods toManagedPtr :: Relation -> ManagedPtr Relation Source #

# Methods

### Click to display all available methods, including inherited ones

Expand

#### Methods

count, delete, destroy, print.

#### Getters

None.

#### Setters

None.

## count

relationCount Source #

Arguments

:: (HasCallStack, MonadIO m) |
=> Relation | `relation`: a `Relation`.
-> Ptr () | `key`: the value to compare with.
-> Int32 | `field`: the field of each record to match.
-> m Int32 | Returns: the number of matches.

Deprecated: (Since version 2.26)Rarely used API

Returns the number of tuples in a `Relation` that have the given value in the given field.

## delete

relationDelete Source #

Arguments

:: (HasCallStack, MonadIO m) |
=> Relation | `relation`: a `Relation`.
-> Ptr () | `key`: the value to compare with.
-> Int32 | `field`: the field of each record to match.
-> m Int32 | Returns: the number of records deleted.

Deprecated: (Since version 2.26)Rarely used API

Deletes any records from a `Relation` that have the given key value in the given field.

## destroy

relationDestroy Source #

Arguments

:: (HasCallStack, MonadIO m) |
=> Relation | `relation`: a `Relation`.
-> m () |

Deprecated: (Since version 2.26)Rarely used API

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

relationPrint Source #

Arguments

:: (HasCallStack, MonadIO m) |
=> Relation | `relation`: a `Relation`.
-> m () |

Deprecated: (Since version 2.26)Rarely used API

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