00001 /* GLIB - Library of useful routines for C programming 00002 * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald 00003 * Portions copyright (c) 2006 Nokia Corporation. All rights reserved. 00004 * 00005 * This library is free software; you can redistribute it and/or 00006 * modify it under the terms of the GNU Lesser General Public 00007 * License as published by the Free Software Foundation; either 00008 * version 2 of the License, or (at your option) any later version. 00009 * 00010 * This library is distributed in the hope that it will be useful, 00011 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00013 * Lesser General Public License for more details. 00014 * 00015 * You should have received a copy of the GNU Lesser General Public 00016 * License along with this library; if not, write to the 00017 * Free Software Foundation, Inc., 59 Temple Place - Suite 330, 00018 * Boston, MA 02111-1307, USA. 00019 */ 00020 00021 /* 00022 * Modified by the GLib Team and others 1997-2000. See the AUTHORS 00023 * file for a list of people on the GLib Team. See the ChangeLog 00024 * files for a list of changes. These files are distributed with 00025 * GLib at ftp://ftp.gtk.org/pub/gtk/. 00026 */ 00027 00028 #ifndef __G_REL_H__ 00029 #define __G_REL_H__ 00030 00031 #include <_ansi.h> 00032 #include <glib/gtypes.h> 00033 00034 G_BEGIN_DECLS 00035 00036 typedef struct _GRelation GRelation; 00037 typedef struct _GTuples GTuples; 00038 00039 struct _GTuples 00040 { 00041 guint len; 00042 }; 00043 00044 /* GRelation 00045 * 00046 * Indexed Relations. Imagine a really simple table in a 00047 * database. Relations are not ordered. This data type is meant for 00048 * maintaining a N-way mapping. 00049 * 00050 * g_relation_new() creates a relation with FIELDS fields 00051 * 00052 * g_relation_destroy() frees all resources 00053 * g_tuples_destroy() frees the result of g_relation_select() 00054 * 00055 * g_relation_index() indexes relation FIELD with the provided 00056 * equality and hash functions. this must be done before any 00057 * calls to insert are made. 00058 * 00059 * g_relation_insert() inserts a new tuple. you are expected to 00060 * provide the right number of fields. 00061 * 00062 * g_relation_delete() deletes all relations with KEY in FIELD 00063 * g_relation_select() returns ... 00064 * g_relation_count() counts ... 00065 */ 00066 00067 IMPORT_C GRelation* g_relation_new (gint fields); 00068 IMPORT_C void g_relation_destroy (GRelation *relation); 00069 IMPORT_C void g_relation_index (GRelation *relation, 00070 gint field, 00071 GHashFunc hash_func, 00072 GEqualFunc key_equal_func); 00073 IMPORT_C void g_relation_insert (GRelation *relation, 00074 ...); 00075 IMPORT_C gint g_relation_delete (GRelation *relation, 00076 gconstpointer key, 00077 gint field); 00078 IMPORT_C GTuples* g_relation_select (GRelation *relation, 00079 gconstpointer key, 00080 gint field); 00081 IMPORT_C gint g_relation_count (GRelation *relation, 00082 gconstpointer key, 00083 gint field); 00084 IMPORT_C gboolean g_relation_exists (GRelation *relation, 00085 ...); 00086 IMPORT_C void g_relation_print (GRelation *relation); 00087 00088 IMPORT_C void g_tuples_destroy (GTuples *tuples); 00089 IMPORT_C gpointer g_tuples_index (GTuples *tuples, 00090 gint index_, 00091 gint field); 00092 00093 G_END_DECLS 00094 00095 #endif /* __G_REL_H__ */ 00096