hi ,when im trying to insert key-value pair in map(key-char array field of a structure,value-entire structure)im having errors .
NDBAPI/TGBitsNdbApi.cpp: In function `int get_map(Ndb*, char*, char*, void*, void*)':
NDBAPI/TGBitsNdbApi.cpp:154: error: request for member `Msisdn' in `structPtr', which is of non-class type `void*'
NDBAPI/TGBitsNdbApi.cpp:156: error: `void*' is not a pointer-to-object type
NDBAPI/TGBitsNdbApi.cpp:156: error: request for member `Msisdn' in `structPtr', which is of non-class type `void*'
NDBAPI/TGBitsNdbApi.cpp:156: error: `make_pair' was not declared in this scope
TGBitsNdbApi.cpp
#include "TGBitsNdbApi.h"
#include <map>
......
......
int get_map(Ndb * myNdb,char * tableName,char * field,void * structPtr,void *Map)
{
const NdbDictionary::Dictionary* myDict= myNdb->getDictionary();
const NdbDictionary::Table *myTable= myDict->getTable(tableName);
if (myTable == NULL)
APIERROR(myDict->getNdbError());
const NdbDictionary::Index *myIndex= myDict->getIndex("index1",tableName);
if(myIndex == NULL)
APIERROR(myDict->getNdbError());
NdbTransaction *myTransaction= myNdb->startTransaction();
if (myTransaction == NULL) APIERROR(myNdb->getNdbError());
NdbIndexOperation *myIndexOp= myTransaction->getNdbIndexOperation(myIndex);
if (myIndexOp == NULL)
{
std::cout << myTransaction->getNdbError().message << std::endl;
myNdb->closeTransaction(myTransaction);
return -1;
}
if(myIndexOp->readTuple(NdbOperation::LM_Exclusive) != 0)
{
std::cout << myTransaction->getNdbError().message << std::endl;
myNdb->closeTransaction(myTransaction);
return -1;
}
else
{
if(strcmp(structPtr.Msisdn,field)==0)
{
Map->insert(make_pair(structPtr.Msisdn,structPtr));//im gettin error in this line
}
}
......
......
TGBitsNdbApi.h
#ifndef TGBITSNDBAPI_H_
#define TGBITSNDBAPI_H_
....
....
typedef pair<char *,void *>make_pair;
....
....
HomeNwList.cpp
int main(int argc, char** argv)
{
.....
.....
HomeNwSt homeNwSt;
map<char *,HomeNwSt> HomeMap;
map<char *,HomeNwSt>::iterator it;
int val=get_map(Ndb * myNdb,char * tableName,char * field,(void *)&homeNwSt ,(void*)&HomeMap)
if(val==-1)
........
........
for( it = HomeNwList.begin(); it != HomeNwList.end(); it++)
{
HomeNwSt obj = (*it).second;
std::cout << "col 1: "<< obj.NwId << "\t";
std::cout << "col 2: "<< obj.Msisdn << "\t\n";
}
return 0;
}
HomeNwList.h
#ifndef HOMENWLIST_H_
#define HOMENWLIST_H_
#include "./NDBAPI/TGBitsNdbApi.h"
#include<map>
#include<utility>
typedef struct _HomeNwSt
{
char Msisdn[20];
int NwId;
}HomeNwSt;
//typedef pair<char *,void *>make_pair;
....
....
#endif
i do understand it is showing this error because im sending the entire structure,map as void * in get_map() function and im trying to insert char array field of structure.i did tried typecastin it into char * which im not sure whether it is correct,but it was not working.so anyone could help me in fixing this error and explain me,as im not good in pointers.
Also,i didnt get the last error ,as i declared the make_pair in correct scope and i also checked spelling.
thanks