|
|
| version 1.13, 2001/01/29 21:51:51 | version 1.22, 2001/02/20 18:45:51 |
|---|---|
| Line 6 | Line 6 |
| String Chunk0 | String Chunk0 |
| ====== ======== | ====== ======== |
| head--------->[ptr, size] | head--------------->[ptr, size, ...] |
| append_here-------->[ptr, size] | append_here-------->[ptr, size, ...] |
| link_row ........ | . |
| . . | . |
| . [ptr, size] | [ptr, size, ...] |
| ...........>[link to the next chunk] | link_row----------->[link to the next chunk] |
| */ | */ |
| Line 24 | Line 24 |
| #include <stddef.h> | #include <stddef.h> |
| #include "pa_pool.h" | |
| #include "pa_types.h" | #include "pa_types.h" |
| class Pool; | |
| #ifndef NO_STRING_ORIGIN | #ifndef NO_STRING_ORIGIN |
| # define STRING_APPEND_PARAMS const char *src, char *file, uint line | # define STRING_APPEND_PARAMS const char *src, size_t size, char *file, uint line |
| # define APPEND(src, file, line) real_append(src, file, line) | # define APPEND(src, size, file, line) real_append(src, size, file, line) |
| #else | #else |
| # define STRING_APPEND_PARAMS const char *src | # define STRING_APPEND_PARAMS const char *src, size_t size |
| # define APPEND(src, file, line) real_append(src) | # define APPEND(src, size, file, line) real_append(src, size) |
| #endif | #endif |
| //class String_iterator; | |
| class String { | class String : public Pooled { |
| // friend String_iterator; | |
| public: | public: |
| enum { | enum { |
| CR_PREALLOCATED_COUNT=5, | CR_PREALLOCATED_COUNT=5, |
| Line 46 public: | Line 47 public: |
| public: | public: |
| void *operator new(size_t size, Pool& apool); | |
| String(Pool& apool); | String(Pool& apool); |
| String(String& src); | String(const String& src); |
| size_t size() { return fsize; } | //String(const String_iterator& begin, const String_iterator& end); |
| int used_rows() { return fused_rows; } | size_t size() const { return fsize; } |
| char *cstr(); | int used_rows() const { return fused_rows; } |
| char *cstr() const; | |
| String& real_append(STRING_APPEND_PARAMS); | String& real_append(STRING_APPEND_PARAMS); |
| bool operator == (String& src); | bool operator == (const String& src) const; |
| // String& append(const String_iterator& begin, const String_iterator& end); | |
| uint hash_code(); | uint hash_code() const; |
| const Origin& origin() const { return head.rows[0].item.origin; } | const Origin& origin() const { return head.rows[0].item.origin; } |
| protected: | |
| // the pool I'm allocated on | |
| Pool& pool; | |
| private: | private: |
| struct Chunk { | struct Chunk { |
| Line 113 private: //disabled | Line 110 private: //disabled |
| }; | }; |
| /* | |
| class Char_types { | |
| public: | |
| Char_types(); | |
| void set(char from, char to, int type); | |
| void set(char c, int type) { | |
| types[static_cast<unsigned int>(c)]=static_cast<char>(type); | |
| } | |
| int get(char c) { | |
| return static_cast<int>(types[static_cast<unsigned int>(c)]); | |
| } | |
| private: | |
| char types[0x100]; | |
| }; | |
| class String_iterator { | |
| public: | |
| String_iterator(String& astring); | |
| String_iterator(String_iterator& asi); | |
| void operator ++() { skip(); } | |
| void operator ++(int) { skip(); } | |
| int skip_to(Char_types& types); | |
| bool skip_to(char c); | |
| bool eof() { return position==0; } | |
| // current char | |
| char operator() () const; | |
| protected: | |
| // home string | |
| String& string; | |
| // the row in which we are | |
| String::Chunk::Row *read_here; | |
| // position in text, eof when 0 | |
| const char *position; | |
| // when read_here reaches this row, move to the next chunk | |
| String::Chunk::Row *link_row; | |
| protected: | |
| // advances position by one char | |
| void skip(); | |
| }; | |
| */ | |
| #endif | #endif |