SgmlParser.h 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  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: SgmlParser.h /main/1 1996/07/29 17:04:16 cde-hp $ */
  24. // Copyright (c) 1994 James Clark
  25. // See the file COPYING for copying permission.
  26. #ifndef SgmlParser_INCLUDED
  27. #define SgmlParser_INCLUDED 1
  28. #ifdef __GNUG__
  29. #pragma interface
  30. #endif
  31. #include "StringC.h"
  32. #include "Ptr.h"
  33. #include "Location.h"
  34. #include "EntityManager.h"
  35. #include <signal.h>
  36. #ifdef SP_NAMESPACE
  37. namespace SP_NAMESPACE {
  38. #endif
  39. class Event;
  40. class Parser;
  41. class UnivCharsetDesc;
  42. class EventHandler;
  43. struct ParserOptions;
  44. template<class T> class Ptr;
  45. template<class T> class ConstPtr;
  46. class InputSourceOrigin;
  47. class Sd;
  48. class Syntax;
  49. class Dtd;
  50. class SP_API SgmlParser {
  51. public:
  52. struct SP_API Params {
  53. enum EntityType {
  54. document,
  55. subdoc,
  56. dtd
  57. };
  58. Params();
  59. EntityType entityType; // defaults to document
  60. StringC sysid; // must be specified
  61. Ptr<InputSourceOrigin> origin;
  62. Ptr<EntityManager> entityManager;
  63. const UnivCharsetDesc *initialCharset;
  64. const SgmlParser *parent;
  65. ConstPtr<Sd> sd;
  66. ConstPtr<Syntax> prologSyntax;
  67. ConstPtr<Syntax> instanceSyntax;
  68. unsigned subdocLevel;
  69. const ParserOptions *options;
  70. PackedBoolean subdocInheritActiveLinkTypes;
  71. // referenced subdocs count against SUBDOC limit in SGML declaration
  72. PackedBoolean subdocReferenced;
  73. StringC doctypeName;
  74. };
  75. SgmlParser(); // must call init
  76. SgmlParser(const Params &params);
  77. void init(const Params &params);
  78. ~SgmlParser();
  79. Event *nextEvent();
  80. void parseAll(EventHandler &,
  81. SP_CONST SP_VOLATILE sig_atomic_t *cancelPtr = 0);
  82. ConstPtr<Sd> sd() const;
  83. ConstPtr<Syntax> instanceSyntax() const;
  84. ConstPtr<Syntax> prologSyntax() const;
  85. const EntityManager &entityManager() const;
  86. const EntityCatalog &entityCatalog() const;
  87. const ParserOptions &options() const;
  88. // Only to be called after the parse has ended.
  89. Ptr<Dtd> baseDtd();
  90. void activateLinkType(const StringC &);
  91. void allLinkTypesActivated();
  92. void swap(SgmlParser &);
  93. friend class Parser;
  94. private:
  95. SgmlParser(const SgmlParser &);
  96. void operator=(const SgmlParser &);
  97. Parser *parser_;
  98. };
  99. #ifdef SP_NAMESPACE
  100. }
  101. #endif
  102. #endif /* not SgmlParser_INCLUDED */