您当前的位置:首页 > IT编程 > C++
| C语言 | Java | VB | VC | python | Android | TensorFlow | C++ | oracle | 学术与代码 | cnn卷积神经网络 | gnn | 图像修复 | Keras | 数据集 | Neo4j | 自然语言处理 | 深度学习 | 医学CAD | 医学影像 | 超参数 | pointnet | pytorch | 异常检测 | Transformers | 情感分类 | 知识图谱 |

自学教程:C++ sqlite3_user_data函数代码示例

51自学网 2021-06-03 08:15:58
  C++
这篇教程C++ sqlite3_user_data函数代码示例写得很实用,希望能帮到您。

本文整理汇总了C++中sqlite3_user_data函数的典型用法代码示例。如果您正苦于以下问题:C++ sqlite3_user_data函数的具体用法?C++ sqlite3_user_data怎么用?C++ sqlite3_user_data使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。

在下文中一共展示了sqlite3_user_data函数的29个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: BFileFullPathFunc

/* * The BFileFullPathFunc() SQL function  returns full path of a BFile */static void BFileFullPathFunc(    sqlite3_context *context,    int argc,    sqlite3_value **argv){    int rc;    sqlite3 *db;    int loc_size;    char *pLoc, *full_path;    assert(context != NULL && argc == 1 && argv != NULL);    loc_size = sqlite3_value_bytes(argv[0]);    if (loc_size == 0) {        sqlite3_result_null(context);        return;    }    pLoc = (char *)sqlite3_value_text(argv[0]);    db = (sqlite3 *)sqlite3_user_data(context);    rc = get_full_path(db, pLoc, loc_size, &full_path);    if (rc) {        if (rc == SQLITE_NOMEM)            sqlite3_result_error_nomem(context);        else            sqlite3_result_error(context, "internal error", -1);        return;    }    sqlite3_result_text(context, full_path, strlen(full_path), sqlite3_free);}
开发者ID:rohitlodha,项目名称:DenverDB,代码行数:36,


示例2: php_sqlite3_func_step_callback

static void php_sqlite3_func_step_callback(sqlite3_context *context, int argc,	sqlite3_value **argv){	struct pdo_sqlite_func *func = (struct pdo_sqlite_func*)sqlite3_user_data(context);	do_callback(&func->astep, &func->step, argc, argv, context, 1);}
开发者ID:LTD-Beget,项目名称:php-src,代码行数:7,


示例3: currentTimeFunc

