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-Lexical-Scanner.html 27 * outPack = glib 28 * outFile = ScannerG 29 * strct = GScanner 30 * realStrct= 31 * ctorStrct= 32 * clss = ScannerG 33 * interf = 34 * class Code: No 35 * interface Code: No 36 * template for: 37 * extend = 38 * implements: 39 * prefixes: 40 * - g_scanner_ 41 * omit structs: 42 * omit prefixes: 43 * omit code: 44 * omit signals: 45 * imports: 46 * - glib.Str 47 * structWrap: 48 * - GScanner* -> ScannerG 49 * module aliases: 50 * local aliases: 51 * overrides: 52 */ 53 54 module glib.ScannerG; 55 56 public import gtkc.glibtypes; 57 58 private import gtkc.glib; 59 private import glib.ConstructionException; 60 61 62 private import glib.Str; 63 64 65 66 67 /** 68 * Description 69 * The GScanner and its associated functions provide a general purpose 70 * lexical scanner. 71 */ 72 public class ScannerG 73 { 74 75 /** the main Gtk struct */ 76 protected GScanner* gScanner; 77 78 79 public GScanner* getScannerGStruct() 80 { 81 return gScanner; 82 } 83 84 85 /** the main Gtk struct as a void* */ 86 protected void* getStruct() 87 { 88 return cast(void*)gScanner; 89 } 90 91 /** 92 * Sets our main struct and passes it to the parent class 93 */ 94 public this (GScanner* gScanner) 95 { 96 this.gScanner = gScanner; 97 } 98 99 /** 100 */ 101 102 /** 103 * Creates a new GScanner. 104 * The config_templ structure specifies the initial settings of the scanner, 105 * which are copied into the GScanner config field. 106 * If you pass NULL then the default settings are used. 107 * Params: 108 * configTempl = the initial scanner settings. 109 * Throws: ConstructionException GTK+ fails to create the object. 110 */ 111 public this (GScannerConfig* configTempl) 112 { 113 // GScanner * g_scanner_new (const GScannerConfig *config_templ); 114 auto p = g_scanner_new(configTempl); 115 if(p is null) 116 { 117 throw new ConstructionException("null returned by g_scanner_new(configTempl)"); 118 } 119 this(cast(GScanner*) p); 120 } 121 122 /** 123 * Frees all memory used by the GScanner. 124 */ 125 public void destroy() 126 { 127 // void g_scanner_destroy (GScanner *scanner); 128 g_scanner_destroy(gScanner); 129 } 130 131 /** 132 * Prepares to scan a file. 133 * Params: 134 * inputFd = a file descriptor. 135 */ 136 public void inputFile(int inputFd) 137 { 138 // void g_scanner_input_file (GScanner *scanner, gint input_fd); 139 g_scanner_input_file(gScanner, inputFd); 140 } 141 142 /** 143 * Rewinds the filedescriptor to the current buffer position and blows 144 * the file read ahead buffer. This is useful for third party uses of 145 * the scanners filedescriptor, which hooks onto the current scanning 146 * position. 147 */ 148 public void syncFileOffset() 149 { 150 // void g_scanner_sync_file_offset (GScanner *scanner); 151 g_scanner_sync_file_offset(gScanner); 152 } 153 154 /** 155 * Prepares to scan a text buffer. 156 * Params: 157 * text = the text buffer to scan. 158 * textLen = the length of the text buffer. 159 */ 160 public void inputText(string text, uint textLen) 161 { 162 // void g_scanner_input_text (GScanner *scanner, const gchar *text, guint text_len); 163 g_scanner_input_text(gScanner, Str.toStringz(text), textLen); 164 } 165 166 /** 167 * Parses the next token, without removing it from the input stream. 168 * The token data is placed in the 169 * next_token, 170 * next_value, 171 * next_line, and 172 * next_position fields of the GScanner structure. 173 * Note that, while the token is not removed from the input stream (i.e. 174 * the next call to g_scanner_get_next_token() will return the same token), 175 * it will not be reevaluated. This can lead to surprising results when 176 * changing scope or the scanner configuration after peeking the next token. 177 * Getting the next token after switching the scope or configuration will 178 * return whatever was peeked before, regardless of any symbols that may 179 * have been added or removed in the new scope. 180 * Returns: the type of the token. 181 */ 182 public GTokenType peekNextToken() 183 { 184 // GTokenType g_scanner_peek_next_token (GScanner *scanner); 185 return g_scanner_peek_next_token(gScanner); 186 } 187 188 /** 189 * Parses the next token just like g_scanner_peek_next_token() and also 190 * removes it from the input stream. 191 * The token data is placed in the 192 * token, 193 * value, 194 * line, and 195 * position fields of the GScanner structure. 196 * Returns: the type of the token. 197 */ 198 public GTokenType getNextToken() 199 { 200 // GTokenType g_scanner_get_next_token (GScanner *scanner); 201 return g_scanner_get_next_token(gScanner); 202 } 203 204 /** 205 * Returns TRUE if the scanner has reached the end of the file or text buffer. 206 * Returns: TRUE if the scanner has reached the end of the file or text buffer. 207 */ 208 public int eof() 209 { 210 // gboolean g_scanner_eof (GScanner *scanner); 211 return g_scanner_eof(gScanner); 212 } 213 214 /** 215 * Returns the current line in the input stream (counting from 1). 216 * This is the line of the last token parsed via g_scanner_get_next_token(). 217 * Returns: the current line. 218 */ 219 public uint curLine() 220 { 221 // guint g_scanner_cur_line (GScanner *scanner); 222 return g_scanner_cur_line(gScanner); 223 } 224 225 /** 226 * Returns the current position in the current line (counting from 0). 227 * This is the position of the last token parsed via g_scanner_get_next_token(). 228 * Returns: the current position on the line. 229 */ 230 public uint curPosition() 231 { 232 // guint g_scanner_cur_position (GScanner *scanner); 233 return g_scanner_cur_position(gScanner); 234 } 235 236 /** 237 * Gets the current token type. 238 * This is simply the token field in the GScanner 239 * structure. 240 * Returns: the current token type. 241 */ 242 public GTokenType curToken() 243 { 244 // GTokenType g_scanner_cur_token (GScanner *scanner); 245 return g_scanner_cur_token(gScanner); 246 } 247 248 /** 249 * Gets the current token value. 250 * This is simply the value field in the GScanner 251 * structure. 252 * Returns: the current token value. 253 */ 254 public GTokenValue curValue() 255 { 256 // GTokenValue g_scanner_cur_value (GScanner *scanner); 257 return g_scanner_cur_value(gScanner); 258 } 259 260 /** 261 * Sets the current scope. 262 * Params: 263 * scopeId = the new scope id. 264 * Returns: the old scope id. 265 */ 266 public uint setScope(uint scopeId) 267 { 268 // guint g_scanner_set_scope (GScanner *scanner, guint scope_id); 269 return g_scanner_set_scope(gScanner, scopeId); 270 } 271 272 /** 273 * Adds a symbol to the given scope. 274 * Params: 275 * scopeId = the scope id. 276 * symbol = the symbol to add. 277 * value = the value of the symbol. 278 */ 279 public void scopeAddSymbol(uint scopeId, string symbol, void* value) 280 { 281 // void g_scanner_scope_add_symbol (GScanner *scanner, guint scope_id, const gchar *symbol, gpointer value); 282 g_scanner_scope_add_symbol(gScanner, scopeId, Str.toStringz(symbol), value); 283 } 284 285 /** 286 * Calls the given function for each of the symbol/value pairs in the 287 * given scope of the GScanner. The function is passed the symbol and 288 * value of each pair, and the given user_data parameter. 289 * Params: 290 * scopeId = the scope id. 291 * func = the function to call for each symbol/value pair. 292 * userData = user data to pass to the function. 293 */ 294 public void scopeForeachSymbol(uint scopeId, GHFunc func, void* userData) 295 { 296 // void g_scanner_scope_foreach_symbol (GScanner *scanner, guint scope_id, GHFunc func, gpointer user_data); 297 g_scanner_scope_foreach_symbol(gScanner, scopeId, func, userData); 298 } 299 300 /** 301 * Looks up a symbol in a scope and return its value. If the 302 * symbol is not bound in the scope, NULL is returned. 303 * Params: 304 * scopeId = the scope id. 305 * symbol = the symbol to look up. 306 * Returns: the value of symbol in the given scope, or NULL if symbol is not bound in the given scope. 307 */ 308 public void* scopeLookupSymbol(uint scopeId, string symbol) 309 { 310 // gpointer g_scanner_scope_lookup_symbol (GScanner *scanner, guint scope_id, const gchar *symbol); 311 return g_scanner_scope_lookup_symbol(gScanner, scopeId, Str.toStringz(symbol)); 312 } 313 314 /** 315 * Removes a symbol from a scope. 316 * Params: 317 * scopeId = the scope id. 318 * symbol = the symbol to remove. 319 */ 320 public void scopeRemoveSymbol(uint scopeId, string symbol) 321 { 322 // void g_scanner_scope_remove_symbol (GScanner *scanner, guint scope_id, const gchar *symbol); 323 g_scanner_scope_remove_symbol(gScanner, scopeId, Str.toStringz(symbol)); 324 } 325 326 /** 327 * Looks up a symbol in the current scope and return its value. If the 328 * symbol is not bound in the current scope, NULL is returned. 329 * Params: 330 * symbol = the symbol to look up. 331 * Returns: the value of symbol in the current scope, or NULL if symbol is not bound in the current scope. 332 */ 333 public void* lookupSymbol(string symbol) 334 { 335 // gpointer g_scanner_lookup_symbol (GScanner *scanner, const gchar *symbol); 336 return g_scanner_lookup_symbol(gScanner, Str.toStringz(symbol)); 337 } 338 339 /** 340 * Outputs a message through the scanner's msg_handler, resulting from an 341 * unexpected token in the input stream. 342 * Note that you should not call g_scanner_peek_next_token() followed by 343 * g_scanner_unexp_token() without an intermediate call to 344 * g_scanner_get_next_token(), as g_scanner_unexp_token() evaluates the 345 * scanner's current token (not the peeked token) to construct part 346 * of the message. 347 * Params: 348 * expectedToken = the expected token. 349 * identifierSpec = a string describing how the scanner's user refers to 350 * identifiers (NULL defaults to "identifier"). 351 * This is used if expected_token is G_TOKEN_IDENTIFIER 352 * or G_TOKEN_IDENTIFIER_NULL. 353 * symbolSpec = a string describing how the scanner's user refers to 354 * symbols (NULL defaults to "symbol"). 355 * This is used if expected_token is G_TOKEN_SYMBOL or 356 * any token value greater than G_TOKEN_LAST. 357 * symbolName = the name of the symbol, if the scanner's current token 358 * is a symbol. 359 * message = a message string to output at the end of the warning/error, or NULL. 360 * isError = if TRUE it is output as an error. If FALSE it is output as a 361 * warning. 362 */ 363 public void unexpToken(GTokenType expectedToken, string identifierSpec, string symbolSpec, string symbolName, string message, int isError) 364 { 365 // void g_scanner_unexp_token (GScanner *scanner, GTokenType expected_token, const gchar *identifier_spec, const gchar *symbol_spec, const gchar *symbol_name, const gchar *message, gint is_error); 366 g_scanner_unexp_token(gScanner, expectedToken, Str.toStringz(identifierSpec), Str.toStringz(symbolSpec), Str.toStringz(symbolName), Str.toStringz(message), isError); 367 } 368 }