2 * This file is part of duit.
4 * duit is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation; either version 2.1 of the License, or
7 * (at your option) any later version.
9 * duit is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public License
15 * along with duit; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 // generated automatically - do not change
20 // find conversion definition on APILookup.txt
21 // implement new conversion functionalities on the wrap.utils pakage
24 * Conversion parameters:
25 * inFile = glib-Relations-and-Tuples.html
48 * - GHashTable* -> HashTable
49 * - GTuples* -> Tuples
55 private import glib
.glibtypes
;
57 private import lib
.glib
;
59 private import glib
.HashTable
;
60 private import glib
.Tuples
;
64 * A GRelation is a table of data which can be indexed on any number of fields,
65 * rather like simple database tables. A GRelation contains a number of
66 * records, called tuples. Each record contains a number of fields.
67 * Records are not ordered, so it is not possible to find the record at a
69 * Note that GRelation tables are currently limited to 2 fields.
70 * To create a GRelation, use g_relation_new().
71 * To specify which fields should be indexed, use g_relation_index().
72 * Note that this must be called before any tuples are added to the GRelation.
73 * To add records to a GRelation use g_relation_insert().
74 * To determine if a given record appears in a GRelation, use
75 * g_relation_exists(). Note that fields are compared directly, so pointers
76 * must point to the exact same position (i.e. different copies of the same
77 * string will not match.)
78 * To count the number of records which have a particular value in a given
79 * field, use g_relation_count().
80 * To get all the records which have a particular value in a given field,
81 * use g_relation_select(). To access fields of the resulting records,
82 * use g_tuples_index(). To free the resulting records use g_tuples_destroy().
83 * To delete all records which have a particular value in a given field,
84 * use g_relation_delete().
85 * To destroy the GRelation, use g_relation_destroy().
86 * To help debug GRelation objects, use g_relation_print().
91 /** the main Gtk struct */
92 protected GRelation
* gRelation
;
95 public GRelation
* getRelationStruct()
101 /** the main Gtk struct as a void* */
102 protected void* getStruct()
104 return cast(void*)gRelation
;
108 * Sets our main struct and passes it to the parent class
110 public this (GRelation
* gRelation
)
112 this.gRelation
= gRelation
;
120 * Creates a new GRelation with the given number of fields.
121 * Note that currently the number of fields must be 2.
123 * the number of fields.
127 public this (int fields
)
129 // GRelation* g_relation_new (gint fields);
130 this(cast(GRelation
*)g_relation_new(fields
) );
134 * Creates an index on the given field.
135 * Note that this must be called before any records are added to the GRelation.
139 * the field to index, counting from 0.
141 * a function to produce a hash value from the field data.
143 * a function to compare two values of the given field.
145 public void index(int field
, GHashFunc hashFunc
, GEqualFunc keyEqualFunc
)
147 // void g_relation_index (GRelation *relation, gint field, GHashFunc hash_func, GEqualFunc key_equal_func);
148 g_relation_index(gRelation
, field
, hashFunc
, keyEqualFunc
);
152 * Inserts a record into a GRelation.
156 * the fields of the record to add. These must match the number of
157 * fields in the GRelation, and of type gpointer or gconstpointer.
159 public void insert(... )
161 // void g_relation_insert (GRelation *relation, ...);
162 g_relation_insert(gRelation
);
166 * Returns TRUE if a record with the given values exists in a GRelation.
167 * Note that the values are compared directly, so that, for example, two
168 * copies of the same string will not match.
172 * the fields of the record to compare. The number must match the
173 * number of fields in the GRelation.
175 * TRUE if a record matches.
177 public int exists(... )
179 // gboolean g_relation_exists (GRelation *relation, ...);
180 return g_relation_exists(gRelation
);
184 * Returns the number of tuples in a GRelation that have the given value
185 * in the given field.
189 * the value to compare with.
191 * the field of each record to match.
193 * the number of matches.
195 public int count(void* key
, int field
)
197 // gint g_relation_count (GRelation *relation, gconstpointer key, gint field);
198 return g_relation_count(gRelation
, key
, field
);
202 * Returns all of the tuples which have the given key in the given field.
203 * Use g_tuples_index() to access the returned records.
204 * The returned records should be freed with g_tuples_destroy().
208 * the value to compare with.
210 * the field of each record to match.
212 * the records (tuples) that matched.
214 public Tuples
select(void* key
, int field
)
216 // GTuples* g_relation_select (GRelation *relation, gconstpointer key, gint field);
217 return new Tuples( g_relation_select(gRelation
, key
, field
) );
221 * Deletes any records from a GRelation that have the given key value in
226 * the value to compare with.
228 * the field of each record to match.
230 * the number of records deleted.
232 public int delet(void* key
, int field
)
234 // gint g_relation_delete (GRelation *relation, gconstpointer key, gint field);
235 return g_relation_delete(gRelation
, key
, field
);
239 * Destroys the GRelation, freeing all memory allocated.
240 * However, it does not free memory allocated for the
241 * tuple data, so you should free that first if appropriate.
245 public void destroy()
247 // void g_relation_destroy (GRelation *relation);
248 g_relation_destroy(gRelation
);
252 * Outputs information about all records in a GRelation, as well as the indexes.
253 * It is for debugging.
259 // void g_relation_print (GRelation *relation);
260 g_relation_print(gRelation
);