/*** If the library is compiled to omit the full-scale date and time** handling (to get a smaller binary), the following minimal version** of the functions current_time(), current_date() and current_timestamp()** are included instead. This is to support column declarations that** include "DEFAULT CURRENT_TIME" etc.**** This function uses the C-library functions time(), gmtime()** and strftime(). The format string to pass to strftime() is supplied** as the user-data for the function.*/static void currentTimeFunc(  sqlite3_context *context,  int argc,  sqlite3_value **argv){  time_t t;  char *zFormat = (char *)sqlite3_user_data(context);  sqlite3 *db;  sqlite3_int64 iT;  struct tm *pTm;  struct tm sNow;  char zBuf[20];  UNUSED_PARAMETER(argc);  UNUSED_PARAMETER(argv);  iT = sqlite3StmtCurrentTime(context);  if( iT<=0 ) return;  t = iT/1000 - 10000*(sqlite3_int64)21086676;#if HAVE_GMTIME_R  pTm = gmtime_r(&t, &sNow);#else  sqlite3_mutex_enter(sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MASTER));  pTm = gmtime(&t);  if( pTm ) memcpy(&sNow, pTm, sizeof(sNow));  sqlite3_mutex_leave(sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MASTER));#endif  if( pTm ){    strftime(zBuf, 20, zFormat, &sNow);    sqlite3_result_text(context, zBuf, -1, SQLITE_TRANSIENT);  }}
开发者ID:1018824313,项目名称:sqlite,代码行数:43,


示例4: currentTimeFunc

/*** If the library is compiled to omit the full-scale date and time** handling (to get a smaller binary), the following minimal version** of the functions current_time(), current_date() and current_timestamp()** are included instead. This is to support column declarations that** include "DEFAULT CURRENT_TIME" etc.**** This function uses the C-library functions time(), gmtime()** and strftime(). The format string to pass to strftime() is supplied** as the user-data for the function.*/static void currentTimeFunc(  sqlite3_context *context,  int argc,  sqlite3_value **argv){  time_t t;  char *zFormat = (char *)sqlite3_user_data(context);  char zBuf[20];  time(&t);#ifdef SQLITE_TEST  {    extern int sqlite3_current_time;  /* See os_XXX.c */    if( sqlite3_current_time ){      t = sqlite3_current_time;    }  }#endif  sqlite3OsEnterMutex();  strftime(zBuf, 20, zFormat, gmtime(&t));  sqlite3OsLeaveMutex();  sqlite3_result_text(context, zBuf, -1, SQLITE_TRANSIENT);}
开发者ID:ProjectZeroSlackr,项目名称:Floydzilla,代码行数:36,


示例5: likeFunc

/*** Implementation of the like() SQL function.  This function implements** the build-in LIKE operator.  The first argument to the function is the** pattern and the second argument is the string.  So, the SQL statements:****       A LIKE B**** is implemented as like(B,A).**** This same function (with a different compareInfo structure) computes** the GLOB operator.*/static void likeFunc(  sqlite3_context *context,   int argc,   sqlite3_value **argv){  const unsigned char *zA = sqlite3_value_text(argv[0]);  const unsigned char *zB = sqlite3_value_text(argv[1]);  int escape = 0;  if( argc==3 ){    /* The escape character string must consist of a single UTF-8 character.    ** Otherwise, return an error.    */    const unsigned char *zEsc = sqlite3_value_text(argv[2]);    if( sqlite3utf8CharLen((char*)zEsc, -1)!=1 ){      sqlite3_result_error(context,           "ESCAPE expression must be a single character", -1);      return;    }    escape = sqlite3ReadUtf8(zEsc);  }  if( zA && zB ){    struct compareInfo *pInfo = sqlite3_user_data(context);#ifdef SQLITE_TEST    sqlite3_like_count++;#endif    sqlite3_result_int(context, patternCompare(zA, zB, pInfo, escape));  }}
开发者ID:f059074251,项目名称:interested,代码行数:40,


示例6: func_callback_wrapper

static void func_callback_wrapper(int which, sqlite3_context * ctx, int num_args, sqlite3_value ** values){  CB_Data *	cb_data	= sqlite3_user_data(ctx);  DB *		db 	= cb_data->db;  lua_State * 	L	= db->L;    switch(which)  {    case 0:	push_callback(L, db, KEY_XFUNC(cb_data)); break;    case 1:	push_callback(L, db, KEY_XSTEP(cb_data)); break;    case 2:	push_callback(L, db, KEY_XFINAL(cb_data)); break;  }    if (lua_isnil(L, -1))  {    lua_pop(L, 1);    fprintf(stderr, "libluasqlite3: func_callback_wrapper: Warning: function is null/n");    return;  }    lua_pushlightuserdata(L, ctx);    if (values)  {    lua_pushnumber(L, num_args);    lua_pushlightuserdata(L, values);  }    if (lua_pcall(L, values ? 3 : 1, 0, 0))  {    fprintf(stderr, "libluasqlite3: func_callback_wrapper: Warning: user function error: %s/n", lua_tostring(L, -1));    sqlite3_result_error(ctx, lua_tostring(L, -1), lua_strlen(L, -1));    lua_pop(L, 1);  }}
开发者ID:WeyrSDev,项目名称:gamecode3,代码行数:35,


示例7: icuLoadCollation

/*** Implementation of the scalar function icu_load_collation().**** This scalar function is used to add ICU collation based collation ** types to an SQLite database connection. It is intended to be called** as follows:****     SELECT icu_load_collation(<locale>, <collation-name>);**** Where <locale> is a string containing an ICU locale identifier (i.e.** "en_AU", "tr_TR" etc.) and <collation-name> is the name of the** collation sequence to create.*/static void icuLoadCollation(  sqlite3_context *p,   int nArg,   sqlite3_value **apArg){  sqlite3 *db = (sqlite3 *)sqlite3_user_data(p);  UErrorCode status = U_ZERO_ERROR;  const char *zLocale;      /* Locale identifier - (eg. "jp_JP") */  const char *zName;        /* SQL Collation sequence name (eg. "japanese") */  UCollator *pUCollator;    /* ICU library collation object */  int rc;                   /* Return code from sqlite3_create_collation_x() */  assert(nArg==2);  zLocale = (const char *)sqlite3_value_text(apArg[0]);  zName = (const char *)sqlite3_value_text(apArg[1]);  if( !zLocale || !zName ){    return;  }  pUCollator = ucol_open(zLocale, &status);  if( !U_SUCCESS(status) ){    icuFunctionError(p, "ucol_open", status);    return;  }  assert(p);  rc = sqlite3_create_collation_v2(db, zName, SQLITE_UTF16, (void *)pUCollator,       icuCollationColl, icuCollationDel  );  if( rc!=SQLITE_OK ){    ucol_close(pUCollator);    sqlite3_result_error(p, "Error registering collation function", -1);  }}
开发者ID:520060628,项目名称:Sqlite3.07.14,代码行数:48,


示例8: minmaxStep

/*** Routines to implement min() and max() aggregate functions.*/static void minmaxStep(  sqlite3_context *context,   int NotUsed,   sqlite3_value **argv){  Mem *pArg  = (Mem *)argv[0];  Mem *pBest;  UNUSED_PARAMETER(NotUsed);  if( sqlite3_value_type(argv[0])==SQLITE_NULL ) return;  pBest = (Mem *)sqlite3_aggregate_context(context, sizeof(*pBest));  if( !pBest ) return;  if( pBest->flags ){    int max;    int cmp;    CollSeq *pColl = sqlite3GetFuncCollSeq(context);    /* This step function is used for both the min() and max() aggregates,    ** the only difference between the two being that the sense of the    ** comparison is inverted. For the max() aggregate, the    ** sqlite3_user_data() function returns (void *)-1. For min() it    ** returns (void *)db, where db is the sqlite3* database pointer.    ** Therefore the next statement sets variable 'max' to 1 for the max()    ** aggregate, or 0 for min().    */    max = sqlite3_user_data(context)!=0;    cmp = sqlite3MemCompare(pBest, pArg, pColl);    if( (max && cmp<0) || (!max && cmp>0) ){      sqlite3VdbeMemCopy(pBest, pArg);    }  }else{    sqlite3VdbeMemCopy(pBest, pArg);  }}
开发者ID:blingstorm,项目名称:sqlcipher,代码行数:37,


示例9: intTestFunc

/*** Implementation of the scalar function fts3_tokenizer_internal_test().** This function is used for testing only, it is not included in the** build unless SQLITE_TEST is defined.**** The purpose of this is to test that the fts3_tokenizer() function** can be used as designed by the C-code in the queryTokenizer and** registerTokenizer() functions above. These two functions are repeated** in the README.tokenizer file as an example, so it is important to** test them.**** To run the tests, evaluate the fts3_tokenizer_internal_test() scalar** function with no arguments. An assert() will fail if a problem is** detected. i.e.:****     SELECT fts3_tokenizer_internal_test();***/static void intTestFunc(  sqlite3_context *context,  int argc,  sqlite3_value **argv){  int rc;  const sqlite3_tokenizer_module *p1;  const sqlite3_tokenizer_module *p2;  sqlite3 *db = (sqlite3 *)sqlite3_user_data(context);  UNUSED_PARAMETER(argc);  UNUSED_PARAMETER(argv);  /* Test the query function */  sqlite3Fts3SimpleTokenizerModule(&p1);  rc = queryTokenizer(db, "simple", &p2);  assert( rc==SQLITE_OK );  assert( p1==p2 );  rc = queryTokenizer(db, "nosuchtokenizer", &p2);  assert( rc==SQLITE_ERROR );  assert( p2==0 );  assert( 0==strcmp(sqlite3_errmsg(db), "unknown tokenizer: nosuchtokenizer") );  /* Test the storage function */#ifdef SQLITE_ENABLE_FTS3_TOKENIZER  rc = registerTokenizer(db, "nosuchtokenizer", p1);  assert( rc==SQLITE_OK );  rc = queryTokenizer(db, "nosuchtokenizer", &p2);  assert( rc==SQLITE_OK );  assert( p2==p1 );#endif  sqlite3_result_text(context, "ok", -1, SQLITE_STATIC);}
开发者ID:Amazeus-Mozart,项目名称:sqlcipher,代码行数:52,


示例10: test_destructor

static void test_destructor(  sqlite3_context *pCtx,   int nArg,  sqlite3_value **argv){  char *zVal;  int len;  sqlite3 *db = sqlite3_user_data(pCtx);   test_destructor_count_var++;  assert( nArg==1 );  if( sqlite3_value_type(argv[0])==SQLITE_NULL ) return;  len = sqlite3ValueBytes(argv[0], ENC(db));   zVal = sqliteMalloc(len+3);  zVal[len] = 0;  zVal[len-1] = 0;  assert( zVal );  zVal++;  memcpy(zVal, sqlite3ValueText(argv[0], ENC(db)), len);  if( ENC(db)==SQLITE_UTF8 ){    sqlite3_result_text(pCtx, zVal, -1, destructor);#ifndef SQLITE_OMIT_UTF16  }else if( ENC(db)==SQLITE_UTF16LE ){    sqlite3_result_text16le(pCtx, zVal, -1, destructor);  }else{    sqlite3_result_text16be(pCtx, zVal, -1, destructor);#endif /* SQLITE_OMIT_UTF16 */  }}
开发者ID:f059074251,项目名称:interested,代码行数:29,


示例11: minmaxFunc

/*** Implementation of the non-aggregate min() and max() functions*/static void minmaxFunc(  sqlite3_context *context,  int argc,  sqlite3_value **argv){  int i;  int mask;    /* 0 for min() or 0xffffffff for max() */  int iBest;  CollSeq *pColl;  if( argc==0 ) return;  mask = sqlite3_user_data(context)==0 ? 0 : -1;  pColl = sqlite3GetFuncCollSeq(context);  assert( pColl );  assert( mask==-1 || mask==0 );  iBest = 0;  if( sqlite3_value_type(argv[0])==SQLITE_NULL ) return;  for(i=1; i<argc; i++){    if( sqlite3_value_type(argv[i])==SQLITE_NULL ) return;    if( (sqlite3MemCompare(argv[iBest], argv[i], pColl)^mask)>=0 ){      iBest = i;    }  }  sqlite3_result_value(context, argv[iBest]);}
开发者ID:f059074251,项目名称:interested,代码行数:28,


示例12: validate_double_udf

void validate_double_udf(sqlite3_context* ctx, int nargs, sqlite3_value** values){    sqlite3 *db;    const char *value;    char *tmp;    db    = (sqlite3*)sqlite3_user_data(ctx);    value = sqlite3_value_text(values[0]);    /* Assuming NULL values for type checked columns not allowed */    if(value == NULL) {        sqlite3_result_int(ctx, 0);        return;    }    // Validate type:    tmp = NULL;    strtod(value, &tmp);        if(*tmp != '/0') {        // Value does not conform to type        sqlite3_result_int(ctx, 0);        return;    }    // If we got this far value is valid.    sqlite3_result_int(ctx, 1);}
开发者ID:PengJi,项目名称:sql_prac,代码行数:28,


示例13: wrapped_func

static voidwrapped_func(sqlite3_context *context,             int argc,             sqlite3_value *values[]){  struct function_wrapper_baton_t *fwb = sqlite3_user_data(context);  svn_sqlite__context_t sctx;  svn_sqlite__value_t **local_vals =                            apr_palloc(fwb->scratch_pool,                                       sizeof(svn_sqlite__value_t *) * argc);  svn_error_t *err;  int i;  sctx.context = context;  for (i = 0; i < argc; i++)    {      local_vals[i] = apr_palloc(fwb->scratch_pool, sizeof(*local_vals[i]));      local_vals[i]->value = values[i];    }  err = fwb->func(&sctx, argc, local_vals, fwb->scratch_pool);  svn_pool_clear(fwb->scratch_pool);  if (err)    {      char buf[256];      sqlite3_result_error(context,                           svn_err_best_message(err, buf, sizeof(buf)),                           -1);      svn_error_clear(err);    }}
开发者ID:DJEX93,项目名称:dsploit,代码行数:33,


示例14: sqlite_callback_final

static void sqlite_callback_final(sqlite3_context *ctx){    RefNode *klass = (RefNode*)sqlite3_user_data(ctx);    Value *v = sqlite3_aggregate_context(ctx, sizeof(Value));    if (*v == VALUE_NULL) {        if (!sqlite_aggrigate_new(v, klass)) {            goto ERROR_END;        }    }    fs->Value_push("v", v);    if (!fs->call_member_func(fs->intern("final", -1), 0, TRUE)) {        goto ERROR_END;    }    // 
C++ sqlite3_value_blob函数代码示例
C++ sqlite3_step函数代码示例
万事OK自学网:51自学网_软件自学网_CAD自学网自学excel、自学PS、自学CAD、自学C语言、自学css3实例,是一个通过网络自主学习工作技能的自学平台,网友喜欢的软件自学网站。