当前位置: 首页>>代码示例>>C++>>正文


C++ sqlite3_result_blob函数代码示例

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


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

示例1: dbpageColumn

static int dbpageColumn(
  sqlite3_vtab_cursor *pCursor, 
  sqlite3_context *ctx, 
  int i
){
  DbpageCursor *pCsr = (DbpageCursor *)pCursor;
  DbpageTable *pTab = (DbpageTable *)pCursor->pVtab;
  int rc = SQLITE_OK;
  switch( i ){
    case 0: {           /* pgno */
      sqlite3_result_int(ctx, pCsr->pgno);
      break;
    }
    case 1: {           /* data */
      DbPage *pDbPage = 0;
      rc = sqlite3PagerGet(pTab->pPager, pCsr->pgno, (DbPage**)&pDbPage, 0);
      if( rc==SQLITE_OK ){
        sqlite3_result_blob(ctx, sqlite3PagerGetData(pDbPage), pTab->szPage,
                            SQLITE_TRANSIENT);
      }
      sqlite3PagerUnref(pDbPage);
      break;
    }
    default: {          /* schema */
      sqlite3 *db = sqlite3_context_db_handle(ctx);
      sqlite3_result_text(ctx, db->aDb[pTab->iDb].zDbSName, -1, SQLITE_STATIC);
      break;
    }
  }
  return SQLITE_OK;
}
开发者ID:cznic,项目名称:cc,代码行数:31,代码来源:dbpage.c

示例2: sha3Func

/*
** Implementation of the sha3(X,SIZE) function.
**
** Return a BLOB which is the SIZE-bit SHA3 hash of X.  The default
** size is 256.  If X is a BLOB, it is hashed as is.  
** For all other non-NULL types of input, X is converted into a UTF-8 string
** and the string is hashed without the trailing 0x00 terminator.  The hash
** of a NULL value is NULL.
*/
static void sha3Func(
  sqlite3_context *context,
  int argc,
  sqlite3_value **argv
){
  SHA3Context cx;
  int eType = sqlite3_value_type(argv[0]);
  int nByte = sqlite3_value_bytes(argv[0]);
  int iSize;
  if( argc==1 ){
    iSize = 256;
  }else{
    iSize = sqlite3_value_int(argv[1]);
    if( iSize!=224 && iSize!=256 && iSize!=384 && iSize!=512 ){
      sqlite3_result_error(context, "SHA3 size should be one of: 224 256 "
                                    "384 512", -1);
      return;
    }
  }
  if( eType==SQLITE_NULL ) return;
  SHA3Init(&cx, iSize);
  if( eType==SQLITE_BLOB ){
    SHA3Update(&cx, sqlite3_value_blob(argv[0]), nByte);
  }else{
    SHA3Update(&cx, sqlite3_value_text(argv[0]), nByte);
  }
  sqlite3_result_blob(context, SHA3Final(&cx), iSize/8, SQLITE_TRANSIENT);
}
开发者ID:cznic,项目名称:cc,代码行数:37,代码来源:shathree.c

示例3: recordFunc

/*
 ** The implementation of the sqlite_record() function. This function accepts
 ** a single argument of any type. The return value is a formatted database
 ** record (a blob) containing the argument value.
 **
 ** This is used to convert the value stored in the 'sample' column of the
 ** sqlite_stat3 table to the record format SQLite uses internally.
 */
static void recordFunc(
                       sqlite3_context *context,
                       int argc,
                       sqlite3_value **argv
                       ){
    const int file_format = 1;
    int iSerial;                    /* Serial type */
    int nSerial;                    /* Bytes of space for iSerial as varint */
    int nVal;                       /* Bytes of space required for argv[0] */
    int nRet;
    sqlite3 *db;
    u8 *aRet;
    
    UNUSED_PARAMETER( argc );
    iSerial = sqlite3VdbeSerialType(argv[0], file_format);
    nSerial = sqlite3VarintLen(iSerial);
    nVal = sqlite3VdbeSerialTypeLen(iSerial);
    db = sqlite3_context_db_handle(context);
    
    nRet = 1 + nSerial + nVal;
    aRet = sqlite3DbMallocRaw(db, nRet);
    if( aRet==0 ){
        sqlite3_result_error_nomem(context);
    }else{
        aRet[0] = nSerial+1;
        sqlite3PutVarint(&aRet[1], iSerial);
        sqlite3VdbeSerialPut(&aRet[1+nSerial], nVal, argv[0], file_format);
        sqlite3_result_blob(context, aRet, nRet, SQLITE_TRANSIENT);
        sqlite3DbFree(db, aRet);
    }
}
开发者ID:pchernev,项目名称:Objective-C-iOS-Categories,代码行数:39,代码来源:vdbemem.c

