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.BitsetIter; 26 27 private import glib.MemorySlice; 28 private import gobject.ObjectG; 29 private import gtk.Bitset; 30 private import gtk.c.functions; 31 public import gtk.c.types; 32 33 34 /** 35 * An opaque, stack-allocated struct for iterating 36 * over the elements of a `GtkBitset`. 37 * 38 * Before a `GtkBitsetIter` can be used, it needs to be initialized with 39 * [func@Gtk.BitsetIter.init_first], [func@Gtk.BitsetIter.init_last] 40 * or [func@Gtk.BitsetIter.init_at]. 41 */ 42 public class BitsetIter 43 { 44 /** the main Gtk struct */ 45 protected GtkBitsetIter* gtkBitsetIter; 46 protected bool ownedRef; 47 48 /** Get the main Gtk struct */ 49 public GtkBitsetIter* getBitsetIterStruct(bool transferOwnership = false) 50 { 51 if (transferOwnership) 52 ownedRef = false; 53 return gtkBitsetIter; 54 } 55 56 /** the main Gtk struct as a void* */ 57 protected void* getStruct() 58 { 59 return cast(void*)gtkBitsetIter; 60 } 61 62 /** 63 * Sets our main struct and passes it to the parent class. 64 */ 65 public this (GtkBitsetIter* gtkBitsetIter, bool ownedRef = false) 66 { 67 this.gtkBitsetIter = gtkBitsetIter; 68 this.ownedRef = ownedRef; 69 } 70 71 72 /** 73 * Gets the current value that @iter points to. 74 * 75 * If @iter is not valid and [method@Gtk.BitsetIter.is_valid] 76 * returns %FALSE, this function returns 0. 77 * 78 * Returns: The current value pointer to by @iter 79 */ 80 public uint getValue() 81 { 82 return gtk_bitset_iter_get_value(gtkBitsetIter); 83 } 84 85 /** 86 * Checks if @iter points to a valid value. 87 * 88 * Returns: %TRUE if @iter points to a valid value 89 */ 90 public bool isValid() 91 { 92 return gtk_bitset_iter_is_valid(gtkBitsetIter) != 0; 93 } 94 95 /** 96 * Moves @iter to the next value in the set. 97 * 98 * If it was already pointing to the last value in the set, 99 * %FALSE is returned and @iter is invalidated. 100 * 101 * Params: 102 * value = Set to the next value 103 * 104 * Returns: %TRUE if a next value existed 105 */ 106 public bool next(out uint value) 107 { 108 return gtk_bitset_iter_next(gtkBitsetIter, &value) != 0; 109 } 110 111 /** 112 * Moves @iter to the previous value in the set. 113 * 114 * If it was already pointing to the first value in the set, 115 * %FALSE is returned and @iter is invalidated. 116 * 117 * Params: 118 * value = Set to the previous value 119 * 120 * Returns: %TRUE if a previous value existed 121 */ 122 public bool previous(out uint value) 123 { 124 return gtk_bitset_iter_previous(gtkBitsetIter, &value) != 0; 125 } 126 127 /** 128 * Initializes @iter to point to @target. 129 * 130 * If @target is not found, finds the next value after it. 131 * If no value >= @target exists in @set, this function returns %FALSE. 132 * 133 * Params: 134 * iter = a pointer to an uninitialized `GtkBitsetIter` 135 * set = a `GtkBitset` 136 * target = target value to start iterating at 137 * value = Set to the found value in @set 138 * 139 * Returns: %TRUE if a value was found. 140 */ 141 public static bool initAt(out BitsetIter iter, Bitset set, uint target, out uint value) 142 { 143 GtkBitsetIter* outiter = sliceNew!GtkBitsetIter(); 144 145 auto __p = gtk_bitset_iter_init_at(outiter, (set is null) ? null : set.getBitsetStruct(), target, &value) != 0; 146 147 iter = ObjectG.getDObject!(BitsetIter)(outiter, true); 148 149 return __p; 150 } 151 152 /** 153 * Initializes an iterator for @set and points it to the first 154 * value in @set. 155 * 156 * If @set is empty, %FALSE is returned and @value is set to %G_MAXUINT. 157 * 158 * Params: 159 * iter = a pointer to an uninitialized `GtkBitsetIter` 160 * set = a `GtkBitset` 161 * value = Set to the first value in @set 162 * 163 * Returns: %TRUE if @set isn't empty. 164 */ 165 public static bool initFirst(out BitsetIter iter, Bitset set, out uint value) 166 { 167 GtkBitsetIter* outiter = sliceNew!GtkBitsetIter(); 168 169 auto __p = gtk_bitset_iter_init_first(outiter, (set is null) ? null : set.getBitsetStruct(), &value) != 0; 170 171 iter = ObjectG.getDObject!(BitsetIter)(outiter, true); 172 173 return __p; 174 } 175 176 /** 177 * Initializes an iterator for @set and points it to the last 178 * value in @set. 179 * 180 * If @set is empty, %FALSE is returned. 181 * 182 * Params: 183 * iter = a pointer to an uninitialized `GtkBitsetIter` 184 * set = a `GtkBitset` 185 * value = Set to the last value in @set 186 * 187 * Returns: %TRUE if @set isn't empty. 188 */ 189 public static bool initLast(out BitsetIter iter, Bitset set, out uint value) 190 { 191 GtkBitsetIter* outiter = sliceNew!GtkBitsetIter(); 192 193 auto __p = gtk_bitset_iter_init_last(outiter, (set is null) ? null : set.getBitsetStruct(), &value) != 0; 194 195 iter = ObjectG.getDObject!(BitsetIter)(outiter, true); 196 197 return __p; 198 } 199 }