1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193
|
// Copyright (c) 1994 James Clark
// See the file COPYING for copying permission.
#ifndef RastEventHandler_INCLUDED
#define RastEventHandler_INCLUDED 1
#ifdef __GNUG__
#pragma interface
#endif
#include "Event.h"
#include "Vector.h"
#include "Vector.h"
#include "Boolean.h"
#include "Vector.h"
#include "StringC.h"
#include "types.h"
#include "OutputCharStream.h"
#include "LinkProcess.h"
#include "Message.h"
#include "Link.h"
#include "IQueue.h"
#include "ErrorCountEventHandler.h"
#include <limits.h>
#include <stddef.h>
#ifdef SP_NAMESPACE
namespace SP_NAMESPACE {
#endif
class AttributeList;
class ExternalDataEntity;
class SubdocEntity;
class ExternalId;
class InternalEntity;
class SgmlParser;
class RastPrintable {
public:
RastPrintable();
int operator()(Char c) const;
private:
char v_[UCHAR_MAX + 1];
};
class RastEventHandler;
class RastLinkProcess : public LinkProcess {
public:
RastLinkProcess();
void setHandler(RastEventHandler *);
Boolean selectLinkRule(const Vector<const AttributeList *> &linkAttributes,
const Location &location,
size_t &selected);
void swap(RastLinkProcess &);
private:
Boolean selectLinkRulePi(const StringC &str,
const Location &loc,
const Vector<const AttributeList *> &linkAttributes,
size_t &selected);
RastLinkProcess(const RastLinkProcess &); // undefined
void operator=(RastLinkProcess &); // undefined
RastEventHandler *rast_;
};
struct LinkRulePi : public Link {
inline virtual ~LinkRulePi() {}
StringC pi;
Location loc;
};
class RastSubdocState {
public:
RastSubdocState();
RastSubdocState(SgmlParser *, RastEventHandler *);
void init(SgmlParser *, RastEventHandler *);
void swap(RastSubdocState &);
protected:
SgmlParser *parser_;
Boolean hadActiveLpdOrDtd_;
Location activeLpdOrDtdLocation_;
Vector<StringC> activeLinkTypes_;
Boolean hadDocumentElement_;
RastLinkProcess linkProcess_;
Boolean haveLinkProcess_;
Owner<EndPrologEvent> endPrologEvent_;
Vector<PackedBoolean> parseSubdocQueue_;
IQueue<LinkRulePi> linkRuleQueue_;
enum AttributeType {
dtdAttribute,
linkAttribute,
resultAttribute,
simpleAttribute
};
enum { nAttributeType = simpleAttribute + 1 };
Vector<Vector<size_t> > attributeSortOrder_[nAttributeType];
private:
RastSubdocState(const RastSubdocState &); // undefined
void operator=(const RastSubdocState &); // undefined
friend class RastLinkProcess;
};
class RastEventHandler : public ErrorCountEventHandler,
private RastSubdocState,
protected Messenger {
public:
RastEventHandler(SgmlParser *, Messenger *);
void data(DataEvent *);
void startElement(StartElementEvent *);
void endElement(EndElementEvent *);
void pi(PiEvent *);
void sdataEntity(SdataEntityEvent *);
void externalDataEntity(ExternalDataEntityEvent *);
void subdocEntity(SubdocEntityEvent *);
void nonSgmlChar(NonSgmlCharEvent *);
void sgmlDecl(SgmlDeclEvent *);
void endProlog(EndPrologEvent *);
void uselink(UselinkEvent *);
virtual void truncateOutput();
void end();
void setOutputStream(OutputCharStream *os);
static const char *messageText(int);
static const char messageSource[];
protected:
void initMessage(Message &);
void dispatchMessage(const Message &);
private:
RastEventHandler(const RastEventHandler &); // undefined
void operator=(const RastEventHandler &); // undefined
enum LineType { dataLine = '|', markupLine = '!' };
void lines(LineType, const Char *p, size_t length);
enum { maxLineLength = 60 };
enum { RS = '\n', RE = '\r', TAB = '\t' };
#if 0
static const RastPrintable printable;
#else
static RastPrintable printable;
#endif
int lineLength_;
OutputCharStream *os_;
StringC rastParseSubdocYesString_;
StringC rastParseSubdocNoString_;
StringC rastActiveLpdString_;
StringC rastLinkRuleString_;
unsigned piErrorCount_;
Messenger *mgr_;
int lexCmp(const StringC &s1, const StringC &s2);
void flushLine(LineType);
void attributeInfo(const AttributeList &, AttributeType);
void externalEntityInfo(const ExternalDataEntity *, AttributeType);
void subdocEntityInfo(const SubdocEntity *,
const Ptr<InputSourceOrigin> &entityOrigin,
Boolean referenced);
void externalIdInfo(const ExternalId &);
void internalEntityInfo(const InternalEntity *);
void queueParseSubdoc(Boolean);
Boolean parseNextSubdoc();
Boolean interpretRastPi(const Char *data, size_t dataLength,
const Location &);
void activeLinks();
void simpleLinkInfo();
void impliedSourceLinkRules();
OutputCharStream &os();
friend class RastLinkProcess;
};
inline
int RastPrintable::operator()(Char c) const
{
return c <= UCHAR_MAX ? v_[c] : 0;
}
inline
void RastEventHandler::setOutputStream(OutputCharStream *os)
{
os_ = os;
}
inline
OutputCharStream &RastEventHandler::os()
{
return *os_;
}
#ifdef SP_NAMESPACE
}
#endif
#endif /* not RastEventHandler_INCLUDED */
|