OpenBarnyard
 
Loading...
Searching...
No Matches
T2String16 Class Reference

#include <T2String16.h>

Static Public Member Functions

static TWCHARCreateCopy (const TWCHAR *a_wszString, TSIZE a_uiSize=-1)
 
static TINT Format (TWCHAR *a_pcString, TINT size, const TWCHAR *a_pcFormat,...)
 
static TINT Format (TWCHAR *a_pcString, const TWCHAR *a_pcFormat,...)
 
static TINT FormatV (TWCHAR *a_pcString, TINT size, const TWCHAR *a_pcFormat, va_list args)
 
static TINT FormatV (TWCHAR *a_pcString, const TWCHAR *a_pcFormat, va_list args)
 
static TINT Compare (const TWCHAR *str1, const TWCHAR *str2, TSIZE size=-1)
 
static TINT CompareNoCase (const TWCHAR *str1, const TWCHAR *str2, TSIZE size=-1)
 
static TWCHARCopy (TWCHAR *dst, const TWCHAR *src, TSIZE size=-1)
 
static TWCHARCopySafe (TWCHAR *dst, const TWCHAR *src, TSIZE size)
 
static TWCHARConcat (TWCHAR *dst, const TWCHAR *src, TSIZE size=-1)
 
static TWCHARFindChar (TWCHAR *str, TWCHAR character)
 
static const TWCHARFindChar (const TWCHAR *str, TWCHAR character)
 
static TWCHARFindString (TWCHAR *str, const TWCHAR *substr)
 
static const TWCHARFindString (const TWCHAR *str, const TWCHAR *substr)
 
static TSIZE Length (const TWCHAR *str)
 
static TBOOL IsLowerCase (const TWCHAR *str)
 
static TBOOL IsUpperCase (const TWCHAR *str)
 
static void ToLowerCase (TWCHAR *str)
 
static void ToUpperCase (TWCHAR *str)
 
static void IntToString (TINT value, TWCHAR *dst, TINT unused, TINT radix)
 
static void IntToString (TINT value, TWCHAR *dst, TINT radix)
 
static TINT StringToInt (const TWCHAR *src)
 
static TFLOAT StringToFloat (const TWCHAR *src)
 
static TWCHARSkipSpaces (TWCHAR *str)
 
static const TWCHARSkipSpaces (const TWCHAR *str)
 
static T2AllocatorGetDefaultAllocatorCB ()
 

Static Public Attributes

static constexpr TSIZE SCRATCH_MEM_SIZE = 512
 
static T2Allocatorsm_pDefaultAllocatorCB = GetDefaultAllocatorCB()
 
static TWCHAR ms_aScratchMem [SCRATCH_MEM_SIZE]
 

Detailed Description

Definition at line 9 of file T2String16.h.

Member Function Documentation

◆ Compare()

TINT T2String16::Compare ( const TWCHAR * str1,
const TWCHAR * str2,
TSIZE size = -1 )
static

Definition at line 52 of file T2String16.cpp.

53{
54 if ( size != -1 )
55 return wcsncmp( str1, str2, size );
56
57 return wcscmp( str1, str2 );
58}

◆ CompareNoCase()

TINT T2String16::CompareNoCase ( const TWCHAR * str1,
const TWCHAR * str2,
TSIZE size = -1 )
static

Definition at line 60 of file T2String16.cpp.

61{
62 if ( size != -1 )
63 {
64 return _wcsnicmp( str1, str2, size );
65 }
66
67 return _wcsicmp( str1, str2 );
68}

◆ Concat()

TWCHAR * T2String16::Concat ( TWCHAR * dst,
const TWCHAR * src,
TSIZE size = -1 )
static

Definition at line 87 of file T2String16.cpp.

88{
89 if ( size != -1 )
90 return wcsncat( dst, src, size );
91
92 return wcscat( dst, src );
93}

◆ Copy()

TWCHAR * T2String16::Copy ( TWCHAR * dst,
const TWCHAR * src,
TSIZE size = -1 )
static

Definition at line 70 of file T2String16.cpp.

71{
72 if ( size != -1 )
73 return wcsncpy( dst, src, size );
74
75 return wcscpy( dst, src );
76}

◆ CopySafe()

TWCHAR * T2String16::CopySafe ( TWCHAR * dst,
const TWCHAR * src,
TSIZE size )
static

Definition at line 78 of file T2String16.cpp.

