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 pango.PgScriptIter; 26 27 private import glib.ConstructionException; 28 private import glib.Str; 29 private import gobject.ObjectG; 30 private import gtkc.pango; 31 public import gtkc.pangotypes; 32 private import gtkd.Loader; 33 34 35 /** 36 * A #PangoScriptIter is used to iterate through a string 37 * and identify ranges in different scripts. 38 */ 39 public class PgScriptIter 40 { 41 /** the main Gtk struct */ 42 protected PangoScriptIter* pangoScriptIter; 43 protected bool ownedRef; 44 45 /** Get the main Gtk struct */ 46 public PangoScriptIter* getPgScriptIterStruct(bool transferOwnership = false) 47 { 48 if (transferOwnership) 49 ownedRef = false; 50 return pangoScriptIter; 51 } 52 53 /** the main Gtk struct as a void* */ 54 protected void* getStruct() 55 { 56 return cast(void*)pangoScriptIter; 57 } 58 59 /** 60 * Sets our main struct and passes it to the parent class. 61 */ 62 public this (PangoScriptIter* pangoScriptIter, bool ownedRef = false) 63 { 64 this.pangoScriptIter = pangoScriptIter; 65 this.ownedRef = ownedRef; 66 } 67 68 ~this () 69 { 70 if ( Linker.isLoaded(LIBRARY_PANGO) && ownedRef ) 71 pango_script_iter_free(pangoScriptIter); 72 } 73 74 75 /** 76 * Frees a #PangoScriptIter created with pango_script_iter_new(). 77 * 78 * Since: 1.4 79 */ 80 public void free() 81 { 82 pango_script_iter_free(pangoScriptIter); 83 ownedRef = false; 84 } 85 86 /** 87 * Gets information about the range to which @iter currently points. 88 * The range is the set of locations p where *start <= p < *end. 89 * (That is, it doesn't include the character stored at *end) 90 * 91 * Params: 92 * start = location to store start position of the range, or %NULL 93 * end = location to store end position of the range, or %NULL 94 * script = location to store script for range, or %NULL 95 * 96 * Since: 1.4 97 */ 98 public void getRange(out string start, out string end, out PangoScript script) 99 { 100 char* outstart = null; 101 char* outend = null; 102 103 pango_script_iter_get_range(pangoScriptIter, &outstart, &outend, &script); 104 105 start = Str.toString(outstart); 106 end = Str.toString(outend); 107 } 108 109 /** 110 * Advances a #PangoScriptIter to the next range. If @iter 111 * is already at the end, it is left unchanged and %FALSE 112 * is returned. 113 * 114 * Returns: %TRUE if @iter was successfully advanced. 115 * 116 * Since: 1.4 117 */ 118 public bool next() 119 { 120 return pango_script_iter_next(pangoScriptIter) != 0; 121 } 122 123 /** 124 * Create a new #PangoScriptIter, used to break a string of 125 * Unicode text into runs by Unicode script. No copy is made of 126 * @text, so the caller needs to make sure it remains valid until 127 * the iterator is freed with pango_script_iter_free(). 128 * 129 * Params: 130 * text = a UTF-8 string 131 * length = length of @text, or -1 if @text is nul-terminated. 132 * 133 * Returns: the new script iterator, initialized 134 * to point at the first range in the text, which should be 135 * freed with pango_script_iter_free(). If the string is 136 * empty, it will point at an empty range. 137 * 138 * Since: 1.4 139 * 140 * Throws: ConstructionException GTK+ fails to create the object. 141 */ 142 public this(string text, int length) 143 { 144 auto p = pango_script_iter_new(Str.toStringz(text), length); 145 146 if(p is null) 147 { 148 throw new ConstructionException("null returned by new"); 149 } 150 151 this(cast(PangoScriptIter*) p); 152 } 153 }