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 #ifndef QML_ZLIST_H 9 #define QML_ZLIST_H 10 11 #include <QtQml> 12 13 #include <czmq.h> 14 #include "qml_czmq_plugin.h" 15 16 17 class QmlZlist : public QObject 18 { 19 Q_OBJECT 20 Q_PROPERTY(bool isNULL READ isNULL) 21 22 public: 23 zlist_t *self; 24 QmlZlist()25 QmlZlist() { self = NULL; } isNULL()26 bool isNULL() { return self == NULL; } 27 28 static QObject* qmlAttachedProperties(QObject* object); // defined in QmlZlist.cpp 29 30 public slots: 31 // Return the item at the head of list. If the list is empty, returns NULL. 32 // Leaves cursor pointing at the head item, or NULL if the list is empty. 33 void *first (); 34 35 // Return the next item. If the list is empty, returns NULL. To move to 36 // the start of the list call zlist_first (). Advances the cursor. 37 void *next (); 38 39 // Return the item at the tail of list. If the list is empty, returns NULL. 40 // Leaves cursor pointing at the tail item, or NULL if the list is empty. 41 void *last (); 42 43 // Return first item in the list, or null, leaves the cursor 44 void *head (); 45 46 // Return last item in the list, or null, leaves the cursor 47 void *tail (); 48 49 // Return the current item of list. If the list is empty, returns NULL. 50 // Leaves cursor pointing at the current item, or NULL if the list is empty. 51 void *item (); 52 53 // Append an item to the end of the list, return 0 if OK or -1 if this 54 // failed for some reason (out of memory). Note that if a duplicator has 55 // been set, this method will also duplicate the item. 56 int append (void *item); 57 58 // Push an item to the start of the list, return 0 if OK or -1 if this 59 // failed for some reason (out of memory). Note that if a duplicator has 60 // been set, this method will also duplicate the item. 61 int push (void *item); 62 63 // Pop the item off the start of the list, if any 64 void *pop (); 65 66 // Checks if an item already is present. Uses compare method to determine if 67 // items are equal. If the compare method is NULL the check will only compare 68 // pointers. Returns true if item is present else false. 69 bool exists (void *item); 70 71 // Remove the specified item from the list if present 72 void remove (void *item); 73 74 // Make a copy of list. If the list has autofree set, the copied list will 75 // duplicate all items, which must be strings. Otherwise, the list will hold 76 // pointers back to the items in the original list. If list is null, returns 77 // NULL. 78 QmlZlist *dup (); 79 80 // Purge all items from list 81 void purge (); 82 83 // Return number of items in the list 84 size_t size (); 85 86 // Sort the list. If the compare function is null, sorts the list by 87 // ascending key value using a straight ASCII comparison. If you specify 88 // a compare function, this decides how items are sorted. The sort is not 89 // stable, so may reorder items with the same keys. The algorithm used is 90 // combsort, a compromise between performance and simplicity. 91 void sort (zlist_compare_fn compare); 92 93 // Set list for automatic item destruction; item values MUST be strings. 94 // By default a list item refers to a value held elsewhere. When you set 95 // this, each time you append or push a list item, zlist will take a copy 96 // of the string value. Then, when you destroy the list, it will free all 97 // item values automatically. If you use any other technique to allocate 98 // list values, you must free them explicitly before destroying the list. 99 // The usual technique is to pop list items and destroy them, until the 100 // list is empty. 101 void autofree (); 102 103 // Sets a compare function for this list. The function compares two items. 104 // It returns an integer less than, equal to, or greater than zero if the 105 // first item is found, respectively, to be less than, to match, or be 106 // greater than the second item. 107 // This function is used for sorting, removal and exists checking. 108 void comparefn (zlist_compare_fn fn); 109 110 // Set a free function for the specified list item. When the item is 111 // destroyed, the free function, if any, is called on that item. 112 // Use this when list items are dynamically allocated, to ensure that 113 // you don't have memory leaks. You can pass 'free' or NULL as a free_fn. 114 // Returns the item, or NULL if there is no such item. 115 void *freefn (void *item, zlist_free_fn fn, bool atTail); 116 }; 117 118 class QmlZlistAttached : public QObject 119 { 120 Q_OBJECT 121 QObject* m_attached; 122 123 public: QmlZlistAttached(QObject * attached)124 QmlZlistAttached (QObject* attached) { 125 Q_UNUSED (attached); 126 }; 127 128 public slots: 129 // Self test of this class. 130 void test (bool verbose); 131 132 // Create a new list container 133 QmlZlist *construct (); 134 135 // Destroy a list container 136 void destruct (QmlZlist *qmlSelf); 137 }; 138 139 140 QML_DECLARE_TYPEINFO(QmlZlist, QML_HAS_ATTACHED_PROPERTIES) 141 142 #endif 143 /* 144 ################################################################################ 145 # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # 146 # Read the zproject/README.md for information about making permanent changes. # 147 ################################################################################ 148 */ 149