1 // Copyright (c) 1994, 1996 James Clark
2 // See the file COPYING for copying permission.
3 #pragma ident "%Z%%M% %I% %E% SMI"
5 #ifndef ContentState_INCLUDED
6 #define ContentState_INCLUDED 1
13 #include "OpenElement.h"
22 namespace SP_NAMESPACE
{
25 class SP_API ContentState
{
28 void startContent(const Dtd
&);
29 void pushElement(OpenElement
*);
30 OpenElement
*popSaveElement();
32 OpenElement
¤tElement();
33 const OpenElement
¤tElement() const;
34 void getOpenElementInfo(Vector
<OpenElementInfo
> &,
35 const StringC
&rniPcdata
) const;
36 unsigned tagLevel() const;
37 Boolean
elementIsIncluded(const ElementType
*) const;
38 Boolean
elementIsExcluded(const ElementType
*) const;
39 Boolean
elementIsOpen(const ElementType
*) const;
40 Boolean
afterDocumentElement() const;
41 const ElementType
*lastEndedElementType() const;
42 Mode
contentMode() const;
43 ElementType
*lookupCreateUndefinedElement(const StringC
&,
46 Boolean
checkImplyLoop(unsigned);
47 static const ShortReferenceMap theEmptyMap
;
49 IList
<OpenElement
> openElements_
;
50 Vector
<unsigned> openElementCount_
;
51 Vector
<unsigned> includeCount_
;
52 Vector
<unsigned> excludeCount_
;
53 unsigned totalExcludeCount_
;
55 unsigned netEnablingCount_
;
56 unsigned long nextIndex_
;
57 const ElementType
*lastEndedElementType_
;
58 ElementType documentElementContainer_
;
62 OpenElement
&ContentState::currentElement()
64 return *openElements_
.head();
68 const OpenElement
&ContentState::currentElement() const
70 return *openElements_
.head();
74 Boolean
ContentState::elementIsOpen(const ElementType
*e
) const
76 return openElementCount_
[e
->index()] != 0;
80 Boolean
ContentState::elementIsIncluded(const ElementType
*e
) const
82 return includeCount_
[e
->index()] != 0 && excludeCount_
[e
->index()] == 0;
86 Boolean
ContentState::elementIsExcluded(const ElementType
*e
) const
88 return excludeCount_
[e
->index()] != 0;
92 const ElementType
*ContentState::lastEndedElementType() const
94 return lastEndedElementType_
;
98 unsigned ContentState::tagLevel() const
104 Boolean
ContentState::afterDocumentElement() const
106 return tagLevel() == 0 && currentElement().isFinished();
110 Mode
ContentState::contentMode() const
112 return openElements_
.head()->mode(netEnablingCount_
> 0);
119 #endif /* not ContentState_INCLUDED */