0376cac979d5965f3d2d80a18b54188c78c8dd02
[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 #ifndef __G_DATASET_H__
28 #define __G_DATASET_H__
29
30 #include <glib/gquark.h>
31
32 G_BEGIN_DECLS
33
34 typedef struct _GData           GData;
35
36 typedef void            (*GDataForeachFunc)     (GQuark         key_id,
37                                                  gpointer       data,
38                                                  gpointer       user_data);
39
40 /* Keyed Data List
41  */
42 void     g_datalist_init                (GData            **datalist);
43 void     g_datalist_clear               (GData            **datalist);
44 gpointer g_datalist_id_get_data         (GData            **datalist,
45                                          GQuark             key_id);
46 void     g_datalist_id_set_data_full    (GData            **datalist,
47                                          GQuark             key_id,
48                                          gpointer           data,
49                                          GDestroyNotify     destroy_func);
50 gpointer g_datalist_id_remove_no_notify (GData            **datalist,
51                                          GQuark             key_id);
52 void     g_datalist_foreach             (GData            **datalist,
53                                          GDataForeachFunc   func,
54                                          gpointer           user_data);
55
56 /**
57  * G_DATALIST_FLAGS_MASK:
58  *
59  * A bitmask that restricts the possible flags passed to
60  * g_datalist_set_flags(). Passing a flags value where
61  * flags & ~G_DATALIST_FLAGS_MASK != 0 is an error.
62  */
63 #define G_DATALIST_FLAGS_MASK 0x3
64
65 void     g_datalist_set_flags           (GData            **datalist,
66                                          guint              flags);
67 void     g_datalist_unset_flags         (GData            **datalist,
68                                          guint              flags);
69 guint    g_datalist_get_flags           (GData            **datalist);
70
71 #define   g_datalist_id_set_data(dl, q, d)      \
72      g_datalist_id_set_data_full ((dl), (q), (d), NULL)
73 #define   g_datalist_id_remove_data(dl, q)      \
74      g_datalist_id_set_data ((dl), (q), NULL)
75 #define   g_datalist_get_data(dl, k)            \
76      (g_datalist_id_get_data ((dl), g_quark_try_string (k)))
77 #define   g_datalist_set_data_full(dl, k, d, f) \
78      g_datalist_id_set_data_full ((dl), g_quark_from_string (k), (d), (f))
79 #define   g_datalist_remove_no_notify(dl, k)    \
80      g_datalist_id_remove_no_notify ((dl), g_quark_try_string (k))
81 #define   g_datalist_set_data(dl, k, d)         \
82      g_datalist_set_data_full ((dl), (k), (d), NULL)
83 #define   g_datalist_remove_data(dl, k)         \
84      g_datalist_id_set_data ((dl), g_quark_try_string (k), NULL)
85
86
87 /* Location Associated Keyed Data
88  */
89 void      g_dataset_destroy             (gconstpointer    dataset_location);
90 gpointer  g_dataset_id_get_data         (gconstpointer    dataset_location,
91                                          GQuark           key_id);
92 void      g_dataset_id_set_data_full    (gconstpointer    dataset_location,
93                                          GQuark           key_id,
94                                          gpointer         data,
95                                          GDestroyNotify   destroy_func);
96 gpointer  g_dataset_id_remove_no_notify (gconstpointer    dataset_location,
97                                          GQuark           key_id);
98 void      g_dataset_foreach             (gconstpointer    dataset_location,
99                                          GDataForeachFunc func,
100                                          gpointer         user_data);
101 #define   g_dataset_id_set_data(l, k, d)        \
102      g_dataset_id_set_data_full ((l), (k), (d), NULL)
103 #define   g_dataset_id_remove_data(l, k)        \
104      g_dataset_id_set_data ((l), (k), NULL)
105 #define   g_dataset_get_data(l, k)              \
106      (g_dataset_id_get_data ((l), g_quark_try_string (k)))
107 #define   g_dataset_set_data_full(l, k, d, f)   \
108      g_dataset_id_set_data_full ((l), g_quark_from_string (k), (d), (f))
109 #define   g_dataset_remove_no_notify(l, k)      \
110      g_dataset_id_remove_no_notify ((l), g_quark_try_string (k))
111 #define   g_dataset_set_data(l, k, d)           \
112      g_dataset_set_data_full ((l), (k), (d), NULL)
113 #define   g_dataset_remove_data(l, k)           \
114      g_dataset_id_set_data ((l), g_quark_try_string (k), NULL)
115
116 G_END_DECLS
117
118 #endif /* __G_DATASET_H__ */
119
120
121
122