alternative to assert
[gtkD.git] / gtkD / src / glib / Quark.d
blob9ee925980989a08e932cc2bea59d41bfa8837614
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 = glib-Quarks.html
26 * outPack = glib
27 * outFile = Quark
28 * strct = GQuark
29 * realStrct=
30 * ctorStrct=
31 * clss = Quark
32 * interf =
33 * class Code: No
34 * interface Code: No
35 * template for:
36 * extend =
37 * implements:
38 * prefixes:
39 * - g_quark_
40 * omit structs:
41 * omit prefixes:
42 * omit code:
43 * imports:
44 * - glib.ErrorG
45 * - glib.Str
46 * structWrap:
47 * module aliases:
48 * local aliases:
51 module glib.Quark;
53 version(noAssert)
55 version(Tango)
57 import tango.io.Stdout; // use the tango loging?
61 private import gtkc.glibtypes;
63 private import gtkc.glib;
66 private import glib.ErrorG;
67 private import glib.Str;
72 /**
73 * Description
74 * Quarks are associations between strings and integer identifiers.
75 * Given either the string or the GQuark identifier it is possible to
76 * retrieve the other.
77 * Quarks are used for both
78 * Datasets and
79 * Keyed Data Lists.
80 * To create a new quark from a string, use g_quark_from_string() or
81 * g_quark_from_static_string().
82 * To find the string corresponding to a given GQuark, use g_quark_to_string().
83 * To find the GQuark corresponding to a given string, use g_quark_try_string().
84 * Another use for the string pool maintained for the quark functions is string
85 * interning, using g_intern_string() or g_intern_static_string(). An interned string
86 * is a canonical representation for a string. One important advantage of interned strings
87 * is that they can be compared for equality by a simple pointer comparision, rather than
88 * using strcmp().
90 public class Quark
93 /** the main Gtk struct */
94 protected GQuark* gQuark;
97 public GQuark* getQuarkStruct()
99 return gQuark;
103 /** the main Gtk struct as a void* */
104 protected void* getStruct()
106 return cast(void*)gQuark;
110 * Sets our main struct and passes it to the parent class
112 public this (GQuark* gQuark)
114 version(noAssert)
116 if ( gQuark is null )
118 int zero = 0;
119 version(Tango)
121 Stdout("struct gQuark is null on constructor").newline;
123 else
125 printf("struct gQuark is null on constructor");
127 zero = zero / zero;
130 else
132 assert(gQuark !is null, "struct gQuark is null on constructor");
134 this.gQuark = gQuark;
142 * Gets the GQuark identifying the given string.
143 * If the string does not currently have an associated GQuark, a new
144 * GQuark is created, using a copy of the string.
145 * string:
146 * a string.
147 * Returns:
148 * the GQuark identifying the string.
150 public static GQuark fromString(char[] string)
152 // GQuark g_quark_from_string (const gchar *string);
153 return g_quark_from_string(Str.toStringz(string));
157 * Gets the GQuark identifying the given (static) string.
158 * If the string does not currently have an associated GQuark, a new
159 * GQuark is created, linked to the given string.
160 * Note that this function is identical to g_quark_from_string() except
161 * that if a new GQuark is created the string itself is used rather than
162 * a copy. This saves memory, but can only be used if the string will
163 * always exist. It can be used with statically
164 * allocated strings in the main program, but not with statically
165 * allocated memory in dynamically loaded modules, if you expect to
166 * ever unload the module again (e.g. do not use this function in
167 * GTK+ theme engines).
168 * string:
169 * a string.
170 * Returns:
171 * the GQuark identifying the string.
173 public static GQuark fromStaticString(char[] string)
175 // GQuark g_quark_from_static_string (const gchar *string);
176 return g_quark_from_static_string(Str.toStringz(string));
180 * Gets the string associated with the given GQuark.
181 * quark:
182 * a GQuark.
183 * Returns:
184 * the string associated with the GQuark.
186 public static char[] toString(GQuark quark)
188 // const gchar* g_quark_to_string (GQuark quark);
189 return Str.toString(g_quark_to_string(quark) );
193 * Gets the GQuark associated with the given string, or 0 if the string has
194 * no associated GQuark.
195 * If you want the GQuark to be created if it doesn't already exist, use
196 * g_quark_from_string() or g_quark_from_static_string().
197 * string:
198 * a string.
199 * Returns:
200 * the GQuark associated with the string, or 0 if there is no
201 * GQuark associated with the string.
203 public static GQuark tryString(char[] string)
205 // GQuark g_quark_try_string (const gchar *string);
206 return g_quark_try_string(Str.toStringz(string));
210 * Returns a canonical representation for string. Interned strings can
211 * be compared for equality by comparing the pointers, instead of using strcmp().
212 * string:
213 * a string
214 * Returns:
215 * a canonical representation for the string
216 * Since 2.10
218 public static char[] gInternString(char[] string)
220 // const gchar* g_intern_string (const gchar *string);
221 return Str.toString(g_intern_string(Str.toStringz(string)) );
225 * Returns a canonical representation for string. Interned strings can
226 * be compared for equality by comparing the pointers, instead of using strcmp().
227 * g_intern_static_string() does not copy the string, therefore string must
228 * not be freed or modified.
229 * string:
230 * a static string
231 * Returns:
232 * a canonical representation for the string
233 * Since 2.10
235 public static char[] gInternStaticString(char[] string)
237 // const gchar* g_intern_static_string (const gchar *string);
238 return Str.toString(g_intern_static_string(Str.toStringz(string)) );