Back to index

nux  3.0.0
TextString.h
Go to the documentation of this file.
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         size_t 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         size_t 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     unsigned int 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     unsigned int 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 int StringCompareWithOperator (const T *lhs, const T *rhs, U functor)
00217   {
00218     nuxAssert (lhs);
00219     nuxAssert (rhs);
00220     int 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 int StringCompareWithOperator (const T *lhs, const T *rhs, unsigned int numCharToCompare, U functor)
00240   {
00241     nuxAssert (lhs);
00242     nuxAssert (rhs);
00243 
00244     int 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 int StringCompare (const T *lhs, const T *rhs)
00263   {
00264     return StringCompareWithOperator (lhs, rhs, LexicographicCompare<T>() );
00265   }
00266 
00273   template<class T>
00274   static int StringCompare (const T *lhs, const T *rhs, unsigned int len)
00275   {
00276     return StringCompareWithOperator (lhs, rhs, len, LexicographicCompare<T>() );
00277   }
00278 
00279 
00286   template<typename T>
00287   static int 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 unsigned int 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 (unsigned int) (src - origin);
00314   }
00315 
00322   template<typename T>
00323   static unsigned int StringCopy (T *dest, unsigned int bufferSize, const T *src, unsigned int 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     unsigned int NumCharCopied = (unsigned int) (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 size_t StringLength (const T *s)
00411   {
00412     nuxAssert (s);
00413     const T *end = s;
00414 
00415     while (*end)
00416     {
00417       ++end;
00418     }
00419 
00420     return (size_t) (end - s);
00421   }
00422 
00423   template<class T>
00424   size_t ToCharString (char *buffer, size_t 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   int ToTCharString (TCHAR *buffer, size_t 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   size_t ValueToLiteralString (char *buffer, size_t len, unsigned short     value);
00458   size_t ValueToLiteralString (char *buffer, size_t len, short     value);
00459   size_t ValueToLiteralString (char *buffer, size_t len, unsigned int     value);
00460   size_t ValueToLiteralString (char *buffer, size_t len, int     value);
00461   size_t ValueToLiteralString (char *buffer, size_t len, unsigned long   value);
00462   size_t ValueToLiteralString (char *buffer, size_t len, long    value);
00463   size_t ValueToLiteralString (char *buffer, size_t len, unsigned long long     value);
00464   size_t ValueToLiteralString (char *buffer, size_t len, long long     value);
00465   size_t ValueToLiteralString (char *buffer, size_t len, float   value);
00466   size_t ValueToLiteralString (char *buffer, size_t len, double  value);
00467   size_t ValueToLiteralString (char *buffer, size_t len, unsigned char      value);
00468   size_t ValueToLiteralString (char *buffer, size_t len, char      value);
00469   size_t ValueToLiteralString (char *buffer, size_t len, char   value);
00470 
00471   template<class T>
00472   bool FromCharString (const char *buffer, size_t bufferlen, const char *format, T &value)
00473   {
00474     nuxAssert (buffer);
00475     nuxAssert (bufferlen);
00476 
00477 #if defined(NUX_OS_WINDOWS)
00478     size_t res = _snscanf_s (buffer, bufferlen, format, &value);
00479 #elif defined(NUX_OS_LINUX)
00480     size_t 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, size_t bufferlen, const TCHAR *format, T &value)
00489   {
00490     nuxAssert (buffer);
00491     nuxAssert (bufferlen);
00492 
00493 #if defined(NUX_OS_WINDOWS)
00494     size_t res = _snwscanf_s (buffer, bufferlen, format, &value);
00495 #elif defined(NUX_OS_LINUX)
00496     size_t res = swscanf (buffer, format, &value);
00497 #endif
00498 
00499     nuxAssert (res != 0);
00500     return res != 0;
00501   }
00502 
00503   bool ValueFromLiteralString (const char *buffer, size_t len, unsigned short &value);
00504   bool ValueFromLiteralString (const char *buffer, size_t len, short &value);
00505   bool ValueFromLiteralString (const char *buffer, size_t len, unsigned int &value);
00506   bool ValueFromLiteralString (const char *buffer, size_t len, int &value);
00507   bool ValueFromLiteralString (const char *buffer, size_t len, unsigned long &value);
00508   bool ValueFromLiteralString (const char *buffer, size_t len, long &value);
00509   bool ValueFromLiteralString (const char *buffer, size_t len, unsigned long long &value);
00510   bool ValueFromLiteralString (const char *buffer, size_t len, long long &value);
00511   bool ValueFromLiteralString (const char *buffer, size_t len, float &value);
00512   bool ValueFromLiteralString (const char *buffer, size_t len, double &value);
00513   bool ValueFromLiteralString (const char *buffer, size_t len, unsigned char &value);
00514   bool ValueFromLiteralString (const char *buffer, size_t len, char &value);
00515 
00516 
00517   /*-----------------------------------------------------------------------------
00518   String functions.
00519   -----------------------------------------------------------------------------*/
00520 // Copy Src into Dest. Check length of Dest. Dest is NULL terminated.
00521   TCHAR *Strncpy ( TCHAR *Dest, size_t Size, const TCHAR *Src, size_t Max);
00523   TCHAR *Strncat ( TCHAR *Dest, size_t Size, const TCHAR *Src, size_t Max);
00524 
00525 // Search a string inside a string. Return a pointer to the beginning of the searched string if it is found.
00526 // Else, return NULL;
00527   const TCHAR *Strfind (const TCHAR *Str, const TCHAR *Find);
00528 
00529 
00530 
00531 #ifdef WIN32_SECURE
00532 
00533   inline int inlTCharStringCopy ( TCHAR *Dest, size_t numberOfElements, const TCHAR *Src )
00534   {
00535     return _tcscpy_s ( Dest, numberOfElements, Src );
00536   }
00537   inline int inlCharStringCopy ( char *Dest, size_t numberOfElements, const char *Src )
00538   {
00539     return strcpy_s ( Dest, numberOfElements, Src );
00540   }
00541 
00543   inline int inlTCharStringConcat ( TCHAR *Dest, size_t numberOfElements, const TCHAR *Src )
00544   {
00545     return _tcscat_s ( Dest, numberOfElements, Src );
00546   }
00547   inline int inlCharStringConcat ( char *Dest, size_t numberOfElements, const char *Src )
00548   {
00549     return strcat_s ( Dest, numberOfElements, Src );
00550   }
00552   inline int inlStrupr (TCHAR *String, size_t numberOfElements)
00553   {
00554     return _tcsupr_s ( String, numberOfElements );
00555   }
00556 #else
00557 
00558   inline TCHAR *inlStringCopy (TCHAR *Dest, size_t numberOfElements, const TCHAR *Src)
00559   {
00560     return _tcscpy ( Dest, Src );
00561   }
00563   inline TCHAR *inlTCharStringConcat (TCHAR *Dest, size_t numberOfElements, const TCHAR *Src)
00564   {
00565     return _tcscat ( Dest, Src );
00566   }
00568   inline TCHAR *inlStrupr (TCHAR *String, size_t numberOfElements)
00569   {
00570     nuxAssert (String);
00571 
00572     if (String == 0)
00573       return NULL;
00574 
00575     size_t i = 0;
00576 
00577     while (String[i])
00578     {
00579       String[i] = _totupper (String[i]); // Conversion is done in place.
00580       ++i;
00581     }
00582 
00583     return String;
00584   }
00585 #endif
00586 
00588   inline TCHAR *Strstr ( const TCHAR *String, const TCHAR *Find )
00589   {
00590     return (TCHAR *) _tcsstr ( String, Find );
00591   }
00593   inline TCHAR *Strchr ( const TCHAR *String, int c )
00594   {
00595     return (TCHAR *) _tcschr ( String, c );
00596   }
00598   inline TCHAR *Strrchr ( const TCHAR *String, int c )
00599   {
00600     return (TCHAR *) _tcsrchr ( String, c );
00601   }
00602 
00604   inline int TCharStringCompare ( const TCHAR *String1, const TCHAR *String2 )
00605   {
00606     return _tcscmp ( String1, String2 );
00607   }
00609   inline int Stricmp ( const TCHAR *String1, const TCHAR *String2 )
00610   {
00611     return _tcscmp ( (TCHAR *) TCharToLowerCase (String1), (TCHAR *) TCharToLowerCase (String2) );
00612   }
00613 
00614 
00615   inline int Strtoi ( const TCHAR *Start, TCHAR **End, int Base )
00616   {
00617     return _tcstoul ( Start, End, Base );
00618   }
00619   inline int TCharStringNCompare ( const TCHAR *A, const TCHAR *B, size_t Count )
00620   {
00621     return _tcsncmp ( A, B, Count );
00622   }
00623   inline int TCharStringNICompare ( const TCHAR *A, const TCHAR *B, size_t Count )
00624   {
00625     return _tcsncmp ( (TCHAR *) TCharToLowerCase (A), (TCHAR *) TCharToLowerCase (B), Count );
00626   }
00627 
00629   TCHAR *Strdup (const TCHAR *str);
00630 
00632   ANSICHAR *StrdupA ( const ANSICHAR *str);
00633 
00635   UNICHAR *StrdupU ( const UNICHAR *str);
00636 
00638   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) );
00639 
00640   bool IsLastChar (const TCHAR *CharString, const TCHAR Chr);
00641 
00642 //
00643 // Convert an integer to a string.
00644 //
00645   NString Itoa ( int InNum );
00646 
00647 
00648 
00649   class NString
00650   {
00651   public:
00652     NString();
00653     NString (const NString &s);
00654     NString (const tstring &s);
00655     NString (const TCHAR &s);
00656     //NString(const TCHAR* s);
00657     NString (const ANSICHAR *s);
00658     NString (const UNICHAR *s);
00659 
00660     ~NString();
00661     NString &operator= (const NString &s);
00662 
00663     const tstring &GetTStringRef() const;
00664     //const TCHAR* GetTChar() const;
00665     const TCHAR *GetTCharPtr() const;
00666 
00667     size_t Length() const;
00668     size_t Size() const;
00669     void Clear();
00670     bool IsEmpty() const;
00671 
00672     void Erase (size_t Pos, size_t count);
00673     NString &Insert (size_t Pos, const TCHAR *Ptr);
00674     NString &Insert (size_t Pos, const TCHAR *Ptr, size_t Count);
00675     NString &Insert (size_t Pos, const tstring &Str);
00676     NString &Insert (size_t Pos, const tstring &Str, size_t Offset, size_t Count);
00677     NString &Insert (size_t Pos, const NString &Str);
00678     NString &Insert (size_t Pos, const NString &Str, size_t Offset, size_t Count);
00679     NString &Insert (size_t Pos, int Count, const TCHAR &Ch);
00680 
00681     const TCHAR &operator[] (size_t ChPos) const;
00682     TCHAR &operator[] (size_t ChPos);
00683 
00684     NString &Replace (size_t Pos1, size_t Num1, const TCHAR *Ptr);
00685     NString &Replace (size_t Pos1, size_t Num1, const TCHAR *Ptr, size_t Num2);
00686     NString &Replace (size_t Pos1, size_t Num1, const tstring &Str);
00687     NString &Replace (size_t Pos1, size_t Num1, const tstring &Str, size_t Pos2, size_t Num2);
00688     NString &Replace (size_t Pos1, size_t Num1, const NString &Str);
00689     NString &Replace (size_t Pos1, size_t Num1, const NString &Str, size_t Pos2, size_t Num2);
00690     NString &Replace (size_t Pos1, size_t Num1, size_t Count, TCHAR Ch);
00691 
00693     void Reverse();
00694 
00696     NString &SearchAndReplace (TCHAR ChOut, TCHAR ChIn);
00697 
00699     size_t FindLastOccurence (const TCHAR &suffix) const;
00701     size_t FindLastOccurence (const TCHAR *suffix) const;
00703     size_t FindLastOccurence (const tstring &suffix) const;
00705     size_t FindLastOccurence (const NString &suffix) const;
00706 
00708     size_t FindFirstOccurence (const TCHAR &suffix) const;
00710     size_t FindFirstOccurence (const TCHAR *suffix) const;
00712     size_t FindFirstOccurence (const tstring &suffix) const;
00714     size_t FindFirstOccurence (const NString &suffix) const;
00715 
00717     size_t FindNextOccurence (const TCHAR &suffix, size_t start = 0) const;
00719     size_t FindNextOccurence (const TCHAR *suffix, size_t start = 0) const;
00721     size_t FindNextOccurence (const tstring &suffix, size_t start = 0) const;
00723     size_t FindNextOccurence (const NString &suffix, size_t start = 0) const;
00724 
00726     size_t FindFirstOccurenceOf (const TCHAR &str) const;
00728     size_t FindFirstOccurenceOf (const TCHAR *str) const;
00730     size_t FindFirstOccurenceOf (const tstring &str) const;
00732     size_t FindFirstOccurenceOf (const NString &str) const;
00733 
00735     size_t FindLastOccurenceOf (const TCHAR &str) const;
00737     size_t FindLastOccurenceOf (const TCHAR *str) const;
00739     size_t FindLastOccurenceOf (const tstring &str) const;
00741     size_t FindLastOccurenceOf (const NString &str) const;
00742 
00744     size_t Find (NString str, int start = 0);
00746     size_t Find (TCHAR c, int start = 0);
00747 
00749     bool IsSuffix (const TCHAR &suffix);
00751     bool IsSuffix (const TCHAR *suffix);
00753     bool IsSuffix (const tstring &suffix);
00755     bool IsSuffix (const NString &suffix);
00756 
00758     bool IsPrefix (const TCHAR &prefix);
00760     bool IsPrefix (const TCHAR *prefix);
00762     bool IsPrefix (const tstring &prefix);
00764     bool IsPrefix (const NString &prefix);
00765 
00767     void RemoveSuffix (const TCHAR &suffix);
00769     void RemoveSuffix (const TCHAR *suffix);
00771     void RemoveSuffix (const tstring &suffix);
00773     void RemoveSuffix (const NString &suffix);
00774 
00776     void RemovePrefix (const TCHAR &prefix);
00778     void RemovePrefix (const TCHAR *prefix);
00780     void RemovePrefix (const tstring &prefix);
00782     void RemovePrefix (const NString &prefix);
00783 
00785     NString GetSubString (size_t count) const;
00787     NString GetSubString (size_t start, size_t count) const;
00788 
00789 
00791     NString Mid (size_t count) const;
00793     NString Mid (size_t start, size_t count) const;
00795     NString Left (size_t N) const;
00797     NString Right (size_t N) const;
00798 
00800     NString Trim() const;
00802     NString TrimLeft() const;
00804     NString TrimRight() const;
00805 
00807     NString TrimLeft (NString str) const;
00809     NString TrimRight (NString str) const;
00810 
00812 
00815     TCHAR GetFirstChar() const;
00816 
00818 
00821     TCHAR GetLastChar() const;
00822 
00823     const TCHAR *operator () () const;
00824     const TCHAR *operator * () const;
00825     //operator const TCHAR*() const;
00826 
00828     NString &operator += (const TCHAR &sufix);
00830     NString &operator += (const TCHAR *sufix);
00832     NString &operator += (const tstring sufix);
00834     NString &operator += (const NString sufix);
00835 
00836 
00837     void SplitAtFirstOccurenceOf (const TCHAR *SplitString, NString &Left, NString &Right);
00838     void SplitAtFirstOccurenceOf (const TCHAR &SplitChar, NString &Left, NString &Right);
00839     void SplitAtFirstOccurenceOf (const NString &SplitString, NString &Left, NString &Right);
00840 
00841     void SplitAtLastOccurenceOf (const TCHAR *SplitString, NString &Left, NString &Right);
00842     void SplitAtLastOccurenceOf (const TCHAR &SplitChar, NString &Left, NString &Right);
00843     void SplitAtLastOccurenceOf (const NString &SplitString, NString &Left, NString &Right);
00844 
00845     void ParseToArray (std::vector<NString>& StringArray, const NString &delimiter);
00846 
00847     friend bool operator!= (const NString &left, const NString &right);
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 
00854 
00855     friend NString operator+ (const NString &left, const NString &right);
00856 
00857     friend NString operator+ (const NString &left, const TCHAR *right);
00858     friend NString operator+ (const NString &left, const TCHAR right);
00859 
00860     friend NString operator+ (const TCHAR *left, const NString &right);
00861     friend NString operator+ (const TCHAR left, const NString &right);
00862 
00863     friend tostream &operator << (tostream &o, const NString &s);
00864 
00870     VARARG_DECL ( static NString, static NString, return, Printf, VARARG_NONE, const TCHAR *, VARARG_NONE, VARARG_NONE );
00871 
00872   public:
00873     tstring m_string;
00874   };
00875 
00876 }
00877 
00878 #endif // TEXTSTRING_H
00879