
/* This file is generated by glib-mkenums, do not modify it. This code is licensed under the same license as the containing project. Note that it links to GLib, so must comply with the LGPL linking clauses. */

#include "qmi-flag-types-private.h"
/* enumerations from "../git/src/libqmi-glib/qmi-enums-private.h" */
static const GFlagsValue qmi_ctl_flag_values[] = {
    { QMI_CTL_FLAG_NONE, "QMI_CTL_FLAG_NONE", "none" },
    { QMI_CTL_FLAG_RESPONSE, "QMI_CTL_FLAG_RESPONSE", "response" },
    { QMI_CTL_FLAG_INDICATION, "QMI_CTL_FLAG_INDICATION", "indication" },
    { 0, NULL, NULL }
};

/* Define type-specific symbols */

GType
qmi_ctl_flag_get_type (void)
{
    static gsize g_define_type_id_initialized = 0;

    if (g_once_init_enter (&g_define_type_id_initialized)) {
        GType g_define_type_id =
            g_flags_register_static (g_intern_static_string ("QmiCtlFlag"),
                                      qmi_ctl_flag_values);
        g_once_init_leave (&g_define_type_id_initialized, g_define_type_id);
    }

    return g_define_type_id_initialized;
}

/* Flags-specific method to build a string with the given mask.
 * We get a comma separated list of the nicks of the GFlagsValues.
 * Note that this will be valid even if the GFlagsClass is not referenced
 * anywhere. */
gchar *
qmi_ctl_flag_build_string_from_mask (QmiCtlFlag mask)
{
    guint i;
    gboolean first = TRUE;
    GString *str = NULL;

    for (i = 0; qmi_ctl_flag_values[i].value_nick; i++) {
        /* We also look for exact matches */
      if ((guint)mask == qmi_ctl_flag_values[i].value) {
            if (str)
                g_string_free (str, TRUE);
            return g_strdup (qmi_ctl_flag_values[i].value_nick);
        }

        /* Build list with single-bit masks */
        if (mask & qmi_ctl_flag_values[i].value) {
            guint c;
            gulong number = qmi_ctl_flag_values[i].value;

            for (c = 0; number; c++)
                number &= number - 1;

            if (c == 1) {
                if (!str)
                    str = g_string_new ("");
                g_string_append_printf (str, "%s%s",
                                        first ? "" : ", ",
                                        qmi_ctl_flag_values[i].value_nick);
                if (first)
                    first = FALSE;
            }
        }
    }

    return (str ? g_string_free (str, FALSE) : NULL);
}
static const GFlagsValue qmi_service_flag_values[] = {
    { QMI_SERVICE_FLAG_NONE, "QMI_SERVICE_FLAG_NONE", "none" },
    { QMI_SERVICE_FLAG_COMPOUND, "QMI_SERVICE_FLAG_COMPOUND", "compound" },
    { QMI_SERVICE_FLAG_RESPONSE, "QMI_SERVICE_FLAG_RESPONSE", "response" },
    { QMI_SERVICE_FLAG_INDICATION, "QMI_SERVICE_FLAG_INDICATION", "indication" },
    { 0, NULL, NULL }
};

/* Define type-specific symbols */

GType
qmi_service_flag_get_type (void)
{
    static gsize g_define_type_id_initialized = 0;

    if (g_once_init_enter (&g_define_type_id_initialized)) {
        GType g_define_type_id =
            g_flags_register_static (g_intern_static_string ("QmiServiceFlag"),
                                      qmi_service_flag_values);
        g_once_init_leave (&g_define_type_id_initialized, g_define_type_id);
    }

    return g_define_type_id_initialized;
}

/* Flags-specific method to build a string with the given mask.
 * We get a comma separated list of the nicks of the GFlagsValues.
 * Note that this will be valid even if the GFlagsClass is not referenced
 * anywhere. */
gchar *
qmi_service_flag_build_string_from_mask (QmiServiceFlag mask)
{
    guint i;
    gboolean first = TRUE;
    GString *str = NULL;

    for (i = 0; qmi_service_flag_values[i].value_nick; i++) {
        /* We also look for exact matches */
      if ((guint)mask == qmi_service_flag_values[i].value) {
            if (str)
                g_string_free (str, TRUE);
            return g_strdup (qmi_service_flag_values[i].value_nick);
        }

        /* Build list with single-bit masks */
        if (mask & qmi_service_flag_values[i].value) {
            guint c;
            gulong number = qmi_service_flag_values[i].value;

            for (c = 0; number; c++)
                number &= number - 1;

            if (c == 1) {
                if (!str)
                    str = g_string_new ("");
                g_string_append_printf (str, "%s%s",
                                        first ? "" : ", ",
                                        qmi_service_flag_values[i].value_nick);
                if (first)
                    first = FALSE;
            }
        }
    }

    return (str ? g_string_free (str, FALSE) : NULL);
}

/* Generated data ends here */

