Disable all code related to libXp
[oweals/cde.git] / cde / programs / dtinfo / DtMmdb / StyleSheet / SymTab.h
1 /*
2  * CDE - Common Desktop Environment
3  *
4  * Copyright (c) 1993-2012, The Open Group. All rights reserved.
5  *
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)
10  * any later version.
11  *
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
16  * details.
17  *
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
22  */
23 /* $XConsortium: SymTab.h /main/5 1996/08/21 15:50:57 drk $ */
24 #ifndef _SymTab_h
25 #define _SymTab_h
26
27 #ifndef CDE_NEXT
28
29
30 #else
31 #include "dti_cc/CC_String.h"
32 #include "dti_cc/cc_hdict.h"
33 //#include "StyleSheet/cde_next.h"
34 #include <iostream>
35 using namespace std;
36 #endif
37
38 #include "Types.h"
39
40 /* **************************************************************
41  Creating a Symbol Table Class
42  
43  Symbol Table has one user function, intern, which returns a
44  reference to a Symbol  
45
46
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
49  SymbolTable
50
51  * ************************************************************** */
52
53
54 // forward declarations 
55 class Symbol;
56
57 /* -------- class SymbolName -------- */
58 // derived from CC_String to give a version of  ==
59
60 // should be privately inherited with a few promotions
61
62 class SymbolName : public CC_String
63 {
64 public:
65   SymbolName(const char *);
66   unsigned int operator==(const SymbolName &);
67   ostream &print(ostream &) const ;
68 };
69
70
71
72
73
74 /* **************************************************************
75  SymbolTable derives privately from RWTPtrHashSet so only the
76  SymbolTable has access to internal operations
77  * ************************************************************** */
78
79 class SymbolTable : private hashTable<SymbolName, unsigned int>
80 {
81 public:
82   SymbolTable();
83   ~SymbolTable();
84
85   // intern creates symbol if necessary
86   const Symbol intern(const char *name, unsigned int createId = false) ;
87
88   ostream &print(ostream &) const ;
89
90   unsigned int IdsAssigned() { 
91     return f_IDsAssigned;
92   };
93
94   unsigned int wildCardId() { return f_wildCardId; };
95   unsigned int unlimitedWildCardId() { return f_unlimitedWildCardId; };
96
97 private:
98   static unsigned hashsym(const SymbolName &);
99
100   unsigned int f_wildCardId;
101   unsigned int f_unlimitedWildCardId;
102
103   unsigned int f_IDsAssigned;
104
105 };
106
107
108 /* **************************************************************
109  * class Symbol
110  * ************************************************************** */
111
112 class Symbol  
113 {
114 public:
115   // constructor 
116   Symbol(const Symbol &);
117
118   // assignment 
119   Symbol operator=(const Symbol &other) ;
120
121   const char *name() const;
122   unsigned int operator==(const Symbol &) const; /* identity operator */
123
124   // some methods need to be public
125
126   ostream &print(ostream &) const ;
127
128   // for path table 
129   unsigned int hash() const     { return f_name->hash(); }
130   unsigned int id() const       { return f_id; }
131
132 protected:
133   // alternate constructor 
134   // only SymbolTable::intern can create these 
135   Symbol(const SymbolName *name, unsigned int);
136
137 friend const Symbol SymbolTable::intern(const char *, unsigned int assignId);
138
139 private:  
140   const SymbolName    *f_name ; /* never delete this */
141   unsigned int        f_id;
142 };
143
144
145 /* **************************************************************
146  * external declarations
147  * ************************************************************** */
148
149 ostream &operator<<(ostream &, const Symbol&);
150 ostream &operator<<(ostream &, const SymbolTable&);
151
152
153 #endif /* _SymTab_h */
154 /* DO NOT ADD ANY LINES AFTER THIS #endif */