TIVI-153: Add as dependency for iputils
[profile/ivi/opensp.git] / include / SgmlParser.h
1 // Copyright (c) 1994 James Clark
2 // See the file COPYING for copying permission.
3
4 #ifndef SgmlParser_INCLUDED
5 #define SgmlParser_INCLUDED 1
6
7 #ifdef __GNUG__
8 #pragma interface
9 #endif
10
11 #include "StringC.h"
12 #include "Ptr.h"
13 #include "Location.h"
14 #include "EntityManager.h"
15
16 #include <signal.h>
17
18 #ifdef SP_NAMESPACE
19 namespace SP_NAMESPACE {
20 #endif
21
22 class Event;
23 class Parser;
24 class UnivCharsetDesc;
25 class EventHandler;
26 struct ParserOptions;
27 template<class T> class Ptr;
28 template<class T> class ConstPtr;
29 class InputSourceOrigin;
30 class Sd;
31 class Syntax;
32 class Dtd;
33
34 class SP_API SgmlParser {
35 public:
36   struct SP_API Params {
37     enum EntityType {
38       document,
39       subdoc,
40       dtd
41     };
42     Params();
43     EntityType entityType;      // defaults to document
44     StringC sysid;              // must be specified
45     Ptr<InputSourceOrigin> origin;
46     Ptr<EntityManager> entityManager;
47     const SgmlParser *parent;
48     ConstPtr<Sd> sd;
49     ConstPtr<Syntax> prologSyntax;
50     ConstPtr<Syntax> instanceSyntax;
51     unsigned subdocLevel;
52     const ParserOptions *options;
53     PackedBoolean subdocInheritActiveLinkTypes;
54     // referenced subdocs count against SUBDOC limit in SGML declaration
55     PackedBoolean subdocReferenced;
56     StringC doctypeName;
57   };
58   SgmlParser();                 // must call init
59   SgmlParser(const Params &params);
60   void init(const Params &params);
61   ~SgmlParser();
62   Event *nextEvent();
63   void parseAll(EventHandler &, const volatile sig_atomic_t *cancelPtr = 0);
64   ConstPtr<Sd> sd() const;
65   ConstPtr<Syntax> instanceSyntax() const;
66   ConstPtr<Syntax> prologSyntax() const;
67   EntityManager &entityManager() const;
68   const EntityCatalog &entityCatalog() const;
69   const ParserOptions &options() const;
70   // Only to be called after the parse has ended.
71   Ptr<Dtd> baseDtd();
72   void activateLinkType(const StringC &);
73   void allLinkTypesActivated();
74   void swap(SgmlParser &);
75   friend class Parser;
76   friend class PiAttspecParser;
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 */