00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 
00012 
00013 
00014 
00015 
00016 
00017 
00018 
00019 
00020 
00021 
00022 
00023 #ifndef skSTRINGBUFFER_H
00024 #define skSTRINGBUFFER_H
00025 
00026 #include "skString.h"
00027 
00031 class skStringBuffer 
00032 #ifdef __SYMBIAN32__
00033 : public CBase
00034 #endif
00035 {
00036  public:
00041   inline skStringBuffer(USize capacity,USize growth_increment=16);
00042 #ifndef __SYMBIAN32__
00043 
00048   IMPORT_C skStringBuffer(const skString& s,USize growth_increment=16);
00053   IMPORT_C skStringBuffer(const skStringBuffer& s);
00054 #endif
00055 
00058   IMPORT_C virtual ~skStringBuffer();
00063   IMPORT_C skStringBuffer& operator=(const skStringBuffer& s);
00069   IMPORT_C void append(Char ch);
00075   IMPORT_C void append(const skString& s);
00081   IMPORT_C void append(const Char * s);
00082 #ifdef __SYMBIAN32__
00083 
00089   IMPORT_C void append(const TDesC& s);
00090 #endif
00091 
00096   IMPORT_C skString toString() ;
00102   IMPORT_C skString toStringCopy() const;
00103 #ifdef __SYMBIAN32__
00104 
00109   inline TPtrC ptr() const;
00110 #else
00111 
00117   IMPORT_C operator const Char * () const;
00118 #endif
00119 
00122   inline void reset();
00127   inline USize length() const;
00132   inline USize capacity() const;
00133  private:
00139   void ensureCapacity(USize capacity);
00141   Char * m_Buffer;
00143   USize m_Length;
00145   USize m_Capacity;
00147   USize m_GrowthIncrement;
00148 };
00149 
00150 
00151 inline skStringBuffer::skStringBuffer(USize length,USize growth_increment)
00152 
00153   : m_Buffer(0),m_Length(0),m_Capacity(length+1),m_GrowthIncrement(growth_increment)
00154 {
00155 }
00156 
00157 inline USize skStringBuffer::length() const
00158 
00159 {
00160   return m_Length;
00161 }
00162 
00163 inline USize skStringBuffer::capacity() const
00164 
00165 {
00166   return m_Capacity;
00167 }
00168 
00169 inline void skStringBuffer::reset()
00170 
00171 {
00172   m_Length=0;
00173   if (m_Buffer)
00174     m_Buffer[0]=0;
00175 }
00176 #ifdef __SYMBIAN32__
00177 
00178 inline TPtrC skStringBuffer::ptr() const 
00179 
00180 {
00181   if (m_Buffer)
00182     return TPtrC((const TUint16 *)(m_Buffer),m_Length);
00183   else
00184     return TPtrC();
00185 }
00186 #endif
00187 #endif