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

#include <T2String8.h>

Static Public Member Functions

static TCHARCreateCopy (const TCHAR *a_pcString, TSIZE a_uiSize=-1)
 
static TINT FormatV (TCHAR *a_pcString, TINT size, const TCHAR *a_pcFormat, va_list args)
 
static TINT FormatV (TCHAR *a_pcString, const TCHAR *a_pcFormat, va_list args)
 
static TINT Format (TCHAR *a_pcString, TINT size, const TCHAR *a_pcFormat,...)
 
static TINT Format (TCHAR *a_pcString, const TCHAR *a_pcFormat,...)
 
static TINT Compare (const TCHAR *str1, const TCHAR *str2, TSIZE size=-1)
 
static TINT CompareNoCase (const TCHAR *str1, const TCHAR *str2, TSIZE size=-1)
 
static TCHARCopy (TCHAR *dst, const TCHAR *src, TSIZE size=-1)
 
static TCHARCopySafe (TCHAR *dst, const TCHAR *src, TSIZE size)
 
static TCHARConcat (TCHAR *dst, const TCHAR *src, TSIZE size=-1)
 
static TCHARFindChar (TCHAR *str, TCHAR character)
 
static const TCHARFindChar (const TCHAR *str, TCHAR character)
 
static TCHARFindString (TCHAR *str, const TCHAR *substr)
 
static const TCHARFindString (const TCHAR *str, const TCHAR *substr)
 
static TSIZE Length (const TCHAR *str)
 
static TBOOL IsLowerCase (const TCHAR *str)
 
static TBOOL IsUpperCase (const TCHAR *str)
 
static void ToLowerCase (TCHAR *str)
 
static void ToUpperCase (TCHAR *str)
 
static void IntToString (TINT value, TCHAR *dst, TINT unused, TINT radix)
 
static void IntToString (TINT value, TCHAR *dst, TINT radix)
 
static TINT StringToInt (const TCHAR *src)
 
static TFLOAT StringToFloat (const TCHAR *src)
 
static TCHARSkipSpaces (TCHAR *str)
 
static const TCHARSkipSpaces (const TCHAR *str)
 
static T2AllocatorGetDefaultAllocatorCB ()
 

Static Public Attributes

static constexpr TSIZE SCRATCH_MEM_SIZE = 2048
 
static T2Allocatorsm_pDefaultAllocatorCB = GetDefaultAllocatorCB()
 
static TCHAR ms_aScratchMem [SCRATCH_MEM_SIZE]
 

Detailed Description

Definition at line 9 of file T2String8.h.

Member Function Documentation

◆ Compare()

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

Definition at line 52 of file T2String8.cpp.

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

◆ CompareNoCase()

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

Definition at line 60 of file T2String8.cpp.

61{
62 if ( size != -1 )
63 return _strnicmp( str1, str2, size );
64
65 return _stricmp( str1, str2 );
66}

◆ Concat()

TCHAR * T2String8::Concat ( TCHAR * dst,
const TCHAR * src,
TSIZE size = -1 )
static

Definition at line 76 of file T2String8.cpp.

77{
78 if ( size != -1 )
79 return strncat( dst, src, size );
80
81 return strcat( dst, src );
82}

◆ Copy()

TCHAR * T2String8::Copy ( TCHAR * dst,
const TCHAR * src,
TSIZE size = -1 )
static

Definition at line 68 of file T2String8.cpp.

69{
70 if ( size != -1 )
71 return strncpy( dst, src, size );
72
73 return strcpy( dst, src );
74}

◆ CopySafe()

TCHAR * T2String8::CopySafe ( TCHAR * dst,
const TCHAR * src,
TSIZE size )
static

Definition at line 84 of file T2String8.cpp.

85{
86 TSIZE srcLen = Length( src );
87 size = TMath::Min( size - 1, srcLen );
88 strncpy( dst, src, size );
89 dst[ size ] = '\0';
90 return dst;
91}
size_t TSIZE
Definition Typedefs.h:9
TFORCEINLINE const T & Min(const T &a, const T &b)
static TSIZE Length(const TCHAR *str)

◆ CreateCopy()

TCHAR * T2String8::CreateCopy ( const TCHAR * a_pcString,
TSIZE a_uiSize = -1 )
static

Definition at line 203 of file T2String8.cpp.

204{
205 TSIZE uiSize = ( a_uiSize == -1 ) ? T2String8::Length( a_pcString ) : a_uiSize;
206
207 TCHAR* pcBuffer = new TCHAR[ uiSize + 1 ];
208 TUtil::MemCopy( pcBuffer, a_pcString, uiSize * sizeof( TCHAR ) );
209 pcBuffer[ uiSize ] = '\0';
210
211 return pcBuffer;
212}
char TCHAR
Definition Typedefs.h:20
static void * MemCopy(void *dst, const void *src, TSIZE size)
Definition TUtil.h:90

◆ FindChar() [1/2]

const TCHAR * T2String8::FindChar ( const TCHAR * str,
TCHAR character )
static

Definition at line 93 of file T2String8.cpp.

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

◆ FindChar() [2/2]

TCHAR * T2String8::FindChar ( TCHAR * str,
TCHAR character )
static

Definition at line 105 of file T2String8.cpp.

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

◆ FindString() [1/2]

const TCHAR * T2String8::FindString ( const TCHAR * str,
const TCHAR * substr )
static

Definition at line 117 of file T2String8.cpp.

118{
119 return strstr( str, substr );
120}

◆ FindString() [2/2]

