1
// RegExp class - search text using regular expressions
3
//Please refer to http://dansguardian.org/?page=copyright2
4
//for the license for this code.
5
//Written by Daniel Barron (daniel@// jadeb.com).
6
//For support go to http://groups.yahoo.com/group/dansguardian
8
// This program is free software; you can redistribute it and/or modify
9
// it under the terms of the GNU General Public License as published by
10
// the Free Software Foundation; either version 2 of the License, or
11
// (at your option) any later version.
13
// This program is distributed in the hope that it will be useful,
14
// but WITHOUT ANY WARRANTY; without even the implied warranty of
15
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
// GNU General Public License for more details.
18
// You should have received a copy of the GNU General Public License
19
// along with this program; if not, write to the Free Software
20
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
30
#include <sys/types.h> // needed for size_t used in regex.h
33
#include <pcreposix.h>
51
// constructor - set sensible defaults
53
// destructor - delete regexp if compiled
56
RegExp(const RegExp & r);
58
// compile the given regular expression
59
bool comp(const char *exp);
60
// match the given text against the pre-compiled expression
61
bool match(const char *text);
63
// how many matches did the last run generate?
64
int numberOfMatches();
65
// did it generate any at all?
68
// the i'th match from the last run
69
std::string result(int i);
70
// position of the i'th match in the overall text
71
unsigned int offset(int i);
72
// length of the i'th match
73
unsigned int length(int i);
75
// faster equivalent of STL::Search
76
char *search(char *file, char *fileend, char *phrase, char *phraseend);
79
// the match results, their positions in the text & their lengths
80
std::deque<std::string> results;
81
std::deque<unsigned int> offsets;
82
std::deque<unsigned int> lengths;
84
// have we matched something yet?
87
// the expression itself
89
// whether it's been pre-compiled
92
// the uncompiled form of the expression (checkme: is this only used
93
// for debugging purposes?)
94
std::string searchstring;