1 /* $XConsortium: ContentState.h /main/1 1996/07/29 16:48:27 cde-hp $ */
2 // Copyright (c) 1994, 1996 James Clark
3 // See the file COPYING for copying permission.
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 const ElementType *lookupCreateUndefinedElement(const StringC &,
45 Boolean checkImplyLoop(unsigned);
46 static const ShortReferenceMap theEmptyMap;
48 IList<OpenElement> openElements_;
49 Vector<unsigned> openElementCount_;
50 Vector<unsigned> includeCount_;
51 Vector<unsigned> excludeCount_;
52 unsigned totalExcludeCount_;
54 unsigned netEnablingCount_;
55 const ElementType *lastEndedElementType_;
56 NamedTable<ElementType> undefinedElementTypeTable_;
57 ElementType documentElementContainer_;
61 OpenElement &ContentState::currentElement()
63 return *openElements_.head();
67 const OpenElement &ContentState::currentElement() const
69 return *openElements_.head();
73 Boolean ContentState::elementIsOpen(const ElementType *e) const
75 return openElementCount_[e->index()] != 0;
79 Boolean ContentState::elementIsIncluded(const ElementType *e) const
81 return includeCount_[e->index()] != 0 && excludeCount_[e->index()] == 0;
85 Boolean ContentState::elementIsExcluded(const ElementType *e) const
87 return excludeCount_[e->index()] != 0;
91 const ElementType *ContentState::lastEndedElementType() const
93 return lastEndedElementType_;
97 unsigned ContentState::tagLevel() const
103 Boolean ContentState::afterDocumentElement() const
105 return tagLevel() == 0 && currentElement().isFinished();
109 Mode ContentState::contentMode() const
111 return openElements_.head()->mode(netEnablingCount_ > 0);
118 #endif /* not ContentState_INCLUDED */