Click here to Skip to main content
15,886,919 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am using CppSQLite3 as a wrapper of sqlite3 because it allows passing UNICODE strings and because it supports UNICODE in general.
Is there an CppSQLite3 function which is similar to sqlite3_exec() in the sense of allowing passing a callback function?


sqlite3_exe is declared as follow:
C++
SQLITE_API int sqlite3_exec(
		sqlite3*,                                  /* An open database */
		const char *sql,                           /* SQL to be evaluated */
		int(*callback)(void*, int, char**, char**),  /* Callback function */
		void *,                                    /* 1st argument to callback */
		char **errmsg                              /* Error msg written here */
		);


CppSQLite3's execQuery() is declared as follow:
C++
CppSQLite3Query execQuery(LPCTSTR szSQL);


What I have tried:

I have tried looking for such wrapper function that will accept
C++
wchar_t *
instead of
C++
char *
but couldn't find any...
Posted
Updated 1-Feb-17 8:01am
v2
Comments
Richard MacCutchan 30-Jan-17 12:48pm    
Is there any documentation available?
Michael Haephrati 30-Jan-17 14:02pm    
Not that I'm aware of

1 solution

As you have the source code for CppSqlite , you could always write an additional (Unicode) method as follows:

C++
SQLITE_API int sqlite3_execW(
		sqlite3*,                                  /* An open database */
		const wchar_t *sql,                           /* SQL to be evaluated */
		int(*callback)(void*, int, wchar_t**, wchar_t**),  /* Callback function */
		void *,                                    /* 1st argument to callback */
		wchar_t **errmsg                              /* Error msg written here */
		);


This code would (a) convert any parameters from Unicode to (for example) UTF-8, and call the char version. If a Unicode callback function is provided, it can be wrapped in a similar manner - provide a callback function that accepts char parameters which converts them to Unicode, and calls the Unicode callback function.

If your code runs under Windows, the MultibyteToWideChar() and WideCharToMultiByte() APIs will do the conversion for you.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900