3065 some functions in the tcp module can be static
[unleashed.git] / usr / src / cmd / man / src / util / nsgmls.src / nsgmls / SgmlsEventHandler.h
blobff45762bff271f242abf39d704add67cccef24fb
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
8 #include <stddef.h>
9 #include "Event.h"
10 #include "Boolean.h"
11 #include "StringC.h"
12 #include "OutputCharStream.h"
13 #include "StringSet.h"
14 #include "Location.h"
15 #include "Syntax.h"
16 #include "Sd.h"
17 #include "Ptr.h"
18 #include "LinkProcess.h"
19 #include "Message.h"
20 #include "ErrorCountEventHandler.h"
22 #ifdef SP_NAMESPACE
23 namespace SP_NAMESPACE {
24 #endif
26 class SgmlParser;
27 struct StorageObjectSpec;
29 class SgmlsSubdocState {
30 public:
31 SgmlsSubdocState();
32 SgmlsSubdocState(const SgmlParser *);
33 void init(const SgmlParser *);
34 void swap(SgmlsSubdocState &);
35 protected:
36 const SgmlParser *parser_;
37 StringSet definedEntities_;
38 StringSet definedNotations_;
39 Boolean haveLinkProcess_;
40 LinkProcess linkProcess_;
41 private:
42 SgmlsSubdocState(const SgmlsSubdocState &); // undefined
43 void operator=(const SgmlsSubdocState &); // undefined
46 class SgmlsEventHandler : public ErrorCountEventHandler,
47 private SgmlsSubdocState, private Messenger {
48 public:
49 enum {
50 outputLine = 01,
51 outputEntity = 02,
52 outputId = 04,
53 outputIncluded = 010,
54 outputNotationSysid = 020,
55 outputNonSgml = 040,
56 outputEmpty = 0100
59 SgmlsEventHandler(const SgmlParser *,
60 OutputCharStream *,
61 Messenger *,
62 unsigned outputFlags);
63 ~SgmlsEventHandler();
64 void data(DataEvent *);
65 void startElement(StartElementEvent *);
66 void endElement(EndElementEvent *);
67 void pi(PiEvent *);
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);
78 protected:
79 void dispatchMessage(const Message &);
80 void dispatchMessage(Message &tmp_message) {
81 dispatchMessage((const Message &)tmp_message);
83 void initMessage(Message &);
84 private:
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 *);
101 void startData();
102 void flushData();
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_;
115 Boolean haveData_;
116 ConstPtr<Sd> sd_;
117 ConstPtr<Syntax> syntax_;
118 const StorageObjectSpec *lastSos_;
119 unsigned long lastLineno_;
120 Location lastLoc_;
121 PackedBoolean outputLine_;
122 PackedBoolean outputIncluded_;
123 PackedBoolean outputEntity_;
124 PackedBoolean outputId_;
125 PackedBoolean outputNotationSysid_;
126 PackedBoolean outputNonSgml_;
127 PackedBoolean outputEmpty_;
130 inline
131 void SgmlsEventHandler::outputString(const StringC &str)
133 outputString(str.data(), str.size());
136 inline
137 OutputCharStream &SgmlsEventHandler::os()
139 return *os_;
142 #ifdef SP_NAMESPACE
144 #endif
146 #endif /* not SgmlsEventHandler_INCLUDED */