什么是cppsqlite3中的sqlite3的sqlite3_exec(如果有的话)? [英] What is the equivalent of sqlite3's sqlite3_exec in cppsqlite3 (if there is any)?

查看:151
本文介绍了什么是cppsqlite3中的sqlite3的sqlite3_exec(如果有的话)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用CppSQLite3作为sqlite3的包装器,因为它允许传递UNICODE字符串,因为它通常支持UNICODE。

是否有一个CppSQLite3函数类似于允许传递回调函数的sqlite3_exec()?





sqlite3_exe声明如下:

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:

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的execQuery()声明如下:



CppSQLite3's execQuery() is declared as follow:

CppSQLite3Query execQuery(LPCTSTR szSQL);





我尝试过:



我试过寻找这样的包装函数来接受



What I have tried:

I have tried looking for such wrapper function that will accept

wchar_t *

而不是

instead of

char *

但找不到任何...

推荐答案

由于您拥有CppSqlite的源代码,您可以随时编写其他(Unicode)方法,如下所示: br $>


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

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 */
		);





此代码将(a)将任何参数从Unicode转换为(例如)UTF-8,并调用 char 版本。如果提供了Unicode回调函数,它可以以类似的方式包装 - 提供一个回调函数,该函数接受 char 参数,将它们转换为Unicode,并调用Unicode回调函数。



如果您的代码在Windows下运行,MultibyteToWideChar()和WideCharToMultiByte()API将为您进行转换。



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.


这篇关于什么是cppsqlite3中的sqlite3的sqlite3_exec(如果有的话)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