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

FXRex.h
1 /********************************************************************************
2 * *
3 * R e g u l a r E x p r e s s i o n C l a s s *
4 * *
5 *********************************************************************************
6 * Copyright (C) 1999,2017 by Jeroen van der Zijp. All Rights Reserved. *
7 *********************************************************************************
8 * This library is free software; you can redistribute it and/or modify *
9 * it under the terms of the GNU Lesser General Public License as published by *
10 * the Free Software Foundation; either version 3 of the License, or *
11 * (at your option) any later version. *
12 * *
13 * This library is distributed in the hope that it will be useful, *
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
16 * GNU Lesser General Public License for more details. *
17 * *
18 * You should have received a copy of the GNU Lesser General Public License *
19 * along with this program. If not, see <http://www.gnu.org/licenses/> *
20 ********************************************************************************/
21 #ifndef FXREX_H
22 #define FXREX_H
23 
24 namespace FX {
25 
26 
67 class FXAPI FXRex {
68 private:
69  FXuchar *code;
70 private:
71  static const FXchar *const errors[];
72  static const FXuchar fallback[];
73 public:
74 
76  enum {
77 
79  Normal = 0,
80  Unicode = 1,
81 
83  Syntax = 2,
84  Verbatim = 4,
85  Capture = 8,
86  IgnoreCase = 16,
87  Newline = 32,
88  Exact = 64,
89  NotEmpty = 128,
90  Reverse = 256,
91 
93  NotBol = 512,
94  NotEol = 1024
95  };
96 
98  enum Error {
99  ErrOK = 0,
100  ErrEmpty = 1,
101  ErrParent = 2,
102  ErrBracket = 3,
103  ErrBrace = 4,
104  ErrRange = 5,
105  ErrEscape = 6,
106  ErrCount = 7,
107  ErrNoAtom = 8,
108  ErrRepeat = 9,
109  ErrBackRef = 10,
110  ErrClass = 11,
111  ErrComplex = 12,
112  ErrMemory = 13,
113  ErrToken = 14,
114  ErrBehind = 15,
115  ErrSupport = 16
116  };
117 
118 public:
119 
124  FXRex();
125 
129  FXRex(const FXRex& orig);
130 
132  FXRex(const FXchar* pattern,FXint mode=Normal,Error* error=NULL);
133 
135  FXRex(const FXString& pattern,FXint mode=Normal,Error* error=NULL);
136 
142  FXbool empty() const { return (code==fallback); }
143 
151  Error parse(const FXchar* pattern,FXint mode=Normal);
152  Error parse(const FXString& pattern,FXint mode=Normal);
153 
160  FXbool amatch(const FXchar* string,FXint len,FXint pos=0,FXint mode=Normal,FXint* beg=NULL,FXint* end=NULL,FXint npar=0) const;
161  FXbool amatch(const FXString& string,FXint pos=0,FXint mode=Normal,FXint* beg=NULL,FXint* end=NULL,FXint npar=0) const;
162 
171  FXint search(const FXchar* string,FXint len,FXint fm,FXint to,FXint mode=Normal,FXint* beg=NULL,FXint* end=NULL,FXint npar=0) const;
172  FXint search(const FXString& string,FXint fm,FXint to,FXint mode=Normal,FXint* beg=NULL,FXint* end=NULL,FXint npar=0) const;
173 
183  static FXString substitute(const FXchar* string,FXint len,FXint* beg,FXint* end,const FXchar* replace,FXint npar=1);
184  static FXString substitute(const FXchar* string,FXint len,FXint* beg,FXint* end,const FXString& replace,FXint npar=1);
185  static FXString substitute(const FXString& string,FXint* beg,FXint* end,const FXchar* replace,FXint npar=1);
186  static FXString substitute(const FXString& string,FXint* beg,FXint* end,const FXString& replace,FXint npar=1);
187 
189  static const FXchar* getError(Error err){ return errors[err]; }
190 
192  FXRex& operator=(const FXRex& orig);
193 
195  FXbool operator==(const FXRex& rex) const;
196  FXbool operator!=(const FXRex& rex) const;
197 
199  friend FXAPI FXStream& operator<<(FXStream& store,const FXRex& s);
200  friend FXAPI FXStream& operator>>(FXStream& store,FXRex& s);
201 
205  void clear();
206 
208  ~FXRex();
209  };
210 
211 
212 // Serialization
213 extern FXAPI FXStream& operator<<(FXStream& store,const FXRex& s);
214 extern FXAPI FXStream& operator>>(FXStream& store,FXRex& s);
215 
216 }
217 
218 #endif

Copyright © 1997-2016 Jeroen van der Zijp