/contrib/groff/src/include/cset.h

https://bitbucket.org/freebsd/freebsd-head/ · C++ Header · 75 lines · 47 code · 9 blank · 19 comment · 0 complexity · 36fdd5fe65e0a72d71e6bc9dde7a8349 MD5 · raw file

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