home *** CD-ROM | disk | FTP | other *** search
/ GEMini Atari / GEMini_Atari_CD-ROM_Walnut_Creek_December_1993.iso / files / gnu / g__inc / xregex.h < prev    next >
Encoding:
C/C++ Source or Header  |  1993-07-23  |  2.4 KB  |  72 lines

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