1 // Copyright (c) 1994 James Clark
2 // See the file COPYING for copying permission.
3 #pragma ident "%Z%%M% %I% %E% SMI"
14 #include "CharsetInfo.h"
15 #include "ExternalId.h"
18 #include "CharsetDecl.h"
19 #include "HashTable.h"
20 #include "EntityManager.h"
23 // Information about the SGML declaration that is not syntax specific.
26 namespace SP_NAMESPACE
{
29 class SP_API Sd
: public Resource
{
31 // These must be in the same order as in the SGML declaration.
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.
66 enum { nNumberFeature
= fSUBDOC
+ 1 };
77 // These are names used in the SGML declaration.
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
&)
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
&);
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
);
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_
;
258 NetEnable netEnable_
;
259 EntityRef entityRef_
;
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_
[];
271 Boolean
Sd::link() const
273 return (numberFeature_
[fSIMPLE
]
274 || booleanFeature_
[fIMPLICIT
]
275 || numberFeature_
[fEXPLICIT
]);
279 Number
Sd::explicitLink() const
281 return numberFeature_
[fEXPLICIT
];
285 Boolean
Sd::implicitLink() const
287 return booleanFeature_
[fIMPLICIT
];
291 Number
Sd::simpleLink() const
293 return numberFeature_
[fSIMPLE
];
297 Boolean
Sd::startTagEmpty() const
299 return booleanFeature_
[fSTARTTAGEMPTY
];
303 Boolean
Sd::startTagUnclosed() const
305 return booleanFeature_
[fSTARTTAGUNCLOSED
];
309 Sd::NetEnable
Sd::startTagNetEnable() const
315 void Sd::setStartTagNetEnable(NetEnable e
)
321 Boolean
Sd::endTagEmpty() const
323 return booleanFeature_
[fENDTAGEMPTY
];
327 Boolean
Sd::endTagUnclosed() const
329 return booleanFeature_
[fENDTAGUNCLOSED
];
333 Boolean
Sd::attributeDefault() const
335 return booleanFeature_
[fATTRIBDEFAULT
];
339 Boolean
Sd::attributeValueNotLiteral() const
341 return booleanFeature_
[fATTRIBVALUE
];
345 Boolean
Sd::attributeOmitName() const
347 return booleanFeature_
[fATTRIBOMITNAME
];
351 Boolean
Sd::emptyElementNormal() const
353 return booleanFeature_
[fEMPTYNRM
];
357 Boolean
Sd::implydefAttlist() const
359 return booleanFeature_
[fIMPLYDEFATTLIST
];
363 Boolean
Sd::implydefDoctype() const
365 return booleanFeature_
[fIMPLYDEFDOCTYPE
];
369 Boolean
Sd::implydefElement() const
371 return booleanFeature_
[fIMPLYDEFELEMENT
];
375 Boolean
Sd::implydefEntity() const
377 return booleanFeature_
[fIMPLYDEFENTITY
];
381 Boolean
Sd::implydefNotation() const
383 return booleanFeature_
[fIMPLYDEFNOTATION
];
387 Number
Sd::concur() const
389 return numberFeature_
[fCONCUR
];
393 Number
Sd::subdoc() const
395 return numberFeature_
[fSUBDOC
];
400 Boolean
Sd::omittag() const
402 return booleanFeature_
[fOMITTAG
];
406 Boolean
Sd::rank() const
408 return booleanFeature_
[fRANK
];
412 Boolean
Sd::datatag() const
414 return booleanFeature_
[fDATATAG
];
418 Boolean
Sd::formal() const
420 return booleanFeature_
[fFORMAL
];
424 Boolean
Sd::keeprsre() const
426 return booleanFeature_
[fKEEPRSRE
];
430 const CharsetInfo
&Sd::internalCharset() const
432 return internalCharsetPtr_
? *internalCharsetPtr_
: docCharset_
;
436 Char
Sd::execToInternal(char c
) const
438 return internalCharset().execToDesc(c
);
442 StringC
Sd::execToInternal(const char *s
) const
444 return internalCharset().execToDesc(s
);
448 StringC
Sd::reservedName(int i
) const
450 return execToInternal(reservedName_
[i
]);
454 Boolean
Sd::internalCharsetIsDocCharset() const
456 return internalCharsetIsDocCharset_
;
460 const CharsetInfo
&Sd::docCharset() const
466 int Sd::digitWeight(Char c
) const
468 return internalCharset().digitWeight(c
);
472 int Sd::hexDigitWeight(Char c
) const
474 return internalCharset().hexDigitWeight(c
);
478 Number
Sd::capacity(int i
) const
484 void Sd::setCapacity(int i
, Number n
)
490 StringC
Sd::capacityName(int i
) const
492 return execToInternal(capacityName_
[i
]);
496 Boolean
Sd::scopeInstance() const
498 return scopeInstance_
;
502 void Sd::setScopeInstance()
508 void Sd::setDocCharsetDecl(CharsetDecl
&decl
)
510 decl
.swap(docCharsetDecl_
);
514 const CharsetDecl
&Sd::docCharsetDecl() const
516 return docCharsetDecl_
;
520 void Sd::setBooleanFeature(BooleanFeature i
, Boolean b
)
522 booleanFeature_
[i
] = b
;
526 void Sd::setNumberFeature(NumberFeature i
, Number n
)
528 numberFeature_
[i
] = n
;
532 Boolean
Sd::www() const
538 void Sd::setWww(Boolean b
)
544 Sd::EntityRef
Sd::entityRef() const
550 void Sd::setEntityRef(EntityRef r
)
556 Boolean
Sd::typeValid() const
562 void Sd::setTypeValid(Boolean b
)
568 Boolean
Sd::integrallyStored() const
570 return integrallyStored_
;
574 void Sd::setIntegrallyStored(Boolean b
)
576 integrallyStored_
= b
;
583 #endif /* Sd_INCLUDED */