alternative to assert
[gtkD.git] / src / glib / Quark.d
blob58e81bdf97d79b1bc5da483f4d1c57ca12efc06a
1 /*
2 * This file is part of duit.
4 * duit 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 * duit 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 duit; 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 * local aliases:
50 module glib.Quark;
52 private import glib.glibtypes;
54 private import lib.glib;
56 private import glib.ErrorG;
57 private import glib.Str;
59 /**
60 * Description
61 * Quarks are associations between strings and integer identifiers.
62 * Given either the string or the GQuark identifier it is possible to
63 * retrieve the other.
64 * Quarks are used for both
65 * Datasets and
66 * Keyed Data Lists.
67 * To create a new quark from a string, use g_quark_from_string() or
68 * g_quark_from_static_string().
69 * To find the string corresponding to a given GQuark, use g_quark_to_string().
70 * To find the GQuark corresponding to a given string, use g_quark_try_string().
71 * Another use for the string pool maintained for the quark functions is string
72 * interning, using g_intern_string() or g_intern_static_string(). An interned string
73 * is a canonical representation for a string. One important advantage of interned strings
74 * is that they can be compared for equality by a simple pointer comparision, rather than
75 * using strcmp().
77 public class Quark
80 /** the main Gtk struct */
81 protected GQuark* gQuark;
84 public GQuark* getQuarkStruct()
86 return gQuark;
90 /** the main Gtk struct as a void* */
91 protected void* getStruct()
93 return cast(void*)gQuark;
96 /**
97 * Sets our main struct and passes it to the parent class
99 public this (GQuark* gQuark)
101 this.gQuark = gQuark;
109 * Gets the GQuark identifying the given string.
110 * If the string does not currently have an associated GQuark, a new
111 * GQuark is created, using a copy of the string.
112 * string:
113 * a string.
114 * Returns:
115 * the GQuark identifying the string.
117 public static GQuark fromString(char[] string)
119 // GQuark g_quark_from_string (const gchar *string);
120 return g_quark_from_string(Str.toStringz(string));
124 * Gets the GQuark identifying the given (static) string.
125 * If the string does not currently have an associated GQuark, a new
126 * GQuark is created, linked to the given string.
127 * Note that this function is identical to g_quark_from_string() except
128 * that if a new GQuark is created the string itself is used rather than
129 * a copy. This saves memory, but can only be used if the string will
130 * always exist. It can be used with statically
131 * allocated strings in the main program, but not with statically
132 * allocated memory in dynamically loaded modules, if you expect to
133 * ever unload the module again (e.g. do not use this function in
134 * GTK+ theme engines).
135 * string:
136 * a string.
137 * Returns:
138 * the GQuark identifying the string.
140 public static GQuark fromStaticString(char[] string)
142 // GQuark g_quark_from_static_string (const gchar *string);
143 return g_quark_from_static_string(Str.toStringz(string));
147 * Gets the string associated with the given GQuark.
148 * quark:
149 * a GQuark.
150 * Returns:
151 * the string associated with the GQuark.
153 public static char[] toString(GQuark quark)
155 // const gchar* g_quark_to_string (GQuark quark);
156 return Str.toString(g_quark_to_string(quark) );
160 * Gets the GQuark associated with the given string, or 0 if the string has
161 * no associated GQuark.
162 * If you want the GQuark to be created if it doesn't already exist, use
163 * g_quark_from_string() or g_quark_from_static_string().
164 * string:
165 * a string.
166 * Returns:
167 * the GQuark associated with the string, or 0 if there is no
168 * GQuark associated with the string.
170 public static GQuark tryString(char[] string)
172 // GQuark g_quark_try_string (const gchar *string);
173 return g_quark_try_string(Str.toStringz(string));
177 * Returns a canonical representation for string. Interned strings can
178 * be compared for equality by comparing the pointers, instead of using strcmp().
179 * string:
180 * a string
181 * Returns:
182 * a canonical representation for the string
183 * Since 2.10
185 public static char[] gInternString(char[] string)
187 // const gchar* g_intern_string (const gchar *string);
188 return Str.toString(g_intern_string(Str.toStringz(string)) );
192 * Returns a canonical representation for string. Interned strings can
193 * be compared for equality by comparing the pointers, instead of using strcmp().
194 * g_intern_static_string() does not copy the string, therefore string must
195 * not be freed or modified.
196 * string:
197 * a static string
198 * Returns:
199 * a canonical representation for the string
200 * Since 2.10
202 public static char[] gInternStaticString(char[] string)
204 // const gchar* g_intern_static_string (const gchar *string);
205 return Str.toString(g_intern_static_string(Str.toStringz(string)) );