1 /* $XConsortium: SGMLApplication.h /main/1 1996/07/29 17:03:14 cde-hp $ */
2 // Copyright (c) 1995 James Clark
3 // See the file COPYING for copying permission.
5 #ifndef SGMLApplication_INCLUDED
6 #define SGMLApplication_INCLUDED 1
15 #define SP_API /* as nothing */
18 class SP_API SGMLApplication {
21 typedef unsigned short Char;
23 typedef unsigned char Char;
25 // A Position represents a position in an OpenEntity.
26 // The meaning of a Position depends on the
27 // particular implementation of OpenEntity.
28 // It might be a line number or it might be
29 // an offset in the entity. The only thing
30 // that can be done with Position is to use
31 // it with an OpenEntityPtr to get a Location.
32 typedef unsigned long Position;
40 bool haveGeneratedSystemId;
41 CharString systemId; // valid only if haveSystemId is true
42 CharString publicId; // valid only if havePublicId is true
43 CharString generatedSystemId; // valid if haveGeneratedSystemId is true
47 ExternalId externalId;
52 enum DataType { sgml, cdata, sdata, ndata, subdoc, pi };
53 enum DeclType { general, parameter, doctype, linktype };
57 // Following valid if isInternal is true
59 // Following valid if isInternal is false
60 ExternalId externalId;
62 const Attribute *attributes;
75 specified, // not defaulted
76 definition, // defaulted from definition
77 current // defaulted from current value
79 Defaulted defaulted; // non-ESIS; valid only if type != implied
83 CharString entityName; // non-ESIS; optional for SDATA chunks
85 // Following valid if type == cdata
87 const CdataChunk *cdataChunks; // valid if type == cdata
88 // Following valid if type == tokenized
89 CharString tokens; // separated by spaces
90 bool isId; // non-ESIS (probably)
91 bool isGroup; // non-ESIS
93 const Entity *entities;
94 // length of notation.name will be 0 if no notation
100 CharString entityName; // non-ESIS; optional for PI entities
102 struct StartElementEvent {
105 empty, // declared EMPTY or with CONREF attribute
112 ContentType contentType; // non-ESIS
113 bool included; // non-ESIS
115 const Attribute *attributes;
118 struct EndElementEvent {
129 CharString entityName; // non-ESIS; optional
131 struct ExternalDataEntityRefEvent {
135 struct SubdocEntityRefEvent {
142 info, // not an error
143 warning, // not an error
152 struct AppinfoEvent {
157 struct StartDtdEvent {
161 ExternalId externalId;
167 struct EndPrologEvent {
171 struct GeneralEntityEvent {
176 struct CommentDeclEvent {
179 const CharString *comments;
180 const CharString *seps;
183 struct MarkedSectionStartEvent {
202 CharString entityName;
208 struct MarkedSectionEndEvent {
218 struct IgnoredCharsEvent {
223 struct SP_API Location {
225 Location(const OpenEntityPtr &, Position);
228 unsigned long lineNumber;
229 unsigned long columnNumber;
230 unsigned long byteOffset;
231 unsigned long entityOffset;
232 CharString entityName;
237 class SP_API OpenEntityPtr {
240 OpenEntityPtr(const OpenEntityPtr &);
241 void operator=(const OpenEntityPtr &);
242 void operator=(OpenEntity *);
244 const OpenEntity *operator->() const;
245 operator int() const;
249 class SP_API OpenEntity {
252 virtual ~OpenEntity();
253 virtual Location location(Position) const = 0;
255 OpenEntity(const OpenEntity &); // undefined
256 void operator=(const OpenEntity &); // undefined
258 friend class OpenEntityPtr;
260 virtual ~SGMLApplication();
261 virtual void appinfo(const AppinfoEvent &);
262 virtual void startDtd(const StartDtdEvent &);
263 virtual void endDtd(const EndDtdEvent &);
264 virtual void endProlog(const EndPrologEvent &);
265 virtual void startElement(const StartElementEvent &);
266 virtual void endElement(const EndElementEvent &);
267 virtual void data(const DataEvent &);
268 virtual void sdata(const SdataEvent &);
269 virtual void pi(const PiEvent &);
270 virtual void externalDataEntityRef(const ExternalDataEntityRefEvent &);
271 virtual void subdocEntityRef(const SubdocEntityRefEvent &);
272 virtual void commentDecl(const CommentDeclEvent &);
273 virtual void markedSectionStart(const MarkedSectionStartEvent &);
274 virtual void markedSectionEnd(const MarkedSectionEndEvent &);
275 virtual void ignoredChars(const IgnoredCharsEvent &);
276 virtual void generalEntity(const GeneralEntityEvent &);
277 virtual void error(const ErrorEvent &);
278 virtual void openEntityChange(const OpenEntityPtr &);
282 const SGMLApplication::OpenEntity *
283 SGMLApplication::OpenEntityPtr::operator->() const
289 void SGMLApplication::OpenEntityPtr::operator=(const OpenEntityPtr &ptr)
295 SGMLApplication::OpenEntityPtr::operator int() const
300 #endif /* not SGMLApplication_INCLUDED */