1 // Copyright (c) 1994 James Clark
2 // See the file COPYING for copying permission.
3 #pragma ident "%Z%%M% %I% %E% SMI"
4
5 #ifndef Event_INCLUDED
6 #define Event_INCLUDED 1
7 #ifdef __GNUG__
8 #pragma interface
9 #endif
10
11 #include "Link.h"
12 #include "Allocator.h"
13 #include "Location.h"
14 #include "Vector.h"
15 #include "Owner.h"
16 #include "Boolean.h"
17 #include "types.h"
18 #include "Ptr.h"
19 #include "StringC.h"
20 #include "Notation.h"
21 #include "Sd.h"
22 #include "Syntax.h"
23 #include "Dtd.h"
24 #include "ElementType.h"
25 #include "Text.h"
26 #include "Lpd.h"
27 #include "Message.h"
28 #include "Markup.h"
29 #include "ShortReferenceMap.h"
30
31 #ifdef SP_NAMESPACE
32 namespace SP_NAMESPACE {
33 #endif
34
35 class EventHandler;
36
37 class SP_API Event : public Link {
38 public:
39 enum Type {
40 message,
41 characterData,
42 startElement,
43 endElement,
44 pi,
45 sdataEntity,
46 externalDataEntity,
47 subdocEntity,
48 nonSgmlChar,
49 appinfo,
50 startDtd,
51 endDtd,
52 startLpd,
53 endLpd,
54 endProlog,
55 sgmlDecl,
56 uselink,
57 usemap,
58 commentDecl,
59 sSep,
60 ignoredRs,
61 ignoredRe,
62 reOrigin,
63 ignoredChars,
64 markedSectionStart,
65 markedSectionEnd,
66 entityStart,
67 entityEnd,
68 notationDecl,
69 entityDecl,
70 elementDecl,
71 attlistDecl, // not #NOTATION and not in LPD
72 attlistNotationDecl,
73 linkAttlistDecl,
74 linkDecl,
75 idLinkDecl,
76 shortrefDecl,
77 ignoredMarkup,
78 entityDefaulted,
79 sgmlDeclEntity
80 };
81 Event(Type);
82 virtual void handle(EventHandler &) = 0;
83 virtual void copyData();
new(size_t sz,Allocator & alloc)84 void *operator new(size_t sz, Allocator &alloc) { return alloc.alloc(sz); }
new(size_t sz)85 void *operator new(size_t sz) { return Allocator::allocSimple(sz); }
delete(void * p)86 void operator delete(void *p) { Allocator::free(p); }
87 Type type() const;
88 private:
89 Event(const Event &); // undefined
90 void operator=(const Event &); // undefined
91 Type type_;
92 };
93
94 class LocatedEvent : public Event {
95 public:
96 LocatedEvent(Type type, const Location &);
97 const Location &location() const;
98 private:
99 LocatedEvent(const LocatedEvent &); // undefined
100 void operator=(const LocatedEvent &); // undefined
101 Location location_;
102 };
103
104 class MarkupEvent : public LocatedEvent {
105 public:
106 MarkupEvent(Type type);
107 MarkupEvent(Type type, const Location &, Markup *);
108 const Markup &markup() const;
109 private:
110 MarkupEvent(const MarkupEvent &); // undefined
111 void operator=(const MarkupEvent &); // undefined
112 Markup markup_;
113 };
114
115 class SP_API MessageEvent : public Event {
116 public:
117 MessageEvent(Message &);
118 MessageEvent(const Message &);
119 const Message &message() const;
120 void handle(EventHandler &);
121 private:
122 MessageEvent(const MessageEvent &); // undefined
123 void operator=(const MessageEvent &); // undefined
124 Message message_;
125 };
126
127 class AttributeList;
128
129 class StartElementEvent : public LocatedEvent {
130 public:
131 StartElementEvent(const ElementType *,
132 const ConstPtr<Dtd> &,
133 AttributeList *,
134 const Location &,
135 Markup *);
136 ~StartElementEvent();
137 void handle(EventHandler &);
138 Boolean mustOmitEnd() const;
139 void setIncluded();
140 Boolean included() const;
141 const StringC &name() const;
142 const ElementType *elementType() const;
143 const Markup *markupPtr() const;
144 const AttributeList &attributes() const;
145 void copyData();
146 private:
147 StartElementEvent(const StartElementEvent &); // undefined
148 void operator=(const StartElementEvent &); // undefined
149 const ElementType *elementType_;
150 ConstPtr<Dtd> dtd_;
151 PackedBoolean included_;
152 PackedBoolean copied_; // has copyData() been called
153 Markup *markup_;
154 AttributeList *attributes_;
155 };
156
157 class EndElementEvent : public LocatedEvent {
158 public:
159 EndElementEvent(const ElementType *,
160 const ConstPtr<Dtd> &,
161 const Location &,
162 Markup *);
163 ~EndElementEvent();
164 void handle(EventHandler &);
165 void setIncluded();
166 Boolean included() const;
167 const StringC &name() const;
168 const ElementType *elementType() const;
169 const Markup *markupPtr() const;
170 void copyData();
171 private:
172 EndElementEvent(const EndElementEvent &); // undefined
173 void operator=(const EndElementEvent &); // undefined
174 const ElementType *elementType_;
175 ConstPtr<Dtd> dtd_;
176 PackedBoolean included_;
177 PackedBoolean copied_; // has copyData() been called
178 Markup *markup_;
179 };
180
181 class DataEvent : public LocatedEvent {
182 public:
183 DataEvent(Type, const Char *, size_t, const Location &);
184 void handle(EventHandler &);
185 const Char *data() const;
186 size_t dataLength() const;
187 virtual Boolean isRe(unsigned long &serial) const;
188 virtual const Entity *entity() const;
189 protected:
190 const Char *p_;
191 size_t length_;
192 private:
193 DataEvent(const DataEvent &); // undefined
194 void operator=(const DataEvent &); // undefined
195 };
196
197 class ImmediateDataEvent : public DataEvent {
198 public:
199 ImmediateDataEvent(Type type, const Char *, size_t, const Location &,
200 Boolean copy);
201 ~ImmediateDataEvent();
202 void copyData();
203 private:
204 ImmediateDataEvent(const ImmediateDataEvent &); // undefined
205 void operator=(const ImmediateDataEvent &); // undefined
206 Char *alloc_;
207 };
208
209 class InternalDataEntity;
210
211 class DataEntityEvent : public DataEvent {
212 public:
213 DataEntityEvent(Type type, const InternalEntity *,
214 const ConstPtr<Origin> &);
215 const Entity *entity() const;
216 private:
217 DataEntityEvent(const DataEntityEvent &); // undefined
218 void operator=(const DataEntityEvent &); // undefined
219 };
220
221 class InternalCdataEntity;
222
223 class CdataEntityEvent : public DataEntityEvent {
224 public:
225 CdataEntityEvent(const InternalEntity *,
226 const ConstPtr<Origin> &);
227 private:
228 CdataEntityEvent(const CdataEntityEvent &); // undefined
229 void operator=(const CdataEntityEvent &); // undefined
230 };
231
232 class InternalSdataEntity;
233
234 class SdataEntityEvent : public DataEntityEvent {
235 public:
236 SdataEntityEvent(const InternalEntity *,
237 const ConstPtr<Origin> &);
238 void handle(EventHandler &);
239 private:
240 SdataEntityEvent(const SdataEntityEvent &); // undefined
241 void operator=(const SdataEntityEvent &); // undefined
242 };
243
244 class PiEntity;
245
246 class PiEvent : public LocatedEvent {
247 public:
248 PiEvent(const Char *, size_t, const Location &);
249 const Char *data() const;
250 size_t dataLength() const;
251 virtual const Entity *entity() const;
252 void handle(EventHandler &);
253 private:
254 PiEvent(const PiEvent &); // undefined
255 void operator=(const PiEvent &); // undefined
256 const Char *data_;
257 size_t dataLength_;
258 };
259
260 class ImmediatePiEvent : public PiEvent {
261 public:
262 ImmediatePiEvent(StringC &, const Location &);
263 private:
264 ImmediatePiEvent(const ImmediatePiEvent &); // undefined
265 void operator=(const ImmediatePiEvent &); // undefined
266 StringC string_;
267 };
268
269 class PiEntityEvent : public PiEvent {
270 public:
271 PiEntityEvent(const PiEntity *entity,
272 const ConstPtr<Origin> &origin);
273 const Entity *entity() const;
274 private:
275 PiEntityEvent(const PiEntityEvent &); // undefined
276 void operator=(const PiEntityEvent &); // undefined
277 };
278
279 class ExternalNonTextEntity;
280 class ExternalDataEntity;
281 class SubdocEntity;
282
283 class ExternalEntityEvent : public Event {
284 public:
285 ExternalEntityEvent(Type type,
286 const ConstPtr<EntityOrigin> &);
287 const ConstPtr<EntityOrigin> &entityOrigin() const;
288 const Location &location() const;
289 private:
290 ExternalEntityEvent(const ExternalEntityEvent &); // undefined
291 void operator=(const ExternalEntityEvent &); // undefined
292 ConstPtr<EntityOrigin> origin_;
293 };
294
295 class ExternalDataEntityEvent : public ExternalEntityEvent {
296 public:
297 ExternalDataEntityEvent(const ExternalDataEntity *,
298 const ConstPtr<EntityOrigin> &);
299 void handle(EventHandler &);
300 const ExternalDataEntity *entity() const;
301 private:
302 ExternalDataEntityEvent(const ExternalDataEntityEvent &); // undefined
303 void operator=(const ExternalDataEntityEvent &); // undefined
304 const ExternalDataEntity *dataEntity_;
305 };
306
307 class SubdocEntityEvent : public ExternalEntityEvent {
308 public:
309 SubdocEntityEvent(const SubdocEntity *,
310 const ConstPtr<EntityOrigin> &);
311 void handle(EventHandler &);
312 const SubdocEntity *entity() const;
313 private:
314 SubdocEntityEvent(const SubdocEntityEvent &); // undefined
315 void operator=(const SubdocEntityEvent &); // undefined
316 const SubdocEntity *subdocEntity_;
317 };
318
319 class NonSgmlCharEvent : public LocatedEvent {
320 public:
321 NonSgmlCharEvent(Char c, const Location &);
322 Char character() const;
323 void handle(EventHandler &);
324 private:
325 NonSgmlCharEvent(const NonSgmlCharEvent &); // undefined
326 void operator=(const NonSgmlCharEvent &); // undefined
327 Char c_;
328 };
329
330 class AppinfoEvent : public LocatedEvent {
331 public:
332 AppinfoEvent(const Location &);
333 AppinfoEvent(const Text &, const Location &);
334 void handle(EventHandler &);
335 Boolean literal(const StringC *&) const;
336 private:
337 AppinfoEvent(const AppinfoEvent &); // undefined
338 void operator=(const AppinfoEvent &); // undefined
339 Boolean appinfoNone_;
340 Text appinfo_;
341 };
342
343 class UselinkEvent : public MarkupEvent {
344 public:
345 UselinkEvent(const ConstPtr<Lpd> &,
346 const LinkSet *,
347 Boolean restore,
348 const Location &,
349 Markup *);
350 void handle(EventHandler &);
351 const ConstPtr<Lpd> &lpd() const;
352 const LinkSet *linkSet() const;
353 Boolean restore() const;
354 private:
355 UselinkEvent(const UselinkEvent &); // undefined
356 void operator=(const UselinkEvent &); // undefined
357 ConstPtr<Lpd> lpd_;
358 const LinkSet *linkSet_;
359 Boolean restore_;
360 };
361
362 class UsemapEvent : public MarkupEvent {
363 public:
364 UsemapEvent(const ShortReferenceMap *,
365 Vector<const ElementType *> &,
366 const ConstPtr<Dtd> &,
367 const Location &,
368 Markup *);
369 void handle(EventHandler &);
370 const ShortReferenceMap *map() const;
371 const Vector<const ElementType *> &elements() const;
372 private:
373 UsemapEvent(const UsemapEvent &); // undefined
374 void operator=(const UsemapEvent &); // undefined
375 ConstPtr<Dtd> dtd_;
376 Vector<const ElementType *> elements_;
377 const ShortReferenceMap *map_;
378 };
379
380 class StartSubsetEvent : public MarkupEvent {
381 public:
382 StartSubsetEvent(Type,
383 const StringC &,
384 const ConstPtr<Entity> &entity,
385 Boolean hasInternalSubset,
386 const Location &,
387 Markup *);
388 const StringC &name() const;
389 const ConstPtr<Entity> &entity() const;
390 Boolean hasInternalSubset() const;
391 private:
392 StartSubsetEvent(const StartSubsetEvent &); // undefined
393 void operator=(const StartSubsetEvent &); // undefined
394 StringC name_;
395 ConstPtr<Entity> entity_;
396 Boolean hasInternalSubset_;
397 };
398
399 class StartDtdEvent : public StartSubsetEvent {
400 public:
401 StartDtdEvent(const StringC &,
402 const ConstPtr<Entity> &entity,
403 Boolean hasInternalSubset,
404 const Location &,
405 Markup *);
406 void handle(EventHandler &);
407 private:
408 StartDtdEvent(const StartDtdEvent &); // undefined
409 void operator=(const StartDtdEvent &); // undefined
410 };
411
412 class StartLpdEvent : public StartSubsetEvent {
413 public:
414 StartLpdEvent(Boolean active,
415 const StringC &,
416 const ConstPtr<Entity> &entity,
417 Boolean hasInternalSubset,
418 const Location &,
419 Markup *);
420 void handle(EventHandler &);
421 Boolean active() const;
422 private:
423 StartLpdEvent(const StartLpdEvent &); // undefined
424 void operator=(const StartLpdEvent &); // undefined
425 Boolean active_;
426 };
427
428 class EndDtdEvent : public MarkupEvent {
429 public:
430 EndDtdEvent(const ConstPtr<Dtd> &, const Location &,
431 Markup *);
432 void handle(EventHandler &);
433 const Dtd &dtd() const;
434 const ConstPtr<Dtd> &dtdPointer() const;
435 private:
436 EndDtdEvent(const EndDtdEvent &); // undefined
437 void operator=(const EndDtdEvent &); // undefined
438 ConstPtr<Dtd> dtd_;
439 };
440
441 class EndLpdEvent : public MarkupEvent {
442 public:
443 EndLpdEvent(const ConstPtr<Lpd> &, const Location &,
444 Markup *);
445 void handle(EventHandler &);
446 const Lpd &lpd() const;
447 const ConstPtr<Lpd> &lpdPointer() const;
448 private:
449 EndLpdEvent(const EndLpdEvent &); // undefined
450 void operator=(const EndLpdEvent &); // undefined
451 ConstPtr<Lpd> lpd_;
452 };
453
454 class EndPrologEvent : public LocatedEvent {
455 public:
456 EndPrologEvent(const ConstPtr<Dtd> &dtd,
457 const ConstPtr<ComplexLpd> &lpd,
458 Vector<StringC> &simpleLinkNames,
459 Vector<AttributeList> &simpleLinkAttributes,
460 const Location &);
461 EndPrologEvent(const ConstPtr<Dtd> &dtd,
462 const Location &);
463 void handle(EventHandler &);
464 const Dtd &dtd() const;
465 const ConstPtr<Dtd> &dtdPointer() const;
466 const ConstPtr<ComplexLpd> &lpdPointer() const;
467 const Vector<StringC> &simpleLinkNames() const;
468 const Vector<AttributeList> &simpleLinkAttributes() const;
469 private:
470 EndPrologEvent(const EndPrologEvent &); // undefined
471 void operator=(const EndPrologEvent &); // undefined
472 ConstPtr<Dtd> dtd_;
473 ConstPtr<ComplexLpd> lpd_;
474 Vector<StringC> simpleLinkNames_;
475 Vector<AttributeList> simpleLinkAttributes_;
476 };
477
478 class SgmlDeclEvent : public MarkupEvent {
479 public:
480 // for an implied SGML declaration
481 SgmlDeclEvent(const ConstPtr<Sd> &,
482 const ConstPtr<Syntax> &syntax);
483 // for an explicit SGML declaration
484 SgmlDeclEvent(const ConstPtr<Sd> &,
485 const ConstPtr<Syntax> &syntax,
486 const ConstPtr<Syntax> &instanceSyntax,
487 const ConstPtr<Sd> &refSd,
488 const ConstPtr<Syntax> &refSyntax,
489 Index nextIndex,
490 const StringC &implySystemId,
491 const Location &,
492 Markup *);
493 void handle(EventHandler &);
494 const Sd &sd() const;
495 const ConstPtr<Sd> &sdPointer() const;
496 const Syntax &prologSyntax() const;
497 const ConstPtr<Syntax> &prologSyntaxPointer() const;
498 const Syntax &instanceSyntax() const;
499 const ConstPtr<Syntax> &instanceSyntaxPointer() const;
500 const ConstPtr<Sd> &refSdPointer() const;
501 const ConstPtr<Syntax> &refSyntaxPointer() const;
502 const StringC &implySystemId() const;
503 private:
504 SgmlDeclEvent(const SgmlDeclEvent &); // undefined
505 void operator=(const SgmlDeclEvent &); // undefined
506 ConstPtr<Sd> sd_;
507 ConstPtr<Syntax> prologSyntax_;
508 ConstPtr<Syntax> instanceSyntax_;
509 ConstPtr<Sd> refSd_;
510 ConstPtr<Syntax> refSyntax_;
511 Index nextIndex_;
512 StringC implySystemId_;
513 };
514
515 class CommentDeclEvent : public MarkupEvent {
516 public:
517 CommentDeclEvent(const Location &, Markup *);
518 void handle(EventHandler &);
519 private:
520 CommentDeclEvent(const CommentDeclEvent &); // undefined
521 void operator=(const CommentDeclEvent &); // undefined
522 };
523
524 class SSepEvent : public ImmediateDataEvent {
525 public:
526 SSepEvent(const Char *, size_t, const Location &, Boolean copy);
527 void handle(EventHandler &);
528 private:
529 SSepEvent(const SSepEvent &); // undefined
530 void operator=(const SSepEvent &); // undefined
531 };
532
533 class IgnoredRsEvent : public LocatedEvent {
534 public:
535 IgnoredRsEvent(Char c, const Location &);
536 void handle(EventHandler &);
537 Char rs() const;
538 private:
539 IgnoredRsEvent(const IgnoredRsEvent &); // undefined
540 void operator=(const IgnoredRsEvent &); // undefined
541 Char c_;
542 };
543
544 class IgnoredReEvent : public LocatedEvent {
545 public:
546 IgnoredReEvent(Char c, const Location &, unsigned long serial);
547 void handle(EventHandler &);
548 Char re() const;
549 unsigned long serial() const;
550 private:
551 IgnoredReEvent(const IgnoredReEvent &); // undefined
552 void operator=(const IgnoredReEvent &); // undefined
553 unsigned long serial_;
554 Char c_;
555 };
556
557 class ReEvent : public ImmediateDataEvent {
558 public:
559 ReEvent(const Char *, const Location &, unsigned long serial);
560 Boolean isRe(unsigned long &serial) const;
561 private:
562 ReEvent(const ReEvent &); // undefined
563 void operator=(const ReEvent &); // undefined
564 unsigned long serial_;
565 };
566
567 class ReOriginEvent : public LocatedEvent {
568 public:
569 ReOriginEvent(Char c, const Location &, unsigned long serial);
570 void handle(EventHandler &);
571 Char re() const;
572 unsigned long serial() const;
573 private:
574 ReOriginEvent(const ReOriginEvent &); // undefined
575 void operator=(const ReOriginEvent &); // undefined
576 unsigned long serial_;
577 Char c_;
578 };
579
580 class IgnoredCharsEvent : public ImmediateDataEvent {
581 public:
582 IgnoredCharsEvent(const Char *, size_t, const Location &, Boolean copy);
583 void handle(EventHandler &);
584 private:
585 IgnoredCharsEvent(const IgnoredCharsEvent &); // undefined
586 void operator=(const IgnoredCharsEvent &); // undefined
587 };
588
589 class MarkedSectionEvent : public MarkupEvent {
590 public:
591 enum Status { include, rcdata, cdata, ignore }; // in priority order
592 MarkedSectionEvent(Type, Status, const Location &, Markup *);
593 Status status() const;
594 private:
595 MarkedSectionEvent(const MarkedSectionEvent &); // undefined
596 void operator=(const MarkedSectionEvent &); // undefined
597 Status status_;
598 };
599
600 class MarkedSectionStartEvent : public MarkedSectionEvent {
601 public:
602 MarkedSectionStartEvent(Status, const Location &, Markup *);
603 void handle(EventHandler &);
604 private:
605 MarkedSectionStartEvent(const MarkedSectionStartEvent &); // undefined
606 void operator=(const MarkedSectionStartEvent &); // undefined
607 };
608
609 class MarkedSectionEndEvent : public MarkedSectionEvent {
610 public:
611 MarkedSectionEndEvent(Status, const Location &, Markup *);
612 void handle(EventHandler &);
613 private:
614 MarkedSectionEndEvent(const MarkedSectionEndEvent &); // undefined
615 void operator=(const MarkedSectionEndEvent &); // undefined
616 };
617
618 class EntityStartEvent : public Event {
619 public:
620 EntityStartEvent(const ConstPtr<EntityOrigin> &origin);
621 void handle(EventHandler &);
622 const Entity *entity() const;
623 const ConstPtr<EntityOrigin> &entityOrigin() const;
624 private:
625 EntityStartEvent(const EntityStartEvent &); // undefined
626 void operator=(const EntityStartEvent &); // undefined
627
628 ConstPtr<EntityOrigin> origin_;
629 };
630
631 class EntityEndEvent : public LocatedEvent {
632 public:
633 EntityEndEvent(const Location &);
634 void handle(EventHandler &);
635 private:
636 EntityEndEvent(const EntityEndEvent &); // undefined
637 void operator=(const EntityEndEvent &); // undefined
638 };
639
640 class EntityDeclEvent : public MarkupEvent {
641 public:
642 EntityDeclEvent(const ConstPtr<Entity> &,
643 Boolean ignored,
644 const Location &,
645 Markup *);
646 void handle(EventHandler &);
647 const Entity &entity() const;
648 const ConstPtr<Entity> &entityPointer() const;
649 Boolean ignored() const;
650 // The name of the entity will be empty if this is the default entity.
651 private:
652 Boolean ignored_;
653 // This will actually point to an external entity.
654 ConstPtr<Entity> entity_;
655 };
656
657 class NotationDeclEvent : public MarkupEvent {
658 public:
659 NotationDeclEvent(const ConstPtr<Notation> &,
660 const Location &,
661 Markup *);
662 void handle(EventHandler &);
663 const Notation ¬ation() const;
664 const ConstPtr<Notation> ¬ationPointer() const;
665 private:
666 NotationDeclEvent(const NotationDeclEvent &); // undefined
667 void operator=(const NotationDeclEvent &); // undefined
668 ConstPtr<Notation> notation_;
669 };
670
671 class ElementDeclEvent : public MarkupEvent {
672 public:
673 ElementDeclEvent(Vector<const ElementType *> &elements,
674 const ConstPtr<Dtd> &,
675 const Location &,
676 Markup *);
677 void handle(EventHandler &);
678 const Vector<const ElementType *> &elements() const;
679 private:
680 ElementDeclEvent(const ElementDeclEvent &); // undefined
681 void operator=(const ElementDeclEvent &); // undefined
682 Vector<const ElementType *> elements_;
683 ConstPtr<Dtd> dtd_;
684 };
685
686 class AttlistDeclEvent : public MarkupEvent {
687 public:
688 AttlistDeclEvent(Vector<const ElementType *> &elements,
689 const ConstPtr<Dtd> &,
690 const Location &,
691 Markup *);
692 void handle(EventHandler &);
693 const Vector<const ElementType *> &elements() const;
694 private:
695 AttlistDeclEvent(const AttlistDeclEvent &); // undefined
696 void operator=(const AttlistDeclEvent &); // undefined
697 Vector<const ElementType *> elements_;
698 ConstPtr<Dtd> dtd_;
699 };
700
701 class AttlistNotationDeclEvent : public MarkupEvent {
702 public:
703 AttlistNotationDeclEvent(Vector<ConstPtr<Notation> > ¬ations,
704 const Location &,
705 Markup *);
706 void handle(EventHandler &);
707 const Vector<ConstPtr<Notation> > ¬ations() const;
708 private:
709 AttlistNotationDeclEvent(const AttlistNotationDeclEvent &); // undefined
710 void operator=(const AttlistDeclEvent &); // undefined
711 Vector<ConstPtr<Notation> > notations_;
712 };
713
714 class LinkAttlistDeclEvent : public MarkupEvent {
715 public:
716 LinkAttlistDeclEvent(Vector<const ElementType *> &elements,
717 const ConstPtr<Lpd> &,
718 const Location &,
719 Markup *);
720 void handle(EventHandler &);
721 const Vector<const ElementType *> &elements() const;
722 const Lpd &lpd() const;
723 private:
724 LinkAttlistDeclEvent(const LinkAttlistDeclEvent &); // undefined
725 void operator=(const LinkAttlistDeclEvent &); // undefined
726 Vector<const ElementType *> elements_;
727 ConstPtr<Lpd> lpd_;
728 };
729
730 class LinkDeclEvent : public MarkupEvent {
731 public:
732 LinkDeclEvent(const LinkSet *linkSet,
733 const ConstPtr<ComplexLpd> &,
734 const Location &,
735 Markup *);
736 void handle(EventHandler &);
737 const LinkSet *linkSet() const;
738 const ComplexLpd &lpd() const;
739 private:
740 LinkDeclEvent(const LinkDeclEvent &); // undefined
741 void operator=(const LinkDeclEvent &); // undefined
742 const LinkSet *linkSet_;
743 ConstPtr<ComplexLpd> lpd_;
744 };
745
746 class IdLinkDeclEvent : public MarkupEvent {
747 public:
748 IdLinkDeclEvent(const ConstPtr<ComplexLpd> &,
749 const Location &,
750 Markup *);
751 void handle(EventHandler &);
752 const ComplexLpd &lpd() const;
753 private:
754 IdLinkDeclEvent(const IdLinkDeclEvent &); // undefined
755 void operator=(const IdLinkDeclEvent &); // undefined
756 ConstPtr<ComplexLpd> lpd_;
757 };
758
759 class ShortrefDeclEvent : public MarkupEvent {
760 public:
761 ShortrefDeclEvent(const ShortReferenceMap *,
762 const ConstPtr<Dtd> &,
763 const Location &,
764 Markup *);
765 void handle(EventHandler &);
766 const ShortReferenceMap *map() const;
767 private:
768 ShortrefDeclEvent(const ShortrefDeclEvent &); // undefined
769 void operator=(const ShortrefDeclEvent &); // undefined
770 const ShortReferenceMap *map_;
771 ConstPtr<Dtd> dtd_;
772 };
773
774 class IgnoredMarkupEvent : public MarkupEvent {
775 public:
776 IgnoredMarkupEvent(const Location &, Markup *);
777 void handle(EventHandler &);
778 private:
779 IgnoredMarkupEvent(const IgnoredMarkupEvent &); // undefined
780 void operator=(const IgnoredMarkupEvent &); // undefined
781 };
782
783 // This is for an undeclared entity whose first occurrence
784 // is in the instance, when there is a default entity:
785 // ie it extends the namespace of general entities after
786 // the end of the prolog.
787
788 class EntityDefaultedEvent : public LocatedEvent {
789 public:
790 EntityDefaultedEvent(const ConstPtr<Entity> &,
791 const Location &);
792 void handle(EventHandler &);
793 const Entity &entity() const;
794 const ConstPtr<Entity> &entityPointer() const;
795 private:
796 EntityDefaultedEvent(const EntityDefaultedEvent &); // undefined
797 void operator=(const EntityDefaultedEvent &); // undefined
798 ConstPtr<Entity> entity_;
799 };
800
801 class SgmlDeclEntityEvent : public LocatedEvent {
802 public:
803 SgmlDeclEntityEvent(const PublicId &publicId,
804 PublicId::TextClass entityType,
805 const StringC &effectiveSystemId,
806 const Location &);
807 void handle(EventHandler &);
808 const PublicId &publicId() const;
809 PublicId::TextClass entityType() const;
810 const StringC &effectiveSystemId() const;
811 private:
812 SgmlDeclEntityEvent(const SgmlDeclEntityEvent &); // undefined
813 void operator=(const SgmlDeclEntityEvent &); // undefined
814 PublicId publicId_;
815 PublicId::TextClass entityType_;
816 StringC effectiveSystemId_;
817 };
818
819 class SP_API EventHandler {
820 public:
821 virtual ~EventHandler();
822 virtual void message(MessageEvent *) = 0;
823 virtual void data(DataEvent *);
824 virtual void startElement(StartElementEvent *);
825 virtual void endElement(EndElementEvent *);
826 virtual void pi(PiEvent *);
827 virtual void sdataEntity(SdataEntityEvent *);
828 virtual void externalDataEntity(ExternalDataEntityEvent *);
829 virtual void subdocEntity(SubdocEntityEvent *);
830 virtual void nonSgmlChar(NonSgmlCharEvent *);
831 virtual void appinfo(AppinfoEvent *);
832 virtual void uselink(UselinkEvent *);
833 virtual void usemap(UsemapEvent *);
834 virtual void startDtd(StartDtdEvent *);
835 virtual void endDtd(EndDtdEvent *);
836 virtual void startLpd(StartLpdEvent *);
837 virtual void endLpd(EndLpdEvent *);
838 virtual void endProlog(EndPrologEvent *);
839 virtual void sgmlDecl(SgmlDeclEvent *);
840 virtual void commentDecl(CommentDeclEvent *);
841 virtual void sSep(SSepEvent *);
842 virtual void ignoredRs(IgnoredRsEvent *);
843 virtual void ignoredRe(IgnoredReEvent *);
844 virtual void reOrigin(ReOriginEvent *);
845 virtual void ignoredChars(IgnoredCharsEvent *);
846 virtual void markedSectionStart(MarkedSectionStartEvent *);
847 virtual void markedSectionEnd(MarkedSectionEndEvent *);
848 virtual void entityStart(EntityStartEvent *);
849 virtual void entityEnd(EntityEndEvent *);
850 virtual void notationDecl(NotationDeclEvent *);
851 virtual void entityDecl(EntityDeclEvent *);
852 virtual void elementDecl(ElementDeclEvent *);
853 virtual void attlistDecl(AttlistDeclEvent *);
854 virtual void linkAttlistDecl(LinkAttlistDeclEvent *);
855 virtual void attlistNotationDecl(AttlistNotationDeclEvent *);
856 virtual void linkDecl(LinkDeclEvent *);
857 virtual void idLinkDecl(IdLinkDeclEvent *);
858 virtual void shortrefDecl(ShortrefDeclEvent *);
859 virtual void ignoredMarkup(IgnoredMarkupEvent *);
860 virtual void entityDefaulted(EntityDefaultedEvent *);
861 virtual void sgmlDeclEntity(SgmlDeclEntityEvent *);
862 };
863
864 inline
Event(Type type)865 Event::Event(Type type)
866 : type_(type)
867 {
868 }
869
870 inline
type()871 Event::Type Event::type() const
872 {
873 return type_;
874 }
875
876 inline
location()877 const Location &LocatedEvent::location() const
878 {
879 return location_;
880 }
881
882 inline
markup()883 const Markup &MarkupEvent::markup() const
884 {
885 return markup_;
886 }
887
888 inline
message()889 const Message &MessageEvent::message() const
890 {
891 return message_;
892 }
893
894 inline
elementType()895 const ElementType *StartElementEvent::elementType() const
896 {
897 return elementType_;
898 }
899
900 inline
name()901 const StringC &StartElementEvent::name() const
902 {
903 return elementType_->name();
904 }
905
906 inline
setIncluded()907 void StartElementEvent::setIncluded()
908 {
909 included_ = 1;
910 }
911
912 inline
included()913 Boolean StartElementEvent::included() const
914 {
915 return included_;
916 }
917
918 inline
markupPtr()919 const Markup *StartElementEvent::markupPtr() const
920 {
921 return markup_;
922 }
923
924 inline
attributes()925 const AttributeList &StartElementEvent::attributes() const
926 {
927 return *attributes_;
928 }
929
930 inline
mustOmitEnd()931 Boolean StartElementEvent::mustOmitEnd() const
932 {
933 return ((elementType()->definition()->declaredContent()
934 == ElementDefinition::empty)
935 || attributes_->conref());
936 }
937
938 inline
elementType()939 const ElementType *EndElementEvent::elementType() const
940 {
941 return elementType_;
942 }
943
944 inline
name()945 const StringC &EndElementEvent::name() const
946 {
947 return elementType_->name();
948 }
949
950 inline
setIncluded()951 void EndElementEvent::setIncluded()
952 {
953 included_ = 1;
954 }
955
956 inline
included()957 Boolean EndElementEvent::included() const
958 {
959 return included_;
960 }
961
962 inline
markupPtr()963 const Markup *EndElementEvent::markupPtr() const
964 {
965 return markup_;
966 }
967
968 inline
data()969 const Char *DataEvent::data() const
970 {
971 return p_;
972 }
973
974 inline
dataLength()975 size_t DataEvent::dataLength() const
976 {
977 return length_;
978 }
979
980 inline
data()981 const Char *PiEvent::data() const
982 {
983 return data_;
984 }
985
986 inline
dataLength()987 size_t PiEvent::dataLength() const
988 {
989 return dataLength_;
990 }
991
992 inline
993 const ConstPtr<EntityOrigin> &
entityOrigin()994 ExternalEntityEvent::entityOrigin() const
995 {
996 return origin_;
997 }
998
999 inline
location()1000 const Location &ExternalEntityEvent::location() const
1001 {
1002 return origin_->parent();
1003 }
1004
1005 inline
entity()1006 const ExternalDataEntity *ExternalDataEntityEvent::entity() const
1007 {
1008 return dataEntity_;
1009 }
1010
1011 inline
entity()1012 const SubdocEntity *SubdocEntityEvent::entity() const
1013 {
1014 return subdocEntity_;
1015 }
1016
1017 inline
character()1018 Char NonSgmlCharEvent::character() const
1019 {
1020 return c_;
1021 }
1022
1023 inline
literal(const StringC * & p)1024 Boolean AppinfoEvent::literal(const StringC *&p) const
1025 {
1026 if (appinfoNone_)
1027 return 0;
1028 p = &appinfo_.string();
1029 return 1;
1030 }
1031
1032 inline
lpd()1033 const ConstPtr<Lpd> &UselinkEvent::lpd() const
1034 {
1035 return lpd_;
1036 }
1037
1038 inline
linkSet()1039 const LinkSet *UselinkEvent::linkSet() const
1040 {
1041 return linkSet_;
1042 }
1043
1044 inline
restore()1045 Boolean UselinkEvent::restore() const
1046 {
1047 return restore_;
1048 }
1049
1050 inline
map()1051 const ShortReferenceMap *UsemapEvent::map() const
1052 {
1053 return map_;
1054 }
1055
1056 inline
name()1057 const StringC &StartSubsetEvent::name() const
1058 {
1059 return name_;
1060 }
1061
1062 inline
entity()1063 const ConstPtr<Entity> &StartSubsetEvent::entity() const
1064 {
1065 return entity_;
1066 }
1067
1068 inline
hasInternalSubset()1069 Boolean StartSubsetEvent::hasInternalSubset() const
1070 {
1071 return hasInternalSubset_;
1072 }
1073
1074 inline
active()1075 Boolean StartLpdEvent::active() const
1076 {
1077 return active_;
1078 }
1079
1080 inline
dtd()1081 const Dtd &EndDtdEvent::dtd() const
1082 {
1083 return *dtd_;
1084 }
1085
1086 inline
dtdPointer()1087 const ConstPtr<Dtd> &EndDtdEvent::dtdPointer() const
1088 {
1089 return dtd_;
1090 }
1091
1092 inline
lpd()1093 const Lpd &EndLpdEvent::lpd() const
1094 {
1095 return *lpd_;
1096 }
1097
1098 inline
lpdPointer()1099 const ConstPtr<Lpd> &EndLpdEvent::lpdPointer() const
1100 {
1101 return lpd_;
1102 }
1103
1104 inline
dtd()1105 const Dtd &EndPrologEvent::dtd() const
1106 {
1107 return *dtd_;
1108 }
1109
1110 inline
dtdPointer()1111 const ConstPtr<Dtd> &EndPrologEvent::dtdPointer() const
1112 {
1113 return dtd_;
1114 }
1115
1116 inline
lpdPointer()1117 const ConstPtr<ComplexLpd> &EndPrologEvent::lpdPointer() const
1118 {
1119 return lpd_;
1120 }
1121
1122 inline
simpleLinkNames()1123 const Vector<StringC> &EndPrologEvent::simpleLinkNames() const
1124 {
1125 return simpleLinkNames_;
1126 }
1127
1128 inline
simpleLinkAttributes()1129 const Vector<AttributeList> &EndPrologEvent::simpleLinkAttributes() const
1130 {
1131 return simpleLinkAttributes_;
1132 }
1133
1134 inline
sd()1135 const Sd &SgmlDeclEvent::sd() const
1136 {
1137 return *sd_;
1138 }
1139
1140 inline
sdPointer()1141 const ConstPtr<Sd> &SgmlDeclEvent::sdPointer() const
1142 {
1143 return sd_;
1144 }
1145
1146 inline
refSdPointer()1147 const ConstPtr<Sd> &SgmlDeclEvent::refSdPointer() const
1148 {
1149 return refSd_;
1150 }
1151
1152 inline
prologSyntax()1153 const Syntax &SgmlDeclEvent::prologSyntax() const
1154 {
1155 return *prologSyntax_;
1156 }
1157
1158 inline
prologSyntaxPointer()1159 const ConstPtr<Syntax> &SgmlDeclEvent::prologSyntaxPointer() const
1160 {
1161 return prologSyntax_;
1162 }
1163
1164 inline
instanceSyntax()1165 const Syntax &SgmlDeclEvent::instanceSyntax() const
1166 {
1167 return *instanceSyntax_;
1168 }
1169
1170 inline
instanceSyntaxPointer()1171 const ConstPtr<Syntax> &SgmlDeclEvent::instanceSyntaxPointer() const
1172 {
1173 return instanceSyntax_;
1174 }
1175
1176 inline
refSyntaxPointer()1177 const ConstPtr<Syntax> &SgmlDeclEvent::refSyntaxPointer() const
1178 {
1179 return refSyntax_;
1180 }
1181
1182 inline
implySystemId()1183 const StringC &SgmlDeclEvent::implySystemId() const
1184 {
1185 return implySystemId_;
1186 }
1187
1188 inline
rs()1189 Char IgnoredRsEvent::rs() const
1190 {
1191 return c_;
1192 }
1193
1194 inline
re()1195 Char IgnoredReEvent::re() const
1196 {
1197 return c_;
1198 }
1199
1200 inline
serial()1201 unsigned long IgnoredReEvent::serial() const
1202 {
1203 return serial_;
1204 }
1205
1206 inline
re()1207 Char ReOriginEvent::re() const
1208 {
1209 return c_;
1210 }
1211
1212 inline
serial()1213 unsigned long ReOriginEvent::serial() const
1214 {
1215 return serial_;
1216 }
1217
1218 inline
status()1219 MarkedSectionEvent::Status MarkedSectionEvent::status() const
1220 {
1221 return status_;
1222 }
1223
1224 inline
entity()1225 const Entity *EntityStartEvent::entity() const
1226 {
1227 return origin_->entity();
1228 }
1229
1230 inline
1231 const ConstPtr<EntityOrigin> &
entityOrigin()1232 EntityStartEvent::entityOrigin() const
1233 {
1234 return origin_;
1235 }
1236
1237 inline
entityPointer()1238 const ConstPtr<Entity> &EntityDeclEvent::entityPointer() const
1239 {
1240 return entity_;
1241 }
1242
1243 inline
entity()1244 const Entity &EntityDeclEvent::entity() const
1245 {
1246 return *entity_;
1247 }
1248
1249 inline
ignored()1250 Boolean EntityDeclEvent::ignored() const
1251 {
1252 return ignored_;
1253 }
1254
1255 inline
notation()1256 const Notation &NotationDeclEvent::notation() const
1257 {
1258 return *notation_;
1259 }
1260
1261 inline
notationPointer()1262 const ConstPtr<Notation> &NotationDeclEvent::notationPointer() const
1263 {
1264 return notation_;
1265 }
1266
1267 inline
elements()1268 const Vector<const ElementType *> &ElementDeclEvent::elements() const
1269 {
1270 return elements_;
1271 }
1272
1273 inline
elements()1274 const Vector<const ElementType *> &AttlistDeclEvent::elements() const
1275 {
1276 return elements_;
1277 }
1278
1279 inline
elements()1280 const Vector<const ElementType *> &LinkAttlistDeclEvent::elements() const
1281 {
1282 return elements_;
1283 }
1284
1285 inline
lpd()1286 const Lpd &LinkAttlistDeclEvent::lpd() const
1287 {
1288 return *lpd_;
1289 }
1290
1291 inline
linkSet()1292 const LinkSet *LinkDeclEvent::linkSet() const
1293 {
1294 return linkSet_;
1295 }
1296
1297 inline
lpd()1298 const ComplexLpd &LinkDeclEvent::lpd() const
1299 {
1300 return *lpd_;
1301 }
1302
1303 inline
lpd()1304 const ComplexLpd &IdLinkDeclEvent::lpd() const
1305 {
1306 return *lpd_;
1307 }
1308
1309 inline
1310 const Vector<ConstPtr<Notation> > &
notations()1311 AttlistNotationDeclEvent::notations() const
1312 {
1313 return notations_;
1314 }
1315
1316 inline
map()1317 const ShortReferenceMap *ShortrefDeclEvent::map() const
1318 {
1319 return map_;
1320 }
1321
1322 inline
entity()1323 const Entity &EntityDefaultedEvent::entity() const
1324 {
1325 return *entity_;
1326 }
1327
1328 inline
entityPointer()1329 const ConstPtr<Entity> &EntityDefaultedEvent::entityPointer()
1330 const
1331 {
1332 return entity_;
1333 }
1334
1335 inline
publicId()1336 const PublicId &SgmlDeclEntityEvent::publicId() const
1337 {
1338 return publicId_;
1339 }
1340
1341 inline
entityType()1342 PublicId::TextClass SgmlDeclEntityEvent::entityType() const
1343 {
1344 return entityType_;
1345 }
1346
1347 inline
effectiveSystemId()1348 const StringC &SgmlDeclEntityEvent::effectiveSystemId() const
1349 {
1350 return effectiveSystemId_;
1351 }
1352
1353 #ifdef SP_NAMESPACE
1354 }
1355 #endif
1356
1357 #endif /* not Event_INCLUDED */
1358