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