示例4: OGR2SQLITE_ogr_inflate

static
void OGR2SQLITE_ogr_inflate(sqlite3_context* pContext,
                            int argc, sqlite3_value** argv)
{
    if( argc != 1 ||
            sqlite3_value_type (argv[0]) != SQLITE_BLOB )
    {
        sqlite3_result_null (pContext);
        return;
    }

    size_t nOutBytes = 0;
    void* pOut;

    const void* pSrc = sqlite3_value_blob (argv[0]);
    int nLen = sqlite3_value_bytes (argv[0]);
    pOut = CPLZLibInflate( pSrc, nLen, NULL, 0, &nOutBytes);

    if( pOut != NULL )
    {
        sqlite3_result_blob (pContext, pOut, nOutBytes, VSIFree);
    }
    else
    {
        sqlite3_result_null (pContext);
    }

    return;
}
开发者ID:rashadkm,项目名称:lib_gdal,代码行数:29,代码来源:ogrsqlitesqlfunctions.cpp

示例5: readfileFunc

SQLITE_EXTENSION_INIT1
#include <stdio.h>

/*
** Implementation of the "readfile(X)" SQL function.  The entire content
** of the file named X is read and returned as a BLOB.  NULL is returned
** if the file does not exist or is unreadable.
*/
static void readfileFunc(
  sqlite3_context *context,
  int argc,
  sqlite3_value **argv
){
  const char *zName;
  FILE *in;
  long nIn;
  void *pBuf;

  zName = (const char*)sqlite3_value_text(argv[0]);
  if( zName==0 ) return;
  in = fopen(zName, "rb");
  if( in==0 ) return;
  fseek(in, 0, SEEK_END);
  nIn = ftell(in);
  rewind(in);
  pBuf = sqlite3_malloc( nIn );
  if( pBuf && 1==fread(pBuf, nIn, 1, in) ){
    sqlite3_result_blob(context, pBuf, nIn, sqlite3_free);
  }else{
    sqlite3_free(pBuf);
  }
  fclose(in);
}
开发者ID:1018824313,项目名称:sqlite,代码行数:33,代码来源:fileio.c

示例6: fts5MatchinfoFunc

static void fts5MatchinfoFunc(
  const Fts5ExtensionApi *pApi,   /* API offered by current FTS version */
  Fts5Context *pFts,              /* First arg to pass to pApi functions */
  sqlite3_context *pCtx,          /* Context for returning result/error */
  int nVal,                       /* Number of values in apVal[] array */
  sqlite3_value **apVal           /* Array of trailing arguments */
){
  const char *zArg;
  Fts5MatchinfoCtx *p;
  int rc;

  if( nVal>0 ){
    zArg = (const char*)sqlite3_value_text(apVal[0]);
  }else{
    zArg = "pcx";
  }

  p = (Fts5MatchinfoCtx*)pApi->xGetAuxdata(pFts, 0);
  if( p==0 || sqlite3_stricmp(zArg, p->zArg) ){
    p = fts5MatchinfoNew(pApi, pFts, pCtx, zArg);
    pApi->xSetAuxdata(pFts, p, sqlite3_free);
    if( p==0 ) return;
  }

  rc = fts5MatchinfoIter(pApi, pFts, p, fts5MatchinfoLocalCb);
  if( rc!=SQLITE_OK ){
    sqlite3_result_error_code(pCtx, rc);
  }else{
    /* No errors has occured, so return a copy of the array of integers. */
    int nByte = p->nRet * sizeof(u32);
    sqlite3_result_blob(pCtx, (void*)p->aRet, nByte, SQLITE_TRANSIENT);
  }
}
开发者ID:yaoweidong,项目名称:sqlite,代码行数:33,代码来源:fts5_test_mi.c

示例7: geo_simplify

