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

Comparing:
Bender/Matcher.hpp (file contents), Revision 115 by Douglas Thrift, 2004-03-16T22:53:38-08:00 vs.
Matcher/Menes/Matcher.hpp (file contents), Revision 324 by douglas, 2004-12-13T19:40:34-08:00

# Line 1 | Line 1
1 < // Bender
1 > // Matcher
2   //
3   // Douglas Thrift
4   //
# Line 7 | Line 7
7   #ifndef _Matcher_hpp_
8   #define _Matcher_hpp_
9  
10 < #include <pcre.h>
10 > #include <menes/platform.hpp>
11 >
12 > #ifdef MENES_PRAGMA_ONCE
13 > #pragma once
14 > #endif
15  
16 < #include "Bender.hpp"
16 > #include <menes-ext/casts.hpp>
17 > #include <menes-ext/string.hpp>
18 >
19 > #include <pcre.h>
20  
21   class Matcher
22   {
23   private:
24 <        pcre* expression;
25 <        vector<string> substrings;
24 >        ::pcre* expression;
25 >        ext::Vector<ext::String> substrings;
26   public:
27 <        Matcher() { expression = NULL; }
28 <        Matcher(const string& expression);
29 <        ~Matcher();
30 <        bool match(const string& stuff);
31 <        Matcher& operator()(const string& expression);
32 <        string& operator[](unsigned index) { return substrings[index]; }
33 <        bool operator==(const string& stuff) { return match(stuff); }
34 <        bool operator!=(const string& stuff) { return !match(stuff); }
27 >        Matcher() : expression(NULL) {}
28 >        Matcher(const ext::String& expression) : expression(NULL) { (*this)(expression); }
29 >        ~Matcher() { if (expression != NULL) ::pcre_free(expression); }
30 >        bool match(const ext::String& stuff);
31 >        size_t size() const { return substrings.GetSize(); }
32 >        Matcher& operator()(const ext::String& expression);
33 >        const ext::String& operator[](size_t index) const { return substrings[index]; }
34 >        operator ext::String() const { return substrings[0]; }
35 >        bool operator==(const ext::String& stuff) { return match(stuff); }
36 >        bool operator!=(const ext::String& stuff) { return !match(stuff); }
37   // friends:
38 <        friend bool operator==(const string& stuff, Matcher& matcher) { return
39 <                matcher == stuff; }
31 <        friend bool operator!=(const string& stuff, Matcher& matcher) { return
32 <                matcher != stuff; }
38 >        friend bool operator==(const ext::String& stuff, Matcher& matcher) { return matcher == stuff; }
39 >        friend bool operator!=(const ext::String& stuff, Matcher& matcher) { return matcher != stuff; }
40   };
41  
42   #endif // _Matcher_hpp_

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines