Go to the documentation of this file.00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 
00012 
00013 
00014 
00015 
00016 
00017 
00018 
00019 
00020 
00021 
00022 
00023 
00024 #ifndef __TS_REGEX_H__
00025 #define __TS_REGEX_H__
00026 
00027 #ifdef HAVE_PCRE_PCRE_H
00028 #include <pcre/pcre.h>
00029 #else
00030 #include <pcre.h>
00031 #endif
00032 
00033 
00034 enum REFlags
00035 {
00036   RE_CASE_INSENSITIVE = 0x0001, 
00037   RE_UNANCHORED = 0x0002        
00038 };
00039 
00040 typedef struct __pat {
00041   int _idx;
00042   pcre *_re;
00043   pcre_extra *_pe;
00044   char *_p;
00045   __pat * _next;
00046 } dfa_pattern;
00047 
00048 class DFA
00049 {
00050 public:
00051   DFA():_my_patterns(0) {
00052   }
00053   
00054   ~DFA();
00055 
00056   int compile(const char *pattern, unsigned flags = 0);
00057   int compile(const char **patterns, int npatterns, unsigned flags = 0);
00058   
00059   int match(const char *str) const;
00060   int match(const char *str, int length) const;
00061 
00062 private:
00063   dfa_pattern * build(const char *pattern, unsigned flags = 0);
00064 
00065   dfa_pattern * _my_patterns;
00066 };
00067 
00068 
00069 #endif