• Main Page
  • Related Pages
  • Namespaces
  • Data Structures
  • Files
  • File List
  • Globals

Regex.h

Go to the documentation of this file.
00001 /** @file
00002 
00003   A brief file description
00004 
00005   @section license License
00006 
00007   Licensed to the Apache Software Foundation (ASF) under one
00008   or more contributor license agreements.  See the NOTICE file
00009   distributed with this work for additional information
00010   regarding copyright ownership.  The ASF licenses this file
00011   to you under the Apache License, Version 2.0 (the
00012   "License"); you may not use this file except in compliance
00013   with the License.  You may obtain a copy of the License at
00014 
00015       http://www.apache.org/licenses/LICENSE-2.0
00016 
00017   Unless required by applicable law or agreed to in writing, software
00018   distributed under the License is distributed on an "AS IS" BASIS,
00019   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00020   See the License for the specific language governing permissions and
00021   limitations under the License.
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, // default is case sensitive
00037   RE_UNANCHORED = 0x0002        // default is to anchor at the first matching position
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 /* __TS_REGEX_H__ */

Generated by  doxygen 1.7.1