1 /* $XConsortium: ArcProcessor.h /main/1 1996/07/29 16:46:28 cde-hp $ */
2 // Copyright (c) 1996 James Clark
3 // See the file COPYING for copying permission.
5 #ifndef ArcProcessor_INCLUDED
6 #define ArcProcessor_INCLUDED 1
9 #include "ContentState.h"
11 #include "NamedTable.h"
13 #include "ArcEngine.h"
14 #include "SgmlParser.h"
17 namespace SP_NAMESPACE {
22 // Processor for a single architecture
24 class ArcProcessor : private ContentState, private AttributeContext {
29 const Attributed *attributed;
30 unsigned suppressFlags;
31 // #ARCCONT and #CONTENT are handled with a special index
32 // list of indexes into element's attlist of architectural attributes
33 Vector<unsigned> attMapFrom;
34 // corresponding list of indexes in form's attlist
35 Vector<unsigned> attMapTo;
42 // Prerequisites for this cached entry to be valid.
43 // The cache is only valid if for each member of noSpec != -1
44 // the attribute with that index was not specified (or current)
45 unsigned noSpec[nNoSpec];
46 unsigned suppressFlags;
47 const AttributeList *linkAtts;
50 void setName(const StringC &);
51 void init(const EndPrologEvent &,
53 const ConstPtr<Syntax> &,
54 const SgmlParser *parser,
56 const Vector<StringC> &superName,
57 ArcDirector &director,
58 SP_CONST SP_VOLATILE sig_atomic_t *cancelPtr);
59 // Return 0 if the content is needed, but wasn't supplied
60 Boolean processStartElement(const StartElementEvent &,
61 const AttributeList *linkAttributes,
64 void processEndElement(const EndElementEvent &,
66 // Return true if its architectural.
67 Boolean processData();
68 const ConstPtr<Dtd> &dtdPointer() const { return metaDtd_; }
69 Boolean valid() const { return valid_; }
71 const StringC &name() const { return name_; }
72 EventHandler &docHandler() const { return *docHandler_; }
74 ArcProcessor(const ArcProcessor &); // undefined
75 void operator=(const ArcProcessor &); // undefined
76 const Syntax &attributeSyntax() const;
77 ConstPtr<Notation> getAttributeNotation(const StringC &,
79 ConstPtr<Entity> getAttributeEntity(const StringC &,
81 void noteCurrentAttribute(size_t, AttributeValue *);
82 ConstPtr<AttributeValue> getCurrentAttribute(size_t) const;
83 Boolean defineId(const StringC &, const Location &, Location &);
84 void noteIdref(const StringC &, const Location &);
85 Id *lookupCreateId(const StringC &);
86 void dispatchMessage(const Message &);
87 void dispatchMessage(Message &);
88 void initMessage(Message &);
89 const MetaMap &buildMetaMap(const ElementType *,
91 const AttributeList &,
92 const AttributeList *linkAtts,
93 unsigned suppressFlags);
94 void considerSupr(const AttributeList &atts,
95 const AttributeList *linkAtts,
96 unsigned &thisSuppressFlags,
97 unsigned &newSuppressFlags,
98 Boolean &inhibitCache,
99 unsigned &arcSuprIndex);
100 void considerIgnD(const AttributeList &atts,
101 const AttributeList *linkAtts,
102 unsigned thisSuppressFlags,
103 unsigned &newSuppressFlags,
104 Boolean &inhibitCache,
105 unsigned &arcSuprIndex);
106 const Attributed *considerForm(const AttributeList &atts,
107 const AttributeList *linkAtts,
110 unsigned thisSuppressFlags,
111 unsigned &newSuppressFlags,
112 Boolean &inhibitCache,
113 unsigned &arcFormIndex);
114 const Attributed *autoForm(const AttributeList &atts,
117 unsigned thisSuppressFlags,
118 unsigned &newSuppressFlags,
119 Boolean &inhibitCache,
121 const Text *considerNamer(const AttributeList &atts,
122 Boolean &inhibitCache,
123 unsigned &arcNamerIndex);
124 void buildAttributeMapRename(MetaMap &map,
126 const AttributeList &atts,
127 const AttributeList *linkAtts,
128 Vector<PackedBoolean> &attRenamed);
129 void buildAttributeMapRest(MetaMap &map,
130 const AttributeList &atts,
131 const AttributeList *linkAtts,
132 const Vector<PackedBoolean> &attRenamed);
133 Boolean matchName(const StringC &name, const char *key);
134 void split(const Text &text,
136 Vector<StringC> &tokens,
137 Vector<size_t> &tokenPos);
138 Boolean mapAttributes(const AttributeList &from,
139 const AttributeList *fromLink,
142 ConstPtr<AttributeValue> &arcContent,
144 void initNotationSet(const Location &loc);
145 const Attributed *considerNotation(const AttributeList &atts,
146 unsigned thisSuppressFlags,
147 Boolean &inhibitCache,
148 unsigned ¬AttIndex);
149 void supportAttributes(const AttributeList &);
150 void processArcOpts(const AttributeList &atts);
151 void processArcQuant(const Text &);
152 ConstPtr<Entity> makeDtdEntity(const Notation *);
153 void mungeMetaDtd(Dtd &metaDtd, const Dtd &docDtd);
154 Boolean mungeDataEntity(ExternalDataEntity &entity);
155 void emitArcContent(const Text &text,
156 EventHandler &handler,
157 Allocator &allocator);
162 ConstPtr<Dtd> docDtd_;
163 ConstPtr<Dtd> metaDtd_;
164 ConstPtr<Syntax> docSyntax_;
165 ConstPtr<Syntax> metaSyntax_;
181 enum { nReserve = rArcQuant + 1 };
182 StringC supportAtts_[nReserve];
183 Boolean arcDtdIsParam_;
185 Vector<StringC> arcOpts_;
194 condIgnoreData = 020,
195 // recovering from invalid data
198 Vector<unsigned> openElementFlags_;
199 AttributeList attributeList_;
200 NCVector<Owner<struct MetaMapCache> > metaMapCache_;
201 MetaMap noCacheMetaMap_;
202 NamedTable<Id> idTable_;
203 Vector<ConstPtr<AttributeValue> > currentAttributes_;
204 ConstPtr<Notation> defaultNotation_;
206 Boolean notationSetArch_;
207 ArcDirector *director_;
208 EventHandler *docHandler_;
209 Owner<EventHandler> ownEventHandler_;
217 #endif /* not ArcProcessor_INCLUDED */