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