00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043 #ifndef HAVE_PCRE_PP_H
00044 #define HAVE_PCRE_PP_H
00045
00046 #include <string>
00047 #include <vector>
00048
00049 extern "C" {
00050 #include <pcre.h>
00051 }
00052
00053 #include "exception.h"
00054
00055 #include "config.h"
00056
00057
00058
00060 typedef vector<string>::iterator ResultIterator;
00061
00063 typedef vector<string> ResultSet;
00064
00092 class Pcre {
00093 private:
00094 string _expression;
00095 pcre *p_pcre;
00096 pcre_extra *p_pcre_extra;
00097 int sub_len;
00098 int *sub_vec;
00099 int erroffset;
00100 char *err_str;
00101 ResultSet *resultset;
00102
00103
00104 void reset();
00105
00106
00107 void Compile(int flags);
00108
00109
00110 bool dosearch(const string& stuff, int OffSet);
00111
00112 public:
00113 bool did_match;
00114 int num_matches;
00124 Pcre(const string& expression);
00125
00148 Pcre(const string& expression, const string& flags);
00149
00157 Pcre(Pcre &P);
00158
00169 const Pcre& operator = (const string& expression);
00170
00176 ~Pcre();
00177
00184 bool search(const string& stuff);
00185
00193 bool search(const string& stuff, int OffSet);
00194
00199 ResultSet* get_sub_strings();
00200
00215 string get_match(int pos);
00216
00235 int get_match_start(int pos);
00236
00255 int get_match_end(int pos);
00256
00261 bool matched() { return did_match; };
00262
00266 int matches() { return num_matches; };
00267 };
00268
00269
00270
00271
00272
00273 class PcreException : public Exception {
00274 private:
00275 int errnum;
00276 public:
00277 PcreException(int num);
00278 PcreException(const string& msg);
00279 };
00280
00281 #endif