• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# sqlite3_context类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: minmaxFunc

		/*
		** Implementation of the non-aggregate min() and max() functions
		*/

		private 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;

			Debug.Assert(argc > 1);
			mask = (int)sqlite3_user_data(context) == 0 ? 0 : -1;
			pColl = sqlite3GetFuncCollSeq(context);
			Debug.Assert(pColl != null);
			Debug.Assert(mask == -1 || mask == 0);
			testcase(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:broettge,项目名称:MatterControl,代码行数:35,代码来源:func_c.cs


示例2: renameTableFunc

/*
** 2005 February 15
**
** The author disclaims copyright to this source code.  In place of
** a legal notice, here is a blessing:
**
**    May you do good and not evil.
**    May you find forgiveness for yourself and forgive others.
**    May you share freely, never taking more than you give.
**
*************************************************************************
** This file contains C code routines that used to generate VDBE code
** that implements the ALTER TABLE command.
*************************************************************************
**  Included in SQLite3 port to C#-SQLite;  2008 Noah B Hart
**  C#-SQLite is an independent reimplementation of the SQLite software library
**
**  SQLITE_SOURCE_ID: 2011-06-23 19:49:22 4374b7e83ea0a3fbc3691f9c0c936272862f32f2
**
*************************************************************************
*/
//#include "sqliteInt.h"

/*
** The code in this file only exists if we are not omitting the
** ALTER TABLE logic from the build.
*/
#if !SQLITE_OMIT_ALTERTABLE


/*
** This function is used by SQL generated to implement the
** ALTER TABLE command. The first argument is the text of a CREATE TABLE or
** CREATE INDEX command. The second is a table name. The table name in
** the CREATE TABLE or CREATE INDEX statement is replaced with the third
** argument and the result returned. Examples:
**
** sqlite_rename_table('CREATE TABLE abc(a, b, c)', 'def')
**     . 'CREATE TABLE def(a, b, c)'
**
** sqlite_rename_table('CREATE INDEX i ON abc(a)', 'def')
**     . 'CREATE INDEX i ON def(a, b, c)'
*/
static void renameTableFunc(
sqlite3_context context,
int NotUsed,
sqlite3_value[] argv
)
{
  string bResult = sqlite3_value_text( argv[0] );
  string zSql = bResult == null ? "" : bResult;
  string zTableName = sqlite3_value_text( argv[1] );

  int token = 0;
  Token tname = new Token();
  int zCsr = 0;
  int zLoc = 0;
  int len = 0;
  string zRet;

  sqlite3 db = sqlite3_context_db_handle( context );

  UNUSED_PARAMETER( NotUsed );

  /* The principle used to locate the table name in the CREATE TABLE
  ** statement is that the table name is the first non-space token that
  ** is immediately followed by a TK_LP or TK_USING token.
  */
  if ( zSql != "" )
  {
    do
    {
      if ( zCsr == zSql.Length )
      {
        /* Ran out of input before finding an opening bracket. Return NULL. */
        return;
      }

      /* Store the token that zCsr points to in tname. */
      zLoc = zCsr;
      tname.z = zSql.Substring( zCsr );//(char*)zCsr;
      tname.n = len;

      /* Advance zCsr to the next token. Store that token type in 'token',
      ** and its length in 'len' (to be used next iteration of this loop).
      */
      do
      {
        zCsr += len;
        len = ( zCsr == zSql.Length ) ? 1 : sqlite3GetToken( zSql, zCsr, ref token );
      } while ( token == TK_SPACE );
      Debug.Assert( len > 0 );
    } while ( token != TK_LP && token != TK_USING );

    zRet = sqlite3MPrintf( db, "%.*s\"%w\"%s", zLoc, zSql.Substring( 0, zLoc ),
    zTableName, zSql.Substring( zLoc + tname.n ) );

    sqlite3_result_text( context, zRet, -1, SQLITE_DYNAMIC );
  }
}
开发者ID:z0rg1nc,项目名称:CsharpSqliteFork,代码行数:100,代码来源:alter_c.cs


示例3: cubeFunc

 /*
 ** The cube() SQL function returns the cube of its input value.
 */
 static void cubeFunc(
 sqlite3_context context,
 int argc,
 sqlite3_value[] argv
 )
 {
   double r = sqlite3_value_double( argv[0] );
   sqlite3_result_double( context, r * r * r );
 }
开发者ID:R4P3-NET,项目名称:AccountingServerEmulatorSource,代码行数:12,代码来源:test_autoext_c.cs


示例4: testContextMalloc

    /*
    ** 2008 March 19
    **
    ** The author disclaims copyright to this source code.  In place of
    ** a legal notice, here is a blessing:
    **
    **    May you do good and not evil.
    **    May you find forgiveness for yourself and forgive others.
    **    May you share freely, never taking more than you give.
    **
    *************************************************************************
    ** Code for testing all sorts of SQLite interfaces.  This code
    ** implements new SQL functions used by the test scripts.
    *************************************************************************
    **  Included in SQLite3 port to C#-SQLite;  2008 Noah B Hart
    **  C#-SQLite is an independent reimplementation of the SQLite software library
    **
    **  SQLITE_SOURCE_ID: 2011-05-19 13:26:54 ed1da510a239ea767a01dc332b667119fa3c908e
    **
    *************************************************************************
    */
    //#include "sqlite3.h"
    //#include "tcl.h"
    //#include <stdlib.h>
    //#include <string.h>
    //#include <assert.h>


    /*
    ** Allocate nByte bytes of space using sqlite3Malloc(). If the
    ** allocation fails, call sqlite3_result_error_nomem() to notify
    ** the database handle that malloc() has failed.
    */
    static Object testContextMalloc( sqlite3_context context, int nByte )
    {
      Object z = new Object();// sqlite3Malloc( nByte );
      if ( z == null && nByte > 0 )
      {
        sqlite3_result_error_nomem( context );
      }
      return z;
    }
开发者ID:R4P3-NET,项目名称:AccountingServerEmulatorSource,代码行数:42,代码来源:test_func_c.cs


示例5: renameParentFunc

        /// <summary>
        /// This C function implements an SQL user function that is used by SQL code
        /// generated by the ALTER TABLE ... RENAME command to modify the definition
        /// of any foreign key constraints that use the table being renamed as the 
        /// parent table. It is passed three arguments:
        ///
        ///   1) The complete text of the CREATE TABLE statement being modified,
        ///   2) The old name of the table being renamed, and
        ///   3) The new name of the table being renamed.
        ///
        /// It returns the new CREATE TABLE statement. For example:
        ///
        ///   sqlite_rename_parent('CREATE TABLE t1(a REFERENCES t2)', 't2', 't3')
        ///       -> 'CREATE TABLE t1(a REFERENCES t3)'
        /// </summary>
        static void renameParentFunc(
		  sqlite3_context context,
		  int NotUsed,
		  sqlite3_value[] argv
		)
        {
            sqlite3 db = sqlite3_context_db_handle(context);
            string zOutput = "";
            string zResult;
            string zInput = sqlite3_value_text(argv[0]);
            string zOld = sqlite3_value_text(argv[1]);
            string zNew = sqlite3_value_text(argv[2]);

            int zIdx;         /* Pointer to token */
            int zLeft = 0;    /* Pointer to remainder of String */
            int n = 0;        /* Length of token z */
            int token = 0;    /* Type of token */

            UNUSED_PARAMETER(NotUsed);
            for (zIdx = 0; zIdx < zInput.Length; zIdx += n)//z=zInput; *z; z=z+n)
            {
                n = sqlite3GetToken(zInput, zIdx, ref token);
                if (token == TK_REFERENCES)
                {
                    string zParent;
                    do
                    {
                        zIdx += n;
                        n = sqlite3GetToken(zInput, zIdx, ref token);
                    } while (token == TK_SPACE);

                    zParent = zIdx + n < zInput.Length ? zInput.Substring(zIdx, n) : "";//sqlite3DbStrNDup(db, zIdx, n);
                    if (String.IsNullOrEmpty(zParent))
                        break;
                    sqlite3Dequote(ref zParent);
                    if (zOld.Equals(zParent, StringComparison.InvariantCultureIgnoreCase))
                    {
                        string zOut = sqlite3MPrintf(db, "%s%.*s\"%w\"",
                            zOutput, zIdx - zLeft, zInput.Substring(zLeft), zNew
                        );
                        sqlite3DbFree(db, ref zOutput);
                        zOutput = zOut;
                        zIdx += n;// zInput = &z[n];
                        zLeft = zIdx;
                    }
                    sqlite3DbFree(db, ref zParent);
                }
            }

            zResult = sqlite3MPrintf(db, "%s%s", zOutput, zInput.Substring(zLeft));
            sqlite3_result_text(context, zResult, -1, SQLITE_DYNAMIC);
            sqlite3DbFree(db, ref zOutput);
        }
开发者ID:RainsSoft,项目名称:CsharpSQLite,代码行数:68,代码来源:alter_c.cs


示例6: absFunc

 /*
 ** Implementation of the abs() function.
 **
 ** IMP: R-23979-26855 The abs(X) function returns the absolute value of
 ** the numeric argument X.
 */
 static void absFunc(
     sqlite3_context context,
     int argc,
     sqlite3_value[] argv
     )
 {
     Debug.Assert( argc == 1 );
       UNUSED_PARAMETER( argc );
       switch ( sqlite3_value_type( argv[0] ) )
       {
     case SQLITE_INTEGER:
       {
     i64 iVal = sqlite3_value_int64( argv[0] );
     if ( iVal < 0 )
     {
       if ( ( iVal << 1 ) == 0 )
       {
         /* IMP: R-35460-15084 If X is the integer -9223372036854775807 then
         ** abs(X) throws an integer overflow error since there is no
         ** equivalent positive 64-bit two complement value. */
         sqlite3_result_error( context, "integer overflow", -1 );
         return;
       }
       iVal = -iVal;
     }
     sqlite3_result_int64( context, iVal );
     break;
       }
     case SQLITE_NULL:
       {
     /* IMP: R-37434-19929 Abs(X) returns NULL if X is NULL. */
     sqlite3_result_null( context );
     break;
       }
     default:
       {
     /* Because sqlite3_value_double() returns 0.0 if the argument is not
     ** something that can be converted into a number, we have:
     ** IMP: R-57326-31541 Abs(X) return 0.0 if X is a string or blob that
     ** cannot be converted to a numeric value.
     */
     double rVal = sqlite3_value_double( argv[0] );
     if ( rVal < 0 )
       rVal = -rVal;
     sqlite3_result_double( context, rVal );
     break;
       }
       }
 }
开发者ID:taxilian,项目名称:some_library,代码行数:55,代码来源:func_c.cs


示例7: randStr

    /*
    ** This function generates a string of random characters.  Used for
    ** generating test data.
    */
    static void randStr( sqlite3_context context, int argc, sqlite3_value[] argv )
    {
      string zSrc =
      "abcdefghijklmnopqrstuvwxyz" +
      "ABCDEFGHIJKLMNOPQRSTUVWXYZ" +
      "0123456789" +
      ".-!,:*^+=_|?/<> ";
      int iMin, iMax, n, i;
      i64 r = 0;

      StringBuilder zBuf = new StringBuilder( 1000 );

      /* It used to be possible to call randstr() with any number of arguments,
      ** but now it is registered with SQLite as requiring exactly 2.
      */
      Debug.Assert( argc == 2 );

      iMin = sqlite3_value_int( argv[0] );
      if ( iMin < 0 )
        iMin = 0;
      if ( iMin >= zBuf.Capacity )
        iMin = zBuf.Capacity - 1;
      iMax = sqlite3_value_int( argv[1] );
      if ( iMax < iMin )
        iMax = iMin;
      if ( iMax >= zBuf.Capacity )
        iMax = zBuf.Capacity - 1;
      n = iMin;
      if ( iMax > iMin )
      {
        sqlite3_randomness( sizeof( i64 ), ref r );
        r &= 0x7fffffff;
        n += (int)( r % ( iMax + 1 - iMin ) );
      }
      Debug.Assert( n < zBuf.Capacity );//sizeof( zBuf ) );
      i64 zRan = 0;
      for ( i = 0; i < n; i++ )
      {
        sqlite3_randomness( 1, ref zRan );
        zBuf.Append( zSrc[(int)( Math.Abs( zRan ) % ( zSrc.Length - 1 ) )] );
      }
      //zBuf[n] = 0;
      sqlite3_result_text( context, zBuf, n, SQLITE_TRANSIENT );
    }
开发者ID:R4P3-NET,项目名称:AccountingServerEmulatorSource,代码行数:48,代码来源:test_func_c.cs


示例8: overloadedGlobFunction

    /*
    ** Implementation of "GLOB" function on the echo module.  Pass
    ** all arguments to the ::echo_glob_overload procedure of TCL
    ** and return the result of that procedure as a string.
    */
    static void overloadedGlobFunction(
      sqlite3_context pContext,
      int nArg,
      sqlite3_value[] apArg
    )
    {
      Tcl_Interp interp = (Interp)sqlite3_user_data( pContext );
      TclObject str = null;
      int i;
      int rc;
      TCL.Tcl_DStringInit( out str );
      TCL.Tcl_DStringAppendElement( str, "::echo_glob_overload" );
      for ( i = 0; i < nArg; i++ )
      {
        TCL.Tcl_DStringAppendElement( str, " " + sqlite3_value_text( apArg[i] ) );
      }

      rc = TCL.Tcl_EvalObjEx( interp, str, 0 );// rc = TCL.Tcl_Eval( interp, TCL.Tcl_DStringValue( ref str ) );
      TCL.Tcl_DStringFree( ref str );
      if ( rc != 0 )
      {
        sqlite3_result_error( pContext, TCL.Tcl_GetStringResult( interp ), -1 );
      }
      else
      {
        sqlite3_result_text( pContext, TCL.Tcl_GetStringResult( interp ),
                            -1, SQLITE_TRANSIENT );
      }
      TCL.Tcl_ResetResult( interp );
    }
开发者ID:Jaden-J,项目名称:csharp-sqlite,代码行数:35,代码来源:test8_c.cs


示例9: sqlite3VdbeExec


//.........这里部分代码省略.........
					** be returned. This is used by the built-in min(), max() and nullif()
					** functions.
					**
					** The interface used by the implementation of the aforementioned functions
					** to retrieve the collation sequence set by this opcode is not available
					** publicly, only to user functions defined in func.c.
					*/
					case OP_CollSeq:
						{
							Debug.Assert(pOp.p4type == P4_COLLSEQ);
							break;
						}

					/* Opcode: Function P1 P2 P3 P4 P5
					**
					** Invoke a user function (P4 is a pointer to a Function structure that
					** defines the function) with P5 arguments taken from register P2 and
					** successors.  The result of the function is stored in register P3.
					** Register P3 must not be one of the function inputs.
					**
					** P1 is a 32-bit bitmask indicating whether or not each argument to the
					** function was determined to be constant at compile time. If the first
					** argument was constant then bit 0 of P1 is set. This is used to determine
					** whether meta data associated with a user function argument using the
					** sqlite3_set_auxdata() API may be safely retained until the next
					** invocation of this opcode.
					**
					** See also: AggStep and AggFinal
					*/
					case OP_Function:
						{
							int i;
							Mem pArg;
							sqlite3_context ctx = new sqlite3_context();
							sqlite3_value[] apVal;
							int n;

							n = pOp.p5;
							apVal = p.apArg;
							Debug.Assert(apVal != null || n == 0);
							Debug.Assert(pOp.p3 > 0 && pOp.p3 <= p.nMem);
							pOut = aMem[pOp.p3];
							memAboutToChange(p, pOut);

							Debug.Assert(n == 0 || (pOp.p2 > 0 && pOp.p2 + n <= p.nMem + 1));
							Debug.Assert(pOp.p3 < pOp.p2 || pOp.p3 >= pOp.p2 + n);
							//pArg = aMem[pOp.p2];
							for (i = 0; i < n; i++)//, pArg++)
							{
								pArg = aMem[pOp.p2 + i];
								Debug.Assert(memIsValid(pArg));
								apVal[i] = pArg;
								Deephemeralize(pArg);
								sqlite3VdbeMemStoreType(pArg);
								REGISTER_TRACE(p, pOp.p2 + i, pArg);
							}

							Debug.Assert(pOp.p4type == P4_FUNCDEF || pOp.p4type == P4_VDBEFUNC);
							if (pOp.p4type == P4_FUNCDEF)
							{
								ctx.pFunc = pOp.p4.pFunc;
								ctx.pVdbeFunc = null;
							}
							else
							{
								ctx.pVdbeFunc = (VdbeFunc)pOp.p4.pVdbeFunc;
开发者ID:jcwmoore,项目名称:athena,代码行数:67,代码来源:vdbe_c.cs


示例10: nullifFunc

		/*
		** Implementation of the NULLIF(x,y) function.  The result is the first
		** argument if the arguments are different.  The result is NULL if the
		** arguments are equal to each other.
		*/

		private static void nullifFunc(
		sqlite3_context context,
		int NotUsed,
		sqlite3_value[] argv
		)
		{
			CollSeq pColl = sqlite3GetFuncCollSeq(context);
			UNUSED_PARAMETER(NotUsed);
			if (sqlite3MemCompare(argv[0], argv[1], pColl) != 0)
			{
				sqlite3_result_value(context, argv[0]);
			}
		}
开发者ID:broettge,项目名称:MatterControl,代码行数:19,代码来源:func_c.cs


示例11: 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.
*/

		private static void likeFunc(
		sqlite3_context context,
		int argc,
		sqlite3_value[] argv
		)
		{
			string zA, zB;
			u32 escape = 0;
			int nPat;
			sqlite3 db = sqlite3_context_db_handle(context);

			zB = sqlite3_value_text(argv[0]);
			zA = sqlite3_value_text(argv[1]);

			/* Limit the length of the LIKE or GLOB pattern to avoid problems
			** of deep recursion and N*N behavior in patternCompare().
			*/
			nPat = sqlite3_value_bytes(argv[0]);
			testcase(nPat == db.aLimit[SQLITE_LIMIT_LIKE_PATTERN_LENGTH]);
			testcase(nPat == db.aLimit[SQLITE_LIMIT_LIKE_PATTERN_LENGTH] + 1);
			if (nPat > db.aLimit[SQLITE_LIMIT_LIKE_PATTERN_LENGTH])
			{
				sqlite3_result_error(context, "LIKE or GLOB pattern too complex", -1);
				return;
			}
			//Debug.Assert( zB == sqlite3_value_text( argv[0] ) );  /* Encoding did not change */

			if (argc == 3)
			{
				/* The escape character string must consist of a single UTF-8 character.
				** Otherwise, return an error.
				*/
				string zEsc = sqlite3_value_text(argv[2]);
				if (zEsc == null)
					return;
				if (sqlite3Utf8CharLen(zEsc, -1) != 1)
				{
					sqlite3_result_error(context,
					"ESCAPE expression must be a single character", -1);
					return;
				}
				escape = sqlite3Utf8Read(zEsc, ref zEsc);
			}
			if (zA != null && zB != null)
			{
				compareInfo pInfo = (compareInfo)sqlite3_user_data(context);
#if SQLITE_TEST
#if !TCLSH
        sqlite3_like_count++;
#else
        sqlite3_like_count.iValue++;
#endif
#endif
				sqlite3_result_int(context, patternCompare(zB, zA, pInfo, escape) ? 1 : 0);
			}
		}
开发者ID:broettge,项目名称:MatterControl,代码行数:69,代码来源:func_c.cs


示例12: changes

		/*
		** Implementation of the changes() SQL function.
		**
		** IMP: R-62073-11209 The changes() SQL function is a wrapper
		** around the sqlite3_changes() C/C++ function and hence follows the same
		** rules for counting changes.
		*/

		private static void changes(
		sqlite3_context context,
		int NotUsed,
		sqlite3_value[] NotUsed2
		)
		{
			sqlite3 db = sqlite3_context_db_handle(context);
			UNUSED_PARAMETER2(NotUsed, NotUsed2);
			sqlite3_result_int(context, sqlite3_changes(db));
		}
开发者ID:broettge,项目名称:MatterControl,代码行数:18,代码来源:func_c.cs


示例13: lengthFunc

		/*
		** Implementation of the length() function
		*/

		private static void lengthFunc(
		sqlite3_context context,
		int argc,
		sqlite3_value[] argv
		)
		{
			int len;

			Debug.Assert(argc == 1);
			UNUSED_PARAMETER(argc);
			switch (sqlite3_value_type(argv[0]))
			{
				case SQLITE_BLOB:
				case SQLITE_INTEGER:
				case SQLITE_FLOAT:
					{
						sqlite3_result_int(context, sqlite3_value_bytes(argv[0]));
						break;
					}
				case SQLITE_TEXT:
					{
						byte[] z = sqlite3_value_blob(argv[0]);
						if (z == null)
							return;
						len = 0;
						int iz = 0;
						while (iz < z.Length && z[iz] != '\0')
						{
							len++;
							SQLITE_SKIP_UTF8(z, ref iz);
						}
						sqlite3_result_int(context, len);
						break;
					}
				default:
					{
						sqlite3_result_null(context);
						break;
					}
			}
		}
开发者ID:broettge,项目名称:MatterControl,代码行数:45,代码来源:func_c.cs


示例14: replaceFunc

		/*
		** The replace() function.  Three arguments are all strings: call
		** them A, B, and C. The result is also a string which is derived
		** from A by replacing every occurance of B with C.  The match
		** must be exact.  Collating sequences are not used.
		*/

		private static void replaceFunc(
		sqlite3_context context,
		int argc,
		sqlite3_value[] argv
		)
		{
			string zStr;        /* The input string A */
			string zPattern;    /* The pattern string B */
			string zRep;        /* The replacement string C */
			string zOut = null; /* The output */
			int nStr;           /* Size of zStr */
			int nOut;           /* Maximum size of zOut */
			//int loopLimit;    /* Last zStr[] that might match zPattern[] */
			int i, j = 0;       /* Loop counters */

			Debug.Assert(argc == 3);
			UNUSED_PARAMETER(argc);
			zStr = sqlite3_value_text(argv[0]);
			if (zStr == null)
				return;
			nStr = sqlite3_value_bytes(argv[0]);
			Debug.Assert(zStr == sqlite3_value_text(argv[0]));  /* No encoding change */
			zPattern = sqlite3_value_text(argv[1]);
			if (zPattern == null)
			{
				Debug.Assert(sqlite3_value_type(argv[1]) == SQLITE_NULL
					//|| sqlite3_context_db_handle( context ).mallocFailed != 0
				);
				return;
			}
			if (zPattern == "")
			{
				Debug.Assert(sqlite3_value_type(argv[1]) != SQLITE_NULL);
				sqlite3_result_value(context, argv[0]);
				return;
			}
			////nPattern = sqlite3_value_bytes( argv[1] );
			Debug.Assert(zPattern == sqlite3_value_text(argv[1]));  /* No encoding change */
			zRep = sqlite3_value_text(argv[2]);
			if (zRep == null)
				return;
			////nRep = sqlite3_value_bytes( argv[2] );
			Debug.Assert(zRep == sqlite3_value_text(argv[2]));
			nOut = nStr + 1;
			Debug.Assert(nOut < SQLITE_MAX_LENGTH);
			if (nOut <= sqlite3_context_db_handle(context).aLimit[SQLITE_LIMIT_LENGTH])
			{
				//int nPattern;       /* Size of zPattern */
				//int nRep;           /* Size of zRep */
				//zOut = contextMalloc(context, (i64)nOut);
				//if( zOut==0 ){
				//  return;
				//}
				//loopLimit = nStr - nPattern;
				//for(i=j=0; i<=loopLimit; i++){
				//  if( zStr[i]!=zPattern[0] || memcmp(&zStr[i], zPattern, nPattern) ){
				//    zOut[j++] = zStr[i];
				//  }else{
				//    u8 *zOld;
				// sqlite3 db = sqlite3_context_db_handle( context );
				//    nOut += nRep - nPattern;
				//testcase( nOut-1==db->aLimit[SQLITE_LIMIT_LENGTH] );
				//testcase( nOut-2==db->aLimit[SQLITE_LIMIT_LENGTH] );
				//if( nOut-1>db->aLimit[SQLITE_LIMIT_LENGTH] ){
				//      sqlite3_result_error_toobig(context);
				//      sqlite3_free(zOut);
				//      return;
				//    }
				//    zOld = zOut;
				//    zOut = sqlite3_realloc(zOut, (int)nOut);
				//    if( zOut==0 ){
				//      sqlite3_result_error_nomem(context);
				//      sqlite3_free(zOld);
				//      return;
				//    }
				//    memcpy(&zOut[j], zRep, nRep);
				//    j += nRep;
				//    i += nPattern-1;
				//  }
				//}
				//Debug.Assert( j+nStr-i+1==nOut );
				//memcpy(&zOut[j], zStr[i], nStr-i);
				//j += nStr - i;
				//Debug.Assert( j<=nOut );
				//zOut[j] = 0;
				try
				{
					zOut = zStr.Replace(zPattern, zRep);
					j = zOut.Length;
				}
				catch
				{
					j = 0;
//.........这里部分代码省略.........
开发者ID:broettge,项目名称:MatterControl,代码行数:101,代码来源:func_c.cs


示例15: zeroblobFunc

		/*
		** The zeroblob(N) function returns a zero-filled blob of size N bytes.
		*/

		private static void zeroblobFunc(
		sqlite3_context context,
		int argc,
		sqlite3_value[] argv
		)
		{
			i64 n;
			sqlite3 db = sqlite3_context_db_handle(context);
			Debug.Assert(argc == 1);
			UNUSED_PARAMETER(argc);
			n = sqlite3_value_int64(argv[0]);
			testcase(n == db.aLimit[SQLITE_LIMIT_LENGTH]);
			testcase(n == db.aLimit[SQLITE_LIMIT_LENGTH] + 1);
			if (n > db.aLimit[SQLITE_LIMIT_LENGTH])
			{
				sqlite3_result_error_toobig(context);
			}
			else
			{
				sqlite3_result_zeroblob(context, (int)n);/* IMP: R-00293-64994 */
			}
		}
开发者ID:broettge,项目名称:MatterControl,代码行数:26,代码来源:func_c.cs


示例16: randomFunc

		//#define ifnullFunc versionFunc   /* Substitute function - never called */

		/*
		** Implementation of random().  Return a random integer.
		*/

		private static void randomFunc(
		sqlite3_context context,
		int NotUsed,
		sqlite3_value[] NotUsed2
		)
		{
			sqlite_int64 r = 0;
			UNUSED_PARAMETER2(NotUsed, NotUsed2);
			sqlite3_randomness(sizeof(sqlite_int64), ref r);
			if (r < 0)
			{
				/* We need to prevent a random number of 0x8000000000000000
				** (or -9223372036854775808) since when you do abs() of that
				** number of you get the same value back again.  To do this
				** in a way that is testable, mask the sign bit off of negative
				** values, resulting in a positive value.  Then take the
				** 2s complement of that positive value.  The end result can
				** therefore be no less than -9223372036854775807.
				*/
				r = -(r ^ (((sqlite3_int64)1) << 63));
			}
			sqlite3_result_int64(context, r);
		}
开发者ID:broettge,项目名称:MatterControl,代码行数:29,代码来源:func_c.cs


示例17: randomBlob

		/*
		** Implementation of randomblob(N).  Return a random blob
		** that is N bytes long.
		*/

		private static void randomBlob(
		sqlite3_context context,
		int argc,
		sqlite3_value[] argv
		)
		{
			int n;
			char[] p;
			Debug.Assert(argc == 1);
			UNUSED_PARAMETER(argc);
			n = sqlite3_value_int(argv[0]);
			if (n < 1)
			{
				n = 1;
			}
			if (n > sqlite3_context_db_handle(context).aLimit[SQLITE_LIMIT_LENGTH])
			{
				sqlite3_result_error_toobig(context);
				p = null;
			}
			else
			{
				p = new char[n]; //contextMalloc( context, n );
			}
			if (p != null)
			{
				i64 _p = 0;
				for (int i = 0; i < n; i++)
				{
					sqlite3_randomness(sizeof(u8), ref _p);
					p[i] = (char)(_p & 0x7F);
				}
				sqlite3_result_blob(context, new string(p), n, null);//sqlite3_free );
			}
		}
开发者ID:broettge,项目名称:MatterControl,代码行数:40,代码来源:func_c.cs


示例18: trimFunc

		/*
		** Implementation of the TRIM(), LTRIM(), and RTRIM() functions.
		** The userdata is 0x1 for left trim, 0x2 for right trim, 0x3 for both.
		*/

		private static void trimFunc(
		sqlite3_context context,
		int argc,
		sqlite3_value[] argv
		)
		{
			string zIn;           /* Input string */
			string zCharSet;      /* Set of characters to trim */
			int nIn;              /* Number of bytes in input */
			int izIn = 0;         /* C# string pointer */
			int flags;            /* 1: trimleft  2: trimright  3: trim */
			int i;                /* Loop counter */
			int[] aLen = null;    /* Length of each character in zCharSet */
			byte[][] azChar = null; /* Individual characters in zCharSet */
			int nChar = 0;          /* Number of characters in zCharSet */
			byte[] zBytes = null;
			byte[] zBlob = null;

			if (sqlite3_value_type(argv[0]) == SQLITE_NULL)
			{
				return;
			}
			zIn = sqlite3_value_text(argv[0]);
			if (zIn == null)
				return;
			nIn = sqlite3_value_bytes(argv[0]);
			zBlob = sqlite3_value_blob(argv[0]);
			//Debug.Assert( zIn == sqlite3_value_text( argv[0] ) );
			if (argc == 1)
			{
				int[] lenOne = new int[] { 1 };
				byte[] azOne = new byte[] { (u8)' ' };//static unsigned char * const azOne[] = { (u8*)" " };
				nChar = 1;
				aLen = lenOne;
				azChar = new byte[1][];
				azChar[0] = azOne;
				zCharSet = null;
			}
			else if ((zCharSet = sqlite3_value_text(argv[1])) == null)
			{
				return;
			}
			else
			{
				if ((zBytes = sqlite3_value_blob(argv[1])) != null)
				{
					int iz = 0;
					for (nChar = 0; iz < zBytes.Length; nChar++)
					{
						SQLITE_SKIP_UTF8(zBytes, ref iz);
					}
					if (nChar > 0)
					{
						azChar = new byte[nChar][];//contextMalloc(context, ((i64)nChar)*(sizeof(char*)+1));
						if (azChar == null)
						{
							return;
						}
						aLen = new int[nChar];

						int iz0 = 0;
						int iz1 = 0;
						for (int ii = 0; ii < nChar; ii++)
						{
							SQLITE_SKIP_UTF8(zBytes, ref iz1);
							aLen[ii] = iz1 - iz0;
							azChar[ii] = new byte[aLen[ii]];
							Buffer.BlockCopy(zBytes, iz0, azChar[ii], 0, azChar[ii].Length);
							iz0 = iz1;
						}
					}
				}
			}
			if (nChar > 0)
			{
				flags = (int)sqlite3_user_data(context); // flags = SQLITE_PTR_TO_INT(sqlite3_user_data(context));
				if ((flags & 1) != 0)
				{
					while (nIn > 0)
					{
						int len = 0;
						for (i = 0; i < nChar; i++)
						{
							len = aLen[i];
							if (len <= nIn && memcmp(zBlob, izIn, azChar[i], len) == 0)
								break;
						}
						if (i >= nChar)
							break;
						izIn += len;
						nIn -= len;
					}
				}
				if ((flags & 2) != 0)
				{
//.........这里部分代码省略.........
开发者ID:broettge,项目名称:MatterControl,代码行数:101,代码来源:func_c.cs


示例19: last_insert_rowid

		/*
		** Implementation of the last_insert_rowid() SQL function.  The return
		** value is the same as the sqlite3_last_insert_rowid() API function.
		*/

		private static void last_insert_rowid(
		sqlite3_context context,
		int NotUsed,
		sqlite3_value[] NotUsed2
		)
		{
			sqlite3 db = sqlite3_context_db_handle(context);
			UNUSED_PARAMETER2(NotUsed, NotUsed2);
			/* IMP: R-51513-12026 The last_insert_rowid() SQL function is a
			** wrapper around the sqlite3_last_insert_rowid() C/C++ interface
			** function. */
			sqlite3_result_int64(context, sqlite3_last_insert_rowid(db));
		}
开发者ID:broettge,项目名称:MatterControl,代码行数:18,代码来源:func_c.cs


示例20: soundexFunc

		/* IMP: R-25361-16150 This function is omitted from SQLite by default. It
		** is only available if the SQLITE_SOUNDEX compile-time option is used
		** when SQLite is built.
		*/
#if SQLITE_SOUNDEX
/*
** Compute the soundex encoding of a word.
**
** IMP: R-59782-00072 The soundex(X) function returns a string that is the
** soundex encoding of the string X.
*/
static void soundexFunc(
sqlite3_context context,
int argc,
sqlite3_value[] argv
)
{
Debug.Assert(false); // TODO -- func_c
char zResult[8];
开发者ID:broettge,项目名称:MatterControl,代码行数:19,代码来源:func_c.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# sqlite3_file类代码示例发布时间:2022-05-24
下一篇:
C# sqlite3_backup类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap