/[pcre]/code/trunk/pcrecpp.h
ViewVC logotype

Diff of /code/trunk/pcrecpp.h

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 92 by nigel, Sat Feb 24 21:41:21 2007 UTC revision 93 by nigel, Sat Feb 24 21:41:42 2007 UTC
# Line 112  Line 112 
112  //    T             (where "bool T::ParseFrom(const char*, int)" exists)  //    T             (where "bool T::ParseFrom(const char*, int)" exists)
113  //    NULL          (the corresponding matched sub-pattern is not copied)  //    NULL          (the corresponding matched sub-pattern is not copied)
114  //  //
115    // CAVEAT: An optional sub-pattern that does not exist in the matched
116    // string is assigned the empty string.  Therefore, the following will
117    // return false (because the empty string is not a valid number):
118    //    int number;
119    //    pcrecpp::RE::FullMatch("abc", "[a-z]+(\\d+)?", &number);
120    //
121  // -----------------------------------------------------------------------  // -----------------------------------------------------------------------
122  // DO_MATCH  // DO_MATCH
123  //  //
# Line 488  class RE { Line 494  class RE {
494    // pass in a string or a "const char*" wherever an "RE" is expected.    // pass in a string or a "const char*" wherever an "RE" is expected.
495    RE(const char* pat) { Init(pat, NULL); }    RE(const char* pat) { Init(pat, NULL); }
496    RE(const char *pat, const RE_Options& option) { Init(pat, &option); }    RE(const char *pat, const RE_Options& option) { Init(pat, &option); }
497    RE(const string& pat) { Init(pat.c_str(), NULL); }    RE(const string& pat) { Init(pat, NULL); }
498    RE(const string& pat, const RE_Options& option) { Init(pat.c_str(), &option); }    RE(const string& pat, const RE_Options& option) { Init(pat, &option); }
499    
500      // Copy constructor & assignment - note that these are expensive
501      // because they recompile the expression.
502      RE(const RE& re) { Init(re.pattern_, &re.options_); }
503      const RE& operator=(const RE& re) {
504        if (this != &re) {
505          Cleanup();
506    
507          // This is the code that originally came from Google
508          // Init(re.pattern_.c_str(), &re.options_);
509    
510          // This is the replacement from Ari Pollak
511          Init(re.pattern_, &re.options_);
512        }
513        return *this;
514      }
515    
516    
517    ~RE();    ~RE();
518    
# Line 589  class RE { Line 612  class RE {
612                 const StringPiece &text,                 const StringPiece &text,
613                 string *out) const;                 string *out) const;
614    
615      // Escapes all potentially meaningful regexp characters in
616      // 'unquoted'.  The returned string, used as a regular expression,
617      // will exactly match the original string.  For example,
618      //           1.5-2.0?
619      // may become:
620      //           1\.5\-2\.0\?
621      static string QuoteMeta(const StringPiece& unquoted);
622    
623    
624    /***** Generic matching interface *****/    /***** Generic matching interface *****/
625    
626    // Type of match (TODO: Should be restructured as part of RE_Options)    // Type of match (TODO: Should be restructured as part of RE_Options)
# Line 611  class RE { Line 643  class RE {
643    
644   private:   private:
645    
646    void Init(const char* pattern, const RE_Options* options);    void Init(const string& pattern, const RE_Options* options);
647      void Cleanup();
648    
649    // Match against "text", filling in "vec" (up to "vecsize" * 2/3) with    // Match against "text", filling in "vec" (up to "vecsize" * 2/3) with
650    // pairs of integers for the beginning and end positions of matched    // pairs of integers for the beginning and end positions of matched
# Line 655  class RE { Line 688  class RE {
688    pcre*         re_full_;       // For full matches    pcre*         re_full_;       // For full matches
689    pcre*         re_partial_;    // For partial matches    pcre*         re_partial_;    // For partial matches
690    const string* error_;         // Error indicator (or points to empty string)    const string* error_;         // Error indicator (or points to empty string)
   
   // Don't allow the default copy or assignment constructors --  
   // they're expensive and too easy to do by accident.  
   RE(const RE&);  
   void operator=(const RE&);  
691  };  };
692    
693  }   // namespace pcrecpp  }   // namespace pcrecpp

Legend:
Removed from v.92  
changed lines
  Added in v.93

webmaster@exim.org
ViewVC Help
Powered by ViewVC 1.1.12