Hello,
Petit souci de convertion... Surement rapide à régler, mais la, y a qqch qui me laisse pantois...
J'ai 2 méthodes dans ma classe (classe d'abstraction de connexion a une db postgresql):
etCode:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 DB_Err Db_manager::get_configdata(string configModule, string configParameter, string &configData) { // Initialize sql string this->sqlQuery.str(""); this->sqlQuery << "select parameterData from configurations where moduleId = '" << configModule << "' and parameterId = '"<< configParameter <<"' limit 1"; // Execute SQL this->res = PQexec(this->conn,this->sqlQuery.str().c_str()); if(this->isDebug){ this->debug(); } if(PQntuples(this->res) != 0){ configData = PQgetvalue(this->res,0,0); } return this->get_internal_status(); }
Et le problème se pose sur ma ligne:Code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14 DB_Err Db_manager::get_configdata_int(string configModule, string configParameter, int &configData) { string tempConfigData; if(this->get_configdata(configModule, configParameter, tempConfigData) == DB_OK){ configData = atoi(tempConfigData); } if(this->isDebug){ this->debug(); } return this->get_internal_status(); }
Il me renvois un gentil:Code:configData = atoi(tempConfigData);
Alors que je ne comprends pas pourquoi! J'ai pas de char *! Mon tempConfigData est un string, et si je fais un (en mettant configData en int, évidemment...)Citation:
Description Resource Path Location Type
cannot convert 'std::string' to 'const char*' for argument '1' to 'int atoi(const char*)' db_manager.cpp /dbmanager/src line 711 C/C++ Problem
Je n'ai pas la moindre erreur.Code:configData = PQgetvalue(this->res,0,0);
Pourquoi le fait de faire mon atoi sur ma string après etre passée par la fonction me fait chier ? De meme, si je fais un
Il rale plus!Code:configData = atoi("1");
Bref, y a qqch qui m'échappe, mais je vois pas quoi?
Merci d'avance.
Onet