nux-0.9.48
|
00001 /* 00002 * Copyright 2010 Inalogic® Inc. 00003 * 00004 * This program is free software: you can redistribute it and/or modify it 00005 * under the terms of the GNU Lesser General Public License, as 00006 * published by the Free Software Foundation; either version 2.1 or 3.0 00007 * of the License. 00008 * 00009 * This program is distributed in the hope that it will be useful, but 00010 * WITHOUT ANY WARRANTY; without even the implied warranties of 00011 * MERCHANTABILITY, SATISFACTORY QUALITY or FITNESS FOR A PARTICULAR 00012 * PURPOSE. See the applicable version of the GNU Lesser General Public 00013 * License for more details. 00014 * 00015 * You should have received a copy of both the GNU Lesser General Public 00016 * License along with this program. If not, see <http://www.gnu.org/licenses/> 00017 * 00018 * Authored by: Jay Taoko <jaytaoko@inalogic.com> 00019 * 00020 */ 00021 00022 00023 #ifndef TEXTSTRING_H 00024 #define TEXTSTRING_H 00025 00026 #include "Math/MathUtility.h" 00027 00028 namespace nux 00029 { 00030 00031 class NString; 00032 00033 class TCharToUpperCase 00034 { 00035 TCHAR *UpperCaseString; 00036 TCharToUpperCase(); 00037 00038 public: 00042 explicit inline TCharToUpperCase (const TCHAR *Source) 00043 { 00044 if (Source != NULL) 00045 { 00046 UpperCaseString = _tcsdup (Source); // Duplicate string. Allocated with malloc. 00047 00048 t_size i = 0; 00049 00050 while (UpperCaseString[i]) 00051 { 00052 UpperCaseString[i] = _totupper (UpperCaseString[i]); // Conversion is done in place. 00053 ++i; 00054 } 00055 } 00056 else 00057 { 00058 UpperCaseString = NULL; 00059 } 00060 } 00061 00062 inline ~TCharToUpperCase() 00063 { 00064 if (UpperCaseString != NULL) 00065 { 00066 std::free (UpperCaseString); 00067 } 00068 } 00069 00070 inline operator const TCHAR* () const 00071 { 00072 return UpperCaseString; 00073 } 00074 00075 inline operator TCHAR* () const 00076 { 00077 return UpperCaseString; 00078 } 00079 }; 00080 00081 class TCharToLowerCase 00082 { 00083 TCHAR *LowerCaseString; 00084 TCharToLowerCase(); 00085 00086 public: 00090 explicit inline TCharToLowerCase (const TCHAR *Source) 00091 { 00092 if (Source != NULL) 00093 { 00094 LowerCaseString = _tcsdup (Source); // Duplicate string. Allocated with malloc. 00095 00096 t_size i = 0; 00097 00098 while (LowerCaseString[i]) 00099 { 00100 LowerCaseString[i] = _totlower (LowerCaseString[i]); // Conversion is done in place. 00101 ++i; 00102 } 00103 } 00104 else 00105 { 00106 LowerCaseString = NULL; 00107 } 00108 } 00109 00110 inline ~TCharToLowerCase() 00111 { 00112 if (LowerCaseString != NULL) 00113 { 00114 std::free (LowerCaseString); 00115 } 00116 } 00117 00118 inline operator const TCHAR* () const 00119 { 00120 return LowerCaseString; 00121 } 00122 00123 inline operator TCHAR* () const 00124 { 00125 return LowerCaseString; 00126 } 00127 }; 00128 00130 00131 template<typename T> 00132 T ToLowerCase (T c) 00133 { 00134 // Valid for Basic Latin characters in ASCII, UTF8 or Unicode. 00135 if (c >= 'A' && c <= 'Z') 00136 c += 32; 00137 00138 return c; 00139 } 00140 00141 template<typename T> 00142 struct ToLowerCaseFunctor 00143 { 00144 T operator() (T value) 00145 { 00146 return ToLower (value); 00147 } 00148 }; 00149 00150 template<typename T> 00151 T ToUpperCase (T c) 00152 { 00153 // Valid for Basic Latin characters in ASCII, UTF8 or Unicode. 00154 if (c >= 'a' && c <= 'z') 00155 c -= 32; 00156 00157 return c; 00158 } 00159 00160 template<typename T> 00161 struct ToUpperCaseFunctor 00162 { 00163 T operator() (T value) 00164 { 00165 return ToUpperCase (value); 00166 } 00167 }; 00168 00173 template<typename T> 00174 struct LexicographicCompare 00175 { 00176 t_u32 operator() (const T &lhs, const T &rhs) 00177 { 00178 if (lhs < rhs) return -1; 00179 00180 if (rhs < lhs) return 1; 00181 00182 return 0; 00183 } 00184 }; 00185 00190 template<typename T, typename ConversionFunctor> 00191 struct LexicographicCompareWithConversion 00192 { 00193 LexicographicCompareWithConversion() {} 00194 t_u32 operator() (const T &lhs, const T &rhs) 00195 { 00196 T newlhs = m_ConversionFunctor (lhs); 00197 T newrhs = m_ConversionFunctor (rhs); 00198 00199 if (newlhs < newrhs) return -1; 00200 00201 if (newrhs < newlhs) return 1; 00202 00203 return 0; 00204 } 00205 ConversionFunctor m_ConversionFunctor; 00206 }; 00207 00215 template<typename T, typename U> 00216 static t_s32 StringCompareWithOperator (const T *lhs, const T *rhs, U functor) 00217 { 00218 nuxAssert (lhs); 00219 nuxAssert (rhs); 00220 t_s32 result = 0; 00221 00222 while ( (*lhs || *rhs) && !result) 00223 { 00224 result = functor (* (lhs++), * (rhs++) ); 00225 } 00226 00227 return result; 00228 } 00229 00238 template<typename T, typename U> 00239 static t_s32 StringCompareWithOperator (const T *lhs, const T *rhs, t_u32 numCharToCompare, U functor) 00240 { 00241 nuxAssert (lhs); 00242 nuxAssert (rhs); 00243 00244 t_s32 result = 0; 00245 00246 while ( (*lhs || *rhs) && !result && numCharToCompare) 00247 { 00248 result = functor (* (lhs++), * (rhs++) ); 00249 --numCharToCompare; 00250 } 00251 00252 return result; 00253 } 00254 00261 template<typename T> 00262 static t_s32 StringCompare (const T *lhs, const T *rhs) 00263 { 00264 return StringCompareWithOperator (lhs, rhs, LexicographicCompare<T>() ); 00265 } 00266 00273 template<class T> 00274 static t_s32 StringCompare (const T *lhs, const T *rhs, t_u32 len) 00275 { 00276 return StringCompareWithOperator (lhs, rhs, len, LexicographicCompare<T>() ); 00277 } 00278 00279 00286 template<typename T> 00287 static t_s32 StringCompareCaseInsensitive (const T *lhs, const T *rhs) 00288 { 00289 return StringCompareWithOperator (lhs, rhs, LexicographicCompareWithConversion<T, ToLowerCaseFunctor<T> >() ); 00290 } 00291 00292 00299 template<typename T> 00300 static t_u32 StringCopy (T *dest, const T *src) 00301 { 00302 nuxAssert (src); 00303 nuxAssert (dest); 00304 00305 const T *origin = src; 00306 00307 while (*src) 00308 { 00309 * (dest++) = * (src++); 00310 } 00311 00312 *dest = 0; 00313 return (t_u32) (src - origin); 00314 } 00315 00322 template<typename T> 00323 static t_u32 StringCopy (T *dest, t_u32 bufferSize, const T *src, t_u32 lengthToCopy = 0xFFFFFFFF) 00324 { 00325 nuxAssert (src); 00326 nuxAssert (dest); 00327 nuxAssert (bufferSize); 00328 00329 const T *origin = src; 00330 lengthToCopy = Min (lengthToCopy, bufferSize - 1); 00331 T *MaxNullCharPosition = dest + bufferSize - 1; 00332 00333 // Copy src to dst 00334 while (*src && lengthToCopy) 00335 { 00336 * (dest++) = * (src++); 00337 --lengthToCopy; 00338 } 00339 00340 // Terminate string with Null char 00341 t_u32 NumCharCopied = (t_u32) (src - origin); 00342 00343 if (dest < MaxNullCharPosition) 00344 { 00345 *dest = 0; 00346 } 00347 else 00348 { 00349 *MaxNullCharPosition = 0; 00350 00351 if (NumCharCopied) 00352 NumCharCopied = NumCharCopied - 1; 00353 } 00354 00355 return NumCharCopied; 00356 } 00357 00365 template<typename T, typename U> 00366 static T *FindString (const T *src, const T *str, U functor) 00367 { 00368 const T *original = str; 00369 00370 nuxAssert (src); 00371 nuxAssert (str); 00372 00373 while (*src) 00374 { 00375 if (functor (*src, *str) ) 00376 { 00377 if (* (++str) == 0) 00378 { 00379 return (T *) src - (str - original) + 1; 00380 } 00381 } 00382 else 00383 { 00384 str = original; 00385 } 00386 00387 ++src; 00388 } 00389 00390 return 0; 00391 } 00392 00393 template<typename T> 00394 struct EqualFunctor 00395 { 00396 bool operator() (const T &lhs, const T &rhs) 00397 { 00398 return lhs == rhs; 00399 } 00400 }; 00401 00402 template<typename T> 00403 static T *FindString (const T *src, const T *str) 00404 { 00405 return FindString (src, str, EqualFunctor<T>() ); 00406 } 00407 00409 template<class T> 00410 static t_size StringLength (const T *s) 00411 { 00412 nuxAssert (s); 00413 const T *end = s; 00414 00415 while (*end) 00416 { 00417 ++end; 00418 } 00419 00420 return (t_size) (end - s); 00421 } 00422 00423 template<class T> 00424 t_size ToCharString (char *buffer, t_size bufferlen, const char *format, T value) 00425 { 00426 nuxAssert (bufferlen); 00427 nuxAssert (buffer); 00428 00429 #if defined(NUX_OS_WINDOWS) 00430 int res = _snprintf_s (buffer, bufferlen, bufferlen - 1, format, value); 00431 #elif defined(NUX_OS_LINUX) 00432 int res = snprintf (buffer, bufferlen - 1, format, value); 00433 #endif 00434 00435 nuxAssert (res > 0); 00436 nuxAssert (res < (int) bufferlen); 00437 return res; 00438 } 00439 00440 template<class T> 00441 t_s32 ToTCharString (TCHAR *buffer, t_size bufferlen, const TCHAR *format, T value) 00442 { 00443 nuxAssert (bufferlen); 00444 nuxAssert (buffer); 00445 00446 #if defined(NUX_OS_WINDOWS) 00447 int res = _snwprintf_s (buffer, bufferlen, bufferlen - 1, format, value); 00448 #elif defined(NUX_OS_LINUX) 00449 int res = snwprintf (buffer, bufferlen - 1, format, value); 00450 #endif 00451 00452 nuxAssert (res > 0); 00453 nuxAssert (res < (int) bufferlen); 00454 return res; 00455 } 00456 00457 t_size ValueToLiteralString (char *buffer, t_size len, t_u16 value); 00458 t_size ValueToLiteralString (char *buffer, t_size len, t_s16 value); 00459 t_size ValueToLiteralString (char *buffer, t_size len, t_u32 value); 00460 t_size ValueToLiteralString (char *buffer, t_size len, t_s32 value); 00461 t_size ValueToLiteralString (char *buffer, t_size len, t_ulong value); 00462 t_size ValueToLiteralString (char *buffer, t_size len, t_long value); 00463 t_size ValueToLiteralString (char *buffer, t_size len, t_u64 value); 00464 t_size ValueToLiteralString (char *buffer, t_size len, t_s64 value); 00465 t_size ValueToLiteralString (char *buffer, t_size len, t_float value); 00466 t_size ValueToLiteralString (char *buffer, t_size len, t_double value); 00467 t_size ValueToLiteralString (char *buffer, t_size len, t_u8 value); 00468 t_size ValueToLiteralString (char *buffer, t_size len, t_s8 value); 00469 t_size ValueToLiteralString (char *buffer, t_size len, t_schar value); 00470 00471 template<class T> 00472 bool FromCharString (const char *buffer, t_size bufferlen, const char *format, T &value) 00473 { 00474 nuxAssert (buffer); 00475 nuxAssert (bufferlen); 00476 00477 #if defined(NUX_OS_WINDOWS) 00478 t_size res = _snscanf_s (buffer, bufferlen, format, &value); 00479 #elif defined(NUX_OS_LINUX) 00480 t_size res = sscanf (buffer, format, &value); 00481 #endif 00482 00483 nuxAssert (res != 0); 00484 return res != 0; 00485 } 00486 00487 template<class T> 00488 bool FromTCharString (const TCHAR *buffer, t_size bufferlen, const TCHAR *format, T &value) 00489 { 00490 nuxAssert (buffer); 00491 nuxAssert (bufferlen); 00492 00493 #if defined(NUX_OS_WINDOWS) 00494 t_size res = _snwscanf_s (buffer, bufferlen, format, &value); 00495 #elif defined(NUX_OS_LINUX) 00496 t_size res = swscanf (buffer, format, &value); 00497 #endif 00498 00499 nuxAssert (res != 0); 00500 return res != 0; 00501 } 00502 00503 bool ValueFromLiteralString (const char *buffer, t_size len, t_u16 &value); 00504 bool ValueFromLiteralString (const char *buffer, t_size len, t_s16 &value); 00505 bool ValueFromLiteralString (const char *buffer, t_size len, t_u32 &value); 00506 bool ValueFromLiteralString (const char *buffer, t_size len, t_s32 &value); 00507 bool ValueFromLiteralString (const char *buffer, t_size len, t_ulong &value); 00508 bool ValueFromLiteralString (const char *buffer, t_size len, t_long &value); 00509 bool ValueFromLiteralString (const char *buffer, t_size len, t_u64 &value); 00510 bool ValueFromLiteralString (const char *buffer, t_size len, t_s64 &value); 00511 bool ValueFromLiteralString (const char *buffer, t_size len, t_float &value); 00512 bool ValueFromLiteralString (const char *buffer, t_size len, t_double &value); 00513 bool ValueFromLiteralString (const char *buffer, t_size len, t_u8 &value); 00514 bool ValueFromLiteralString (const char *buffer, t_size len, t_s8 &value); 00515 bool ValueFromLiteralString (const char *buffer, t_size len, t_schar &value); 00516 00517 00518 /*----------------------------------------------------------------------------- 00519 String functions. 00520 -----------------------------------------------------------------------------*/ 00521 // Copy Src into Dest. Check length of Dest. Dest is NULL terminated. 00522 TCHAR *Strncpy ( TCHAR *Dest, t_size Size, const TCHAR *Src, t_size Max); 00524 TCHAR *Strncat ( TCHAR *Dest, t_size Size, const TCHAR *Src, t_size Max); 00525 00526 // Search a string inside a string. Return a pointer to the beginning of the searched string if it is found. 00527 // Else, return NULL; 00528 const TCHAR *Strfind (const TCHAR *Str, const TCHAR *Find); 00529 00530 00531 00532 #ifdef WIN32_SECURE 00533 00534 inline int inlTCharStringCopy ( TCHAR *Dest, t_size numberOfElements, const TCHAR *Src ) 00535 { 00536 return _tcscpy_s ( Dest, numberOfElements, Src ); 00537 } 00538 inline int inlCharStringCopy ( char *Dest, t_size numberOfElements, const char *Src ) 00539 { 00540 return strcpy_s ( Dest, numberOfElements, Src ); 00541 } 00542 00544 inline int inlTCharStringConcat ( TCHAR *Dest, t_size numberOfElements, const TCHAR *Src ) 00545 { 00546 return _tcscat_s ( Dest, numberOfElements, Src ); 00547 } 00548 inline int inlCharStringConcat ( char *Dest, t_size numberOfElements, const char *Src ) 00549 { 00550 return strcat_s ( Dest, numberOfElements, Src ); 00551 } 00553 inline int inlStrupr (TCHAR *String, t_size numberOfElements) 00554 { 00555 return _tcsupr_s ( String, numberOfElements ); 00556 } 00557 #else 00558 00559 inline TCHAR *inlStringCopy (TCHAR *Dest, t_size numberOfElements, const TCHAR *Src) 00560 { 00561 return _tcscpy ( Dest, Src ); 00562 } 00564 inline TCHAR *inlTCharStringConcat (TCHAR *Dest, t_size numberOfElements, const TCHAR *Src) 00565 { 00566 return _tcscat ( Dest, Src ); 00567 } 00569 inline TCHAR *inlStrupr (TCHAR *String, t_size numberOfElements) 00570 { 00571 nuxAssert (String); 00572 00573 if (String == 0) 00574 return NULL; 00575 00576 t_size i = 0; 00577 00578 while (String[i]) 00579 { 00580 String[i] = _totupper (String[i]); // Conversion is done in place. 00581 ++i; 00582 } 00583 00584 return String; 00585 } 00586 #endif 00587 00589 inline TCHAR *Strstr ( const TCHAR *String, const TCHAR *Find ) 00590 { 00591 return (TCHAR *) _tcsstr ( String, Find ); 00592 } 00594 inline TCHAR *Strchr ( const TCHAR *String, int c ) 00595 { 00596 return (TCHAR *) _tcschr ( String, c ); 00597 } 00599 inline TCHAR *Strrchr ( const TCHAR *String, int c ) 00600 { 00601 return (TCHAR *) _tcsrchr ( String, c ); 00602 } 00603 00605 inline int TCharStringCompare ( const TCHAR *String1, const TCHAR *String2 ) 00606 { 00607 return _tcscmp ( String1, String2 ); 00608 } 00610 inline int Stricmp ( const TCHAR *String1, const TCHAR *String2 ) 00611 { 00612 return _tcscmp ( (TCHAR *) TCharToLowerCase (String1), (TCHAR *) TCharToLowerCase (String2) ); 00613 } 00614 00615 00616 inline int Strtoi ( const TCHAR *Start, TCHAR **End, int Base ) 00617 { 00618 return _tcstoul ( Start, End, Base ); 00619 } 00620 inline int TCharStringNCompare ( const TCHAR *A, const TCHAR *B, t_size Count ) 00621 { 00622 return _tcsncmp ( A, B, Count ); 00623 } 00624 inline int TCharStringNICompare ( const TCHAR *A, const TCHAR *B, t_size Count ) 00625 { 00626 return _tcsncmp ( (TCHAR *) TCharToLowerCase (A), (TCHAR *) TCharToLowerCase (B), Count ); 00627 } 00628 00630 TCHAR *Strdup (const TCHAR *str); 00631 00633 ANSICHAR *StrdupA ( const ANSICHAR *str); 00634 00636 UNICHAR *StrdupU ( const UNICHAR *str); 00637 00639 VARARG_DECL ( int, static int, return, Snprintf, VARARG_NONE, const TCHAR *, VARARG_EXTRA (TCHAR *Dest) VARARG_EXTRA (int Size) VARARG_EXTRA (int Count), VARARG_EXTRA (Dest) VARARG_EXTRA (Size) VARARG_EXTRA (Count) ); 00640 00641 bool IsLastChar (const TCHAR *CharString, const TCHAR Chr); 00642 00643 // 00644 // Convert an integer to a string. 00645 // 00646 NString Itoa ( int InNum ); 00647 00648 00649 00650 class NString 00651 { 00652 public: 00653 NString(); 00654 NString (const NString &s); 00655 NString (const tstring &s); 00656 NString (const TCHAR &s); 00657 //NString(const TCHAR* s); 00658 NString (const ANSICHAR *s); 00659 NString (const UNICHAR *s); 00660 00661 ~NString(); 00662 NString &operator= (const NString &s); 00663 00664 const tstring &GetTStringRef() const; 00665 //const TCHAR* GetTChar() const; 00666 const TCHAR *GetTCharPtr() const; 00667 00668 t_size Length() const; 00669 t_size Size() const; 00670 void Clear(); 00671 bool IsEmpty() const; 00672 00673 void Erase (t_size Pos, t_size count); 00674 NString &Insert (t_size Pos, const TCHAR *Ptr); 00675 NString &Insert (t_size Pos, const TCHAR *Ptr, t_size Count); 00676 NString &Insert (t_size Pos, const tstring &Str); 00677 NString &Insert (t_size Pos, const tstring &Str, t_size Offset, t_size Count); 00678 NString &Insert (t_size Pos, const NString &Str); 00679 NString &Insert (t_size Pos, const NString &Str, t_size Offset, t_size Count); 00680 NString &Insert (t_size Pos, int Count, const TCHAR &Ch); 00681 00682 const TCHAR &operator[] (t_size ChPos) const; 00683 TCHAR &operator[] (t_size ChPos); 00684 00685 NString &Replace (t_size Pos1, t_size Num1, const TCHAR *Ptr); 00686 NString &Replace (t_size Pos1, t_size Num1, const TCHAR *Ptr, t_size Num2); 00687 NString &Replace (t_size Pos1, t_size Num1, const tstring &Str); 00688 NString &Replace (t_size Pos1, t_size Num1, const tstring &Str, t_size Pos2, t_size Num2); 00689 NString &Replace (t_size Pos1, t_size Num1, const NString &Str); 00690 NString &Replace (t_size Pos1, t_size Num1, const NString &Str, t_size Pos2, t_size Num2); 00691 NString &Replace (t_size Pos1, t_size Num1, t_size Count, TCHAR Ch); 00692 00694 void Reverse(); 00695 00697 NString &SearchAndReplace (TCHAR ChOut, TCHAR ChIn); 00698 00700 t_size FindLastOccurence (const TCHAR &suffix) const; 00702 t_size FindLastOccurence (const TCHAR *suffix) const; 00704 t_size FindLastOccurence (const tstring &suffix) const; 00706 t_size FindLastOccurence (const NString &suffix) const; 00707 00709 t_size FindFirstOccurence (const TCHAR &suffix) const; 00711 t_size FindFirstOccurence (const TCHAR *suffix) const; 00713 t_size FindFirstOccurence (const tstring &suffix) const; 00715 t_size FindFirstOccurence (const NString &suffix) const; 00716 00718 t_size FindNextOccurence (const TCHAR &suffix, t_size start = 0) const; 00720 t_size FindNextOccurence (const TCHAR *suffix, t_size start = 0) const; 00722 t_size FindNextOccurence (const tstring &suffix, t_size start = 0) const; 00724 t_size FindNextOccurence (const NString &suffix, t_size start = 0) const; 00725 00727 t_size FindFirstOccurenceOf (const TCHAR &str) const; 00729 t_size FindFirstOccurenceOf (const TCHAR *str) const; 00731 t_size FindFirstOccurenceOf (const tstring &str) const; 00733 t_size FindFirstOccurenceOf (const NString &str) const; 00734 00736 t_size FindLastOccurenceOf (const TCHAR &str) const; 00738 t_size FindLastOccurenceOf (const TCHAR *str) const; 00740 t_size FindLastOccurenceOf (const tstring &str) const; 00742 t_size FindLastOccurenceOf (const NString &str) const; 00743 00745 t_size Find (NString str, int start = 0); 00747 t_size Find (TCHAR c, int start = 0); 00748 00750 bool IsSuffix (const TCHAR &suffix); 00752 bool IsSuffix (const TCHAR *suffix); 00754 bool IsSuffix (const tstring &suffix); 00756 bool IsSuffix (const NString &suffix); 00757 00759 bool IsPrefix (const TCHAR &prefix); 00761 bool IsPrefix (const TCHAR *prefix); 00763 bool IsPrefix (const tstring &prefix); 00765 bool IsPrefix (const NString &prefix); 00766 00768 void RemoveSuffix (const TCHAR &suffix); 00770 void RemoveSuffix (const TCHAR *suffix); 00772 void RemoveSuffix (const tstring &suffix); 00774 void RemoveSuffix (const NString &suffix); 00775 00777 void RemovePrefix (const TCHAR &prefix); 00779 void RemovePrefix (const TCHAR *prefix); 00781 void RemovePrefix (const tstring &prefix); 00783 void RemovePrefix (const NString &prefix); 00784 00786 NString GetSubString (t_size count) const; 00788 NString GetSubString (t_size start, t_size count) const; 00789 00790 00792 NString Mid (t_size count) const; 00794 NString Mid (t_size start, t_size count) const; 00796 NString Left (t_size N) const; 00798 NString Right (t_size N) const; 00799 00801 NString Trim() const; 00803 NString TrimLeft() const; 00805 NString TrimRight() const; 00806 00808 NString TrimLeft (NString str) const; 00810 NString TrimRight (NString str) const; 00811 00813 00816 TCHAR GetFirstChar() const; 00817 00819 00822 TCHAR GetLastChar() const; 00823 00824 const TCHAR *operator () () const; 00825 const TCHAR *operator * () const; 00826 //operator const TCHAR*() const; 00827 00829 NString &operator += (const TCHAR &sufix); 00831 NString &operator += (const TCHAR *sufix); 00833 NString &operator += (const tstring sufix); 00835 NString &operator += (const NString sufix); 00836 00837 00838 void SplitAtFirstOccurenceOf (const TCHAR *SplitString, NString &Left, NString &Right); 00839 void SplitAtFirstOccurenceOf (const TCHAR &SplitChar, NString &Left, NString &Right); 00840 void SplitAtFirstOccurenceOf (const NString &SplitString, NString &Left, NString &Right); 00841 00842 void SplitAtLastOccurenceOf (const TCHAR *SplitString, NString &Left, NString &Right); 00843 void SplitAtLastOccurenceOf (const TCHAR &SplitChar, NString &Left, NString &Right); 00844 void SplitAtLastOccurenceOf (const NString &SplitString, NString &Left, NString &Right); 00845 00846 void ParseToArray (std::vector<NString>& StringArray, const NString &delimiter); 00847 00848 friend bool operator!= (const NString &left, const NString &right); 00849 friend bool operator== (const NString &left, const NString &right); 00850 friend bool operator< (const NString &left, const NString &right); 00851 friend bool operator<= (const NString &left, const NString &right); 00852 friend bool operator> (const NString &left, const NString &right); 00853 friend bool operator>= (const NString &left, const NString &right); 00854 00855 00856 friend NString operator+ (const NString &left, const NString &right); 00857 00858 friend NString operator+ (const NString &left, const TCHAR *right); 00859 friend NString operator+ (const NString &left, const TCHAR right); 00860 00861 friend NString operator+ (const TCHAR *left, const NString &right); 00862 friend NString operator+ (const TCHAR left, const NString &right); 00863 00864 friend tostream &operator << (tostream &o, const NString &s); 00865 00871 VARARG_DECL ( static NString, static NString, return, Printf, VARARG_NONE, const TCHAR *, VARARG_NONE, VARARG_NONE ); 00872 00873 public: 00874 tstring m_string; 00875 }; 00876 00877 } 00878 00879 #endif // TEXTSTRING_H 00880