nsgml: Resolve symbol collision when building with SunStudio 12.1
[oweals/cde.git] / cde / programs / nsgmls / Sd.C
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 libraries 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: Sd.C /main/1 1996/07/29 17:03:39 cde-hp $ */
24 // Copyright (c) 1994 James Clark
25 // See the file COPYING for copying permission.
26
27 #ifdef __GNUG__
28 #pragma implementation
29 #endif
30 #include "splib.h"
31 #include "Sd.h"
32 #include "macros.h"
33
34 #ifdef SP_NAMESPACE
35 namespace SP_NAMESPACE {
36 #endif
37
38 Sd::Sd()
39 : scopeInstance_(0)
40 {
41   int i;
42   for (i = 0; i < nBooleanFeature; i++)
43     booleanFeature_[i] = 0;
44   for (i = 0; i < nNumberFeature; i++)
45     numberFeature_[i] = 0;
46   for (i = 0; i < nCapacity; i++)
47     capacity_[i] = 35000;
48 }
49
50 void Sd::setDocCharsetDesc(const UnivCharsetDesc &desc)
51 {
52   docCharset_.set(desc);
53 }
54
55 const char *const Sd::reservedName_[] = {
56   "APPINFO",
57   "BASESET",
58   "CAPACITY",
59   "CHARSET",
60   "CONCUR",
61   "CONTROLS",
62   "DATATAG",
63   "DELIM",
64   "DESCSET",
65   "DOCUMENT",
66   "ENTITY",
67   "EXPLICIT",
68   "FEATURES",
69   "FORMAL",
70   "FUNCHAR",
71   "FUNCTION",
72   "GENERAL",
73   "IMPLICIT",
74   "INSTANCE",
75   "LCNMCHAR",
76   "LCNMSTRT",
77   "LINK",
78   "MINIMIZE",
79   "MSICHAR",
80   "MSOCHAR",
81   "MSSCHAR",
82   "NAMECASE",
83   "NAMES",
84   "NAMING",
85   "NO",
86   "NONE",
87   "OMITTAG",
88   "OTHER",
89   "PUBLIC",
90   "QUANTITY",
91   "RANK",
92   "RE",
93   "RS",
94   "SCOPE",
95   "SEPCHAR",
96   "SGML",
97   "SGMLREF",
98   "SHORTREF",
99   "SHORTTAG",
100   "SHUNCHAR",
101   "SIMPLE",
102   "SPACE",
103   "SUBDOC",
104   "SWITCHES",
105   "SYNTAX",
106   "UCNMCHAR",
107   "UCNMSTRT",
108   "UNUSED",
109   "YES"
110 };
111
112 const char *const Sd::capacityName_[] = {
113   "TOTALCAP",
114   "ENTCAP",
115   "ENTCHCAP",
116   "ELEMCAP",
117   "GRPCAP",
118   "EXGRPCAP",
119   "EXNMCAP",
120   "ATTCAP",
121   "ATTCHCAP",
122   "AVGRPCAP",
123   "NOTCAP",
124   "NOTCHCAP",
125   "IDCAP",
126   "IDREFCAP",
127   "MAPCAP",
128   "LKSETCAP",
129   "LKNMCAP"
130 };
131
132
133 const char *const Sd::quantityName_[] = {
134   "ATTCNT",
135   "ATTSPLEN",
136   "BSEQLEN",
137   "DTAGLEN",
138   "DTEMPLEN",
139   "ENTLVL",
140   "GRPCNT",
141   "GRPGTCNT",
142   "GRPLVL",
143   "LITLEN",
144   "NAMELEN",
145   "NORMSEP",
146   "PILEN",
147   "TAGLEN",
148   "TAGLVL"
149 };
150
151 const char *const Sd::generalDelimiterName_[] = {
152   "AND",
153   "COM",
154   "CRO",
155   "DSC",
156   "DSO",
157   "DTGC",
158   "DTGO",
159   "ERO",
160   "ETAGO",
161   "GRPC",
162   "GRPO",
163   "LIT",
164   "LITA",
165   "MDC",
166   "MDO",
167   "MINUS",
168   "MSC",
169   "NET",
170   "OPT",
171   "OR",
172   "PERO",
173   "PIC",
174   "PIO",
175   "PLUS",
176   "REFC",
177   "REP",
178   "RNI",
179   "SEQ",
180   "STAGO",
181   "TAGC",
182   "VI"
183 };
184
185 Boolean Sd::lookupQuantityName(const StringC &name, Syntax::Quantity &quantity)
186      const
187 {
188   for (size_t i = 0; i < SIZEOF(quantityName_); i++)
189     if (execToDoc(quantityName_[i]) == name) {
190       quantity = Syntax::Quantity(i);
191       return 1;
192     }
193   return 0;
194 }
195
196 Boolean Sd::lookupCapacityName(const StringC &name, Sd::Capacity &capacity)
197      const
198 {
199   for (size_t i = 0; i < SIZEOF(capacityName_); i++)
200     if (execToDoc(capacityName_[i]) == name) {
201       capacity = Sd::Capacity(i);
202       return 1;
203     }
204   return 0;
205 }
206
207 Boolean Sd::lookupGeneralDelimiterName(const StringC &name,
208                                        Syntax::DelimGeneral &delimGeneral)
209      const
210 {
211   for (size_t i = 0; i < SIZEOF(generalDelimiterName_); i++)
212     if (execToDoc(generalDelimiterName_[i]) == name) {
213       delimGeneral = Syntax::DelimGeneral(i);
214       return 1;
215     }
216   return 0;
217 }
218
219 StringC Sd::quantityName(Syntax::Quantity q) const
220 {
221   return execToDoc(quantityName_[q]);
222 }
223
224 StringC Sd::generalDelimiterName(Syntax::DelimGeneral d) const
225 {
226   return execToDoc(generalDelimiterName_[d]);
227 }
228
229 UnivChar Sd::nameToUniv(const StringC &name)
230 {
231   const int *p = namedCharTable_.lookup(name);
232   int n;
233   if (p)
234     n = *p;
235   else {
236     n = int(namedCharTable_.count());
237     namedCharTable_.insert(name, n);
238   }
239   return n + 0x60000000;        // 10646 private use group
240 }
241
242 #ifdef SP_NAMESPACE
243 }
244 #endif