[Gambas-devel] QMap<QString,QString> my implementation in DCOP class file.

Carlo Sorda csorda at ...69...
Thu Feb 24 09:58:54 CET 2005


Hi,
I have try to manage QMap<QString,QString> type in CApplication.cpp.
I have implemented it like this:

...
#include <qmap.h>
...
enum {
  QT_T_VOID,
   ...
  QT_T_QMAP_QSTRING,
};
...
  { "QMap<QString,QString>",(GB_TYPE)"Collection"   },
   { NULL }
};
...
//My implementation.
  else if (type == QT_T_QMAP_QSTRING)
   {
     GB_COLLECTION aCollection;
     GB_STRING aKey;
     GB_STRING aValue;
     //Redefine a type for QMap of QString
     typedef QMap<QString,QString> Map;
     Map r;
     reply >> r;

     //Create a new Collection
     GB.Collection.New(&aCollection,GB_COMP_BINARY);

     //Create an Map Iterator for navigate a Map
     Map::Iterator it;
     for (it =r.begin() ;it != r.end();it++)
     {
       #ifdef DEBUG_ME
       	//This is correct
       	qDebug("QMAP %s->%s", it.key().latin1(),it.data().latin1());
       #endif

       //Create e new GB_STRING that contain a Key (QString)
       GB.NewString((char **)&aKey,it.key().latin1(),0);
       //Generate a new GB_STRING theat cantain a Value (QString)
       GB.NewString((char **)&aValue,it.data().latin1(),0);

       //aValue is NULL??? WHY
       qDebug("aValue: %s-%s",aKey,aValue);
       //Here is the crash
       //GB.Collection.Set(&aCollection,&aKey,GB.StringLength((char 
*)&aKey),(GB_VARIANT *)&aValue);
       //GB.Collection.Set(&aCollection,it.key().latin1(),it.key().length(),(GB_VARIANT*)it.data().latin1());
     }
     //return a Collection
     GB.ReturnObject(aCollection);
   }

Can you help me?





More information about the Devel mailing list