2 * CDE - Common Desktop Environment
4 * Copyright (c) 1993-2012, The Open Group. All rights reserved.
6 * These libraries and programs are free software; you can
7 * redistribute them and/or modify them under the terms of the GNU
8 * Lesser General Public License as published by the Free Software
9 * Foundation; either version 2 of the License, or (at your option)
12 * These libraries and programs are distributed in the hope that
13 * they will be useful, but WITHOUT ANY WARRANTY; without even the
14 * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU Lesser General Public License for more
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with these librararies and programs; if not, write
20 * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
21 * Floor, Boston, MA 02110-1301 USA
23 /* $XConsortium: SymTab.h /main/5 1996/08/21 15:50:57 drk $ */
31 #include "dti_cc/CC_String.h"
32 #include "dti_cc/cc_hdict.h"
33 //#include "StyleSheet/cde_next.h"
40 /* **************************************************************
41 Creating a Symbol Table Class
43 Symbol Table has one user function, intern, which returns a
47 A Symbol can be compared to other symbols using the == operator.
48 Symbols will only be == if they are the same symbol in the same
51 * ************************************************************** */
54 // forward declarations
57 /* -------- class SymbolName -------- */
58 // derived from CC_String to give a version of ==
60 // should be privately inherited with a few promotions
62 class SymbolName : public CC_String
65 SymbolName(const char *);
66 unsigned int operator==(const SymbolName &);
67 ostream &print(ostream &) const ;
74 /* **************************************************************
75 SymbolTable derives privately from RWTPtrHashSet so only the
76 SymbolTable has access to internal operations
77 * ************************************************************** */
79 class SymbolTable : private hashTable<SymbolName, unsigned int>
85 // intern creates symbol if necessary
86 const Symbol intern(const char *name, unsigned int createId = false) ;
88 ostream &print(ostream &) const ;
90 unsigned int IdsAssigned() {
94 unsigned int wildCardId() { return f_wildCardId; };
95 unsigned int unlimitedWildCardId() { return f_unlimitedWildCardId; };
98 static unsigned hashsym(const SymbolName &);
100 unsigned int f_wildCardId;
101 unsigned int f_unlimitedWildCardId;
103 unsigned int f_IDsAssigned;
108 /* **************************************************************
110 * ************************************************************** */
116 Symbol(const Symbol &);
119 Symbol operator=(const Symbol &other) ;
121 const char *name() const;
122 unsigned int operator==(const Symbol &) const; /* identity operator */
124 // some methods need to be public
126 ostream &print(ostream &) const ;
129 unsigned int hash() const { return f_name->hash(); }
130 unsigned int id() const { return f_id; }
133 // alternate constructor
134 // only SymbolTable::intern can create these
135 Symbol(const SymbolName *name, unsigned int);
137 friend const Symbol SymbolTable::intern(const char *, unsigned int assignId);
140 const SymbolName *f_name ; /* never delete this */
145 /* **************************************************************
146 * external declarations
147 * ************************************************************** */
149 ostream &operator<<(ostream &, const Symbol&);
150 ostream &operator<<(ostream &, const SymbolTable&);
153 #endif /* _SymTab_h */
154 /* DO NOT ADD ANY LINES AFTER THIS #endif */