ViewVC Help
View File | Revision Log | Show Annotations | Download File | View Changeset | Root Listing
root/zoe/trunk/Matcher.hpp
Revision: 34
Committed: 2004-07-20T16:49:06-07:00 (20 years, 11 months ago) by douglas
File size: 1089 byte(s)
Log Message:
Yeah, that's right.

File Contents

# User Rev Content
1 douglas 6 // Zoe AIM Away Message RSS Feed Generator
2 douglas 5 //
3     // Douglas Thrift
4     //
5     // $Id$
6    
7     #ifndef _Matcher_hpp_
8     #define _Matcher_hpp_
9    
10     #include <pcre.h>
11    
12     #include "Zoe.hpp"
13    
14     class Matcher
15     {
16     private:
17     pcre* expression;
18 douglas 7 std::vector<ext::String> substrings;
19 douglas 5 public:
20     Matcher() : expression(NULL) {}
21 douglas 34 Matcher(const ext::String& expression) : expression(NULL) { (*this)(expression); }
22     ~Matcher() { if (expression != NULL) pcre_free(expression); }
23 douglas 7 bool match(const ext::String& stuff);
24 douglas 5 unsigned size(void) const { return substrings.size(); }
25 douglas 7 Matcher& operator()(const ext::String& expression);
26 douglas 34 const ext::String& operator[](unsigned index) const { return substrings[index]; }
27 douglas 7 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 douglas 5 // friends:
31 douglas 34 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 douglas 5 };
34    
35     #endif // _Matcher_hpp_

Properties

Name Value
svn:eol-style native
svn:keywords Id