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

skStringBuffer.h

00001 /*
00002   Copyright 1996-2003
00003   Simon Whiteside
00004 
00005     This library is free software; you can redistribute it and/or
00006     modify it under the terms of the GNU Lesser General Public
00007     License as published by the Free Software Foundation; either
00008     version 2 of the License, or (at your option) any later version.
00009 
00010     This library is distributed in the hope that it will be useful,
00011     but WITHOUT ANY WARRANTY; without even the implied warranty of
00012     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013     Lesser General Public License for more details.
00014 
00015     You should have received a copy of the GNU Lesser General Public
00016     License along with this library; if not, write to the Free Software
00017     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00018 
00019 * $Id: skStringBuffer_8h-source.html,v 1.7 2004/12/17 21:31:15 sdw Exp $
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

Generated on Fri Dec 17 20:28:26 2004 for Simkin C++ for Symbian by doxygen1.3