3 #ifndef _CL_SPUSHSTRING_H
4 #define _CL_SPUSHSTRING_H
8 #include "cl_sstring.h"
11 class cl_spushstring {
14 uintL alloc; // allocated size of buffer
15 uintL index; // index into buffer, 0 <= index <= alloc
17 // Constructor. When constructed, the string is empty.
21 // Forget the contents.
23 // Add a character at the end.
25 // Adds several characters at the end at once.
26 void append (const char * ptr, uintL len);
27 // Get the contents as a string. Free it using cl_free_hook() when done.
29 // Look at the contents.
30 uintL length () const;
31 char operator[] (uintL i) const;
33 inline cl_spushstring::cl_spushstring ()
35 alloc = 20; // Must be > 0.
36 buffer = (char *) cl_malloc_hook(alloc);
39 inline cl_spushstring::~cl_spushstring ()
43 inline void cl_spushstring::reset ()
47 inline char* cl_spushstring::contents ()
49 return cl_sstring(buffer,index);
51 inline uintL cl_spushstring::length () const
55 inline char cl_spushstring::operator[] (uintL i) const
57 if (!(i < index)) cl_abort();
61 #endif /* _CL_SPUSHSTRING_H */