Diff for /parser3/src/include/pa_string.h between versions 1.97 and 1.112

version 1.97, 2001/07/07 17:59:02 version 1.112, 2001/10/29 16:29:07
Line 2 Line 2
         Parser: string class decl.          Parser: string class decl.
   
         Copyright (c) 2001 ArtLebedev Group (http://www.artlebedev.com)          Copyright (c) 2001 ArtLebedev Group (http://www.artlebedev.com)
   
         Author: Alexander Petrosyan <paf@design.ru> (http://design.ru/paf)          Author: Alexander Petrosyan <paf@design.ru> (http://design.ru/paf)
   
         $Id$          $Id$
Line 57  class Table; Line 56  class Table;
   
 class Array;  class Array;
 class SQL_Connection;  class SQL_Connection;
   class Dictionary;
   
 /**   /** 
         Pooled string.          Pooled string.
Line 86  public: Line 86  public:
                 CR_GROW_COUNT=2 ///< each time the String chunk_is_full() string expanded()                  CR_GROW_COUNT=2 ///< 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
                   remember to change String_Untaint_lang_name @ untaint.C along
           */
         enum Untaint_lang {          enum Untaint_lang {
                 UL_UNSPECIFIED=0, ///< zero value handy for hash lookup @see untaint_lang_name2enum                  UL_UNSPECIFIED=0, ///< zero value handy for hash lookup @see untaint_lang_name2enum
                 UL_CLEAN, ///< clean                  UL_CLEAN, ///< clean
Line 98  public: Line 100  public:
                                 just a flag, that value not stored                                  just a flag, that value not stored
                         */                          */
                 UL_AS_IS,     ///< leave all characters intact                  UL_AS_IS,     ///< leave all characters intact
                 UL_FILE_NAME, ///< filename                  UL_FILE_SPEC, ///< file specification
                 UL_HTTP_HEADER,    ///< text in HTTP response header                  UL_HTTP_HEADER,    ///< text in HTTP response header
                 UL_MAIL_HEADER,    ///< text in mail header                  UL_MAIL_HEADER,    ///< text in mail header
                 UL_URI,       ///< text in uri                  UL_URI,       ///< text in uri
                 UL_TABLE,     ///< ^table:set body                  UL_TABLE,     ///< ^table:set body
                 UL_SQL,       ///< ^table:sql body                  UL_SQL,       ///< ^table:sql body
                 UL_JS,        ///< JavaScript code                  UL_JS,        ///< JavaScript code
                   UL_XML,         ///< ^dom:set xml
                 UL_HTML,      ///< HTML code (for editing)                  UL_HTML,      ///< HTML code (for editing)
                 UL_USER_HTML  ///< HTML code with USER chars                  UL_USER_HTML  ///< HTML code with USER chars
         };          };
Line 114  public: Line 117  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);
         size_t size() const { return fsize; }          size_t size() const { return fsize; }
           /// makes store_to produce origin:text\n output
           void set_origins_mode(bool aorigins_mode) const { forigins_mode=aorigins_mode; }
         /// 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_UNSPECIFIED,           char *cstr(Untaint_lang lang=UL_AS_IS, 
                 SQL_Connection *connection=0,                  SQL_Connection *connection=0,
                 const char *charset=0) const {                  const char *charset=0) const {
   
Line 124  public: Line 129  public:
                 *eol=0;                  *eol=0;
                 return result;                  return result;
         }          }
           /// puts pieces to buf
           void serialize(size_t prolog_size,  void *& buf, size_t& buf_size) const;
           /// appends pieces from buf to self
           void deserialize(size_t prolog_size, void *buf, size_t buf_size, const char *file);
         /** append fragment          /** append fragment
                 @see APPEND_AS_IS, APPEND_CLEAN, APPEND_TAINTED, APPEND_CONST                  @see APPEND_AS_IS, APPEND_CLEAN, APPEND_TAINTED, APPEND_CONST
         */          */
