ALL,
Consider following code snippet:
In database_sqlite.h:
class __declspec(dllexport) SQLiteDatabase : public Database
{
virtual void GetTableProperties(DatabaseTable *table, std::vector<std::wstring> &errorMsg);
protected:
struct SQLiteImpl;
};
struct SQLiteDatabase::SQLiteImpl
{
std::wstring m_catalog;
std::wstring_convert<std::codecvt_utf8<wchar_t> > m_myconv;
};
In database_sqlite.cpp:
void SQLiteDatabase::GetTableProperties(DatabaseTable *table, std::vector<std::wstring> &errorMsg)
{
sqlite3_stmt *stmt = NULL;
std::wstring errorMessage;
int result;
std::wstring query = L"SELECT * FROM \"sys.abcattbl\" WHERE \"abt_tnam\" = ? AND \"abt_ownr\" = ?;";
const unsigned char *dataFontName, *headingFontName, *labelFontName;
int res = sqlite3_prepare_v2( m_db, sqlite_pimpl->m_myconv.to_bytes( query.c_str() ).c_str(), (int) query.length(), &stmt, 0 );
if( res == SQLITE_OK )
{
const char *name = sqlite_pimpl->m_myconv.to_bytes( table->GetTableName().c_str() ).c_str();
I'm using MSVC2010 and, to my surprise, "*name" contains empty string. The first call to "to_bytes()" succeeded, since I can check the query that will be used.
Do I have to do something after the first call to "to_bytes()"? Or I simply have to upgrade the compiler?
TIA and Happy Holidays to people on this community.
Aucun commentaire:
Enregistrer un commentaire