void geo_simplify(sqlite3_context *context,int argc,sqlite3_value **argv)
{
	if(argc == 2 && sqlite3_value_type(argv[0]) == SQLITE_BLOB)
	{ 
		GEOSGeometry* geometry;
		GEOSGeometry* simplify_geo;
		unsigned char* wkb;
		size_t size;
		const void* data = sqlite3_value_blob(argv[0]);
		size_t data_size = sqlite3_value_bytes(argv[0]);

		double tolerance = sqlite3_value_double(argv[1]);

		_init_geos();
		geometry = _geo_from_wkb((const unsigned char*)data,data_size);
		if(geometry != 0)
		{
			simplify_geo = GEOSSimplify(geometry,tolerance);
			if(simplify_geo != 0)
			{
				wkb = GEOSGeomToWKB_buf(simplify_geo,&size);
				sqlite3_result_blob(context,wkb,size,SQLITE_TRANSIENT);
				GEOSGeom_destroy(simplify_geo);
				GEOSFree(wkb);
			}
		}
		GEOSGeom_destroy(geometry);
		finishGEOS();
	}
}
开发者ID:maowang,项目名称:sqlite-ogc,代码行数:30,代码来源:extfunction.c

示例8: OGR2SQLITE_ST_AsBinary

static
void OGR2SQLITE_ST_AsBinary(sqlite3_context* pContext,
                            int argc, sqlite3_value** argv)
{
    OGRGeometry* poGeom = OGR2SQLITE_GetGeom(pContext, argc, argv, NULL);
    if( poGeom != NULL )
    {
        int nBLOBLen = poGeom->WkbSize();
        GByte* pabyGeomBLOB = (GByte*) VSIMalloc(nBLOBLen);
        if( pabyGeomBLOB != NULL )
        {
            if( poGeom->exportToWkb(wkbNDR, pabyGeomBLOB) == OGRERR_NONE )
                sqlite3_result_blob( pContext, pabyGeomBLOB, nBLOBLen, CPLFree);
            else
            {
                VSIFree(pabyGeomBLOB);
                sqlite3_result_null (pContext);
            }
        }
        else
            sqlite3_result_null (pContext);
        delete poGeom;
    }
    else
        sqlite3_result_null (pContext);
}
开发者ID:rashadkm,项目名称:lib_gdal,代码行数:26,代码来源:ogrsqlitesqlfunctions.cpp

示例9: sqlite_callback_return

static int sqlite_callback_return(Value v, sqlite3_context *ctx)
{
    const RefNode *r_type = fs->Value_type(v);
    if (r_type == fs->cls_int) {
        int err = FALSE;
        int64_t i64 = fs->Value_int64(v, &err);
        if (err) {
            fs->throw_errorf(mod_sqlite, "SQLiteError", "'INTEGER' out of range (-2^63 - 2^63-1)");
            return FALSE;
        }
        sqlite3_result_int64(ctx, i64);
    } else if (r_type == fs->cls_bool) {
        int i32 = Value_bool(v);
        sqlite3_result_int(ctx, i32);
    } else if (r_type == fs->cls_float) {
        double dval = Value_float2(v);
        sqlite3_result_double(ctx, dval);
    } else if (r_type == fs->cls_str) {
        RefStr *s = Value_vp(v);
        sqlite3_result_text(ctx, s->c, s->size, SQLITE_TRANSIENT);
    } else if (r_type == fs->cls_bytes) {
        RefStr *s = Value_vp(v);
        sqlite3_result_blob(ctx, s->c, s->size, SQLITE_TRANSIENT);
    } else if (r_type == fs->cls_null) {
        sqlite3_result_null(ctx);
    } else {
        fs->throw_errorf(fs->mod_lang, "TypeError", "Bool, Int, Float, Str, Bytes or Null required but %n", r_type);
        return FALSE;
    }
    return TRUE;
}
开发者ID:x768,项目名称:fox-lang,代码行数:31,代码来源:m_sqlite.c

示例10: _relation_compute

