Event.h 32 KB

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