79{
80 TSIZE srcLen = Length( src );
81 size = TMath::Min( size - 1, srcLen );
82 wcsncpy( dst, src, size );
83 dst[ size ] = L'\0';
84 return dst;
85}
size_t TSIZE
Definition Typedefs.h:9
TFORCEINLINE const T & Min(const T &a, const T &b)
static TSIZE Length(const TWCHAR *str)

◆ CreateCopy()

TWCHAR * T2String16::CreateCopy ( const TWCHAR * a_wszString,
TSIZE a_uiSize = -1 )
static

Definition at line 205 of file T2String16.cpp.

206{
207 TSIZE uiSize = ( a_uiSize == -1 ) ? T2String16::Length( a_wszString ) : a_uiSize;
208
209 TWCHAR* wszBuffer = new TWCHAR[ uiSize + 1 ];
210 TUtil::MemCopy( wszBuffer, a_wszString, uiSize * sizeof( TWCHAR ) );
211 wszBuffer[ uiSize ] = L'\0';
212
213 return wszBuffer;
214}
wchar_t TWCHAR
Definition Typedefs.h:21
static void * MemCopy(void *dst, const void *src, TSIZE size)
Definition TUtil.h:90

◆ FindChar() [1/2]

const TWCHAR * T2String16::FindChar ( const TWCHAR * str,
TWCHAR character )
static

Definition at line 95 of file T2String16.cpp.

96{
97 while ( TTRUE )
98 {
99 if ( *str == L'\0' ) return TNULL;
100 if ( *str == character ) return str;
101 str++;
102 }
103
104 return TNULL;
105}
#define TNULL
Definition Typedefs.h:23
#define TTRUE
Definition Typedefs.h:25

◆ FindChar() [2/2]

TWCHAR * T2String16::FindChar ( TWCHAR * str,
TWCHAR character )
static

Definition at line 107 of file T2String16.cpp.

108{
109 while ( TTRUE )
110 {
111 if ( *str == L'\0' ) return TNULL;
112 if ( *str == character ) return str;
113 str++;
114 }
115
116 return TNULL;
117}

◆ FindString() [1/2]

const TWCHAR * T2String16::FindString ( const TWCHAR * str,
const TWCHAR * substr )
static

Definition at line 119 of file T2String16.cpp.

120{
121 return wcsstr( str, substr );
122}

◆ FindString() [2/2]

TWCHAR * T2String16::FindString ( TWCHAR * str,
const TWCHAR * substr )
static

Definition at line 124 of file T2String16.cpp.

125{
126 return wcsstr( str, substr );
127}

◆ Format() [1/2]

TINT T2String16::Format ( TWCHAR * a_pcString,
const TWCHAR * a_pcFormat,
... )
static

Definition at line 30 of file T2String16.cpp.

31{
32 va_list args;
33
34 va_start( args, a_pcFormat );
35 TINT iResult = FormatV( a_pcString, a_pcFormat, args );
36 va_end( args );
37
38 return iResult;
39}
int TINT
Definition Typedefs.h:7
static TINT FormatV(TWCHAR *a_pcString, TINT size, const TWCHAR *a_pcFormat, va_list args)

◆ Format() [2/2]

TINT T2String16::Format ( TWCHAR * a_pcString,
TINT size,
const TWCHAR * a_pcFormat,
... )
static

Definition at line 41 of file T2String16.cpp.

42{
43 va_list args;
44
45 va_start( args, a_pcFormat );
46 TINT iResult = FormatV( a_pcString, size, a_pcFormat, args );
47 va_end( args );
48
49 return iResult;
50}

◆ FormatV() [1/2]

TINT T2String16::FormatV ( TWCHAR * a_pcString,
const TWCHAR * a_pcFormat,
va_list args )
static

Definition at line 23 of file T2String16.cpp.

24{
25 TINT iResult = _vswprintf( a_pcString, a_pcFormat, args );
26 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" );
27 return iResult;
28}
#define TASSERT(X,...)
Definition Defines.h:138

◆ FormatV() [2/2]

TINT T2String16::FormatV ( TWCHAR * a_pcString,
TINT size,
const TWCHAR * a_pcFormat,
va_list args )
static

Definition at line 15 of file T2String16.cpp.

16{
17 TINT iResult = _vsnwprintf( a_pcString, size, a_pcFormat, args );
18 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" );
19 a_pcString[ size - 1 ] = '\0';
20 return iResult;
21}

