1 /*
2  * This file is part of gtkD.
3  *
4  * gtkD is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU Lesser General Public License
6  * as published by the Free Software Foundation; either version 3
7  * of the License, or (at your option) any later version, with
8  * some exceptions, please read the COPYING file.
9  *
10  * gtkD is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public License
16  * along with gtkD; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA
18  */
19  
20 // generated automatically - do not change
21 // find conversion definition on APILookup.txt
22 // implement new conversion functionalities on the wrap.utils pakage
23 
24 /*
25  * Conversion parameters:
26  * inFile  = glib-Quarks.html
27  * outPack = glib
28  * outFile = Quark
29  * strct   = GQuark
30  * realStrct=
31  * ctorStrct=
32  * clss    = Quark
33  * interf  = 
34  * class Code: No
35  * interface Code: No
36  * template for:
37  * extend  = 
38  * implements:
39  * prefixes:
40  * 	- g_quark_
41  * omit structs:
42  * omit prefixes:
43  * omit code:
44  * omit signals:
45  * imports:
46  * 	- glib.Str
47  * structWrap:
48  * module aliases:
49  * local aliases:
50  * overrides:
51  */
52 
53 module glib.Quark;
54 
55 public  import gtkc.glibtypes;
56 
57 private import gtkc.glib;
58 private import glib.ConstructionException;
59 
60 
61 private import glib.Str;
62 
63 
64 
65 
66 /**
67  * Quarks are associations between strings and integer identifiers.
68  * Given either the string or the GQuark identifier it is possible to
69  * retrieve the other.
70  *
71  * Quarks are used for both Datasets and Keyed Data Lists.
72  *
73  * To create a new quark from a string, use g_quark_from_string() or
74  * g_quark_from_static_string().
75  *
76  * To find the string corresponding to a given GQuark, use
77  * g_quark_to_string().
78  *
79  * To find the GQuark corresponding to a given string, use
80  * g_quark_try_string().
81  *
82  * Another use for the string pool maintained for the quark functions
83  * is string interning, using g_intern_string() or
84  * g_intern_static_string(). An interned string is a canonical
85  * representation for a string. One important advantage of interned
86  * strings is that they can be compared for equality by a simple
87  * pointer comparison, rather than using strcmp().
88  */
89 public class Quark
90 {
91 	
92 	/** the main Gtk struct */
93 	protected GQuark* gQuark;
94 	
95 	
96 	public GQuark* getQuarkStruct()
97 	{
98 		return gQuark;
99 	}
100 	
101 	
102 	/** the main Gtk struct as a void* */
103 	protected void* getStruct()
104 	{
105 		return cast(void*)gQuark;
106 	}
107 	
108 	/**
109 	 * Sets our main struct and passes it to the parent class
110 	 */
111 	public this (GQuark* gQuark)
112 	{
113 		this.gQuark = gQuark;
114 	}
115 	
116 	/**
117 	 */
118 	
119 	/**
120 	 * Gets the GQuark identifying the given string. If the string does
121 	 * not currently have an associated GQuark, a new GQuark is created,
122 	 * using a copy of the string.
123 	 * Params:
124 	 * string = a string. [allow-none]
125 	 * Returns: the GQuark identifying the string, or 0 if string is NULL.
126 	 */
127 	public static GQuark fromString(string string)
128 	{
129 		// GQuark g_quark_from_string (const gchar *string);
130 		return g_quark_from_string(Str.toStringz(string));
131 	}
132 	
133 	/**
134 	 * Gets the GQuark identifying the given (static) string. If the
135 	 * string does not currently have an associated GQuark, a new GQuark
136 	 * is created, linked to the given string.
137 	 * Note that this function is identical to g_quark_from_string() except
138 	 * that if a new GQuark is created the string itself is used rather
139 	 * than a copy. This saves memory, but can only be used if the string
140 	 * will always exist. It can be used with
141 	 * statically allocated strings in the main program, but not with
142 	 * statically allocated memory in dynamically loaded modules, if you
143 	 * expect to ever unload the module again (e.g. do not use this
144 	 * function in GTK+ theme engines).
145 	 * Params:
146 	 * string = a string. [allow-none]
147 	 * Returns: the GQuark identifying the string, or 0 if string is NULL.
148 	 */
149 	public static GQuark fromStaticString(string string)
150 	{
151 		// GQuark g_quark_from_static_string (const gchar *string);
152 		return g_quark_from_static_string(Str.toStringz(string));
153 	}
154 	
155 	/**
156 	 * Gets the string associated with the given GQuark.
157 	 * Params:
158 	 * quark = a GQuark.
159 	 * Returns: the string associated with the GQuark
160 	 */
161 	public static string toString(GQuark quark)
162 	{
163 		// const gchar * g_quark_to_string (GQuark quark);
164 		return Str.toString(g_quark_to_string(quark));
165 	}
166 	
167 	/**
168 	 * Gets the GQuark associated with the given string, or 0 if string is
169 	 * NULL or it has no associated GQuark.
170 	 * If you want the GQuark to be created if it doesn't already exist,
171 	 * use g_quark_from_string() or g_quark_from_static_string().
172 	 * Params:
173 	 * string = a string. [allow-none]
174 	 * Returns: the GQuark associated with the string, or 0 if string is NULL or there is no GQuark associated with it.
175 	 */
176 	public static GQuark tryString(string string)
177 	{
178 		// GQuark g_quark_try_string (const gchar *string);
179 		return g_quark_try_string(Str.toStringz(string));
180 	}
181 	
182 	/**
183 	 * Returns a canonical representation for string. Interned strings
184 	 * can be compared for equality by comparing the pointers, instead of
185 	 * using strcmp().
186 	 * Since 2.10
187 	 * Params:
188 	 * string = a string. [allow-none]
189 	 * Returns: a canonical representation for the string
190 	 */
191 	public static string gInternString(string string)
192 	{
193 		// const gchar * g_intern_string (const gchar *string);
194 		return Str.toString(g_intern_string(Str.toStringz(string)));
195 	}
196 	
197 	/**
198 	 * Returns a canonical representation for string. Interned strings
199 	 * can be compared for equality by comparing the pointers, instead of
200 	 * using strcmp(). g_intern_static_string() does not copy the string,
201 	 * therefore string must not be freed or modified.
202 	 * Since 2.10
203 	 * Params:
204 	 * string = a static string. [allow-none]
205 	 * Returns: a canonical representation for the string
206 	 */
207 	public static string gInternStaticString(string string)
208 	{
209 		// const gchar * g_intern_static_string (const gchar *string);
210 		return Str.toString(g_intern_static_string(Str.toStringz(string)));
211 	}
212 }