00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
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
00178 extern FXAPI FXStream& operator<<(FXStream& store,const FXRex& s);
00179 extern FXAPI FXStream& operator>>(FXStream& store,FXRex& s);
00180
00181 }
00182
00183 #endif