Diff for /parser3/src/include/pa_string.h between versions 1.11 and 1.24

version 1.11, 2001/01/29 20:10:32 version 1.24, 2001/02/21 12:43:41
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 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 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
   #define APPEND_CONST(src) APPEND(src, 0, 0, 0)
   
   //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 48  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;
           bool operator == (char* src) const;
         uint hash_code();  //      String& append(const String_iterator& begin, const String_iterator& end);
   
 protected:          uint hash_code() const;
   
         // the pool I'm allocated on          const Origin& origin() const { return head.rows[0].item.origin; }
         Pool& pool;  
   
 private:  private:
   
Line 70  private: Line 71  private:
                 union Row {                  union Row {
                         // chunk item                          // chunk item
                         struct {                          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                                  size_t size;  // length of the fragment
                                 Origin origin;  // origin of this fragment                                  Origin origin;  // origin of this fragment
                         } item;                          } item;
Line 107  private: Line 108  private:
   
 private: //disabled  private: //disabled
   
         String& operator = (String&) { return *this; }          String& operator = (const String&) { return *this; }
   
 };  };
   
   /*
   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

Removed from v.1.11  
changed lines
  Added in v.1.24


E-mail: