src/include/common/base/util/StringBuffer.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_BASE_STRING_BUFFER
00020 #define INCL_BASE_STRING_BUFFER
00021 
00023 #include "base/util/ArrayElement.h"
00024 
00025 #include <stdarg.h>
00026 
00027 class ArrayList;
00028 
00032 class StringBuffer: public ArrayElement {
00033     public:
00034         // Constant value for an invalid pos (returned by find and rfind)
00035         static const size_t npos;
00036 
00037         StringBuffer(const char*  str = NULL, size_t len = npos) EXTRA_SECTION_00;
00038 
00039         StringBuffer(const StringBuffer &sb) EXTRA_SECTION_00;
00040 
00041         StringBuffer(const void* str, size_t len) EXTRA_SECTION_00;
00042 
00043         ~StringBuffer() EXTRA_SECTION_00;
00044 
00045         StringBuffer& append(const char* ) EXTRA_SECTION_00;
00046 
00047         StringBuffer& append(unsigned long u, BOOL sign = TRUE) EXTRA_SECTION_00;
00048 
00049         StringBuffer& append(StringBuffer& s) EXTRA_SECTION_00;
00050 
00051         StringBuffer& append(StringBuffer* str) EXTRA_SECTION_00;
00052 
00053         StringBuffer& set(const char* ) EXTRA_SECTION_00;
00054 
00060         StringBuffer& sprintf(const char* format, ...) EXTRA_SECTION_00
00061 #ifdef __GNUC__
00062             /* enables GCC checking of format <-> parameter mismatches */
00063             __attribute__ ((format (printf, 2, 3)))
00064 #endif
00065             ;
00066 
00072         StringBuffer& vsprintf(const char* format, va_list ap) EXTRA_SECTION_00
00073 #ifdef __GNUC__
00074             /* enables GCC checking of format <-> parameter mismatches */
00075             __attribute__ ((format (printf, 2, 0)))
00076 #endif
00077             ;
00078 
00079 
00083         StringBuffer& reset() EXTRA_SECTION_00;
00084 
00088         const char*  getChars() const EXTRA_SECTION_00;
00089         inline const char*  c_str() const { return s; } EXTRA_SECTION_00;
00090 
00097         size_t find(const char *str, size_t pos = 0) const EXTRA_SECTION_00;
00098 
00104         size_t ifind(const char *str, size_t pos = 0) const EXTRA_SECTION_00;
00105 
00111         size_t rfind(const char *str, size_t pos = 0) const EXTRA_SECTION_00;
00112 
00119         size_t replace(const char *from, const char *to, size_t pos = 0) EXTRA_SECTION_00;
00125         int replaceAll(const char *from, const char *to, size_t pos = 0) EXTRA_SECTION_00;
00126 
00133         ArrayList &split (ArrayList &tokens,
00134                           const char *delimiters = " ") const EXTRA_SECTION_00;
00135 
00142         StringBuffer& join(ArrayList &tokens, const char *separator);
00143 
00150         StringBuffer substr(size_t pos, size_t len = npos) const EXTRA_SECTION_00;
00151 
00156         unsigned long length() const EXTRA_SECTION_00;
00157 
00161         void reserve(size_t len) EXTRA_SECTION_00;
00162 
00166         StringBuffer& upperCase() EXTRA_SECTION_00 ;
00167 
00171         StringBuffer& lowerCase() EXTRA_SECTION_00 ;
00172 
00176         bool icmp(const char *sc) const EXTRA_SECTION_00 ;
00177 
00181         bool empty() const EXTRA_SECTION_00;
00182 
00186         bool null() const EXTRA_SECTION_00;
00187         
00191         ArrayElement* clone() EXTRA_SECTION_00 ;
00192 
00196         StringBuffer& operator= (const char*  sc) EXTRA_SECTION_00 ;
00197         StringBuffer& operator= (const StringBuffer& s) EXTRA_SECTION_00 ;
00198         StringBuffer& operator+= (const char*  sc) EXTRA_SECTION_00 ;
00199         StringBuffer& operator+= (const StringBuffer& s) EXTRA_SECTION_00 ;
00200         bool operator== (const char*  sc) const EXTRA_SECTION_00 ;
00201         bool operator== (const StringBuffer& sb) const EXTRA_SECTION_00 ;
00202         bool operator!= (const char*  sc) const EXTRA_SECTION_00 ;
00203         bool operator!= (const StringBuffer& s) const EXTRA_SECTION_00 ;
00204         
00205         operator const char* () const { return s; } EXTRA_SECTION_00 ;
00206         
00207     private:
00208         char*  s;
00209         size_t size;
00210 
00211         // Allocator
00212         void getmem(size_t len);
00213         // Deallocator
00214         void freemem();
00215 };
00216 
00217 StringBuffer operator+(const StringBuffer& x, const char *y);
00218 
00220 #endif
00221 

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