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 glib.SequenceIter;
26 
27 private import glib.Sequence;
28 private import glib.c.functions;
29 public  import glib.c.types;
30 public  import gtkc.glibtypes;
31 
32 
33 /**
34  * The #GSequenceIter struct is an opaque data type representing an
35  * iterator pointing into a #GSequence.
36  */
37 public class SequenceIter
38 {
39 	/** the main Gtk struct */
40 	protected GSequenceIter* gSequenceIter;
41 	protected bool ownedRef;
42 
43 	/** Get the main Gtk struct */
44 	public GSequenceIter* getSequenceIterStruct(bool transferOwnership = false)
45 	{
46 		if (transferOwnership)
47 			ownedRef = false;
48 		return gSequenceIter;
49 	}
50 
51 	/** the main Gtk struct as a void* */
52 	protected void* getStruct()
53 	{
54 		return cast(void*)gSequenceIter;
55 	}
56 
57 	/**
58 	 * Sets our main struct and passes it to the parent class.
59 	 */
60 	public this (GSequenceIter* gSequenceIter, bool ownedRef = false)
61 	{
62 		this.gSequenceIter = gSequenceIter;
63 		this.ownedRef = ownedRef;
64 	}
65 
66 
67 	/**
68 	 * Returns a negative number if @a comes before @b, 0 if they are equal,
69 	 * and a positive number if @a comes after @b.
70 	 *
71 	 * The @a and @b iterators must point into the same sequence.
72 	 *
73 	 * Params:
74 	 *     b = a #GSequenceIter
75 	 *
76 	 * Returns: a negative number if @a comes before @b, 0 if they are
77 	 *     equal, and a positive number if @a comes after @b
78 	 *
79 	 * Since: 2.14
80 	 */
81 	public int compare(SequenceIter b)
82 	{
83 		return g_sequence_iter_compare(gSequenceIter, (b is null) ? null : b.getSequenceIterStruct());
84 	}
85 
86 	/**
87 	 * Returns the position of @iter
88 	 *
89 	 * Returns: the position of @iter
90 	 *
91 	 * Since: 2.14
92 	 */
93 	public int getPosition()
94 	{
95 		return g_sequence_iter_get_position(gSequenceIter);
96 	}
97 
98 	/**
99 	 * Returns the #GSequence that @iter points into.
100 	 *
101 	 * Returns: the #GSequence that @iter points into
102 	 *
103 	 * Since: 2.14
104 	 */
105 	public Sequence getSequence()
106 	{
107 		auto p = g_sequence_iter_get_sequence(gSequenceIter);
108 
109 		if(p is null)
110 		{
111 			return null;
112 		}
113 
114 		return new Sequence(cast(GSequence*) p);
115 	}
116 
117 	/**
118 	 * Returns whether @iter is the begin iterator
119 	 *
120 	 * Returns: whether @iter is the begin iterator
121 	 *
122 	 * Since: 2.14
123 	 */
124 	public bool isBegin()
125 	{
126 		return g_sequence_iter_is_begin(gSequenceIter) != 0;
127 	}
128 
129 	/**
130 	 * Returns whether @iter is the end iterator
131 	 *
132 	 * Returns: Whether @iter is the end iterator
133 	 *
134 	 * Since: 2.14
135 	 */
136 	public bool isEnd()
137 	{
138 		return g_sequence_iter_is_end(gSequenceIter) != 0;
139 	}
140 
141 	/**
142 	 * Returns the #GSequenceIter which is @delta positions away from @iter.
143 	 * If @iter is closer than -@delta positions to the beginning of the sequence,
144 	 * the begin iterator is returned. If @iter is closer than @delta positions
145 	 * to the end of the sequence, the end iterator is returned.
146 	 *
147 	 * Params:
148 	 *     delta = A positive or negative number indicating how many positions away
149 	 *         from @iter the returned #GSequenceIter will be
150 	 *
151 	 * Returns: a #GSequenceIter which is @delta positions away from @iter
152 	 *
153 	 * Since: 2.14
154 	 */
155 	public SequenceIter move(int delta)
156 	{
157 		auto p = g_sequence_iter_move(gSequenceIter, delta);
158 
159 		if(p is null)
160 		{
161 			return null;
162 		}
163 
164 		return new SequenceIter(cast(GSequenceIter*) p);
165 	}
166 
167 	/**
168 	 * Returns an iterator pointing to the next position after @iter.
169 	 * If @iter is the end iterator, the end iterator is returned.
170 	 *
171 	 * Returns: a #GSequenceIter pointing to the next position after @iter
172 	 *
173 	 * Since: 2.14
174 	 */
175 	public SequenceIter next()
176 	{
177 		auto p = g_sequence_iter_next(gSequenceIter);
178 
179 		if(p is null)
180 		{
181 			return null;
182 		}
183 
184 		return new SequenceIter(cast(GSequenceIter*) p);
185 	}
186 
187 	/**
188 	 * Returns an iterator pointing to the previous position before @iter.
189 	 * If @iter is the begin iterator, the begin iterator is returned.
190 	 *
191 	 * Returns: a #GSequenceIter pointing to the previous position
192 	 *     before @iter
193 	 *
194 	 * Since: 2.14
195 	 */
196 	public SequenceIter prev()
197 	{
198 		auto p = g_sequence_iter_prev(gSequenceIter);
199 
200 		if(p is null)
201 		{
202 			return null;
203 		}
204 
205 		return new SequenceIter(cast(GSequenceIter*) p);
206 	}
207 }