17 m_pAllocator = GetAllocator();
23 m_pAllocator = allocator ==
TNULL ? GetAllocator() : allocator;
28 TString16::m_pAllocator = src.m_pAllocator;
29 TString16::m_iExcessLen = src.m_iExcessLen;
30 TString16::m_iStrLen = src.m_iStrLen;
31 TString16::m_pBuffer = src.m_pBuffer;
38 m_pAllocator = allocator ==
TNULL ? GetAllocator() : allocator;
45 m_pAllocator = allocator ==
TNULL ? GetAllocator() : allocator;
52 m_pAllocator = allocator ==
TNULL ? GetAllocator() : allocator;
58 if ( src != m_pBuffer )
61 TASSERT( srcLen <= 0xFFFFFF,
"Too big string" );
63 if ( srcLen < size || size == -1 )
71 m_pBuffer[ size ] = 0;
79 const TWCHAR* foundAt = wcschr( &m_pBuffer[ pos ], character );
80 if ( foundAt ==
TNULL )
return -1;
82 return (
TINT)( foundAt - m_pBuffer );
90 if ( foundAt ==
TNULL )
return -1;
92 return (
TINT)( foundAt - m_pBuffer );
100 TASSERT( a_iLength >= 0,
"Length can't be less than 0" );
101 TASSERT( a_iLength <= 0xFFFFFF,
"Too big string" );
103 if ( a_iLength != currentLength )
105 if ( a_iLength == 0 )
107 if ( freeMemory ) m_pAllocator->Free( m_pBuffer );
109 m_pBuffer = NullWString;
116 TINT newExcessLen = ( currentLength - a_iLength ) + m_iExcessLen;
118 if ( newExcessLen < 0 || newExcessLen > 0xFF )
120 if ( currentLength != 0 && freeMemory )
122 m_pAllocator->Free( m_pBuffer );
125 m_pBuffer = (
TWCHAR*)m_pAllocator->Malloc( ( a_iLength + 1 ) *
sizeof(
TWCHAR ) );
132 m_iExcessLen = newExcessLen;
137 m_iStrLen = a_iLength;
140 if ( freeMemory ) m_pBuffer[ 0 ] = L
'\0';
150 va_start( args, a_pcFormat );
152 TINT iResult = _vsnwprintf( buffer,
sizeof( buffer ), a_pcFormat, args );
153 TASSERT( iResult != -1,
"PS2/GC/X360 do not correctly support _vsnprintf, this code will cause memory to be clobbered on those platforms! Increase the size of the destination string to avoid this problem" );
154 buffer2.
Copy( buffer, -1 );
163 TINT iResult = _vsnwprintf( buffer,
sizeof( buffer ), a_pcFormat, a_vargs );
164 TASSERT( iResult != -1,
"PS2/GC/X360 do not correctly support _vsnprintf, this code will cause memory to be clobbered on those platforms! Increase the size of the destination string to avoid this problem" );
172 m_pBuffer = a_cString;
180 m_iStrLen = a_iLength;
198 for ( ; pos > -1; pos-- )
200 if ( a_findChar == m_pBuffer[ pos ] )
216 TWCHAR* oldBuffer = m_pBuffer;
224 m_pBuffer[ length ] = 0;
226 if ( allocated &&
Length() != 0 )
228 m_pAllocator->Free( oldBuffer );
234 if (
Length() != 0 ) m_pAllocator->Free( m_pBuffer );
240 TASSERT( a_iIndex >= 0 && a_iIndex <= m_iStrLen );
241 if (
IsIndexValid( a_iIndex ) ) {
return &m_pBuffer[ a_iIndex ]; }
247 TASSERT( a_iIndex >= 0 && a_iIndex <= m_iStrLen );
248 if (
IsIndexValid( a_iIndex ) ) {
return &m_pBuffer[ a_iIndex ]; }
256 if ( ( len < size ) || ( size == -1 ) )
261 TINT oldLength = m_iStrLen;
262 TWCHAR* oldString = m_pBuffer;
276 m_pBuffer[ m_iStrLen ] = 0;
278 if ( allocated && oldLength != 0 )
280 m_pAllocator->Free( oldString );
288 TASSERT( a_pcString !=
TNULL,
"TCString::CompareNoCase - Passed string cannot be TNULL" );
294 return wcsncmp(
GetString(), a_pcString, param_2 );
303 bVar4 = bVar1 < *a_pcString;
305 if ( bVar1 != *a_pcString )
break;
306 if ( bVar1 == 0 )
return 0;
309 bVar4 = bVar1 < a_pcString[ 1 ];
311 if ( bVar1 != a_pcString[ 1 ] )
break;
312 if ( bVar1 == 0 )
return 0;
324 TINT iOldLength = m_iStrLen;
325 TWCHAR* pOldString = m_pBuffer;
333 m_pBuffer[ iCopySize ] = 0;
336 if ( bAllocated && iOldLength != 0 )
337 m_pAllocator->Free( pOldString );
345 TASSERT( a_pcString !=
TNULL,
"TWString::CompareNoCase - Passed string cannot be TNULL" );
351 return _wcsicmp(
GetString(), a_pcString );
356 return _wcsnicmp(
GetString(), a_pcString, param_2 );
365 else if (
Length() <= a_iFirst )
371 if ( a_iCount < 0 ||
Length() < a_iFirst + a_iCount )
373 a_iCount =
Length() - a_iFirst;
378 strResult[ a_iCount ] =
'\0';
385 return Mid( a_iFrom,
Length() - a_iFrom );
390 if ( m_iStrLen != 0 )
393 TWCHAR* endStr = m_pBuffer + m_iStrLen;
397 TWCHAR currentC = *iter++;
398 if ( !iswlower( currentC ) )
return TFALSE;
399 }
while ( iter < endStr );
407 if ( m_iStrLen != 0 )
410 TWCHAR* endStr = m_pBuffer + m_iStrLen;
414 TWCHAR currentC = *iter++;
415 if ( !iswupper( currentC ) )
return TFALSE;
416 }
while ( iter < endStr );
#define TOSHI_NAMESPACE_START
#define TOSHI_NAMESPACE_END
TFORCEINLINE const T & Min(const T &a, const T &b)
TString16 & Concat(const TString16 &str, TINT size=-1)
void Copy(const TString16 &src, TINT size=-1)
TString16 Mid(TINT a_iFirst, TINT a_iCount) const
TBOOL AllocBuffer(TINT size, TBOOL freeMemory=true)
TString16 Right(TINT a_iFrom) const
TINT Find(TWCHAR character, TINT pos=0) const
TString16 & Reserve(TINT size)
TBOOL IsAllLowerCase() const
TUINT16 ExcessLength() const
TWCHAR * GetStringUnsafe(TINT a_iIndex=0)
TINT CompareNoCase(const TWCHAR *a_wszString, TINT a_iLength=-1) const
void ForceSetData(TWCHAR *a_cString, TINT a_ilength)
TString16 & VFormat(const TWCHAR *a_pcFormat, va_list a_vargs)
const TWCHAR * GetString(TINT index=0) const
TINT Compare(const TWCHAR *a_wszString, TINT a_iLength=-1) const
static TString16 Format(const TWCHAR *a_pcFormat,...)
void Truncate(TINT length)
TBOOL IsIndexValid(TINT index) const
TBOOL IsAllUpperCase() const
TINT FindReverse(TWCHAR a_findChar, TINT pos=-1) const
static TWCHAR * String16Copy(TWCHAR *dst, const TWCHAR *src, TSIZE size=-1)
static TSIZE String16Length(const TWCHAR *str)
static void * MemCopy(void *dst, const void *src, TSIZE size)