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.gvarianttype;
7 
8 import glib.gtypes;
9 import glib.gmessages;
10 
11 struct GVariantType;
12 
13 // /**
14 //  * G_VARIANT_TYPE_BOOLEAN:
15 //  *
16 //  * The type of a value that can be either %TRUE or %FALSE.
17 //  **/
18 // #define G_VARIANT_TYPE_BOOLEAN              ((const GVariantType *) "b")
19 //
20 // /**
21 //  * G_VARIANT_TYPE_BYTE:
22 //  *
23 //  * The type of an integer value that can range from 0 to 255.
24 //  **/
25 // #define G_VARIANT_TYPE_BYTE                 ((const GVariantType *) "y")
26 //
27 // /**
28 //  * G_VARIANT_TYPE_INT16:
29 //  *
30 //  * The type of an integer value that can range from -32768 to 32767.
31 //  **/
32 // #define G_VARIANT_TYPE_INT16                ((const GVariantType *) "n")
33 //
34 // /**
35 //  * G_VARIANT_TYPE_UINT16:
36 //  *
37 //  * The type of an integer value that can range from 0 to 65535.
38 //  * There were about this many people living in Toronto in the 1870s.
39 //  **/
40 // #define G_VARIANT_TYPE_UINT16               ((const GVariantType *) "q")
41 //
42 // /**
43 //  * G_VARIANT_TYPE_INT32:
44 //  *
45 //  * The type of an integer value that can range from -2147483648 to
46 //  * 2147483647.
47 //  **/
48 // #define G_VARIANT_TYPE_INT32                ((const GVariantType *) "i")
49 //
50 // /**
51 //  * G_VARIANT_TYPE_UINT32:
52 //  *
53 //  * The type of an integer value that can range from 0 to 4294967295.
54 //  * That's one number for everyone who was around in the late 1970s.
55 //  **/
56 // #define G_VARIANT_TYPE_UINT32               ((const GVariantType *) "u")
57 //
58 // /**
59 //  * G_VARIANT_TYPE_INT64:
60 //  *
61 //  * The type of an integer value that can range from
62 //  * -9223372036854775808 to 9223372036854775807.
63 //  **/
64 // #define G_VARIANT_TYPE_INT64                ((const GVariantType *) "x")
65 //
66 // /**
67 //  * G_VARIANT_TYPE_UINT64:
68 //  *
69 //  * The type of an integer value that can range from 0 to
70 //  * 18446744073709551616.  That's a really big number, but a Rubik's
71 //  * cube can have a bit more than twice as many possible positions.
72 //  **/
73 // #define G_VARIANT_TYPE_UINT64               ((const GVariantType *) "t")
74 //
75 // /**
76 //  * G_VARIANT_TYPE_DOUBLE:
77 //  *
78 //  * The type of a double precision IEEE754 floating point number.
79 //  * These guys go up to about 1.80e308 (plus and minus) but miss out on
80 //  * some numbers in between.  In any case, that's far greater than the
81 //  * estimated number of fundamental particles in the observable
82 //  * universe.
83 //  **/
84 // #define G_VARIANT_TYPE_DOUBLE               ((const GVariantType *) "d")
85 //
86 // /**
87 //  * G_VARIANT_TYPE_STRING:
88 //  *
89 //  * The type of a string.  "" is a string.  %NULL is not a string.
90 //  **/
91 // #define G_VARIANT_TYPE_STRING               ((const GVariantType *) "s")
92 //
93 // /**
94 //  * G_VARIANT_TYPE_OBJECT_PATH:
95 //  *
96 //  * The type of a D-Bus object reference.  These are strings of a
97 //  * specific format used to identify objects at a given destination on
98 //  * the bus.
99 //  *
100 //  * If you are not interacting with D-Bus, then there is no reason to make
101 //  * use of this type.  If you are, then the D-Bus specification contains a
102 //  * precise description of valid object paths.
103 //  **/
104 // #define G_VARIANT_TYPE_OBJECT_PATH          ((const GVariantType *) "o")
105 //
106 // /**
107 //  * G_VARIANT_TYPE_SIGNATURE:
108 //  *
109 //  * The type of a D-Bus type signature.  These are strings of a specific
110 //  * format used as type signatures for D-Bus methods and messages.
111 //  *
112 //  * If you are not interacting with D-Bus, then there is no reason to make
113 //  * use of this type.  If you are, then the D-Bus specification contains a
114 //  * precise description of valid signature strings.
115 //  **/
116 // #define G_VARIANT_TYPE_SIGNATURE            ((const GVariantType *) "g")
117 //
118 // /**
119 //  * G_VARIANT_TYPE_VARIANT:
120 //  *
121 //  * The type of a box that contains any other value (including another
122 //  * variant).
123 //  **/
124 // #define G_VARIANT_TYPE_VARIANT              ((const GVariantType *) "v")
125 //
126 // /**
127 //  * G_VARIANT_TYPE_HANDLE:
128 //  *
129 //  * The type of a 32bit signed integer value, that by convention, is used
130 //  * as an index into an array of file descriptors that are sent alongside
131 //  * a D-Bus message.
132 //  *
133 //  * If you are not interacting with D-Bus, then there is no reason to make
134 //  * use of this type.
135 //  **/
136 // #define G_VARIANT_TYPE_HANDLE               ((const GVariantType *) "h")
137 //
138 // /**
139 //  * G_VARIANT_TYPE_UNIT:
140 //  *
141 //  * The empty tuple type.  Has only one instance.  Known also as "triv"
142 //  * or "void".
143 //  **/
144 // #define G_VARIANT_TYPE_UNIT                 ((const GVariantType *) "()")
145 //
146 // /**
147 //  * G_VARIANT_TYPE_ANY:
148 //  *
149 //  * An indefinite type that is a supertype of every type (including
150 //  * itself).
151 //  **/
152 // #define G_VARIANT_TYPE_ANY                  ((const GVariantType *) "*")
153 //
154 // /**
155 //  * G_VARIANT_TYPE_BASIC:
156 //  *
157 //  * An indefinite type that is a supertype of every basic (ie:
158 //  * non-container) type.
159 //  **/
160 // #define G_VARIANT_TYPE_BASIC                ((const GVariantType *) "?")
161 //
162 // /**
163 //  * G_VARIANT_TYPE_MAYBE:
164 //  *
165 //  * An indefinite type that is a supertype of every maybe type.
166 //  **/
167 // #define G_VARIANT_TYPE_MAYBE                ((const GVariantType *) "m*")
168 //
169 // /**
170 //  * G_VARIANT_TYPE_ARRAY:
171 //  *
172 //  * An indefinite type that is a supertype of every array type.
173 //  **/
174 // #define G_VARIANT_TYPE_ARRAY                ((const GVariantType *) "a*")
175 //
176 // /**
177 //  * G_VARIANT_TYPE_TUPLE:
178 //  *
179 //  * An indefinite type that is a supertype of every tuple type,
180 //  * regardless of the number of items in the tuple.
181 //  **/
182 // #define G_VARIANT_TYPE_TUPLE                ((const GVariantType *) "r")
183 //
184 // /**
185 //  * G_VARIANT_TYPE_DICT_ENTRY:
186 //  *
187 //  * An indefinite type that is a supertype of every dictionary entry
188 //  * type.
189 //  **/
190 // #define G_VARIANT_TYPE_DICT_ENTRY           ((const GVariantType *) "{?*}")
191 //
192 // /**
193 //  * G_VARIANT_TYPE_DICTIONARY:
194 //  *
195 //  * An indefinite type that is a supertype of every dictionary type --
196 //  * that is, any array type that has an element type equal to any
197 //  * dictionary entry type.
198 //  **/
199 // #define G_VARIANT_TYPE_DICTIONARY           ((const GVariantType *) "a{?*}")
200 //
201 // /**
202 //  * G_VARIANT_TYPE_STRING_ARRAY:
203 //  *
204 //  * The type of an array of strings.
205 //  **/
206 // #define G_VARIANT_TYPE_STRING_ARRAY         ((const GVariantType *) "as")
207 //
208 // /**
209 //  * G_VARIANT_TYPE_OBJECT_PATH_ARRAY:
210 //  *
211 //  * The type of an array of object paths.
212 //  **/
213 // #define G_VARIANT_TYPE_OBJECT_PATH_ARRAY    ((const GVariantType *) "ao")
214 //
215 // /**
216 //  * G_VARIANT_TYPE_BYTESTRING:
217 //  *
218 //  * The type of an array of bytes.  This type is commonly used to pass
219 //  * around strings that may not be valid utf8.  In that case, the
220 //  * convention is that the nul terminator character should be included as
221 //  * the last character in the array.
222 //  **/
223 // #define G_VARIANT_TYPE_BYTESTRING           ((const GVariantType *) "ay")
224 //
225 // /**
226 //  * G_VARIANT_TYPE_BYTESTRING_ARRAY:
227 //  *
228 //  * The type of an array of byte strings (an array of arrays of bytes).
229 //  **/
230 // #define G_VARIANT_TYPE_BYTESTRING_ARRAY     ((const GVariantType *) "aay")
231 //
232 // /**
233 //  * G_VARIANT_TYPE_VARDICT:
234 //  *
235 //  * The type of a dictionary mapping strings to variants (the ubiquitous
236 //  * "a{sv}" type).
237 //  *
238 //  * Since: 2.30
239 //  **/
240 // #define G_VARIANT_TYPE_VARDICT              ((const GVariantType *) "a{sv}")
241 //
242 //
243 // /**
244 //  * G_VARIANT_TYPE:
245 //  * @type_string: a well-formed #GVariantType type string
246 //  *
247 //  * Converts a string to a const #GVariantType.  Depending on the
248 //  * current debugging level, this function may perform a runtime check
249 //  * to ensure that @string is a valid GVariant type string.
250 //  *
251 //  * It is always a programmer error to use this macro with an invalid
252 //  * type string. If in doubt, use g_variant_type_string_is_valid() to
253 //  * check if the string is valid.
254 //  *
255 //  * Since 2.24
256 //  **/
257 // #ifndef G_DISABLE_CHECKS
258 // # define G_VARIANT_TYPE(type_string)            (g_variant_type_checked_ ((type_string)))
259 // #else
260 // # define G_VARIANT_TYPE(type_string)            ((const GVariantType *) (type_string))
261 // #endif
262 
263 /* type string checking */
264 
265 extern (C) {
266 
267 
268 gboolean                        g_variant_type_string_is_valid          (const(gchar)         *type_string);
269 
270 gboolean                        g_variant_type_string_scan              (const(gchar)         *string,
271                                                                          const(gchar)         *limit,
272                                                                          const(gchar)        **endptr);
273 
274 /* create/destroy */
275 
276 void                            g_variant_type_free                     (GVariantType        *type);
277 
278 GVariantType *                  g_variant_type_copy                     (const(GVariantType)  *type);
279 
280 GVariantType *                  g_variant_type_new                      (const(gchar)         *type_string);
281 
282 /* getters */
283 
284 gsize                           g_variant_type_get_string_length        (const(GVariantType)  *type);
285 
286 const(gchar) *                   g_variant_type_peek_string              (const(GVariantType)  *type);
287 
288 gchar *                         g_variant_type_dup_string               (const(GVariantType)  *type);
289 
290 /* classification */
291 
292 gboolean                        g_variant_type_is_definite              (const(GVariantType)  *type);
293 
294 gboolean                        g_variant_type_is_container             (const(GVariantType)  *type);
295 
296 gboolean                        g_variant_type_is_basic                 (const(GVariantType)  *type);
297 
298 gboolean                        g_variant_type_is_maybe                 (const(GVariantType)  *type);
299 
300 gboolean                        g_variant_type_is_array                 (const(GVariantType)  *type);
301 
302 gboolean                        g_variant_type_is_tuple                 (const(GVariantType)  *type);
303 
304 gboolean                        g_variant_type_is_dict_entry            (const(GVariantType)  *type);
305 
306 gboolean                        g_variant_type_is_variant               (const(GVariantType)  *type);
307 
308 /* for hash tables */
309 
310 guint                           g_variant_type_hash                     (gconstpointer        type);
311 
312 gboolean                        g_variant_type_equal                    (gconstpointer        type1,
313                                                                          gconstpointer        type2);
314 
315 /* subtypes */
316 
317 gboolean                        g_variant_type_is_subtype_of            (const(GVariantType)  *type,
318                                                                          const(GVariantType)  *supertype);
319 
320 /* type iterator interface */
321 
322     const(GVariantType) *            g_variant_type_element                  (const(GVariantType)  *type);
323 
324     const(GVariantType) *            g_variant_type_first                    (const(GVariantType)  *type);
325 
326     const(GVariantType) *            g_variant_type_next                     (const(GVariantType)  *type);
327 
328     gsize                           g_variant_type_n_items                  (const(GVariantType)  *type);
329 
330     const(GVariantType) *            g_variant_type_key                      (const(GVariantType)  *type);
331 
332     const(GVariantType) *            g_variant_type_value                    (const(GVariantType)  *type);
333 
334     /* constructors */
335 
336     GVariantType *                  g_variant_type_new_array                (const(GVariantType)  *element);
337 
338     GVariantType *                  g_variant_type_new_maybe                (const(GVariantType)  *element);
339 
340     GVariantType *                  g_variant_type_new_tuple                (const(GVariantType*) *items,
341                                                                              gint                 length);
342 
343     GVariantType *                  g_variant_type_new_dict_entry           (const(GVariantType)  *key,
344                                                                              const(GVariantType)  *value);
345 
346     /*< private >*/
347 
348     const(GVariantType) *            g_variant_type_checked_                 (const(gchar) *);
349 
350 }
351