Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members

FXString.h

Go to the documentation of this file.
00001 /********************************************************************************
00002 *                                                                               *
00003 *                           S t r i n g   O b j e c t                           *
00004 *                                                                               *
00005 *********************************************************************************
00006 * Copyright (C) 1997,2006 by Jeroen van der Zijp.   All Rights Reserved.        *
00007 *********************************************************************************
00008 * This library is free software; you can redistribute it and/or                 *
00009 * modify it under the terms of the GNU Lesser General Public                    *
00010 * License as published by the Free Software Foundation; either                  *
00011 * version 2.1 of the License, or (at your option) any later version.            *
00012 *                                                                               *
00013 * This library is distributed in the hope that it will be useful,               *
00014 * but WITHOUT ANY WARRANTY; without even the implied warranty of                *
00015 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU             *
00016 * Lesser General Public License for more details.                               *
00017 *                                                                               *
00018 * You should have received a copy of the GNU Lesser General Public              *
00019 * License along with this library; if not, write to the Free Software           *
00020 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA.    *
00021 *********************************************************************************
00022 * $Id: FXString.h,v 1.120 2006/02/20 03:32:12 fox Exp $                         *
00023 ********************************************************************************/
00024 #ifndef FXSTRING_H
00025 #define FXSTRING_H
00026 
00027 namespace FX {
00028 
00029 
00030 /**
00031 * FXString provides essential string manipulation capabilities.
00032 */
00033 class FXAPI FXString {
00034 private:
00035   FXchar* str;
00036 public:
00037   static const FXchar null[];
00038   static const FXchar hex[17];
00039   static const FXchar HEX[17];
00040 public:
00041   static const signed char utfBytes[256];
00042 public:
00043 
00044   /// Create empty string
00045   FXString();
00046 
00047   /// Copy construct
00048   FXString(const FXString& s);
00049 
00050   /// Construct and init from string
00051   FXString(const FXchar* s);
00052 
00053   /// Construct and init from wide character string
00054   FXString(const FXwchar* s);
00055 
00056   /// Construct and init from narrow character string
00057   FXString(const FXnchar* s);
00058 
00059   /// Construct and init with substring
00060   FXString(const FXchar* s,FXint n);
00061 
00062   /// Construct and init with wide character substring
00063   FXString(const FXwchar* s,FXint n);
00064 
00065   /// Construct and init with narrow character substring
00066   FXString(const FXnchar* s,FXint n);
00067 
00068   /// Construct and fill with constant
00069   FXString(FXchar c,FXint n);
00070 
00071   /// Length of text in bytes
00072   FXint length() const { return *(((FXint*)str)-1); }
00073 
00074   /// Change the length of the string to len
00075   void length(FXint len);
00076 
00077   /// Count number of utf8 characters
00078   FXint count() const;
00079 
00080   /// Count number of utf8 characters in subrange
00081   FXint count(FXint pos,FXint len) const;
00082 
00083   /// Return byte offset of utf8 character at index
00084   FXint offset(FXint indx) const;
00085 
00086   /// Return index of utf8 character at byte offset
00087   FXint index(FXint offs) const;
00088 
00089   /// Validate position to point to begin of utf8 character
00090   FXint validate(FXint p) const;
00091 
00092   /// Return extent of utf8 character at position
00093   FXint extent(FXint p) const { return utfBytes[(FXuchar)str[p]]; }
00094 
00095   /// Return start of next utf8 character
00096   FXint inc(FXint p) const;
00097 
00098   /// Return start of previous utf8 character
00099   FXint dec(FXint p) const;
00100 
00101   /// Get text contents
00102   const FXchar* text() const { return (const FXchar*)str; }
00103 
00104   /// See if string is empty
00105   bool empty() const { return (((FXint*)str)[-1]==0); }
00106 
00107   /// See if string is empty
00108   bool operator!() const { return (((FXint*)str)[-1]==0); }
00109 
00110   /// Return a non-const reference to the ith character
00111   FXchar& operator[](FXint i){ return str[i]; }
00112 
00113   /// Return a const reference to the ith character
00114   const FXchar& operator[](FXint i) const { return str[i]; }
00115 
00116   /// Return a non-const reference to the ith character
00117   FXchar& at(FXint i){ return str[i]; }
00118 
00119   /// Return a const reference to the ith character
00120   const FXchar& at(FXint i) const { return str[i]; }
00121 
00122   /// Return wide character starting at offset i
00123   FXwchar wc(FXint i) const;
00124 
00125   /// Assign a string to this
00126   FXString& operator=(const FXchar* s);
00127 
00128   /// Assign a wide character string to this
00129   FXString& operator=(const FXwchar* s);
00130 
00131   /// Assign a narrow character string to this
00132   FXString& operator=(const FXnchar* s);
00133 
00134   /// Assign another string to this
00135   FXString& operator=(const FXString& s);
00136 
00137   /// Convert to lower case
00138   FXString& lower();
00139 
00140   /// Convert to upper case
00141   FXString& upper();
00142 
00143   /// Return num partition(s) beginning at start from a string separated by delimiters delim.
00144   FXString section(FXchar delim,FXint start,FXint num=1) const;
00145 
00146   /// Return num partition(s) beginning at start from a string separated by set of delimiters from delim of size n
00147   FXString section(const FXchar* delim,FXint n,FXint start,FXint num) const;
00148 
00149   /// Return num partition(s) beginning at start from a string separated by set of delimiters from delim.
00150   FXString section(const FXchar* delim,FXint start,FXint num=1) const;
00151 
00152   /// Return num partition(s) beginning at start from a string separated by set of delimiters from delim.
00153   FXString section(const FXString& delim,FXint start,FXint num=1) const;
00154 
00155   /// Adopt string s, leaving s empty
00156   FXString& adopt(FXString& s);
00157 
00158   /// Assign character c to this string
00159   FXString& assign(FXchar c);
00160 
00161   /// Assign n characters c to this string
00162   FXString& assign(FXchar c,FXint n);
00163 
00164   /// Assign first n characters of string s to this string
00165   FXString& assign(const FXchar *s,FXint n);
00166 
00167   /// Assign first n characters of wide character string s to this string
00168   FXString& assign(const FXwchar *s,FXint n);
00169 
00170   /// Assign first n characters of narrow character string s to this string
00171   FXString& assign(const FXnchar *s,FXint n);
00172 
00173   /// Assign string s to this string
00174   FXString& assign(const FXchar* s);
00175 
00176   /// Assign wide character string s to this string
00177   FXString& assign(const FXwchar* s);
00178 
00179   /// Assign narrow character string s to this string
00180   FXString& assign(const FXnchar* s);
00181 
00182   /// Assign string s to this string
00183   FXString& assign(const FXString& s);
00184 
00185   /// Insert character at specified position
00186   FXString& insert(FXint pos,FXchar c);
00187 
00188   /// Insert n characters c at specified position
00189   FXString& insert(FXint pos,FXchar c,FXint n);
00190 
00191   /// Insert first n characters of string at specified position
00192   FXString& insert(FXint pos,const FXchar* s,FXint n);
00193 
00194   /// Insert first n characters of wide character string at specified position
00195   FXString& insert(FXint pos,const FXwchar* s,FXint n);
00196 
00197   /// Insert first n characters of narrow character string at specified position
00198   FXString& insert(FXint pos,const FXnchar* s,FXint n);
00199 
00200   /// Insert string at specified position
00201   FXString& insert(FXint pos,const FXchar* s);
00202 
00203   /// Insert wide character string at specified position
00204   FXString& insert(FXint pos,const FXwchar* s);
00205 
00206   /// Insert narrow character string at specified position
00207   FXString& insert(FXint pos,const FXnchar* s);
00208 
00209   /// Insert string at specified position
00210   FXString& insert(FXint pos,const FXString& s);
00211 
00212   /// Prepend string with input character
00213   FXString& prepend(FXchar c);
00214 
00215   /// Prepend string with n characters c
00216   FXString& prepend(FXchar c,FXint n);
00217 
00218   /// Prepend first n characters of string s
00219   FXString& prepend(const FXchar* s,FXint n);
00220 
00221   /// Prepend first n characters of wide character string s
00222   FXString& prepend(const FXwchar* s,FXint n);
00223 
00224   /// Prepend first n characters of narrow character string s
00225   FXString& prepend(const FXnchar* s,FXint n);
00226 
00227   /// Prepend string with string s
00228   FXString& prepend(const FXchar* s);
00229 
00230   /// Prepend string with wide character string
00231   FXString& prepend(const FXwchar* s);
00232 
00233   /// Prepend string with narrow character string
00234   FXString& prepend(const FXnchar* s);
00235 
00236   /// Prepend string with string s
00237   FXString& prepend(const FXString& s);
00238 
00239   /// Append character c to this string
00240   FXString& append(FXchar c);
00241 
00242   /// Append n characters c to this string
00243   FXString& append(FXchar c,FXint n);
00244 
00245   /// Append first n characters of string s to this string
00246   FXString& append(const FXchar* s,FXint n);
00247 
00248   /// Append first n characters of wide character string s to this string
00249   FXString& append(const FXwchar* s,FXint n);
00250 
00251   /// Append first n characters of narrow character string s to this string
00252   FXString& append(const FXnchar* s,FXint n);
00253 
00254   /// Append string s to this string
00255   FXString& append(const FXchar* s);
00256 
00257   /// Append wide character string s to this string
00258   FXString& append(const FXwchar* s);
00259 
00260   /// Append narrow character string s to this string
00261   FXString& append(const FXnchar* s);
00262 
00263   /// Append string s to this string
00264   FXString& append(const FXString& s);
00265 
00266   /// Replace a single character
00267   FXString& replace(FXint pos,FXchar c);
00268 
00269   /// Replace the m characters at pos with n characters c
00270   FXString& replace(FXint pos,FXint m,FXchar c,FXint n);
00271 
00272   /// Replaces the m characters at pos with first n characters of string s
00273   FXString& replace(FXint pos,FXint m,const FXchar* s,FXint n);
00274 
00275   /// Replaces the m characters at pos with first n characters of wide character string s
00276   FXString& replace(FXint pos,FXint m,const FXwchar* s,FXint n);
00277 
00278   /// Replaces the m characters at pos with first n characters of narrow character string s
00279   FXString& replace(FXint pos,FXint m,const FXnchar* s,FXint n);
00280 
00281   /// Replace the m characters at pos with string s
00282   FXString& replace(FXint pos,FXint m,const FXchar* s);
00283 
00284   /// Replace the m characters at pos with wide character string s
00285   FXString& replace(FXint pos,FXint m,const FXwchar* s);
00286 
00287   /// Replace the m characters at pos with narrow character string s
00288   FXString& replace(FXint pos,FXint m,const FXnchar* s);
00289 
00290   /// Replace the m characters at pos with string s
00291   FXString& replace(FXint pos,FXint m,const FXString& s);
00292 
00293   /// Move range of m characters from src position to dst position
00294   FXString& move(FXint dst,FXint src,FXint n);
00295 
00296   /// Remove one character
00297   FXString& erase(FXint pos);
00298 
00299   /// Remove substring
00300   FXString& erase(FXint pos,FXint n);
00301 
00302   /// Return number of occurrences of ch in string
00303   FXint contains(FXchar ch) const;
00304 
00305   /// Return number of occurrences of string sub in string
00306   FXint contains(const FXchar* sub,FXint n) const;
00307 
00308   /// Return number of occurrences of string sub in string
00309   FXint contains(const FXchar* sub) const;
00310 
00311   /// Return number of occurrences of string sub in string
00312   FXint contains(const FXString& sub) const;
00313 
00314   /// Substitute one character by another
00315   FXString& substitute(FXchar org,FXchar sub,bool all=true);
00316 
00317   /// Substitute one string by another
00318   FXString& substitute(const FXchar* org,FXint olen,const FXchar *rep,FXint rlen,bool all=true);
00319 
00320   /// Substitute one string by another
00321   FXString& substitute(const FXchar* org,const FXchar *rep,bool all=true);
00322 
00323   /// Substitute one string by another
00324   FXString& substitute(const FXString& org,const FXString& rep,bool all=true);
00325 
00326   /// Simplify whitespace in string
00327   FXString& simplify();
00328 
00329   /// Remove leading and trailing whitespace
00330   FXString& trim();
00331 
00332   /// Remove leading whitespace
00333   FXString& trimBegin();
00334 
00335   /// Remove trailing whitespace
00336   FXString& trimEnd();
00337 
00338   /// Truncate string at pos
00339   FXString& trunc(FXint pos);
00340 
00341   /// Clear
00342   FXString& clear();
00343 
00344   /// Get left most part
00345   FXString left(FXint n) const;
00346 
00347   /// Get right most part
00348   FXString right(FXint n) const;
00349 
00350   /// Get some part in the middle
00351   FXString mid(FXint pos,FXint n) const;
00352 
00353   /**
00354   * Return all characters before the n-th occurrence of ch,
00355   * searching from the beginning of the string. If the character
00356   * is not found, return the entire string.  If n<=0, return
00357   * the empty string.
00358   */
00359   FXString before(FXchar ch,FXint n=1) const;
00360 
00361   /**
00362   * Return all characters before the n-th occurrence of ch,
00363   * searching from the end of the string. If the character
00364   * is not found, return the empty string. If n<=0, return
00365   * the entire string.
00366   */
00367   FXString rbefore(FXchar ch,FXint n=1) const;
00368 
00369   /**
00370   * Return all characters after the nth occurrence of ch,
00371   * searching from the beginning of the string. If the character
00372   * is not found, return the empty string.  If n<=0, return
00373   * the entire string.
00374   */
00375   FXString after(FXchar ch,FXint n=1) const;
00376 
00377   /**
00378   * Return all characters after the nth occurrence of ch,
00379   * searching from the end of the string. If the character
00380   * is not found, return the entire string. If n<=0, return
00381   * the empty string.
00382   */
00383   FXString rafter(FXchar ch,FXint n=1) const;
00384 
00385   /// Find a character, searching forward; return position or -1
00386   FXint find(FXchar c,FXint pos=0) const;
00387 
00388   /// Find a character, searching backward; return position or -1
00389   FXint rfind(FXchar c,FXint pos=2147483647) const;
00390 
00391   /// Find n-th occurrence of character, searching forward; return position or -1
00392   FXint find(FXchar c,FXint pos,FXint n) const;
00393 
00394   /// Find n-th occurrence of character, searching backward; return position or -1
00395   FXint rfind(FXchar c,FXint pos,FXint n) const;
00396 
00397   /// Find a substring of length n, searching forward; return position or -1
00398   FXint find(const FXchar* substr,FXint n,FXint pos) const;
00399 
00400   /// Find a substring of length n, searching backward; return position or -1
00401   FXint rfind(const FXchar* substr,FXint n,FXint pos) const;
00402 
00403   /// Find a substring, searching forward; return position or -1
00404   FXint find(const FXchar* substr,FXint pos=0) const;
00405 
00406   /// Find a substring, searching backward; return position or -1
00407   FXint rfind(const FXchar* substr,FXint pos=2147483647) const;
00408 
00409   /// Find a substring, searching forward; return position or -1
00410   FXint find(const FXString& substr,FXint pos=0) const;
00411 
00412   /// Find a substring, searching backward; return position or -1
00413   FXint rfind(const FXString& substr,FXint pos=2147483647) const;
00414 
00415   /// Find first character in the set of size n, starting from pos; return position or -1
00416   FXint find_first_of(const FXchar* set,FXint n,FXint pos) const;
00417 
00418   /// Find first character in the set, starting from pos; return position or -1
00419   FXint find_first_of(const FXchar* set,FXint pos=0) const;
00420 
00421   /// Find first character in the set, starting from pos; return position or -1
00422   FXint find_first_of(const FXString& set,FXint pos=0) const;
00423 
00424   /// Find first character, starting from pos; return position or -1
00425   FXint find_first_of(FXchar c,FXint pos=0) const;
00426 
00427   /// Find last character in the set of size n, starting from pos; return position or -1
00428   FXint find_last_of(const FXchar* set,FXint n,FXint pos) const;
00429 
00430   /// Find last character in the set, starting from pos; return position or -1
00431   FXint find_last_of(const FXchar* set,FXint pos=2147483647) const;
00432 
00433   /// Find last character in the set, starting from pos; return position or -1
00434   FXint find_last_of(const FXString& set,FXint pos=2147483647) const;
00435 
00436   /// Find last character, starting from pos; return position or -1
00437   FXint find_last_of(FXchar c,FXint pos=0) const;
00438 
00439   /// Find first character NOT in the set of size n, starting from pos; return position or -1
00440   FXint find_first_not_of(const FXchar* set,FXint n,FXint pos) const;
00441 
00442   /// Find first character NOT in the set, starting from pos; return position or -1
00443   FXint find_first_not_of(const FXchar* set,FXint pos=0) const;
00444 
00445   /// Find first character NOT in the set, starting from pos; return position or -1
00446   FXint find_first_not_of(const FXString& set,FXint pos=0) const;
00447 
00448   /// Find first character NOT equal to c, starting from pos; return position or -1
00449   FXint find_first_not_of(FXchar c,FXint pos=0) const;
00450 
00451   /// Find last character NOT in the set of size n, starting from pos; return position or -1
00452   FXint find_last_not_of(const FXchar* set,FXint n,FXint pos) const;
00453 
00454   /// Find last character NOT in the set, starting from pos; return position or -1
00455   FXint find_last_not_of(const FXchar* set,FXint pos=2147483647) const;
00456 
00457   /// Find last character NOT in the set, starting from pos; return position or -1
00458   FXint find_last_not_of(const FXString& set,FXint pos=2147483647) const;
00459 
00460   /// Find last character NOT equal to c, starting from pos; return position or -1
00461   FXint find_last_not_of(FXchar c,FXint pos=0) const;
00462 
00463   /// Format a string a-la printf
00464   FXString& format(const FXchar* fmt,...) FX_PRINTF(2,3) ;
00465   FXString& vformat(const FXchar* fmt,va_list args);
00466 
00467   /// Scan a string a-la scanf
00468   FXint scan(const FXchar* fmt,...) const FX_SCANF(2,3) ;
00469   FXint vscan(const FXchar* fmt,va_list args) const;
00470 
00471   /// Get hash value
00472   FXuint hash() const;
00473 
00474   /// Compare
00475   friend FXAPI FXint compare(const FXchar* s1,const FXchar* s2);
00476   friend FXAPI FXint compare(const FXchar* s1,const FXString& s2);
00477   friend FXAPI FXint compare(const FXString& s1,const FXchar* s2);
00478   friend FXAPI FXint compare(const FXString& s1,const FXString& s2);
00479 
00480   /// Compare up to n
00481   friend FXAPI FXint compare(const FXchar* s1,const FXchar* s2,FXint n);
00482   friend FXAPI FXint compare(const FXchar* s1,const FXString& s2,FXint n);
00483   friend FXAPI FXint compare(const FXString& s1,const FXchar* s2,FXint n);
00484   friend FXAPI FXint compare(const FXString& s1,const FXString& s2,FXint n);
00485 
00486   /// Compare case insensitive
00487   friend FXAPI FXint comparecase(const FXchar* s1,const FXchar* s2);
00488   friend FXAPI FXint comparecase(const FXchar* s1,const FXString& s2);
00489   friend FXAPI FXint comparecase(const FXString& s1,const FXchar* s2);
00490   friend FXAPI FXint comparecase(const FXString& s1,const FXString& s2);
00491 
00492   /// Compare case insensitive up to n
00493   friend FXAPI FXint comparecase(const FXchar* s1,const FXchar* s2,FXint n);
00494   friend FXAPI FXint comparecase(const FXchar* s1,const FXString& s2,FXint n);
00495   friend FXAPI FXint comparecase(const FXString& s1,const FXchar* s2,FXint n);
00496   friend FXAPI FXint comparecase(const FXString& s1,const FXString& s2,FXint n);
00497 
00498   /// Compare with numeric interpretation
00499   friend FXAPI FXint compareversion(const FXchar* s1,const FXchar* s2);
00500   friend FXAPI FXint compareversion(const FXchar* s1,const FXString& s2);
00501   friend FXAPI FXint compareversion(const FXString& s1,const FXchar* s2);
00502   friend FXAPI FXint compareversion(const FXString& s1,const FXString& s2);
00503 
00504   /// Comparison operators
00505   friend FXAPI bool operator==(const FXString& s1,const FXString& s2);
00506   friend FXAPI bool operator==(const FXString& s1,const FXchar* s2);
00507   friend FXAPI bool operator==(const FXchar* s1,const FXString& s2);
00508 
00509   friend FXAPI bool operator!=(const FXString& s1,const FXString& s2);
00510   friend FXAPI bool operator!=(const FXString& s1,const FXchar* s2);
00511   friend FXAPI bool operator!=(const FXchar* s1,const FXString& s2);
00512 
00513   friend FXAPI bool operator<(const FXString& s1,const FXString& s2);
00514   friend FXAPI bool operator<(const FXString& s1,const FXchar* s2);
00515   friend FXAPI bool operator<(const FXchar* s1,const FXString& s2);
00516 
00517   friend FXAPI bool operator<=(const FXString& s1,const FXString& s2);
00518   friend FXAPI bool operator<=(const FXString& s1,const FXchar* s2);
00519   friend FXAPI bool operator<=(const FXchar* s1,const FXString& s2);
00520 
00521   friend FXAPI bool operator>(const FXString& s1,const FXString& s2);
00522   friend FXAPI bool operator>(const FXString& s1,const FXchar* s2);
00523   friend FXAPI bool operator>(const FXchar* s1,const FXString& s2);
00524 
00525   friend FXAPI bool operator>=(const FXString& s1,const FXString& s2);
00526   friend FXAPI bool operator>=(const FXString& s1,const FXchar* s2);
00527   friend FXAPI bool operator>=(const FXchar* s1,const FXString& s2);
00528 
00529   /// Append operators
00530   FXString& operator+=(const FXString& s);
00531   FXString& operator+=(const FXchar* s);
00532   FXString& operator+=(const FXwchar* s);
00533   FXString& operator+=(const FXnchar* s);
00534   FXString& operator+=(FXchar c);
00535 
00536   /// Concatenate one FXString with another
00537   friend FXAPI FXString operator+(const FXString& s1,const FXString& s2);
00538 
00539   /// Concatenate FXString and a string
00540   friend FXAPI FXString operator+(const FXString& s1,const FXchar* s2);
00541   friend FXAPI FXString operator+(const FXString& s1,const FXwchar* s2);
00542   friend FXAPI FXString operator+(const FXString& s1,const FXnchar* s2);
00543 
00544   /// Concatenate string and FXString
00545   friend FXAPI FXString operator+(const FXchar* s1,const FXString& s2);
00546   friend FXAPI FXString operator+(const FXwchar* s1,const FXString& s2);
00547   friend FXAPI FXString operator+(const FXnchar* s1,const FXString& s2);
00548 
00549   /// Concatenate string and single character
00550   friend FXAPI FXString operator+(const FXString& s,FXchar c);
00551   friend FXAPI FXString operator+(FXchar c,const FXString& s);
00552 
00553   /// Saving to a stream
00554   friend FXAPI FXStream& operator<<(FXStream& store,const FXString& s);
00555 
00556   /// Load from a stream
00557   friend FXAPI FXStream& operator>>(FXStream& store,FXString& s);
00558 
00559   /// Format a string a-la printf
00560   friend FXAPI FXString FXStringFormat(const FXchar* fmt,...) FX_PRINTF(1,2) ;
00561   friend FXAPI FXString FXStringVFormat(const FXchar* fmt,va_list args);
00562 
00563   /**
00564   * Convert integer number to a string, using the given number
00565   * base, which must be between 2 and 16.
00566   */
00567   friend FXAPI FXString FXStringVal(FXint num,FXint base);
00568   friend FXAPI FXString FXStringVal(FXuint num,FXint base);
00569 
00570   /**
00571   * Convert long integer number to a string, using the given number
00572   * base, which must be between 2 and 16.
00573   */
00574   friend FXAPI FXString FXStringVal(FXlong num,FXint base);
00575   friend FXAPI FXString FXStringVal(FXulong num,FXint base);
00576 
00577   /**
00578   * Convert real number to a string, using the given procision and
00579   * exponential notation mode, which may be FALSE (never), TRUE (always), or
00580   * MAYBE (when needed).
00581   */
00582   friend FXAPI FXString FXStringVal(FXfloat num,FXint prec,FXint exp);
00583   friend FXAPI FXString FXStringVal(FXdouble num,FXint prec,FXint exp);
00584 
00585   /// Convert string to a integer number, assuming given number base
00586   friend FXAPI FXint FXIntVal(const FXString& s,FXint base);
00587   friend FXAPI FXuint FXUIntVal(const FXString& s,FXint base);
00588 
00589   /// Convert string to long integer number, assuming given number base
00590   friend FXAPI FXlong FXLongVal(const FXString& s,FXint base);
00591   friend FXAPI FXulong FXULongVal(const FXString& s,FXint base);
00592 
00593   /// Convert string into real number
00594   friend FXAPI FXfloat FXFloatVal(const FXString& s);
00595   friend FXAPI FXdouble FXDoubleVal(const FXString& s);
00596 
00597   /// Return utf8 from ascii containing unicode escapes
00598   friend FXAPI FXString fromAscii(const FXString& s);
00599 
00600   /// Return ascii containing unicode escapes from utf8
00601   friend FXAPI FXString toAscii(const FXString& s);
00602 
00603   /// Escape special characters in a string
00604   friend FXAPI FXString escape(const FXString& s);
00605 
00606   /// Unescape special characters in a string
00607   friend FXAPI FXString unescape(const FXString& s);
00608 
00609   /// Return normalized string, i.e. reordering of diacritical marks
00610   friend FXAPI FXString normalize(const FXString& s);
00611 
00612   /// Return normalized decomposition of string
00613   friend FXAPI FXString decompose(const FXString& s,FXuint kind);
00614 
00615   /// Return normalized composition of string; this first performs normalized decomposition
00616   friend FXAPI FXString compose(const FXString& s,FXuint kind);
00617 
00618   /// Swap two strings
00619   friend inline void swap(FXString& a,FXString& b);
00620 
00621   /// Convert to and from dos
00622   friend FXAPI FXString& unixToDos(FXString& str);
00623   friend FXAPI FXString& dosToUnix(FXString& str);
00624 
00625   /// Delete
00626  ~FXString();
00627   };
00628 
00629 
00630 inline void swap(FXString& a,FXString& b){ FXchar *t=a.str; a.str=b.str; b.str=t; }
00631 
00632 extern FXAPI FXint compare(const FXchar* s1,const FXchar* s2);
00633 extern FXAPI FXint compare(const FXchar* s1,const FXString& s2);
00634 extern FXAPI FXint compare(const FXString& s1,const FXchar* s2);
00635 extern FXAPI FXint compare(const FXString& s1,const FXString& s2);
00636 
00637 extern FXAPI FXint compare(const FXchar* s1,const FXchar* s2,FXint n);
00638 extern FXAPI FXint compare(const FXchar* s1,const FXString& s2,FXint n);
00639 extern FXAPI FXint compare(const FXString& s1,const FXchar* s2,FXint n);
00640 extern FXAPI FXint compare(const FXString& s1,const FXString& s2,FXint n);
00641 
00642 extern FXAPI FXint comparecase(const FXchar* s1,const FXchar* s2);
00643 extern FXAPI FXint comparecase(const FXchar* s1,const FXString& s2);
00644 extern FXAPI FXint comparecase(const FXString& s1,const FXchar* s2);
00645 extern FXAPI FXint comparecase(const FXString& s1,const FXString& s2);
00646 
00647 extern FXAPI FXint comparecase(const FXchar* s1,const FXchar* s2,FXint n);
00648 extern FXAPI FXint comparecase(const FXchar* s1,const FXString& s2,FXint n);
00649 extern FXAPI FXint comparecase(const FXString& s1,const FXchar* s2,FXint n);
00650 extern FXAPI FXint comparecase(const FXString& s1,const FXString& s2,FXint n);
00651 
00652 extern FXAPI FXint compareversion(const FXchar* s1,const FXchar* s2);
00653 extern FXAPI FXint compareversion(const FXchar* s1,const FXString& s2);
00654 extern FXAPI FXint compareversion(const FXString& s1,const FXchar* s2);
00655 extern FXAPI FXint compareversion(const FXString& s1,const FXString& s2);
00656 
00657 extern FXAPI bool operator==(const FXString& s1,const FXString& s2);
00658 extern FXAPI bool operator==(const FXString& s1,const FXchar* s2);
00659 extern FXAPI bool operator==(const FXchar* s1,const FXString& s2);
00660 
00661 extern FXAPI bool operator!=(const FXString& s1,const FXString& s2);
00662 extern FXAPI bool operator!=(const FXString& s1,const FXchar* s2);
00663 extern FXAPI bool operator!=(const FXchar* s1,const FXString& s2);
00664 
00665 extern FXAPI bool operator<(const FXString& s1,const FXString& s2);
00666 extern FXAPI bool operator<(const FXString& s1,const FXchar* s2);
00667 extern FXAPI bool operator<(const FXchar* s1,const FXString& s2);
00668 
00669 extern FXAPI bool operator<=(const FXString& s1,const FXString& s2);
00670 extern FXAPI bool operator<=(const FXString& s1,const FXchar* s2);
00671 extern FXAPI bool operator<=(const FXchar* s1,const FXString& s2);
00672 
00673 extern FXAPI bool operator>(const FXString& s1,const FXString& s2);
00674 extern FXAPI bool operator>(const FXString& s1,const FXchar* s2);
00675 extern FXAPI bool operator>(const FXchar* s1,const FXString& s2);
00676 
00677 extern FXAPI bool operator>=(const FXString& s1,const FXString& s2);
00678 extern FXAPI bool operator>=(const FXString& s1,const FXchar* s2);
00679 extern FXAPI bool operator>=(const FXchar* s1,const FXString& s2);
00680 
00681 extern FXAPI FXString operator+(const FXString& s1,const FXString& s2);
00682 
00683 extern FXAPI FXString operator+(const FXString& s1,const FXchar* s2);
00684 extern FXAPI FXString operator+(const FXString& s1,const FXwchar* s2);
00685 extern FXAPI FXString operator+(const FXString& s1,const FXnchar* s2);
00686 
00687 extern FXAPI FXString operator+(const FXchar* s1,const FXString& s2);
00688 extern FXAPI FXString operator+(const FXwchar* s1,const FXString& s2);
00689 extern FXAPI FXString operator+(const FXnchar* s1,const FXString& s2);
00690 
00691 extern FXAPI FXString operator+(const FXString& s,FXchar c);
00692 extern FXAPI FXString operator+(FXchar c,const FXString& s);
00693 
00694 extern FXAPI FXStream& operator<<(FXStream& store,const FXString& s);
00695 extern FXAPI FXStream& operator>>(FXStream& store,FXString& s);
00696 
00697 extern FXAPI FXString FXStringFormat(const FXchar* fmt,...) FX_PRINTF(1,2) ;
00698 extern FXAPI FXString FXStringVFormat(const FXchar* fmt,va_list args);
00699 
00700 extern FXAPI FXString FXStringVal(FXint num,FXint base=10);
00701 extern FXAPI FXString FXStringVal(FXuint num,FXint base=10);
00702 extern FXAPI FXString FXStringVal(FXlong num,FXint base=10);
00703 extern FXAPI FXString FXStringVal(FXulong num,FXint base=10);
00704 extern FXAPI FXString FXStringVal(FXfloat num,FXint prec=6,FXint exp=MAYBE);
00705 extern FXAPI FXString FXStringVal(FXdouble num,FXint prec=6,FXint exp=MAYBE);
00706 
00707 extern FXAPI FXint FXIntVal(const FXString& s,FXint base=10);
00708 extern FXAPI FXuint FXUIntVal(const FXString& s,FXint base=10);
00709 extern FXAPI FXlong FXLongVal(const FXString& s,FXint base=10);
00710 extern FXAPI FXulong FXULongVal(const FXString& s,FXint base=10);
00711 extern FXAPI FXfloat FXFloatVal(const FXString& s);
00712 extern FXAPI FXdouble FXDoubleVal(const FXString& s);
00713 
00714 extern FXAPI FXString fromAscii(const FXString& s);
00715 extern FXAPI FXString toAscii(const FXString& s);
00716 
00717 extern FXAPI FXString escape(const FXString& s);
00718 extern FXAPI FXString unescape(const FXString& s);
00719 
00720 extern FXAPI FXString normalize(const FXString& s);
00721 extern FXAPI FXString decompose(const FXString& s,FXuint kind);
00722 extern FXAPI FXString compose(const FXString& s,FXuint kind);
00723 
00724 extern FXAPI FXString& unixToDos(FXString& str);
00725 extern FXAPI FXString& dosToUnix(FXString& str);
00726 
00727 }
00728 
00729 #endif

Copyright © 1997-2005 Jeroen van der Zijp