1 |
< |
// Smersh |
1 |
> |
// Zoe AIM Away Message RSS Feed Generator |
2 |
|
// |
3 |
|
// Douglas Thrift |
4 |
|
// |
6 |
|
|
7 |
|
#include "Matcher.hpp" |
8 |
|
|
9 |
< |
Matcher::Matcher(const std::string& expression) |
9 |
> |
Matcher::Matcher(const ext::String& expression) : expression(NULL) |
10 |
|
{ |
11 |
– |
this->expression = NULL; |
12 |
– |
|
11 |
|
(*this)(expression); |
12 |
|
} |
13 |
|
|
19 |
|
} |
20 |
|
} |
21 |
|
|
22 |
< |
bool Matcher::match(const std::string& stuff) |
22 |
> |
bool Matcher::match(const ext::String& stuff) |
23 |
|
{ |
24 |
|
substrings.clear(); |
25 |
|
|
29 |
|
|
30 |
|
pcre_fullinfo(expression, NULL, PCRE_INFO_CAPTURECOUNT, &length); |
31 |
|
|
32 |
< |
int* substrings = new int[(++length *= 3)]; |
33 |
< |
int count = pcre_exec(expression, NULL, stuff.c_str(), stuff.length(), |
34 |
< |
0, 0, substrings, length); |
32 |
> |
int* substrings(new int[(++length *= 3)]); |
33 |
> |
int count(pcre_exec(expression, NULL, stuff.c_str(), stuff.length(), 0, 0, |
34 |
> |
substrings, length)); |
35 |
|
|
36 |
|
if (count > 0) |
37 |
|
{ |
38 |
< |
char* substring = new char[stuff.length() + 1]; |
38 |
> |
char* substring(new char[stuff.length() + 1]); |
39 |
|
|
40 |
< |
for (int index = 0; index < count; index++) |
40 |
> |
for (int index(0); index < count; ++index) |
41 |
|
{ |
42 |
|
pcre_copy_substring(stuff.c_str(), substrings, count, index, |
43 |
|
substring, stuff.length() + 1); |
56 |
|
return false; |
57 |
|
} |
58 |
|
|
59 |
< |
Matcher& Matcher::operator()(const std::string& expression) |
59 |
> |
Matcher& Matcher::operator()(const ext::String& expression) |
60 |
|
{ |
61 |
|
substrings.clear(); |
62 |
|
|