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 
59 class FXAPI FXRex {
60 private:
61  FXuchar *code;
62 private:
63  static const FXchar *const errors[];
64  static const FXuchar fallback[];
65 public:
66 
68  enum {
69 
71  Normal = 0,
72  Unicode = 1,
73 
75  Syntax = 2,
76  Verbatim = 4,
77  Capture = 8,
78  IgnoreCase = 16,
79  Newline = 32,
80  Exact = 64,
81  NotEmpty = 128,
82 
84  NotBol = 256,
85  NotEol = 512
86  };
87 
89  enum Error {
90  ErrOK = 0,
91  ErrEmpty = 1,
92  ErrParent = 2,
93  ErrBracket = 3,
94  ErrBrace = 4,
95  ErrRange = 5,
96  ErrEscape = 6,
97  ErrCount = 7,
98  ErrNoAtom = 8,
99  ErrRepeat = 9,
100  ErrBackRef = 10,
101  ErrClass = 11,
102  ErrComplex = 12,
103  ErrMemory = 13,
104  ErrToken = 14,
105  ErrBehind = 15,
106  ErrSupport = 16
107  };
108 
109 public:
110 
115  FXRex();
116 
120  FXRex(const FXRex& orig);
121 
123  FXRex(const FXchar* pattern,FXint mode=Normal,Error* error=NULL);
124 
126  FXRex(const FXString& pattern,FXint mode=Normal,Error* error=NULL);
127 
133  FXbool empty() const { return (code==fallback); }
134 
142  Error parse(const FXchar* pattern,FXint mode=Normal);
143  Error parse(const FXString& pattern,FXint mode=Normal);
144 
151  FXbool amatch(const FXchar* string,FXint len,FXint pos=0,FXint mode=Normal,FXint* beg=NULL,FXint* end=NULL,FXint npar=0) const;
152  FXbool amatch(const FXString& string,FXint pos=0,FXint mode=Normal,FXint* beg=NULL,FXint* end=NULL,FXint npar=0) const;
153 
162  FXint search(const FXchar* string,FXint len,FXint fm,FXint to,FXint mode=Normal,FXint* beg=NULL,FXint* end=NULL,FXint npar=0) const;
163  FXint search(const FXString& string,FXint fm,FXint to,FXint mode=Normal,FXint* beg=NULL,FXint* end=NULL,FXint npar=0) const;
164 
174  static FXString substitute(const FXchar* string,FXint len,FXint* beg,FXint* end,const FXchar* replace,FXint npar=1);
175  static FXString substitute(const FXchar* string,FXint len,FXint* beg,FXint* end,const FXString& replace,FXint npar=1);
176  static FXString substitute(const FXString& string,FXint* beg,FXint* end,const FXchar* replace,FXint npar=1);
177  static FXString substitute(const FXString& string,FXint* beg,FXint* end,const FXString& replace,FXint npar=1);
178 
180  static const FXchar* getError(Error err){ return errors[err]; }
181 
183  FXRex& operator=(const FXRex& orig);
184 
186  FXbool operator==(const FXRex& rex) const;
187  FXbool operator!=(const FXRex& rex) const;
188 
190  friend FXAPI FXStream& operator<<(FXStream& store,const FXRex& s);
191  friend FXAPI FXStream& operator>>(FXStream& store,FXRex& s);
192 
196  void clear();
197 
199  ~FXRex();
200  };
201 
202 
203 // Serialization
204 extern FXAPI FXStream& operator<<(FXStream& store,const FXRex& s);
205 extern FXAPI FXStream& operator>>(FXStream& store,FXRex& s);
206 
207 }
208 
209 #endif

Copyright © 1997-2016 Jeroen van der Zijp