1*58184Selan // This may look like C code, but it is really -*- C++ -*- 2*58184Selan /* 3*58184Selan Copyright (C) 1988 Free Software Foundation 4*58184Selan written by Doug Lea (dl@rocky.oswego.edu) 5*58184Selan 6*58184Selan This file is part of the GNU C++ Library. This library is free 7*58184Selan software; you can redistribute it and/or modify it under the terms of 8*58184Selan the GNU Library General Public License as published by the Free 9*58184Selan Software Foundation; either version 2 of the License, or (at your 10*58184Selan option) any later version. This library is distributed in the hope 11*58184Selan that it will be useful, but WITHOUT ANY WARRANTY; without even the 12*58184Selan implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 13*58184Selan PURPOSE. See the GNU Library General Public License for more details. 14*58184Selan You should have received a copy of the GNU Library General Public 15*58184Selan License along with this library; if not, write to the Free Software 16*58184Selan Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. 17*58184Selan */ 18*58184Selan 19*58184Selan 20*58184Selan #ifndef _Regex_h 21*58184Selan #ifdef __GNUG__ 22*58184Selan #pragma interface 23*58184Selan #endif 24*58184Selan #define _Regex_h 1 25*58184Selan 26*58184Selan #if defined(SHORT_NAMES) || defined(VMS) 27*58184Selan #define re_compile_pattern recmppat 28*58184Selan #define re_pattern_buffer repatbuf 29*58184Selan #define re_registers reregs 30*58184Selan #endif 31*58184Selan 32*58184Selan struct re_pattern_buffer; // defined elsewhere 33*58184Selan struct re_registers; 34*58184Selan 35*58184Selan class Regex 36*58184Selan { 37*58184Selan private: 38*58184Selan Regex(const Regex &)39*58184Selan Regex(const Regex&) {} // no X(X&) 40*58184Selan void operator = (const Regex&) {} // no assignment 41*58184Selan 42*58184Selan protected: 43*58184Selan re_pattern_buffer* buf; 44*58184Selan re_registers* reg; 45*58184Selan 46*58184Selan public: 47*58184Selan Regex(const char* t, 48*58184Selan int fast = 0, 49*58184Selan int bufsize = 40, 50*58184Selan const char* transtable = 0); 51*58184Selan 52*58184Selan ~Regex(); 53*58184Selan 54*58184Selan int match(const char* s, int len, int pos = 0) const; 55*58184Selan int search(const char* s, int len, 56*58184Selan int& matchlen, int startpos = 0) const; 57*58184Selan int match_info(int& start, int& length, int nth = 0) const; 58*58184Selan 59*58184Selan int OK() const; // representation invariant 60*58184Selan }; 61*58184Selan 62*58184Selan // some built in regular expressions 63*58184Selan 64*58184Selan extern const Regex RXwhite; // = "[ \n\t\r\v\f]+" 65*58184Selan extern const Regex RXint; // = "-?[0-9]+" 66*58184Selan extern const Regex RXdouble; // = "-?\\(\\([0-9]+\\.[0-9]*\\)\\| 67*58184Selan // \\([0-9]+\\)\\|\\(\\.[0-9]+\\)\\) 68*58184Selan // \\([eE][---+]?[0-9]+\\)?" 69*58184Selan extern const Regex RXalpha; // = "[A-Za-z]+" 70*58184Selan extern const Regex RXlowercase; // = "[a-z]+" 71*58184Selan extern const Regex RXuppercase; // = "[A-Z]+" 72*58184Selan extern const Regex RXalphanum; // = "[0-9A-Za-z]+" 73*58184Selan extern const Regex RXidentifier; // = "[A-Za-z_][A-Za-z0-9_]*" 74*58184Selan 75*58184Selan 76*58184Selan #endif 77