本文整理汇总了C#中StrAccum类的典型用法代码示例。如果您正苦于以下问题:C# StrAccum类的具体用法?C# StrAccum怎么用?C# StrAccum使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
StrAccum类属于命名空间,在下文中一共展示了StrAccum类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: sqlite3StrAccumReset
/*
** Reset an StrAccum string. Reclaim all malloced memory.
*/
static void sqlite3StrAccumReset( StrAccum p )
{
//if ( p.zText.ToString() != p.zBase.ToString() )
//{
// if ( p.useMalloc == 1 )
// {
// sqlite3DbFree( p.db, ref p.zText );
// }
// else
// {
// sqlite3_free( ref p.zText );
// }
//}
p.zText.Length = 0;
}
示例2: sqlite3StrAccumAppend
} /* End of function */
/*
** Append N bytes of text from z to the StrAccum object.
*/
static void sqlite3StrAccumAppend( StrAccum p, string z, int N )
{
Debug.Assert( z != null || N == 0 );
if ( p.tooBig )//|| p.mallocFailed != 0 )
{
testcase( p.tooBig );
//testcase( p.mallocFailed );
return;
}
if ( N < 0 )
{
N = sqlite3Strlen30( z );
}
if ( N == 0 || NEVER( z == null ) )
{
return;
}
//if( p->nChar+N >= p->nAlloc ){
// char *zNew;
// if( !p->useMalloc ){
// p->tooBig = 1;
// N = p->nAlloc - p->nChar - 1;
// if( N<=0 ){
// return;
// }
// }else{
// char *zOld = (p->zText==p->zBase ? 0 : p->zText);
// i64 szNew = p->nChar;
// szNew += N + 1;
// if( szNew > p->mxAlloc ){
// sqlite3StrAccumReset(p);
// p->tooBig = 1;
// return;
// }else{
// p->nAlloc = (int)szNew;
// }
// if( p->useMalloc==1 ){
// zNew = sqlite3DbRealloc(p->db, zOld, p->nAlloc);
// }else{
// zNew = sqlite3_realloc(zOld, p->nAlloc);
// }
// if( zNew ){
// if( zOld==0 ) memcpy(zNew, p->zText, p->nChar);
// p->zText = zNew;
// }else{
// p->mallocFailed = 1;
// sqlite3StrAccumReset(p);
// return;
// }
// }
//}
//memcpy(&p->zText[p->nChar], z, N);
p.zText.Append( z.Substring( 0, N <= z.Length ? N : z.Length ) );
//p.nChar += N;
}
示例3: sqlite3StrAccumFinish
/*
** Finish off a string by making sure it is zero-terminated.
** Return a pointer to the resulting string. Return a NULL
** pointer if any kind of error was encountered.
*/
static string sqlite3StrAccumFinish( StrAccum p )
{
//if ( p->zText )
//{
// p->zText[p->nChar] = 0;
// if ( p->useMalloc && p->zText == p->zBase )
// {
// if ( p->useMalloc == 1 )
// {
// p->zText = sqlite3DbMallocRaw( p->db, p->nChar + 1 );
// }
// else
// {
// p->zText = sqlite3_malloc( p->nChar + 1 );
// }
// if ( p->zText )
// {
// memcpy( p->zText, p->zBase, p->nChar + 1 );
// }
// else
// {
// p->mallocFailed = 1;
// }
// }
//}
return p.zText.ToString();
}
示例4: sqlite3StrAccumAppend
} /* End of function */
/*
** Append N bytes of text from z to the StrAccum object.
*/
static void sqlite3StrAccumAppend( StrAccum p, string z, int N )
{
Debug.Assert( z != null || N == 0 );
if ( p.tooBig != 0 )//|| p.mallocFailed != 0 )
{
testcase( p.tooBig );
//testcase( p.mallocFailed );
return;
}
if ( N < 0 )
{
N = sqlite3Strlen30( z );
}
if ( N == 0 || NEVER( z == null ) )
{
return;
}
//if ( p.nChar + N >= p.nAlloc )
//{
// char* zNew;
// if ( !p.useMalloc )
// {
// p.tooBig = 1;
// N = p.nAlloc - p.nChar - 1;
// if ( N <= 0 )
// {
// return;
// }
// }
// else
// {
// i64 szNew = p.nChar;
// szNew += N + 1;
// if ( szNew > p.mxAlloc )
// {
// sqlite3StrAccumReset( p );
// p.tooBig = 1;
// return;
// }
// else
// {
// p.nAlloc = (int)szNew;
// }
// zNew = sqlite3DbMalloc( p.nAlloc );
// if ( zNew )
// {
// memcpy( zNew, p.zText, p.nChar );
// sqlite3StrAccumReset( p );
// p.zText = zNew;
// }
// else
// {
// p.mallocFailed = 1;
// sqlite3StrAccumReset( p );
// return;
// }
// }
//}
//memcpy( &p.zText[p.nChar], z, N );
p.zText.Append( z.Substring( 0, N <= z.Length ? N : z.Length ) );
p.nChar += N;
}
示例5: sqlite3GenerateConstraintChecks
//.........这里部分代码省略.........
sqlite3VdbeAddOp2( v, OP_SCopy, regRowid, regIdx + i );
sqlite3VdbeAddOp3( v, OP_MakeRecord, regIdx, pIdx.nColumn + 1, aRegIdx[iCur] );
sqlite3VdbeChangeP4( v, -1, sqlite3IndexAffinityStr( v, pIdx ), P4_TRANSIENT );
sqlite3ExprCacheAffinityChange( pParse, regIdx, pIdx.nColumn + 1 );
/* Find out what action to take in case there is an indexing conflict */
onError = pIdx.onError;
if ( onError == OE_None )
{
sqlite3ReleaseTempRange( pParse, regIdx, pIdx.nColumn + 1 );
continue; /* pIdx is not a UNIQUE index */
}
if ( overrideError != OE_Default )
{
onError = overrideError;
}
else if ( onError == OE_Default )
{
onError = OE_Abort;
}
if ( seenReplace )
{
if ( onError == OE_Ignore )
onError = OE_Replace;
else if ( onError == OE_Fail )
onError = OE_Abort;
}
/* Check to see if the new index entry will be unique */
regR = sqlite3GetTempReg( pParse );
sqlite3VdbeAddOp2( v, OP_SCopy, regOldRowid, regR );
j3 = sqlite3VdbeAddOp4( v, OP_IsUnique, baseCur + iCur + 1, 0,
regR, regIdx,//regR, SQLITE_INT_TO_PTR(regIdx),
P4_INT32 );
sqlite3ReleaseTempRange( pParse, regIdx, pIdx.nColumn + 1 );
/* Generate code that executes if the new index entry is not unique */
Debug.Assert( onError == OE_Rollback || onError == OE_Abort || onError == OE_Fail
|| onError == OE_Ignore || onError == OE_Replace );
switch ( onError )
{
case OE_Rollback:
case OE_Abort:
case OE_Fail:
{
int j;
StrAccum errMsg = new StrAccum( 200 );
string zSep;
string zErr;
sqlite3StrAccumInit( errMsg, null, 0, 200 );
errMsg.db = pParse.db;
zSep = pIdx.nColumn > 1 ? "columns " : "column ";
for ( j = 0; j < pIdx.nColumn; j++ )
{
string zCol = pTab.aCol[pIdx.aiColumn[j]].zName;
sqlite3StrAccumAppend( errMsg, zSep, -1 );
zSep = ", ";
sqlite3StrAccumAppend( errMsg, zCol, -1 );
}
sqlite3StrAccumAppend( errMsg,
pIdx.nColumn > 1 ? " are not unique" : " is not unique", -1 );
zErr = sqlite3StrAccumFinish( errMsg );
sqlite3HaltConstraint( pParse, onError, zErr, 0 );
sqlite3DbFree( errMsg.db, ref zErr );
break;
}
case OE_Ignore:
{
Debug.Assert( !seenReplace );
sqlite3VdbeAddOp2( v, OP_Goto, 0, ignoreDest );
break;
}
default:
{
Trigger pTrigger = null;
Debug.Assert( onError == OE_Replace );
sqlite3MultiWrite( pParse );
if ( ( pParse.db.flags & SQLITE_RecTriggers ) != 0 )
{
int iDummy;
pTrigger = sqlite3TriggersExist( pParse, pTab, TK_DELETE, null, out iDummy );
}
sqlite3GenerateRowDelete(
pParse, pTab, baseCur, regR, 0, pTrigger, OE_Replace
);
seenReplace = true;
break;
}
}
sqlite3VdbeJumpHere( v, j3 );
sqlite3ReleaseTempReg( pParse, regR );
}
//if ( pbMayReplace )
{
pbMayReplace = seenReplace ? 1 : 0;
}
}
示例6: appendSpace
/*
** Append N space characters to the given string buffer.
*/
static void appendSpace( StrAccum pAccum, int N )
{
//static const char zSpaces[] = " ";
//while( N>=zSpaces.Length-1 ){
// sqlite3StrAccumAppend(pAccum, zSpaces, zSpaces.Length-1);
// N -= zSpaces.Length-1;
//}
//if( N>0 ){
// sqlite3StrAccumAppend(pAccum, zSpaces, N);
//}
pAccum.zText.AppendFormat( "{0," + N + "}", "" );
}
示例7: sqlite3StrAccumInit
/*
** Initialize a string accumulator
*/
static void sqlite3StrAccumInit( StrAccum p, StringBuilder zBase, int n, int mx )
{
p.zText = p.zBase = zBase;
p.db = null;
p.nChar = 0;
p.nAlloc = n;
p.mxAlloc = mx;
p.useMalloc = 1;
p.tooBig = 0;
//p.mallocFailed = 0;
}
示例8: sqlite3GenerateConstraintChecks
//.........这里部分代码省略.........
{
int idx = pIdx.aiColumn[i];
if ( idx == pTab.iPKey )
{
sqlite3VdbeAddOp2( v, OP_SCopy, regRowid, regIdx + i );
}
else
{
sqlite3VdbeAddOp2( v, OP_SCopy, regData + idx, regIdx + i );
}
}
sqlite3VdbeAddOp2( v, OP_SCopy, regRowid, regIdx + i );
sqlite3VdbeAddOp3( v, OP_MakeRecord, regIdx, pIdx.nColumn + 1, aRegIdx[iCur] );
sqlite3IndexAffinityStr( v, pIdx );
sqlite3ExprCacheAffinityChange( pParse, regIdx, pIdx.nColumn + 1 );
/* Find out what action to take in case there is an indexing conflict */
onError = pIdx.onError;
if ( onError == OE_None )
{
sqlite3ReleaseTempRange( pParse, regIdx, pIdx.nColumn + 1 );
continue; /* pIdx is not a UNIQUE index */
}
if ( overrideError != OE_Default )
{
onError = overrideError;
}
else if ( onError == OE_Default )
{
onError = OE_Abort;
}
if ( seenReplace )
{
if ( onError == OE_Ignore ) onError = OE_Replace;
else if ( onError == OE_Fail ) onError = OE_Abort;
}
/* Check to see if the new index entry will be unique */
regR = sqlite3GetTempReg( pParse );
sqlite3VdbeAddOp2( v, OP_SCopy, regRowid - ( hasTwoRowids ? 1 : 0 ), regR );
j3 = sqlite3VdbeAddOp4( v, OP_IsUnique, baseCur + iCur + 1, 0,
regR, regIdx,//regR, SQLITE_INT_TO_PTR(regIdx),
P4_INT32 );
sqlite3ReleaseTempRange( pParse, regIdx, pIdx.nColumn + 1 );
/* Generate code that executes if the new index entry is not unique */
Debug.Assert( onError == OE_Rollback || onError == OE_Abort || onError == OE_Fail
|| onError == OE_Ignore || onError == OE_Replace );
switch ( onError )
{
case OE_Rollback:
case OE_Abort:
case OE_Fail:
{
int j;
StrAccum errMsg = new StrAccum();
string zSep;
string zErr;
sqlite3StrAccumInit( errMsg, new StringBuilder( 200 ), 0, 200 );
errMsg.db = pParse.db;
zSep = pIdx.nColumn > 1 ? "columns " : "column ";
for ( j = 0 ; j < pIdx.nColumn ; j++ )
{
string zCol = pTab.aCol[pIdx.aiColumn[j]].zName;
sqlite3StrAccumAppend( errMsg, zSep, -1 );
zSep = ", ";
sqlite3StrAccumAppend( errMsg, zCol, -1 );
}
sqlite3StrAccumAppend( errMsg,
pIdx.nColumn > 1 ? " are not unique" : " is not unique", -1 );
zErr = sqlite3StrAccumFinish( errMsg );
sqlite3VdbeAddOp4( v, OP_Halt, SQLITE_CONSTRAINT, onError, 0, zErr, 0 );
//sqlite3DbFree( errMsg.db, zErr );
break;
}
case OE_Ignore:
{
Debug.Assert( !seenReplace );
sqlite3VdbeAddOp2( v, OP_Goto, 0, ignoreDest );
break;
}
default:
{
Debug.Assert( onError == OE_Replace );
sqlite3GenerateRowDelete( pParse, pTab, baseCur, regR, 0 );
seenReplace = true;
break;
}
}
sqlite3VdbeJumpHere( v, j3 );
sqlite3ReleaseTempReg( pParse, regR );
}
//if ( pbMayReplace )
{
pbMayReplace = seenReplace ? 1 : 0;
}
}
示例9: sqlite3VdbeExpandSql
/*
** This function returns a pointer to a nul-terminated string in memory
** obtained from sqlite3DbMalloc(). If sqlite3.vdbeExecCnt is 1, then the
** string contains a copy of zRawSql but with host parameters expanded to
** their current bindings. Or, if sqlite3.vdbeExecCnt is greater than 1,
** then the returned string holds a copy of zRawSql with "-- " prepended
** to each line of text.
**
** The calling function is responsible for making sure the memory returned
** is eventually freed.
**
** ALGORITHM: Scan the input string looking for host parameters in any of
** these forms: ?, ?N, $A, @A, :A. Take care to avoid text within
** string literals, quoted identifier names, and comments. For text forms,
** the host parameter index is found by scanning the perpared
** statement for the corresponding OP_Variable opcode. Once the host
** parameter index is known, locate the value in p->aVar[]. Then render
** the value as a literal in place of the host parameter name.
*/
static string sqlite3VdbeExpandSql(
Vdbe p, /* The prepared statement being evaluated */
string zRawSql /* Raw text of the SQL statement */
)
{
sqlite3 db; /* The database connection */
int idx = 0; /* Index of a host parameter */
int nextIndex = 1; /* Index of next ? host parameter */
int n; /* Length of a token prefix */
int nToken = 0; /* Length of the parameter token */
int i; /* Loop counter */
Mem pVar; /* Value of a host parameter */
StrAccum _out = new StrAccum(1000); /* Accumulate the _output here */
StringBuilder zBase = new StringBuilder(100); /* Initial working space */
int izRawSql = 0;
db = p.db;
sqlite3StrAccumInit(_out, null, 100,
db.aLimit[SQLITE_LIMIT_LENGTH]);
_out.db = db;
if (db.vdbeExecCnt > 1)
{
while (izRawSql < zRawSql.Length)
{
//string zStart = zRawSql;
while (zRawSql[izRawSql++] != '\n' && izRawSql < zRawSql.Length)
;
sqlite3StrAccumAppend(_out, "-- ", 3);
sqlite3StrAccumAppend(_out, zRawSql, (int)izRawSql);//zRawSql - zStart );
}
}
else
{
while (izRawSql < zRawSql.Length)
{
n = findNextHostParameter(zRawSql, izRawSql, ref nToken);
Debug.Assert(n > 0);
sqlite3StrAccumAppend(_out, zRawSql.Substring(izRawSql, n), n);
izRawSql += n;
Debug.Assert(izRawSql < zRawSql.Length || nToken == 0);
if (nToken == 0)
break;
if (zRawSql[izRawSql] == '?')
{
if (nToken > 1)
{
Debug.Assert(sqlite3Isdigit(zRawSql[izRawSql + 1]));
sqlite3GetInt32(zRawSql, izRawSql + 1, ref idx);
}
else
{
idx = nextIndex;
}
}
else
{
Debug.Assert(zRawSql[izRawSql] == ':' || zRawSql[izRawSql] == '$' || zRawSql[izRawSql] == '@');
testcase(zRawSql[izRawSql] == ':');
testcase(zRawSql[izRawSql] == '$');
testcase(zRawSql[izRawSql] == '@');
idx = sqlite3VdbeParameterIndex(p, zRawSql.Substring(izRawSql, nToken), nToken);
Debug.Assert(idx > 0);
}
izRawSql += nToken;
nextIndex = idx + 1;
Debug.Assert(idx > 0 && idx <= p.nVar);
pVar = p.aVar[idx - 1];
if ((pVar.flags & MEM_Null) != 0)
{
sqlite3StrAccumAppend(_out, "NULL", 4);
}
else if ((pVar.flags & MEM_Int) != 0)
{
sqlite3XPrintf(_out, "%lld", pVar.u.i);
}
else if ((pVar.flags & MEM_Real) != 0)
{
sqlite3XPrintf(_out, "%!.15g", pVar.r);
}
else if ((pVar.flags & MEM_Str) != 0)
{
//.........这里部分代码省略.........
示例10: sqlite3_snprintf
static public string sqlite3_snprintf( int n, ref string zBuf, string zFormat, params va_list[] ap )
{
string z;
StringBuilder zBase = new StringBuilder( SQLITE_PRINT_BUF_SIZE );
//va_list ap;
StrAccum acc = new StrAccum();
if ( n <= 0 )
{
return zBuf;
}
sqlite3StrAccumInit( acc, zBase, n, 0 );
acc.useMalloc = 0;
va_start( ap, zFormat );
sqlite3VXPrintf( acc, 0, zFormat, ap );
va_end( ap );
z = sqlite3StrAccumFinish( acc );
return ( zBuf = z );
}
示例11: sqlite3DebugPrintf
/*
** A version of printf() that understands %lld. Used for debugging.
** The printf() built into some versions of windows does not understand %lld
** and segfaults if you give it a long long int.
*/
static void sqlite3DebugPrintf( string zFormat, params va_list[] ap )
{
//va_list ap;
StrAccum acc = new StrAccum();
StringBuilder zBuf = new StringBuilder( SQLITE_PRINT_BUF_SIZE );
sqlite3StrAccumInit( acc, zBuf, zBuf.Capacity, 0 );
acc.useMalloc = 0;
va_start( ap, zFormat );
sqlite3VXPrintf( acc, 0, zFormat, ap );
va_end( ap );
sqlite3StrAccumFinish( acc );
Console.Write( zBuf.ToString() );
//fflush(stdout);
}
示例12: sqlite3_vmprintf
/*
** Print into memory obtained from sqlite3Malloc(). Omit the internal
** %-conversion extensions.
*/
static string sqlite3_vmprintf( string zFormat, params va_list[] ap )
{
string z;
StringBuilder zBase = new StringBuilder( SQLITE_PRINT_BUF_SIZE );
StrAccum acc = new StrAccum();
#if !SQLITE_OMIT_AUTOINIT
if ( sqlite3_initialize() != 0 ) return "";
#endif
sqlite3StrAccumInit( acc, zBase, zBase.Length, SQLITE_PRINT_BUF_SIZE );//zBase).Length;
sqlite3VXPrintf( acc, 0, zFormat, ap );
z = sqlite3StrAccumFinish( acc );
return z;
}
示例13: sqlite3VMPrintf
/*
** Print into memory obtained from sqliteMalloc(). Use the internal
** %-conversion extensions.
*/
static string sqlite3VMPrintf( sqlite3 db, string zFormat, params va_list[] ap )
{
if ( zFormat == null ) return null;
if ( ap.Length == 0 ) return zFormat;
string z;
StringBuilder zBase = new StringBuilder( SQLITE_PRINT_BUF_SIZE );
StrAccum acc = new StrAccum();
Debug.Assert( db != null );
sqlite3StrAccumInit( acc, zBase, zBase.Capacity, //zBase).Length;
db.aLimit[SQLITE_LIMIT_LENGTH] );
acc.db = db;
sqlite3VXPrintf( acc, 1, zFormat, ap );
z = sqlite3StrAccumFinish( acc );
// if ( acc.mallocFailed != 0 )
// {
////// db.mallocFailed = 1;
// }
return z;
}
示例14: sqlite3StrAccumInit
/*
** Initialize a string accumulator
*/
static void sqlite3StrAccumInit( StrAccum p, StringBuilder zBase, int n, int mx )
{
//p.zBase.Length = 0;
//if ( p.zBase.Capacity < n )
// p.zBase.Capacity = n;
p.zText.Length = 0;
if ( p.zText.Capacity < n )
p.zText.Capacity = n;
p.db = null;
//p.nChar = 0;
//p.nAlloc = n;
p.mxAlloc = mx;
//p.useMalloc = 1;
//p.tooBig = 0;
//p.mallocFailed = 0;
}
示例15: sqlite3XPrintf
/*
** variable-argument wrapper around sqlite3VXPrintf().
*/
static void sqlite3XPrintf( StrAccum p, string zFormat, params object[] ap )
{
//va_list ap;
lock ( lock_va_list )
{
va_start( ap, zFormat );
sqlite3VXPrintf( p, 1, zFormat, ap );
va_end( ref ap );
}
}