ViewVC Help
View File | Revision Log | Show Annotations | Download File | View Changeset | Root Listing
root/repos/FeepingCreaturism/Matcher.hpp
(Generate patch)

Comparing FeepingCreaturism/Matcher.hpp (file contents):
Revision 191 by Douglas Thrift, 2004-08-20T02:44:20-07:00 vs.
Revision 203 by Douglas Thrift, 2004-09-01T02:10:19-07:00

# Line 7 | Line 7
7   #ifndef _Matcher_hpp_
8   #define _Matcher_hpp_
9  
10 #include <pcre.h>
11
10   #include "FeepingCreaturism.hpp"
11  
12 + #include <pcre.h>
13 +
14   class Matcher
15   {
16   private:
17          pcre* expression;
18 <        std::vector<std::string> substrings;
18 >        std::vector<ext::String> substrings;
19   public:
20          Matcher() : expression(NULL) {}
21 <        Matcher(const std::string& expression) : expression(NULL) { (*this)(expression); }
21 >        Matcher(const ext::String& expression) : expression(NULL) { (*this)(expression); }
22          ~Matcher() { if (expression != NULL) pcre_free(expression); }
23 <        bool match(const std::string& stuff);
23 >        bool match(const ext::String& stuff);
24          unsigned size(void) const { return substrings.size(); }
25 <        Matcher& operator()(const std::string& expression);
26 <        const std::string& operator[](unsigned index) const { return substrings[index]; }
27 <        operator std::string() const { return substrings[0]; }
28 <        bool operator==(const std::string& stuff) { return match(stuff); }
29 <        bool operator!=(const std::string& stuff) { return !match(stuff); }
25 >        Matcher& operator()(const ext::String& expression);
26 >        const ext::String& operator[](unsigned index) const { return substrings[index]; }
27 >        operator ext::String() const { return substrings[0]; }
28 >        bool operator==(const ext::String& stuff) { return match(stuff); }
29 >        bool operator!=(const ext::String& stuff) { return !match(stuff); }
30   // friends:
31 <        friend bool operator==(const std::string& stuff, Matcher& matcher) { return matcher == stuff; }
32 <        friend bool operator!=(const std::string& stuff, Matcher& matcher) { return matcher != stuff; }
31 >        friend bool operator==(const ext::String& stuff, Matcher& matcher) { return matcher == stuff; }
32 >        friend bool operator!=(const ext::String& stuff, Matcher& matcher) { return matcher != stuff; }
33   };
34  
35   #endif // _Matcher_hpp_

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines