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: ArcProcessor.h /main/1 1996/07/29 16:46:28 cde-hp $ */
24 // Copyright (c) 1996 James Clark
25 // See the file COPYING for copying permission.
27 #ifndef ArcProcessor_INCLUDED
28 #define ArcProcessor_INCLUDED 1
31 #include "ContentState.h"
33 #include "NamedTable.h"
35 #include "ArcEngine.h"
36 #include "SgmlParser.h"
39 namespace SP_NAMESPACE {
44 // Processor for a single architecture
46 class ArcProcessor : private ContentState, private AttributeContext {
51 const Attributed *attributed;
52 unsigned suppressFlags;
53 // #ARCCONT and #CONTENT are handled with a special index
54 // list of indexes into element's attlist of architectural attributes
55 Vector<unsigned> attMapFrom;
56 // corresponding list of indexes in form's attlist
57 Vector<unsigned> attMapTo;
64 // Prerequisites for this cached entry to be valid.
65 // The cache is only valid if for each member of noSpec != -1
66 // the attribute with that index was not specified (or current)
67 unsigned noSpec[nNoSpec];
68 unsigned suppressFlags;
69 const AttributeList *linkAtts;
72 void setName(const StringC &);
73 void init(const EndPrologEvent &,
75 const ConstPtr<Syntax> &,
76 const SgmlParser *parser,
78 const Vector<StringC> &superName,
79 ArcDirector &director,
80 SP_CONST SP_VOLATILE sig_atomic_t *cancelPtr);
81 // Return 0 if the content is needed, but wasn't supplied
82 Boolean processStartElement(const StartElementEvent &,
83 const AttributeList *linkAttributes,
86 void processEndElement(const EndElementEvent &,
88 // Return true if its architectural.
89 Boolean processData();
90 const ConstPtr<Dtd> &dtdPointer() const { return metaDtd_; }
91 Boolean valid() const { return valid_; }
93 const StringC &name() const { return name_; }
94 EventHandler &docHandler() const { return *docHandler_; }
96 ArcProcessor(const ArcProcessor &); // undefined
97 void operator=(const ArcProcessor &); // undefined
98 const Syntax &attributeSyntax() const;
99 ConstPtr<Notation> getAttributeNotation(const StringC &,
101 ConstPtr<Entity> getAttributeEntity(const StringC &,
103 void noteCurrentAttribute(size_t, AttributeValue *);
104 ConstPtr<AttributeValue> getCurrentAttribute(size_t) const;
105 Boolean defineId(const StringC &, const Location &, Location &);
106 void noteIdref(const StringC &, const Location &);
107 Id *lookupCreateId(const StringC &);
108 void dispatchMessage(const Message &);
109 void dispatchMessage(Message &);
110 void initMessage(Message &);
111 const MetaMap &buildMetaMap(const ElementType *,
113 const AttributeList &,
114 const AttributeList *linkAtts,
115 unsigned suppressFlags);
116 void considerSupr(const AttributeList &atts,
117 const AttributeList *linkAtts,
118 unsigned &thisSuppressFlags,
119 unsigned &newSuppressFlags,
120 Boolean &inhibitCache,
121 unsigned &arcSuprIndex);
122 void considerIgnD(const AttributeList &atts,
123 const AttributeList *linkAtts,
124 unsigned thisSuppressFlags,
125 unsigned &newSuppressFlags,
126 Boolean &inhibitCache,
127 unsigned &arcSuprIndex);
128 const Attributed *considerForm(const AttributeList &atts,
129 const AttributeList *linkAtts,
132 unsigned thisSuppressFlags,
133 unsigned &newSuppressFlags,
134 Boolean &inhibitCache,
135 unsigned &arcFormIndex);
136 const Attributed *autoForm(const AttributeList &atts,
139 unsigned thisSuppressFlags,
140 unsigned &newSuppressFlags,
141 Boolean &inhibitCache,
143 const Text *considerNamer(const AttributeList &atts,
144 Boolean &inhibitCache,
145 unsigned &arcNamerIndex);
146 void buildAttributeMapRename(MetaMap &map,
148 const AttributeList &atts,
149 const AttributeList *linkAtts,
150 Vector<PackedBoolean> &attRenamed);
151 void buildAttributeMapRest(MetaMap &map,
152 const AttributeList &atts,
153 const AttributeList *linkAtts,
154 const Vector<PackedBoolean> &attRenamed);
155 Boolean matchName(const StringC &name, const char *key);
156 void split(const Text &text,
158 Vector<StringC> &tokens,
159 Vector<size_t> &tokenPos);
160 Boolean mapAttributes(const AttributeList &from,
161 const AttributeList *fromLink,
164 ConstPtr<AttributeValue> &arcContent,
166 void initNotationSet(const Location &loc);
167 const Attributed *considerNotation(const AttributeList &atts,
168 unsigned thisSuppressFlags,
169 Boolean &inhibitCache,
170 unsigned ¬AttIndex);
171 void supportAttributes(const AttributeList &);
172 void processArcOpts(const AttributeList &atts);
173 void processArcQuant(const Text &);
174 ConstPtr<Entity> makeDtdEntity(const Notation *);
175 void mungeMetaDtd(Dtd &metaDtd, const Dtd &docDtd);
176 Boolean mungeDataEntity(ExternalDataEntity &entity);
177 void emitArcContent(const Text &text,
178 EventHandler &handler,
179 Allocator &allocator);
184 ConstPtr<Dtd> docDtd_;
185 ConstPtr<Dtd> metaDtd_;
186 ConstPtr<Syntax> docSyntax_;
187 ConstPtr<Syntax> metaSyntax_;
203 enum { nReserve = rArcQuant + 1 };
204 StringC supportAtts_[nReserve];
205 Boolean arcDtdIsParam_;
207 Vector<StringC> arcOpts_;
216 condIgnoreData = 020,
217 // recovering from invalid data
220 Vector<unsigned> openElementFlags_;
221 AttributeList attributeList_;
222 NCVector<Owner<struct MetaMapCache> > metaMapCache_;
223 MetaMap noCacheMetaMap_;
224 NamedTable<Id> idTable_;
225 Vector<ConstPtr<AttributeValue> > currentAttributes_;
226 ConstPtr<Notation> defaultNotation_;
228 Boolean notationSetArch_;
229 ArcDirector *director_;
230 EventHandler *docHandler_;
231 Owner<EventHandler> ownEventHandler_;
239 #endif /* not ArcProcessor_INCLUDED */