alternative to assert
[gtkD.git] / gtkD / src / gobject / Flags.d
blob6e0eb62168b65df00827322c0b37ccc81c71b2f0
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 =
26 * outPack = gobject
27 * outFile = Flags
28 * strct = GFlagsValue
29 * realStrct=
30 * ctorStrct=
31 * clss = Flags
32 * interf =
33 * class Code: No
34 * interface Code: No
35 * template for:
36 * extend =
37 * implements:
38 * prefixes:
39 * - g_flags_
40 * omit structs:
41 * omit prefixes:
42 * - g_enum_
43 * omit code:
44 * imports:
45 * - glib.Str
46 * - gobject.Flags
47 * structWrap:
48 * - GFlagsValue* -> Flags
49 * module aliases:
50 * local aliases:
53 module gobject.Flags;
55 version(noAssert)
57 version(Tango)
59 import tango.io.Stdout; // use the tango loging?
63 private import gtkc.gobjecttypes;
65 private import gtkc.gobject;
68 private import glib.Str;
69 private import gobject.Flags;
74 /**
75 * Description
76 * The GLib type system provides fundamental types for enumeration and flags types. (Flags types
77 * are like enumerations, but allow their values to be combined by bitwise or). A registered
78 * enumeration or flags type associates a name and a nickname with each allowed value, and
79 * the methods g_enum_get_value_by_name(), g_enum_get_value_by_nick(), g_flags_get_value_by_name()
80 * and g_flags_get_value_by_nick() can look up values by their name or nickname.
81 * When an enumeration or flags type is registered with the GLib type system, it can
82 * be used as value type for object properties, using g_param_spec_enum() or
83 * g_param_spec_flags().
84 * GObject ships with a utility called glib-mkenums that can
85 * construct suitable type registration functions from C enumeration definitions.
87 public class Flags
90 /** the main Gtk struct */
91 protected GFlagsValue* gFlagsValue;
94 public GFlagsValue* getFlagsStruct()
96 return gFlagsValue;
100 /** the main Gtk struct as a void* */
101 protected void* getStruct()
103 return cast(void*)gFlagsValue;
107 * Sets our main struct and passes it to the parent class
109 public this (GFlagsValue* gFlagsValue)
111 version(noAssert)
113 if ( gFlagsValue is null )
115 int zero = 0;
116 version(Tango)
118 Stdout("struct gFlagsValue is null on constructor").newline;
120 else
122 printf("struct gFlagsValue is null on constructor");
124 zero = zero / zero;
127 else
129 assert(gFlagsValue !is null, "struct gFlagsValue is null on constructor");
131 this.gFlagsValue = gFlagsValue;
155 * Returns the first GFlagsValue which is set in value.
156 * flags_class:
157 * a GFlagsClass
158 * value:
159 * the value
160 * Returns:
161 * the first GFlagsValue which is set in value, or NULL if none is set
163 public static Flags getFirstValue(GFlagsClass* flagsClass, uint value)
165 // GFlagsValue* g_flags_get_first_value (GFlagsClass *flags_class, guint value);
166 return new Flags( g_flags_get_first_value(flagsClass, value) );
170 * Looks up a GFlagsValue by name.
171 * flags_class:
172 * a GFlagsClass
173 * name:
174 * the name to look up
175 * Returns:
176 * the GFlagsValue with name name, or NULL if there is no flag with
177 * that name
179 public static Flags getValueByName(GFlagsClass* flagsClass, char[] name)
181 // GFlagsValue* g_flags_get_value_by_name (GFlagsClass *flags_class, const gchar *name);
182 return new Flags( g_flags_get_value_by_name(flagsClass, Str.toStringz(name)) );
186 * Looks up a GFlagsValue by nickname.
187 * flags_class:
188 * a GFlagsClass
189 * nick:
190 * the nickname to look up
191 * Returns:
192 * the GFlagsValue with nickname nick, or NULL if there is no flag
193 * with that nickname
195 public static Flags getValueByNick(GFlagsClass* flagsClass, char[] nick)
197 // GFlagsValue* g_flags_get_value_by_nick (GFlagsClass *flags_class, const gchar *nick);
198 return new Flags( g_flags_get_value_by_nick(flagsClass, Str.toStringz(nick)) );
203 * Registers a new static flags type with the name name.
204 * It is normally more convenient to let glib-mkenums
205 * generate a my_flags_get_type() function from a usual C enumeration definition
206 * than to write one yourself using g_flags_register_static().
207 * name:
208 * A nul-terminated string used as the name of the new type.
209 * _static_values:
210 * Returns:
211 * The new type identifier.
213 public static GType registerStatic(char[] name, Flags _StaticValues)
215 // GType g_flags_register_static (const gchar *name, const GFlagsValue *const _static_values);
216 return g_flags_register_static(Str.toStringz(name), (_StaticValues is null) ? null : _StaticValues.getFlagsStruct());
221 * This function is meant to be called from the complete_type_info() function
222 * of a GTypePlugin implementation, see the example for
223 * g_enumeration_complete_type_info() above.
224 * g_flags_type:
225 * the type identifier of the type being completed
226 * info:
227 * the GTypeInfo struct to be filled in
228 * _values:
229 * See Also
230 * GParamSpecEnum, GParamSpecFlags, g_param_spec_enum(), g_param_spec_flags(),
231 * glib-mkenums
233 public static void completeTypeInfo(GType type, GTypeInfo* info, Flags _Values)
235 // void g_flags_complete_type_info (GType g_flags_type, GTypeInfo *info, const GFlagsValue *const _values);
236 g_flags_complete_type_info(type, info, (_Values is null) ? null : _Values.getFlagsStruct());