ViewVC Help
View File | Revision Log | Show Annotations | Download File | View Changeset | Root Listing
root/repos/SiteMapper/Matcher.hpp
Revision: 299
Committed: 2004-12-12T16:39:07-08:00 (20 years, 6 months ago) by douglas
File size: 1039 byte(s)
Log Message:
May actually work on Windows, probably not.

File Contents

# User Rev Content
1 Douglas Thrift 126 // Site Mapper
2     //
3     // Douglas Thrift
4     //
5     // $Id$
6    
7     #ifndef _Matcher_hpp_
8     #define _Matcher_hpp_
9    
10 douglas 299 #ifdef MENES_PRAGMA_ONCE
11     #pragma once
12     #endif
13    
14 Douglas Thrift 200 #include "SiteMapper.hpp"
15    
16 Douglas Thrift 126 #include <pcre.h>
17    
18     class Matcher
19     {
20     private:
21 douglas 285 ::pcre* expression;
22     ext::Vector<ext::String> substrings;
23 Douglas Thrift 126 public:
24 douglas 285 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 Douglas Thrift 126 // friends:
34 douglas 285 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 Douglas Thrift 126 };
37    
38     #endif // _Matcher_hpp_

Properties

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