1 /* GLIB - Library of useful routines for C programming
2 * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
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.
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.
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/>.
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/.
25 #ifndef __G_DATASET_H__
26 #define __G_DATASET_H__
28 #if !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION)
29 #error "Only <glib.h> can be included directly."
32 #include <glib/gquark.h>
36 typedef struct _GData GData
;
38 typedef void (*GDataForeachFunc
) (GQuark key_id
,
45 void g_datalist_init (GData
**datalist
);
47 void g_datalist_clear (GData
**datalist
);
49 gpointer
g_datalist_id_get_data (GData
**datalist
,
52 void g_datalist_id_set_data_full (GData
**datalist
,
55 GDestroyNotify destroy_func
);
57 typedef gpointer (*GDuplicateFunc
) (gpointer data
, gpointer user_data
);
59 GLIB_AVAILABLE_IN_2_34
60 gpointer
g_datalist_id_dup_data (GData
**datalist
,
62 GDuplicateFunc dup_func
,
64 GLIB_AVAILABLE_IN_2_34
65 gboolean
g_datalist_id_replace_data (GData
**datalist
,
69 GDestroyNotify destroy
,
70 GDestroyNotify
*old_destroy
);
73 gpointer
g_datalist_id_remove_no_notify (GData
**datalist
,
76 void g_datalist_foreach (GData
**datalist
,
77 GDataForeachFunc func
,
81 * G_DATALIST_FLAGS_MASK:
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.
87 #define G_DATALIST_FLAGS_MASK 0x3
90 void g_datalist_set_flags (GData
**datalist
,
93 void g_datalist_unset_flags (GData
**datalist
,
96 guint
g_datalist_get_flags (GData
**datalist
);
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)
111 /* Location Associated Keyed Data
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
,
118 GLIB_AVAILABLE_IN_ALL
119 gpointer
g_datalist_get_data (GData
**datalist
,
121 GLIB_AVAILABLE_IN_ALL
122 void g_dataset_id_set_data_full (gconstpointer dataset_location
,
125 GDestroyNotify destroy_func
);
126 GLIB_AVAILABLE_IN_ALL
127 gpointer
g_dataset_id_remove_no_notify (gconstpointer dataset_location
,
129 GLIB_AVAILABLE_IN_ALL
130 void g_dataset_foreach (gconstpointer dataset_location
,
131 GDataForeachFunc func
,
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)
150 #endif /* __G_DATASET_H__ */