1 // Copyright (c) 1994, 1996 James Clark
2 // See the file COPYING for copying permission.
4 #ifndef ContentState_INCLUDED
5 #define ContentState_INCLUDED 1
12 #include "OpenElement.h"
21 namespace SP_NAMESPACE {
24 class SP_API ContentState {
27 void startContent(const Dtd &);
28 void pushElement(OpenElement *);
29 OpenElement *popSaveElement();
31 OpenElement ¤tElement();
32 const OpenElement ¤tElement() const;
33 void getOpenElementInfo(Vector<OpenElementInfo> &,
34 const StringC &rniPcdata) const;
35 unsigned tagLevel() const;
36 Boolean elementIsIncluded(const ElementType *) const;
37 Boolean elementIsExcluded(const ElementType *) const;
38 Boolean elementIsOpen(const ElementType *) const;
39 Boolean afterDocumentElement() const;
40 const ElementType *lastEndedElementType() const;
41 Mode contentMode() const;
42 ElementType *lookupCreateUndefinedElement(const StringC &,
45 Boolean allowImmediateRecursion = 1);
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 */