## Enums and Flags

Enums and Flags — Enumeration and flags types

## Synopsis

    #include <gobject.h>

    struct      GEnumClass;
    struct      GFlagsClass;
    #define     G_ENUM_CLASS_TYPE               (class)
    #define     G_ENUM_CLASS_TYPE_NAME          (class)
    #define     G_TYPE_IS_ENUM                  (type)
    #define     G_ENUM_CLASS                    (class)
    #define     G_IS_ENUM_CLASS                 (class)
    #define     G_TYPE_IS_FLAGS                 (type)
    #define     G_FLAGS_CLASS                   (class)
    #define     G_IS_FLAGS_CLASS                (class)
    #define     G_FLAGS_CLASS_TYPE              (class)
    #define     G_FLAGS_CLASS_TYPE_NAME         (class)
    struct      GEnumValue;
    struct      GFlagsValue;
    GEnumValue* g_enum_get_value                (GEnumClass *enum_class,
                                                 gint value);
    GEnumValue* g_enum_get_value_by_name        (GEnumClass *enum_class,
                                                 const gchar *name);
    GEnumValue* g_enum_get_value_by_nick        (GEnumClass *enum_class,
                                                 const gchar *nick);
    GFlagsValue* g_flags_get_first_value        (GFlagsClass *flags_class,
                                                 guint value);
    GFlagsValue* g_flags_get_value_by_name      (GFlagsClass *flags_class,
                                                 const gchar *name);
    GFlagsValue* g_flags_get_value_by_nick      (GFlagsClass *flags_class,
                                                 const gchar *nick);
    GType       g_enum_register_static          (const gchar *name,
                                                 const GEnumValue *const_static_values);
    GType       g_flags_register_static         (const gchar *name,
                                                 const GFlagsValue *const_static_values);
    void        g_enum_complete_type_info       (GType g_enum_type,
                                                 GTypeInfo *info,
                                                 const GEnumValue *const_values);
    void        g_flags_complete_type_info      (GType g_flags_type,
                                                 GTypeInfo *info,
                                                 const GFlagsValue *const_values);

## Description

## Details

### struct GEnumClass

    struct GEnumClass {

      GTypeClass  g_type_class;

      gint	      minimum;
      gint	      maximum;
      guint	      n_values;
      GEnumValue *values;
    };

### struct GFlagsClass

    struct GFlagsClass {

      GTypeClass   g_type_class;

      guint	       mask;
      guint	       n_values;
      GFlagsValue *values;
    };

### G_ENUM_CLASS_TYPE()

    #define G_ENUM_CLASS_TYPE(class)       (G_TYPE_FROM_CLASS (class))

Returns the type identifier from a given GEnumClass structure.

`class` : | a GEnumClass

### G_ENUM_CLASS_TYPE_NAME()

    #define G_ENUM_CLASS_TYPE_NAME(class)  (g_type_name (G_ENUM_CLASS_TYPE (class)))

Returns the static type name from a given GEnumClass structure.

`class` : | a GEnumClass

### G_TYPE_IS_ENUM()

    #define G_TYPE_IS_ENUM(type)	       (G_TYPE_FUNDAMENTAL (type) == G_TYPE_ENUM)

Returns whether `type` "is a" `G_TYPE_ENUM`.

`type` : | a GType ID.

### G_ENUM_CLASS()

    #define G_ENUM_CLASS(class)	       (G_TYPE_CHECK_CLASS_CAST ((class), G_TYPE_ENUM, GEnumClass))

Casts a derived GEnumClass structure into a GEnumClass structure.

`class` : | a valid GEnumClass

### G_IS_ENUM_CLASS()

    #define G_IS_ENUM_CLASS(class)	       (G_TYPE_CHECK_CLASS_TYPE ((class), G_TYPE_ENUM))

Checks whether `class` "is a" valid GEnumClass structure of type `G_TYPE_ENUM` or derived.

`class` : | a GEnumClass

