--- parser3/src/include/pa_string.h 2001/01/29 20:10:32 1.11 +++ parser3/src/include/pa_string.h 2001/02/11 11:27:24 1.15 @@ -1,5 +1,5 @@ /* - $Id: pa_string.h,v 1.11 2001/01/29 20:10:32 paf Exp $ + $Id: pa_string.h,v 1.15 2001/02/11 11:27:24 paf Exp $ */ /* @@ -24,20 +24,18 @@ #include +#include "pa_pool.h" #include "pa_types.h" -class Pool; - #ifndef NO_STRING_ORIGIN -# define STRING_APPEND_PARAMS char *src, char *file, uint line +# define STRING_APPEND_PARAMS const char *src, char *file, uint line # define APPEND(src, file, line) real_append(src, file, line) #else -# define STRING_APPEND_PARAMS char *src +# define STRING_APPEND_PARAMS const char *src # define APPEND(src, file, line) real_append(src) #endif - -class String { +class String : public Pooled { public: enum { CR_PREALLOCATED_COUNT=5, @@ -46,21 +44,17 @@ public: public: - void *operator new(size_t size, Pool& apool); String(Pool& apool); - String(String& src); - size_t size() { return fsize; } - int used_rows() { return fused_rows; } - char *cstr(); + String(const String& src); + size_t size() const { return fsize; } + int used_rows() const { return fused_rows; } + char *cstr() const; String& real_append(STRING_APPEND_PARAMS); - bool operator == (String& src); + bool operator == (const String& src) const; - uint hash_code(); + uint hash_code() const; -protected: - - // the pool I'm allocated on - Pool& pool; + const Origin& origin() const { return head.rows[0].item.origin; } private: @@ -70,7 +64,7 @@ private: union Row { // chunk item struct { - char *ptr; // pointer to the start of string fragment + const char *ptr; // pointer to the start of string fragment size_t size; // length of the fragment Origin origin; // origin of this fragment } item; @@ -107,8 +101,9 @@ private: private: //disabled - String& operator = (String&) { return *this; } + String& operator = (const String&) { return *this; } }; + #endif