2 // file: SC_StringBuffer.h
3 // copyright: 2003 stefan kersten <steve@k-hornz.de>
6 // This program is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU General Public License as
8 // published by the Free Software Foundation; either version 2 of the
9 // License, or (at your option) any later version.
11 // This program is distributed in the hope that it will be useful, but
12 // WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // General Public License for more details.
16 // You should have received a copy of the GNU General Public License
17 // along with this program; if not, write to the Free Software
18 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
21 #ifndef SC_STRINGBUFFER_H_INCLUDED
22 #define SC_STRINGBUFFER_H_INCLUDED
27 // =====================================================================
28 // SC_StringBuffer - Autogrowing string buffer.
29 // =====================================================================
34 SC_StringBuffer(size_t initialSize
=0);
35 SC_StringBuffer(const SC_StringBuffer
& other
);
38 size_t getCapacity() const { return mCapacity
; }
39 size_t getSize() const { return mPtr
- mData
; }
40 size_t getRemaining() const { return mCapacity
- getSize(); }
41 char* getData() const { return mData
; }
43 bool isEmpty() const { return getSize() == 0; }
45 void finish() { append('\0'); }
46 void reset() { mPtr
= mData
; }
47 void append(const char* src
, size_t len
);
49 void append(const char* str
);
50 void vappendf(const char* fmt
, va_list vargs
);
51 void appendf(const char* fmt
, ...);
56 kGrowMask
= kGrowAlign
- 1
59 void growBy(size_t request
);
67 #endif // SC_STRINGBUFFER_H_INCLUDED