1 /*
2  * Distributed under the Boost Software License, Version 1.0.
3  *    (See accompanying file LICENSE_1_0.txt or copy at
4  *          http://www.boost.org/LICENSE_1_0.txt)
5  */
6 module glib.gdataset;
7 
8 import glib.gtypes;
9 import glib.gquark;
10 
11 
12 struct GData;
13 
14 
15 extern (C) {
16 
17 
18     alias GDataForeachFunc = void function (GQuark         key_id,
19                                             gpointer       data,
20                                             gpointer       user_data);
21 
22 
23     void     g_datalist_init                (GData            **datalist);
24 
25     void     g_datalist_clear               (GData            **datalist);
26 
27     gpointer g_datalist_id_get_data         (GData            **datalist,
28                          GQuark             key_id);
29 
30     void     g_datalist_id_set_data_full    (GData            **datalist,
31                          GQuark             key_id,
32                          gpointer           data,
33                          GDestroyNotify     destroy_func);
34 
35     alias GDuplicateFunc = gpointer function(gpointer data, gpointer user_data);
36 
37 
38     gpointer g_datalist_id_dup_data         (GData            **datalist,
39                                              GQuark             key_id,
40                                              GDuplicateFunc     dup_func,
41                          gpointer           user_data);
42 
43     gboolean g_datalist_id_replace_data     (GData            **datalist,
44                                              GQuark             key_id,
45                                              gpointer           oldval,
46                                              gpointer           newval,
47                                              GDestroyNotify     destroy,
48                          GDestroyNotify    *old_destroy);
49 
50 
51     gpointer g_datalist_id_remove_no_notify (GData            **datalist,
52                          GQuark             key_id);
53 
54     void     g_datalist_foreach             (GData            **datalist,
55                          GDataForeachFunc   func,
56                          gpointer           user_data);
57 
58 
59 
60     void     g_datalist_set_flags           (GData            **datalist,
61                          guint              flags);
62 
63     void     g_datalist_unset_flags         (GData            **datalist,
64                          guint              flags);
65 
66     guint    g_datalist_get_flags           (GData            **datalist);
67 
68 }
69 
70 enum G_DATALIST_FLAGS_MASK = 0x3;
71 
72 auto g_datalist_id_set_data(DL, Q, D)(DL dl, Q q, D d) {
73     g_datalist_id_set_data_full(dl, q, d, null);
74 }
75 
76 auto g_datalist_id_remove_data(DL, Q)(DL dl, Q q) {
77     g_datalist_id_set_data(dl, q, null);
78 }
79 
80 auto g_datalist_set_data_full(DL, K, D, F)(DL dl, K k, D d, F f) {
81     g_datalist_id_set_data_full (dl, g_quark_from_string (k), d, f);
82 }
83 
84 auto g_datalist_remove_no_notify(DL, K)(DK dl, K k) {
85     return g_datalist_id_remove_no_notify (dl, g_quark_try_string (k));
86 }
87 
88 auto g_datalist_set_data(DL, K, D)(DL dl, K k, D d) {
89     g_datalist_set_data_full (dl, k, d, null);
90 }
91 
92 auto g_datalist_remove_data(DL, K)(DL dl, K k) {
93     g_datalist_id_set_data (dl, g_quark_try_string (k), null);
94 }
95 
96 extern (C) {
97 
98     void      g_dataset_destroy             (gconstpointer    dataset_location);
99 
100     gpointer  g_dataset_id_get_data         (gconstpointer    dataset_location,
101                                              GQuark           key_id);
102 
103     gpointer  g_datalist_get_data            (GData	 **datalist,
104                           const(gchar) *key);
105 
106     void      g_dataset_id_set_data_full    (gconstpointer    dataset_location,
107                                              GQuark           key_id,
108                                              gpointer         data,
109                                              GDestroyNotify   destroy_func);
110 
111     gpointer  g_dataset_id_remove_no_notify (gconstpointer    dataset_location,
112                                              GQuark           key_id);
113 
114     void      g_dataset_foreach             (gconstpointer    dataset_location,
115                                              GDataForeachFunc func,
116                                              gpointer         user_data);
117 
118 }
119 
120 auto g_dataset_id_set_data(L, K, D)(L l, K k, D d) {
121     g_dataset_id_set_data_full(l, k, d, null);
122 }
123 
124 auto g_dataset_id_remove_data(L, K)(L l, K k) {
125     g_dataset_id_set_data(l, k, null);
126 }
127 
128 auto g_dataset_get_data(L, K)(L l, K k) {
129     return g_dataset_id_get_data(l, g_quark_try_string(k));
130 }
131 
132 auto g_dataset_set_data_full(L, K, D, F)(L l, K k, D d, F f) {
133     g_dataset_id_set_data_full (l, g_quark_from_string (k), d, f);
134 }
135 
136 auto g_dataset_remove_no_notify(L, K)(L dl, K k) {
137     return g_dataset_id_remove_no_notify (l, g_quark_try_string (k));
138 }
139 
140 auto g_dataset_set_data(L, K, D)(L l, K k, D d) {
141     g_dataset_set_data_full (l, k, d, null);
142 }
143 
144 auto g_dataset_remove_data(L, K)(L l, K k) {
145     g_dataset_id_set_data (l, g_quark_try_string (k), null);
146 }
147