File: ArcProcessor.h

package info (click to toggle)
opensp 1.5.2-15.2
  • links: PTS
  • area: main
  • in suites: forky, sid, trixie
  • size: 9,168 kB
  • sloc: cpp: 65,784; ansic: 17,124; sh: 11,193; xml: 2,704; makefile: 895; perl: 561; yacc: 288; sed: 16
file content (230 lines) | stat: -rw-r--r-- 7,336 bytes parent folder | download | duplicates (8)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
// Copyright (c) 1996 James Clark, 2000 Matthias Clasen
// See the file COPYING for copying permission.

#ifndef ArcProcessor_INCLUDED
#define ArcProcessor_INCLUDED 1

#include "Event.h"
#include "ContentState.h"
#include "Id.h"
#include "NamedTable.h"
#include "Vector.h"
#include "ArcEngine.h"
#include "SgmlParser.h"

#ifdef SP_NAMESPACE
namespace SP_NAMESPACE {
#endif

class Allocator;

// Processor for a single architecture

class ArcProcessor : private ContentState, private AttributeContext {
public:
  struct MetaMap {
    MetaMap();
    void clear();
    const Attributed *attributed;
    unsigned suppressFlags;
    // #ARCCONT and #CONTENT are handled with a special index
    // list of indexes into element's attlist of architectural attributes
    Vector<unsigned> attMapFrom;
    // corresponding list of indexes in form's attlist
    Vector<unsigned> attMapTo;
    // corresponding list of pointers in the token maps
    Vector<size_t> attTokenMapBase;
    Vector<StringC> tokenMapFrom;
    Vector<StringC> tokenMapTo;
  };
  struct MetaMapCache {
    MetaMapCache();
    void clear();
    MetaMap map;
    enum { nNoSpec = 4 };
    // Prerequisites for this cached entry to be valid.
    // The cache is only valid if for each member of noSpec != -1
    // the attribute with that index was not specified (or current)
    unsigned noSpec[nNoSpec];
    unsigned suppressFlags;
    const AttributeList *linkAtts;
  };
  ArcProcessor();
  void setName(const StringC &, const Location &);
  void init(const EndPrologEvent &,
	    const ConstPtr<Sd> &,
	    const ConstPtr<Syntax> &,
	    const SgmlParser *parser,
	    Messenger *,
	    const Vector<StringC> &superName,
	    const NCVector<ArcProcessor> &arcProcessors,
	    ArcDirector &director,
	    const volatile sig_atomic_t *cancelPtr);
  // Return 0 if the content is needed, but wasn't supplied
  Boolean processStartElement(const StartElementEvent &,
			      const AttributeList *linkAttributes,
			      const Text *content,
			      Allocator &);
  void processEndElement(const EndElementEvent &,
			 Allocator &);
  // Return true if its architectural.
  Boolean processData();
  ConstPtr<Dtd> dtdPointer() const { return metaDtd_; }
  Boolean valid() const { return valid_; }
  void checkIdrefs();
  const StringC &name() const { return name_; }
  Boolean piDecl() const { return piDecl_; }
  EventHandler &docHandler() const { return *docHandler_; }
  void setPiDecl(const Location &loc, const StringC &attspecText, Index attspecIndex,
		 const ConstPtr<AttributeDefinitionList> &archPiAttributeDefs);
private:
  ArcProcessor(const ArcProcessor &); // undefined
  void operator=(const ArcProcessor &);	// undefined
  const Syntax &attributeSyntax() const;
  ConstPtr<Notation> getAttributeNotation(const StringC &,
					  const Location &);
  ConstPtr<Entity> getAttributeEntity(const StringC &,
				      const Location &);
  void noteCurrentAttribute(size_t, AttributeValue *);
  ConstPtr<AttributeValue> getCurrentAttribute(size_t) const;
  Boolean defineId(const StringC &, const Location &, Location &);
  void noteIdref(const StringC &, const Location &);
  Id *lookupCreateId(const StringC &);
  void dispatchMessage(const Message &);
  void dispatchMessage(Message &);
  void initMessage(Message &);
  const MetaMap &buildMetaMap(const ElementType *,
			      const Notation *,
			      const AttributeList &,
			      const AttributeList *linkAtts,
			      unsigned suppressFlags);
  void considerSupr(const AttributeList &atts,
		    const AttributeList *linkAtts,
		    unsigned &thisSuppressFlags,
		    unsigned &newSuppressFlags,
		    Boolean &inhibitCache,
		    unsigned &arcSuprIndex);
  void considerIgnD(const AttributeList &atts,
		    const AttributeList *linkAtts,
		    unsigned thisSuppressFlags,
		    unsigned &newSuppressFlags,
		    Boolean &inhibitCache,
		    unsigned &arcSuprIndex);
  const Attributed *considerForm(const AttributeList &atts,
				 const AttributeList *linkAtts,
				 const StringC &name,
				 Boolean isNotation,
				 unsigned thisSuppressFlags,
				 unsigned &newSuppressFlags,
				 Boolean &inhibitCache,
				 unsigned &arcFormIndex);
  const Attributed *autoForm(const AttributeList &atts,
			     const StringC &name,
			     Boolean isNotation,
			     unsigned thisSuppressFlags,
			     unsigned &newSuppressFlags,
			     Boolean &inhibitCache,
			     unsigned &idIndex);
  const Text *considerNamer(const AttributeList &atts,
			    Boolean &inhibitCache,
			    unsigned &arcNamerIndex);
  void buildAttributeMapRename(MetaMap &map,
			       const Text &rename,
			       const AttributeList &atts,
			       const AttributeList *linkAtts,
			       Vector<PackedBoolean> &attRenamed,
			       Vector<PackedBoolean> &attSubstituted,
                               Boolean isNotation);
  void buildAttributeMapRest(MetaMap &map,
			     const AttributeList &atts,
			     const AttributeList *linkAtts,
			     const Vector<PackedBoolean> &attRenamed);
  Boolean matchName(const StringC &name, const char *key);
  void split(const Text &text,
	     Char space,
	     Vector<StringC> &tokens,
	     Vector<size_t> &tokenPos);
  Boolean mapAttributes(const AttributeList &from,
			const AttributeList *fromLink,
			const Text *content,
			AttributeList &to,
			ConstPtr<AttributeValue> &arcContent,
			const MetaMap &map);
  void supportAttributes(const AttributeList &, Boolean piDecl);
  void processArcOpts(const AttributeList &atts, Boolean piDecl);
  void processArcQuant(const Text &);
  ConstPtr<Entity> makeDtdEntity(const Notation *);
  void mungeMetaDtd(Dtd &metaDtd, const Dtd &docDtd);
  Boolean mungeDataEntity(ExternalDataEntity &entity);
  void emitArcContent(const Text &text,
		      EventHandler &handler,
		      Allocator &allocator);

