1 // Copyright (c) 1994 James Clark
2 // See the file COPYING for copying permission.
3 #pragma ident "%Z%%M% %I% %E% SMI"
5 #ifndef SgmlsEventHandler_INCLUDED
6 #define SgmlsEventHandler_INCLUDED 1
12 #include "OutputCharStream.h"
13 #include "StringSet.h"
18 #include "LinkProcess.h"
20 #include "ErrorCountEventHandler.h"
23 namespace SP_NAMESPACE
{
27 struct StorageObjectSpec
;
29 class SgmlsSubdocState
{
32 SgmlsSubdocState(const SgmlParser
*);
33 void init(const SgmlParser
*);
34 void swap(SgmlsSubdocState
&);
36 const SgmlParser
*parser_
;
37 StringSet definedEntities_
;
38 StringSet definedNotations_
;
39 Boolean haveLinkProcess_
;
40 LinkProcess linkProcess_
;
42 SgmlsSubdocState(const SgmlsSubdocState
&); // undefined
43 void operator=(const SgmlsSubdocState
&); // undefined
46 class SgmlsEventHandler
: public ErrorCountEventHandler
,
47 private SgmlsSubdocState
, private Messenger
{
54 outputNotationSysid
= 020,
59 SgmlsEventHandler(const SgmlParser
*,
62 unsigned outputFlags
);
64 void data(DataEvent
*);
65 void startElement(StartElementEvent
*);
66 void endElement(EndElementEvent
*);
68 void sdataEntity(SdataEntityEvent
*);
69 void externalDataEntity(ExternalDataEntityEvent
*);
70 void subdocEntity(SubdocEntityEvent
*);
71 void nonSgmlChar(NonSgmlCharEvent
*);
72 void appinfo(AppinfoEvent
*);
73 void uselink(UselinkEvent
*);
74 void sgmlDecl(SgmlDeclEvent
*);
75 void endProlog(EndPrologEvent
*);
76 void message(MessageEvent
*);
77 void entityDefaulted(EntityDefaultedEvent
*event
);
79 void dispatchMessage(const Message
&);
80 void dispatchMessage(Message
&tmp_message
) {
81 dispatchMessage((const Message
&)tmp_message
);
83 void initMessage(Message
&);
85 SgmlsEventHandler(const SgmlsEventHandler
&); // undefined
86 void operator=(const SgmlsEventHandler
&); // undefined
88 void attributes(const AttributeList
&attributes
, char code
,
89 const StringC
*ownerName
);
90 void startAttribute(const StringC
&name
, char code
,
91 const StringC
*ownerName
);
92 void defineEntity(const Entity
*entity
);
93 void defineExternalDataEntity(const ExternalDataEntity
*entity
);
94 void defineSubdocEntity(const SubdocEntity
*entity
);
95 void defineExternalTextEntity(const ExternalEntity
*entity
);
96 void defineInternalEntity(const InternalEntity
*entity
);
97 void defineNotation(const Notation
*notation
);
98 void externalId(const ExternalId
&id
, Boolean outputFile
= 1);
99 Boolean
markEntity(const Entity
*);
100 Boolean
markNotation(const Notation
*);
104 void outputLocation(const Location
&loc
);
105 void outputLocation1(const Location
&loc
);
106 void outputString(const StringC
&str
);
107 void outputString(const Char
*, size_t);
108 static void escape(OutputCharStream
&, Char
);
110 OutputCharStream
&os();
112 Messenger
*messenger_
;
113 Location currentLocation_
;
114 OutputCharStream
*os_
;
117 ConstPtr
<Syntax
> syntax_
;
118 const StorageObjectSpec
*lastSos_
;
119 unsigned long lastLineno_
;
121 PackedBoolean outputLine_
;
122 PackedBoolean outputIncluded_
;
123 PackedBoolean outputEntity_
;
124 PackedBoolean outputId_
;
125 PackedBoolean outputNotationSysid_
;
126 PackedBoolean outputNonSgml_
;
127 PackedBoolean outputEmpty_
;
131 void SgmlsEventHandler::outputString(const StringC
&str
)
133 outputString(str
.data(), str
.size());
137 OutputCharStream
&SgmlsEventHandler::os()
146 #endif /* not SgmlsEventHandler_INCLUDED */