1 /*
2 ################################################################################
3 #  THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY  #
4 #  Read the zproject/README.md for information about making permanent changes. #
5 ################################################################################
6 */
7 
8 #include "QmlZlistx.h"
9 
10 
11 ///
12 //  Add an item to the head of the list. Calls the item duplicator, if any,
13 //  on the item. Resets cursor to list head. Returns an item handle on
14 //  success, NULL if memory was exhausted.
addStart(void * item)15 void *QmlZlistx::addStart (void *item) {
16     return zlistx_add_start (self, item);
17 };
18 
19 ///
20 //  Add an item to the tail of the list. Calls the item duplicator, if any,
21 //  on the item. Resets cursor to list head. Returns an item handle on
22 //  success, NULL if memory was exhausted.
addEnd(void * item)23 void *QmlZlistx::addEnd (void *item) {
24     return zlistx_add_end (self, item);
25 };
26 
27 ///
28 //  Return the number of items in the list
size()29 size_t QmlZlistx::size () {
30     return zlistx_size (self);
31 };
32 
33 ///
34 //  Return first item in the list, or null, leaves the cursor
head()35 void *QmlZlistx::head () {
36     return zlistx_head (self);
37 };
38 
39 ///
40 //  Return last item in the list, or null, leaves the cursor
tail()41 void *QmlZlistx::tail () {
42     return zlistx_tail (self);
43 };
44 
45 ///
46 //  Return the item at the head of list. If the list is empty, returns NULL.
47 //  Leaves cursor pointing at the head item, or NULL if the list is empty.
first()48 void *QmlZlistx::first () {
49     return zlistx_first (self);
50 };
51 
52 ///
53 //  Return the next item. At the end of the list (or in an empty list),
54 //  returns NULL. Use repeated zlistx_next () calls to work through the list
55 //  from zlistx_first (). First time, acts as zlistx_first().
next()56 void *QmlZlistx::next () {
57     return zlistx_next (self);
58 };
59 
60 ///
61 //  Return the previous item. At the start of the list (or in an empty list),
62 //  returns NULL. Use repeated zlistx_prev () calls to work through the list
63 //  backwards from zlistx_last (). First time, acts as zlistx_last().
prev()64 void *QmlZlistx::prev () {
65     return zlistx_prev (self);
66 };
67 
68 ///
69 //  Return the item at the tail of list. If the list is empty, returns NULL.
70 //  Leaves cursor pointing at the tail item, or NULL if the list is empty.
last()71 void *QmlZlistx::last () {
72     return zlistx_last (self);
73 };
74 
75 ///
76 //  Returns the value of the item at the cursor, or NULL if the cursor is
77 //  not pointing to an item.
item()78 void *QmlZlistx::item () {
79     return zlistx_item (self);
80 };
81 
82 ///
83 //  Returns the handle of the item at the cursor, or NULL if the cursor is
84 //  not pointing to an item.
cursor()85 void *QmlZlistx::cursor () {
86     return zlistx_cursor (self);
87 };
88 
89 ///
90 //  Find an item in the list, searching from the start. Uses the item
91 //  comparator, if any, else compares item values directly. Returns the
92 //  item handle found, or NULL. Sets the cursor to the found item, if any.
find(void * item)93 void *QmlZlistx::find (void *item) {
94     return zlistx_find (self, item);
95 };
96 
97 ///
98 //  Detach an item from the list, using its handle. The item is not modified,
99 //  and the caller is responsible for destroying it if necessary. If handle is
100 //  null, detaches the first item on the list. Returns item that was detached,
101 //  or null if none was. If cursor was at item, moves cursor to previous item,
102 //  so you can detach items while iterating forwards through a list.
detach(void * handle)103 void *QmlZlistx::detach (void *handle) {
104     return zlistx_detach (self, handle);
105 };
106 
107 ///
108 //  Detach item at the cursor, if any, from the list. The item is not modified,
109 //  and the caller is responsible for destroying it as necessary. Returns item
110 //  that was detached, or null if none was. Moves cursor to previous item, so
111 //  you can detach items while iterating forwards through a list.
detachCur()112 void *QmlZlistx::detachCur () {
113     return zlistx_detach_cur (self);
114 };
115 
116 ///
117 //  Delete an item, using its handle. Calls the item destructor is any is
118 //  set. If handle is null, deletes the first item on the list. Returns 0
119 //  if an item was deleted, -1 if not. If cursor was at item, moves cursor
120 //  to previous item, so you can delete items while iterating forwards
121 //  through a list.
122 int QmlZlistx::delete (void *handle) {
123     return zlistx_delete (self, handle);
124 };
125 
126 ///
127 //  Move an item to the start of the list, via its handle.
moveStart(void * handle)128 void QmlZlistx::moveStart (void *handle) {
129     zlistx_move_start (self, handle);
130 };
131 
132 ///
133 //  Move an item to the end of the list, via its handle.
moveEnd(void * handle)134 void QmlZlistx::moveEnd (void *handle) {
135     zlistx_move_end (self, handle);
136 };
137 
138 ///
139 //  Remove all items from the list, and destroy them if the item destructor
140 //  is set.
purge()141 void QmlZlistx::purge () {
142     zlistx_purge (self);
143 };
144 
145 ///
146 //  Sort the list. If an item comparator was set, calls that to compare
147 //  items, otherwise compares on item value. The sort is not stable, so may
148 //  reorder equal items.
sort()149 void QmlZlistx::sort () {
150     zlistx_sort (self);
151 };
152 
153 ///
154 //  Create a new node and insert it into a sorted list. Calls the item
155 //  duplicator, if any, on the item. If low_value is true, starts searching
156 //  from the start of the list, otherwise searches from the end. Use the item
157 //  comparator, if any, to find where to place the new node. Returns a handle
158 //  to the new node, or NULL if memory was exhausted. Resets the cursor to the
159 //  list head.
insert(void * item,bool lowValue)160 void *QmlZlistx::insert (void *item, bool lowValue) {
161     return zlistx_insert (self, item, lowValue);
162 };
163 
164 ///
165 //  Move an item, specified by handle, into position in a sorted list. Uses
166 //  the item comparator, if any, to determine the new location. If low_value
167 //  is true, starts searching from the start of the list, otherwise searches
168 //  from the end.
reorder(void * handle,bool lowValue)169 void QmlZlistx::reorder (void *handle, bool lowValue) {
170     zlistx_reorder (self, handle, lowValue);
171 };
172 
173 ///
174 //  Make a copy of the list; items are duplicated if you set a duplicator
175 //  for the list, otherwise not. Copying a null reference returns a null
176 //  reference.
dup()177 QmlZlistx *QmlZlistx::dup () {
178     QmlZlistx *retQ_ = new QmlZlistx ();
179     retQ_->self = zlistx_dup (self);
180     return retQ_;
181 };
182 
183 ///
184 //  Set a user-defined deallocator for list items; by default items are not
185 //  freed when the list is destroyed.
setDestructor(zlistx_destructor_fn destructor)186 void QmlZlistx::setDestructor (zlistx_destructor_fn destructor) {
187     zlistx_set_destructor (self, destructor);
188 };
189 
190 ///
191 //  Set a user-defined duplicator for list items; by default items are not
192 //  copied when the list is duplicated.
setDuplicator(zlistx_duplicator_fn duplicator)193 void QmlZlistx::setDuplicator (zlistx_duplicator_fn duplicator) {
194     zlistx_set_duplicator (self, duplicator);
195 };
196 
197 ///
198 //  Set a user-defined comparator for zlistx_find and zlistx_sort; the method
199 //  must return -1, 0, or 1 depending on whether item1 is less than, equal to,
200 //  or greater than, item2.
setComparator(zlistx_comparator_fn comparator)201 void QmlZlistx::setComparator (zlistx_comparator_fn comparator) {
202     zlistx_set_comparator (self, comparator);
203 };
204 
205 
qmlAttachedProperties(QObject * object)206 QObject* QmlZlistx::qmlAttachedProperties(QObject* object) {
207     return new QmlZlistxAttached(object);
208 }
209 
210 
211 ///
212 //  Returns the item associated with the given list handle, or NULL if passed
213 //  in handle is NULL. Asserts that the passed in handle points to a list element.
handleItem(void * handle)214 void *QmlZlistxAttached::handleItem (void *handle) {
215     return zlistx_handle_item (handle);
216 };
217 
218 ///
219 //  Self test of this class.
test(bool verbose)220 void QmlZlistxAttached::test (bool verbose) {
221     zlistx_test (verbose);
222 };
223 
224 ///
225 //  Create a new, empty list.
construct()226 QmlZlistx *QmlZlistxAttached::construct () {
227     QmlZlistx *qmlSelf = new QmlZlistx ();
228     qmlSelf->self = zlistx_new ();
229     return qmlSelf;
230 };
231 
232 ///
233 //  Destroy a list. If an item destructor was specified, all items in the
234 //  list are automatically destroyed as well.
destruct(QmlZlistx * qmlSelf)235 void QmlZlistxAttached::destruct (QmlZlistx *qmlSelf) {
236     zlistx_destroy (&qmlSelf->self);
237 };
238 
239 /*
240 ################################################################################
241 #  THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY  #
242 #  Read the zproject/README.md for information about making permanent changes. #
243 ################################################################################
244 */
245