ViewVC Help
View File | Revision Log | Show Annotations | Download File | View Changeset | Root Listing
root/repos/SiteMapper/Matcher.hpp
Revision: 285
Committed: 2004-11-28T03:01:11-08:00 (20 years, 7 months ago) by douglas
File size: 993 byte(s)
Log Message:
Wow, that's pretty big!

File Contents

# Content
1 // Site Mapper
2 //
3 // Douglas Thrift
4 //
5 // $Id$
6
7 #ifndef _Matcher_hpp_
8 #define _Matcher_hpp_
9
10 #include "SiteMapper.hpp"
11
12 #include <pcre.h>
13
14 class Matcher
15 {
16 private:
17 ::pcre* expression;
18 ext::Vector<ext::String> substrings;
19 public:
20 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 size_t size() { return substrings.GetSize(); }
25 Matcher& operator()(const ext::String& expression);
26 ext::String& operator[](size_t index) { return substrings[index]; }
27 bool operator==(const ext::String& stuff) { return match(stuff); }
28 bool operator!=(const ext::String& stuff) { return !match(stuff); }
29 // friends:
30 friend bool operator==(const ext::String& stuff, Matcher& matcher) { return matcher == stuff; }
31 friend bool operator!=(const ext::String& stuff, Matcher& matcher) { return matcher != stuff; }
32 };
33
34 #endif // _Matcher_hpp_

Properties

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