本文整理汇总了C++中cString::GetLength方法的典型用法代码示例。如果您正苦于以下问题:C++ cString::GetLength方法的具体用法?C++ cString::GetLength怎么用?C++ cString::GetLength使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cString
的用法示例。
在下文中一共展示了cString::GetLength方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CalculateHash
// ****************************************************************************
unsigned long cHashedString::CalculateHash(const cString & strIdent)
{
if(strIdent.IsEmpty())
{
return 0;
}
// largest prime smaller than 65536
unsigned long lBASE = 65521L;
// lMAX is the largest n such that // 255n(n+1)/2 + (n+1)(BASE-1) <= 2^32-1
unsigned int lMAX = 5522;
unsigned int s1 = 0;
unsigned int s2 = 0;
int i = 0;
unsigned int length = strIdent.GetLength();
while(length > 0)
{
int k = length < lMAX ? length : lMAX;
length -= k;
while(--k >= 0)
{
s1 += (unsigned int)(tolower(strIdent[i++]) & 0XFF);
s2 += s1;
}
s1 %= lBASE;
s2 %= lBASE;
}
return ((s2 << 16) | s1);
}
示例2: CalculateChecksum
// *******************************************************************************************************************
uint64 cHashedString::CalculateChecksum(const cString & str)
{
if (str.IsEmpty())
{
return 0;
}
#if 0 // use simple checksum. Keeping this for reference purpose
// largest prime smaller than 65536
UINT64 MOD_ADLER = 65521L;
// MAX is the largest n such that 255n(n+1)/2 + (n+1)(BASE-1) <= 2^32-1
unsigned int MAX_LENGTH = 5522;
unsigned int s1 = 1;
unsigned int s2 = 0;
unsigned int length = str.GetLength();
while(length > 0)
{
int k = length < MAX_LENGTH ? length : MAX_LENGTH;
length -= k;
for(int index = 0; index < k; index++)
{
s1 = (s1 + (str[index] & 0xFF)) % MOD_ADLER;
s2 = (s2 + s1) % MOD_ADLER;
}
}
return ((s2 << 16) | s1);
#else
uint64 hash = 0;
UINT length = str.GetLength();
for (UINT i = 0; i < length; i++)
{
hash = str[i] + (hash << 6) + (hash << 16) - hash;
}
return hash & 0x7fffffff;
#endif
}
示例3: VGetWidth
// *******************************************************************************************************************
float cSentence::VGetWidth(const cString & strText) const
{
float fWidth = 0.0f;
int istrLength = strText.GetLength();
IMyFont::stVertexData vertexData;
for (int i=0; i<istrLength; i++)
{
int val = (int)strText[i];
vertexData = m_pFont->VGetCharVertexData(val);
fWidth += vertexData.ch.XAdvance;
}
return m_fScale * fWidth;
}
示例4: Tokenize
// *******************************************************************************************************************
void cString::Tokenize(const cString & delimiters, std::vector<cString> & parts) const
{
if (IsEmpty() || delimiters.GetLength() == 0)
{
return;
}
int iStartIndex = 0;
tOptional<int> nextIndex;
while (iStartIndex < GetLength())
{
nextIndex = FindFirstOfAny(delimiters, iStartIndex);
if (nextIndex.IsInvalid())
{
nextIndex = GetLength();
}
if (iStartIndex != nextIndex.GetValue())
{
parts.push_back(GetSubString(iStartIndex, nextIndex.GetValue() - 1));
}
iStartIndex = nextIndex.GetValue() + 1;
}
}