1 /* $NetBSD: symbol.h,v 1.1.1.1 2016/01/13 18:41:48 christos Exp $ */
2
3 // -*- C++ -*-
4 /* Copyright (C) 1989, 1990, 1991, 1992, 2002, 2004
5 Free Software Foundation, Inc.
6 Written by James Clark (jjc@jclark.com)
7
8 This file is part of groff.
9
10 groff is free software; you can redistribute it and/or modify it under
11 the terms of the GNU General Public License as published by the Free
12 Software Foundation; either version 2, or (at your option) any later
13 version.
14
15 groff is distributed in the hope that it will be useful, but WITHOUT ANY
16 WARRANTY; without even the implied warranty of MERCHANTABILITY or
17 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
18 for more details.
19
20 You should have received a copy of the GNU General Public License along
21 with groff; see the file COPYING. If not, write to the Free Software
22 Foundation, 51 Franklin St - Fifth Floor, Boston, MA 02110-1301, USA. */
23
24 #define DONT_STORE 1
25 #define MUST_ALREADY_EXIST 2
26
27 class symbol {
28 static const char **table;
29 static int table_used;
30 static int table_size;
31 static char *block;
32 static int block_size;
33 const char *s;
34 public:
35 symbol(const char *p, int how = 0);
36 symbol();
37 unsigned long hash() const;
38 int operator ==(symbol) const;
39 int operator !=(symbol) const;
40 const char *contents() const;
41 int is_null() const;
42 int is_empty() const;
43 };
44
45
46 extern const symbol NULL_SYMBOL;
47 extern const symbol EMPTY_SYMBOL;
48
symbol()49 inline symbol::symbol() : s(0)
50 {
51 }
52
53 inline int symbol::operator==(symbol p) const
54 {
55 return s == p.s;
56 }
57
58 inline int symbol::operator!=(symbol p) const
59 {
60 return s != p.s;
61 }
62
hash()63 inline unsigned long symbol::hash() const
64 {
65 return (unsigned long)s;
66 }
67
contents()68 inline const char *symbol::contents() const
69 {
70 return s;
71 }
72
is_null()73 inline int symbol::is_null() const
74 {
75 return s == 0;
76 }
77
is_empty()78 inline int symbol::is_empty() const
79 {
80 return s != 0 && *s == 0;
81 }
82
83 symbol concat(symbol, symbol);
84
85 extern symbol default_symbol;
86