ViewVC Help
View File | Revision Log | Show Annotations | Download File | View Changeset | Root Listing
root/repos/Bender/Matcher.hpp
Revision: 266
Committed: 2004-10-27T04:14:56-07:00 (20 years, 8 months ago) by Douglas Thrift
File size: 1059 byte(s)
Log Message:
Wow!

File Contents

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

Properties

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