本文整理汇总了C#中sqlite3_value类的典型用法代码示例。如果您正苦于以下问题:C# sqlite3_value类的具体用法?C# sqlite3_value怎么用?C# sqlite3_value使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
sqlite3_value类属于命名空间,在下文中一共展示了sqlite3_value类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: sqlite3ColumnDefault
/*
** 2001 September 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 are called by the parser
** to handle UPDATE statements.
**
** $Id: update.c,v 1.207 2009/08/08 18:01:08 drh Exp $
**
*************************************************************************
** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart
** C#-SQLite is an independent reimplementation of the SQLite software library
**
** $Header$
*************************************************************************
*/
//#include "sqliteInt.h"
#if !SQLITE_OMIT_VIRTUALTABLE
/* Forward declaration */
//static void updateVirtualTable(
//Parse pParse, /* The parsing context */
//SrcList pSrc, /* The virtual table to be modified */
//Table pTab, /* The virtual table */
//ExprList pChanges, /* The columns to change in the UPDATE statement */
//Expr pRowidExpr, /* Expression used to recompute the rowid */
//int aXRef, /* Mapping from columns of pTab to entries in pChanges */
//Expr pWhere /* WHERE clause of the UPDATE statement */
//);
#endif // * SQLITE_OMIT_VIRTUALTABLE */
/*
** The most recently coded instruction was an OP_Column to retrieve the
** i-th column of table pTab. This routine sets the P4 parameter of the
** OP_Column to the default value, if any.
**
** The default value of a column is specified by a DEFAULT clause in the
** column definition. This was either supplied by the user when the table
** was created, or added later to the table definition by an ALTER TABLE
** command. If the latter, then the row-records in the table btree on disk
** may not contain a value for the column and the default value, taken
** from the P4 parameter of the OP_Column instruction, is returned instead.
** If the former, then all row-records are guaranteed to include a value
** for the column and the P4 value is not required.
**
** Column definitions created by an ALTER TABLE command may only have
** literal default values specified: a number, null or a string. (If a more
** complicated default expression value was provided, it is evaluated
** when the ALTER TABLE is executed and one of the literal values written
** into the sqlite_master table.)
**
** Therefore, the P4 parameter is only required if the default value for
** the column is a literal number, string or null. The sqlite3ValueFromExpr()
** function is capable of transforming these types of expressions into
** sqlite3_value objects.
**
** If parameter iReg is not negative, code an OP_RealAffinity instruction
** on register iReg. This is used when an equivalent integer value is
** stored in place of an 8-byte floating point value in order to save
** space.
*/
static void sqlite3ColumnDefault( Vdbe v, Table pTab, int i, int iReg )
{
Debug.Assert( pTab != null );
if ( null == pTab.pSelect )
{
sqlite3_value pValue = new sqlite3_value();
int enc = ENC( sqlite3VdbeDb( v ) );
Column pCol = pTab.aCol[i];
#if SQLITE_DEBUG
VdbeComment( v, "%s.%s", pTab.zName, pCol.zName );
#endif
Debug.Assert( i < pTab.nCol );
sqlite3ValueFromExpr( sqlite3VdbeDb( v ), pCol.pDflt, enc,
pCol.affinity, ref pValue );
if ( pValue != null )
{
sqlite3VdbeChangeP4( v, -1, pValue, P4_MEM );
}
#if !SQLITE_OMIT_FLOATING_POINT
if ( iReg >= 0 && pTab.aCol[i].affinity == SQLITE_AFF_REAL )
{
sqlite3VdbeAddOp1( v, OP_RealAffinity, iReg );
}
#endif
}
}
开发者ID:mbahar94,项目名称:fracture,代码行数:94,代码来源:update_c.cs
示例2: 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
示例3: 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
示例4: 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:plainprogrammer,项目名称:csharp-sqlite,代码行数:12,代码来源:test_autoext_c.cs
示例5: 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
示例6: sqlite3_value_numeric_type
/*
** Try to convert the type of a function argument or a result column
** into a numeric representation. Use either INTEGER or REAL whichever
** is appropriate. But only do the conversion if it is possible without
** loss of information and return the revised type of the argument.
*/
static int sqlite3_value_numeric_type(sqlite3_value pVal)
{
Mem pMem = (Mem)pVal;
if (pMem.type == SQLITE_TEXT)
{
applyNumericAffinity(pMem);
sqlite3VdbeMemStoreType(pMem);
}
return pMem.type;
}
开发者ID:jcwmoore,项目名称:athena,代码行数:16,代码来源:vdbe_c.cs
示例7: 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
示例8: typeofFunc
/*
** Return the type of the argument.
*/
private static void typeofFunc(
sqlite3_context context,
int NotUsed,
sqlite3_value[] argv
)
{
string z = "";
UNUSED_PARAMETER(NotUsed);
switch (sqlite3_value_type(argv[0]))
{
case SQLITE_INTEGER:
z = "integer";
break;
case SQLITE_TEXT:
z = "text";
break;
case SQLITE_FLOAT:
z = "real";
break;
case SQLITE_BLOB:
z = "blob";
break;
default:
z = "null";
break;
}
sqlite3_result_text(context, z, -1, SQLITE_STATIC);
}
开发者ID:broettge,项目名称:MatterControl,代码行数:36,代码来源:func_c.cs
示例9: 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
示例10: sqlite3ValueText
/* This function is only available internally, it is not part of the
** external API. It works in a similar way to sqlite3_value_text(),
** except the data returned is in the encoding specified by the second
** parameter, which must be one of SQLITE_UTF16BE, SQLITE_UTF16LE or
** SQLITE_UTF8.
**
** (2006-02-16:) The enc value can be or-ed with SQLITE_UTF16_ALIGNED.
** If that is the case, then the result must be aligned on an even byte
** boundary.
*/
private static string sqlite3ValueText(sqlite3_value pVal, int enc)
{
if (pVal == null)
return null;
Debug.Assert(pVal.db == null || sqlite3_mutex_held(pVal.db.mutex));
Debug.Assert((enc & 3) == (enc & ~SQLITE_UTF16_ALIGNED));
Debug.Assert((pVal.flags & MEM_RowSet) == 0);
if ((pVal.flags & MEM_Null) != 0)
{
return null;
}
Debug.Assert((MEM_Blob >> 3) == MEM_Str);
pVal.flags |= (u16)((pVal.flags & MEM_Blob) >> 3);
if ((pVal.flags & MEM_Zero) != 0)
sqlite3VdbeMemExpandBlob(pVal); // expandBlob(pVal);
if ((pVal.flags & MEM_Str) != 0)
{
if (sqlite3VdbeChangeEncoding(pVal, enc & ~SQLITE_UTF16_ALIGNED) != SQLITE_OK)
{
return null; // Encoding Error
}
if ((enc & SQLITE_UTF16_ALIGNED) != 0 && 1 == (1 & (pVal.z[0]))) //1==(1&SQLITE_PTR_TO_INT(pVal.z))
{
Debug.Assert((pVal.flags & (MEM_Ephem | MEM_Static)) != 0);
if (sqlite3VdbeMemMakeWriteable(pVal) != SQLITE_OK)
{
return null;
}
}
sqlite3VdbeMemNulTerminate(pVal); /* IMP: R-59893-45467 */
}
else
{
Debug.Assert((pVal.flags & MEM_Blob) == 0);
sqlite3VdbeMemStringify(pVal, enc);
// assert( 0==(1&SQLITE_PTR_TO_INT(pVal->z)) );
}
Debug.Assert(pVal.enc == (enc & ~SQLITE_UTF16_ALIGNED) || pVal.db == null
//|| pVal.db.mallocFailed != 0
);
if (pVal.enc == (enc & ~SQLITE_UTF16_ALIGNED))
{
return pVal.z;
}
else
{
return null;
}
}
开发者ID:broettge,项目名称:MatterControl,代码行数:62,代码来源:vdbemem_c.cs
示例11: absFunc
/*
** Implementation of the abs() function.
**
** IMP: R-23979-26855 The abs(X) function returns the absolute value of
** the numeric argument X.
*/
private 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:broettge,项目名称:MatterControl,代码行数:56,代码来源:func_c.cs
示例12: 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
示例13: sqlite3ValueSetStr
/*
** Change the string value of an sqlite3_value object
*/
private static void sqlite3ValueSetStr(
sqlite3_value v, /* Value to be set */
int n, /* Length of string z */
string z, /* Text of the new string */
u8 enc, /* Encoding to use */
dxDel xDel//)(void*) /* Destructor for the string */
)
{
if (v != null)
sqlite3VdbeMemSetStr(v, z, n, enc, xDel);
}
开发者ID:broettge,项目名称:MatterControl,代码行数:15,代码来源:vdbemem_c.cs
示例14: ifnullFunc
/*
** The COALESCE() and IFNULL() functions used to be implemented as shown
** here. But now they are implemented as VDBE code so that unused arguments
** do not have to be computed. This legacy implementation is retained as
** comment.
*/
/*
** Implementation of the IFNULL(), NVL(), and COALESCE() functions.
** All three do the same thing. They return the first non-NULL
** argument.
*/
static void ifnullFunc(
sqlite3_context context,
int argc,
sqlite3_value[] argv
)
{
int i;
for ( i = 0 ; i < argc ; i++ )
{
if ( SQLITE_NULL != sqlite3_value_type( argv[i] ) )
{
sqlite3_result_value( context, argv[i] );
break;
}
}
}
开发者ID:broettge,项目名称:MatterControl,代码行数:27,代码来源:func_c.cs
示例15: 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
示例16: lowerFunc
private static void lowerFunc(
sqlite3_context context,
int argc,
sqlite3_value[] argv
)
{
string z1;
string z2;
int i, n;
UNUSED_PARAMETER(argc);
z2 = sqlite3_value_text(argv[0]);
n = sqlite3_value_bytes(argv[0]);
/* Verify that the call to _bytes() does not invalidate the _text() pointer */
//Debug.Assert( z2 == sqlite3_value_text( argv[0] ) );
if (z2 != null)
{
//z1 = contextMalloc(context, ((i64)n)+1);
//if ( z1 )
//{
// memcpy( z1, z2, n + 1 );
// for ( i = 0 ; z1[i] ; i++ )
// {
// z1[i] = (char)sqlite3Tolower( z1[i] );
// }
sqlite3_result_text(context, z2.Length == 0 ? "" : z2.Substring(0, n).ToLower(), -1, null);//sqlite3_free );
//}
}
}
开发者ID:broettge,项目名称:MatterControl,代码行数:28,代码来源:func_c.cs
示例17: roundFunc
/*
** Implementation of the round() function
*/
#if !SQLITE_OMIT_FLOATING_POINT
private static void roundFunc(
sqlite3_context context,
int argc,
sqlite3_value[] argv
)
{
int n = 0;
double r;
string zBuf = "";
Debug.Assert(argc == 1 || argc == 2);
if (argc == 2)
{
if (SQLITE_NULL == sqlite3_value_type(argv[1]))
return;
n = sqlite3_value_int(argv[1]);
if (n > 30)
n = 30;
if (n < 0)
n = 0;
}
if (sqlite3_value_type(argv[0]) == SQLITE_NULL)
return;
r = sqlite3_value_double(argv[0]);
/* If Y==0 and X will fit in a 64-bit int,
** handle the rounding directly,
** otherwise use printf.
*/
if (n == 0 && r >= 0 && r < LARGEST_INT64 - 1)
{
r = (double)((sqlite_int64)(r + 0.5));
}
else if (n == 0 && r < 0 && (-r) < LARGEST_INT64 - 1)
{
r = -(double)((sqlite_int64)((-r) + 0.5));
}
else
{
zBuf = sqlite3_mprintf("%.*f", n, r);
if (zBuf == null)
{
sqlite3_result_error_nomem(context);
return;
}
sqlite3AtoF(zBuf, ref r, sqlite3Strlen30(zBuf), SQLITE_UTF8);
//sqlite3_free( ref zBuf );
}
sqlite3_result_double(context, r);
}
开发者ID:broettge,项目名称:MatterControl,代码行数:53,代码来源:func_c.cs
示例18: substrFunc
/*
** Implementation of the substr() function.
**
** substr(x,p1,p2) returns p2 characters of x[] beginning with p1.
** p1 is 1-indexed. So substr(x,1,1) returns the first character
** of x. If x is text, then we actually count UTF-8 characters.
** If x is a blob, then we count bytes.
**
** If p1 is negative, then we begin abs(p1) from the end of x[].
**
** If p2 is negative, return the p2 characters preceeding p1.
*/
private static void substrFunc(
sqlite3_context context,
int argc,
sqlite3_value[] argv
)
{
string z = "";
byte[] zBLOB = null;
string z2;
int len;
int p0type;
int p1, p2;
int negP2 = 0;
Debug.Assert(argc == 3 || argc == 2);
if (sqlite3_value_type(argv[1]) == SQLITE_NULL
|| (argc == 3 && sqlite3_value_type(argv[2]) == SQLITE_NULL)
)
{
return;
}
p0type = sqlite3_value_type(argv[0]);
p1 = sqlite3_value_int(argv[1]);
if (p0type == SQLITE_BLOB)
{
len = sqlite3_value_bytes(argv[0]);
zBLOB = argv[0].zBLOB;
if (zBLOB == null)
return;
Debug.Assert(len == zBLOB.Length);
}
else
{
z = sqlite3_value_text(argv[0]);
if (String.IsNullOrEmpty(z))
return;
len = 0;
if (p1 < 0)
{
len = z.Length;
//for ( z2 = z ; z2 != "" ; len++ )
//{
// SQLITE_SKIP_UTF8( ref z2 );
//}
}
}
if (argc == 3)
{
p2 = sqlite3_value_int(argv[2]);
if (p2 < 0)
{
p2 = -p2;
negP2 = 1;
}
}
else
{
p2 = (sqlite3_context_db_handle(context)).aLimit[SQLITE_LIMIT_LENGTH];
}
if (p1 < 0)
{
p1 += len;
if (p1 < 0)
{
p2 += p1;
if (p2 < 0)
p2 = 0;
p1 = 0;
}
}
else if (p1 > 0)
{
p1--;
}
else if (p2 > 0)
{
p2--;
}
if (negP2 != 0)
{
p1 -= p2;
if (p1 < 0)
{
p2 += p1;
p1 = 0;
}
}
//.........这里部分代码省略.........
开发者ID:broettge,项目名称:MatterControl,代码行数:101,代码来源:func_c.cs
示例19: sqlite3ValueApplyAffinity
/*
** Exported version of applyAffinity(). This one works on sqlite3_value*,
** not the internal Mem type.
*/
static void sqlite3ValueApplyAffinity(
sqlite3_value pVal,
char affinity,
int enc
)
{
applyAffinity((Mem)pVal, affinity, enc);
}
开发者ID:jcwmoore,项目名称:athena,代码行数:12,代码来源:vdbe_c.cs
示例20: sqlite3ValueBytes
/*
** Return the number of bytes in the sqlite3_value object assuming
** that it uses the encoding "enc"
*/
private static int sqlite3ValueBytes(sqlite3_value pVal, int enc)
{
Mem p = (Mem)pVal;
if ((p.flags & MEM_Blob) != 0 || sqlite3ValueText(pVal, enc) != null)
{
if ((p.flags & MEM_Zero) != 0)
{
return p.n + p.u.nZero;
}
else
{
return p.z == null ? p.zBLOB.Length : p.n;
}
}
return 0;
}
开发者ID:broettge,项目名称:MatterControl,代码行数:21,代码来源:vdbemem_c.cs
注:本文中的sqlite3_value类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论