src/include/common/base/util/WString.h

00001 /*
00002  * Copyright (C) 2003-2007 Funambol
00003  *
00004  * This program is free software; you can redistribute it and/or modify
00005  * it under the terms of the GNU General Public License as published by
00006  * the Free Software Foundation; either version 2 of the License, or
00007  * (at your option) any later version.
00008  *
00009  * This program is distributed in the hope that it will be useful,
00010  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012  * GNU General Public License for more details.
00013  *
00014  * You should have received a copy of the GNU General Public License
00015  * along with this program; if not, write to the Free Software
00016  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00017  */
00018 
00019 #ifndef INCL_WSTRING
00020 #define INCL_WSTRING
00021 
00023 #include "base/util/ArrayElement.h"
00024 
00025 class ArrayList;
00026 class StringBuffer;
00027 
00028 #define DEFAULT_DELIMITER (const WCHAR* )TEXT(" ")
00029 
00033 class WString: public ArrayElement {
00034     public:
00035         // Constant value for an invalid pos (returned by find and rfind)
00036         static const size_t npos;
00037 
00038         WString(const WCHAR* str = NULL, size_t len = npos) EXTRA_SECTION_00;
00039 
00040         WString(const WString &sb) EXTRA_SECTION_00;
00041 
00042         ~WString() EXTRA_SECTION_00;
00043 
00044         WString& append(const WCHAR*) EXTRA_SECTION_00;
00045 
00046         WString& append(unsigned long u, BOOL sign = TRUE) EXTRA_SECTION_00;
00047 
00048         WString& append(WString& s) EXTRA_SECTION_00;
00049 
00050         WString& append(WString* str) EXTRA_SECTION_00;
00051 
00052         WString& set(const WCHAR*) EXTRA_SECTION_00;
00053 
00057         WString& reset() EXTRA_SECTION_00;
00058 
00062         const WCHAR* getChars() const EXTRA_SECTION_00;
00063         inline const WCHAR* c_str() const { return s; } EXTRA_SECTION_00;
00064 
00070         size_t find(const WCHAR *str, size_t pos = 0) const EXTRA_SECTION_00;
00071 
00077         size_t ifind(const WCHAR *str, size_t pos = 0) const EXTRA_SECTION_00;
00078 
00085         size_t replace(const WCHAR *from, const WCHAR *to, size_t pos = 0) EXTRA_SECTION_00;
00091         int replaceAll(const WCHAR *from, const WCHAR *to, size_t pos = 0) EXTRA_SECTION_00;
00092 
00099         ArrayList &split (ArrayList &tokens,
00100                           const WCHAR *delimiters = DEFAULT_DELIMITER ) const EXTRA_SECTION_00;
00101 
00108         WString& join(ArrayList &tokens, const WCHAR *separator);
00109 
00116         WString substr(size_t pos, size_t len = npos) const EXTRA_SECTION_00;
00117 
00122         unsigned long length() const EXTRA_SECTION_00;
00123 
00127         void reserve(size_t len) EXTRA_SECTION_00;
00128 
00132         WString& upperCase() EXTRA_SECTION_00 ;
00133 
00137         WString& lowerCase() EXTRA_SECTION_00 ;
00138 
00142         bool icmp(const WCHAR *sc) const EXTRA_SECTION_00 ;
00143 
00147         bool empty() const EXTRA_SECTION_00;
00148 
00152         bool null() const EXTRA_SECTION_00;
00153         
00157         ArrayElement* clone() EXTRA_SECTION_00 ;
00158 
00162         WString& operator= (const WCHAR* sc) EXTRA_SECTION_00 ;
00163         WString& operator= (const WString& s) EXTRA_SECTION_00 ;
00164         WString& operator= (const StringBuffer& s) EXTRA_SECTION_00 ;
00165         WString& operator+= (const WCHAR* sc) EXTRA_SECTION_00 ;
00166         WString& operator+= (const WString& s) EXTRA_SECTION_00 ;
00167         WString& operator+= (const StringBuffer& s) EXTRA_SECTION_00 ;
00168         bool operator== (const WCHAR* sc) const EXTRA_SECTION_00 ;
00169         bool operator== (const WString& sb) const EXTRA_SECTION_00 ;
00170         bool operator== (const StringBuffer& sb) const EXTRA_SECTION_00 ;
00171         bool operator!= (const WCHAR* sc) const EXTRA_SECTION_00 ;
00172         bool operator!= (const WString& s) const EXTRA_SECTION_00 ;
00173         bool operator!= (const StringBuffer& sb) const EXTRA_SECTION_00 ;
00174         
00175         inline operator const WCHAR*() const { return s; } EXTRA_SECTION_00 ;
00176         
00177     private:
00178         WCHAR* s;
00179         size_t size;
00180 
00181         // Allocator
00182         void getmem(size_t len);
00183         // Deallocator
00184         void freemem();
00185 };
00186 
00187 WString operator+(const WString& x, const WCHAR *y);
00188 
00190 #endif
00191 

Generated on Fri Apr 27 12:29:18 2007 for Funambol C++ Client Library by  doxygen 1.5.2