14 |
|
class Matcher |
15 |
|
{ |
16 |
|
private: |
17 |
< |
pcre* expression; |
18 |
< |
vector<string> substrings; |
17 |
> |
::pcre* expression; |
18 |
> |
ext::Vector<ext::String> substrings; |
19 |
|
public: |
20 |
< |
Matcher() { expression = NULL; } |
21 |
< |
Matcher(const string& expression); |
22 |
< |
~Matcher(); |
23 |
< |
bool match(const string& stuff); |
24 |
< |
int size(void) { return substrings.size(); } |
25 |
< |
Matcher& operator()(const string& expression); |
26 |
< |
string& operator[](unsigned index) { return substrings[index]; } |
27 |
< |
bool operator==(const string& stuff) { return match(stuff); } |
28 |
< |
bool operator!=(const string& stuff) { return !match(stuff); } |
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 string& stuff, Matcher& matcher) { return |
31 |
< |
matcher == stuff; } |
32 |
< |
friend bool operator!=(const string& stuff, Matcher& matcher) { return |
33 |
< |
matcher != stuff; } |
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_ |