本文整理汇总了C++中TString::GetCharIndex方法的典型用法代码示例。如果您正苦于以下问题:C++ TString::GetCharIndex方法的具体用法?C++ TString::GetCharIndex怎么用?C++ TString::GetCharIndex使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TString
的用法示例。
在下文中一共展示了TString::GetCharIndex方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ReadNextFloatArray
//--------------------------------------------------------
//
//--------------------------------------------------------
Bool TLString::ReadNextFloatArray(const TString& String,u32& CharIndex,float* pFloats,u32 FloatSize,Bool ReturnInvalidFloatZero)
{
// loop through parsing seperators and floats
u32 FloatIndex = 0;
while ( FloatIndex < FloatSize )
{
// step over whitespace
s32 NonWhitespaceIndex = String.GetCharIndexNonWhitespace( CharIndex );
// no more non-whitespace? no more floats then
if ( NonWhitespaceIndex == -1 )
return FALSE;
// move char past whitespace
CharIndex = (u32)NonWhitespaceIndex;
s32 NextComma = String.GetCharIndex(',', CharIndex);
s32 NextWhitespace = String.GetCharIndexWhitespace( CharIndex );
s32 NextSplit = String.GetLength();
if ( NextComma != -1 && NextComma < NextSplit )
NextSplit = NextComma;
if ( NextWhitespace != -1 && NextWhitespace < NextSplit )
NextSplit = NextWhitespace;
// split
TTempString Stringf;
Stringf.Append( String, CharIndex, NextSplit-CharIndex );
if ( !Stringf.GetFloat( pFloats[FloatIndex] ) )
{
// gr: this is a work around when processing floats but encounter invalid floats in strings... say 1.1e07 (invalid floats from outputter)
if ( ReturnInvalidFloatZero )
{
pFloats[FloatIndex] = 0.f;
}
else
{
TLDebug_Break("Failed to parse first float");
return FALSE;
}
}
// next float
FloatIndex++;
// move string along past split
CharIndex = NextSplit+1;
// out of string
if ( CharIndex >= String.GetLength() )
{
CharIndex = String.GetLength();
break;
}
}
return TRUE;
}
示例2: ReadNextInteger
//--------------------------------------------------------
//
//--------------------------------------------------------
Bool TLString::ReadNextInteger(const TString& String,u32& CharIndex,s32& Integer)
{
// step over whitespace
s32 NonWhitespaceIndex = String.GetCharIndexNonWhitespace( CharIndex );
// no more non-whitespace? no more data then
if ( NonWhitespaceIndex == -1 )
return FALSE;
// move char past whitespace
CharIndex = (u32)NonWhitespaceIndex;
s32 NextComma = String.GetCharIndex(',', CharIndex);
s32 NextWhitespace = String.GetCharIndexWhitespace( CharIndex );
s32 NextSplit = String.GetLength();
if ( NextComma != -1 && NextComma < NextSplit )
NextSplit = NextComma;
if ( NextWhitespace != -1 && NextWhitespace < NextSplit )
NextSplit = NextWhitespace;
// split
TTempString StringValue;
StringValue.Append( String, CharIndex, NextSplit-CharIndex );
if ( !StringValue.GetInteger( Integer ) )
{
TLDebug_Break("Failed to parse integer from string");
return FALSE;
}
// move string along past split
CharIndex = NextSplit+1;
// out of string
if ( CharIndex >= String.GetLength() )
CharIndex = String.GetLength();
return TRUE;
}