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