18 |
|
std::vector<ext::String> substrings; |
19 |
|
public: |
20 |
|
Matcher() : expression(NULL) {} |
21 |
< |
Matcher(const ext::String& expression); |
22 |
< |
~Matcher(); |
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 |
27 |
< |
substrings[index]; } |
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 |
|
// friends: |
31 |
< |
friend bool operator==(const ext::String& stuff, Matcher& matcher) { return |
32 |
< |
matcher == stuff; } |
34 |
< |
friend bool operator!=(const ext::String& stuff, Matcher& matcher) { return |
35 |
< |
matcher != stuff; } |
31 |
> |
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 |
|
}; |
34 |
|
|
35 |
|
#endif // _Matcher_hpp_ |