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"
39 /* **************************************************************
40 Creating a Symbol Table Class
42 Symbol Table has one user function, intern, which returns a
46 A Symbol can be compared to other symbols using the == operator.
47 Symbols will only be == if they are the same symbol in the same
50 * ************************************************************** */
53 // forward declarations
56 /* -------- class SymbolName -------- */
57 // derived from CC_String to give a version of ==
59 // should be privately inherited with a few promotions
61 class SymbolName : public CC_String
64 SymbolName(const char *);
65 unsigned int operator==(const SymbolName &);
66 ostream &print(ostream &) const ;
73 /* **************************************************************
74 SymbolTable derives privately from RWTPtrHashSet so only the
75 SymbolTable has access to internal operations
76 * ************************************************************** */
78 class SymbolTable : private hashTable<SymbolName, unsigned int>
84 // intern creates symbol if necessary
85 const Symbol intern(const char *name, unsigned int createId = false) ;
87 ostream &print(ostream &) const ;
89 unsigned int IdsAssigned() {
93 unsigned int wildCardId() { return f_wildCardId; };
94 unsigned int unlimitedWildCardId() { return f_unlimitedWildCardId; };
97 static unsigned hashsym(const SymbolName &);
99 unsigned int f_wildCardId;
100 unsigned int f_unlimitedWildCardId;
102 unsigned int f_IDsAssigned;
107 /* **************************************************************
109 * ************************************************************** */
115 Symbol(const Symbol &);
118 Symbol operator=(const Symbol &other) ;
120 const char *name() const;
121 unsigned int operator==(const Symbol &) const; /* identity operator */
123 // some methods need to be public
125 ostream &print(ostream &) const ;
128 unsigned int hash() const { return f_name->hash(); }
129 unsigned int id() const { return f_id; }
132 // alternate constructor
133 // only SymbolTable::intern can create these
134 Symbol(const SymbolName *name, unsigned int);
136 friend const Symbol SymbolTable::intern(const char *, unsigned int assignId);
139 const SymbolName *f_name ; /* never delete this */
144 /* **************************************************************
145 * external declarations
146 * ************************************************************** */
148 ostream &operator<<(ostream &, const Symbol&);
149 ostream &operator<<(ostream &, const SymbolTable&);
152 #endif /* _SymTab_h */
153 /* DO NOT ADD ANY LINES AFTER THIS #endif */