Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

qucom.cpp

Go to the documentation of this file.
00001 /****************************************************************************
00002 ** $Id: qucom.cpp,v 1.2 2003/07/10 02:40:12 llornkcor Exp $
00003 **
00004 ** Implementation of the QUcom classes
00005 **
00006 ** Created : 990101
00007 **
00008 ** Copyright (C) 1992-2002 Trolltech AS.  All rights reserved.
00009 **
00010 ** This file is part of the tools module of the Qt GUI Toolkit.
00011 **
00012 ** This file may be distributed under the terms of the Q Public License
00013 ** as defined by Trolltech AS of Norway and appearing in the file
00014 ** LICENSE.QPL included in the packaging of this file.
00015 **
00016 ** This file may be distributed and/or modified under the terms of the
00017 ** GNU General Public License version 2 as published by the Free Software
00018 ** Foundation and appearing in the file LICENSE.GPL included in the
00019 ** packaging of this file.
00020 **
00021 ** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition
00022 ** licenses may use this file in accordance with the Qt Commercial License
00023 ** Agreement provided with the Software.
00024 **
00025 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
00026 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
00027 **
00028 ** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
00029 **   information about Qt Commercial License Agreements.
00030 ** See http://www.trolltech.com/qpl/ for QPL licensing information.
00031 ** See http://www.trolltech.com/gpl/ for GPL licensing information.
00032 **
00033 ** Contact info@trolltech.com if any conditions of this licensing are
00034 ** not clear to you.
00035 **
00036 **********************************************************************/
00037 
00038 #include "qucom_p.h"
00039 
00040 // Standard types
00041 
00042 // {DE56510E-4E9F-4b76-A3C2-D1E2EF42F1AC}
00043 const QUuid TID_QUType_Null( 0xde56510e, 0x4e9f, 0x4b76, 0xa3, 0xc2, 0xd1, 0xe2, 0xef, 0x42, 0xf1, 0xac );
00044 const QUuid *QUType_Null::uuid() const { return &TID_QUType_Null; }
00045 const char *QUType_Null::desc() const { return "null"; }
00046 bool QUType_Null::canConvertFrom( QUObject *, QUType * ) { return FALSE; }
00047 bool QUType_Null::canConvertTo( QUObject *, QUType * ) { return FALSE; }
00048 bool QUType_Null::convertFrom( QUObject *, QUType * ) { return FALSE; }
00049 bool QUType_Null::convertTo( QUObject *, QUType * ) { return FALSE; }
00050 void QUType_Null::clear( QUObject *) {};
00051 int QUType_Null::serializeTo( QUObject *, QUBuffer * ) { return 0; }
00052 int QUType_Null::serializeFrom( QUObject *, QUBuffer * ) { return 0; };
00053 QUType_Null static_QUType_Null;
00054 
00055 
00056 // {7EE17B08-5419-47e2-9776-8EEA112DCAEC}
00057 const QUuid TID_QUType_enum( 0x7ee17b08, 0x5419, 0x47e2, 0x97, 0x76, 0x8e, 0xea, 0x11, 0x2d, 0xca, 0xec );
00058 QUType_enum static_QUType_enum;
00059 const QUuid *QUType_enum::uuid() const { return &TID_QUType_enum; }
00060 const char *QUType_enum::desc() const { return "enum"; }
00061 void QUType_enum::set( QUObject *o, int v )
00062 {
00063     o->payload.i = v;
00064     o->type = this;
00065 }
00066 
00067 bool QUType_enum::canConvertFrom( QUObject *o, QUType *t )
00068 {
00069     if ( isEqual( t, &static_QUType_int ) ) // ## todo unsigned int?
00070         return TRUE;
00071 
00072     return t->canConvertTo( o, this );
00073 }
00074 
00075 bool QUType_enum::canConvertTo( QUObject * /*o*/, QUType *t )
00076 {
00077     return isEqual( t, &static_QUType_int );
00078 }
00079 
00080 bool QUType_enum::convertFrom( QUObject *o, QUType *t )
00081 {
00082     if ( isEqual( t, &static_QUType_int ) ) // ## todo unsigned int?
00083         ;
00084     else
00085         return t->convertTo( o, this );
00086 
00087     o->type = this;
00088     return TRUE;
00089 }
00090 
00091 bool QUType_enum::convertTo( QUObject *o, QUType *t )
00092 {
00093     if ( isEqual( t,  &static_QUType_int ) ) {
00094         o->type = &static_QUType_int;
00095         return TRUE;
00096     }
00097     return FALSE;
00098 }
00099 
00100 int QUType_enum::serializeTo( QUObject *, QUBuffer * )
00101 {
00102     return 0;
00103 }
00104 
00105 int QUType_enum::serializeFrom( QUObject *, QUBuffer * )
00106 {
00107     return 0;
00108 }
00109 
00110 // {8AC26448-5AB4-49eb-968C-8F30AB13D732}
00111 const QUuid TID_QUType_ptr( 0x8ac26448, 0x5ab4, 0x49eb, 0x96, 0x8c, 0x8f, 0x30, 0xab, 0x13, 0xd7, 0x32 );
00112 QUType_ptr static_QUType_ptr;
00113 const QUuid *QUType_ptr::uuid() const  { return &TID_QUType_ptr; }
00114 const char *QUType_ptr::desc() const { return "ptr"; }
00115 
00116 void QUType_ptr::set( QUObject *o, const void* v )
00117 {
00118     o->payload.ptr = (void*) v;
00119     o->type = this;
00120 }
00121 
00122 bool QUType_ptr::canConvertFrom( QUObject *o, QUType *t )
00123 {
00124     return t->canConvertTo( o, this );
00125 }
00126 
00127 bool QUType_ptr::canConvertTo( QUObject *, QUType * )
00128 {
00129     return FALSE;
00130 }
00131 
00132 bool QUType_ptr::convertFrom( QUObject *o, QUType *t )
00133 {
00134     return t->convertTo( o, this );
00135 }
00136 
00137 bool QUType_ptr::convertTo( QUObject *, QUType * )
00138 {
00139     return FALSE;
00140 }
00141 
00142 int QUType_ptr::serializeTo( QUObject *, QUBuffer * )
00143 {
00144     return 0;
00145 }
00146 
00147 int QUType_ptr::serializeFrom( QUObject *, QUBuffer * )
00148 {
00149     return 0;
00150 }
00151 
00152 // {97A2594D-6496-4402-A11E-55AEF2D4D25C}
00153 const QUuid TID_QUType_iface( 0x97a2594d, 0x6496, 0x4402, 0xa1, 0x1e, 0x55, 0xae, 0xf2, 0xd4, 0xd2, 0x5c );
00154 QUType_iface static_QUType_iface;
00155 const QUuid *QUType_iface::uuid() const  { return &TID_QUType_iface; }
00156 const char *QUType_iface::desc() const { return "UnknownInterface"; }
00157 
00158 void QUType_iface::set( QUObject *o, QUnknownInterface* iface )
00159 {
00160     o->payload.iface = iface;
00161     o->type = this;
00162 }
00163 
00164 bool QUType_iface::canConvertFrom( QUObject *o, QUType *t )
00165 {
00166     return t->canConvertTo( o, this );
00167 }
00168 
00169 bool QUType_iface::canConvertTo( QUObject *, QUType * )
00170 {
00171     return FALSE;
00172 }
00173 
00174 bool QUType_iface::convertFrom( QUObject *o, QUType *t )
00175 {
00176     return t->convertTo( o, this );
00177 }
00178 
00179 bool QUType_iface::convertTo( QUObject *, QUType * )
00180 {
00181     return FALSE;
00182 }
00183 
00184 int QUType_iface::serializeTo( QUObject *, QUBuffer * )
00185 {
00186     return 0;
00187 }
00188 
00189 int QUType_iface::serializeFrom( QUObject *, QUBuffer * )
00190 {
00191     return 0;
00192 }
00193 
00194 // {2F358164-E28F-4bf4-9FA9-4E0CDCABA50B}
00195 const QUuid TID_QUType_idisp( 0x2f358164, 0xe28f, 0x4bf4, 0x9f, 0xa9, 0x4e, 0xc, 0xdc, 0xab, 0xa5, 0xb );
00196 QUType_idisp static_QUType_idisp;
00197 const QUuid *QUType_idisp::uuid() const  { return &TID_QUType_idisp; }
00198 const char *QUType_idisp::desc() const { return "DispatchInterface"; }
00199 
00200 void QUType_idisp::set( QUObject *o, QDispatchInterface* idisp )
00201 {
00202     o->payload.idisp = idisp;
00203     o->type = this;
00204 }
00205 
00206 bool QUType_idisp::canConvertFrom( QUObject *o, QUType *t )
00207 {
00208     return t->canConvertTo( o, this );
00209 }
00210 
00211 bool QUType_idisp::canConvertTo( QUObject * /*o*/, QUType *t )
00212 {
00213     return isEqual( t, &static_QUType_iface );
00214 }
00215 
00216 bool QUType_idisp::convertFrom( QUObject *o, QUType *t )
00217 {
00218     return t->convertTo( o, this );
00219 }
00220 
00221 bool QUType_idisp::convertTo( QUObject *o, QUType *t )
00222 {
00223 #ifndef QT_NO_COMPONENT
00224     if ( isEqual( t, &static_QUType_iface ) ) {
00225         o->payload.iface = (QUnknownInterface*)o->payload.idisp;
00226         o->type = &static_QUType_iface;
00227         return TRUE;
00228     }
00229 #endif
00230     return FALSE;
00231 }
00232 
00233 int QUType_idisp::serializeTo( QUObject *, QUBuffer * )
00234 {
00235     return 0;
00236 }
00237 
00238 int QUType_idisp::serializeFrom( QUObject *, QUBuffer * )
00239 {
00240     return 0;
00241 }
00242 
00243 // {CA42115D-13D0-456c-82B5-FC10187F313E}
00244 const QUuid TID_QUType_bool( 0xca42115d, 0x13d0, 0x456c, 0x82, 0xb5, 0xfc, 0x10, 0x18, 0x7f, 0x31, 0x3e );
00245 QUType_bool static_QUType_bool;
00246 const QUuid *QUType_bool::uuid() const  { return &TID_QUType_bool; }
00247 const char *QUType_bool::desc() const { return "bool"; }
00248 
00249 void QUType_bool::set( QUObject *o, bool v )
00250 {
00251     o->payload.b = v;
00252     o->type = this;
00253 }
00254 
00255 bool QUType_bool::canConvertFrom( QUObject *o, QUType *t )
00256 {
00257     return t->canConvertTo( o, this );
00258 }
00259 
00260 bool QUType_bool::canConvertTo( QUObject *, QUType * )
00261 {
00262     return FALSE;
00263 }
00264 
00265 bool QUType_bool::convertFrom( QUObject *o, QUType *t )
00266 {
00267     return t->convertTo( o, this );
00268 }
00269 
00270 bool QUType_bool::convertTo( QUObject *, QUType * )
00271 {
00272     return FALSE;
00273 }
00274 
00275 int QUType_bool::serializeTo( QUObject *, QUBuffer * )
00276 {
00277     return 0;
00278 }
00279 
00280 int QUType_bool::serializeFrom( QUObject *, QUBuffer * )
00281 {
00282     return 0;
00283 }
00284 
00285 // {53C1F3BE-73C3-4c7d-9E05-CCF09EB676B5}
00286 const QUuid TID_QUType_int( 0x53c1f3be, 0x73c3, 0x4c7d, 0x9e, 0x5, 0xcc, 0xf0, 0x9e, 0xb6, 0x76, 0xb5 );
00287 QUType_int static_QUType_int;
00288 const QUuid *QUType_int::uuid() const  { return &TID_QUType_int; }
00289 const char *QUType_int::desc() const { return "int"; }
00290 
00291 void QUType_int::set( QUObject *o, int v )
00292 {
00293     o->payload.i = v;
00294     o->type = this;
00295 }
00296 
00297 bool QUType_int::canConvertFrom( QUObject *o, QUType *t )
00298 {
00299     if ( isEqual( t, &static_QUType_double ) )
00300         return TRUE;
00301 
00302     return t->canConvertTo( o, this );
00303 }
00304 
00305 bool QUType_int::canConvertTo( QUObject * /*o*/, QUType *t )
00306 {
00307     return isEqual( t,  &static_QUType_double );
00308 }
00309 
00310 bool QUType_int::convertFrom( QUObject *o, QUType *t )
00311 {
00312     if ( isEqual( t, &static_QUType_double ) )
00313         o->payload.i = (long)o->payload.d;
00314     else
00315         return t->convertTo( o, this );
00316 
00317     o->type = this;
00318     return TRUE;
00319 }
00320 
00321 bool QUType_int::convertTo( QUObject *o, QUType *t )
00322 {
00323     if ( isEqual( t,  &static_QUType_double ) ) {
00324         o->payload.d = (double)o->payload.i;
00325         o->type = &static_QUType_double;
00326     } else
00327         return FALSE;
00328     return TRUE;
00329 }
00330 
00331 int QUType_int::serializeTo( QUObject *, QUBuffer * )
00332 {
00333     return 0;
00334 }
00335 
00336 int QUType_int::serializeFrom( QUObject *, QUBuffer * )
00337 {
00338     return 0;
00339 }
00340 
00341 // {2D0974E5-0BA6-4ec2-8837-C198972CB48C}
00342 const QUuid TID_QUType_double( 0x2d0974e5, 0xba6, 0x4ec2, 0x88, 0x37, 0xc1, 0x98, 0x97, 0x2c, 0xb4, 0x8c );
00343 QUType_double static_QUType_double;
00344 const QUuid *QUType_double::uuid() const { return &TID_QUType_double; }
00345 const char *QUType_double::desc() const {return "double"; }
00346 
00347 void QUType_double::set( QUObject *o, double v )
00348 {
00349     o->payload.d = v;
00350     o->type = this;
00351 }
00352 
00353 bool QUType_double::canConvertFrom( QUObject *o, QUType *t )
00354 {
00355     if ( isEqual( t, &static_QUType_int ) )
00356         return TRUE;
00357 
00358     return t->canConvertTo( o, this );
00359 }
00360 
00361 bool QUType_double::canConvertTo( QUObject * /*o*/, QUType *t )
00362 {
00363     return isEqual( t,  &static_QUType_int );
00364 }
00365 
00366 bool QUType_double::convertFrom( QUObject *o, QUType *t )
00367 {
00368     if ( isEqual( t, &static_QUType_int ) )
00369         o->payload.d = (double)o->payload.i;
00370      else
00371         return t->convertTo( o, this );
00372 
00373     o->type = this;
00374     return TRUE;
00375 }
00376 
00377 bool QUType_double::convertTo( QUObject *o, QUType *t )
00378 {
00379     if ( isEqual( t,  &static_QUType_int ) ) {
00380         o->payload.i = (int) o->payload.d;
00381         o->type = &static_QUType_int;
00382     } else if ( isEqual( t,  &static_QUType_double ) ) {
00383         o->payload.d = (double) o->payload.f;
00384         o->type = &static_QUType_double;
00385     } else
00386         return FALSE;
00387     return TRUE;
00388 }
00389 
00390 int QUType_double::serializeTo( QUObject *, QUBuffer * )
00391 {
00392     return 0;
00393 }
00394 
00395 int QUType_double::serializeFrom( QUObject *, QUBuffer * )
00396 {
00397     return 0;
00398 }
00399 
00400 // {EFCDD1D4-77A3-4b8e-8D46-DC14B8D393E9}
00401 const QUuid TID_QUType_charstar( 0xefcdd1d4, 0x77a3, 0x4b8e, 0x8d, 0x46, 0xdc, 0x14, 0xb8, 0xd3, 0x93, 0xe9 );
00402 QUType_charstar static_QUType_charstar;
00403 const QUuid *QUType_charstar::uuid() const { return &TID_QUType_charstar; }
00404 const char *QUType_charstar::desc() const { return "char*"; }
00405 
00406 void QUType_charstar::set( QUObject *o, const char* v, bool take )
00407 {
00408     if ( take ) {
00409         if ( v ) {
00410             o->payload.charstar.ptr = new char[ strlen(v) + 1 ];
00411             strcpy( o->payload.charstar.ptr, v );
00412         } else {
00413             o->payload.charstar.ptr = 0;
00414         }
00415         o->payload.charstar.owner = TRUE;
00416     } else {
00417         o->payload.charstar.ptr = (char*) v;
00418         o->payload.charstar.owner = FALSE;
00419     }
00420     o->type = this;
00421 }
00422 
00423 bool QUType_charstar::canConvertFrom( QUObject *o, QUType *t )
00424 {
00425     return t->canConvertTo( o, this );
00426 }
00427 
00428 bool QUType_charstar::canConvertTo( QUObject *, QUType * )
00429 {
00430     return FALSE;
00431 }
00432 
00433 bool QUType_charstar::convertFrom( QUObject *o, QUType *t )
00434 {
00435     return t->convertTo( o, this );
00436 }
00437 
00438 bool QUType_charstar::convertTo( QUObject *, QUType * )
00439 {
00440     return FALSE;
00441 }
00442 
00443 void QUType_charstar::clear( QUObject *o )
00444 {
00445     if ( o->payload.charstar.owner )
00446         delete [] o->payload.charstar.ptr;
00447     o->payload.charstar.ptr = 0;
00448 }
00449 
00450 int QUType_charstar::serializeTo( QUObject *, QUBuffer * )
00451 {
00452     return 0;
00453 }
00454 
00455 int QUType_charstar::serializeFrom( QUObject *, QUBuffer * )
00456 {
00457     return 0;
00458 }
00459 
00460 
00461 // Qt specific types
00462 
00463 // {44C2A547-01E7-4e56-8559-35AF9D2F42B7}
00464 const QUuid TID_QUType_QString( 0x44c2a547, 0x1e7, 0x4e56, 0x85, 0x59, 0x35, 0xaf, 0x9d, 0x2f, 0x42, 0xb7 );
00465 QUType_QString static_QUType_QString;
00466 const QUuid *QUType_QString::uuid() const { return &TID_QUType_QString; }
00467 const char *QUType_QString::desc() const { return "QString"; }
00468 
00469 void QUType_QString::set( QUObject *o, const QString& v )
00470 {
00471     o->payload.ptr = new QString( v );
00472     o->type = this;
00473 }
00474 
00475 bool QUType_QString::canConvertFrom( QUObject *o, QUType *t )
00476 {
00477     if ( isEqual( t, &static_QUType_charstar ) ||
00478          isEqual( t, &static_QUType_double ) ||
00479          isEqual( t, &static_QUType_int ) )
00480         return TRUE;
00481 
00482     return t->canConvertTo( o, this );
00483 }
00484 
00485 bool QUType_QString::canConvertTo( QUObject * /*o*/, QUType *t )
00486 {
00487     return isEqual( t, &static_QUType_charstar ) ||
00488         isEqual( t,  &static_QUType_int ) ||
00489         isEqual( t,  &static_QUType_double );
00490 }
00491 
00492 bool QUType_QString::convertFrom( QUObject *o, QUType *t )
00493 {
00494     QString *str = 0;
00495     if ( isEqual( t, &static_QUType_charstar ) )
00496         str = new QString( o->payload.charstar.ptr );
00497     else if ( isEqual( t, &static_QUType_double ) )
00498         str = new QString( QString::number( o->payload.d ) );
00499     else if ( isEqual( t, &static_QUType_int ) )
00500         str = new QString( QString::number( o->payload.i ) );
00501     else
00502         return t->convertTo( o, this );
00503 
00504     o->type->clear( o );
00505     o->payload.ptr = str;
00506     o->type = this;
00507     return TRUE;
00508 }
00509 
00510 bool QUType_QString::convertTo( QUObject *o, QUType *t )
00511 {
00512     QString *str = (QString *)o->payload.ptr;
00513     if ( isEqual( t, &static_QUType_charstar ) ) {
00514         o->payload.charstar.ptr = qstrdup( str->local8Bit().data() );
00515         o->payload.charstar.owner = TRUE;
00516         o->type = &static_QUType_charstar;
00517     } else if ( isEqual( t,  &static_QUType_int ) ) {
00518         o->payload.l = str->toLong();
00519         o->type = &static_QUType_int;
00520     } else if ( isEqual( t,  &static_QUType_double ) ) {
00521         o->payload.d = str->toDouble();
00522         o->type = &static_QUType_double;
00523     } else {
00524         return FALSE;
00525     }
00526     delete str;
00527     return TRUE;
00528 }
00529 
00530 int QUType_QString::serializeTo( QUObject *, QUBuffer * )
00531 {
00532     return 0;
00533 }
00534 
00535 int QUType_QString::serializeFrom( QUObject *, QUBuffer * )
00536 {
00537     return 0;
00538 }
00539 
00540 void QUType_QString::clear( QUObject *o )
00541 {
00542     delete (QString*)o->payload.ptr;
00543     o->payload.ptr = 0;
00544 }

Generated on Sat Nov 5 16:18:34 2005 for OPIE by  doxygen 1.4.2