alternative to assert
[gtkD.git] / gtkD / src / gobject / Enums.d
blob55e9303693349a95878d1621d18411652bc7b32b
1 /*
2 * This file is part of gtkD.
4 * gtkD is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation; either version 2.1 of the License, or
7 * (at your option) any later version.
9 * gtkD 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
12 * GNU Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public License
15 * along with gtkD; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 // generated automatically - do not change
20 // find conversion definition on APILookup.txt
21 // implement new conversion functionalities on the wrap.utils pakage
24 * Conversion parameters:
25 * inFile = gobject-Enumeration-and-Flag-Types.html
26 * outPack = gobject
27 * outFile = Enums
28 * strct = GEnumValue
29 * realStrct=
30 * ctorStrct=
31 * clss = Enums
32 * interf =
33 * class Code: No
34 * interface Code: No
35 * template for:
36 * extend =
37 * implements:
38 * prefixes:
39 * - g_enum_
40 * omit structs:
41 * omit prefixes:
42 * - g_flags_
43 * omit code:
44 * imports:
45 * - glib.Str
46 * structWrap:
47 * module aliases:
48 * local aliases:
51 module gobject.Enums;
53 version(noAssert)
55 version(Tango)
57 import tango.io.Stdout; // use the tango loging?
61 private import gtkc.gobjecttypes;
63 private import gtkc.gobject;
66 private import glib.Str;
71 /**
72 * Description
73 * The GLib type system provides fundamental types for enumeration and flags types. (Flags types
74 * are like enumerations, but allow their values to be combined by bitwise or). A registered
75 * enumeration or flags type associates a name and a nickname with each allowed value, and
76 * the methods g_enum_get_value_by_name(), g_enum_get_value_by_nick(), g_flags_get_value_by_name()
77 * and g_flags_get_value_by_nick() can look up values by their name or nickname.
78 * When an enumeration or flags type is registered with the GLib type system, it can
79 * be used as value type for object properties, using g_param_spec_enum() or
80 * g_param_spec_flags().
81 * GObject ships with a utility called glib-mkenums that can
82 * construct suitable type registration functions from C enumeration definitions.
84 public class Enums
87 /** the main Gtk struct */
88 protected GEnumValue* gEnumValue;
91 public GEnumValue* getEnumsStruct()
93 return gEnumValue;
97 /** the main Gtk struct as a void* */
98 protected void* getStruct()
100 return cast(void*)gEnumValue;
104 * Sets our main struct and passes it to the parent class
106 public this (GEnumValue* gEnumValue)
108 version(noAssert)
110 if ( gEnumValue is null )
112 int zero = 0;
113 version(Tango)
115 Stdout("struct gEnumValue is null on constructor").newline;
117 else
119 printf("struct gEnumValue is null on constructor");
121 zero = zero / zero;
124 else
126 assert(gEnumValue !is null, "struct gEnumValue is null on constructor");
128 this.gEnumValue = gEnumValue;
149 * Returns the GEnumValue for a value.
150 * enum_class:
151 * a GEnumClass
152 * value:
153 * the value to look up
154 * Returns:
155 * the GEnumValue for value, or NULL if value is not
156 * a member of the enumeration
158 public static GEnumValue* getValue(GEnumClass* enumClass, int value)
160 // GEnumValue* g_enum_get_value (GEnumClass *enum_class, gint value);
161 return g_enum_get_value(enumClass, value);
165 * Looks up a GEnumValue by name.
166 * enum_class:
167 * a GEnumClass
168 * name:
169 * the name to look up
170 * Returns:
171 * the GEnumValue with name name, or NULL if the enumeration doesn'
172 * t have a member with that name
174 public static GEnumValue* getValueByName(GEnumClass* enumClass, char[] name)
176 // GEnumValue* g_enum_get_value_by_name (GEnumClass *enum_class, const gchar *name);
177 return g_enum_get_value_by_name(enumClass, Str.toStringz(name));
181 * Looks up a GEnumValue by nickname.
182 * enum_class:
183 * a GEnumClass
184 * nick:
185 * the nickname to look up
186 * Returns:
187 * the GEnumValue with nickname nick, or NULL if the enumeration doesn'
188 * t have a member with that nickname
190 public static GEnumValue* getValueByNick(GEnumClass* enumClass, char[] nick)
192 // GEnumValue* g_enum_get_value_by_nick (GEnumClass *enum_class, const gchar *nick);
193 return g_enum_get_value_by_nick(enumClass, Str.toStringz(nick));
200 * Registers a new static enumeration type with the name name.
201 * It is normally more convenient to let glib-mkenums
202 * generate a my_enum_get_type() function from a usual C enumeration definition
203 * than to write one yourself using g_enum_register_static().
204 * name:
205 * A nul-terminated string used as the name of the new type.
206 * _static_values:
207 * Returns:
208 * The new type identifier.
210 public static GType registerStatic(char[] name, GEnumValue* _StaticValues)
212 // GType g_enum_register_static (const gchar *name, const GEnumValue *const _static_values);
213 return g_enum_register_static(Str.toStringz(name), _StaticValues);
218 * This function is meant to be called from the complete_type_info() function
219 * of a GTypePlugin implementation, as in the following example:
220 * static void
221 * my_enum_complete_type_info (GTypePlugin *plugin,
222 * GType g_type,
223 * GTypeInfo *info,
224 * GTypeValueTable *value_table)
226 * static const GEnumValue values[] = {
227 * { MY_ENUM_FOO, "MY_ENUM_FOO", "foo" },
228 * { MY_ENUM_BAR, "MY_ENUM_BAR", "bar" },
229 * { 0, NULL, NULL }
230 * };
231 * g_enum_complete_type_info (type, info, values);
233 * g_enum_type:
234 * the type identifier of the type being completed
235 * info:
236 * the GTypeInfo struct to be filled in
237 * _values:
239 public static void completeTypeInfo(GType type, GTypeInfo* info, GEnumValue* _Values)
241 // void g_enum_complete_type_info (GType g_enum_type, GTypeInfo *info, const GEnumValue *const _values);
242 g_enum_complete_type_info(type, info, _Values);