static void _relation_compute(sqlite3_context *context,int argc,sqlite3_value **argv,RelationCompute Func)
{
	if(argc == 2 && sqlite3_value_type(argv[0]) == SQLITE_BLOB &&
		sqlite3_value_type(argv[1]) == SQLITE_BLOB)
	{ 
		GEOSGeometry* geometry1;
		GEOSGeometry* geometry2;
		GEOSGeometry* geo_result;
		unsigned char* wkb;
		size_t size;
		const void* data1 = sqlite3_value_blob(argv[0]);
		size_t data_size1 = sqlite3_value_bytes(argv[0]);

		const void* data2 = sqlite3_value_blob(argv[1]);
		size_t data_size2 = sqlite3_value_bytes(argv[1]);

		_init_geos();
		geometry1 = _geo_from_wkb((const unsigned char*)data1,data_size1);
		geometry2 = _geo_from_wkb((const unsigned char*)data2,data_size2);
		if(geometry1 != 0 && geometry2 != 0)
		{
			geo_result = Func(geometry1,geometry2);
			if(geo_result != 0)
			{
				wkb = GEOSGeomToWKB_buf(geo_result,&size);
				sqlite3_result_blob(context,wkb,size,SQLITE_TRANSIENT);
				GEOSGeom_destroy(geo_result);
				GEOSFree(wkb);
			}
		}
		if(geometry1!=0)GEOSGeom_destroy(geometry1);
		if(geometry2!=0)GEOSGeom_destroy(geometry2);
		finishGEOS();
	}
}
开发者ID:maowang,项目名称:sqlite-ogc,代码行数:35,代码来源:extfunction.c

示例11: readfileFunc

/*
** Implementation of the "readfile(X)" SQL function.  The entire content
** of the file named X is read and returned as a BLOB.  NULL is returned
** if the file does not exist or is unreadable.
*/
static void readfileFunc(
  sqlite3_context *context,
  int argc,
  sqlite3_value **argv
){
  const char *zName;
  FILE *in;
  long nIn;
  void *pBuf;

  zName = (const char*)sqlite3_value_text(argv[0]);
  if( zName==0 ) return;
  in = fopen(zName, "rb");
  if( in==0 ) return;
  fseek(in, 0, SEEK_END);
  nIn = ftell(in);
  rewind(in);
  pBuf = sqlite3_malloc64( nIn );
  if( pBuf && 1==fread(pBuf, nIn, 1, in) ){
    sqlite3_result_blob(context, pBuf, nIn, sqlite3_free);
  }else{
    sqlite3_free(pBuf);
  }
  fclose(in);
}
开发者ID:jmptrader,项目名称:sqlite,代码行数:30,代码来源:fuzzcheck.c

示例12: ST_SRID

static void ST_SRID(sqlite3_context *context, int nbArgs, sqlite3_value **args) {
  spatialdb_t *spatialdb;
  FUNCTION_GEOM_ARG(geomblob);

  FUNCTION_START_STATIC(context, 256);
  spatialdb = (spatialdb_t *)sqlite3_user_data(context);
  FUNCTION_GET_GEOM_ARG_UNSAFE(context, spatialdb, geomblob, 0);

  if (nbArgs == 1) {
    sqlite3_result_int(context, geomblob.srid);
  } else {
    FUNCTION_GET_INT_ARG(geomblob.srid, 1);
    if (binstream_seek(&FUNCTION_GEOM_ARG_STREAM(geomblob), 0) != SQLITE_OK) {
      sqlite3_result_error(context, "Error writing geometry blob header", -1);
      goto exit;
    }
    if (spatialdb->write_blob_header(&FUNCTION_GEOM_ARG_STREAM(geomblob), &geomblob, FUNCTION_ERROR) != SQLITE_OK) {
      if (error_count(FUNCTION_ERROR) == 0) {
        error_append(FUNCTION_ERROR, "Error writing geometry blob header");
      }
      goto exit;
    }
    binstream_seek(&FUNCTION_GEOM_ARG_STREAM(geomblob), 0);
    sqlite3_result_blob(context, binstream_data(&FUNCTION_GEOM_ARG_STREAM(geomblob)), (int) binstream_available(&FUNCTION_GEOM_ARG_STREAM(geomblob)), SQLITE_TRANSIENT);
  }

  FUNCTION_END(context);
  FUNCTION_FREE_GEOM_ARG(geomblob);
}
开发者ID:boundlessgeo,项目名称:libgpkg-mobile,代码行数:29,代码来源:spatialdb.c

示例13: geo_polyline_decode

