You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

102 lines
3.5 KiB

  1. /* GLIB - Library of useful routines for C programming
  2. * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
  3. *
  4. * This library is free software; you can redistribute it and/or
  5. * modify it under the terms of the GNU Lesser General Public
  6. * License as published by the Free Software Foundation; either
  7. * version 2 of the License, or (at your option) any later version.
  8. *
  9. * This library 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 GNU
  12. * Lesser General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU Lesser General Public
  15. * License along with this library; if not, write to the
  16. * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  17. * Boston, MA 02111-1307, USA.
  18. */
  19. /*
  20. * Modified by the GLib Team and others 1997-2000. See the AUTHORS
  21. * file for a list of people on the GLib Team. See the ChangeLog
  22. * files for a list of changes. These files are distributed with
  23. * GLib at ftp://ftp.gtk.org/pub/gtk/.
  24. */
  25. #if defined(G_DISABLE_SINGLE_INCLUDES) && !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION)
  26. #error "Only <glib.h> can be included directly."
  27. #endif
  28. #ifndef __G_REL_H__
  29. #define __G_REL_H__
  30. #include <glib/gtypes.h>
  31. G_BEGIN_DECLS
  32. typedef struct _GRelation GRelation;
  33. typedef struct _GTuples GTuples;
  34. struct _GTuples
  35. {
  36. guint len;
  37. };
  38. /* GRelation
  39. *
  40. * Indexed Relations. Imagine a really simple table in a
  41. * database. Relations are not ordered. This data type is meant for
  42. * maintaining a N-way mapping.
  43. *
  44. * g_relation_new() creates a relation with FIELDS fields
  45. *
  46. * g_relation_destroy() frees all resources
  47. * g_tuples_destroy() frees the result of g_relation_select()
  48. *
  49. * g_relation_index() indexes relation FIELD with the provided
  50. * equality and hash functions. this must be done before any
  51. * calls to insert are made.
  52. *
  53. * g_relation_insert() inserts a new tuple. you are expected to
  54. * provide the right number of fields.
  55. *
  56. * g_relation_delete() deletes all relations with KEY in FIELD
  57. * g_relation_select() returns ...
  58. * g_relation_count() counts ...
  59. */
  60. #ifndef G_DISABLE_DEPRECATED
  61. GRelation* g_relation_new (gint fields);
  62. void g_relation_destroy (GRelation *relation);
  63. void g_relation_index (GRelation *relation,
  64. gint field,
  65. GHashFunc hash_func,
  66. GEqualFunc key_equal_func);
  67. void g_relation_insert (GRelation *relation,
  68. ...);
  69. gint g_relation_delete (GRelation *relation,
  70. gconstpointer key,
  71. gint field);
  72. GTuples* g_relation_select (GRelation *relation,
  73. gconstpointer key,
  74. gint field);
  75. gint g_relation_count (GRelation *relation,
  76. gconstpointer key,
  77. gint field);
  78. gboolean g_relation_exists (GRelation *relation,
  79. ...);
  80. void g_relation_print (GRelation *relation);
  81. void g_tuples_destroy (GTuples *tuples);
  82. gpointer g_tuples_index (GTuples *tuples,
  83. gint index_,
  84. gint field);
  85. #endif
  86. G_END_DECLS
  87. #endif /* __G_REL_H__ */