00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 #ifndef _CONV_H_217412934_
00027 #define _CONV_H_217412934_
00028
00029 #include "teglobal.h"
00030 #include <qstring.h>
00031 #include <qvaluevector.h>
00032 #include <qdatetime.h>
00033 #include <qvariant.h>
00034 #include <qcstring.h>
00035
00036 template <class T>
00037 struct LocVarType
00038 {
00039 typedef T Type;
00040 };
00041
00042 template <>
00043 struct LocVarType<const QString &>
00044 {
00045 typedef QString Type;
00046 };
00047
00048 template <>
00049 struct LocVarType<QString &>
00050 {
00051 typedef QString Type;
00052 };
00053
00054 template <>
00055 struct LocVarType<const int &>
00056 {
00057 typedef int Type;
00058 };
00059
00060 template <>
00061 struct LocVarType<int &>
00062 {
00063 typedef int Type;
00064 };
00065
00066 template <>
00067 struct LocVarType<const QDateTime &>
00068 {
00069 typedef QDateTime Type;
00070 };
00071
00072 template <>
00073 struct LocVarType<QDateTime &>
00074 {
00075 typedef QDateTime Type;
00076 };
00077
00078 template <>
00079 struct LocVarType<const float &>
00080 {
00081 typedef float Type;
00082 };
00083
00084 template <>
00085 struct LocVarType<float &>
00086 {
00087 typedef float Type;
00088 };
00089
00090 template <>
00091 struct LocVarType<double &>
00092 {
00093 typedef double Type;
00094 };
00095
00096 template <>
00097 struct LocVarType<const double &>
00098 {
00099 typedef double Type;
00100 };
00101
00102 template <>
00103 struct LocVarType<const char *>
00104 {
00105 typedef QCString Type;
00106 };
00107
00108 template <class T>
00109 QString toString(T v)
00110 {
00111 return QString("%1").arg(v);
00112 };
00113
00114 template <>
00115 LIB_EXPORT QString toString<double>(double v);
00116
00117 template <>
00118 LIB_EXPORT QString toString<QVariant>(QVariant v);
00119
00120 template <>
00121 LIB_EXPORT QString toString<float>(float v);
00122
00123 template <class T>
00124 T fromQVariant(const QVariant & s)
00125 {
00126 return (T)s;
00127 };
00128
00129 template <>
00130 LIB_EXPORT bool fromQVariant<bool>(const QVariant &);
00131
00132 template <>
00133 LIB_EXPORT int fromQVariant<int>(const QVariant &);
00134
00135 template <>
00136 LIB_EXPORT uint fromQVariant<uint>(const QVariant &);
00137
00138 template <>
00139 LIB_EXPORT float fromQVariant<float>(const QVariant &);
00140
00141 template <>
00142 LIB_EXPORT double fromQVariant<double>(const QVariant &);
00143
00144 template <>
00145 LIB_EXPORT Q_LLONG fromQVariant<Q_LLONG>(const QVariant &);
00146
00147 template <>
00148 LIB_EXPORT Q_ULLONG fromQVariant<Q_ULLONG>(const QVariant &);
00149
00150 template <>
00151 LIB_EXPORT Q_ULONG fromQVariant<Q_ULONG>(const QVariant &);
00152
00153 template <>
00154 LIB_EXPORT Q_LONG fromQVariant<Q_LONG>(const QVariant &);
00155
00156 template <>
00157 LIB_EXPORT QString fromQVariant<QString>(const QVariant &);
00158
00159 template <>
00160 LIB_EXPORT QCString fromQVariant<QCString>(const QVariant &);
00161
00162 struct LIB_EXPORT memFunc
00163 {
00164 virtual int argc()
00165 {
00166 return 0;
00167 };
00168
00169 virtual int operator()(const QValueVector<QVariant> & , QString & , QString & )
00170 {
00171 return 0;
00172 };
00173 };
00174
00175 template <class T, class R>
00176 struct NonConstFunc0
00177 {
00178 typedef R (T::*memFunPtr)();
00179 };
00180
00181 template <class T>
00182 struct NonConstProc0
00183 {
00184 typedef void (T::*Type)();
00185 };
00186
00187 template <class T>
00188 struct ConstProc0
00189 {
00190 typedef void (T::*Type)() const;
00191 };
00192
00193 template <class T, class R, class P1>
00194 struct NonConstFunc1
00195 {
00196 typedef R (T::*memFunPtr)(P1);
00197 };
00198
00199 template <class T, class R, class P1, class P2>
00200 struct NonConstFunc2
00201 {
00202 typedef R (T::*memFunPtr)(P1,P2);
00203 };
00204
00205 template <class T, class R, class P1, class P2, class P3>
00206 struct NonConstFunc3
00207 {
00208 typedef R (T::*memFunPtr)(P1,P2,P3);
00209 };
00210
00211 template <class T, class R, class P1, class P2, class P3, class P4>
00212 struct NonConstFunc4
00213 {
00214 typedef R (T::*memFunPtr)(P1,P2,P3,P4);
00215 };
00216
00217 template <class T, class R, class P1, class P2, class P3, class P4, class P5>
00218 struct NonConstFunc5
00219 {
00220 typedef R (T::*memFunPtr)(P1,P2,P3,P4,P5);
00221 };
00222
00223 template <class T, class R>
00224 struct ConstFunc0
00225 {
00226 typedef R (T::*memFunPtr)() const;
00227 };
00228
00229 template <class T, class R, class P1>
00230 struct ConstFunc1
00231 {
00232 typedef R (T::*memFunPtr)(P1) const;
00233 };
00234
00235 template <class T, class R, class P1, class P2>
00236 struct ConstFunc2
00237 {
00238 typedef R (T::*memFunPtr)(P1,P2) const;
00239 };
00240
00241 template <class T, class R, class P1, class P2, class P3>
00242 struct ConstFunc3
00243 {
00244 typedef R (T::*memFunPtr)(P1,P2,P3) const;
00245 };
00246
00247 template <class T, class R, class P1, class P2, class P3, class P4>
00248 struct ConstFunc4
00249 {
00250 typedef R (T::*memFunPtr)(P1,P2,P3,P4) const;
00251 };
00252
00253 template <class T, class R, class P1, class P2, class P3, class P4, class P5>
00254 struct ConstFunc5
00255 {
00256 typedef R (T::*memFunPtr)(P1,P2,P3,P4,P5) const;
00257 };
00258
00259
00260
00261
00262 template <class T, class R, class Func=NonConstFunc0<T,R> >
00263 struct memFunc0 : memFunc
00264 {
00265 typedef typename Func::memFunPtr memFunPtr;
00266 memFunPtr m_pfunc;
00267 T * m_pobj;
00268 enum {arity=0};
00269 memFunc0(T * pobj, memFunPtr pfunc):m_pfunc(pfunc),m_pobj(pobj){};
00270 virtual int operator()(const QValueVector<QVariant> & parms, QString & res, QString & err)
00271 {
00272 if (parms.size()!=arity)
00273 {
00274 err=QString("Number of provided parameters doesn't match function definition");
00275 return 1;
00276 };
00277 res=toString<R>((m_pobj->*m_pfunc)());
00278 return 0;
00279 };
00280 virtual int argc()
00281 {
00282 return arity;
00283 };
00284 };
00285
00286 template <class T, class R, class P1, class Func=NonConstFunc1<T,R,P1> >
00287 struct memFunc1 : memFunc
00288 {
00289 typedef typename LocVarType<P1>::Type PL1;
00290 typedef typename Func::memFunPtr memFunPtr;
00291 memFunPtr m_pfunc;
00292 T * m_pobj;
00293 enum {arity=1};
00294 memFunc1(T * pobj, memFunPtr pfunc):m_pfunc(pfunc),m_pobj(pobj){};
00295 virtual int operator()(const QValueVector<QVariant> & parms, QString & res, QString & err)
00296 {
00297 if (parms.size()!=arity)
00298 {
00299 err=QString("Number of provided parameters doesn't match function definition");
00300 return 1;
00301 };
00302 PL1 p1=fromQVariant<PL1>(parms[0]);
00303 res=toString<R>((m_pobj->*m_pfunc)(p1));
00304 return 0;
00305 };
00306 virtual int argc()
00307 {
00308 return arity;
00309 };
00310 };
00311
00312 template <class T, class R, class P1, class P2, class Func=NonConstFunc2<T,R,P1,P2> >
00313 struct memFunc2 : memFunc
00314 {
00315 typedef typename LocVarType<P1>::Type PL1;
00316 typedef typename LocVarType<P2>::Type PL2;
00317 typedef typename Func::memFunPtr memFunPtr;
00318 memFunPtr m_pfunc;
00319 T * m_pobj;
00320 enum {arity=2};
00321 memFunc2(T * pobj, memFunPtr pfunc):m_pfunc(pfunc),m_pobj(pobj){};
00322 virtual int operator()(const QValueVector<QVariant> & parms, QString & res, QString & err)
00323 {
00324 if (parms.size()!=arity)
00325 {
00326 err=QString("Number of provided parameters doesn't match function definition");
00327 return 1;
00328 };
00329 PL1 p1=fromQVariant<PL1>(parms[0]);
00330 PL2 p2=fromQVariant<PL2>(parms[1]);
00331 res=toString<R>((m_pobj->*m_pfunc)(p1,p2));
00332 return 0;
00333 };
00334 virtual int argc()
00335 {
00336 return arity;
00337 };
00338 };
00339
00340 template <class T, class R, class P1, class P2, class P3, class Func=NonConstFunc3<T,R,P1,P2,P3> >
00341 struct memFunc3 : memFunc
00342 {
00343 typedef typename LocVarType<P1>::Type PL1;
00344 typedef typename LocVarType<P2>::Type PL2;
00345 typedef typename LocVarType<P3>::Type PL3;
00346 typedef typename Func::memFunPtr memFunPtr;
00347 memFunPtr m_pfunc;
00348 T * m_pobj;
00349 enum {arity=3};
00350 memFunc3(T * pobj, memFunPtr pfunc):m_pfunc(pfunc),m_pobj(pobj){};
00351 virtual int operator()(const QValueVector<QVariant> & parms, QString & res, QString & err)
00352 {
00353 if (parms.size()!=arity)
00354 {
00355 err=QString("Number of provided parameters doesn't match function definition");
00356 return 1;
00357 };
00358 PL1 p1=fromQVariant<PL1>(parms[0]);
00359 PL2 p2=fromQVariant<PL2>(parms[1]);
00360 PL3 p3=fromQVariant<PL3>(parms[2]);
00361 res=toString<R>((m_pobj->*m_pfunc)(p1,p2,p3));
00362 return 0;
00363 };
00364 virtual int argc()
00365 {
00366 return arity;
00367 };
00368 };
00369
00370 template <class T, class R, class P1, class P2, class P3, class P4, class Func=NonConstFunc4<T,R,P1,P2,P3,P4> >
00371 struct memFunc4 : memFunc
00372 {
00373 typedef typename LocVarType<P1>::Type PL1;
00374 typedef typename LocVarType<P2>::Type PL2;
00375 typedef typename LocVarType<P3>::Type PL3;
00376 typedef typename LocVarType<P4>::Type PL4;
00377 typedef typename Func::memFunPtr memFunPtr;
00378 memFunPtr m_pfunc;
00379 T * m_pobj;
00380 enum {arity=4};
00381 memFunc4(T * pobj, memFunPtr pfunc):m_pfunc(pfunc),m_pobj(pobj){};
00382 virtual int operator()(const QValueVector<QVariant> & parms, QString & res, QString & err)
00383 {
00384 if (parms.size()!=arity)
00385 {
00386 err=QString("Number of provided parameters doesn't match function definition");
00387 return 1;
00388 };
00389 PL1 p1=fromQVariant<PL1>(parms[0]);
00390 PL2 p2=fromQVariant<PL2>(parms[1]);
00391 PL3 p3=fromQVariant<PL3>(parms[2]);
00392 PL4 p4=fromQVariant<PL4>(parms[3]);
00393 res=toString<R>((m_pobj->*m_pfunc)(p1,p2,p3,p4));
00394 return 0;
00395 };
00396 virtual int argc()
00397 {
00398 return arity;
00399 };
00400 };
00401
00402 template <class T, class R, class P1, class P2, class P3, class P4, class P5,
00403 class Func=NonConstFunc5<T,R,P1,P2,P3,P4,P5> >
00404 struct memFunc5 : memFunc
00405 {
00406 typedef typename LocVarType<P1>::Type PL1;
00407 typedef typename LocVarType<P2>::Type PL2;
00408 typedef typename LocVarType<P3>::Type PL3;
00409 typedef typename LocVarType<P4>::Type PL4;
00410 typedef typename LocVarType<P5>::Type PL5;
00411 typedef typename Func::memFunPtr memFunPtr;
00412 memFunPtr m_pfunc;
00413 T * m_pobj;
00414 enum {arity=5};
00415 memFunc5(T * pobj, memFunPtr pfunc):m_pfunc(pfunc),m_pobj(pobj){};
00416 virtual int operator()(const QValueVector<QVariant> & parms, QString & res, QString & err)
00417 {
00418 if (parms.size()!=arity)
00419 {
00420 err=QString("Number of provided parameters doesn't match function definition");
00421 return 1;
00422 };
00423 PL1 p1=fromQVariant<PL1>(parms[0]);
00424 PL2 p2=fromQVariant<PL2>(parms[1]);
00425 PL3 p3=fromQVariant<PL3>(parms[2]);
00426 PL4 p4=fromQVariant<PL4>(parms[3]);
00427 PL5 p5=fromQVariant<PL5>(parms[4]);
00428 res=toString<R>((m_pobj->*m_pfunc)(p1,p2,p3,p4,p5));
00429 return 0;
00430 };
00431 virtual int argc()
00432 {
00433 return arity;
00434 };
00435 };
00436
00437 struct memProc
00438 {
00439 virtual int operator()(const QValueVector<QVariant> & , QString & )
00440 {
00441 return 0;
00442 };
00443 virtual int argc()
00444 {
00445 return 0;
00446 };
00447 };
00448
00449 template <class T, class FT=NonConstProc0<T> >
00450 struct memProc0 : memProc
00451 {
00452 typedef typename FT::Type memProcPtr;
00453 T * m_pobj;
00454 memProcPtr m_pproc;
00455 enum {arity=0};
00456 memProc0(T * pobj, memProcPtr pproc):m_pobj(pobj),m_pproc(pproc){};
00457 virtual int operator()(const QValueVector<QVariant> & parms, QString & err)
00458 {
00459 if (parms.size()!=arity)
00460 {
00461 err=QString("Number of provided parameters doesn't match function definition");
00462 return 1;
00463 };
00464 (m_pobj->*m_pproc)();
00465 return 0;
00466 };
00467 virtual int argc()
00468 {
00469 return arity;
00470 };
00471 };
00472
00473 template <class T, class P1>
00474 struct memProc1 : memProc
00475 {
00476 typedef void (T::*memProcPtr)(P1);
00477 typedef typename LocVarType<P1>::Type PL1;
00478 T * m_pobj;
00479 memProcPtr m_pproc;
00480 enum {arity=1};
00481 memProc1(T * pobj, memProcPtr pproc):m_pobj(pobj),m_pproc(pproc){};
00482 virtual int operator()(const QValueVector<QVariant> & parms, QString & err)
00483 {
00484 if (parms.size()!=arity)
00485 {
00486 err=QString("Number of provided parameters doesn't match function definition");
00487 return 1;
00488 };
00489 PL1 p1=fromQVariant<PL1>(parms[0]);
00490 (m_pobj->*m_pproc)(p1);
00491 return 0;
00492 };
00493 virtual int argc()
00494 {
00495 return arity;
00496 };
00497 };
00498
00499 template <class T, class P1, class P2>
00500 struct memProc2 : memProc
00501 {
00502 typedef void (T::*memProcPtr)(P1,P2);
00503 typedef typename LocVarType<P1>::Type PL1;
00504 typedef typename LocVarType<P2>::Type PL2;
00505 memProcPtr m_pproc;
00506 T * m_pobj;
00507 enum {arity=2};
00508 memProc2(T * pobj, memProcPtr pproc):m_pproc(pproc),m_pobj(pobj){};
00509 virtual int operator()(const QValueVector<QVariant> & parms, QString & err)
00510 {
00511 if (parms.size()!=arity)
00512 {
00513 err=QString("Number of provided parameters doesn't match function definition");
00514 return 1;
00515 };
00516 PL1 p1=fromQVariant<PL1>(parms[0]);
00517 PL2 p2=fromQVariant<PL2>(parms[1]);
00518 (m_pobj->*m_pproc)(p1,p2);
00519 return 0;
00520 };
00521 virtual int argc()
00522 {
00523 return arity;
00524 };
00525 };
00526
00527 template <class T, class P1, class P2, class P3>
00528 struct memProc3 : memProc
00529 {
00530 typedef void (T::*memProcPtr)(P1,P2,P3);
00531 typedef typename LocVarType<P1>::Type PL1;
00532 typedef typename LocVarType<P2>::Type PL2;
00533 typedef typename LocVarType<P3>::Type PL3;
00534 memProcPtr m_pproc;
00535 T * m_pobj;
00536 enum {arity=3};
00537 memProc3(T * pobj, memProcPtr pproc):m_pproc(pproc),m_pobj(pobj){};
00538 virtual int operator()(const QValueVector<QVariant> & parms, QString & err)
00539 {
00540 if (parms.size()!=arity)
00541 {
00542 err=QString("Number of provided parameters doesn't match function definition");
00543 return 1;
00544 };
00545 PL1 p1=fromQVariant<PL1>(parms[0]);
00546 PL2 p2=fromQVariant<PL2>(parms[1]);
00547 PL3 p3=fromQVariant<PL3>(parms[2]);
00548 (m_pobj->*m_pproc)(p1,p2,p3);
00549 return 0;
00550 };
00551 virtual int argc()
00552 {
00553 return arity;
00554 };
00555 };
00556
00557 template <class T, class P1, class P2, class P3, class P4>
00558 struct memProc4 : memProc
00559 {
00560 typedef void (T::*memProcPtr)(P1,P2,P3,P4);
00561 typedef typename LocVarType<P1>::Type PL1;
00562 typedef typename LocVarType<P2>::Type PL2;
00563 typedef typename LocVarType<P3>::Type PL3;
00564 typedef typename LocVarType<P4>::Type PL4;
00565 memProcPtr m_pproc;
00566 T * m_pobj;
00567 enum {arity=4};
00568 memProc4(T * pobj, memProcPtr pproc):m_pproc(pproc),m_pobj(pobj){};
00569 virtual int operator()(const QValueVector<QVariant> & parms, QString & err)
00570 {
00571 if (parms.size()!=arity)
00572 {
00573 err=QString("Number of provided parameters doesn't match function definition");
00574 return 1;
00575 };
00576 PL1 p1=fromQVariant<PL1>(parms[0]);
00577 PL2 p2=fromQVariant<PL2>(parms[1]);
00578 PL3 p3=fromQVariant<PL3>(parms[2]);
00579 PL4 p4=fromQVariant<PL4>(parms[3]);
00580 (m_pobj->*m_pproc)(p1,p2,p3,p4);
00581 return 0;
00582 };
00583 virtual int argc()
00584 {
00585 return arity;
00586 };
00587 };
00588
00589 template <class T, class P1, class P2, class P3, class P4, class P5>
00590 struct memProc5 : memProc
00591 {
00592 typedef void (T::*memProcPtr)(P1,P2,P3,P4,P5);
00593 typedef typename LocVarType<P1>::Type PL1;
00594 typedef typename LocVarType<P2>::Type PL2;
00595 typedef typename LocVarType<P3>::Type PL3;
00596 typedef typename LocVarType<P4>::Type PL4;
00597 typedef typename LocVarType<P5>::Type PL5;
00598 memProcPtr m_pproc;
00599 T * m_pobj;
00600 enum {arity=5};
00601 memProc5(T * pobj, memProcPtr pproc):m_pproc(pproc),m_pobj(pobj){};
00602 virtual int operator()(const QValueVector<QVariant> & parms, QString & err)
00603 {
00604 if (parms.size()!=arity)
00605 {
00606 err=QString("Number of provided parameters doesn't match function definition");
00607 return 1;
00608 };
00609 PL1 p1=fromQVariant<PL1>(parms[0]);
00610 PL2 p2=fromQVariant<PL2>(parms[1]);
00611 PL3 p3=fromQVariant<PL3>(parms[2]);
00612 PL4 p4=fromQVariant<PL4>(parms[3]);
00613 PL5 p5=fromQVariant<PL5>(parms[4]);
00614 (m_pobj->*m_pproc)(p1,p2,p3,p4,p5);
00615 return 0;
00616 };
00617 virtual int argc()
00618 {
00619 return arity;
00620 };
00621 };
00622
00623 #endif