本文整理汇总了C#中CollSeq.xCmp方法的典型用法代码示例。如果您正苦于以下问题:C# CollSeq.xCmp方法的具体用法?C# CollSeq.xCmp怎么用?C# CollSeq.xCmp使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CollSeq
的用法示例。
在下文中一共展示了CollSeq.xCmp方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: sqlite3MemCompare
//.........这里部分代码省略.........
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
** compiled (this was not always the case).
*/
Debug.Assert(pColl == null || pColl.xCmp != null);
if (pColl != null)
{
if (pMem1.enc == pColl.enc)
{
/* The strings are already in the correct encoding. Call the
** comparison function directly */
return pColl.xCmp(pColl.pUser, pMem1.n, pMem1.z, pMem2.n, pMem2.z);
}
else
{
string v1, v2;
int n1, n2;
Mem c1 = null;
Mem c2 = null;
c1 = sqlite3Malloc(c1);// memset( &c1, 0, sizeof( c1 ) );
c2 = sqlite3Malloc(c2);// memset( &c2, 0, sizeof( c2 ) );
sqlite3VdbeMemShallowCopy(c1, pMem1, MEM_Ephem);
sqlite3VdbeMemShallowCopy(c2, pMem2, MEM_Ephem);
v1 = sqlite3ValueText((sqlite3_value)c1, pColl.enc);
n1 = v1 == null ? 0 : c1.n;
v2 = sqlite3ValueText((sqlite3_value)c2, pColl.enc);
n2 = v2 == null ? 0 : c2.n;
rc = pColl.xCmp(pColl.pUser, n1, v1, n2, v2);
sqlite3VdbeMemRelease(c1);
sqlite3VdbeMemRelease(c2);
return rc;
}
}
/* If a NULL pointer was passed as the collate function, fall through
** to the blob case and use memcmp(). */
}
/* Both values must be blobs. Compare using memcmp(). */
if ((pMem1.flags & MEM_Blob) != 0)
if (pMem1.zBLOB != null)
rc = memcmp(pMem1.zBLOB, pMem2.zBLOB, (pMem1.n > pMem2.n) ? pMem2.n : pMem1.n);
else
rc = memcmp(pMem1.z, pMem2.zBLOB, (pMem1.n > pMem2.n) ? pMem2.n : pMem1.n);
else
rc = memcmp(pMem1.z, pMem2.z, (pMem1.n > pMem2.n) ? pMem2.n : pMem1.n);
if (rc == 0)
{
rc = pMem1.n - pMem2.n;
}
return rc;
}