home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Source Code 1993 July / THE_SOURCE_CODE_CD_ROM.iso / bsd_srcs / usr.bin / groff / libgroff / cset.h < prev    next >
Encoding:
C/C++ Source or Header  |  1991-04-30  |  1.6 KB  |  72 lines

  1. // -*- C++ -*-
  2. /* Copyright (C) 1989, 1990 Free Software Foundation, Inc.
  3.      Written by James Clark (jjc@jclark.uucp)
  4.  
  5. This file is part of groff.
  6.  
  7. groff is free software; you can redistribute it and/or modify it under
  8. the terms of the GNU General Public License as published by the Free
  9. Software Foundation; either version 1, or (at your option) any later
  10. version.
  11.  
  12. groff is distributed in the hope that it will be useful, but WITHOUT ANY
  13. WARRANTY; without even the implied warranty of MERCHANTABILITY or
  14. FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  15. for more details.
  16.  
  17. You should have received a copy of the GNU General Public License along
  18. with groff; see the file LICENSE.  If not, write to the Free Software
  19. Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
  20.  
  21. #ifndef UCHAR_MAX
  22. #define UCHAR_MAX 255
  23. #endif
  24.  
  25. enum cset_builtin { CSET_BUILTIN };
  26.  
  27. class cset {
  28. public:
  29.   cset();
  30.   cset(cset_builtin);
  31.   cset(const char *);
  32.   cset(const unsigned char *);
  33.   int operator()(unsigned char) const;
  34.  
  35.   cset &operator|=(const cset &);
  36.   cset &operator|=(unsigned char);
  37.  
  38.   friend class cset_init;
  39. private:
  40.   char v[UCHAR_MAX+1];
  41.   void clear();
  42. };
  43.  
  44. inline int cset::operator()(unsigned char c) const
  45. {
  46.   return v[c];
  47. }
  48.  
  49. inline cset &cset::operator|=(unsigned char c)
  50. {
  51.   v[c] = 1;
  52.   return *this;
  53. }
  54.  
  55. extern cset csalpha;
  56. extern cset csupper;
  57. extern cset cslower;
  58. extern cset csdigit;
  59. extern cset csxdigit;
  60. extern cset csspace;
  61. extern cset cspunct;
  62. extern cset csalnum;
  63. extern cset csprint;
  64. extern cset csgraph;
  65. extern cset cscntrl;
  66.  
  67. static class cset_init {
  68.   static int initialised;
  69. public:
  70.   cset_init();
  71. } _cset_init;
  72.