确定回调的最后一次调用

Determine last invocation of callback

在 c++ 中,使用 sqlite3,回调函数用于从数据库中检索 select 结果:

rc = sqlite3_exec(db, query, callback, 0, &sqlErrorMsg);

对于从数据库返回的每条记录,调用此函数:

static int callback(void *NotUsed, int argc, char **argv, char **azColName) {
    int i;
    std::cout << "Called\n";
    for(i = 0;i < argc;i++) {
        printf("%s = %s\n", azColName[i], argv[i] ? argv[i] : "NULL");
    }
    printf("\n");

    /** Example **/
    //if(last) do something; //to demonstrate that I need access to this information inside of the callback
    return 0;
}

我需要一种方法来确定对这个函数的最后一次调用(在 sql 的最后一条记录上)。

我认为这需要一些在 C++ 方面更有经验的人。我还是个新手,所以随时欢迎提示。提前致谢。

解决方案(在 的帮助下):

rc = sqlite3_exec(db, sql, callback, (void*)rowCount, &zErrMsg);

然后在回调中

static callback(void* rowCount, int argc, char** argv, char** azColName) { //here the integer is converted to hex, but converting it is easy enough
}