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 "qczmq.h"
9 
10 ///
11 //  Copy-construct to return the proper wrapped c types
QZlist(zlist_t * self,QObject * qObjParent)12 QZlist::QZlist (zlist_t *self, QObject *qObjParent) : QObject (qObjParent)
13 {
14     this->self = self;
15 }
16 
17 
18 ///
19 //  Create a new list container
QZlist(QObject * qObjParent)20 QZlist::QZlist (QObject *qObjParent) : QObject (qObjParent)
21 {
22     this->self = zlist_new ();
23 }
24 
25 ///
26 //  Destroy a list container
~QZlist()27 QZlist::~QZlist ()
28 {
29     zlist_destroy (&self);
30 }
31 
32 ///
33 //  Return the item at the head of list. If the list is empty, returns NULL.
34 //  Leaves cursor pointing at the head item, or NULL if the list is empty.
first()35 void * QZlist::first ()
36 {
37     void * rv = zlist_first (self);
38     return rv;
39 }
40 
41 ///
42 //  Return the next item. If the list is empty, returns NULL. To move to
43 //  the start of the list call zlist_first (). Advances the cursor.
next()44 void * QZlist::next ()
45 {
46     void * rv = zlist_next (self);
47     return rv;
48 }
49 
50 ///
51 //  Return the item at the tail of list. If the list is empty, returns NULL.
52 //  Leaves cursor pointing at the tail item, or NULL if the list is empty.
last()53 void * QZlist::last ()
54 {
55     void * rv = zlist_last (self);
56     return rv;
57 }
58 
59 ///
60 //  Return first item in the list, or null, leaves the cursor
head()61 void * QZlist::head ()
62 {
63     void * rv = zlist_head (self);
64     return rv;
65 }
66 
67 ///
68 //  Return last item in the list, or null, leaves the cursor
tail()69 void * QZlist::tail ()
70 {
71     void * rv = zlist_tail (self);
72     return rv;
73 }
74 
75 ///
76 //  Return the current item of list. If the list is empty, returns NULL.
77 //  Leaves cursor pointing at the current item, or NULL if the list is empty.
item()78 void * QZlist::item ()
79 {
80     void * rv = zlist_item (self);
81     return rv;
82 }
83 
84 ///
85 //  Append an item to the end of the list, return 0 if OK or -1 if this
86 //  failed for some reason (out of memory). Note that if a duplicator has
87 //  been set, this method will also duplicate the item.
append(void * item)88 int QZlist::append (void *item)
89 {
90     int rv = zlist_append (self, item);
91     return rv;
92 }
93 
94 ///
95 //  Push an item to the start of the list, return 0 if OK or -1 if this
96 //  failed for some reason (out of memory). Note that if a duplicator has
97 //  been set, this method will also duplicate the item.
push(void * item)98 int QZlist::push (void *item)
99 {
100     int rv = zlist_push (self, item);
101     return rv;
102 }
103 
104 ///
105 //  Pop the item off the start of the list, if any
pop()106 void * QZlist::pop ()
107 {
108     void * rv = zlist_pop (self);
109     return rv;
110 }
111 
112 ///
113 //  Checks if an item already is present. Uses compare method to determine if
114 //  items are equal. If the compare method is NULL the check will only compare
115 //  pointers. Returns true if item is present else false.
exists(void * item)116 bool QZlist::exists (void *item)
117 {
118     bool rv = zlist_exists (self, item);
119     return rv;
120 }
121 
122 ///
123 //  Remove the specified item from the list if present
remove(void * item)124 void QZlist::remove (void *item)
125 {
126     zlist_remove (self, item);
127 
128 }
129 
130 ///
131 //  Make a copy of list. If the list has autofree set, the copied list will
132 //  duplicate all items, which must be strings. Otherwise, the list will hold
133 //  pointers back to the items in the original list. If list is null, returns
134 //  NULL.
dup()135 QZlist * QZlist::dup ()
136 {
137     QZlist *rv = new QZlist (zlist_dup (self));
138     return rv;
139 }
140 
141 ///
142 //  Purge all items from list
purge()143 void QZlist::purge ()
144 {
145     zlist_purge (self);
146 
147 }
148 
149 ///
150 //  Return number of items in the list
size()151 size_t QZlist::size ()
152 {
153     size_t rv = zlist_size (self);
154     return rv;
155 }
156 
157 ///
158 //  Sort the list. If the compare function is null, sorts the list by
159 //  ascending key value using a straight ASCII comparison. If you specify
160 //  a compare function, this decides how items are sorted. The sort is not
161 //  stable, so may reorder items with the same keys. The algorithm used is
162 //  combsort, a compromise between performance and simplicity.
sort(zlist_compare_fn compare)163 void QZlist::sort (zlist_compare_fn compare)
164 {
165     zlist_sort (self, compare);
166 
167 }
168 
169 ///
170 //  Set list for automatic item destruction; item values MUST be strings.
171 //  By default a list item refers to a value held elsewhere. When you set
172 //  this, each time you append or push a list item, zlist will take a copy
173 //  of the string value. Then, when you destroy the list, it will free all
174 //  item values automatically. If you use any other technique to allocate
175 //  list values, you must free them explicitly before destroying the list.
176 //  The usual technique is to pop list items and destroy them, until the
177 //  list is empty.
autofree()178 void QZlist::autofree ()
179 {
180     zlist_autofree (self);
181 
182 }
183 
184 ///
185 //  Sets a compare function for this list. The function compares two items.
186 //  It returns an integer less than, equal to, or greater than zero if the
187 //  first item is found, respectively, to be less than, to match, or be
188 //  greater than the second item.
189 //  This function is used for sorting, removal and exists checking.
comparefn(zlist_compare_fn fn)190 void QZlist::comparefn (zlist_compare_fn fn)
191 {
192     zlist_comparefn (self, fn);
193 
194 }
195 
196 ///
197 //  Set a free function for the specified list item. When the item is
198 //  destroyed, the free function, if any, is called on that item.
199 //  Use this when list items are dynamically allocated, to ensure that
200 //  you don't have memory leaks. You can pass 'free' or NULL as a free_fn.
201 //  Returns the item, or NULL if there is no such item.
freefn(void * item,zlist_free_fn fn,bool atTail)202 void * QZlist::freefn (void *item, zlist_free_fn fn, bool atTail)
203 {
204     void * rv = zlist_freefn (self, item, fn, atTail);
205     return rv;
206 }
207 
208 ///
209 //  Self test of this class.
test(bool verbose)210 void QZlist::test (bool verbose)
211 {
212     zlist_test (verbose);
213 
214 }
215 /*
216 ################################################################################
217 #  THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY  #
218 #  Read the zproject/README.md for information about making permanent changes. #
219 ################################################################################
220 */
221