ポインタと値の変換と割り当てについてアドバイスをお願いします。
私はこの修正クラス定義を持っています:(gsoapによって生成されます)
class LibClass
{
public:
std::string *email; // pointer
int landId; // no pointer
// (....) much more
}
別の関数で、データベース(informix)から上記のクラスメンバーにデータを割り当てます。
(...) // just database connection
// The following is informix interface related stuff
ITRow *row;
// define one time this conversions interface
ITConversions *c;
// placeholder for all string types, temporary data container
ITString its("");
ITString colname;
// read result from executed query
while ( row = query.NextRow() ) {
LibClass *ki = new LibClass;
ki->email = new (string);
//ki->landId = new (int); // obviously : error: invalid conversion from 'int*' to 'int'
// I tried :
// invent a new instance
LibClass rki;
//rki = &ki;
//rki.x = 9;
// this is okay but how to bring ki and rki together,
int *a = new int;
rki.x = *a;
// And for understanding, here's what comes next - It seams as i have to hardcode all 30 DB fields... but thats okay for now.
colname="email";
ITValue *v = row->Column( colname );
v->QueryInterface(ITConversionsIID, (void **) &c);
c->ConvertTo( its );
*( ki->email ) = string(its.Data()); // THE DATA TRANSFER - assignment
v->Release();
} // while end
編集私はこれを続けることができなかったので、提案を承認することはできませんが、ここで閉じたいので、最も詳細な回答を受け入れます。thxすべて。