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


C# sqlite3_context类代码示例

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


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


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