本文整理汇总了C++中TString::GetCharAt方法的典型用法代码示例。如果您正苦于以下问题:C++ TString::GetCharAt方法的具体用法?C++ TString::GetCharAt怎么用?C++ TString::GetCharAt使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TString
的用法示例。
在下文中一共展示了TString::GetCharAt方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ReadNextLetter
//--------------------------------------------------------
//
//--------------------------------------------------------
Bool TLString::ReadNextLetter(const TString& String,u32& CharIndex, TChar& Char)
{
// step over whitespace
s32 NonWhitespaceIndex = String.GetCharIndexNonWhitespace( CharIndex );
if ( NonWhitespaceIndex == -1 )
return FALSE;
// move char past whitespace
CharIndex = (u32)NonWhitespaceIndex;
const TChar& NextChar = String.GetCharAt(CharIndex);
// is next char a letter?
if ( TLString::IsCharLetter( NextChar ) )
{
Char = NextChar;
// move string past this letter for next thing
CharIndex++;
return TRUE;
}
else
{
// not a char, could be a number or summink
return FALSE;
}
}
示例2: ImportBinaryData
//.........这里部分代码省略.........
case TLBinary_TypeRef(TColour32):
{
Type4<s32> Colours;
if ( !TLString::ReadNextInteger( DataString, CharIndex, Colours.x ) ) return SyncFalse;
if ( !TLString::ReadNextInteger( DataString, CharIndex, Colours.y ) ) return SyncFalse;
if ( !TLString::ReadNextInteger( DataString, CharIndex, Colours.z ) ) return SyncFalse;
if ( !TLString::ReadNextInteger( DataString, CharIndex, Colours.w ) ) return SyncFalse;
// check range
// gr: use TLDebug_CheckInRange() ?
if ( Colours.x > 255 || Colours.x < 0 ||
Colours.y > 255 || Colours.y < 0 ||
Colours.z > 255 || Colours.z < 0 ||
Colours.w > 255 || Colours.w < 0 )
{
if ( !TLDebug_Break( TString("Colour32 type has components out of range (0..255); %d,%d,%d,%d", Colours.x, Colours.y, Colours.z, Colours.w ) ) )
return SyncFalse;
}
TColour32 Colour( Colours.x, Colours.y, Colours.z, Colours.w );
BinaryData.Write( Colour );
return SyncTrue;
}
case TLBinary_TypeRef(TColour64):
{
Type4<s32> Colours;
if ( !TLString::ReadNextInteger( DataString, CharIndex, Colours.x ) ) return SyncFalse;
if ( !TLString::ReadNextInteger( DataString, CharIndex, Colours.y ) ) return SyncFalse;
if ( !TLString::ReadNextInteger( DataString, CharIndex, Colours.z ) ) return SyncFalse;
if ( !TLString::ReadNextInteger( DataString, CharIndex, Colours.w ) ) return SyncFalse;
// check range
// gr: use TLDebug_CheckInRange() ?
if ( Colours.x > 65535 || Colours.x < 0 ||
Colours.y > 65535 || Colours.y < 0 ||
Colours.z > 65535 || Colours.z < 0 ||
Colours.w > 65535 || Colours.w < 0 )
{
if ( !TLDebug_Break( TString("Colour64 type has components out of range (0..65535); %d,%d,%d,%d", Colours.x, Colours.y, Colours.z, Colours.w ) ) )
return SyncFalse;
}
TColour64 Colour( Colours.x, Colours.y, Colours.z, Colours.w );
BinaryData.Write( Colour );
return SyncTrue;
}
case TLBinary_TypeRef(u8):
return ImportBinaryDataIntegerInRange<u8>( BinaryData, DataString );
case TLBinary_TypeRef(s8):
return ImportBinaryDataIntegerInRange<s8>( BinaryData, DataString );
case TLBinary_TypeRef(u16):
return ImportBinaryDataIntegerInRange<u16>( BinaryData, DataString );
case TLBinary_TypeRef(s16):
return ImportBinaryDataIntegerInRange<s16>( BinaryData, DataString );
case TLBinary_TypeRef(u32):
return ImportBinaryDataIntegerInRange<u32>( BinaryData, DataString );
case TLBinary_TypeRef(s32):
return ImportBinaryDataIntegerInRange<s32>( BinaryData, DataString );
case TLBinary_TypeRef(Bool):
{
// read first char, we can work out true/false/0/1 from that
if ( DataString.GetLength() == 0 )
return SyncFalse;
const TChar& BoolChar = DataString.GetCharAt(0);
if ( BoolChar == 't' || BoolChar == 'T' || BoolChar == '1' )
{
BinaryData.Write( (Bool)TRUE );
return SyncTrue;
}
else if ( BoolChar == 'f' || BoolChar == 'F' || BoolChar == '0' )
{
BinaryData.Write( (Bool)FALSE );
return SyncTrue;
}
else
{
TLDebug_Break("Bool data is not True,False,0 or 1");
return SyncFalse;
}
}
default:
break;
};
TDebugString Debug_String;
Debug_String << "Unsupported/todo data type " << DataType << ". Data string: [" << DataString << "]";
TLDebug_Break( Debug_String );
return SyncFalse;
}