|
|
| version 1.13, 2001/01/29 21:51:51 | version 1.16, 2001/02/12 13:26:54 |
|---|---|
| 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, char *file, uint line |
| # define APPEND(src, file, line) real_append(src, file, line) | # define APPEND(src, file, line) real_append(src, file, line) |
| Line 36 class Pool; | Line 35 class Pool; |
| # define APPEND(src, file, line) real_append(src) | # define APPEND(src, file, line) real_append(src) |
| #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; } | size_t size() const { return fsize; } |
| int used_rows() { return fused_rows; } | int used_rows() const { return fused_rows; } |
| char *cstr(); | 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 109 private: //disabled |
| }; | }; |
| class Char_set { | |
| public: | |
| Char_set(); | |
| void include(char c) { bools[static_cast<unsigned int>(c)]=true; } | |
| bool in(char c) { return bools[static_cast<unsigned int>(c)]; } | |
| private: | |
| bool bools[0x100]; | |
| }; | |
| class String_iterator { | |
| public: | |
| String_iterator(String& astring); | |
| void operator ++() { skip(); } | |
| void operator ++(int) { skip(); } | |
| void skip_to(Char_set& set); | |
| void skip_to(char c); | |
| bool eof() { return feof; } | |
| // current char | |
| char operator() const; | |
| protected: | |
| // home string | |
| String& string; | |
| // the row in which we are | |
| Chunk::Row *read_here; | |
| // position in that row's string fragment | |
| int offset; | |
| // when read_here reaches this row, move to the next chunk | |
| Chunk::Row *link_row; | |
| bool feof; | |
| protected: | |
| // advances position on one char | |
| void skip() { | |
| } | |
| }; | |
| #endif | #endif |