williamr@2: /* GObject - GLib Type, Object, Parameter and Signal Library williamr@2: * Copyright (C) 1998-1999, 2000-2001 Tim Janik and Red Hat, Inc. williamr@2: * Portions copyright (c) 2006 Nokia Corporation. All rights reserved. williamr@2: * williamr@2: * This library is free software; you can redistribute it and/or williamr@2: * modify it under the terms of the GNU Lesser General Public williamr@2: * License as published by the Free Software Foundation; either williamr@2: * version 2 of the License, or (at your option) any later version. williamr@2: * williamr@2: * This library is distributed in the hope that it will be useful, williamr@2: * but WITHOUT ANY WARRANTY; without even the implied warranty of williamr@2: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU williamr@2: * Lesser General Public License for more details. williamr@2: * williamr@2: * You should have received a copy of the GNU Lesser General williamr@2: * Public License along with this library; if not, write to the williamr@2: * Free Software Foundation, Inc., 59 Temple Place, Suite 330, williamr@2: * Boston, MA 02111-1307, USA. williamr@2: */ williamr@2: #if !defined (__GLIB_GOBJECT_H_INSIDE__) && !defined (GOBJECT_COMPILATION) williamr@2: #error "Only can be included directly." williamr@2: #endif williamr@2: williamr@2: #ifndef __G_ENUMS_H__ williamr@2: #define __G_ENUMS_H__ williamr@2: williamr@2: #include <_ansi.h> williamr@2: #include williamr@2: williamr@2: G_BEGIN_DECLS williamr@2: williamr@2: /* --- type macros --- */ williamr@2: #define G_TYPE_IS_ENUM(type) (G_TYPE_FUNDAMENTAL (type) == G_TYPE_ENUM) williamr@2: #define G_ENUM_CLASS(class) (G_TYPE_CHECK_CLASS_CAST ((class), G_TYPE_ENUM, GEnumClass)) williamr@2: #define G_IS_ENUM_CLASS(class) (G_TYPE_CHECK_CLASS_TYPE ((class), G_TYPE_ENUM)) williamr@2: #define G_ENUM_CLASS_TYPE(class) (G_TYPE_FROM_CLASS (class)) williamr@2: #define G_ENUM_CLASS_TYPE_NAME(class) (g_type_name (G_ENUM_CLASS_TYPE (class))) williamr@2: #define G_TYPE_IS_FLAGS(type) (G_TYPE_FUNDAMENTAL (type) == G_TYPE_FLAGS) williamr@2: #define G_FLAGS_CLASS(class) (G_TYPE_CHECK_CLASS_CAST ((class), G_TYPE_FLAGS, GFlagsClass)) williamr@2: #define G_IS_FLAGS_CLASS(class) (G_TYPE_CHECK_CLASS_TYPE ((class), G_TYPE_FLAGS)) williamr@2: #define G_FLAGS_CLASS_TYPE(class) (G_TYPE_FROM_CLASS (class)) williamr@2: #define G_FLAGS_CLASS_TYPE_NAME(class) (g_type_name (G_FLAGS_CLASS_TYPE (class))) williamr@2: #define G_VALUE_HOLDS_ENUM(value) (G_TYPE_CHECK_VALUE_TYPE ((value), G_TYPE_ENUM)) williamr@2: #define G_VALUE_HOLDS_FLAGS(value) (G_TYPE_CHECK_VALUE_TYPE ((value), G_TYPE_FLAGS)) williamr@2: williamr@2: williamr@2: /* --- enum/flag values & classes --- */ williamr@2: typedef struct _GEnumClass GEnumClass; williamr@2: typedef struct _GFlagsClass GFlagsClass; williamr@2: typedef struct _GEnumValue GEnumValue; williamr@2: typedef struct _GFlagsValue GFlagsValue; williamr@2: struct _GEnumClass williamr@2: { williamr@2: GTypeClass g_type_class; williamr@2: williamr@2: /*< public >*/ williamr@2: gint minimum; williamr@2: gint maximum; williamr@2: guint n_values; williamr@2: GEnumValue *values; williamr@2: }; williamr@2: struct _GFlagsClass williamr@2: { williamr@2: GTypeClass g_type_class; williamr@2: williamr@2: /*< public >*/ williamr@2: guint mask; williamr@2: guint n_values; williamr@2: GFlagsValue *values; williamr@2: }; williamr@2: struct _GEnumValue williamr@2: { williamr@2: gint value; williamr@2: gchar *value_name; williamr@2: gchar *value_nick; williamr@2: }; williamr@2: struct _GFlagsValue williamr@2: { williamr@2: guint value; williamr@2: gchar *value_name; williamr@2: gchar *value_nick; williamr@2: }; williamr@2: williamr@2: williamr@2: /* --- prototypes --- */ williamr@2: IMPORT_C GEnumValue* g_enum_get_value (GEnumClass *enum_class, williamr@2: gint value); williamr@2: IMPORT_C GEnumValue* g_enum_get_value_by_name (GEnumClass *enum_class, williamr@2: const gchar *name); williamr@2: IMPORT_C GEnumValue* g_enum_get_value_by_nick (GEnumClass *enum_class, williamr@2: const gchar *nick); williamr@2: IMPORT_C GFlagsValue* g_flags_get_first_value (GFlagsClass *flags_class, williamr@2: guint value); williamr@2: IMPORT_C GFlagsValue* g_flags_get_value_by_name (GFlagsClass *flags_class, williamr@2: const gchar *name); williamr@2: IMPORT_C GFlagsValue* g_flags_get_value_by_nick (GFlagsClass *flags_class, williamr@2: const gchar *nick); williamr@2: IMPORT_C void g_value_set_enum (GValue *value, williamr@2: gint v_enum); williamr@2: IMPORT_C gint g_value_get_enum (const GValue *value); williamr@2: IMPORT_C void g_value_set_flags (GValue *value, williamr@2: guint v_flags); williamr@2: IMPORT_C guint g_value_get_flags (const GValue *value); williamr@2: williamr@2: williamr@2: williamr@2: /* --- registration functions --- */ williamr@2: /* const_static_values is a NULL terminated array of enum/flags williamr@2: * values that is taken over! williamr@2: */ williamr@2: IMPORT_C GType g_enum_register_static (const gchar *name, williamr@2: const GEnumValue *const_static_values); williamr@2: IMPORT_C GType g_flags_register_static (const gchar *name, williamr@2: const GFlagsValue *const_static_values); williamr@2: /* functions to complete the type information williamr@2: * for enums/flags implemented by plugins williamr@2: */ williamr@2: IMPORT_C void g_enum_complete_type_info (GType g_enum_type, williamr@2: GTypeInfo *info, williamr@2: const GEnumValue *const_values); williamr@2: IMPORT_C void g_flags_complete_type_info (GType g_flags_type, williamr@2: GTypeInfo *info, williamr@2: const GFlagsValue *const_values); williamr@2: williamr@2: G_END_DECLS williamr@2: williamr@2: #endif /* __G_ENUMS_H__ */