xref: /onnv-gate/usr/src/cmd/man/src/util/nsgmls.src/include/Sd.h (revision 0:68f95e015346)
1 // Copyright (c) 1994 James Clark
2 // See the file COPYING for copying permission.
3 #pragma ident	"%Z%%M%	%I%	%E% SMI"
4 
5 #ifndef Sd_INCLUDED
6 #define Sd_INCLUDED 1
7 #ifdef __GNUG__
8 #pragma interface
9 #endif
10 
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"
22 
23 // Information about the SGML declaration that is not syntax specific.
24 
25 #ifdef SP_NAMESPACE
26 namespace SP_NAMESPACE {
27 #endif
28 
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
53     };
54   enum {
55     nBooleanFeature = fKEEPRSRE + 1,
56     fSHORTTAG_FIRST = fSTARTTAGEMPTY,
57     fSHORTTAG_LAST = fATTRIBVALUE
58   };
59   // These must be in the same order as in the SGML declaration.
60   enum NumberFeature {
61     fSIMPLE,
62     fEXPLICIT,
63     fCONCUR,
64     fSUBDOC
65   };
66   enum { nNumberFeature = fSUBDOC + 1 };
67   enum NetEnable {
68     netEnableNo,
69     netEnableImmednet,
70     netEnableAll
71   };
72   enum EntityRef {
73     entityRefAny,
74     entityRefInternal,
75     entityRefNone
76   };
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
164   };
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
183   };
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_[];
268 };
269 
270 inline
link()271 Boolean Sd::link() const
272 {
273   return (numberFeature_[fSIMPLE]
274 	  || booleanFeature_[fIMPLICIT]
275 	  || numberFeature_[fEXPLICIT]);
276 }
277 
278 inline
explicitLink()279 Number Sd::explicitLink() const
280 {
281   return numberFeature_[fEXPLICIT];
282 }
283 
284 inline
implicitLink()285 Boolean Sd::implicitLink() const
286 {
287   return booleanFeature_[fIMPLICIT];
288 }
289 
290 inline
simpleLink()291 Number Sd::simpleLink() const
292 {
293   return numberFeature_[fSIMPLE];
294 }
295 
296 inline
startTagEmpty()297 Boolean Sd::startTagEmpty() const
298 {
299   return booleanFeature_[fSTARTTAGEMPTY];
300 }
301 
302 inline
startTagUnclosed()303 Boolean Sd::startTagUnclosed() const
304 {
305   return booleanFeature_[fSTARTTAGUNCLOSED];
306 }
307 
308 inline
startTagNetEnable()309 Sd::NetEnable Sd::startTagNetEnable() const
310 {
311   return netEnable_;
312 }
313 
314 inline
setStartTagNetEnable(NetEnable e)315 void Sd::setStartTagNetEnable(NetEnable e)
316 {
317   netEnable_ = e;
318 }
319 
320 inline
endTagEmpty()321 Boolean Sd::endTagEmpty() const
322 {
323   return booleanFeature_[fENDTAGEMPTY];
324 }
325 
326 inline
endTagUnclosed()327 Boolean Sd::endTagUnclosed() const
328 {
329   return booleanFeature_[fENDTAGUNCLOSED];
330 }
331 
332 inline
attributeDefault()333 Boolean Sd::attributeDefault() const
334 {
335   return booleanFeature_[fATTRIBDEFAULT];
336 }
337 
338 inline
attributeValueNotLiteral()339 Boolean Sd::attributeValueNotLiteral() const
340 {
341   return booleanFeature_[fATTRIBVALUE];
342 }
343 
344 inline
attributeOmitName()345 Boolean Sd::attributeOmitName() const
346 {
347   return booleanFeature_[fATTRIBOMITNAME];
348 }
349 
350 inline
emptyElementNormal()351 Boolean Sd::emptyElementNormal() const
352 {
353   return booleanFeature_[fEMPTYNRM];
354 }
355 
356 inline
implydefAttlist()357 Boolean Sd::implydefAttlist() const
358 {
359   return booleanFeature_[fIMPLYDEFATTLIST];
360 }
361 
362 inline
implydefDoctype()363 Boolean Sd::implydefDoctype() const
364 {
365   return booleanFeature_[fIMPLYDEFDOCTYPE];
366 }
367 
368 inline
implydefElement()369 Boolean Sd::implydefElement() const
370 {
371   return booleanFeature_[fIMPLYDEFELEMENT];
372 }
373 
374 inline
implydefEntity()375 Boolean Sd::implydefEntity() const
376 {
377   return booleanFeature_[fIMPLYDEFENTITY];
378 }
379 
380 inline
implydefNotation()381 Boolean Sd::implydefNotation() const
382 {
383   return booleanFeature_[fIMPLYDEFNOTATION];
384 }
385 
386 inline
concur()387 Number Sd::concur() const
388 {
389   return numberFeature_[fCONCUR];
390 }
391 
392 inline
subdoc()393 Number Sd::subdoc() const
394 {
395   return numberFeature_[fSUBDOC];
396 }
397 
398 
399 inline
omittag()400 Boolean Sd::omittag() const
401 {
402   return booleanFeature_[fOMITTAG];
403 }
404 
405 inline
rank()406 Boolean Sd::rank() const
407 {
408   return booleanFeature_[fRANK];
409 }
410 
411 inline
datatag()412 Boolean Sd::datatag() const
413 {
414   return booleanFeature_[fDATATAG];
415 }
416 
417 inline
formal()418 Boolean Sd::formal() const
419 {
420   return booleanFeature_[fFORMAL];
421 }
422 
423 inline
keeprsre()424 Boolean Sd::keeprsre() const
425 {
426   return booleanFeature_[fKEEPRSRE];
427 }
428 
429 inline
internalCharset()430 const CharsetInfo &Sd::internalCharset() const
431 {
432   return internalCharsetPtr_ ? *internalCharsetPtr_ : docCharset_;
433 }
434 
435 inline
execToInternal(char c)436 Char Sd::execToInternal(char c) const
437 {
438   return internalCharset().execToDesc(c);
439 }
440 
441 inline
execToInternal(const char * s)442 StringC Sd::execToInternal(const char *s) const
443 {
444   return internalCharset().execToDesc(s);
445 }
446 
447 inline
reservedName(int i)448 StringC Sd::reservedName(int i) const
449 {
450   return execToInternal(reservedName_[i]);
451 }
452 
453 inline
internalCharsetIsDocCharset()454 Boolean Sd::internalCharsetIsDocCharset() const
455 {
456   return internalCharsetIsDocCharset_;
457 }
458 
459 inline
docCharset()460 const CharsetInfo &Sd::docCharset() const
461 {
462   return docCharset_;
463 }
464 
465 inline
digitWeight(Char c)466 int Sd::digitWeight(Char c) const
467 {
468   return internalCharset().digitWeight(c);
469 }
470 
471 inline
hexDigitWeight(Char c)472 int Sd::hexDigitWeight(Char c) const
473 {
474   return internalCharset().hexDigitWeight(c);
475 }
476 
477 inline
capacity(int i)478 Number Sd::capacity(int i) const
479 {
480   return capacity_[i];
481 }
482 
483 inline
setCapacity(int i,Number n)484 void Sd::setCapacity(int i, Number n)
485 {
486   capacity_[i] = n;
487 }
488 
489 inline
capacityName(int i)490 StringC Sd::capacityName(int i) const
491 {
492   return execToInternal(capacityName_[i]);
493 }
494 
495 inline
scopeInstance()496 Boolean Sd::scopeInstance() const
497 {
498   return scopeInstance_;
499 }
500 
501 inline
setScopeInstance()502 void Sd::setScopeInstance()
503 {
504   scopeInstance_ = 1;
505 }
506 
507 inline
setDocCharsetDecl(CharsetDecl & decl)508 void Sd::setDocCharsetDecl(CharsetDecl &decl)
509 {
510   decl.swap(docCharsetDecl_);
511 }
512 
513 inline
docCharsetDecl()514 const CharsetDecl &Sd::docCharsetDecl() const
515 {
516   return docCharsetDecl_;
517 }
518 
519 inline
setBooleanFeature(BooleanFeature i,Boolean b)520 void Sd::setBooleanFeature(BooleanFeature i, Boolean b)
521 {
522   booleanFeature_[i] = b;
523 }
524 
525 inline
setNumberFeature(NumberFeature i,Number n)526 void Sd::setNumberFeature(NumberFeature i, Number n)
527 {
528   numberFeature_[i] = n;
529 }
530 
531 inline
www()532 Boolean Sd::www() const
533 {
534   return www_;
535 }
536 
537 inline
setWww(Boolean b)538 void Sd::setWww(Boolean b)
539 {
540   www_ = b;
541 }
542 
543 inline
entityRef()544 Sd::EntityRef Sd::entityRef() const
545 {
546   return entityRef_;
547 }
548 
549 inline
setEntityRef(EntityRef r)550 void Sd::setEntityRef(EntityRef r)
551 {
552   entityRef_ = r;
553 }
554 
555 inline
typeValid()556 Boolean Sd::typeValid() const
557 {
558   return typeValid_;
559 }
560 
561 inline
setTypeValid(Boolean b)562 void Sd::setTypeValid(Boolean b)
563 {
564   typeValid_ = b;
565 }
566 
567 inline
integrallyStored()568 Boolean Sd::integrallyStored() const
569 {
570   return integrallyStored_;
571 }
572 
573 inline
setIntegrallyStored(Boolean b)574 void Sd::setIntegrallyStored(Boolean b)
575 {
576   integrallyStored_ = b;
577 }
578 
579 #ifdef SP_NAMESPACE
580 }
581 #endif
582 
583 #endif /* Sd_INCLUDED */
584