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

/home/jeroen/FOX/fox/fox-1.7.33/include/FXRex.h
00001 /********************************************************************************
00002 *                                                                               *
00003 *                 R e g u l a r   E x p r e s s i o n   C l a s s               *
00004 *                                                                               *
00005 *********************************************************************************
00006 * Copyright (C) 1999,2012 by Jeroen van der Zijp.   All Rights Reserved.        *
00007 *********************************************************************************
00008 * This library is free software; you can redistribute it and/or modify          *
00009 * it under the terms of the GNU Lesser General Public License as published by   *
00010 * the Free Software Foundation; either version 3 of the License, or             *
00011 * (at your option) any later version.                                           *
00012 *                                                                               *
00013 * This library is distributed in the hope that it will be useful,               *
00014 * but WITHOUT ANY WARRANTY; without even the implied warranty of                *
00015 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the                 *
00016 * GNU Lesser General Public License for more details.                           *
00017 *                                                                               *
00018 * You should have received a copy of the GNU Lesser General Public License      *
00019 * along with this program.  If not, see <http://www.gnu.org/licenses/>          *
00020 ********************************************************************************/
00021 #ifndef FXREX_H
00022 #define FXREX_H
00023 
00024 
00025 namespace FX {
00026 
00027 
00058 class FXAPI FXRex {
00059 private:
00060   FXuchar *code;
00061 private:
00062   static const FXchar *const errors[];
00063   static const FXuchar fallback[];
00064 public:
00065 
00067   enum {
00068     Normal     = 0,     
00069     Capture    = 1,     
00070     IgnoreCase = 2,     
00071     Newline    = 4,     
00072     Verbatim   = 8,     
00073     Syntax     = 16,    
00074     Unicode    = 32     
00075     };
00076 
00077 
00079   enum {
00080     Forward    = 0,     
00081     Backward   = 64,    
00082     NotBol     = 128,   
00083     NotEol     = 256,   
00084     NotEmpty   = 512    
00085     };
00086 
00088   enum Error {
00089     ErrOK      = 0,     
00090     ErrEmpty   = 1,     
00091     ErrParent  = 2,     
00092     ErrBracket = 3,     
00093     ErrBrace   = 4,     
00094     ErrRange   = 5,     
00095     ErrEscape  = 6,     
00096     ErrCount   = 7,     
00097     ErrNoAtom  = 8,     
00098     ErrRepeat  = 9,     
00099     ErrBackRef = 10,    
00100     ErrClass   = 11,    
00101     ErrComplex = 12,    
00102     ErrMemory  = 13,    
00103     ErrToken   = 14,    
00104     ErrBehind  = 15     
00105     };
00106 
00107 public:
00108 
00110   FXRex();
00111 
00113   FXRex(const FXRex& orig);
00114 
00116   FXRex(const FXchar* pattern,FXint mode=Normal,Error* error=NULL);
00117 
00119   FXRex(const FXString& pattern,FXint mode=Normal,Error* error=NULL);
00120 
00122   FXRex& operator=(const FXRex& orig);
00123 
00129   FXbool empty() const { return (code==fallback); }
00130 
00132   FXRex::Error parse(const FXchar* pattern,FXint mode=Normal);
00133 
00135   FXRex::Error parse(const FXString& pattern,FXint mode=Normal);
00136 
00144   FXbool match(const FXchar* string,FXint len,FXint* beg=NULL,FXint* end=NULL,FXint mode=Forward,FXint npar=1,FXint fm=0,FXint to=2147483647) const;
00145 
00147   FXbool match(const FXString& string,FXint* beg=NULL,FXint* end=NULL,FXint mode=Forward,FXint npar=1,FXint fm=0,FXint to=2147483647) const;
00148 
00156   static FXString substitute(const FXchar* string,FXint len,FXint* beg,FXint* end,const FXString& replace,FXint npar=1);
00157 
00159   static FXString substitute(const FXString& string,FXint* beg,FXint* end,const FXString& replace,FXint npar=1);
00160 
00162   static const FXchar* getError(FXRex::Error err){ return errors[err]; }
00163 
00165   FXbool operator==(const FXRex& rex) const;
00166   FXbool operator!=(const FXRex& rex) const;
00167 
00169   friend FXAPI FXStream& operator<<(FXStream& store,const FXRex& s);
00170   friend FXAPI FXStream& operator>>(FXStream& store,FXRex& s);
00171 
00173  ~FXRex();
00174   };
00175 
00176 
00177 // Serialization
00178 extern FXAPI FXStream& operator<<(FXStream& store,const FXRex& s);
00179 extern FXAPI FXStream& operator>>(FXStream& store,FXRex& s);
00180 
00181 }
00182 
00183 #endif

Copyright © 1997-2011 Jeroen van der Zijp