◆ GetDefaultAllocatorCB()

static T2Allocator * T2String16::GetDefaultAllocatorCB ( )
inlinestatic

Definition at line 54 of file T2String16.h.

55 {
56 return GetGlobalAllocator();
57 }
TFORCEINLINE T2Allocator * GetGlobalAllocator()
Definition T2Allocator.h:49

◆ IntToString() [1/2]

void T2String16::IntToString ( TINT value,
TWCHAR * dst,
TINT radix )
static

Definition at line 174 of file T2String16.cpp.

175{
176 _itow( value, dst, radix );
177}

◆ IntToString() [2/2]

void T2String16::IntToString ( TINT value,
TWCHAR * dst,
TINT unused,
TINT radix )
static

Definition at line 169 of file T2String16.cpp.

170{
171 _itow( value, dst, radix );
172}

◆ IsLowerCase()

TBOOL T2String16::IsLowerCase ( const TWCHAR * str)
static

Definition at line 135 of file T2String16.cpp.

136{
137 while ( *str != L'\0' && T2Char16::IsLowerCase( *str ) )
138 str++;
139
140 return ( *str == L'\0' );
141}
static TBOOL IsLowerCase(TINT a_cChar)

◆ IsUpperCase()

TBOOL T2String16::IsUpperCase ( const TWCHAR * str)
static

Definition at line 143 of file T2String16.cpp.

144{
145 while ( *str != L'\0' && T2Char16::IsUpperCase( *str ) )
146 str++;
147
148 return ( *str == L'\0' );
149}
static TBOOL IsUpperCase(TINT a_cChar)

◆ Length()

TSIZE T2String16::Length ( const TWCHAR * str)
static

Definition at line 129 of file T2String16.cpp.

130{
131 if ( str != TNULL ) return wcslen( str );
132 return -1;
133}

◆ SkipSpaces() [1/2]

const TWCHAR * T2String16::SkipSpaces ( const TWCHAR * str)
static

Definition at line 197 of file T2String16.cpp.

198{
199 const TWCHAR* pszCursor = str;
200 while ( T2Char16::IsSpace( *pszCursor ) ) pszCursor++;
201
202 return pszCursor;
203}
static TBOOL IsSpace(TINT a_cChar)

◆ SkipSpaces() [2/2]

TWCHAR * T2String16::SkipSpaces ( TWCHAR * str)
static

Definition at line 189 of file T2String16.cpp.

190{
191 TWCHAR* pszCursor = str;
192 while ( T2Char16::IsSpace( *pszCursor ) ) pszCursor++;
193
194 return pszCursor;
195}

◆ StringToFloat()

TFLOAT T2String16::StringToFloat ( const TWCHAR * src)
static

Definition at line 184 of file T2String16.cpp.

185{
186 return (TFLOAT)_wtof( src );
187}
float TFLOAT
Definition Typedefs.h:4

◆ StringToInt()

TINT T2String16::StringToInt ( const TWCHAR * src)
static

Definition at line 179 of file T2String16.cpp.

180{
181 return _wtoi( src );
182}

◆ ToLowerCase()

void T2String16::ToLowerCase ( TWCHAR * str)
static

Definition at line 151 of file T2String16.cpp.

152{
153 while ( *str )
154 {
155 *str = T2Char16::ToLowerCase( *str );
156 str++;
157 }
158}
static CharType ToLowerCase(TINT a_cChar)

◆ ToUpperCase()

void T2String16::ToUpperCase ( TWCHAR * str)
static

Definition at line 160 of file T2String16.cpp.

161{
162 while ( *str )
163 {
164 *str = T2Char16::ToUpperCase( *str );
165 str++;
166 }
167}
static CharType ToUpperCase(TINT a_cChar)

Member Data Documentation

◆ ms_aScratchMem

TWCHAR T2String16::ms_aScratchMem
static

Definition at line 61 of file T2String16.h.

◆ SCRATCH_MEM_SIZE

TSIZE T2String16::SCRATCH_MEM_SIZE = 512
staticconstexpr

Definition at line 12 of file T2String16.h.

◆ sm_pDefaultAllocatorCB

T2Allocator* T2String16::sm_pDefaultAllocatorCB = GetDefaultAllocatorCB()
inlinestatic

Definition at line 60 of file T2String16.h.


The documentation for this class was generated from the following files: