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 SgmlParser_INCLUDED 6 #define SgmlParser_INCLUDED 1 7 8 #ifdef __GNUG__ 9 #pragma interface 10 #endif 11 12 #include "StringC.h" 13 #include "Ptr.h" 14 #include "Location.h" 15 #include "EntityManager.h" 16 17 #include <signal.h> 18 19 #ifdef SP_NAMESPACE 20 namespace SP_NAMESPACE { 21 #endif 22 23 class Event; 24 class Parser; 25 class UnivCharsetDesc; 26 class EventHandler; 27 struct ParserOptions; 28 template<class T> class Ptr; 29 template<class T> class ConstPtr; 30 class InputSourceOrigin; 31 class Sd; 32 class Syntax; 33 class Dtd; 34 35 class SP_API SgmlParser { 36 public: 37 struct SP_API Params { 38 enum EntityType { 39 document, 40 subdoc, 41 dtd 42 }; 43 Params(); 44 EntityType entityType; // defaults to document 45 StringC sysid; // must be specified 46 Ptr<InputSourceOrigin> origin; 47 Ptr<EntityManager> entityManager; 48 const SgmlParser *parent; 49 ConstPtr<Sd> sd; 50 ConstPtr<Syntax> prologSyntax; 51 ConstPtr<Syntax> instanceSyntax; 52 unsigned subdocLevel; 53 const ParserOptions *options; 54 PackedBoolean subdocInheritActiveLinkTypes; 55 // referenced subdocs count against SUBDOC limit in SGML declaration 56 PackedBoolean subdocReferenced; 57 StringC doctypeName; 58 }; 59 SgmlParser(); // must call init 60 SgmlParser(const Params ¶ms); 61 void init(const Params ¶ms); 62 ~SgmlParser(); 63 Event *nextEvent(); 64 void parseAll(EventHandler &, const volatile sig_atomic_t *cancelPtr = 0); 65 ConstPtr<Sd> sd() const; 66 ConstPtr<Syntax> instanceSyntax() const; 67 ConstPtr<Syntax> prologSyntax() const; 68 EntityManager &entityManager() const; 69 const EntityCatalog &entityCatalog() const; 70 const ParserOptions &options() const; 71 // Only to be called after the parse has ended. 72 Ptr<Dtd> baseDtd(); 73 void activateLinkType(const StringC &); 74 void allLinkTypesActivated(); 75 void swap(SgmlParser &); 76 friend class Parser; 77 private: 78 SgmlParser(const SgmlParser &); 79 void operator=(const SgmlParser &); 80 Parser *parser_; 81 }; 82 83 #ifdef SP_NAMESPACE 84 } 85 #endif 86 87 #endif /* not SgmlParser_INCLUDED */ 88