### G_TYPE_IS_FLAGS()

    #define G_TYPE_IS_FLAGS(type)	       (G_TYPE_FUNDAMENTAL (type) == G_TYPE_FLAGS)

Returns whether `type` "is a" `G_TYPE_FLAGS`.

`type` : | a GType ID.

### G_FLAGS_CLASS()

    #define G_FLAGS_CLASS(class)	       (G_TYPE_CHECK_CLASS_CAST ((class), G_TYPE_FLAGS, GFlagsClass))

Casts a derived GFlagsClass structure into a GFlagsClass structure.

`class` : | a valid GFlagsClass

### G_IS_FLAGS_CLASS()

    #define G_IS_FLAGS_CLASS(class)        (G_TYPE_CHECK_CLASS_TYPE ((class), G_TYPE_FLAGS))

Checks whether `class` "is a" valid GFlagsClass structure of type `G_TYPE_FLAGS` or derived.

`class` : | a GFlagsClass

### G_FLAGS_CLASS_TYPE()

    #define G_FLAGS_CLASS_TYPE(class)      (G_TYPE_FROM_CLASS (class))

Returns the type identifier from a given GFlagsClass structure.

`class` : | a GFlagsClass

### G_FLAGS_CLASS_TYPE_NAME()

    #define G_FLAGS_CLASS_TYPE_NAME(class) (g_type_name (G_FLAGS_TYPE (class)))

Returns the static type name from a given GFlagsClass structure.

`class` : | a GFlagsClass

### struct GEnumValue

    struct GEnumValue {

      gint	 value;
      gchar *value_name;
      gchar *value_nick;
    };

### struct GFlagsValue

    struct GFlagsValue {

      guint	 value;
      gchar *value_name;
      gchar *value_nick;
    };

### g_enum_get_value ()

    GEnumValue* g_enum_get_value                (GEnumClass *enum_class,
                                                 gint value);

`enum_class` : |
`value` : |
Returns : |

### g_enum_get_value_by_name ()

    GEnumValue* g_enum_get_value_by_name        (GEnumClass *enum_class,
                                                 const gchar *name);

`enum_class` : |
`name` : |
Returns : |

### g_enum_get_value_by_nick ()

    GEnumValue* g_enum_get_value_by_nick        (GEnumClass *enum_class,
                                                 const gchar *nick);

`enum_class` : |
`nick` : |
Returns : |

### g_flags_get_first_value ()

    GFlagsValue* g_flags_get_first_value        (GFlagsClass *flags_class,
                                                 guint value);

`flags_class` : |
`value` : |
Returns : |

### g_flags_get_value_by_name ()

    GFlagsValue* g_flags_get_value_by_name      (GFlagsClass *flags_class,
                                                 const gchar *name);

`flags_class` : |
`name` : |
Returns : |

### g_flags_get_value_by_nick ()

    GFlagsValue* g_flags_get_value_by_nick      (GFlagsClass *flags_class,
                                                 const gchar *nick);

`flags_class` : |
`nick` : |
Returns : |

### g_enum_register_static ()

    GType       g_enum_register_static          (const gchar *name,
                                                 const GEnumValue *const_static_values);

`name` : |
`const_static_values` : |
Returns : |

### g_flags_register_static ()

    GType       g_flags_register_static         (const gchar *name,
                                                 const GFlagsValue *const_static_values);

`name` : |
`const_static_values` : |
Returns : |

### g_enum_complete_type_info ()

    void        g_enum_complete_type_info       (GType g_enum_type,
                                                 GTypeInfo *info,
                                                 const GEnumValue *const_values);

`g_enum_type` : |
`info` : |
`const_values` : |

### g_flags_complete_type_info ()

    void        g_flags_complete_type_info      (GType g_flags_type,
                                                 GTypeInfo *info,
                                                 const GFlagsValue *const_values);

`g_flags_type` : |
`info` : |
`const_values` : |