Diff for /parser3/src/include/pa_string.h between versions 1.124 and 1.129

version 1.124, 2002/02/08 08:30:14 version 1.129, 2002/02/20 12:40:24
Line 74  public: Line 74  public:
   
         enum {          enum {
                 CR_PREALLOCATED_COUNT=2, ///< default preallocated item count                  CR_PREALLOCATED_COUNT=2, ///< default preallocated item count
                 CR_GROW_COUNT=2 ///< each time the String chunk_is_full() string expanded()                  CR_GROW_COUNT=1 ///< each time the String chunk_is_full() string expanded()
         };          };
   
         /** piece is tainted or not. the language to use when detaint          /** piece is tainted or not. the language to use when detaint
Line 109  public: Line 109  public:
   
         String(Pool& apool, const char *src=0, size_t src_size=0, bool tainted=false);          String(Pool& apool, const char *src=0, size_t src_size=0, bool tainted=false);
         String(const String& src);          String(const String& src);
           bool is_empty() const { return append_here==head.rows; }
         size_t size() const;          size_t size() const;
         /// convert to C string. if 'lang' known, forcing 'lang' to it          /// convert to C string. if 'lang' known, forcing 'lang' to it
         char *cstr(Untaint_lang lang=UL_AS_IS,           char *cstr(Untaint_lang lang=UL_AS_IS, 
Line 165  public: Line 166  public:
                 return cmp(partial, src_ptr, 0)!=0;                   return cmp(partial, src_ptr, 0)!=0; 
         }          }
   
         /**   
                 appends other String.  
   
                 marking all tainted pieces of it with @a lang.  
                 or marking ALL pieces of it with a @a lang when @a forced to.  
         */  
         String& append(const String& src, uchar lang, bool forced=false);          String& append(const String& src, uchar lang, bool forced=false);
         String& operator << (const String& src) { return append(src, UL_PASS_APPENDED); }          String& operator << (const String& src) { return append(src, UL_PASS_APPENDED); }
         String& operator << (const char *src) { return APPEND_CONST(src); }          String& operator << (const char *src) { return APPEND_CONST(src); }
Line 233  public: Line 228  public:
   
 private:  private:
   
         /// several String fragments          /** several String fragments
         struct Chunk {                  
                 ushort count; ///< the number of rows in chunk                  'mutable' because can write after it's end, after it was appended to somebody 
                   @see String::append
           */
           mutable struct Chunk {
                   typedef uchar count_type;
                   count_type count; ///< the number of rows in chunk
                 /// string fragment or a link to next chunk union                  /// string fragment or a link to next chunk union
                 union Row {                  union Row {
                           typedef uchar item_size_type;
                         /// fragment                          /// fragment
                         struct {                           struct { 
                                 const char *ptr;  ///< pointer to the start                                  const char *ptr;  ///< pointer to the start
                                 ushort size;  ///< length                                  item_size_type size;  ///< length
                                 unsigned char/*Untaint_lang*/ lang; ///< untaint flag, later untaint language                                  uchar/*Untaint_lang*/ lang; ///< untaint flag, later untaint language
 #ifndef NO_STRING_ORIGIN  #ifndef NO_STRING_ORIGIN
                                 Origin origin;  ///< origin                                  Origin origin;  ///< origin
 #endif  #endif
Line 251  private: Line 252  private:
                 } rows[CR_PREALLOCATED_COUNT];                  } rows[CR_PREALLOCATED_COUNT];
         }          }
                 head;  ///< the head chunk of the chunk chain                  head;  ///< the head chunk of the chunk chain
         Chunk *head_link; ///< next rows are here          Chunk *initial_head_link; ///< next rows initially are here[can shrink! @see String::append]. must go right after 'head'
   
         /// next append would write to this record          /// next append would write to this record
         Chunk::Row *append_here;          Chunk::Row *append_here;
                   
         /** the address of place where lies address   
                 of the link to the next chunk to allocate  
         */  
         Chunk::Row *link_row;  
   
 private:  private:
         /// last chunk          /// last chunk
         Chunk *last_chunk;          mutable Chunk *last_chunk;
   
 private:  private:
   
         bool chunk_is_full() {          bool chunk_is_full() {
                 return append_here == link_row;                  return append_here == last_chunk->rows+last_chunk->count;
         }          }
         uint used_rows() const;          uint used_rows() const;
         void expand();          void expand();
           
           Untaint_lang lang_of(size_t offset) const;
   
         size_t cstr_bufsize(Untaint_lang lang,          size_t cstr_bufsize(Untaint_lang lang,
                 SQL_Connection *connection,                  SQL_Connection *connection,

Removed from v.1.124  
changed lines
  Added in v.1.129


E-mail: