Link with C++ linker
[oweals/cde.git] / cde / programs / nsgmls / SgmlsEventHandler.h
1 /*
2  * CDE - Common Desktop Environment
3  *
4  * Copyright (c) 1993-2012, The Open Group. All rights reserved.
5  *
6  * These libraries and programs are free software; you can
7  * redistribute them and/or modify them under the terms of the GNU
8  * Lesser General Public License as published by the Free Software
9  * Foundation; either version 2 of the License, or (at your option)
10  * any later version.
11  *
12  * These libraries and programs are distributed in the hope that
13  * they will be useful, but WITHOUT ANY WARRANTY; without even the
14  * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15  * PURPOSE. See the GNU Lesser General Public License for more
16  * details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with these librararies and programs; if not, write
20  * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
21  * Floor, Boston, MA 02110-1301 USA
22  */
23 /* $XConsortium: SgmlsEventHandler.h /main/1 1996/07/29 17:04:25 cde-hp $ */
24 // Copyright (c) 1994 James Clark
25 // See the file COPYING for copying permission.
26
27 #ifndef SgmlsEventHandler_INCLUDED
28 #define SgmlsEventHandler_INCLUDED 1
29
30 #include <stddef.h>
31 #include "Event.h"
32 #include "Boolean.h"
33 #include "StringC.h"
34 #include "OutputCharStream.h"
35 #include "StringSet.h"
36 #include "Location.h"
37 #include "Syntax.h"
38 #include "Sd.h"
39 #include "Ptr.h"
40 #include "LinkProcess.h"
41 #include "Message.h"
42 #include "ErrorCountEventHandler.h"
43
44 #ifdef SP_NAMESPACE
45 namespace SP_NAMESPACE {
46 #endif
47
48 class SgmlParser;
49 struct StorageObjectSpec;
50
51 class SgmlsSubdocState {
52 public:
53   SgmlsSubdocState();
54   SgmlsSubdocState(const SgmlParser *);
55   void init(const SgmlParser *);
56   void swap(SgmlsSubdocState &);
57 protected:
58   const SgmlParser *parser_;
59   StringSet definedEntities_;
60   StringSet definedNotations_;
61   Boolean haveLinkProcess_;
62   LinkProcess linkProcess_;
63 private:
64   SgmlsSubdocState(const SgmlsSubdocState &); // undefined
65   void operator=(const SgmlsSubdocState &);   // undefined
66 };
67
68 class SgmlsEventHandler : public ErrorCountEventHandler,
69   private SgmlsSubdocState, private Messenger {
70 public:
71   enum {
72     outputLine = 01,
73     outputEntity = 02,
74     outputId = 04,
75     outputIncluded = 010,
76     outputNotationSysid = 020
77     };
78       
79   SgmlsEventHandler(const SgmlParser *,
80                     OutputCharStream *,
81                     Messenger *,
82                     unsigned outputFlags);
83   ~SgmlsEventHandler();
84   void data(DataEvent *);
85   void startElement(StartElementEvent *);
86   void endElement(EndElementEvent *);
87   void pi(PiEvent *);
88   void sdataEntity(SdataEntityEvent *);
89   void externalDataEntity(ExternalDataEntityEvent *);
90   void subdocEntity(SubdocEntityEvent *);
91   void appinfo(AppinfoEvent *);
92   void uselink(UselinkEvent *);
93   void sgmlDecl(SgmlDeclEvent *);
94   void endProlog(EndPrologEvent *);
95   void message(MessageEvent *);
96   void entityDefaulted(EntityDefaultedEvent *event);
97 protected:
98   void dispatchMessage(const Message &);
99   void dispatchMessage(Message &);
100   void initMessage(Message &);
101 private:
102   SgmlsEventHandler(const SgmlsEventHandler &); // undefined
103   void operator=(const SgmlsEventHandler &);    // undefined
104
105   void attributes(const AttributeList &attributes, char code,
106                   const StringC *ownerName);
107   void startAttribute(const StringC &name, char code,
108                       const StringC *ownerName);
109   void defineEntity(const Entity *entity);
110   void defineExternalDataEntity(const ExternalDataEntity *entity);
111   void defineSubdocEntity(const SubdocEntity *entity);
112   void defineExternalTextEntity(const ExternalEntity *entity);
113   void defineInternalEntity(const InternalEntity *entity);
114   void defineNotation(const Notation *notation);
115   void externalId(const ExternalId &id, Boolean outputFile = 1);
116   Boolean markEntity(const Entity *);
117   Boolean markNotation(const Notation *);
118   void startData();
119   void flushData();
120
121   void outputLocation(const Location &loc);
122   void outputLocation1(const Location &loc);
123   void outputString(const StringC &str);
124   void outputString(const Char *, size_t);
125   static void escape(OutputCharStream &, Char);
126
127   OutputCharStream &os();
128
129   Messenger *messenger_;
130   Location currentLocation_;
131   OutputCharStream *os_;
132   Boolean haveData_;
133   ConstPtr<Sd> sd_;
134   ConstPtr<Syntax> syntax_;
135   const StorageObjectSpec *lastSos_;
136   unsigned long lastLineno_;
137   Location lastLoc_;
138   PackedBoolean outputLine_;
139   PackedBoolean outputIncluded_;
140   PackedBoolean outputEntity_;
141   PackedBoolean outputId_;
142   PackedBoolean outputNotationSysid_;
143 };
144
145 inline
146 void SgmlsEventHandler::outputString(const StringC &str)
147 {
148   outputString(str.data(), str.size());
149 }
150
151 inline
152 OutputCharStream &SgmlsEventHandler::os()
153 {
154   return *os_;
155 }
156
157 #ifdef SP_NAMESPACE
158 }
159 #endif
160
161 #endif /* not SgmlsEventHandler_INCLUDED */