/[pcre]/code/tags/pcre-7.8/pcrecpp.h
ViewVC logotype

Diff of /code/tags/pcre-7.8/pcrecpp.h

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

revision 87 by nigel, Sat Feb 24 21:41:21 2007 UTC revision 200 by ph10, Wed Aug 1 09:10:40 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 325  Line 331 
331    
332    
333  #include <string>  #include <string>
 #include <pcrecpparg.h>   // defines the Arg class  
 // These aren't technically needed here, but we include them  
 // anyway so folks who include pcrecpp.h don't have to include  
 // all these other header files as well.  
334  #include <pcre.h>  #include <pcre.h>
335    #include <pcrecpparg.h>   // defines the Arg class
336    // This isn't technically needed here, but we include it
337    // anyway so folks who include pcrecpp.h don't have to.
338  #include <pcre_stringpiece.h>  #include <pcre_stringpiece.h>
339    
340  namespace pcrecpp {  namespace pcrecpp {
# Line 342  namespace pcrecpp { Line 347  namespace pcrecpp {
347          (all_options_ & o) == o          (all_options_ & o) == o
348    
349  // We convert user-passed pointers into special Arg objects  // We convert user-passed pointers into special Arg objects
350  extern Arg no_arg;  PCRECPP_EXP_DECL Arg no_arg;
351    
352  /***** Compiling regular expressions: the RE class *****/  /***** Compiling regular expressions: the RE class *****/
353    
# Line 350  extern Arg no_arg; Line 355  extern Arg no_arg;
355  // along with other options we put on top of pcre.  // along with other options we put on top of pcre.
356  // Only 9 modifiers, plus match_limit and match_limit_recursion,  // Only 9 modifiers, plus match_limit and match_limit_recursion,
357  // are supported now.  // are supported now.
358  class RE_Options {  class PCRECPP_EXP_DEFN RE_Options {
359   public:   public:
360    // constructor    // constructor
361    RE_Options() : match_limit_(0), match_limit_recursion_(0), all_options_(0) {}    RE_Options() : match_limit_(0), match_limit_recursion_(0), all_options_(0) {}
# Line 482  static inline RE_Options EXTENDED() { Line 487  static inline RE_Options EXTENDED() {
487  // Interface for regular expression matching.  Also corresponds to a  // Interface for regular expression matching.  Also corresponds to a
488  // pre-compiled regular expression.  An "RE" object is safe for  // pre-compiled regular expression.  An "RE" object is safe for
489  // concurrent use by multiple threads.  // concurrent use by multiple threads.
490  class RE {  class PCRECPP_EXP_DEFN RE {
491   public:   public:
492    // We provide implicit conversions from strings so that users can    // We provide implicit conversions from strings so that users can
493    // 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.
494    RE(const char* pat) { Init(pat, NULL); }    RE(const char* pat) { Init(pat, NULL); }
495    RE(const char *pat, const RE_Options& option) { Init(pat, &option); }    RE(const char *pat, const RE_Options& option) { Init(pat, &option); }
496    RE(const string& pat) { Init(pat.c_str(), NULL); }    RE(const string& pat) { Init(pat, NULL); }
497    RE(const string& pat, const RE_Options& option) { Init(pat.c_str(), &option); }    RE(const string& pat, const RE_Options& option) { Init(pat, &option); }
498    
499      // Copy constructor & assignment - note that these are expensive
500      // because they recompile the expression.
501      RE(const RE& re) { Init(re.pattern_, &re.options_); }
502      const RE& operator=(const RE& re) {
503        if (this != &re) {
504          Cleanup();
505    
506          // This is the code that originally came from Google
507          // Init(re.pattern_.c_str(), &re.options_);
508    
509          // This is the replacement from Ari Pollak
510          Init(re.pattern_, &re.options_);
511        }
512        return *this;
513      }
514    
515    
516    ~RE();    ~RE();
517    
# Line 589  class RE { Line 611  class RE {
611                 const StringPiece &text,                 const StringPiece &text,
612                 string *out) const;                 string *out) const;
613    
614      // Escapes all potentially meaningful regexp characters in
615      // 'unquoted'.  The returned string, used as a regular expression,
616      // will exactly match the original string.  For example,
617      //           1.5-2.0?
618      // may become:
619      //           1\.5\-2\.0\?
620      static string QuoteMeta(const StringPiece& unquoted);
621    
622    
623    /***** Generic matching interface *****/    /***** Generic matching interface *****/
624    
625    // 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 642  class RE {
642    
643   private:   private:
644    
645    void Init(const char* pattern, const RE_Options* options);    void Init(const string& pattern, const RE_Options* options);
646      void Cleanup();
647    
648    // Match against "text", filling in "vec" (up to "vecsize" * 2/3) with    // Match against "text", filling in "vec" (up to "vecsize" * 2/3) with
649    // 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 687  class RE {
687    pcre*         re_full_;       // For full matches    pcre*         re_full_;       // For full matches
688    pcre*         re_partial_;    // For partial matches    pcre*         re_partial_;    // For partial matches
689    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&);  
690  };  };
691    
692  }   // namespace pcrecpp  }   // namespace pcrecpp

Legend:
Removed from v.87  
changed lines
  Added in v.200

  ViewVC Help
Powered by ViewVC 1.1.5