--- parser3/src/include/pa_string.h 2001/01/29 15:56:03 1.10 +++ parser3/src/include/pa_string.h 2001/01/29 22:34:57 1.14 @@ -1,5 +1,5 @@ /* - $Id: pa_string.h,v 1.10 2001/01/29 15:56:03 paf Exp $ + $Id: pa_string.h,v 1.14 2001/01/29 22:34:57 paf Exp $ */ /* @@ -29,10 +29,10 @@ 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 @@ -46,21 +46,23 @@ 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 *c_str(); + void *operator new(size_t size, Pool& apool); + String(Pool& apool); + 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; + + const Origin& origin() const { return head.rows[0].item.origin; } protected: // the pool I'm allocated on - Pool *pool; + Pool& pool; private: @@ -70,7 +72,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,7 +109,7 @@ private: private: //disabled - String& operator = (String&) { return *this; } + String& operator = (const String&) { return *this; } };