home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Source Code 1993 July / THE_SOURCE_CODE_CD_ROM.iso / gnu / nihcl-3.0 / lib / Regex.h < prev    next >
Encoding:
C/C++ Source or Header  |  1990-05-20  |  2.4 KB  |  80 lines

  1. #ifndef    REGEX_H
  2. #define    REGEX_H
  3.  
  4. /*$Header: /afs/alw.nih.gov/unix/sun4_40c/usr/local/src/nihcl-3.0/share/lib/RCS/Regex.h,v 3.0 90/05/20 13:31:16 kgorlen Rel $*/
  5.  
  6. /* Regex.h -- header file for class Regex
  7.  
  8.     THIS SOFTWARE FITS THE DESCRIPTION IN THE U.S. COPYRIGHT ACT OF A
  9.     "UNITED STATES GOVERNMENT WORK".  IT WAS WRITTEN AS A PART OF THE
  10.     AUTHOR'S OFFICIAL DUTIES AS A GOVERNMENT EMPLOYEE.  THIS MEANS IT
  11.     CANNOT BE COPYRIGHTED.  THIS SOFTWARE IS FREELY AVAILABLE TO THE
  12.     PUBLIC FOR USE WITHOUT A COPYRIGHT NOTICE, AND THERE ARE NO
  13.     RESTRICTIONS ON ITS USE, NOW OR SUBSEQUENTLY.
  14.  
  15. Author:
  16.     K. E. Gorlen
  17.     Bg. 12A, Rm. 2033
  18.     Computer Systems Laboratory
  19.     Division of Computer Research and Technology
  20.     National Institutes of Health
  21.     Bethesda, Maryland 20892
  22.     Phone: (301) 496-1111
  23.     December, 1987
  24.  
  25. $Log:    Regex.h,v $
  26.  * Revision 3.0  90/05/20  13:31:16  kgorlen
  27.  * Release for 1st edition.
  28.  * 
  29. */
  30.  
  31. #include "String.h"
  32. #include "Range.h"
  33. #include "regex.h"
  34.  
  35. class Regex: public String {
  36.     DECLARE_MEMBERS(Regex);
  37.     struct re_pattern_buffer pattern;
  38.     unsigned ngroups;    // 1 + number of \( \) groups in pattern
  39.     struct re_registers regs;
  40.     void re_compile_pattern();
  41.     int re_match(const String&, int pos=0);
  42.     void init(int bufsize);
  43.     void fixCopy();
  44.     void setGroups(int);
  45.     void errRegex(const char*) const;
  46. public:
  47.     static const unsigned DEFAULT_BUFSIZE;
  48. protected:        // storer() functions for object I/O
  49.     virtual void storer(OIOofd&) const;
  50.     virtual void storer(OIOout&) const;
  51. public:
  52.     Regex(unsigned bufsize =DEFAULT_BUFSIZE);
  53.     Regex(const char*, unsigned bufsize =DEFAULT_BUFSIZE);
  54.     Regex(const Regex&);
  55.     ~Regex();
  56.     operator const char*() const    { return *(const String*)this; }
  57.     Range operator[](unsigned) const;
  58.     unsigned groups() const    { return ngroups; }
  59.     bool match(const String&, int pos=0);
  60.     int search(const String&, int startpos=0);
  61.     int search(const String&, int startpos, int range);
  62.     void operator=(const char*);
  63.     void operator=(const String&);
  64.     void operator=(const SubString&);
  65.     void operator=(const Regex&);
  66.     virtual void dumpOn(ostream& strm =cerr) const;
  67.     virtual void deepenShallowCopy();
  68.     virtual void scanFrom(istream& strm);
  69.     virtual void toAscii();
  70.     virtual void toLower();
  71.     virtual void toUpper();
  72. private:
  73.     String& operator&=(const String&)    { shouldNotImplement("operator&="); return *this; }
  74.     String& operator&=(const SubString&)    { shouldNotImplement("operator&="); return *this; }
  75.     String& operator&=(const char*)        { shouldNotImplement("operator&="); return *this; }
  76. };
  77.  
  78.  
  79. #endif
  80.