  Boolean valid_;
  StringC name_;
  Messenger *mgr_;
  ConstPtr<Dtd> docDtd_;
  Ptr<Dtd> metaDtd_;
  ConstPtr<Syntax> docSyntax_;
  ConstPtr<Syntax> metaSyntax_;
  ConstPtr<Sd> docSd_;
  enum ReservedName {
    rArcName,
    rArcPubid,
    rArcFormA,
    rArcNamrA,
    rArcSuprA,
    rArcIgnDA,
    rArcDocF,
    rArcSuprF,
    rArcBridF,
    rArcDataF,
    rArcAuto,
    rArcDTD,
    rArcDtdPubid,
    rArcDtdSysid,
    rArcQuant
  };
  enum { nReserve = rArcQuant + 1 };
  StringC supportAtts_[nReserve];
  const Text *supportAttsText_[nReserve];
  Boolean piDecl_;
  Location declLoc_;
  StringC piDeclAttspecText_;
  Index piDeclAttspecIndex_;
  ConstPtr<AttributeDefinitionList> archPiAttributeDefs_;
  Boolean arcDtdIsParam_;
  Boolean arcAuto_;
  Vector<StringC> arcOpts_;
  StringC rniContent_;
  StringC rniArcCont_;
  StringC rniDefault_;
  StringC rniMaptoken_;
  enum {
    isArc = 01,
    suppressForm = 02,
    suppressSupr = 04,
    ignoreData = 010,
    condIgnoreData = 020,
    // recovering from invalid data
    recoverData = 040
    };
  Vector<unsigned> openElementFlags_;
  AttributeList attributeList_;
  NCVector<Owner<MetaMapCache> > metaMapCache_;
  MetaMap noCacheMetaMap_;
  NamedTable<Id> idTable_;
  Vector<ConstPtr<AttributeValue> > currentAttributes_;
  ConstPtr<Notation> defaultNotation_;
  Boolean errorIdref_;
  ArcDirector *director_;
  EventHandler *docHandler_;
  Owner<EventHandler> ownEventHandler_;
  size_t docIndex_;
};

#ifdef SP_NAMESPACE
}
#endif

#endif /* not ArcProcessor_INCLUDED */