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 "QmlZstr.h"
9
10
11
qmlAttachedProperties(QObject * object)12 QObject* QmlZstr::qmlAttachedProperties(QObject* object) {
13 return new QmlZstrAttached(object);
14 }
15
16
17 ///
18 // Receive C string from socket. Caller must free returned string using
19 // zstr_free(). Returns NULL if the context is being terminated or the
20 // process was interrupted.
recv(void * source)21 QString QmlZstrAttached::recv (void *source) {
22 char *retStr_ = zstr_recv (source);
23 QString retQStr_ = QString (retStr_);
24 free (retStr_);
25 return retQStr_;
26 };
27
28 ///
29 // Receive a series of strings (until NULL) from multipart data.
30 // Each string is allocated and filled with string data; if there
31 // are not enough frames, unallocated strings are set to NULL.
32 // Returns -1 if the message could not be read, else returns the
33 // number of strings filled, zero or more. Free each returned string
34 // using zstr_free(). If not enough strings are provided, remaining
35 // multipart frames in the message are dropped.
recvx(void * source,QString stringP)36 int QmlZstrAttached::recvx (void *source, QString stringP) {
37 return zstr_recvx (source, stringP.toUtf8().data());
38 };
39
40 ///
41 // De-compress and receive C string from socket, received as a message
42 // with two frames: size of the uncompressed string, and the string itself.
43 // Caller must free returned string using zstr_free(). Returns NULL if the
44 // context is being terminated or the process was interrupted.
recvCompress(void * source)45 QString QmlZstrAttached::recvCompress (void *source) {
46 char *retStr_ = zstr_recv_compress (source);
47 QString retQStr_ = QString (retStr_);
48 free (retStr_);
49 return retQStr_;
50 };
51
52 ///
53 // Send a C string to a socket, as a frame. The string is sent without
54 // trailing null byte; to read this you can use zstr_recv, or a similar
55 // method that adds a null terminator on the received string. String
56 // may be NULL, which is sent as "".
send(void * dest,const QString & string)57 int QmlZstrAttached::send (void *dest, const QString &string) {
58 return zstr_send (dest, string.toUtf8().data());
59 };
60
61 ///
62 // Send a C string to a socket, as zstr_send(), with a MORE flag, so that
63 // you can send further strings in the same multi-part message.
sendm(void * dest,const QString & string)64 int QmlZstrAttached::sendm (void *dest, const QString &string) {
65 return zstr_sendm (dest, string.toUtf8().data());
66 };
67
68 ///
69 // Send a formatted string to a socket. Note that you should NOT use
70 // user-supplied strings in the format (they may contain '%' which
71 // will create security holes).
sendf(void * dest,const QString & format)72 int QmlZstrAttached::sendf (void *dest, const QString &format) {
73 return zstr_sendf (dest, "%s", format.toUtf8().data());
74 };
75
76 ///
77 // Send a formatted string to a socket, as for zstr_sendf(), with a
78 // MORE flag, so that you can send further strings in the same multi-part
79 // message.
sendfm(void * dest,const QString & format)80 int QmlZstrAttached::sendfm (void *dest, const QString &format) {
81 return zstr_sendfm (dest, "%s", format.toUtf8().data());
82 };
83
84 ///
85 // Send a series of strings (until NULL) as multipart data
86 // Returns 0 if the strings could be sent OK, or -1 on error.
sendx(void * dest,const QString & string)87 int QmlZstrAttached::sendx (void *dest, const QString &string) {
88 return zstr_sendx (dest, string.toUtf8().data());
89 };
90
91 ///
92 // Compress and send a C string to a socket, as a message with two frames:
93 // size of the uncompressed string, and the string itself. The string is
94 // sent without trailing null byte; to read this you can use
95 // zstr_recv_compress, or a similar method that de-compresses and adds a
96 // null terminator on the received string.
sendCompress(void * dest,const QString & string)97 int QmlZstrAttached::sendCompress (void *dest, const QString &string) {
98 return zstr_send_compress (dest, string.toUtf8().data());
99 };
100
101 ///
102 // Compress and send a C string to a socket, as zstr_send_compress(),
103 // with a MORE flag, so that you can send further strings in the same
104 // multi-part message.
sendmCompress(void * dest,const QString & string)105 int QmlZstrAttached::sendmCompress (void *dest, const QString &string) {
106 return zstr_sendm_compress (dest, string.toUtf8().data());
107 };
108
109 ///
110 // Accepts a void pointer and returns a fresh character string. If source
111 // is null, returns an empty string.
str(void * source)112 QString QmlZstrAttached::str (void *source) {
113 char *retStr_ = zstr_str (source);
114 QString retQStr_ = QString (retStr_);
115 free (retStr_);
116 return retQStr_;
117 };
118
119 ///
120 // Free a provided string, and nullify the parent pointer. Safe to call on
121 // a null pointer.
free(QString stringP)122 void QmlZstrAttached::free (QString stringP) {
123 zstr_free (stringP.toUtf8().data());
124 };
125
126 ///
127 // Self test of this class.
test(bool verbose)128 void QmlZstrAttached::test (bool verbose) {
129 zstr_test (verbose);
130 };
131
132 /*
133 ################################################################################
134 # THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY #
135 # Read the zproject/README.md for information about making permanent changes. #
136 ################################################################################
137 */
138