1151497Sru// -*- C++ -*-
2151497Sru/* Copyright (C) 1989, 1990, 1991, 1992, 2002, 2004
3151497Sru   Free Software Foundation, Inc.
4151497Sru     Written by James Clark (jjc@jclark.com)
5151497Sru
6151497SruThis file is part of groff.
7151497Sru
8151497Srugroff is free software; you can redistribute it and/or modify it under
9151497Sruthe terms of the GNU General Public License as published by the Free
10151497SruSoftware Foundation; either version 2, or (at your option) any later
11151497Sruversion.
12151497Sru
13151497Srugroff is distributed in the hope that it will be useful, but WITHOUT ANY
14151497SruWARRANTY; without even the implied warranty of MERCHANTABILITY or
15151497SruFITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
16151497Srufor more details.
17151497Sru
18151497SruYou should have received a copy of the GNU General Public License along
19151497Sruwith groff; see the file COPYING.  If not, write to the Free Software
20151497SruFoundation, 51 Franklin St - Fifth Floor, Boston, MA 02110-1301, USA. */
21151497Sru
22151497Sru#define DONT_STORE 1
23151497Sru#define MUST_ALREADY_EXIST 2
24151497Sru
25151497Sruclass symbol {
26151497Sru  static const char **table;
27151497Sru  static int table_used;
28151497Sru  static int table_size;
29151497Sru  static char *block;
30151497Sru  static int block_size;
31151497Sru  const char *s;
32151497Srupublic:
33151497Sru  symbol(const char *p, int how = 0);
34151497Sru  symbol();
35151497Sru  unsigned long hash() const;
36151497Sru  int operator ==(symbol) const;
37151497Sru  int operator !=(symbol) const;
38151497Sru  const char *contents() const;
39151497Sru  int is_null() const;
40151497Sru  int is_empty() const;
41151497Sru};
42151497Sru
43151497Sru
44151497Sruextern const symbol NULL_SYMBOL;
45151497Sruextern const symbol EMPTY_SYMBOL;
46151497Sru
47151497Sruinline symbol::symbol() : s(0)
48151497Sru{
49151497Sru}
50151497Sru
51151497Sruinline int symbol::operator==(symbol p) const
52151497Sru{
53151497Sru  return s == p.s;
54151497Sru}
55151497Sru
56151497Sruinline int symbol::operator!=(symbol p) const
57151497Sru{
58151497Sru  return s != p.s;
59151497Sru}
60151497Sru
61151497Sruinline unsigned long symbol::hash() const
62151497Sru{
63151497Sru  return (unsigned long)s;
64151497Sru}
65151497Sru
66151497Sruinline const char *symbol::contents() const
67151497Sru{
68151497Sru  return s;
69151497Sru}
70151497Sru
71151497Sruinline int symbol::is_null() const
72151497Sru{
73151497Sru  return s == 0;
74151497Sru}
75151497Sru
76151497Sruinline int symbol::is_empty() const
77151497Sru{
78151497Sru  return s != 0 && *s == 0;
79151497Sru}
80151497Sru
81151497Srusymbol concat(symbol, symbol);
82151497Sru
83151497Sruextern symbol default_symbol;
84