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 private import glib.Str; 61 62 63 64 /** 65 * Quarks are associations between strings and integer identifiers. 66 * Given either the string or the GQuark identifier it is possible to 67 * retrieve the other. 68 * 69 * Quarks are used for both Datasets and Keyed Data Lists. 70 * 71 * To create a new quark from a string, use g_quark_from_string() or 72 * g_quark_from_static_string(). 73 * 74 * To find the string corresponding to a given GQuark, use 75 * g_quark_to_string(). 76 * 77 * To find the GQuark corresponding to a given string, use 78 * g_quark_try_string(). 79 * 80 * Another use for the string pool maintained for the quark functions 81 * is string interning, using g_intern_string() or 82 * g_intern_static_string(). An interned string is a canonical 83 * representation for a string. One important advantage of interned 84 * strings is that they can be compared for equality by a simple 85 * pointer comparison, rather than using strcmp(). 86 */ 87 public class Quark 88 { 89 90 /** the main Gtk struct */ 91 protected GQuark* gQuark; 92 93 94 /** Get the main Gtk struct */ 95 public GQuark* getQuarkStruct() 96 { 97 return gQuark; 98 } 99 100 101 /** the main Gtk struct as a void* */ 102 protected void* getStruct() 103 { 104 return cast(void*)gQuark; 105 } 106 107 /** 108 * Sets our main struct and passes it to the parent class 109 */ 110 public this (GQuark* gQuark) 111 { 112 this.gQuark = gQuark; 113 } 114 115 /** 116 */ 117 118 /** 119 * Gets the GQuark identifying the given string. If the string does 120 * not currently have an associated GQuark, a new GQuark is created, 121 * using a copy of the string. 122 * Params: 123 * string = a string. [allow-none] 124 * Returns: the GQuark identifying the string, or 0 if string is NULL. 125 */ 126 public static GQuark fromString(string string) 127 { 128 // GQuark g_quark_from_string (const gchar *string); 129 return g_quark_from_string(Str.toStringz(string)); 130 } 131 132 /** 133 * Gets the GQuark identifying the given (static) string. If the 134 * string does not currently have an associated GQuark, a new GQuark 135 * is created, linked to the given string. 136 * Note that this function is identical to g_quark_from_string() except 137 * that if a new GQuark is created the string itself is used rather 138 * than a copy. This saves memory, but can only be used if the string 139 * will always exist. It can be used with 140 * statically allocated strings in the main program, but not with 141 * statically allocated memory in dynamically loaded modules, if you 142 * expect to ever unload the module again (e.g. do not use this 143 * function in GTK+ theme engines). 144 * Params: 145 * string = a string. [allow-none] 146 * Returns: the GQuark identifying the string, or 0 if string is NULL. 147 */ 148 public static GQuark fromStaticString(string string) 149 { 150 // GQuark g_quark_from_static_string (const gchar *string); 151 return g_quark_from_static_string(Str.toStringz(string)); 152 } 153 154 /** 155 * Gets the string associated with the given GQuark. 156 * Params: 157 * quark = a GQuark. 158 * Returns: the string associated with the GQuark 159 */ 160 public static string toString(GQuark quark) 161 { 162 // const gchar * g_quark_to_string (GQuark quark); 163 return Str.toString(g_quark_to_string(quark)); 164 } 165 166 /** 167 * Gets the GQuark associated with the given string, or 0 if string is 168 * NULL or it has no associated GQuark. 169 * If you want the GQuark to be created if it doesn't already exist, 170 * use g_quark_from_string() or g_quark_from_static_string(). 171 * Params: 172 * string = a string. [allow-none] 173 * Returns: the GQuark associated with the string, or 0 if string is NULL or there is no GQuark associated with it. 174 */ 175 public static GQuark tryString(string string) 176 { 177 // GQuark g_quark_try_string (const gchar *string); 178 return g_quark_try_string(Str.toStringz(string)); 179 } 180 181 /** 182 * Returns a canonical representation for string. Interned strings 183 * can be compared for equality by comparing the pointers, instead of 184 * using strcmp(). 185 * Since 2.10 186 * Params: 187 * string = a string. [allow-none] 188 * Returns: a canonical representation for the string 189 */ 190 public static string gInternString(string string) 191 { 192 // const gchar * g_intern_string (const gchar *string); 193 return Str.toString(g_intern_string(Str.toStringz(string))); 194 } 195 196 /** 197 * Returns a canonical representation for string. Interned strings 198 * can be compared for equality by comparing the pointers, instead of 199 * using strcmp(). g_intern_static_string() does not copy the string, 200 * therefore string must not be freed or modified. 201 * Since 2.10 202 * Params: 203 * string = a static string. [allow-none] 204 * Returns: a canonical representation for the string 205 */ 206 public static string gInternStaticString(string string) 207 { 208 // const gchar * g_intern_static_string (const gchar *string); 209 return Str.toString(g_intern_static_string(Str.toStringz(string))); 210 } 211 }