5
// Copy a string with length checking.
6
//warning: Behavior differs from strncpy; last character is zeroed.
8
TCHAR* Strncpy(TCHAR* Dest, t_size Size, const TCHAR* Src, t_size MaxLen)
11
STRNCPY_S(Dest, Size, Src, MaxLen);
17
// Concatenate a string with length checking
19
TCHAR* Strncat(TCHAR* Dest, t_size Size, const TCHAR* Src, t_size MaxLen)
21
t_size Len = StringLength(Dest);
22
nuxAssert(Size >= Len);
23
TCHAR* NewDest = Dest + Len;
24
if((MaxLen -= Len) > 0)
26
Strncpy(NewDest, Size-Len, Src, MaxLen);
27
NewDest[MaxLen-1] = 0;
33
// Search a string inside a string. Return a pointer to the beginning of the searched string if it is found. Else, return NULL;
34
// The shearched string must be preceded by a non alpha numeric character in Str.
36
const TCHAR* Strfind(const TCHAR* Str, const TCHAR* Find)
38
nuxAssert(Find != NULL);
39
nuxAssert(Str != NULL);
41
if(Find == NULL || Str == NULL)
47
TCHAR First = ((*Find < TEXT('a')) || (*Find > TEXT('z'))) ? (*Find) : (*Find + TEXT('A') - TEXT('a'));
48
t_size Len = StringLength(Find++) - 1;
53
if((chr >= TEXT('a')) && (chr <= TEXT('z')))
55
chr += TEXT('A') - TEXT('a');
57
if(!AlphaNum && (chr == First) && !TCharStringNICompare(Str, Find, Len))
61
AlphaNum = ((chr >= TEXT('A')) && (chr <= TEXT('Z'))) || ((chr >= TEXT('0')) && (chr <= TEXT('9')));
67
bool IsLastChar(const TCHAR* CharString, const TCHAR Chr)
69
nuxAssert(CharString != 0);
73
t_size Size = StringLength(CharString);
77
if(CharString[Size-1] == Chr)
82
NString Itoa(int InNum)
84
SQWORD Num = InNum; // This avoids having to deal with negating -MaxS32 - 1
86
const TCHAR* NumberChar[10] = { TEXT("0"), TEXT("1"), TEXT("2"), TEXT("3"), TEXT("4"), TEXT("5"), TEXT("6"), TEXT("7"), TEXT("8"), TEXT("9") };
87
bool bIsNumberNegative = FALSE;
89
// Correctly handle negative numbers and convert to positive integer.
92
bIsNumberNegative = TRUE;
96
// Convert to string assuming base ten and a positive integer.
99
NumberString += NumberChar[Num % 10];
103
// Append sign as we're going to reverse string afterwards.
104
if(bIsNumberNegative)
106
NumberString += TEXT("-");
109
NumberString.Reverse();
113
//! Duplicate a null terminated string using new[]. The resulting string is NULL terminated. Use delete[] to destroy.
114
TCHAR* Strdup(const TCHAR* str)
118
t_size len = StringLength(str);
121
TCHAR* res = new TCHAR[len+1];
122
Strncpy(res, len+1, str, len);
128
//! Duplicate a null terminated ANSICHAR string using new[]. The resulting string is NULL terminated. Use delete[] to destroy.
129
ANSICHAR* StrdupA( const ANSICHAR* str)
133
int len = (int)strlen(str);
136
ANSICHAR* res = new ANSICHAR[len+1];
137
STRNCPY_S((char*)res, len+1, (const char*)str, len);
143
//! Duplicate a null terminated UNICHAR string using new[]. The resulting string is NULL terminated. Use delete[] to destroy.
144
UNICHAR* StrdupU( const UNICHAR* str)
148
int len = (int)wcslen((const wchar_t *)str);
151
UNICHAR* res = new UNICHAR[len+1];
152
WCSNCPY_S((wchar_t*)res, len+1, (const wchar_t*)str, len);
158
// * Standard string formatted print.
160
// VARARG_BODY(int, inlSprintf, const TCHAR*, VARARG_EXTRA(TCHAR* Dest))
164
// va_start(ap, Fmt);
165
// //@warning: make sure code using inlSprintf allocates enough memory if the below 1024 is ever changed.
166
// GET_VARARGS_RESULT(Dest,1024/*!!*/,Fmt,Result);
171
t_size ValueToLiteralString(char* buffer, t_u32 len, t_u16 value) { return ToCharString(buffer, len, "%hu", value); }
172
t_size ValueToLiteralString(char* buffer, t_u32 len, t_s16 value) { return ToCharString(buffer, len, "%hi", value); }
173
t_size ValueToLiteralString(char* buffer, t_u32 len, t_u32 value) { return ToCharString(buffer, len, "%lu", value); }
174
t_size ValueToLiteralString(char* buffer, t_u32 len, t_s32 value) { return ToCharString(buffer, len, "%li", value); }
175
t_size ValueToLiteralString(char* buffer, t_u32 len, t_ulong value) { return ToCharString(buffer, len, "%lu", value); }
176
t_size ValueToLiteralString(char* buffer, t_u32 len, t_long value) { return ToCharString(buffer, len, "%li", value); }
177
t_size ValueToLiteralString(char* buffer, t_u32 len, t_u64 value) { return ToCharString(buffer, len, "%I64u", value); }
178
t_size ValueToLiteralString(char* buffer, t_u32 len, t_s64 value) { return ToCharString(buffer, len, "%I64i", value); }
179
t_size ValueToLiteralString(char* buffer, t_u32 len, t_float value) { return ToCharString(buffer, len, "%.10g", value); }
180
t_size ValueToLiteralString(char* buffer, t_u32 len, t_double value) { return ToCharString(buffer, len, "%.20lg", value); }
181
t_size ValueToLiteralString(char* buffer, t_u32 len, t_u8 value) { return ValueToLiteralString(buffer, len, (t_u32) value); }
182
t_size ValueToLiteralString(char* buffer, t_u32 len, t_char value) { return ValueToLiteralString(buffer, len, (t_s32) value); }
183
t_size ValueToLiteralString(char* buffer, t_u32 len, t_s8 value) { return ValueToLiteralString(buffer, len, (t_s32) value); }
185
bool ValueFromLiteralString(const char* buffer, t_u32 len, t_u16 &value) { return FromCharString(buffer, len, "%hu", value ); }
186
bool ValueFromLiteralString(const char* buffer, t_u32 len, t_s16 &value) { return FromCharString(buffer, len, "%hi", value ); }
187
bool ValueFromLiteralString(const char* buffer, t_u32 len, t_u32 &value) { return FromCharString(buffer, len, "%lu", value ); }
188
bool ValueFromLiteralString(const char* buffer, t_u32 len, t_s32 &value) { return FromCharString(buffer, len, "%li", value ); }
189
bool ValueFromLiteralString(const char* buffer, t_u32 len, t_ulong &value) { return FromCharString(buffer, len, "%lu", value ); }
190
bool ValueFromLiteralString(const char* buffer, t_u32 len, t_long &value) { return FromCharString(buffer, len, "%li", value ); }
191
bool ValueFromLiteralString(const char* buffer, t_u32 len, t_u64 &value) { return FromCharString(buffer, len, "%I64u", value ); }
192
bool ValueFromLiteralString(const char* buffer, t_u32 len, t_s64 &value) { return FromCharString(buffer, len, "%I64i", value ); }
193
bool ValueFromLiteralString(const char* buffer, t_u32 len, t_float &value) { return FromCharString(buffer, len, "%g", value ); }
194
bool ValueFromLiteralString(const char* buffer, t_u32 len, t_double &value) { return FromCharString(buffer, len, "%lg", value ); }
195
bool ValueFromLiteralString(const char* buffer, t_u32 len, t_u8 &value)
199
result = ValueFromLiteralString(buffer, len, tmp);
204
bool ValueFromLiteralString(const char* buffer, t_u32 len, t_char &value)
208
result = ValueFromLiteralString(buffer, len, tmp);
213
bool ValueFromLiteralString(const char* buffer, t_u32 len, t_s8 &value)
217
result = ValueFromLiteralString(buffer, len, tmp);
222
VARARG_BODY(int, Snprintf, const TCHAR*, VARARG_EXTRA(TCHAR* Dest) VARARG_EXTRA(int Size) VARARG_EXTRA(int Count))
225
GET_VARARGS_RESULT(Dest, Size, Count, Fmt, Result);
234
NString::NString(const NString& s)
236
m_string = s.m_string;
239
NString& NString::operator= (const NString& s)
241
m_string = s.m_string;
245
NString::NString(const tstring& s)
250
NString::NString(const TCHAR& s)
255
NString::NString(const ANSICHAR* s)
261
m_string = ANSICHAR_TO_UNICHAR(s);
270
NString::NString(const UNICHAR* s)
281
m_string = UNICHAR_TO_ANSICHAR(s);
290
const tstring& NString::GetTStringRef() const
295
//const TCHAR* NString::GetTChar() const
297
// return m_string.c_str();
300
const TCHAR* NString::GetTCharPtr() const
302
return m_string.c_str();
305
t_size NString::Length() const
307
return m_string.length();
310
t_size NString::Size() const
312
return m_string.size();
315
void NString::Clear()
320
bool NString::IsEmpty()
322
return m_string.empty();
325
void NString::Erase(t_size Pos, t_size Count)
327
m_string.erase(Pos, Count);
330
NString& NString::Insert(t_size Pos, const TCHAR* Ptr)
332
m_string.insert(Pos, Ptr);
336
NString& NString::Insert(t_size Pos, const TCHAR* Ptr, t_size Count)
338
m_string.insert(Pos, Ptr, Count);
342
NString& NString::Insert(t_size Pos, const tstring& Str)
344
m_string.insert(Pos, Str);
348
NString& NString::Insert(t_size Pos, const tstring& Str, t_size Offset, t_size Count)
350
m_string.insert(Pos, Str, Offset, Count);
354
NString& NString::Insert(t_size Pos, const NString& Str)
356
m_string.insert(Pos, Str.m_string);
360
NString& NString::Insert(t_size Pos, const NString& Str, t_size Offset, t_size Count)
362
m_string.insert(Pos, Str.m_string, Offset, Count);
366
NString& NString::Insert(t_size Pos, int Count, const TCHAR& Ch)
368
m_string.insert(Pos, Count, Ch);
372
const TCHAR& NString::operator[](t_size ChPos) const
374
return m_string[ChPos];
377
TCHAR& NString::operator[](t_size ChPos)
379
return m_string[ChPos];
382
NString& NString::Replace(t_size Pos1, t_size Num1, const TCHAR* Ptr)
384
m_string.replace(Pos1, Num1, Ptr);
388
NString& NString::Replace(t_size Pos1, t_size Num1, const TCHAR* Ptr, t_size Num2)
390
m_string.replace(Pos1, Num1, Ptr, Num2);
394
NString& NString::Replace(t_size Pos1, t_size Num1, const tstring& Str)
396
m_string.replace(Pos1, Num1, Str);
400
NString& NString::Replace(t_size Pos1, t_size Num1, const tstring& Str, t_size Pos2, t_size Num2)
402
m_string.replace(Pos1, Num1, Str, Pos2, Num2);
406
NString& NString::Replace(t_size Pos1, t_size Num1, const NString& Str)
408
m_string.replace(Pos1, Num1, Str.m_string);
412
NString& NString::Replace(t_size Pos1, t_size Num1, const NString& Str, t_size Pos2, t_size Num2)
414
m_string.replace(Pos1, Num1, Str.m_string, Pos2, Num2);
418
NString& NString::Replace(t_size Pos1, t_size Num1, t_size Count, TCHAR Ch)
420
m_string.replace(Pos1, Num1, Count, Ch);
424
void NString::Reverse()
428
for(t_size i = l-1; i >= 0; i--)
435
NString& NString::SearchAndReplace(TCHAR ChOut, TCHAR ChIn)
437
for(t_size i = 0; i < Length(); i++)
438
if(m_string[i] == ChOut)
443
//! Return The last position of the substring suffix or -1 if it is not found.
444
t_size NString::FindLastOccurence(const TCHAR& suffix) const
450
pos = m_string.find(suffix, start);
451
if(pos != tstring::npos)
453
} while(pos != tstring::npos);
457
//! Return The last position of the substring suffix or -1 if it is not found.
458
t_size NString::FindLastOccurence(const TCHAR* suffix) const
464
pos = m_string.find(suffix, start);
465
if(pos != tstring::npos)
467
} while(pos != tstring::npos);
471
//! Return The last position of the substring suffix or -1 if it is not found.
472
t_size NString::FindLastOccurence(const tstring& suffix) const
478
pos = m_string.find(suffix, start);
479
if(pos != tstring::npos)
481
} while(pos != tstring::npos);
485
//! Return The last position of the substring suffix or -1 if it is not found.
486
t_size NString::FindLastOccurence(const NString& suffix) const
492
pos = m_string.find(suffix.m_string, start);
493
if(pos != tstring::npos)
495
} while(pos != tstring::npos);
500
//! Return the position of the first occurrence of the substring suffix or -1 if it is not found.
501
t_size NString::FindFirstOccurence(const TCHAR& suffix) const
504
pos = m_string.find(suffix, pos);
505
return (pos != tstring::npos)? pos : -1;
508
//! Return the position of the first occurrence of the substring suffix or -1 if it is not found.
509
t_size NString::FindFirstOccurence(const TCHAR* suffix) const
512
pos = m_string.find(suffix, pos);
513
return (pos != tstring::npos)? pos : -1;
516
//! Return the position of the first occurrence of the substring suffix or -1 if it is not found.
517
t_size NString::FindFirstOccurence(const tstring& suffix) const
520
pos = m_string.find(suffix, pos);
521
return (pos != tstring::npos)? pos : -1;
524
//! Return the position of the first occurrence of the substring suffix or -1 if it is not found.
525
t_size NString::FindFirstOccurence(const NString& suffix) const
528
pos = m_string.find(suffix.m_string, pos);
529
return (pos != tstring::npos)? pos : -1;
532
//! Return the position of the first occurrence of the substring suffix or -1 if it is not found.
533
t_size NString::FindNextOccurence(const TCHAR& suffix, t_size start) const
536
pos = m_string.find(suffix, start);
537
return (pos != tstring::npos)? pos : -1;
540
//! Return the position of the first occurrence of the substring suffix or -1 if it is not found.
541
t_size NString::FindNextOccurence(const TCHAR* suffix, t_size start) const
544
pos = m_string.find(suffix, start);
545
return (pos != tstring::npos)? pos : -1;
548
//! Return the position of the first occurrence of the substring suffix or -1 if it is not found.
549
t_size NString::FindNextOccurence(const tstring& suffix, t_size start) const
552
pos = m_string.find(suffix, start);
553
return (pos != tstring::npos)? pos : -1;
556
//! Return the position of the first occurrence of the substring suffix or -1 if it is not found.
557
t_size NString::FindNextOccurence(const NString& suffix, t_size start) const
560
pos = m_string.find(suffix.m_string, start);
561
return (pos != tstring::npos)? pos : -1;
564
//! Searches through a string for the first character that matches any element of a specified string. Return -1 if it is not found.
565
t_size NString::FindFirstOccurenceOf(const TCHAR& str) const
568
pos = m_string.find_first_of(str, pos);
569
return (pos != tstring::npos)? pos : -1;
571
//! Searches through a string for the first character that matches any element of a specified string. Return -1 if it is not found.
572
t_size NString::FindFirstOccurenceOf(const TCHAR* str) const
575
pos = m_string.find_first_of(str, pos);
576
return (pos != tstring::npos)? pos : -1;
578
//! Searches through a string for the first character that matches any element of a specified string. Return -1 if it is not found.
579
t_size NString::FindFirstOccurenceOf(const tstring& str) const
582
pos = m_string.find_first_of(str, pos);
583
return (pos != tstring::npos)? pos : -1;
585
//! Searches through a string for the first character that matches any element of a specified string. Return -1 if it is not found.
586
t_size NString::FindFirstOccurenceOf(const NString& str) const
589
pos = m_string.find_first_of(str.m_string, pos);
590
return (pos != tstring::npos)? pos : -1;
593
//! Searches through a string for the last character that matches any element of a specified string. Return -1 if it is not found.
594
t_size NString::FindLastOccurenceOf(const TCHAR& str) const
597
pos = m_string.find_last_of(str, pos);
598
return (pos != tstring::npos)? pos : -1;
600
//! Searches through a string for the last character that matches any element of a specified string. Return -1 if it is not found.
601
t_size NString::FindLastOccurenceOf(const TCHAR* str) const
604
pos = m_string.find_last_of(str, pos);
605
return (pos != tstring::npos)? pos : -1;
607
//! Searches through a string for the last character that matches any element of a specified string. Return -1 if it is not found.
608
t_size NString::FindLastOccurenceOf(const tstring& str) const
611
pos = m_string.find_last_of(str, pos);
612
return (pos != tstring::npos)? pos : -1;
614
//! Searches through a string for the last character that matches any element of a specified string. Return -1 if it is not found.
615
t_size NString::FindLastOccurenceOf(const NString& str) const
618
pos = m_string.find_last_of(str.m_string, pos);
619
return (pos != tstring::npos)? pos : -1;
622
t_size NString::Find(NString str, int start)
624
t_size pos = m_string.find(str.m_string, start);
625
return (pos != tstring::npos)? pos : -1;
628
t_size NString::Find(TCHAR c, int start)
630
t_size pos = m_string.find(c, start);
631
return (pos != tstring::npos)? pos : -1;
634
bool NString::IsSuffix(const TCHAR& suffix)
636
t_size l = m_string.length()-1;
639
t_size pos = FindLastOccurence(suffix);
645
bool NString::IsSuffix(const TCHAR* suffix)
647
t_size sl = StringLength(suffix);
650
t_size l = m_string.length() - sl;
653
t_size pos = FindLastOccurence(suffix);
659
//! Return True is the the string is terminated by the tstring 'suffix'
660
bool NString::IsSuffix(const tstring& suffix)
662
t_size sl = suffix.length();
665
t_size l = m_string.length() - sl;
668
t_size pos = FindLastOccurence(suffix);
674
//! Return True is the the string is terminated by the NString 'suffix'
675
bool NString::IsSuffix(const NString& suffix)
677
t_size sl = suffix.Length();
680
t_size l = m_string.length() - sl;
683
t_size pos = FindLastOccurence(suffix);
689
//! Return True if the string start with the character contained in prefix
690
bool NString::IsPrefix(const TCHAR& prefix)
692
t_size l = m_string.length()-1;
695
t_size pos = FindFirstOccurence(prefix);
701
//! Return True if the string start with the character string contained in prefix
702
bool NString::IsPrefix(const TCHAR* prefix)
704
t_size sl = StringLength(prefix);
707
t_size pos = FindFirstOccurence(prefix);
713
//! Return True if the string start with the tstring contained in prefix
714
bool NString::IsPrefix(const tstring& prefix)
716
t_size sl = prefix.length();
719
t_size pos = FindFirstOccurence(prefix);
724
//! Return True if the string start with the NString contained in prefix
725
bool NString::IsPrefix(const NString& prefix)
727
t_size sl = prefix.Length();
730
t_size pos = FindFirstOccurence(prefix);
736
//! Return an NString without the character contained in suffix
737
void NString::RemoveSuffix(const TCHAR& suffix)
741
t_size pos = FindLastOccurence(suffix);
742
*this = NString(m_string.substr(0, pos));
746
//! Return an NString without the character string 'suffix'
747
void NString::RemoveSuffix(const TCHAR* suffix)
751
t_size pos = FindLastOccurence(suffix);
752
*this = NString(m_string.substr(0, pos));
756
//! Return an NString without the tstring 'suffix'
757
void NString::RemoveSuffix(const tstring& suffix)
761
t_size pos = FindLastOccurence(suffix);
762
*this = NString(m_string.substr(0, pos));
766
//! Return an NString without the NString 'suffix'
767
void NString::RemoveSuffix(const NString& suffix)
771
t_size pos = FindLastOccurence(suffix);
772
*this = NString(m_string.substr(0, pos));
776
//! Return an NString striped out of the prefix contained in prefix
777
void NString::RemovePrefix(const TCHAR& prefix)
781
*this = NString(m_string.substr(1));
785
//! Return an NString striped out of the prefix contained in prefix
786
void NString::RemovePrefix(const TCHAR* prefix)
790
t_size l = StringLength(prefix);
791
*this = NString(m_string.substr(l));
795
//! Return an NString striped out of the prefix contained in prefix
796
void NString::RemovePrefix(const tstring& prefix)
800
t_size l = prefix.length();
801
*this = NString(m_string.substr(l));
805
//! Return an NString striped out of the prefix contained in prefix
806
void NString::RemovePrefix(const NString& prefix)
810
t_size l = prefix.Length();
811
*this = NString(m_string.substr(l));
815
NString NString::GetSubString(t_size count) const
817
nuxAssert(count >= 0);
818
return NString(m_string.substr(0, count));
821
NString NString::GetSubString(t_size start, t_size count) const
823
nuxAssert(start >= 0);
824
nuxAssert(count >= 0);
825
return NString(m_string.substr(start, count));
828
NString NString::Mid(t_size count) const
830
return GetSubString(count);
833
NString NString::Mid(t_size start, t_size count) const
835
return GetSubString(start, count);
838
NString NString::Left(t_size N) const
843
return GetSubString(0, N);
846
NString NString::Right(t_size N) const
851
return GetSubString(Length()-N, N);
854
NString NString::Trim() const
856
return TrimLeft().TrimRight();
859
NString NString::TrimLeft() const
862
t_size L = Length()-1;
865
if(IsWhitespaceChar(m_string[n]))
874
return GetSubString(n, Length()-n);
877
NString NString::TrimRight() const
879
t_size L = Length()-1;
882
if(IsWhitespaceChar(m_string[L]))
891
return GetSubString(0, Length()+1);
894
NString NString::TrimLeft(NString str) const
904
t_size sz = str.Length();
905
for(t_size i = 0; i < sz; i++)
907
if(m_string[n] == str[i])
922
return GetSubString(n, Length()-n);
925
NString NString::TrimRight(NString str) const
935
t_size sz = str.Length();
936
for(t_size i = 0; i < sz; i++)
938
if(m_string[L] == str[i])
953
return GetSubString(0, L+1);
956
const TCHAR* NString::operator () () const
960
return GetTCharPtr();
963
const TCHAR* NString::operator * () const
967
return GetTCharPtr();
970
// NString::operator const TCHAR*() const
972
// return (const TCHAR*)GetTCharPtr();
975
NString& NString::operator += (const TCHAR& sufix)
981
NString& NString::operator += (const TCHAR* sufix)
987
NString& NString::operator += (const tstring sufix)
993
NString& NString::operator += (const NString sufix)
995
m_string += sufix.m_string;
999
void NString::SplitAtFirstOccurenceOf(const TCHAR* SplitString, NString& Left, NString& Right)
1001
t_size start = FindFirstOccurence(SplitString);
1004
t_size size = StringLength(SplitString);
1005
Left = GetSubString(0, start);
1006
Right = GetSubString(start+size, Length()-(start+size));
1015
void NString::SplitAtFirstOccurenceOf(const TCHAR& SplitChar, NString& Left, NString& Right)
1017
SplitAtFirstOccurenceOf(NString(SplitChar), Left, Right);
1020
void NString::SplitAtFirstOccurenceOf(const NString& SplitString, NString& Left, NString& Right)
1022
SplitAtFirstOccurenceOf(SplitString.GetTCharPtr(), Left, Right);
1025
void NString::SplitAtLastOccurenceOf(const TCHAR* SplitString, NString& Left, NString& Right)
1027
t_size start = FindLastOccurence(SplitString);
1030
t_size size = StringLength(SplitString);
1031
Left = GetSubString(0, start);
1032
Right = GetSubString(start+size, Length()-(start+size));
1041
void NString::SplitAtLastOccurenceOf(const TCHAR& SplitChar, NString& Left, NString& Right)
1043
SplitAtLastOccurenceOf(NString(SplitChar), Left, Right);
1046
void NString::SplitAtLastOccurenceOf(const NString& SplitString, NString& Left, NString& Right)
1048
SplitAtLastOccurenceOf(SplitString.GetTCharPtr(), Left, Right);
1051
void NString::ParseToArray(std::vector<NString>& StringArray, const NString& delimiter)
1056
SplitAtFirstOccurenceOf(delimiter, Left, Temp);
1060
StringArray.push_back(Left);
1065
Right.SplitAtFirstOccurenceOf(delimiter, Left, Temp);
1069
StringArray.push_back(Left);
1075
TCHAR NString::GetFirstChar()
1082
TCHAR NString::GetLastChar()
1086
return m_string[Size()-1];
1089
bool operator != (const NString& left, const NString& right)
1091
return left.m_string != right.m_string;
1093
bool operator == (const NString& left, const NString& right)
1095
return left.m_string == right.m_string;
1097
bool operator < (const NString& left, const NString& right)
1099
return left.m_string < right.m_string;
1101
bool operator <= (const NString& left, const NString& right)
1103
return left.m_string <= right.m_string;
1105
bool operator > (const NString& left, const NString& right)
1107
return left.m_string > right.m_string;
1109
bool operator >= (const NString& left, const NString& right)
1111
return left.m_string >= right.m_string;
1114
NString operator+ (const NString& left, const NString& right)
1116
return NString(left.m_string + right.m_string);
1119
NString operator+ (const NString& left, const TCHAR* right)
1121
return NString(left.m_string + right);
1124
NString operator+ (const NString& left, const TCHAR right)
1126
return NString(left.m_string + right);
1129
NString operator+ (const TCHAR* left, const NString& right)
1131
return NString(left + right.m_string);
1134
NString operator+ (const TCHAR left, const NString& right)
1136
return NString(left + right.m_string);
1139
tostream& operator << (tostream& o, const NString& s)
1141
return o << s.m_string;
1144
VARARG_BODY(NString, NString::Printf, const TCHAR*, VARARG_NONE)
1146
t_u32 BufferSize = 1024;
1147
TCHAR* Buffer = NULL;
1152
Buffer = (TCHAR*) Realloc(Buffer, BufferSize * sizeof(TCHAR));
1153
GET_VARARGS_RESULT(Buffer, BufferSize, BufferSize-1, Fmt, Result);
1158
NString ResultString(Buffer);
1161
return ResultString;