3 #ifndef _CL_SPUSHSTRING_H
4 #define _CL_SPUSHSTRING_H
6 #include "cln/object.h"
7 #include "cln/malloc.h"
8 #include "cl_sstring.h"
13 class cl_spushstring {
16 uintL alloc; // allocated size of buffer
17 uintL index; // index into buffer, 0 <= index <= alloc
19 // Constructor. When constructed, the string is empty.
23 // Forget the contents.
25 // Add a character at the end.
27 // Adds several characters at the end at once.
28 void append (const char * ptr, uintL len);
29 // Get the contents as a string. Free it using free_hook() when done.
31 // Look at the contents.
32 uintL length () const;
33 char operator[] (uintL i) const;
35 inline cl_spushstring::cl_spushstring ()
37 alloc = 20; // Must be > 0.
38 buffer = (char *) malloc_hook(alloc);
41 inline cl_spushstring::~cl_spushstring ()
45 inline void cl_spushstring::reset ()
49 inline char* cl_spushstring::contents ()
51 return cl_sstring(buffer,index);
53 inline uintL cl_spushstring::length () const
57 inline char cl_spushstring::operator[] (uintL i) const
59 if (!(i < index)) cl_abort();
65 #endif /* _CL_SPUSHSTRING_H */