Debian Codegraph @

build-aux/templates/mbim-error-types.c.template

raw
1 /*** BEGIN file-header ***/
2 /*** END file-header ***/
3
4 /*** BEGIN file-production ***/
5 /* enumerations from "@filename@" */
6 /*** END file-production ***/
7
8 /*** BEGIN value-header ***/
9 static const G@Type@Value @enum_name@_values[] = {
10 /*** END value-header ***/
11 /*** BEGIN value-production ***/
12 { @VALUENAME@, "@VALUENAME@", "@valuenick@" },
13 /*** END value-production ***/
14 /*** BEGIN value-tail ***/
15 { 0, NULL, NULL }
16 };
17
18 /* @enum_name@_quark() implemented in mbim-errors-quarks.c */
19
20 GType
21 @enum_name@_get_type (void)
22 {
23 static gsize g_define_type_id_initialized = 0;
24
25 if (g_once_init_enter (&g_define_type_id_initialized)) {
26 GType g_define_type_id =
27 g_@type@_register_static (g_intern_static_string ("@EnumName@"),
28 @enum_name@_values);
29 g_once_init_leave (&g_define_type_id_initialized, g_define_type_id);
30 }
31
32 return g_define_type_id_initialized;
33 }
34
35 /* Enum-specific method to get the value as a string.
36 * We get the nick of the GEnumValue. Note that this will be
37 * valid even if the GEnumClass is not referenced anywhere. */
38 /**
39 * @enum_name@_get_string:
40 * @val: a @EnumName@.
41 *
42 * Gets the nickname string for the #@EnumName@ specified at @val.
43 *
44 * Returns: (transfer none): a string with the nickname, or %NULL if not found. Do not free the returned value.
45 */
46 const gchar *
47 @enum_name@_get_string (@EnumName@ val)
48 {
49 guint i;
50
51 for (i = 0; @enum_name@_values[i].value_nick; i++) {
52 if ((gint)val == @enum_name@_values[i].value)
53 return @enum_name@_values[i].value_nick;
54 }
55
56 return NULL;
57 }
58
59 /*** END value-tail ***/
60
61 /*** BEGIN file-tail ***/
62 /*** END file-tail ***/