1 | /****************************************************************************
|
---|
2 | ** $Id: qucom.cpp 2 2005-11-16 15:49:26Z dmik $
|
---|
3 | **
|
---|
4 | ** Implementation of the QUcom classes
|
---|
5 | **
|
---|
6 | ** Created : 990101
|
---|
7 | **
|
---|
8 | ** Copyright (C) 1992-2002 Trolltech AS. All rights reserved.
|
---|
9 | **
|
---|
10 | ** This file is part of the tools module of the Qt GUI Toolkit.
|
---|
11 | **
|
---|
12 | ** This file may be distributed under the terms of the Q Public License
|
---|
13 | ** as defined by Trolltech AS of Norway and appearing in the file
|
---|
14 | ** LICENSE.QPL included in the packaging of this file.
|
---|
15 | **
|
---|
16 | ** This file may be distributed and/or modified under the terms of the
|
---|
17 | ** GNU General Public License version 2 as published by the Free Software
|
---|
18 | ** Foundation and appearing in the file LICENSE.GPL included in the
|
---|
19 | ** packaging of this file.
|
---|
20 | **
|
---|
21 | ** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition
|
---|
22 | ** licenses may use this file in accordance with the Qt Commercial License
|
---|
23 | ** Agreement provided with the Software.
|
---|
24 | **
|
---|
25 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
|
---|
26 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
---|
27 | **
|
---|
28 | ** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
|
---|
29 | ** information about Qt Commercial License Agreements.
|
---|
30 | ** See http://www.trolltech.com/qpl/ for QPL licensing information.
|
---|
31 | ** See http://www.trolltech.com/gpl/ for GPL licensing information.
|
---|
32 | **
|
---|
33 | ** Contact info@trolltech.com if any conditions of this licensing are
|
---|
34 | ** not clear to you.
|
---|
35 | **
|
---|
36 | **********************************************************************/
|
---|
37 |
|
---|
38 | #include "qucom_p.h"
|
---|
39 |
|
---|
40 | // Standard types
|
---|
41 |
|
---|
42 | // {DE56510E-4E9F-4b76-A3C2-D1E2EF42F1AC}
|
---|
43 | const QUuid TID_QUType_Null( 0xde56510e, 0x4e9f, 0x4b76, 0xa3, 0xc2, 0xd1, 0xe2, 0xef, 0x42, 0xf1, 0xac );
|
---|
44 | const QUuid *QUType_Null::uuid() const { return &TID_QUType_Null; }
|
---|
45 | const char *QUType_Null::desc() const { return "null"; }
|
---|
46 | bool QUType_Null::canConvertFrom( QUObject *, QUType * ) { return FALSE; }
|
---|
47 | bool QUType_Null::canConvertTo( QUObject *, QUType * ) { return FALSE; }
|
---|
48 | bool QUType_Null::convertFrom( QUObject *, QUType * ) { return FALSE; }
|
---|
49 | bool QUType_Null::convertTo( QUObject *, QUType * ) { return FALSE; }
|
---|
50 | void QUType_Null::clear( QUObject *) {};
|
---|
51 | int QUType_Null::serializeTo( QUObject *, QUBuffer * ) { return 0; }
|
---|
52 | int QUType_Null::serializeFrom( QUObject *, QUBuffer * ) { return 0; };
|
---|
53 | QUType_Null static_QUType_Null;
|
---|
54 |
|
---|
55 |
|
---|
56 | // {7EE17B08-5419-47e2-9776-8EEA112DCAEC}
|
---|
57 | const QUuid TID_QUType_enum( 0x7ee17b08, 0x5419, 0x47e2, 0x97, 0x76, 0x8e, 0xea, 0x11, 0x2d, 0xca, 0xec );
|
---|
58 | QUType_enum static_QUType_enum;
|
---|
59 | const QUuid *QUType_enum::uuid() const { return &TID_QUType_enum; }
|
---|
60 | const char *QUType_enum::desc() const { return "enum"; }
|
---|
61 | void QUType_enum::set( QUObject *o, int v )
|
---|
62 | {
|
---|
63 | o->payload.i = v;
|
---|
64 | o->type = this;
|
---|
65 | }
|
---|
66 |
|
---|
67 | bool QUType_enum::canConvertFrom( QUObject *o, QUType *t )
|
---|
68 | {
|
---|
69 | if ( isEqual( t, &static_QUType_int ) ) // ## todo unsigned int?
|
---|
70 | return TRUE;
|
---|
71 |
|
---|
72 | return t->canConvertTo( o, this );
|
---|
73 | }
|
---|
74 |
|
---|
75 | bool QUType_enum::canConvertTo( QUObject * /*o*/, QUType *t )
|
---|
76 | {
|
---|
77 | return isEqual( t, &static_QUType_int );
|
---|
78 | }
|
---|
79 |
|
---|
80 | bool QUType_enum::convertFrom( QUObject *o, QUType *t )
|
---|
81 | {
|
---|
82 | if ( isEqual( t, &static_QUType_int ) ) // ## todo unsigned int?
|
---|
83 | ;
|
---|
84 | else
|
---|
85 | return t->convertTo( o, this );
|
---|
86 |
|
---|
87 | o->type = this;
|
---|
88 | return TRUE;
|
---|
89 | }
|
---|
90 |
|
---|
91 | bool QUType_enum::convertTo( QUObject *o, QUType *t )
|
---|
92 | {
|
---|
93 | if ( isEqual( t, &static_QUType_int ) ) {
|
---|
94 | o->type = &static_QUType_int;
|
---|
95 | return TRUE;
|
---|
96 | }
|
---|
97 | return FALSE;
|
---|
98 | }
|
---|
99 |
|
---|
100 | int QUType_enum::serializeTo( QUObject *, QUBuffer * )
|
---|
101 | {
|
---|
102 | return 0;
|
---|
103 | }
|
---|
104 |
|
---|
105 | int QUType_enum::serializeFrom( QUObject *, QUBuffer * )
|
---|
106 | {
|
---|
107 | return 0;
|
---|
108 | }
|
---|
109 |
|
---|
110 | // {8AC26448-5AB4-49eb-968C-8F30AB13D732}
|
---|
111 | const QUuid TID_QUType_ptr( 0x8ac26448, 0x5ab4, 0x49eb, 0x96, 0x8c, 0x8f, 0x30, 0xab, 0x13, 0xd7, 0x32 );
|
---|
112 | QUType_ptr static_QUType_ptr;
|
---|
113 | const QUuid *QUType_ptr::uuid() const { return &TID_QUType_ptr; }
|
---|
114 | const char *QUType_ptr::desc() const { return "ptr"; }
|
---|
115 |
|
---|
116 | void QUType_ptr::set( QUObject *o, const void* v )
|
---|
117 | {
|
---|
118 | o->payload.ptr = (void*) v;
|
---|
119 | o->type = this;
|
---|
120 | }
|
---|
121 |
|
---|
122 | bool QUType_ptr::canConvertFrom( QUObject *o, QUType *t )
|
---|
123 | {
|
---|
124 | return t->canConvertTo( o, this );
|
---|
125 | }
|
---|
126 |
|
---|
127 | bool QUType_ptr::canConvertTo( QUObject *, QUType * )
|
---|
128 | {
|
---|
129 | return FALSE;
|
---|
130 | }
|
---|
131 |
|
---|
132 | bool QUType_ptr::convertFrom( QUObject *o, QUType *t )
|
---|
133 | {
|
---|
134 | return t->convertTo( o, this );
|
---|
135 | }
|
---|
136 |
|
---|
137 | bool QUType_ptr::convertTo( QUObject *, QUType * )
|
---|
138 | {
|
---|
139 | return FALSE;
|
---|
140 | }
|
---|
141 |
|
---|
142 | int QUType_ptr::serializeTo( QUObject *, QUBuffer * )
|
---|
143 | {
|
---|
144 | return 0;
|
---|
145 | }
|
---|
146 |
|
---|
147 | int QUType_ptr::serializeFrom( QUObject *, QUBuffer * )
|
---|
148 | {
|
---|
149 | return 0;
|
---|
150 | }
|
---|
151 |
|
---|
152 | // {97A2594D-6496-4402-A11E-55AEF2D4D25C}
|
---|
153 | const QUuid TID_QUType_iface( 0x97a2594d, 0x6496, 0x4402, 0xa1, 0x1e, 0x55, 0xae, 0xf2, 0xd4, 0xd2, 0x5c );
|
---|
154 | QUType_iface static_QUType_iface;
|
---|
155 | const QUuid *QUType_iface::uuid() const { return &TID_QUType_iface; }
|
---|
156 | const char *QUType_iface::desc() const { return "UnknownInterface"; }
|
---|
157 |
|
---|
158 | void QUType_iface::set( QUObject *o, QUnknownInterface* iface )
|
---|
159 | {
|
---|
160 | o->payload.iface = iface;
|
---|
161 | o->type = this;
|
---|
162 | }
|
---|
163 |
|
---|
164 | bool QUType_iface::canConvertFrom( QUObject *o, QUType *t )
|
---|
165 | {
|
---|
166 | return t->canConvertTo( o, this );
|
---|
167 | }
|
---|
168 |
|
---|
169 | bool QUType_iface::canConvertTo( QUObject *, QUType * )
|
---|
170 | {
|
---|
171 | return FALSE;
|
---|
172 | }
|
---|
173 |
|
---|
174 | bool QUType_iface::convertFrom( QUObject *o, QUType *t )
|
---|
175 | {
|
---|
176 | return t->convertTo( o, this );
|
---|
177 | }
|
---|
178 |
|
---|
179 | bool QUType_iface::convertTo( QUObject *, QUType * )
|
---|
180 | {
|
---|
181 | return FALSE;
|
---|
182 | }
|
---|
183 |
|
---|
184 | int QUType_iface::serializeTo( QUObject *, QUBuffer * )
|
---|
185 | {
|
---|
186 | return 0;
|
---|
187 | }
|
---|
188 |
|
---|
189 | int QUType_iface::serializeFrom( QUObject *, QUBuffer * )
|
---|
190 | {
|
---|
191 | return 0;
|
---|
192 | }
|
---|
193 |
|
---|
194 | // {2F358164-E28F-4bf4-9FA9-4E0CDCABA50B}
|
---|
195 | const QUuid TID_QUType_idisp( 0x2f358164, 0xe28f, 0x4bf4, 0x9f, 0xa9, 0x4e, 0xc, 0xdc, 0xab, 0xa5, 0xb );
|
---|
196 | QUType_idisp static_QUType_idisp;
|
---|
197 | const QUuid *QUType_idisp::uuid() const { return &TID_QUType_idisp; }
|
---|
198 | const char *QUType_idisp::desc() const { return "DispatchInterface"; }
|
---|
199 |
|
---|
200 | void QUType_idisp::set( QUObject *o, QDispatchInterface* idisp )
|
---|
201 | {
|
---|
202 | o->payload.idisp = idisp;
|
---|
203 | o->type = this;
|
---|
204 | }
|
---|
205 |
|
---|
206 | bool QUType_idisp::canConvertFrom( QUObject *o, QUType *t )
|
---|
207 | {
|
---|
208 | return t->canConvertTo( o, this );
|
---|
209 | }
|
---|
210 |
|
---|
211 | bool QUType_idisp::canConvertTo( QUObject * /*o*/, QUType *t )
|
---|
212 | {
|
---|
213 | return isEqual( t, &static_QUType_iface );
|
---|
214 | }
|
---|
215 |
|
---|
216 | bool QUType_idisp::convertFrom( QUObject *o, QUType *t )
|
---|
217 | {
|
---|
218 | return t->convertTo( o, this );
|
---|
219 | }
|
---|
220 |
|
---|
221 | bool QUType_idisp::convertTo( QUObject *o, QUType *t )
|
---|
222 | {
|
---|
223 | #ifndef QT_NO_COMPONENT
|
---|
224 | if ( isEqual( t, &static_QUType_iface ) ) {
|
---|
225 | o->payload.iface = (QUnknownInterface*)o->payload.idisp;
|
---|
226 | o->type = &static_QUType_iface;
|
---|
227 | return TRUE;
|
---|
228 | }
|
---|
229 | #endif
|
---|
230 | return FALSE;
|
---|
231 | }
|
---|
232 |
|
---|
233 | int QUType_idisp::serializeTo( QUObject *, QUBuffer * )
|
---|
234 | {
|
---|
235 | return 0;
|
---|
236 | }
|
---|
237 |
|
---|
238 | int QUType_idisp::serializeFrom( QUObject *, QUBuffer * )
|
---|
239 | {
|
---|
240 | return 0;
|
---|
241 | }
|
---|
242 |
|
---|
243 | // {CA42115D-13D0-456c-82B5-FC10187F313E}
|
---|
244 | const QUuid TID_QUType_bool( 0xca42115d, 0x13d0, 0x456c, 0x82, 0xb5, 0xfc, 0x10, 0x18, 0x7f, 0x31, 0x3e );
|
---|
245 | QUType_bool static_QUType_bool;
|
---|
246 | const QUuid *QUType_bool::uuid() const { return &TID_QUType_bool; }
|
---|
247 | const char *QUType_bool::desc() const { return "bool"; }
|
---|
248 |
|
---|
249 | void QUType_bool::set( QUObject *o, bool v )
|
---|
250 | {
|
---|
251 | o->payload.b = v;
|
---|
252 | o->type = this;
|
---|
253 | }
|
---|
254 |
|
---|
255 | bool QUType_bool::canConvertFrom( QUObject *o, QUType *t )
|
---|
256 | {
|
---|
257 | return t->canConvertTo( o, this );
|
---|
258 | }
|
---|
259 |
|
---|
260 | bool QUType_bool::canConvertTo( QUObject *, QUType * )
|
---|
261 | {
|
---|
262 | return FALSE;
|
---|
263 | }
|
---|
264 |
|
---|
265 | bool QUType_bool::convertFrom( QUObject *o, QUType *t )
|
---|
266 | {
|
---|
267 | return t->convertTo( o, this );
|
---|
268 | }
|
---|
269 |
|
---|
270 | bool QUType_bool::convertTo( QUObject *, QUType * )
|
---|
271 | {
|
---|
272 | return FALSE;
|
---|
273 | }
|
---|
274 |
|
---|
275 | int QUType_bool::serializeTo( QUObject *, QUBuffer * )
|
---|
276 | {
|
---|
277 | return 0;
|
---|
278 | }
|
---|
279 |
|
---|
280 | int QUType_bool::serializeFrom( QUObject *, QUBuffer * )
|
---|
281 | {
|
---|
282 | return 0;
|
---|
283 | }
|
---|
284 |
|
---|
285 | // {53C1F3BE-73C3-4c7d-9E05-CCF09EB676B5}
|
---|
286 | const QUuid TID_QUType_int( 0x53c1f3be, 0x73c3, 0x4c7d, 0x9e, 0x5, 0xcc, 0xf0, 0x9e, 0xb6, 0x76, 0xb5 );
|
---|
287 | QUType_int static_QUType_int;
|
---|
288 | const QUuid *QUType_int::uuid() const { return &TID_QUType_int; }
|
---|
289 | const char *QUType_int::desc() const { return "int"; }
|
---|
290 |
|
---|
291 | void QUType_int::set( QUObject *o, int v )
|
---|
292 | {
|
---|
293 | o->payload.i = v;
|
---|
294 | o->type = this;
|
---|
295 | }
|
---|
296 |
|
---|
297 | bool QUType_int::canConvertFrom( QUObject *o, QUType *t )
|
---|
298 | {
|
---|
299 | if ( isEqual( t, &static_QUType_double ) )
|
---|
300 | return TRUE;
|
---|
301 |
|
---|
302 | return t->canConvertTo( o, this );
|
---|
303 | }
|
---|
304 |
|
---|
305 | bool QUType_int::canConvertTo( QUObject * /*o*/, QUType *t )
|
---|
306 | {
|
---|
307 | return isEqual( t, &static_QUType_double );
|
---|
308 | }
|
---|
309 |
|
---|
310 | bool QUType_int::convertFrom( QUObject *o, QUType *t )
|
---|
311 | {
|
---|
312 | if ( isEqual( t, &static_QUType_double ) )
|
---|
313 | o->payload.i = (long)o->payload.d;
|
---|
314 | else
|
---|
315 | return t->convertTo( o, this );
|
---|
316 |
|
---|
317 | o->type = this;
|
---|
318 | return TRUE;
|
---|
319 | }
|
---|
320 |
|
---|
321 | bool QUType_int::convertTo( QUObject *o, QUType *t )
|
---|
322 | {
|
---|
323 | if ( isEqual( t, &static_QUType_double ) ) {
|
---|
324 | o->payload.d = (double)o->payload.i;
|
---|
325 | o->type = &static_QUType_double;
|
---|
326 | } else
|
---|
327 | return FALSE;
|
---|
328 | return TRUE;
|
---|
329 | }
|
---|
330 |
|
---|
331 | int QUType_int::serializeTo( QUObject *, QUBuffer * )
|
---|
332 | {
|
---|
333 | return 0;
|
---|
334 | }
|
---|
335 |
|
---|
336 | int QUType_int::serializeFrom( QUObject *, QUBuffer * )
|
---|
337 | {
|
---|
338 | return 0;
|
---|
339 | }
|
---|
340 |
|
---|
341 | // {2D0974E5-0BA6-4ec2-8837-C198972CB48C}
|
---|
342 | const QUuid TID_QUType_double( 0x2d0974e5, 0xba6, 0x4ec2, 0x88, 0x37, 0xc1, 0x98, 0x97, 0x2c, 0xb4, 0x8c );
|
---|
343 | QUType_double static_QUType_double;
|
---|
344 | const QUuid *QUType_double::uuid() const { return &TID_QUType_double; }
|
---|
345 | const char *QUType_double::desc() const {return "double"; }
|
---|
346 |
|
---|
347 | void QUType_double::set( QUObject *o, double v )
|
---|
348 | {
|
---|
349 | o->payload.d = v;
|
---|
350 | o->type = this;
|
---|
351 | }
|
---|
352 |
|
---|
353 | bool QUType_double::canConvertFrom( QUObject *o, QUType *t )
|
---|
354 | {
|
---|
355 | if ( isEqual( t, &static_QUType_int ) )
|
---|
356 | return TRUE;
|
---|
357 |
|
---|
358 | return t->canConvertTo( o, this );
|
---|
359 | }
|
---|
360 |
|
---|
361 | bool QUType_double::canConvertTo( QUObject * /*o*/, QUType *t )
|
---|
362 | {
|
---|
363 | return isEqual( t, &static_QUType_int );
|
---|
364 | }
|
---|
365 |
|
---|
366 | bool QUType_double::convertFrom( QUObject *o, QUType *t )
|
---|
367 | {
|
---|
368 | if ( isEqual( t, &static_QUType_int ) )
|
---|
369 | o->payload.d = (double)o->payload.i;
|
---|
370 | else
|
---|
371 | return t->convertTo( o, this );
|
---|
372 |
|
---|
373 | o->type = this;
|
---|
374 | return TRUE;
|
---|
375 | }
|
---|
376 |
|
---|
377 | bool QUType_double::convertTo( QUObject *o, QUType *t )
|
---|
378 | {
|
---|
379 | if ( isEqual( t, &static_QUType_int ) ) {
|
---|
380 | o->payload.i = (int) o->payload.d;
|
---|
381 | o->type = &static_QUType_int;
|
---|
382 | } else if ( isEqual( t, &static_QUType_double ) ) {
|
---|
383 | o->payload.d = (double) o->payload.f;
|
---|
384 | o->type = &static_QUType_double;
|
---|
385 | } else
|
---|
386 | return FALSE;
|
---|
387 | return TRUE;
|
---|
388 | }
|
---|
389 |
|
---|
390 | int QUType_double::serializeTo( QUObject *, QUBuffer * )
|
---|
391 | {
|
---|
392 | return 0;
|
---|
393 | }
|
---|
394 |
|
---|
395 | int QUType_double::serializeFrom( QUObject *, QUBuffer * )
|
---|
396 | {
|
---|
397 | return 0;
|
---|
398 | }
|
---|
399 |
|
---|
400 | // {EFCDD1D4-77A3-4b8e-8D46-DC14B8D393E9}
|
---|
401 | const QUuid TID_QUType_charstar( 0xefcdd1d4, 0x77a3, 0x4b8e, 0x8d, 0x46, 0xdc, 0x14, 0xb8, 0xd3, 0x93, 0xe9 );
|
---|
402 | QUType_charstar static_QUType_charstar;
|
---|
403 | const QUuid *QUType_charstar::uuid() const { return &TID_QUType_charstar; }
|
---|
404 | const char *QUType_charstar::desc() const { return "char*"; }
|
---|
405 |
|
---|
406 | void QUType_charstar::set( QUObject *o, const char* v, bool take )
|
---|
407 | {
|
---|
408 | if ( take ) {
|
---|
409 | if ( v ) {
|
---|
410 | o->payload.charstar.ptr = new char[ strlen(v) + 1 ];
|
---|
411 | strcpy( o->payload.charstar.ptr, v );
|
---|
412 | } else {
|
---|
413 | o->payload.charstar.ptr = 0;
|
---|
414 | }
|
---|
415 | o->payload.charstar.owner = TRUE;
|
---|
416 | } else {
|
---|
417 | o->payload.charstar.ptr = (char*) v;
|
---|
418 | o->payload.charstar.owner = FALSE;
|
---|
419 | }
|
---|
420 | o->type = this;
|
---|
421 | }
|
---|
422 |
|
---|
423 | bool QUType_charstar::canConvertFrom( QUObject *o, QUType *t )
|
---|
424 | {
|
---|
425 | return t->canConvertTo( o, this );
|
---|
426 | }
|
---|
427 |
|
---|
428 | bool QUType_charstar::canConvertTo( QUObject *, QUType * )
|
---|
429 | {
|
---|
430 | return FALSE;
|
---|
431 | }
|
---|
432 |
|
---|
433 | bool QUType_charstar::convertFrom( QUObject *o, QUType *t )
|
---|
434 | {
|
---|
435 | return t->convertTo( o, this );
|
---|
436 | }
|
---|
437 |
|
---|
438 | bool QUType_charstar::convertTo( QUObject *, QUType * )
|
---|
439 | {
|
---|
440 | return FALSE;
|
---|
441 | }
|
---|
442 |
|
---|
443 | void QUType_charstar::clear( QUObject *o )
|
---|
444 | {
|
---|
445 | if ( o->payload.charstar.owner )
|
---|
446 | delete [] o->payload.charstar.ptr;
|
---|
447 | o->payload.charstar.ptr = 0;
|
---|
448 | }
|
---|
449 |
|
---|
450 | int QUType_charstar::serializeTo( QUObject *, QUBuffer * )
|
---|
451 | {
|
---|
452 | return 0;
|
---|
453 | }
|
---|
454 |
|
---|
455 | int QUType_charstar::serializeFrom( QUObject *, QUBuffer * )
|
---|
456 | {
|
---|
457 | return 0;
|
---|
458 | }
|
---|
459 |
|
---|
460 |
|
---|
461 | // Qt specific types
|
---|
462 |
|
---|
463 | // {44C2A547-01E7-4e56-8559-35AF9D2F42B7}
|
---|
464 | const QUuid TID_QUType_QString( 0x44c2a547, 0x1e7, 0x4e56, 0x85, 0x59, 0x35, 0xaf, 0x9d, 0x2f, 0x42, 0xb7 );
|
---|
465 | QUType_QString static_QUType_QString;
|
---|
466 | const QUuid *QUType_QString::uuid() const { return &TID_QUType_QString; }
|
---|
467 | const char *QUType_QString::desc() const { return "QString"; }
|
---|
468 |
|
---|
469 | void QUType_QString::set( QUObject *o, const QString& v )
|
---|
470 | {
|
---|
471 | o->payload.ptr = new QString( v );
|
---|
472 | o->type = this;
|
---|
473 | }
|
---|
474 |
|
---|
475 | bool QUType_QString::canConvertFrom( QUObject *o, QUType *t )
|
---|
476 | {
|
---|
477 | if ( isEqual( t, &static_QUType_charstar ) ||
|
---|
478 | isEqual( t, &static_QUType_double ) ||
|
---|
479 | isEqual( t, &static_QUType_int ) )
|
---|
480 | return TRUE;
|
---|
481 |
|
---|
482 | return t->canConvertTo( o, this );
|
---|
483 | }
|
---|
484 |
|
---|
485 | bool QUType_QString::canConvertTo( QUObject * /*o*/, QUType *t )
|
---|
486 | {
|
---|
487 | return isEqual( t, &static_QUType_charstar ) ||
|
---|
488 | isEqual( t, &static_QUType_int ) ||
|
---|
489 | isEqual( t, &static_QUType_double );
|
---|
490 | }
|
---|
491 |
|
---|
492 | bool QUType_QString::convertFrom( QUObject *o, QUType *t )
|
---|
493 | {
|
---|
494 | QString *str = 0;
|
---|
495 | if ( isEqual( t, &static_QUType_charstar ) )
|
---|
496 | str = new QString( o->payload.charstar.ptr );
|
---|
497 | else if ( isEqual( t, &static_QUType_double ) )
|
---|
498 | str = new QString( QString::number( o->payload.d ) );
|
---|
499 | else if ( isEqual( t, &static_QUType_int ) )
|
---|
500 | str = new QString( QString::number( o->payload.i ) );
|
---|
501 | else
|
---|
502 | return t->convertTo( o, this );
|
---|
503 |
|
---|
504 | o->type->clear( o );
|
---|
505 | o->payload.ptr = str;
|
---|
506 | o->type = this;
|
---|
507 | return TRUE;
|
---|
508 | }
|
---|
509 |
|
---|
510 | bool QUType_QString::convertTo( QUObject *o, QUType *t )
|
---|
511 | {
|
---|
512 | QString *str = (QString *)o->payload.ptr;
|
---|
513 | if ( isEqual( t, &static_QUType_charstar ) ) {
|
---|
514 | o->payload.charstar.ptr = qstrdup( str->local8Bit().data() );
|
---|
515 | o->payload.charstar.owner = TRUE;
|
---|
516 | o->type = &static_QUType_charstar;
|
---|
517 | } else if ( isEqual( t, &static_QUType_int ) ) {
|
---|
518 | o->payload.l = str->toLong();
|
---|
519 | o->type = &static_QUType_int;
|
---|
520 | } else if ( isEqual( t, &static_QUType_double ) ) {
|
---|
521 | o->payload.d = str->toDouble();
|
---|
522 | o->type = &static_QUType_double;
|
---|
523 | } else {
|
---|
524 | return FALSE;
|
---|
525 | }
|
---|
526 | delete str;
|
---|
527 | return TRUE;
|
---|
528 | }
|
---|
529 |
|
---|
530 | int QUType_QString::serializeTo( QUObject *, QUBuffer * )
|
---|
531 | {
|
---|
532 | return 0;
|
---|
533 | }
|
---|
534 |
|
---|
535 | int QUType_QString::serializeFrom( QUObject *, QUBuffer * )
|
---|
536 | {
|
---|
537 | return 0;
|
---|
538 | }
|
---|
539 |
|
---|
540 | void QUType_QString::clear( QUObject *o )
|
---|
541 | {
|
---|
542 | delete (QString*)o->payload.ptr;
|
---|
543 | o->payload.ptr = 0;
|
---|
544 | }
|
---|