本文整理汇总了C#中CollSeq类的典型用法代码示例。如果您正苦于以下问题:C# CollSeq类的具体用法?C# CollSeq怎么用?C# CollSeq使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
CollSeq类属于命名空间,在下文中一共展示了CollSeq类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: synthCollSeq
/*
** This routine is called if the collation factory fails to deliver a
** collation function in the best encoding but there may be other versions
** of this collation function (for other text encodings) available. Use one
** of these instead if they exist. Avoid a UTF-8 <. UTF-16 conversion if
** possible.
*/
static int synthCollSeq( sqlite3 db, CollSeq pColl )
{
CollSeq pColl2;
string z = pColl.zName;
int i;
byte[] aEnc = { SQLITE_UTF16BE, SQLITE_UTF16LE, SQLITE_UTF8 };
for ( i = 0; i < 3; i++ )
{
pColl2 = sqlite3FindCollSeq( db, aEnc[i], z, 0 );
if ( pColl2.xCmp != null )
{
pColl = pColl2.Copy(); //memcpy(pColl, pColl2, sizeof(CollSeq));
pColl.xDel = null; /* Do not copy the destructor */
return SQLITE_OK;
}
}
return SQLITE_ERROR;
}
示例2: sqlite3MemCompare
/*
** Compare the values contained by the two memory cells, returning
** negative, zero or positive if pMem1 is less than, equal to, or greater
** than pMem2. Sorting order is NULL's first, followed by numbers (integers
** and reals) sorted numerically, followed by text ordered by the collating
** sequence pColl and finally blob's ordered by memcmp().
**
** Two NULL values are considered equal by this function.
*/
private static int sqlite3MemCompare(Mem pMem1, Mem pMem2, CollSeq pColl)
{
int rc;
int f1, f2;
int combined_flags;
f1 = pMem1.flags;
f2 = pMem2.flags;
combined_flags = f1 | f2;
Debug.Assert((combined_flags & MEM_RowSet) == 0);
/* If one value is NULL, it is less than the other. If both values
** are NULL, return 0.
*/
if ((combined_flags & MEM_Null) != 0)
{
return (f2 & MEM_Null) - (f1 & MEM_Null);
}
/* If one value is a number and the other is not, the number is less.
** If both are numbers, compare as reals if one is a real, or as integers
** if both values are integers.
*/
if ((combined_flags & (MEM_Int | MEM_Real)) != 0)
{
if ((f1 & (MEM_Int | MEM_Real)) == 0)
{
return 1;
}
if ((f2 & (MEM_Int | MEM_Real)) == 0)
{
return -1;
}
if ((f1 & f2 & MEM_Int) == 0)
{
double r1, r2;
if ((f1 & MEM_Real) == 0)
{
r1 = (double)pMem1.u.i;
}
else
{
r1 = pMem1.r;
}
if ((f2 & MEM_Real) == 0)
{
r2 = (double)pMem2.u.i;
}
else
{
r2 = pMem2.r;
}
if (r1 < r2)
return -1;
if (r1 > r2)
return 1;
return 0;
}
else
{
Debug.Assert((f1 & MEM_Int) != 0);
Debug.Assert((f2 & MEM_Int) != 0);
if (pMem1.u.i < pMem2.u.i)
return -1;
if (pMem1.u.i > pMem2.u.i)
return 1;
return 0;
}
}
/* If one value is a string and the other is a blob, the string is less.
** If both are strings, compare using the collating functions.
*/
if ((combined_flags & MEM_Str) != 0)
{
if ((f1 & MEM_Str) == 0)
{
return 1;
}
if ((f2 & MEM_Str) == 0)
{
return -1;
}
Debug.Assert(pMem1.enc == pMem2.enc);
Debug.Assert(pMem1.enc == SQLITE_UTF8 ||
pMem1.enc == SQLITE_UTF16LE || pMem1.enc == SQLITE_UTF16BE);
/* The collation sequence must be defined at this point, even if
** the user deletes the collation sequence after the vdbe program is
//.........这里部分代码省略.........
示例3: sqlite3ExprSetColl
/*
** Set the explicit collating sequence for an expression to the
** collating sequence supplied in the second argument.
*/
static Expr sqlite3ExprSetColl( Expr pExpr, CollSeq pColl )
{
if ( pExpr != null && pColl != null )
{
pExpr.pColl = pColl;
pExpr.flags |= EP_ExpCollate;
}
return pExpr;
}
示例4: sqlite3FindCollSeq
/*
** Parameter zName points to a UTF-8 encoded string nName bytes long.
** Return the CollSeq* pointer for the collation sequence named zName
** for the encoding 'enc' from the database 'db'.
**
** If the entry specified is not found and 'create' is true, then create a
** new entry. Otherwise return NULL.
**
** A separate function sqlite3LocateCollSeq() is a wrapper around
** this routine. sqlite3LocateCollSeq() invokes the collation factory
** if necessary and generates an error message if the collating sequence
** cannot be found.
**
** See also: sqlite3LocateCollSeq(), sqlite3GetCollSeq()
*/
static CollSeq sqlite3FindCollSeq(
sqlite3 db,
u8 enc,
string zName,
u8 create
)
{
CollSeq[] pColl;
if ( zName != null )
{
pColl = findCollSeqEntry( db, zName, create );
}
else
{
pColl = new CollSeq[enc];
pColl[enc - 1] = db.pDfltColl;
}
Debug.Assert( SQLITE_UTF8 == 1 && SQLITE_UTF16LE == 2 && SQLITE_UTF16BE == 3 );
Debug.Assert( enc >= SQLITE_UTF8 && enc <= SQLITE_UTF16BE );
if ( pColl != null )
{
enc -= 1; // if (pColl != null) pColl += enc - 1;
return pColl[enc];
}
else
return null;
}
示例5: findCollSeqEntry
/*
** Locate and return an entry from the db.aCollSeq hash table. If the entry
** specified by zName and nName is not found and parameter 'create' is
** true, then create a new entry. Otherwise return NULL.
**
** Each pointer stored in the sqlite3.aCollSeq hash table contains an
** array of three CollSeq structures. The first is the collation sequence
** prefferred for UTF-8, the second UTF-16le, and the third UTF-16be.
**
** Stored immediately after the three collation sequences is a copy of
** the collation sequence name. A pointer to this string is stored in
** each collation sequence structure.
*/
static CollSeq[] findCollSeqEntry(
sqlite3 db, /* Database connection */
string zName, /* Name of the collating sequence */
int create /* Create a new entry if true */
)
{
CollSeq[] pColl;
int nName = sqlite3Strlen30( zName );
pColl = sqlite3HashFind( db.aCollSeq, zName, nName, (CollSeq[])null );
if ( ( null == pColl ) && create != 0 )
{
pColl = new CollSeq[3]; //sqlite3DbMallocZero(db, 3*sizeof(*pColl) + nName + 1 );
if ( pColl != null )
{
CollSeq pDel = null;
pColl[0] = new CollSeq();
pColl[0].zName = zName;
pColl[0].enc = SQLITE_UTF8;
pColl[1] = new CollSeq();
pColl[1].zName = zName;
pColl[1].enc = SQLITE_UTF16LE;
pColl[2] = new CollSeq();
pColl[2].zName = zName;
pColl[2].enc = SQLITE_UTF16BE;
//memcpy(pColl[0].zName, zName, nName);
//pColl[0].zName[nName] = 0;
CollSeq[] pDelArray = sqlite3HashInsert( ref db.aCollSeq, pColl[0].zName, nName, pColl );
if ( pDelArray != null )
pDel = pDelArray[0];
/* If a malloc() failure occurred in sqlite3HashInsert(), it will
** return the pColl pointer to be deleted (because it wasn't added
** to the hash table).
*/
Debug.Assert( pDel == null || pDel == pColl[0] );
if ( pDel != null )
{
//// db.mallocFailed = 1;
pDel = null; //was sqlite3DbFree(db,ref pDel);
pColl = null;
}
}
}
return pColl;
}
示例6: sqlite3CheckCollSeq
/*
** This routine is called on a collation sequence before it is used to
** check that it is defined. An undefined collation sequence exists when
** a database is loaded that contains references to collation sequences
** that have not been defined by sqlite3_create_collation() etc.
**
** If required, this routine calls the 'collation needed' callback to
** request a definition of the collating sequence. If this doesn't work,
** an equivalent collating sequence that uses a text encoding different
** from the main database is substituted, if one is available.
*/
static int sqlite3CheckCollSeq( Parse pParse, CollSeq pColl )
{
if ( pColl != null )
{
string zName = pColl.zName;
sqlite3 db = pParse.db;
CollSeq p = sqlite3GetCollSeq( db, ENC( db ), pColl, zName );
if ( null == p )
{
sqlite3ErrorMsg( pParse, "no such collation sequence: %s", zName );
pParse.nErr++;
return SQLITE_ERROR;
}
//
//Debug.Assert(p == pColl);
if ( p != pColl ) // Had to lookup appropriate sequence
{
pColl.enc = p.enc;
pColl.pUser = p.pUser;
pColl.type = p.type;
pColl.xCmp = p.xCmp;
pColl.xDel = p.xDel;
}
}
return SQLITE_OK;
}
示例7: sqlite3GetCollSeq
/*
** This function is responsible for invoking the collation factory callback
** or substituting a collation sequence of a different encoding when the
** requested collation sequence is not available in the desired encoding.
**
** If it is not NULL, then pColl must point to the database native encoding
** collation sequence with name zName, length nName.
**
** The return value is either the collation sequence to be used in database
** db for collation type name zName, length nName, or NULL, if no collation
** sequence can be found.
**
** See also: sqlite3LocateCollSeq(), sqlite3FindCollSeq()
*/
static CollSeq sqlite3GetCollSeq(
sqlite3 db, /* The database connection */
u8 enc, /* The desired encoding for the collating sequence */
CollSeq pColl, /* Collating sequence with native encoding, or NULL */
string zName /* Collating sequence name */
)
{
CollSeq p;
p = pColl;
if ( p == null )
{
p = sqlite3FindCollSeq( db, enc, zName, 0 );
}
if ( p == null || p.xCmp == null )
{
/* No collation sequence of this type for this encoding is registered.
** Call the collation factory to see if it can supply us with one.
*/
callCollNeeded( db, enc, zName );
p = sqlite3FindCollSeq( db, enc, zName, 0 );
}
if ( p != null && p.xCmp == null && synthCollSeq( db, p ) != 0 )
{
p = null;
}
Debug.Assert( p == null || p.xCmp != null );
return p;
}
示例8: sqlite3VdbeAddOp4
//CollSeq
static int sqlite3VdbeAddOp4( Vdbe p, int op, int p1, int p2, int p3, CollSeq pP4, int p4type )
{
union_p4 _p4 = new union_p4();
_p4.pColl = pP4;
int addr = sqlite3VdbeAddOp3( p, op, p1, p2, p3 );
sqlite3VdbeChangeP4( p, addr, _p4, p4type );
return addr;
}
示例9: sqlite3VdbeChangeP4
/*
** Change the value of the P4 operand for a specific instruction.
** This routine is useful when a large program is loaded from a
** static array using sqlite3VdbeAddOpList but we want to make a
** few minor changes to the program.
**
** If n>=0 then the P4 operand is dynamic, meaning that a copy of
** the string is made into memory obtained from sqlite3Malloc().
** A value of n==0 means copy bytes of zP4 up to and including the
** first null byte. If n>0 then copy n+1 bytes of zP4.
**
** If n==P4_KEYINFO it means that zP4 is a pointer to a KeyInfo structure.
** A copy is made of the KeyInfo structure into memory obtained from
** sqlite3Malloc, to be freed when the Vdbe is finalized.
** n==P4_KEYINFO_HANDOFF indicates that zP4 points to a KeyInfo structure
** stored in memory that the caller has obtained from sqlite3Malloc. The
** caller should not free the allocation, it will be freed when the Vdbe is
** finalized.
**
** Other values of n (P4_STATIC, P4_COLLSEQ etc.) indicate that zP4 points
** to a string or structure that is guaranteed to exist for the lifetime of
** the Vdbe. In these cases we can just copy the pointer.
**
** If addr<0 then change P4 on the most recently inserted instruction.
*/
//P4_COLLSEQ
static void sqlite3VdbeChangeP4( Vdbe p, int addr, CollSeq pColl, int n )
{
union_p4 _p4 = new union_p4();
_p4.pColl = pColl;
sqlite3VdbeChangeP4( p, addr, _p4, n );
}