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 "QmlZmsg.h"
9 
10 
11 ///
12 //  Return size of message, i.e. number of frames (0 or more).
size()13 size_t QmlZmsg::size () {
14     return zmsg_size (self);
15 };
16 
17 ///
18 //  Return total size of all frames in message.
contentSize()19 size_t QmlZmsg::contentSize () {
20     return zmsg_content_size (self);
21 };
22 
23 ///
24 //  Return message routing ID, if the message came from a ZMQ_SERVER socket.
25 //  Else returns zero.
routingId()26 uint32_t QmlZmsg::routingId () {
27     return zmsg_routing_id (self);
28 };
29 
30 ///
31 //  Set routing ID on message. This is used if/when the message is sent to a
32 //  ZMQ_SERVER socket.
setRoutingId(uint32_t routingId)33 void QmlZmsg::setRoutingId (uint32_t routingId) {
34     zmsg_set_routing_id (self, routingId);
35 };
36 
37 ///
38 //  Push frame to the front of the message, i.e. before all other frames.
39 //  Message takes ownership of frame, will destroy it when message is sent.
40 //  Returns 0 on success, -1 on error. Deprecates zmsg_push, which did not
41 //  nullify the caller's frame reference.
prepend(QmlZframe * frameP)42 int QmlZmsg::prepend (QmlZframe *frameP) {
43     return zmsg_prepend (self, &frameP->self);
44 };
45 
46 ///
47 //  Add frame to the end of the message, i.e. after all other frames.
48 //  Message takes ownership of frame, will destroy it when message is sent.
49 //  Returns 0 on success. Deprecates zmsg_add, which did not nullify the
50 //  caller's frame reference.
append(QmlZframe * frameP)51 int QmlZmsg::append (QmlZframe *frameP) {
52     return zmsg_append (self, &frameP->self);
53 };
54 
55 ///
56 //  Remove first frame from message, if any. Returns frame, or NULL.
pop()57 QmlZframe *QmlZmsg::pop () {
58     QmlZframe *retQ_ = new QmlZframe ();
59     retQ_->self = zmsg_pop (self);
60     return retQ_;
61 };
62 
63 ///
64 //  Push block of memory to front of message, as a new frame.
65 //  Returns 0 on success, -1 on error.
pushmem(const void * data,size_t size)66 int QmlZmsg::pushmem (const void *data, size_t size) {
67     return zmsg_pushmem (self, data, size);
68 };
69 
70 ///
71 //  Add block of memory to the end of the message, as a new frame.
72 //  Returns 0 on success, -1 on error.
addmem(const void * data,size_t size)73 int QmlZmsg::addmem (const void *data, size_t size) {
74     return zmsg_addmem (self, data, size);
75 };
76 
77 ///
78 //  Push string as new frame to front of message.
79 //  Returns 0 on success, -1 on error.
pushstr(const QString & string)80 int QmlZmsg::pushstr (const QString &string) {
81     return zmsg_pushstr (self, string.toUtf8().data());
82 };
83 
84 ///
85 //  Push string as new frame to end of message.
86 //  Returns 0 on success, -1 on error.
addstr(const QString & string)87 int QmlZmsg::addstr (const QString &string) {
88     return zmsg_addstr (self, string.toUtf8().data());
89 };
90 
91 ///
92 //  Push formatted string as new frame to front of message.
93 //  Returns 0 on success, -1 on error.
pushstrf(const QString & format)94 int QmlZmsg::pushstrf (const QString &format) {
95     return zmsg_pushstrf (self, "%s", format.toUtf8().data());
96 };
97 
98 ///
99 //  Push formatted string as new frame to end of message.
100 //  Returns 0 on success, -1 on error.
addstrf(const QString & format)101 int QmlZmsg::addstrf (const QString &format) {
102     return zmsg_addstrf (self, "%s", format.toUtf8().data());
103 };
104 
105 ///
106 //  Pop frame off front of message, return as fresh string. If there were
107 //  no more frames in the message, returns NULL.
popstr()108 QString QmlZmsg::popstr () {
109     char *retStr_ = zmsg_popstr (self);
110     QString retQStr_ = QString (retStr_);
111     free (retStr_);
112     return retQStr_;
113 };
114 
115 ///
116 //  Push encoded message as a new frame. Message takes ownership of
117 //  submessage, so the original is destroyed in this call. Returns 0 on
118 //  success, -1 on error.
addmsg(QmlZmsg * msgP)119 int QmlZmsg::addmsg (QmlZmsg *msgP) {
120     return zmsg_addmsg (self, &msgP->self);
121 };
122 
123 ///
124 //  Remove first submessage from message, if any. Returns zmsg_t, or NULL if
125 //  decoding was not successful.
popmsg()126 QmlZmsg *QmlZmsg::popmsg () {
127     QmlZmsg *retQ_ = new QmlZmsg ();
128     retQ_->self = zmsg_popmsg (self);
129     return retQ_;
130 };
131 
132 ///
133 //  Remove specified frame from list, if present. Does not destroy frame.
remove(QmlZframe * frame)134 void QmlZmsg::remove (QmlZframe *frame) {
135     zmsg_remove (self, frame->self);
136 };
137 
138 ///
139 //  Set cursor to first frame in message. Returns frame, or NULL, if the
140 //  message is empty. Use this to navigate the frames as a list.
first()141 QmlZframe *QmlZmsg::first () {
142     QmlZframe *retQ_ = new QmlZframe ();
143     retQ_->self = zmsg_first (self);
144     return retQ_;
145 };
146 
147 ///
148 //  Return the next frame. If there are no more frames, returns NULL. To move
149 //  to the first frame call zmsg_first(). Advances the cursor.
next()150 QmlZframe *QmlZmsg::next () {
151     QmlZframe *retQ_ = new QmlZframe ();
152     retQ_->self = zmsg_next (self);
153     return retQ_;
154 };
155 
156 ///
157 //  Return the last frame. If there are no frames, returns NULL.
last()158 QmlZframe *QmlZmsg::last () {
159     QmlZframe *retQ_ = new QmlZframe ();
160     retQ_->self = zmsg_last (self);
161     return retQ_;
162 };
163 
164 ///
165 //  Save message to an open file, return 0 if OK, else -1. The message is
166 //  saved as a series of frames, each with length and data. Note that the
167 //  file is NOT guaranteed to be portable between operating systems, not
168 //  versions of CZMQ. The file format is at present undocumented and liable
169 //  to arbitrary change.
save(FILE * file)170 int QmlZmsg::save (FILE *file) {
171     return zmsg_save (self, file);
172 };
173 
174 ///
175 //  Serialize multipart message to a single message frame. Use this method
176 //  to send structured messages across transports that do not support
177 //  multipart data. Allocates and returns a new frame containing the
178 //  serialized message. To decode a serialized message frame, use
179 //  zmsg_decode ().
encode()180 QmlZframe *QmlZmsg::encode () {
181     QmlZframe *retQ_ = new QmlZframe ();
182     retQ_->self = zmsg_encode (self);
183     return retQ_;
184 };
185 
186 ///
187 //  Create copy of message, as new message object. Returns a fresh zmsg_t
188 //  object. If message is null, or memory was exhausted, returns null.
dup()189 QmlZmsg *QmlZmsg::dup () {
190     QmlZmsg *retQ_ = new QmlZmsg ();
191     retQ_->self = zmsg_dup (self);
192     return retQ_;
193 };
194 
195 ///
196 //  Send message to zsys log sink (may be stdout, or system facility as
197 //  configured by zsys_set_logstream).
print()198 void QmlZmsg::print () {
199     zmsg_print (self);
200 };
201 
202 ///
203 //  Return true if the two messages have the same number of frames and each
204 //  frame in the first message is identical to the corresponding frame in the
205 //  other message. As with zframe_eq, return false if either message is NULL.
eq(QmlZmsg * other)206 bool QmlZmsg::eq (QmlZmsg *other) {
207     return zmsg_eq (self, other->self);
208 };
209 
210 ///
211 //  Return signal value, 0 or greater, if message is a signal, -1 if not.
signal()212 int QmlZmsg::signal () {
213     return zmsg_signal (self);
214 };
215 
216 
qmlAttachedProperties(QObject * object)217 QObject* QmlZmsg::qmlAttachedProperties(QObject* object) {
218     return new QmlZmsgAttached(object);
219 }
220 
221 
222 ///
223 //  Send message to destination socket, and destroy the message after sending
224 //  it successfully. If the message has no frames, sends nothing but destroys
225 //  the message anyhow. Nullifies the caller's reference to the message (as
226 //  it is a destructor).
send(QmlZmsg * selfP,void * dest)227 int QmlZmsgAttached::send (QmlZmsg *selfP, void *dest) {
228     return zmsg_send (&selfP->self, dest);
229 };
230 
231 ///
232 //  Send message to destination socket as part of a multipart sequence, and
233 //  destroy the message after sending it successfully. Note that after a
234 //  zmsg_sendm, you must call zmsg_send or another method that sends a final
235 //  message part. If the message has no frames, sends nothing but destroys
236 //  the message anyhow. Nullifies the caller's reference to the message (as
237 //  it is a destructor).
sendm(QmlZmsg * selfP,void * dest)238 int QmlZmsgAttached::sendm (QmlZmsg *selfP, void *dest) {
239     return zmsg_sendm (&selfP->self, dest);
240 };
241 
242 ///
243 //  Probe the supplied object, and report if it looks like a zmsg_t.
is(void * self)244 bool QmlZmsgAttached::is (void *self) {
245     return zmsg_is (self);
246 };
247 
248 ///
249 //  Self test of this class.
test(bool verbose)250 void QmlZmsgAttached::test (bool verbose) {
251     zmsg_test (verbose);
252 };
253 
254 ///
255 //  Create a new empty message object
construct()256 QmlZmsg *QmlZmsgAttached::construct () {
257     QmlZmsg *qmlSelf = new QmlZmsg ();
258     qmlSelf->self = zmsg_new ();
259     return qmlSelf;
260 };
261 
262 ///
263 //  Receive message from socket, returns zmsg_t object or NULL if the recv
264 //  was interrupted. Does a blocking recv. If you want to not block then use
265 //  the zloop class or zmsg_recv_nowait or zmq_poll to check for socket input
266 //  before receiving.
recv(void * source)267 QmlZmsg *QmlZmsgAttached::recv (void *source) {
268     QmlZmsg *qmlSelf = new QmlZmsg ();
269     qmlSelf->self = zmsg_recv (source);
270     return qmlSelf;
271 };
272 
273 ///
274 //  Load/append an open file into new message, return the message.
275 //  Returns NULL if the message could not be loaded.
load(FILE * file)276 QmlZmsg *QmlZmsgAttached::load (FILE *file) {
277     QmlZmsg *qmlSelf = new QmlZmsg ();
278     qmlSelf->self = zmsg_load (file);
279     return qmlSelf;
280 };
281 
282 ///
283 //  Decodes a serialized message frame created by zmsg_encode () and returns
284 //  a new zmsg_t object. Returns NULL if the frame was badly formatted or
285 //  there was insufficient memory to work.
decode(QmlZframe * frame)286 QmlZmsg *QmlZmsgAttached::decode (QmlZframe *frame) {
287     QmlZmsg *qmlSelf = new QmlZmsg ();
288     qmlSelf->self = zmsg_decode (frame->self);
289     return qmlSelf;
290 };
291 
292 ///
293 //  Generate a signal message encoding the given status. A signal is a short
294 //  message carrying a 1-byte success/failure code (by convention, 0 means
295 //  OK). Signals are encoded to be distinguishable from "normal" messages.
constructSignal(byte status)296 QmlZmsg *QmlZmsgAttached::constructSignal (byte status) {
297     QmlZmsg *qmlSelf = new QmlZmsg ();
298     qmlSelf->self = zmsg_new_signal (status);
299     return qmlSelf;
300 };
301 
302 ///
303 //  Destroy a message object and all frames it contains
destruct(QmlZmsg * qmlSelf)304 void QmlZmsgAttached::destruct (QmlZmsg *qmlSelf) {
305     zmsg_destroy (&qmlSelf->self);
306 };
307 
308 /*
309 ################################################################################
310 #  THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY  #
311 #  Read the zproject/README.md for information about making permanent changes. #
312 ################################################################################
313 */
314