//-------------------------------------------------------- // //-------------------------------------------------------- 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; }
//-------------------------------------------------------- // //-------------------------------------------------------- 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; }