Remove Unixware and openserver support
[oweals/cde.git] / cde / programs / nsgmls / ContentState.h
1 /*
2  * CDE - Common Desktop Environment
3  *
4  * Copyright (c) 1993-2012, The Open Group. All rights reserved.
5  *
6  * These libraries and programs are free software; you can
7  * redistribute them and/or modify them under the terms of the GNU
8  * Lesser General Public License as published by the Free Software
9  * Foundation; either version 2 of the License, or (at your option)
10  * any later version.
11  *
12  * These libraries and programs are distributed in the hope that
13  * they will be useful, but WITHOUT ANY WARRANTY; without even the
14  * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15  * PURPOSE. See the GNU Lesser General Public License for more
16  * details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with these libraries and programs; if not, write
20  * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
21  * Floor, Boston, MA 02110-1301 USA
22  */
23 /* $XConsortium: ContentState.h /main/1 1996/07/29 16:48:27 cde-hp $ */
24 // Copyright (c) 1994, 1996 James Clark
25 // See the file COPYING for copying permission.
26
27 #ifndef ContentState_INCLUDED
28 #define ContentState_INCLUDED 1
29
30 #ifdef __GNUG__
31 #pragma interface
32 #endif
33
34 #include <stddef.h>
35 #include "OpenElement.h"
36 #include "IList.h"
37 #include "Vector.h"
38 #include "Message.h"
39 #include "Dtd.h"
40 #include "Mode.h"
41 #include "Boolean.h"
42
43 #ifdef SP_NAMESPACE
44 namespace SP_NAMESPACE {
45 #endif
46
47 class SP_API ContentState {
48 public:
49   ContentState();
50   void startContent(const Dtd &);
51   void pushElement(OpenElement *);
52   OpenElement *popSaveElement();
53   void popElement();
54   OpenElement &currentElement();
55   const OpenElement &currentElement() const;
56   void getOpenElementInfo(Vector<OpenElementInfo> &,
57                           const StringC &rniPcdata) const;
58   unsigned tagLevel() const;
59   Boolean elementIsIncluded(const ElementType *) const;
60   Boolean elementIsExcluded(const ElementType *) const;
61   Boolean elementIsOpen(const ElementType *) const;
62   Boolean afterDocumentElement() const;
63   const ElementType *lastEndedElementType() const;
64   Mode contentMode() const;
65   const ElementType *lookupCreateUndefinedElement(const StringC &,
66                                                   const Location &);
67   Boolean checkImplyLoop(unsigned);
68   static const ShortReferenceMap theEmptyMap;
69 private:
70   IList<OpenElement> openElements_;
71   Vector<unsigned> openElementCount_;
72   Vector<unsigned> includeCount_;
73   Vector<unsigned> excludeCount_;
74   unsigned totalExcludeCount_;
75   unsigned tagLevel_;
76   unsigned netEnablingCount_;
77   const ElementType *lastEndedElementType_;
78   NamedTable<ElementType> undefinedElementTypeTable_;
79   ElementType documentElementContainer_;
80 };
81
82 inline
83 OpenElement &ContentState::currentElement()
84 {
85   return *openElements_.head();
86 }
87
88 inline
89 const OpenElement &ContentState::currentElement() const
90 {
91   return *openElements_.head();
92 }
93
94 inline
95 Boolean ContentState::elementIsOpen(const ElementType *e) const
96 {
97   return openElementCount_[e->index()] != 0;
98 }
99
100 inline
101 Boolean ContentState::elementIsIncluded(const ElementType *e) const
102 {
103   return includeCount_[e->index()] != 0 && excludeCount_[e->index()] == 0;
104 }
105
106 inline
107 Boolean ContentState::elementIsExcluded(const ElementType *e) const
108 {
109   return excludeCount_[e->index()] != 0;
110 }
111
112 inline
113 const ElementType *ContentState::lastEndedElementType() const
114 {
115   return lastEndedElementType_;
116 }
117
118 inline
119 unsigned ContentState::tagLevel() const
120 {
121   return tagLevel_;
122 }
123
124 inline
125 Boolean ContentState::afterDocumentElement() const
126 {
127   return tagLevel() == 0 && currentElement().isFinished();
128 }
129
130 inline
131 Mode ContentState::contentMode() const
132 {
133   return openElements_.head()->mode(netEnablingCount_ > 0);
134 }
135
136 #ifdef SP_NAMESPACE
137 }
138 #endif
139
140 #endif /* not ContentState_INCLUDED */