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 8This file is part of groff. 9 10groff is free software; you can redistribute it and/or modify it under 11the terms of the GNU General Public License as published by the Free 12Software Foundation; either version 2, or (at your option) any later 13version. 14 15groff is distributed in the hope that it will be useful, but WITHOUT ANY 16WARRANTY; without even the implied warranty of MERCHANTABILITY or 17FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 18for more details. 19 20You should have received a copy of the GNU General Public License along 21with groff; see the file COPYING. If not, write to the Free Software 22Foundation, 51 Franklin St - Fifth Floor, Boston, MA 02110-1301, USA. */ 23 24#define DONT_STORE 1 25#define MUST_ALREADY_EXIST 2 26 27class 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; 34public: 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 46extern const symbol NULL_SYMBOL; 47extern const symbol EMPTY_SYMBOL; 48 49inline symbol::symbol() : s(0) 50{ 51} 52 53inline int symbol::operator==(symbol p) const 54{ 55 return s == p.s; 56} 57 58inline int symbol::operator!=(symbol p) const 59{ 60 return s != p.s; 61} 62 63inline unsigned long symbol::hash() const 64{ 65 return (unsigned long)s; 66} 67 68inline const char *symbol::contents() const 69{ 70 return s; 71} 72 73inline int symbol::is_null() const 74{ 75 return s == 0; 76} 77 78inline int symbol::is_empty() const 79{ 80 return s != 0 && *s == 0; 81} 82 83symbol concat(symbol, symbol); 84 85extern symbol default_symbol; 86