3065 some functions in the tcp module can be static
[unleashed.git] / usr / src / cmd / man / src / util / nsgmls.src / include / Sd.h
blob6d1e254dccad4238e431df28c2f4aae1484e7d14
1 // Copyright (c) 1994 James Clark
2 // See the file COPYING for copying permission.
3 #pragma ident "%Z%%M% %I% %E% SMI"
5 #ifndef Sd_INCLUDED
6 #define Sd_INCLUDED 1
7 #ifdef __GNUG__
8 #pragma interface
9 #endif
11 #include "types.h"
12 #include "Boolean.h"
13 #include "Resource.h"
14 #include "CharsetInfo.h"
15 #include "ExternalId.h"
16 #include "ISet.h"
17 #include "Syntax.h"
18 #include "CharsetDecl.h"
19 #include "HashTable.h"
20 #include "EntityManager.h"
21 #include "Ptr.h"
23 // Information about the SGML declaration that is not syntax specific.
25 #ifdef SP_NAMESPACE
26 namespace SP_NAMESPACE {
27 #endif
29 class SP_API Sd : public Resource {
30 public:
31 // These must be in the same order as in the SGML declaration.
32 enum BooleanFeature {
33 fDATATAG,
34 fOMITTAG,
35 fRANK,
36 fSTARTTAGEMPTY,
37 fSTARTTAGUNCLOSED,
38 fENDTAGEMPTY,
39 fENDTAGUNCLOSED,
40 fATTRIBDEFAULT,
41 fATTRIBOMITNAME,
42 fATTRIBVALUE,
43 fEMPTYNRM,
44 fIMPLYDEFATTLIST,
45 fIMPLYDEFDOCTYPE,
46 fIMPLYDEFELEMENT,
47 fIMPLYDEFENTITY,
48 fIMPLYDEFNOTATION,
49 fIMPLICIT,
50 fFORMAL,
51 fURN,
52 fKEEPRSRE
54 enum {
55 nBooleanFeature = fKEEPRSRE + 1,
56 fSHORTTAG_FIRST = fSTARTTAGEMPTY,
57 fSHORTTAG_LAST = fATTRIBVALUE
59 // These must be in the same order as in the SGML declaration.
60 enum NumberFeature {
61 fSIMPLE,
62 fEXPLICIT,
63 fCONCUR,
64 fSUBDOC
66 enum { nNumberFeature = fSUBDOC + 1 };
67 enum NetEnable {
68 netEnableNo,
69 netEnableImmednet,
70 netEnableAll
72 enum EntityRef {
73 entityRefAny,
74 entityRefInternal,
75 entityRefNone
77 // These are names used in the SGML declaration.
78 enum ReservedName {
79 rALL,
80 rANY,
81 rAPPINFO,
82 rATTLIST,
83 rATTRIB,
84 rBASESET,
85 rCAPACITY,
86 rCHARSET,
87 rCONCUR,
88 rCONTROLS,
89 rDATATAG,
90 rDEFAULT,
91 rDELIM,
92 rDESCSET,
93 rDOCTYPE,
94 rDOCUMENT,
95 rELEMENT,
96 rEMPTY,
97 rEMPTYNRM,
98 rENDTAG,
99 rENTITIES,
100 rENTITY,
101 rEXPLICIT,
102 rFEATURES,
103 rFORMAL,
104 rFUNCHAR,
105 rFUNCTION,
106 rGENERAL,
107 rIMMEDNET,
108 rIMPLICIT,
109 rIMPLYDEF,
110 rINSTANCE,
111 rINTEGRAL,
112 rINTERNAL,
113 rKEEPRSRE,
114 rLCNMCHAR,
115 rLCNMSTRT,
116 rLINK,
117 rMINIMIZE,
118 rMSICHAR,
119 rMSOCHAR,
120 rMSSCHAR,
121 rNAMECASE,
122 rNAMECHAR,
123 rNAMES,
124 rNAMESTRT,
125 rNAMING,
126 rNETENABL,
127 rNO,
128 rNOASSERT,
129 rNONE,
130 rNOTATION,
131 rOMITNAME,
132 rOMITTAG,
133 rOTHER,
134 rPUBLIC,
135 rQUANTITY,
136 rRANK,
137 rRE,
138 rREF,
139 rRS,
140 rSCOPE,
141 rSEEALSO,
142 rSEPCHAR,
143 rSGML,
144 rSGMLREF,
145 rSHORTREF,
146 rSHORTTAG,
147 rSHUNCHAR,
148 rSIMPLE,
149 rSPACE,
150 rSTARTTAG,
151 rSUBDOC,
152 rSWITCHES,
153 rSYNTAX,
154 rSYSTEM,
155 rTYPE,
156 rUCNMCHAR,
157 rUCNMSTRT,
158 rUNCLOSED,
159 rUNUSED,
160 rURN,
161 rVALIDITY,
162 rVALUE,
163 rYES
165 enum Capacity {
166 TOTALCAP,
167 ENTCAP,
168 ENTCHCAP,
169 ELEMCAP,
170 GRPCAP,
171 EXGRPCAP,
172 EXNMCAP,
173 ATTCAP,
174 ATTCHCAP,
175 AVGRPCAP,
176 NOTCAP,
177 NOTCHCAP,
178 IDCAP,
179 IDREFCAP,
180 MAPCAP,
181 LKSETCAP,
182 LKNMCAP
184 enum { nCapacity = LKNMCAP + 1 };
185 Sd(const Ptr<EntityManager> &);
186 void setDocCharsetDesc(const UnivCharsetDesc &);
187 Boolean matchesReservedName(const StringC &, ReservedName) const;
188 int digitWeight(Char) const;
189 int hexDigitWeight(Char) const;
190 Boolean link() const;
191 Number simpleLink() const;
192 Boolean implicitLink() const;
193 Number explicitLink() const;
194 Boolean startTagEmpty() const;
195 Boolean startTagUnclosed() const;
196 NetEnable startTagNetEnable() const;
197 void setStartTagNetEnable(NetEnable);
198 Boolean endTagEmpty() const;
199 Boolean endTagUnclosed() const;
200 Boolean attributeDefault() const;
201 Boolean attributeValueNotLiteral() const;
202 Boolean attributeOmitName() const;
203 Boolean emptyElementNormal() const;
204 Boolean implydefAttlist() const;
205 Boolean implydefDoctype() const;
206 Boolean implydefElement() const;
207 Boolean implydefEntity() const;
208 Boolean implydefNotation() const;
209 Number concur() const;
210 Boolean omittag() const;
211 Boolean rank() const;
212 Boolean datatag() const;
213 Boolean formal() const;
214 Boolean keeprsre() const;
215 Number subdoc() const;
216 StringC reservedName(int) const;
217 Boolean lookupQuantityName(const StringC &, Syntax::Quantity &) const;
218 Boolean lookupGeneralDelimiterName(const StringC &, Syntax::DelimGeneral &)
219 const;
220 Boolean lookupCapacityName(const StringC &, Sd::Capacity &) const;
221 StringC quantityName(Syntax::Quantity) const;
222 Boolean internalCharsetIsDocCharset() const;
223 const CharsetInfo &internalCharset() const;
224 const CharsetInfo &docCharset() const;
225 Char execToInternal(char) const;
226 StringC execToInternal(const char *) const;
227 Number capacity(int) const;
228 void setCapacity(int, Number);
229 StringC capacityName(int) const;
230 Boolean scopeInstance() const;
231 void setScopeInstance();
232 void setDocCharsetDecl(CharsetDecl &);
233 const CharsetDecl &docCharsetDecl() const;
234 void setBooleanFeature(BooleanFeature, Boolean);
235 void setShorttag(Boolean);
236 void setNumberFeature(NumberFeature, Number);
237 StringC generalDelimiterName(Syntax::DelimGeneral) const;
238 UnivChar nameToUniv(const StringC &);
239 Boolean www() const;
240 void setWww(Boolean);
241 EntityRef entityRef() const;
242 void setEntityRef(EntityRef);
243 Boolean typeValid() const;
244 void setTypeValid(Boolean);
245 Boolean integrallyStored() const;
246 void setIntegrallyStored(Boolean);
247 private:
248 PackedBoolean booleanFeature_[nBooleanFeature];
249 Number numberFeature_[nNumberFeature];
250 Number capacity_[nCapacity];
251 PackedBoolean internalCharsetIsDocCharset_;
252 // if null, use docCharset_
253 const CharsetInfo *internalCharsetPtr_;
254 CharsetInfo docCharset_;
255 CharsetDecl docCharsetDecl_;
256 Boolean scopeInstance_;
257 Boolean www_;
258 NetEnable netEnable_;
259 EntityRef entityRef_;
260 Boolean typeValid_;
261 Boolean integrallyStored_;
262 HashTable<StringC,int> namedCharTable_;
263 Ptr<EntityManager> entityManager_;
264 static const char *const reservedName_[];
265 static const char *const generalDelimiterName_[];
266 static const char *const capacityName_[];
267 static const char *const quantityName_[];
270 inline
271 Boolean Sd::link() const
273 return (numberFeature_[fSIMPLE]
274 || booleanFeature_[fIMPLICIT]
275 || numberFeature_[fEXPLICIT]);
278 inline
279 Number Sd::explicitLink() const
281 return numberFeature_[fEXPLICIT];
284 inline
285 Boolean Sd::implicitLink() const
287 return booleanFeature_[fIMPLICIT];
290 inline
291 Number Sd::simpleLink() const
293 return numberFeature_[fSIMPLE];
296 inline
297 Boolean Sd::startTagEmpty() const
299 return booleanFeature_[fSTARTTAGEMPTY];
302 inline
303 Boolean Sd::startTagUnclosed() const
305 return booleanFeature_[fSTARTTAGUNCLOSED];
308 inline
309 Sd::NetEnable Sd::startTagNetEnable() const
311 return netEnable_;
314 inline
315 void Sd::setStartTagNetEnable(NetEnable e)
317 netEnable_ = e;
320 inline
321 Boolean Sd::endTagEmpty() const
323 return booleanFeature_[fENDTAGEMPTY];
326 inline
327 Boolean Sd::endTagUnclosed() const
329 return booleanFeature_[fENDTAGUNCLOSED];
332 inline
333 Boolean Sd::attributeDefault() const
335 return booleanFeature_[fATTRIBDEFAULT];
338 inline
339 Boolean Sd::attributeValueNotLiteral() const
341 return booleanFeature_[fATTRIBVALUE];
344 inline
345 Boolean Sd::attributeOmitName() const
347 return booleanFeature_[fATTRIBOMITNAME];
350 inline
351 Boolean Sd::emptyElementNormal() const
353 return booleanFeature_[fEMPTYNRM];
356 inline
357 Boolean Sd::implydefAttlist() const
359 return booleanFeature_[fIMPLYDEFATTLIST];
362 inline
363 Boolean Sd::implydefDoctype() const
365 return booleanFeature_[fIMPLYDEFDOCTYPE];
368 inline
369 Boolean Sd::implydefElement() const
371 return booleanFeature_[fIMPLYDEFELEMENT];
374 inline
375 Boolean Sd::implydefEntity() const
377 return booleanFeature_[fIMPLYDEFENTITY];
380 inline
381 Boolean Sd::implydefNotation() const
383 return booleanFeature_[fIMPLYDEFNOTATION];
386 inline
387 Number Sd::concur() const
389 return numberFeature_[fCONCUR];
392 inline
393 Number Sd::subdoc() const
395 return numberFeature_[fSUBDOC];
399 inline
400 Boolean Sd::omittag() const
402 return booleanFeature_[fOMITTAG];
405 inline
406 Boolean Sd::rank() const
408 return booleanFeature_[fRANK];
411 inline
412 Boolean Sd::datatag() const
414 return booleanFeature_[fDATATAG];
417 inline
418 Boolean Sd::formal() const
420 return booleanFeature_[fFORMAL];
423 inline
424 Boolean Sd::keeprsre() const
426 return booleanFeature_[fKEEPRSRE];
429 inline
430 const CharsetInfo &Sd::internalCharset() const
432 return internalCharsetPtr_ ? *internalCharsetPtr_ : docCharset_;
435 inline
436 Char Sd::execToInternal(char c) const
438 return internalCharset().execToDesc(c);
441 inline
442 StringC Sd::execToInternal(const char *s) const
444 return internalCharset().execToDesc(s);
447 inline
448 StringC Sd::reservedName(int i) const
450 return execToInternal(reservedName_[i]);
453 inline
454 Boolean Sd::internalCharsetIsDocCharset() const
456 return internalCharsetIsDocCharset_;
459 inline
460 const CharsetInfo &Sd::docCharset() const
462 return docCharset_;
465 inline
466 int Sd::digitWeight(Char c) const
468 return internalCharset().digitWeight(c);
471 inline
472 int Sd::hexDigitWeight(Char c) const
474 return internalCharset().hexDigitWeight(c);
477 inline
478 Number Sd::capacity(int i) const
480 return capacity_[i];
483 inline
484 void Sd::setCapacity(int i, Number n)
486 capacity_[i] = n;
489 inline
490 StringC Sd::capacityName(int i) const
492 return execToInternal(capacityName_[i]);
495 inline
496 Boolean Sd::scopeInstance() const
498 return scopeInstance_;
501 inline
502 void Sd::setScopeInstance()
504 scopeInstance_ = 1;
507 inline
508 void Sd::setDocCharsetDecl(CharsetDecl &decl)
510 decl.swap(docCharsetDecl_);
513 inline
514 const CharsetDecl &Sd::docCharsetDecl() const
516 return docCharsetDecl_;
519 inline
520 void Sd::setBooleanFeature(BooleanFeature i, Boolean b)
522 booleanFeature_[i] = b;
525 inline
526 void Sd::setNumberFeature(NumberFeature i, Number n)
528 numberFeature_[i] = n;
531 inline
532 Boolean Sd::www() const
534 return www_;
537 inline
538 void Sd::setWww(Boolean b)
540 www_ = b;
543 inline
544 Sd::EntityRef Sd::entityRef() const
546 return entityRef_;
549 inline
550 void Sd::setEntityRef(EntityRef r)
552 entityRef_ = r;
555 inline
556 Boolean Sd::typeValid() const
558 return typeValid_;
561 inline
562 void Sd::setTypeValid(Boolean b)
564 typeValid_ = b;
567 inline
568 Boolean Sd::integrallyStored() const
570 return integrallyStored_;
573 inline
574 void Sd::setIntegrallyStored(Boolean b)
576 integrallyStored_ = b;
579 #ifdef SP_NAMESPACE
581 #endif
583 #endif /* Sd_INCLUDED */