source: trunk/third/glib2/gobject/genums.h @ 20721

Revision 20721, 4.3 KB checked in by ghudson, 20 years ago (diff)
This commit was generated by cvs2svn to compensate for changes in r20720, which included commits to RCS files with non-trunk default branches.
Line 
1/* GObject - GLib Type, Object, Parameter and Signal Library
2 * Copyright (C) 1998-1999, 2000-2001 Tim Janik and Red Hat, Inc.
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General
15 * Public License along with this library; if not, write to the
16 * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
17 * Boston, MA 02111-1307, USA.
18 */
19#if !defined (__GLIB_GOBJECT_H_INSIDE__) && !defined (GOBJECT_COMPILATION)
20#error "Only <glib-object.h> can be included directly."
21#endif
22
23#ifndef __G_ENUMS_H__
24#define __G_ENUMS_H__
25
26#include <gobject/gtype.h>
27
28G_BEGIN_DECLS
29
30/* --- type macros --- */
31#define G_TYPE_IS_ENUM(type)           (G_TYPE_FUNDAMENTAL (type) == G_TYPE_ENUM)
32#define G_ENUM_CLASS(class)            (G_TYPE_CHECK_CLASS_CAST ((class), G_TYPE_ENUM, GEnumClass))
33#define G_IS_ENUM_CLASS(class)         (G_TYPE_CHECK_CLASS_TYPE ((class), G_TYPE_ENUM))
34#define G_ENUM_CLASS_TYPE(class)       (G_TYPE_FROM_CLASS (class))
35#define G_ENUM_CLASS_TYPE_NAME(class)  (g_type_name (G_ENUM_CLASS_TYPE (class)))
36#define G_TYPE_IS_FLAGS(type)          (G_TYPE_FUNDAMENTAL (type) == G_TYPE_FLAGS)
37#define G_FLAGS_CLASS(class)           (G_TYPE_CHECK_CLASS_CAST ((class), G_TYPE_FLAGS, GFlagsClass))
38#define G_IS_FLAGS_CLASS(class)        (G_TYPE_CHECK_CLASS_TYPE ((class), G_TYPE_FLAGS))
39#define G_FLAGS_CLASS_TYPE(class)      (G_TYPE_FROM_CLASS (class))
40#define G_FLAGS_CLASS_TYPE_NAME(class) (g_type_name (G_FLAGS_TYPE (class)))
41#define G_VALUE_HOLDS_ENUM(value)      (G_TYPE_CHECK_VALUE_TYPE ((value), G_TYPE_ENUM))
42#define G_VALUE_HOLDS_FLAGS(value)     (G_TYPE_CHECK_VALUE_TYPE ((value), G_TYPE_FLAGS))
43
44
45/* --- enum/flag values & classes --- */
46typedef struct _GEnumClass  GEnumClass;
47typedef struct _GFlagsClass GFlagsClass;
48typedef struct _GEnumValue  GEnumValue;
49typedef struct _GFlagsValue GFlagsValue;
50struct  _GEnumClass
51{
52  GTypeClass  g_type_class;
53
54  /*< public >*/ 
55  gint        minimum;
56  gint        maximum;
57  guint       n_values;
58  GEnumValue *values;
59};
60struct  _GFlagsClass
61{
62  GTypeClass   g_type_class;
63 
64  /*< public >*/ 
65  guint        mask;
66  guint        n_values;
67  GFlagsValue *values;
68};
69struct _GEnumValue
70{
71  gint   value;
72  gchar *value_name;
73  gchar *value_nick;
74};
75struct _GFlagsValue
76{
77  guint  value;
78  gchar *value_name;
79  gchar *value_nick;
80};
81
82
83/* --- prototypes --- */
84GEnumValue*     g_enum_get_value                (GEnumClass     *enum_class,
85                                                 gint            value);
86GEnumValue*     g_enum_get_value_by_name        (GEnumClass     *enum_class,
87                                                 const gchar    *name);
88GEnumValue*     g_enum_get_value_by_nick        (GEnumClass     *enum_class,
89                                                 const gchar    *nick);
90GFlagsValue*    g_flags_get_first_value         (GFlagsClass    *flags_class,
91                                                 guint           value);
92GFlagsValue*    g_flags_get_value_by_name       (GFlagsClass    *flags_class,
93                                                 const gchar    *name);
94GFlagsValue*    g_flags_get_value_by_nick       (GFlagsClass    *flags_class,
95                                                 const gchar    *nick);
96void            g_value_set_enum                (GValue         *value,
97                                                 gint            v_enum);
98gint            g_value_get_enum                (const GValue   *value);
99void            g_value_set_flags               (GValue         *value,
100                                                 guint           v_flags);
101guint           g_value_get_flags               (const GValue   *value);
102
103
104
105/* --- registration functions --- */
106/* const_static_values is a NULL terminated array of enum/flags
107 * values that is taken over!
108 */
109GType   g_enum_register_static     (const gchar       *name,
110                                    const GEnumValue  *const_static_values);
111GType   g_flags_register_static    (const gchar       *name,
112                                    const GFlagsValue *const_static_values);
113/* functions to complete the type information
114 * for enums/flags implemented by plugins
115 */
116void    g_enum_complete_type_info  (GType              g_enum_type,
117                                    GTypeInfo         *info,
118                                    const GEnumValue  *const_values);
119void    g_flags_complete_type_info (GType              g_flags_type,
120                                    GTypeInfo         *info,
121                                    const GFlagsValue *const_values);
122
123G_END_DECLS
124
125#endif /* __G_ENUMS_H__ */
Note: See TracBrowser for help on using the repository browser.