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 #include "pcre++.h"
00043
00044 using namespace std;
00045
00046
00047
00048
00049
00050
00051
00052 Array* Pcre::get_sub_strings() {
00053 if(resultset != NULL)
00054 return resultset;
00055 else
00056 return NULL;
00057 }
00058
00059 string Pcre::get_match(int pos) {
00060 if(pos >= 0 && pos < num_matches) {
00061 ArrayIterator P = resultset->begin() + pos;
00062 return *P;
00063 }
00064 else {
00065 throw exception("Pcre::get_match(int): out of range");
00066 }
00067 }
00068
00069 int Pcre::get_match_start() {
00070 if (sub_vec)
00071 return sub_vec[0];
00072 else
00073 return -1;
00074 }
00075
00076 int Pcre::get_match_end() {
00077 if (sub_vec)
00078 return sub_vec[1] - 1;
00079 else
00080 return -1;
00081 }
00082
00083 int Pcre::get_match_start(int pos) {
00084 if(pos >= 0 && pos <= num_matches) {
00085
00086
00087
00088 return sub_vec[ (++pos) * 2 ];
00089 }
00090 else {
00091 throw exception("Pcre::get_match_start(int): out of range");
00092 }
00093 }
00094
00095 int Pcre::get_match_end(int pos) {
00096 if(pos >= 0 && pos <= num_matches) {
00097
00098
00099
00100
00101
00102 return sub_vec[ ((++pos) * 2) + 1 ] - 1;
00103 }
00104 else {
00105 throw exception("Pcre::get_match_end(int): out of range");
00106 }
00107 }
00108
00109 size_t Pcre::get_match_length(int pos) {
00110 if(pos >= 0 && pos < num_matches) {
00111 ArrayIterator P = resultset->begin() + pos;
00112 return P->length();
00113 }
00114 else {
00115 throw exception("Pcre::get_match_length(int): out of range");
00116 }
00117 }