TCHAR * T2String8::FindString ( TCHAR * str,
const TCHAR * substr )
static

Definition at line 122 of file T2String8.cpp.

123{
124 return strstr( str, substr );
125}

◆ Format() [1/2]

TINT T2String8::Format ( TCHAR * a_pcString,
const TCHAR * a_pcFormat,
... )
static

Definition at line 30 of file T2String8.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(TCHAR *a_pcString, TINT size, const TCHAR *a_pcFormat, va_list args)
Definition T2String8.cpp:22

◆ Format() [2/2]

TINT T2String8::Format ( TCHAR * a_pcString,
TINT size,
const TCHAR * a_pcFormat,
... )
static

Definition at line 41 of file T2String8.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 T2String8::FormatV ( TCHAR * a_pcString,
const TCHAR * a_pcFormat,
va_list args )
static

Definition at line 15 of file T2String8.cpp.

16{
17 TINT iResult = vsprintf( a_pcString, 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 return iResult;
20}
#define TASSERT(X,...)
Definition Defines.h:138

◆ FormatV() [2/2]

TINT T2String8::FormatV ( TCHAR * a_pcString,
TINT size,
const TCHAR * a_pcFormat,
va_list args )
static

Definition at line 22 of file T2String8.cpp.

23{
24 TINT iResult = _vsnprintf( a_pcString, size, a_pcFormat, args );
25 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" );
26 a_pcString[ size - 1 ] = '\0';
27 return iResult;
28}

◆ GetDefaultAllocatorCB()

static T2Allocator * T2String8::GetDefaultAllocatorCB ( )
inlinestatic

Definition at line 54 of file T2String8.h.

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

◆ IntToString() [1/2]

void T2String8::IntToString ( TINT value,
TCHAR * dst,
TINT radix )
static

Definition at line 167 of file T2String8.cpp.

168{
169 _itoa( value, dst, radix );
170}

◆ IntToString() [2/2]

void T2String8::IntToString ( TINT value,
TCHAR * dst,
TINT unused,
TINT radix )
static

Definition at line 172 of file T2String8.cpp.

173{
174 _itoa( value, dst, radix );
175}

◆ IsLowerCase()

TBOOL T2String8::IsLowerCase ( const TCHAR * str)
static

Definition at line 133 of file T2String8.cpp.

134{
135 while ( *str != '\0' && T2Char8::IsLowerCase( *str ) )
136 str++;
137
138 return *str == '\0';
139}
static TBOOL IsLowerCase(TINT a_cChar)

◆ IsUpperCase()

TBOOL T2String8::IsUpperCase ( const TCHAR * str)
static

Definition at line 141 of file T2String8.cpp.

142{
143 while ( *str != '\0' && T2Char8::IsUpperCase( *str ) )
144 str++;
145
146 return *str == '\0';
147}
static TBOOL IsUpperCase(TINT a_cChar)

◆ Length()

TSIZE T2String8::Length ( const TCHAR * str)
static

Definition at line 127 of file T2String8.cpp.

128{
129 if ( str != TNULL ) return strlen( str );
130 return -1;
131}

◆ SkipSpaces() [1/2]

const TCHAR * T2String8::SkipSpaces ( const TCHAR * str)
static

Definition at line 195 of file T2String8.cpp.

196{
197 const TCHAR* pszCursor = str;
198 while ( T2Char8::IsSpace( *pszCursor ) ) pszCursor++;
199
200 return pszCursor;
201}
static TBOOL IsSpace(TINT a_cChar)

◆ SkipSpaces() [2/2]

TCHAR * T2String8::SkipSpaces ( TCHAR * str)
static

Definition at line 187 of file T2String8.cpp.

188{
189 TCHAR* pszCursor = str;
190 while ( T2Char8::IsSpace( *pszCursor ) ) pszCursor++;
191
192 return pszCursor;
193}

◆ StringToFloat()

TFLOAT T2String8::StringToFloat ( const TCHAR * src)
static

Definition at line 182 of file T2String8.cpp.

183{
184 return TFLOAT( atof( src ) );
185}
float TFLOAT
Definition Typedefs.h:4

◆ StringToInt()

TINT T2String8::StringToInt ( const TCHAR * src)
static

Definition at line 177 of file T2String8.cpp.

178{
179 return atoi( src );
180}

◆ ToLowerCase()

void T2String8::ToLowerCase ( TCHAR * str)
static

Definition at line 149 of file T2String8.cpp.

150{
151 while ( *str )
152 {
153 *str = T2Char8::ToLowerCase( *str );
154 str++;
155 }
156}
static CharType ToLowerCase(TINT a_cChar)

◆ ToUpperCase()

void T2String8::ToUpperCase ( TCHAR * str)
static

Definition at line 158 of file T2String8.cpp.

159{
160 while ( *str )
161 {
162 *str = T2Char8::ToUpperCase( *str );
163 str++;
164 }
165}
static CharType ToUpperCase(TINT a_cChar)

Member Data Documentation

◆ ms_aScratchMem

TCHAR T2String8::ms_aScratchMem
static

Definition at line 61 of file T2String8.h.

◆ SCRATCH_MEM_SIZE

TSIZE T2String8::SCRATCH_MEM_SIZE = 2048
staticconstexpr

Definition at line 12 of file T2String8.h.

◆ sm_pDefaultAllocatorCB

T2Allocator* T2String8::sm_pDefaultAllocatorCB = GetDefaultAllocatorCB()
inlinestatic

Definition at line 60 of file T2String8.h.


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