79 StringClass (
int initial_len = 0,
bool hint_temporary =
false);
81 StringClass (
const TCHAR *
string,
bool hint_temporary =
false);
82 StringClass (TCHAR ch,
bool hint_temporary =
false);
83 StringClass (
const WCHAR *
string,
bool hint_temporary =
false);
112 inline operator const TCHAR * (void)
const;
117 int Compare (
const TCHAR *
string)
const;
123 void Erase (
int start_index,
int char_count);
124 int _cdecl
Format (
const TCHAR *format, ...);
125 int _cdecl
Format_Args (
const TCHAR *format,
const va_list & arg_list );
146 typedef struct _HEADER
148 int allocated_length;
159 MAX_TEMP_LEN = 256-
sizeof(_HEADER),
160 MAX_TEMP_BYTES = (MAX_TEMP_LEN *
sizeof (TCHAR)) +
sizeof (HEADER),
161 ALL_TEMP_STRINGS_USED_MASK = 0xff
167 void Get_String (
int length,
bool is_temp);
168 TCHAR * Allocate_Buffer (
int length);
169 void Resize (
int size);
170 void Uninitialised_Grow (
int length);
171 void Free_String (
void);
173 inline void Store_Length (
int length);
174 inline void Store_Allocated_Length (
int allocated_length);
175 inline HEADER * Get_Header (
void)
const;
176 int Get_Allocated_Length (
void)
const;
178 void Set_Buffer_And_Allocated_Length (TCHAR *buffer,
int length);
188 static unsigned ReservedMask;
189 static char m_TempStrings[];
193 static TCHAR m_NullChar;
194 static TCHAR * m_EmptyString;
204 Uninitialised_Grow(len+1);
207 ::memcpy (m_Buffer,
string.m_Buffer, (len+1) *
sizeof (TCHAR));
220 int len = _tcslen (
string);
221 Uninitialised_Grow (len+1);
224 ::memcpy (m_Buffer,
string, (len + 1) *
sizeof (TCHAR));
251 Uninitialised_Grow (2);
254 m_Buffer[1] = m_NullChar;
265 : m_Buffer (m_EmptyString)
267 Get_String (MAX_TEMP_LEN, hint_temporary);
268 m_Buffer[0] = m_NullChar;
278 : m_Buffer (m_EmptyString)
280 Get_String (initial_len, hint_temporary);
281 m_Buffer[0] = m_NullChar;
291 : m_Buffer (m_EmptyString)
293 Get_String (2, hint_temporary);
303 : m_Buffer (m_EmptyString)
305 if (hint_temporary || (
string.
Get_Length()>0)) {
306 Get_String (
string.
Get_Length()+1, hint_temporary);
318 : m_Buffer (m_EmptyString)
320 int len=
string ? _tcsclen(
string) : 0;
321 if (hint_temporary || len>0) {
322 Get_String (len+1, hint_temporary);
334 : m_Buffer (m_EmptyString)
336 int len =
string ? wcslen (
string) : 0;
337 if (hint_temporary || len > 0) {
338 Get_String (len + 1, hint_temporary);
362 return (m_Buffer[0] == m_NullChar);
371 return _tcscmp (m_Buffer,
string);
380 return _tcsicmp (m_Buffer,
string);
390 return m_Buffer[index];
400 return m_Buffer[index];
407StringClass::operator
const TCHAR * (void)
const
418 return (
Compare (rvalue) == 0);
427 return (
Compare (rvalue) != 0);
436 return (_tcscmp (m_Buffer,
string) < 0);
445 return (_tcscmp (m_Buffer,
string) <= 0);
454 return (_tcscmp (m_Buffer,
string) > 0);
463 return (_tcscmp (m_Buffer,
string) >= 0);
475 if (start_index < len) {
477 if (start_index + char_count > len) {
478 char_count = len - start_index;
481 ::memmove ( &m_Buffer[start_index],
482 &m_Buffer[start_index + char_count],
483 (len - (start_index + char_count) + 1) *
sizeof (TCHAR));
485 Store_Length( len - char_count );
510 int src_len = _tcslen (
string);
511 int new_len = cur_len + src_len;
516 Resize (new_len + 1);
517 Store_Length (new_len);
522 ::memcpy (&m_Buffer[cur_len],
string, (src_len + 1) *
sizeof (TCHAR));
533 Resize (cur_len + 2);
535 m_Buffer[cur_len] = ch;
536 m_Buffer[cur_len + 1] = m_NullChar;
538 if (ch != m_NullChar) {
539 Store_Length (cur_len + 1);
551 Uninitialised_Grow (new_length);
583 int new_len = cur_len + src_len;
588 Resize (new_len + 1);
589 Store_Length (new_len);
594 ::memcpy (&m_Buffer[cur_len], (
const TCHAR *)
string, (src_len + 1) *
sizeof (TCHAR));
607 new_string += string2;
618 new_string += string2;
630 new_string += new_string2;
640StringClass::Get_Allocated_Length (
void)
const
642 int allocated_length = 0;
647 if (m_Buffer != m_EmptyString) {
648 HEADER *header = Get_Header ();
649 allocated_length = header->allocated_length;
652 return allocated_length;
668 if (m_Buffer != m_EmptyString) {
673 HEADER *header = Get_Header ();
674 length = header->length;
681 length = _tcslen (m_Buffer);
696StringClass::Set_Buffer_And_Allocated_Length (TCHAR *buffer,
int length)
704 if (m_Buffer != m_EmptyString) {
705 Store_Allocated_Length (length);
718StringClass::Allocate_Buffer (
int length)
724 char *
buffer =
W3DNEWARRAY char[(
sizeof (TCHAR) * length) +
sizeof (StringClass::_HEADER)];
729 HEADER *header =
reinterpret_cast<HEADER *
>(
buffer);
731 header->allocated_length = length;
736 return reinterpret_cast<TCHAR *
>(
buffer +
sizeof (StringClass::_HEADER));
742inline StringClass::HEADER *
743StringClass::Get_Header (
void)
const
745 return reinterpret_cast<HEADER *
>(((
char *)m_Buffer) -
sizeof (StringClass::_HEADER));
752StringClass::Store_Allocated_Length (
int allocated_length)
754 if (m_Buffer != m_EmptyString) {
755 HEADER *header = Get_Header ();
756 header->allocated_length = allocated_length;
771StringClass::Store_Length (
int length)
773 if (m_Buffer != m_EmptyString) {
774 HEADER *header = Get_Header ();
775 header->length = length;
const StringClass & operator+=(const StringClass &string)
const StringClass & operator=(const StringClass &string)
StringClass(bool hint_temporary)
int Compare(const TCHAR *string) const
int _cdecl Format(const TCHAR *format,...)
bool operator>(const TCHAR *string) const
void Erase(int start_index, int char_count)
bool operator>=(const TCHAR *string) const
int _cdecl Format_Args(const TCHAR *format, const va_list &arg_list)
bool operator==(const TCHAR *rvalue) const
TCHAR * Get_Buffer(int new_length)
bool Is_Empty(void) const
bool operator!=(const TCHAR *rvalue) const
int Get_Length(void) const
bool operator<(const TCHAR *string) const
int Compare_No_Case(const TCHAR *string) const
TCHAR * Peek_Buffer(void)
void Release_Resources(void)
friend StringClass operator+(const StringClass &string1, const StringClass &string2)
bool operator<=(const TCHAR *string) const
bool Copy_Wide(const WCHAR *source)
const TCHAR & operator[](int index) const
LOCALEFILE_HEADERCHUNK HEADER
char * strtrim(char *buffer)
StringClass operator+(const StringClass &string1, const StringClass &string2)