2 * CDE - Common Desktop Environment
4 * Copyright (c) 1993-2012, The Open Group. All rights reserved.
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)
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
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
23 /* $XConsortium: GenericEventHandler.h /main/1 1996/07/29 16:52:21 cde-hp $ */
24 // Copyright (c) 1995, 1996 James Clark
25 // See the file COPYING for copying permission.
27 #ifndef GenericEventHandler_INCLUDED
28 #define GenericEventHandler_INCLUDED 1
34 // Must include Boolean.h before SGMLApplication.h.
37 #include "SGMLApplication.h"
39 #include "MessageReporter.h"
40 #include "ErrorCountEventHandler.h"
43 namespace SP_NAMESPACE {
46 class SP_API GenericEventHandler : public ErrorCountEventHandler {
48 GenericEventHandler(SGMLApplication &, bool generalEntities);
49 ~GenericEventHandler();
50 void message(MessageEvent *);
51 void appinfo(AppinfoEvent *);
52 void startDtd(StartDtdEvent *);
53 void endDtd(EndDtdEvent *);
54 void endProlog(EndPrologEvent *);
55 void entityDefaulted(EntityDefaultedEvent *);
56 void startElement(StartElementEvent *);
57 void endElement(EndElementEvent *);
58 void data(DataEvent *);
60 void sdataEntity(SdataEntityEvent *);
61 void externalDataEntity(ExternalDataEntityEvent *);
62 void subdocEntity(SubdocEntityEvent *);
63 void commentDecl(CommentDeclEvent *);
64 void ignoredChars(IgnoredCharsEvent *);
65 void markedSectionStart(MarkedSectionStartEvent *);
66 void markedSectionEnd(MarkedSectionEndEvent *);
67 void *allocate(size_t);
76 static void setString(SGMLApplication::CharString &, const StringC &);
77 static void clearString(SGMLApplication::CharString &);
78 virtual void reportMessage(const Message &msg, StringC &) = 0;
80 GenericEventHandler(const GenericEventHandler &); // undefined
81 void operator=(const GenericEventHandler &); // undefined
82 void setLocation(SGMLApplication::Position &, const Location &);
83 void setLocation1(SGMLApplication::Position &, const Location &);
84 void setAttributes(const SGMLApplication::Attribute *&attributes,
85 const AttributeList &attributeList);
86 void setExternalId(SGMLApplication::ExternalId &to,
87 const ExternalId &from);
88 void setEntity(SGMLApplication::Entity &to, const Entity &from);
89 void setNotation(SGMLApplication::Notation &, const Notation ¬ation);
90 static void clearNotation(SGMLApplication::Notation &);
91 static void clearExternalId(SGMLApplication::ExternalId &);
92 ConstPtr<Origin> lastOrigin_;
93 SGMLApplication::OpenEntityPtr openEntityPtr_;
94 size_t firstBlockUsed_;
95 size_t firstBlockSpare_;
98 bool generalEntities_;
99 SGMLApplication *app_;
102 class SP_API MsgGenericEventHandler : public GenericEventHandler {
104 MsgGenericEventHandler(SGMLApplication &,
105 bool generalEntities,
106 MessageReporter &reporter,
107 const bool *messagesInhibitedPtr);
108 void reportMessage(const Message &msg, StringC &);
110 MsgGenericEventHandler(const MsgGenericEventHandler &); // undefined
111 void operator=(const MsgGenericEventHandler &); // undefined
112 struct WrapReporter {
113 WrapReporter(MessageReporter *r) : reporter(r), origStream(0) {
114 origStream = reporter->releaseMessageStream();
115 reporter->setMessageStream(&strStream);
119 reporter->releaseMessageStream();
120 reporter->setMessageStream(origStream);
123 MessageReporter *reporter;
124 OutputCharStream *origStream;
125 StrOutputCharStream strStream;
127 const bool *messagesInhibitedPtr_;
128 MessageReporter *reporter_;
132 GenericEventHandler::setString(SGMLApplication::CharString &to,
135 to.ptr = from.data();
136 to.len = from.size();
140 void GenericEventHandler::clearString(SGMLApplication::CharString &to)
149 #endif /* not GenericEventHandler_INCLUDED */