29 #ifndef _GLIBCXX_ALGORITHM
42 void set_pos(
size_t toPos) {
44 if (data) data[pos] = 0;
46 void inc_pos(
size_t inc) { set_pos(pos+inc); }
48 char *release_mem(
size_t& size) {
56 void assign_mem(
char *
block,
size_t blocksize) {
62 buffer_size = blocksize;
67 void alloc_mem(
size_t blocksize) {
71 assign_mem(ARB_alloc<char>(blocksize), blocksize);
73 void realloc_mem(
size_t newsize) {
74 if (!data) alloc_mem(newsize);
78 buffer_size = newsize;
83 void ensure_mem(
size_t needed_size) {
85 size_t whole_needed_size = pos+needed_size+1;
86 if (buffer_size<whole_needed_size) {
87 size_t next_size = (whole_needed_size * 3) >> 1;
88 realloc_mem(next_size);
104 alloc_mem(buffersize);
123 return null2empty(data);
131 size_t s;
return release_mem(s);
135 if (buffer_size > (pos*2) && buffer_size>1000) {
147 set_pos(pos<byte_count ? 0 : pos-byte_count);
150 void cut(
const size_t at,
const size_t byte_count) {
152 const size_t keepFrom = at+byte_count;
156 memmove(data+at, data+keepFrom, restlen+1);
168 std::swap(buffer_size, other.buffer_size);
180 void nput(
char c,
size_t count) {
184 memset(data+pos, c, count);
189 void ncat(
const char *from,
size_t count) {
195 memcpy(data+pos, from, count);
199 void cat(
const char *from) {
201 ncat(from, strlen(from));
204 int ncatPadded(
const char *from,
size_t count,
size_t paddedWidth) {
206 ensure_mem(
std::max(count, paddedWidth));
208 int toPad =
long(paddedWidth)-
long(count);
209 if (toPad>0)
nput(
' ', toPad);
217 return ncatPadded(from, strlen(from), paddedWidth);
220 void npaste_at(
size_t at,
const char *from,
size_t count) {
224 size_t till = at+count-1;
230 memcpy(data+at, from, count);
256 #error arb_strbuf.h included twice
257 #endif // ARB_STRBUF_H
void cut_tail(size_t byte_count)
void cut(const size_t at, const size_t byte_count)
void vnprintf(size_t maxlen, const char *templat, va_list &parg) __ATTR__VFORMAT_MEMBER(2)
void paste_at(size_t at, const char *from)
void npaste_at(size_t at, const char *from, size_t count)
void nput(char c, size_t count)
void cat(const char *from)
int ncatPadded(const char *from, size_t count, size_t paddedWidth)
size_t get_buffer_size() const
#define __ATTR__FORMAT_MEMBER(pos)
CONSTEXPR_INLINE_Cxx14 void swap(unsigned char &c1, unsigned char &c2)
void cat_wrapped(const char *in, const char *from)
void swap_content(GBS_strstruct &other)
GBS_strstruct(size_t buffersize)
void ncat(const char *from, size_t count)
char * ARB_strndup(const char *start, int len)
void nprintf(size_t maxlen, const char *templat,...) __ATTR__FORMAT_MEMBER(2)
void ARB_realloc(TYPE *&tgt, size_t nelem)
int catPadded(const char *from, size_t paddedWidth)
void cat_dQuoted(const char *from)
const char * get_data() const
#define __ATTR__VFORMAT_MEMBER(pos)
char * release_memfriendly()
void cat_sQuoted(const char *from)
size_t get_position() const
GB_write_int const char s