Diff for /parser3/src/include/pa_string.h between versions 1.147 and 1.151

version 1.147, 2003/09/25 09:41:24 version 1.151, 2003/10/21 05:11:00
Line 24  extern "C" { // cord's author forgot to Line 24  extern "C" { // cord's author forgot to
 /* Returns true if x does contain                                       */  /* Returns true if x does contain                                       */
 /* char not_c at positions i..i+n. Value i,i+n must be < CORD_len(x).   */  /* char not_c at positions i..i+n. Value i,i+n must be < CORD_len(x).   */
 int CORD_range_contains_chr_greater_then(CORD x, size_t i, size_t n, int c);  int CORD_range_contains_chr_greater_then(CORD x, size_t i, size_t n, int c);
   size_t CORD_block_count(CORD x);
   
 // forwards  // forwards
   
Line 55  public: Line 56  public:
   
         /** piece is tainted or not. the lang to use when detaint          /** piece is tainted or not. the lang to use when detaint
                 remember to change String_Untaint_lang_name @ untaint.C along                  remember to change String_Untaint_lang_name @ untaint.C along
   
                   WARNING WARNING WARNING WARNING WARNING WARNING 
                   
                   pos function compares(<=) languages, that is used in searching
                   for table column separator being L_CLEAN or L_AS_IS.
                   they search for AS_IS, meaning AS_IS|CLEAN [doing <=L_AS_IS check].
                   
                   letters assigned for debugging, but it's important for no language-letter
                   come before L_AS_IS other then L_CLEAN
   
                   WARNING WARNING WARNING WARNING WARNING WARNING 
         */          */
         enum Language {          enum Language {
                 L_UNSPECIFIED=0, ///< no real string has parts of this lange: it's just convinient to check when string's empty                  L_UNSPECIFIED=0, ///< no real string has parts of this lange: it's just convinient to check when string's empty
                 // these two must go before others, there are checks for >L_AS_IS                  // these two must go before others, there are checks for >L_AS_IS
                 L_CLEAN='1', ///< clean                  L_CLEAN='0', ///< clean  WARNING: read above warning before changing
                 L_AS_IS,     ///< leave all characters intact                  L_AS_IS='A',     ///< leave all characters intact  WARNING: read above warning before changing
   
                 L_PASS_APPENDED,                  L_PASS_APPENDED='P',
                         /**<                          /**<
                                 leave lang built into string being appended.                                  leave lang built into string being appended.
                                 just a flag, that value not stored                                  just a flag, that value not stored
                         */                          */
                 L_TAINTED,  ///< tainted, untaint lang as assigned later                   L_TAINTED='T',  ///< tainted, untaint lang as assigned later 
                 // untaint langs. assigned by ^untaint[lang]{...}                  // untaint langs. assigned by ^untaint[lang]{...}
                 L_FILE_SPEC, ///< file specification                  L_FILE_SPEC='F', ///< file specification
                 L_HTTP_HEADER,    ///< text in HTTP response header                  L_HTTP_HEADER='h',    ///< text in HTTP response header
                 L_MAIL_HEADER,    ///< text in mail header                  L_MAIL_HEADER='m',    ///< text in mail header
                 L_URI,       ///< text in uri                  L_URI='U',       ///< text in uri
                 L_TABLE,     ///< ^table:set body                  L_TABLE='L',     ///< ^table:set body
                 L_SQL,       ///< ^table:sql body                  L_SQL='Q',       ///< ^table:sql body
                 L_JS,        ///< JavaScript code                  L_JS='J',        ///< JavaScript code
                 L_XML,          ///< ^dom:set xml                  L_XML='X',              ///< ^dom:set xml
                 L_HTML,      ///< HTML code (for editing)                  L_HTML='H',      ///< HTML code (for editing)
                   // READ WARNING ABOVE BEFORE ADDING ANYTHING
                 L_OPTIMIZE_BIT = 0x80  ///< flag, requiring cstr whitespace optimization                  L_OPTIMIZE_BIT = 0x80  ///< flag, requiring cstr whitespace optimization
         };          };
   
Line 190  public: Line 203  public:
                                 return opt.lang<=alang;                                  return opt.lang<=alang;
                 }                  }
   
                   /// @returns count of blocks
                   /// @todo currently there can be adjucent blocks of same language. someday merge them
                   size_t count() const {
                           return opt.is_not_just_lang?
                                   CORD_block_count(langs)
                                   : opt.lang?
                                           1
                                           : 0;
                   };
   
                 template<typename C, typename I>                   template<typename C, typename I> 
                 void for_each(C current,                   void for_each(C current, 
                         int callback(char, size_t, I), I info) const {                          int callback(char, size_t, I), I info) const {
Line 275  public: Line 298  public:
                 size_t pos(const Body substr, size_t offset=0) const {                   size_t pos(const Body substr, size_t offset=0) const { 
                         if(!substr.length())                          if(!substr.length())
                                 return STRING_NOT_FOUND; // in this case CORD_str returns 0 [parser users got used to -1]                                  return STRING_NOT_FOUND; // in this case CORD_str returns 0 [parser users got used to -1]
   
                           // CORD_str checks for bad offset [CORD_chr does not]
                         return CORD_str(body, offset, substr.body);                           return CORD_str(body, offset, substr.body); 
                 }                  }
                 size_t pos(char c,                   size_t pos(char c, 
                         size_t offset=0) const {                          size_t offset=0) const {
                           if(offset>=length()) // CORD_chr does not check that [and ABORT's in that case]
                                   return STRING_NOT_FOUND;
   
                         return CORD_chr(body, offset, c);                          return CORD_chr(body, offset, c);
                 }                  }
   
         /*      template<typename I> void for_each(int (*callback)(const char* s, I), I info) const {                  template<typename I> void for_each(
                         CORD_iter5(body, 0, 0, (CORD_batched_iter_fn)callback, info);                          int (*f1)(char c, I), 
                 }*/                          int (*f2)(const char* s, I), 
                           I info) const {
                           CORD_iter5(body, 0, (CORD_iter_fn)f1, (CORD_batched_iter_fn)f2, info);
                   }
   
                 void set_pos(CORD_pos& pos, size_t index) const { CORD_set_pos(pos, body, index); }                  void set_pos(CORD_pos& pos, size_t index) const { CORD_set_pos(pos, body, index); }
   
Line 319  private: Line 350  private:
   
 public:  public:
   
           static const String Empty;
   
         explicit String(const char* cstr=0, size_t helper_length=0, bool tainted=false);          explicit String(const char* cstr=0, size_t helper_length=0, bool tainted=false);
         explicit String(const C cstr, bool tainted=false);          explicit String(const C cstr, bool tainted=false);
         String(Body abody, Language alang): body(abody), langs(alang) {          String(Body abody, Language alang): body(abody), langs(alang) {

Removed from v.1.147  
changed lines
  Added in v.1.151


E-mail: