ViewVC Help
View File | Revision Log | Show Annotations | Download File | View Changeset | Root Listing
root/repos/SiteMapper/Matcher.hpp
Revision: 312
Committed: 2004-12-13T15:01:12-08:00 (20 years, 6 months ago) by douglas
File size: 1039 byte(s)
Log Message:
This might be a little more sane.

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 #ifdef MENES_PRAGMA_ONCE
13 #pragma once
14 #endif
15
16 #include <pcre.h>
17
18 class Matcher
19 {
20 private:
21 ::pcre* expression;
22 ext::Vector<ext::String> substrings;
23 public:
24 Matcher() : expression(NULL) {}
25 Matcher(const ext::String& expression) : expression(NULL) { (*this)(expression); }
26 ~Matcher() { if (expression != NULL) ::pcre_free(expression); }
27 bool match(const ext::String& stuff);
28 size_t size() { return substrings.GetSize(); }
29 Matcher& operator()(const ext::String& expression);
30 ext::String& operator[](size_t index) { return substrings[index]; }
31 bool operator==(const ext::String& stuff) { return match(stuff); }
32 bool operator!=(const ext::String& stuff) { return !match(stuff); }
33 // friends:
34 friend bool operator==(const ext::String& stuff, Matcher& matcher) { return matcher == stuff; }
35 friend bool operator!=(const ext::String& stuff, Matcher& matcher) { return matcher != stuff; }
36 };
37
38 #endif // _Matcher_hpp_

Properties

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