gdataset.h 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  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, see <http://www.gnu.org/licenses/>.
  16. */
  17. /*
  18. * Modified by the GLib Team and others 1997-2000. See the AUTHORS
  19. * file for a list of people on the GLib Team. See the ChangeLog
  20. * files for a list of changes. These files are distributed with
  21. * GLib at ftp://ftp.gtk.org/pub/gtk/.
  22. */
  23. #ifndef __G_DATASET_H__
  24. #define __G_DATASET_H__
  25. #if !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION)
  26. #error "Only <glib.h> can be included directly."
  27. #endif
  28. #include <glib/gquark.h>
  29. G_BEGIN_DECLS
  30. typedef struct _GData GData;
  31. typedef void (*GDataForeachFunc) (GQuark key_id,
  32. gpointer data,
  33. gpointer user_data);
  34. /* Keyed Data List
  35. */
  36. GLIB_AVAILABLE_IN_ALL
  37. void g_datalist_init (GData **datalist);
  38. GLIB_AVAILABLE_IN_ALL
  39. void g_datalist_clear (GData **datalist);
  40. GLIB_AVAILABLE_IN_ALL
  41. gpointer g_datalist_id_get_data (GData **datalist,
  42. GQuark key_id);
  43. GLIB_AVAILABLE_IN_ALL
  44. void g_datalist_id_set_data_full (GData **datalist,
  45. GQuark key_id,
  46. gpointer data,
  47. GDestroyNotify destroy_func);
  48. typedef gpointer (*GDuplicateFunc) (gpointer data, gpointer user_data);
  49. GLIB_AVAILABLE_IN_2_34
  50. gpointer g_datalist_id_dup_data (GData **datalist,
  51. GQuark key_id,
  52. GDuplicateFunc dup_func,
  53. gpointer user_data);
  54. GLIB_AVAILABLE_IN_2_34
  55. gboolean g_datalist_id_replace_data (GData **datalist,
  56. GQuark key_id,
  57. gpointer oldval,
  58. gpointer newval,
  59. GDestroyNotify destroy,
  60. GDestroyNotify *old_destroy);
  61. GLIB_AVAILABLE_IN_ALL
  62. gpointer g_datalist_id_remove_no_notify (GData **datalist,
  63. GQuark key_id);
  64. GLIB_AVAILABLE_IN_ALL
  65. void g_datalist_foreach (GData **datalist,
  66. GDataForeachFunc func,
  67. gpointer user_data);
  68. /**
  69. * G_DATALIST_FLAGS_MASK:
  70. *
  71. * A bitmask that restricts the possible flags passed to
  72. * g_datalist_set_flags(). Passing a flags value where
  73. * flags & ~G_DATALIST_FLAGS_MASK != 0 is an error.
  74. */
  75. #define G_DATALIST_FLAGS_MASK 0x3
  76. GLIB_AVAILABLE_IN_ALL
  77. void g_datalist_set_flags (GData **datalist,
  78. guint flags);
  79. GLIB_AVAILABLE_IN_ALL
  80. void g_datalist_unset_flags (GData **datalist,
  81. guint flags);
  82. GLIB_AVAILABLE_IN_ALL
  83. guint g_datalist_get_flags (GData **datalist);
  84. #define g_datalist_id_set_data(dl, q, d) \
  85. g_datalist_id_set_data_full ((dl), (q), (d), NULL)
  86. #define g_datalist_id_remove_data(dl, q) \
  87. g_datalist_id_set_data ((dl), (q), NULL)
  88. #define g_datalist_set_data_full(dl, k, d, f) \
  89. g_datalist_id_set_data_full ((dl), g_quark_from_string (k), (d), (f))
  90. #define g_datalist_remove_no_notify(dl, k) \
  91. g_datalist_id_remove_no_notify ((dl), g_quark_try_string (k))
  92. #define g_datalist_set_data(dl, k, d) \
  93. g_datalist_set_data_full ((dl), (k), (d), NULL)
  94. #define g_datalist_remove_data(dl, k) \
  95. g_datalist_id_set_data ((dl), g_quark_try_string (k), NULL)
  96. /* Location Associated Keyed Data
  97. */
  98. GLIB_AVAILABLE_IN_ALL
  99. void g_dataset_destroy (gconstpointer dataset_location);
  100. GLIB_AVAILABLE_IN_ALL
  101. gpointer g_dataset_id_get_data (gconstpointer dataset_location,
  102. GQuark key_id);
  103. GLIB_AVAILABLE_IN_ALL
  104. gpointer g_datalist_get_data (GData **datalist,
  105. const gchar *key);
  106. GLIB_AVAILABLE_IN_ALL
  107. void g_dataset_id_set_data_full (gconstpointer dataset_location,
  108. GQuark key_id,
  109. gpointer data,
  110. GDestroyNotify destroy_func);
  111. GLIB_AVAILABLE_IN_ALL
  112. gpointer g_dataset_id_remove_no_notify (gconstpointer dataset_location,
  113. GQuark key_id);
  114. GLIB_AVAILABLE_IN_ALL
  115. void g_dataset_foreach (gconstpointer dataset_location,
  116. GDataForeachFunc func,
  117. gpointer user_data);
  118. #define g_dataset_id_set_data(l, k, d) \
  119. g_dataset_id_set_data_full ((l), (k), (d), NULL)
  120. #define g_dataset_id_remove_data(l, k) \
  121. g_dataset_id_set_data ((l), (k), NULL)
  122. #define g_dataset_get_data(l, k) \
  123. (g_dataset_id_get_data ((l), g_quark_try_string (k)))
  124. #define g_dataset_set_data_full(l, k, d, f) \
  125. g_dataset_id_set_data_full ((l), g_quark_from_string (k), (d), (f))
  126. #define g_dataset_remove_no_notify(l, k) \
  127. g_dataset_id_remove_no_notify ((l), g_quark_try_string (k))
  128. #define g_dataset_set_data(l, k, d) \
  129. g_dataset_set_data_full ((l), (k), (d), NULL)
  130. #define g_dataset_remove_data(l, k) \
  131. g_dataset_id_set_data ((l), g_quark_try_string (k), NULL)
  132. G_END_DECLS
  133. #endif /* __G_DATASET_H__ */