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