Line 178  public: Line 187  public:
         /// simple hash code of string. used by Hash          /// simple hash code of string. used by Hash
         uint hash_code() const;          uint hash_code() const;
   
           /// extracts first char of a string
           char first_char() const;
   
         /// extracts [start, finish) piece of string          /// extracts [start, finish) piece of string
         String& mid(size_t start, size_t finish) const;          String& mid(size_t start, size_t finish) const;
   
         /// @return position of substr in string, -1 means "not found" [String version]          /// @return position of substr in string, -1 means "not found" [String version]
         int pos(const String& substr,           int pos(const String& substr, 
                 size_t this_offset=0, Untaint_lang lang=UL_UNSPECIFIED) const;                  int this_offset=0, Untaint_lang lang=UL_UNSPECIFIED) const;
         /// @return position of substr in string, -1 means "not found" [const char* version]          /// @return position of substr in string, -1 means "not found" [const char* version]
         int pos(const char *substr, size_t substr_size=0,           int pos(const char *substr, size_t substr_size=0, 
                 size_t this_offset=0, Untaint_lang lang=UL_UNSPECIFIED) const;                  int this_offset=0, Untaint_lang lang=UL_UNSPECIFIED) const;
   
         void split(Array& result,           void split(Array& result, 
                 size_t *pos_after_ref,                   size_t *pos_after_ref, 
Line 211  public: Line 223  public:
                 const String& regexp,                   const String& regexp, 
                 const String *options,                  const String *options,
                 Table **table,                  Table **table,
                 Row_action row_action, void *info) const;                  Row_action row_action, void *info,
                   bool *was_global=0) const;
         enum Change_case_kind {          enum Change_case_kind {
                 CC_UPPER,                  CC_UPPER,
                 CC_LOWER                  CC_LOWER
         };          };
         String& change_case(Pool& pool, const unsigned char *pcre_tables,           String& change_case(Pool& pool, const unsigned char *pcre_tables, 
                 Change_case_kind kind) const;                  Change_case_kind kind) const;
           String& replace(Pool& pool, Dictionary& dict) const;
         double as_double() const;          double as_double() const;
         int as_int() const;          int as_int() const;
   
Line 230  private: Line 244  private:
   
         /// several String fragments          /// several String fragments
         struct Chunk {          struct Chunk {
                 size_t count; ///< the number of rows in chunk                  uint 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 {
                         /// fragment                          /// fragment
Line 257  private: Line 271  private:
         Chunk::Row *link_row;          Chunk::Row *link_row;
   
 private:  private:
         // last chunk          /// last chunk
         Chunk *last_chunk;          Chunk *last_chunk;
   
         // string size          /// string size
         size_t fsize;          size_t fsize;
   
         // used rows in all chunks          /// origins_mode changes behaviour of store_to[cstr()]
         int fused_rows;          mutable bool forigins_mode;
   
 private:  private:
   
         bool chunk_is_full() {          bool chunk_is_full() {
                 return append_here == link_row;                  return append_here == link_row;
         }          }
           uint used_rows() const;
         void expand();          void expand();
   
         size_t cstr_bufsize(Untaint_lang lang) const;          size_t cstr_bufsize(Untaint_lang lang) const;
Line 279  private: Line 294  private:
                 SQL_Connection *connection=0,                  SQL_Connection *connection=0,
                 const char *charset=0) const;                  const char *charset=0) const;
   
           String& reconstruct(Pool& pool) const;
           void join_chain(Pool& pool, 
                                              uint& ai, const Chunk*& achunk, const Chunk::Row*& arow,
                                              Untaint_lang& joined_lang, const char *& joined_ptr, size_t& joined_size) const;
           String& replace_in_reconstructed(Pool& pool, Dictionary& dict) const;
   
 private: //disabled  private: //disabled
   
         String& operator = (const String&) { return *this; }          String& operator = (const String&) { return *this; }

Removed from v.1.97  
changed lines
  Added in v.1.112


E-mail: