39 #ifndef BLOCXX_STRINGBUFFER_HPP_INCLUDE_GUARD_
40 #define BLOCXX_STRINGBUFFER_HPP_INCLUDE_GUARD_
41 #include "blocxx/BLOCXX_config.h"
48 namespace BLOCXX_NAMESPACE
54 #if defined(BLOCXX_AIX)
55 static const size_t BLOCXX_DEFAULT_ALLOCATION_UNIT;
57 static const size_t BLOCXX_DEFAULT_ALLOCATION_UNIT = 128;
59 StringBuffer(
size_t allocSize = BLOCXX_DEFAULT_ALLOCATION_UNIT);
77 size_t len = ::strlen(str);
79 ::strcpy(m_bfr+m_len, str);
95 {
return append(str); }
97 {
return append(arg); }
108 #if defined(BLOCXX_INT32_IS_INT) && defined(BLOCXX_INT64_IS_LONG_LONG)
118 char operator[] (
size_t ndx)
const;
137 void truncate(
size_t index);
145 const char* getLine(std::istream& is,
bool resetBuffer=
true);
147 bool endsWith(
char ch)
const;
148 bool startsWith(
char ch)
const;
154 const char*
c_str()
const {
return m_bfr; }
155 bool equals(
const char* arg)
const;
159 void checkAvail(
size_t len=1)
161 size_t freeSpace = m_allocated - (m_len+1);
165 size_t toalloc = m_allocated * 2 + len;
166 char* bfr =
new char[toalloc];
167 ::memmove(bfr, m_bfr, m_len);
169 m_allocated = toalloc;