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 module gtk.BuildableParseContext; 26 27 private import glib.PtrArray; 28 private import glib.Str; 29 private import glib.c.functions; 30 private import gtk.c.functions; 31 public import gtk.c.types; 32 33 34 /** 35 * An opaque context struct for `GtkBuildableParser`. 36 */ 37 public class BuildableParseContext 38 { 39 /** the main Gtk struct */ 40 protected GtkBuildableParseContext* gtkBuildableParseContext; 41 protected bool ownedRef; 42 43 /** Get the main Gtk struct */ 44 public GtkBuildableParseContext* getBuildableParseContextStruct(bool transferOwnership = false) 45 { 46 if (transferOwnership) 47 ownedRef = false; 48 return gtkBuildableParseContext; 49 } 50 51 /** the main Gtk struct as a void* */ 52 protected void* getStruct() 53 { 54 return cast(void*)gtkBuildableParseContext; 55 } 56 57 /** 58 * Sets our main struct and passes it to the parent class. 59 */ 60 public this (GtkBuildableParseContext* gtkBuildableParseContext, bool ownedRef = false) 61 { 62 this.gtkBuildableParseContext = gtkBuildableParseContext; 63 this.ownedRef = ownedRef; 64 } 65 66 67 /** 68 * Retrieves the name of the currently open element. 69 * 70 * If called from the start_element or end_element handlers this will 71 * give the element_name as passed to those functions. For the parent 72 * elements, see gtk_buildable_parse_context_get_element_stack(). 73 * 74 * Returns: the name of the currently open element, or %NULL 75 */ 76 public string getElement() 77 { 78 return Str.toString(gtk_buildable_parse_context_get_element(gtkBuildableParseContext)); 79 } 80 81 /** 82 * Retrieves the element stack from the internal state of the parser. 83 * 84 * The returned #GPtrArray is an array of strings where the last item is 85 * the currently open tag (as would be returned by 86 * gtk_buildable_parse_context_get_element()) and the previous item is its 87 * immediate parent. 88 * 89 * This function is intended to be used in the start_element and 90 * end_element handlers where gtk_buildable_parse_context_get_element() 91 * would merely return the name of the element that is being 92 * processed. 93 * 94 * Returns: the element stack, which must not be modified 95 */ 96 public PtrArray getElementStack() 97 { 98 auto __p = gtk_buildable_parse_context_get_element_stack(gtkBuildableParseContext); 99 100 if(__p is null) 101 { 102 return null; 103 } 104 105 return new PtrArray(cast(GPtrArray*) __p); 106 } 107 108 /** 109 * Retrieves the current line number and the number of the character on 110 * that line. Intended for use in error messages; there are no strict 111 * semantics for what constitutes the "current" line number other than 112 * "the best number we could come up with for error messages." 113 * 114 * Params: 115 * lineNumber = return location for a line number, or %NULL 116 * charNumber = return location for a char-on-line number, or %NULL 117 */ 118 public void getPosition(out int lineNumber, out int charNumber) 119 { 120 gtk_buildable_parse_context_get_position(gtkBuildableParseContext, &lineNumber, &charNumber); 121 } 122 123 /** 124 * Completes the process of a temporary sub-parser redirection. 125 * 126 * This function exists to collect the user_data allocated by a 127 * matching call to gtk_buildable_parse_context_push(). It must be called 128 * in the end_element handler corresponding to the start_element 129 * handler during which gtk_buildable_parse_context_push() was called. 130 * You must not call this function from the error callback -- the 131 * @user_data is provided directly to the callback in that case. 132 * 133 * This function is not intended to be directly called by users 134 * interested in invoking subparsers. Instead, it is intended to 135 * be used by the subparsers themselves to implement a higher-level 136 * interface. 137 * 138 * Returns: the user data passed to gtk_buildable_parse_context_push() 139 */ 140 public void* pop() 141 { 142 return gtk_buildable_parse_context_pop(gtkBuildableParseContext); 143 } 144 145 /** 146 * Temporarily redirects markup data to a sub-parser. 147 * 148 * This function may only be called from the start_element handler of 149 * a #GtkBuildableParser. It must be matched with a corresponding call to 150 * gtk_buildable_parse_context_pop() in the matching end_element handler 151 * (except in the case that the parser aborts due to an error). 152 * 153 * All tags, text and other data between the matching tags is 154 * redirected to the subparser given by @parser. @user_data is used 155 * as the user_data for that parser. @user_data is also passed to the 156 * error callback in the event that an error occurs. This includes 157 * errors that occur in subparsers of the subparser. 158 * 159 * The end tag matching the start tag for which this call was made is 160 * handled by the previous parser (which is given its own user_data) 161 * which is why gtk_buildable_parse_context_pop() is provided to allow "one 162 * last access" to the @user_data provided to this function. In the 163 * case of error, the @user_data provided here is passed directly to 164 * the error callback of the subparser and gtk_buildable_parse_context_pop() 165 * should not be called. In either case, if @user_data was allocated 166 * then it ought to be freed from both of these locations. 167 * 168 * This function is not intended to be directly called by users 169 * interested in invoking subparsers. Instead, it is intended to be 170 * used by the subparsers themselves to implement a higher-level 171 * interface. 172 * 173 * For an example of how to use this, see g_markup_parse_context_push() which 174 * has the same kind of API. 175 * 176 * Params: 177 * parser = a #GtkBuildableParser 178 * userData = user data to pass to #GtkBuildableParser functions 179 */ 180 public void push(GtkBuildableParser* parser, void* userData) 181 { 182 gtk_buildable_parse_context_push(gtkBuildableParseContext, parser, userData); 183 } 184 }