void geo_polyline_decode(sqlite3_context *context,int argc,sqlite3_value **argv)
{
	if(argc >= 1 && sqlite3_value_type(argv[0]) == SQLITE_TEXT)
	{ 
		GEOSGeometry* geometry;
		const unsigned char* data = sqlite3_value_text(argv[0]);
		int point = 1;
		size_t size = 0;

		if(argc > 1)
		{
			point = sqlite3_value_int(argv[1]);
		}

		_init_geos();
		geometry = polyline_decode(data,point);
		if(geometry != 0)
		{
			unsigned char* wkb = GEOSGeomToWKB_buf(geometry,&size);
			if(wkb != NULL)
			{
				sqlite3_result_blob(context,wkb,size,SQLITE_TRANSIENT);
				GEOSFree(wkb);
			}
		}
		GEOSGeom_destroy(geometry);
		finishGEOS();
	}
}
开发者ID:maowang,项目名称:sqlite-ogc,代码行数:29,代码来源:extfunction.c

示例14: my_load_file

extern void  my_load_file(sqlite3_context * context,
                          int               argc,
                          sqlite3_value  ** argv) {

   struct stat    statbuf;
   char          *fname;
   unsigned char *blob;
   FILE          *fp;
   size_t         nread;

   _ksu_null_if_null_param(argc, argv);
   fname = (char *)sqlite3_value_text(argv[0]);
   if (stat((const char *)fname, &statbuf) == -1) {
     sqlite3_result_null(context);
     return;
   }
   if ((blob = (unsigned char *)sqlite3_malloc((int)statbuf.st_size))
            == (unsigned char *)NULL) {
     sqlite3_result_error_nomem(context);
     return;
   }
   if ((fp = fopen(fname, "r")) != (FILE *)NULL) {
      nread = fread((void *)blob, sizeof(unsigned char),
                                  (size_t)statbuf.st_size, fp);
      fclose(fp);
      sqlite3_result_blob(context, (const void *)blob,
                          (int)nread, sqlite3_free);
   } else {
      sqlite3_free(blob);
      sqlite3_result_null(context);
   }
}
开发者ID:sfaroult,项目名称:sqlite_libs,代码行数:32,代码来源:my_load_file.c

示例15: OGR2SQLITE_Transform

static
void OGR2SQLITE_Transform(sqlite3_context* pContext,
                          int argc, sqlite3_value** argv)
{
    if( argc != 3 )
    {
        sqlite3_result_null (pContext);
        return;
    }

    if( sqlite3_value_type (argv[0]) != SQLITE_BLOB )
    {
        sqlite3_result_null (pContext);
        return;
    }

    if( sqlite3_value_type (argv[1]) != SQLITE_INTEGER )
    {
        sqlite3_result_null (pContext);
        return;
    }

    if( sqlite3_value_type (argv[2]) != SQLITE_INTEGER )
    {
        sqlite3_result_null (pContext);
        return;
    }

    int nSrcSRSId = sqlite3_value_int(argv[1]);
    int nDstSRSId = sqlite3_value_int(argv[2]);

    OGRSQLiteExtensionData* poModule =
        (OGRSQLiteExtensionData*) sqlite3_user_data(pContext);
    OGRCoordinateTransformation* poCT =
        poModule->GetTransform(nSrcSRSId, nDstSRSId);
    if( poCT == NULL )
    {
        sqlite3_result_null (pContext);
        return;
    }

    GByte* pabySLBLOB = (GByte *) sqlite3_value_blob (argv[0]);
    int nBLOBLen = sqlite3_value_bytes (argv[0]);
    OGRGeometry* poGeom = NULL;
    if( OGRSQLiteLayer::ImportSpatiaLiteGeometry(
                pabySLBLOB, nBLOBLen, &poGeom ) == CE_None &&
            poGeom->transform(poCT) == OGRERR_NONE &&
            OGRSQLiteLayer::ExportSpatiaLiteGeometry(
                poGeom, nDstSRSId, wkbNDR, FALSE,
                FALSE, FALSE, &pabySLBLOB, &nBLOBLen ) == CE_None )
    {
        sqlite3_result_blob(pContext, pabySLBLOB, nBLOBLen, CPLFree);
    }
    else
    {
        sqlite3_result_null (pContext);
    }
    delete poGeom;
}
开发者ID:rashadkm,项目名称:lib_gdal,代码行数:59,代码来源:ogrsqlitesqlfunctions.cpp


注:本文中的sqlite3_result_blob函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。