Main Page   Class Hierarchy   Compound List   File List   Compound Members   File Members  

pcre++.h

Go to the documentation of this file.
00001 /*
00002  *
00003  *  $Id: pcre++.h,v 1.1.1.1 2001/12/30 04:01:36 zarahg Exp $
00004  * 
00005  *  This file  is part of the  NABOU  Intrusion Detection System.
00006  *
00007  *  By  accessing  this software,  NABOU, you  are  duly informed
00008  *  of and agree to be  bound by the  conditions  described below
00009  *  in this notice:
00010  *
00011  *  This software product,  NABOU,  is developed by Thomas Linden
00012  *  and   copyrighted (C) 1999-2002   by  Thomas Linden, with all
00013  *  rights reserved.
00014  *
00015  *  There  is no charge for NABOU software.  You can redistribute
00016  *  it and/or modify it under the terms of the GNU General Public
00017  *  License, which is incorporated by reference herein.
00018  *
00019  *  NABOU is distributed WITHOUT ANY WARRANTY, IMPLIED OR EXPRESS,
00020  *  OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE or that
00021  *  the use of it will not infringe on any third party's intellec-
00022  *  tual property rights.
00023  *
00024  *  You should have received a copy of the GNU General Public
00025  *  License along with NABOU.  Copies can also be obtained from:
00026  *
00027  *    http://www.gnu.org/copyleft/gpl.html
00028  *
00029  *  or by writing to:
00030  *
00031  *  Free Software Foundation, Inc.
00032  *  59 Temple Place, Suite 330
00033  *  Boston, MA 02111-1307
00034  *  USA
00035  *
00036  *  Or contact:
00037  *
00038  *   "Thomas Linden" <tom@nabou.org>
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;         /* the given regular expression */
00095   pcre *p_pcre;              /* pcre object pointer */
00096   pcre_extra *p_pcre_extra;  /* stuff required by pcre lib */
00097   int sub_len;
00098   int *sub_vec;
00099   int erroffset;
00100   char *err_str;
00101   ResultSet *resultset;   /* store substrings, if any */
00102 
00103   /* reset all counters and free objects, prepare for another search */
00104   void reset();
00105 
00106   /* compile the pattern */
00107   void Compile(int flags);
00108 
00109   /* do the actual search, will be called by the public ::search(..) methods */
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  * Register exceptions of Pcre:: class
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

Generated at Fri Jan 4 03:57:03 2002 for PCRE++ by doxygen1.2.6 written by Dimitri van Heesch, © 1997-2001