2 * CDE - Common Desktop Environment
4 * Copyright (c) 1993-2012, The Open Group. All rights reserved.
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)
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
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with these librararies and programs; if not, write
20 * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
21 * Floor, Boston, MA 02110-1301 USA
23 /* $XConsortium: OpenElement.h /main/1 1996/07/29 16:59:20 cde-hp $ */
24 // Copyright (c) 1994 James Clark
25 // See the file COPYING for copying permission.
27 #ifndef OpenElement_INCLUDED
28 #define OpenElement_INCLUDED 1
34 #include "ContentToken.h"
35 #include "ElementType.h"
38 #include "Allocator.h"
42 namespace SP_NAMESPACE {
45 class SP_API OpenElement : public Link {
47 void *operator new(size_t sz, Allocator &alloc) { return alloc.alloc(sz); }
48 void *operator new(size_t sz) { return Allocator::allocSimple(sz); }
49 void operator delete(void *p) { Allocator::free(p); }
50 OpenElement(const ElementType *, Boolean net, Boolean included,
51 const ShortReferenceMap *currentMap,
52 const Location &startLocation);
53 Boolean isFinished() const;
54 Boolean tryTransition(const ElementType *);
55 const LeafContentToken *invalidExclusion(const ElementType *) const;
56 // This doesn't handle declared content of EMPTY.
57 // If this situation can arise must use declaredEmpty().
58 Boolean tryTransitionPcdata();
59 const LeafContentToken *impliedStartTag() const;
60 void doRequiredTransition();
61 const ElementType *type() const;
62 Boolean netEnabling() const;
63 Boolean included() const;
64 const MatchState &matchState() const;
65 void setMatchState(const MatchState &);
66 Mode mode(Boolean netEnabled) const;
67 const ShortReferenceMap *map() const;
68 void setMap(const ShortReferenceMap *);
69 Boolean requiresSpecialParse() const;
70 const Location &startLocation() const;
71 const LeafContentToken *currentPosition() const;
72 Boolean declaredEmpty() const;
75 OpenElement(const OpenElement &); // undefined
76 void operator=(const OpenElement &); // undefined
77 const ElementType *elementType_;
78 PackedBoolean netEnabling_; // start-tag was net-enabling
79 PackedBoolean included_;
80 MatchState matchState_;
81 ElementDefinition::DeclaredContent declaredContent_;
82 const ShortReferenceMap *map_;
83 Location startLocation_;
87 const ElementType *OpenElement::type() const
93 Boolean OpenElement::netEnabling() const
99 Boolean OpenElement::included() const
105 const MatchState &OpenElement::matchState() const
111 void OpenElement::setMatchState(const MatchState &state)
117 Boolean OpenElement::isFinished() const
119 return (declaredContent_ != ElementDefinition::modelGroup
120 || matchState_.isFinished());
124 Boolean OpenElement::tryTransition(const ElementType *e)
126 return (declaredContent_ == ElementDefinition::modelGroup
127 ? matchState_.tryTransition(e)
128 : (declaredContent_ == ElementDefinition::any));
132 Boolean OpenElement::tryTransitionPcdata()
134 return (declaredContent_ == ElementDefinition::modelGroup
135 ? matchState_.tryTransitionPcdata()
136 : 1); // CDATA, RCDATA, ANY all ok
140 const LeafContentToken *OpenElement::invalidExclusion(const ElementType *e)
143 return (declaredContent_ == ElementDefinition::modelGroup
144 ? matchState_.invalidExclusion(e)
149 void OpenElement::doRequiredTransition()
151 matchState_.doRequiredTransition();
155 const LeafContentToken *OpenElement::impliedStartTag() const
157 return (declaredContent_ == ElementDefinition::modelGroup
158 ? matchState_.impliedStartTag()
163 const ShortReferenceMap *OpenElement::map() const
169 void OpenElement::setMap(const ShortReferenceMap *map)
175 Boolean OpenElement::requiresSpecialParse() const
177 return (declaredContent_ == ElementDefinition::cdata
178 || declaredContent_ == ElementDefinition::rcdata);
182 Mode OpenElement::mode(Boolean netEnabled) const
184 return elementType_->definition()->mode(netEnabled);
188 const Location &OpenElement::startLocation() const
190 return startLocation_;
194 const LeafContentToken *OpenElement::currentPosition() const
196 return (declaredContent_ == ElementDefinition::modelGroup
197 ? matchState_.currentPosition()
202 Boolean OpenElement::declaredEmpty() const
204 return declaredContent_ == ElementDefinition::empty;
208 void OpenElement::setConref()
210 declaredContent_ = ElementDefinition::empty;
217 #endif /* not OpenElement_INCLUDED */