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 libraries 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: ElementType.h /main/1 1996/07/29 16:49:41 cde-hp $ */
24 // Copyright (c) 1994 James Clark
25 // See the file COPYING for copying permission.
27 #ifndef ElementType_INCLUDED
28 #define ElementType_INCLUDED 1
41 #include "Attributed.h"
43 #include "ContentToken.h"
46 namespace SP_NAMESPACE {
50 class ShortReferenceMap;
53 class SP_API ElementDefinition : public Resource {
55 enum DeclaredContent { modelGroup, any, cdata, rcdata, empty };
56 enum OmitFlags { omitStart = 01, omitEnd = 02, omitSpec = 04 };
57 enum { undefinedIndex = -1 };
58 ElementDefinition(const Location &location,
60 unsigned char omitFlags,
61 DeclaredContent declaredContent);
62 ElementDefinition(const Location &location,
64 unsigned char omitFlags,
65 DeclaredContent declaredContent,
66 Owner<CompiledModelGroup> &modelGroup);
67 const CompiledModelGroup *compiledModelGroup() const;
68 DeclaredContent declaredContent() const;
69 // Was the omitted tag minimization specified?
70 Boolean omittedTagSpec() const;
71 Boolean canOmitStartTag() const;
72 Boolean canOmitEndTag() const;
73 size_t nRankStems() const;
74 const RankStem *rankStem(size_t i) const;
75 const StringC &rankSuffix() const;
76 size_t nInclusions() const;
77 const ElementType *inclusion(size_t) const;
78 size_t nExclusions() const;
79 const ElementType *exclusion(size_t) const;
80 Boolean undefined() const;
81 void setInclusions(Vector<const ElementType *> &inclusions);
82 void setExclusions(Vector<const ElementType *> &exclusions);
83 void setRank(StringC &suffix, Vector<const RankStem *> &rankStems);
84 Mode mode(Boolean netEnabled) const;
86 ElementDefinition(const ElementDefinition &); // undefined
87 void operator=(const ElementDefinition &); // undefined
92 unsigned char omitFlags_;
93 DeclaredContent declaredContent_;
94 Owner<CompiledModelGroup> modelGroup_;
95 Vector<const ElementType *> inclusions_;
96 Vector<const ElementType *> exclusions_;
97 // rankStems_ contains all the rank stems in the ranked group in this
99 Vector<const RankStem *> rankStems_;
105 class SP_API RankStem : public Named {
107 RankStem(const StringC &, size_t);
108 size_t index() const;
109 void addDefinition(const ConstPtr<ElementDefinition> &);
110 size_t nDefinitions() const;
111 const ElementDefinition *definition(size_t) const;
113 RankStem(const RankStem &); // undefined
114 void operator=(const RankStem &); // undefined
116 Vector<ConstPtr<ElementDefinition> > def_;
119 class SP_API ElementType : public Named, public Attributed {
121 ElementType(const StringC &, size_t);
122 void setElementDefinition(const ConstPtr<ElementDefinition> &,
124 void setMap(const ShortReferenceMap *);
125 void setRankStem(RankStem *);
126 Boolean undefined() const;
127 const ElementDefinition *definition() const;
128 Boolean isRankedElement() const;
129 const RankStem *rankedElementRankStem() const;
130 size_t index() const;
131 const ShortReferenceMap *map() const;
132 void swap(ElementType &);
134 ElementType(const ElementType &); // undefined
135 void operator=(const ElementType &); // undefined
137 size_t defIndex_; // index in the group having same definition
138 ConstPtr<ElementDefinition> def_;
139 const ShortReferenceMap *map_;
143 const CompiledModelGroup *ElementDefinition::compiledModelGroup() const
145 return modelGroup_.pointer();
149 ElementDefinition::DeclaredContent ElementDefinition::declaredContent() const
151 return declaredContent_;
155 Boolean ElementDefinition::canOmitStartTag() const
157 return (omitFlags_ & omitStart) != 0;
161 Boolean ElementDefinition::canOmitEndTag() const
163 return (omitFlags_ & omitEnd) != 0;
167 Boolean ElementDefinition::omittedTagSpec() const
169 return (omitFlags_ & omitSpec) != 0;
173 size_t ElementDefinition::nRankStems() const
175 return rankStems_.size();
179 const StringC &ElementDefinition::rankSuffix() const
185 const RankStem *ElementDefinition::rankStem(size_t i) const
187 return rankStems_[i];
191 const ElementType *ElementDefinition::inclusion(size_t i) const
193 return inclusions_[i];
197 size_t ElementDefinition::nInclusions() const
199 return inclusions_.size();
203 const ElementType *ElementDefinition::exclusion(size_t i) const
205 return exclusions_[i];
209 size_t ElementDefinition::nExclusions() const
211 return exclusions_.size();
215 Boolean ElementDefinition::undefined() const
217 return index_ == size_t(undefinedIndex);
221 void ElementDefinition::setInclusions(Vector<const ElementType *> &inclusions)
223 inclusions.swap(inclusions_);
227 void ElementDefinition::setExclusions(Vector<const ElementType *> &exclusions)
229 exclusions.swap(exclusions_);
233 void ElementDefinition::setRank(StringC &rankSuffix,
234 Vector<const RankStem *> &rankStems)
236 rankStems.swap(rankStems_);
237 rankSuffix.swap(rankSuffix_);
241 Boolean ElementType::undefined() const
243 return def_->undefined();
247 Boolean ElementType::isRankedElement() const
249 return def_->nRankStems() > 0;
253 const ElementDefinition *ElementType::definition() const
255 return def_.pointer();
259 void ElementType::setElementDefinition(const ConstPtr<ElementDefinition> &def,
263 defIndex_ = defIndex;
267 size_t ElementType::index() const
273 const RankStem *ElementType::rankedElementRankStem() const
275 return def_->rankStem(defIndex_);
279 void ElementType::setMap(const ShortReferenceMap *map)
285 const ShortReferenceMap *ElementType::map() const
291 size_t RankStem::index() const
297 size_t RankStem::nDefinitions() const
303 const ElementDefinition *RankStem::definition(size_t i) const
305 return def_[i].pointer();
309 Mode ElementDefinition::mode(Boolean netEnabled) const
311 return netEnabled ? netMode_ : mode_;
318 #endif /* not ElementType_INCLUDED */