OpenElement.h 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217
  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: OpenElement.h /main/1 1996/07/29 16:59:20 cde-hp $ */
  24. // Copyright (c) 1994 James Clark
  25. // See the file COPYING for copying permission.
  26. #ifndef OpenElement_INCLUDED
  27. #define OpenElement_INCLUDED 1
  28. #ifdef __GNUG__
  29. #pragma interface
  30. #endif
  31. #include "Boolean.h"
  32. #include "ContentToken.h"
  33. #include "ElementType.h"
  34. #include "Link.h"
  35. #include "Mode.h"
  36. #include "Allocator.h"
  37. #include "Location.h"
  38. #ifdef SP_NAMESPACE
  39. namespace SP_NAMESPACE {
  40. #endif
  41. class SP_API OpenElement : public Link {
  42. public:
  43. void *operator new(size_t sz, Allocator &alloc) { return alloc.alloc(sz); }
  44. void *operator new(size_t sz) { return Allocator::allocSimple(sz); }
  45. void operator delete(void *p) { Allocator::free(p); }
  46. OpenElement(const ElementType *, Boolean net, Boolean included,
  47. const ShortReferenceMap *currentMap,
  48. const Location &startLocation);
  49. Boolean isFinished() const;
  50. Boolean tryTransition(const ElementType *);
  51. const LeafContentToken *invalidExclusion(const ElementType *) const;
  52. // This doesn't handle declared content of EMPTY.
  53. // If this situation can arise must use declaredEmpty().
  54. Boolean tryTransitionPcdata();
  55. const LeafContentToken *impliedStartTag() const;
  56. void doRequiredTransition();
  57. const ElementType *type() const;
  58. Boolean netEnabling() const;
  59. Boolean included() const;
  60. const MatchState &matchState() const;
  61. void setMatchState(const MatchState &);
  62. Mode mode(Boolean netEnabled) const;
  63. const ShortReferenceMap *map() const;
  64. void setMap(const ShortReferenceMap *);
  65. Boolean requiresSpecialParse() const;
  66. const Location &startLocation() const;
  67. const LeafContentToken *currentPosition() const;
  68. Boolean declaredEmpty() const;
  69. void setConref();
  70. private:
  71. OpenElement(const OpenElement &); // undefined
  72. void operator=(const OpenElement &); // undefined
  73. const ElementType *elementType_;
  74. PackedBoolean netEnabling_; // start-tag was net-enabling
  75. PackedBoolean included_;
  76. MatchState matchState_;
  77. ElementDefinition::DeclaredContent declaredContent_;
  78. const ShortReferenceMap *map_;
  79. Location startLocation_;
  80. };
  81. inline
  82. const ElementType *OpenElement::type() const
  83. {
  84. return elementType_;
  85. }
  86. inline
  87. Boolean OpenElement::netEnabling() const
  88. {
  89. return netEnabling_;
  90. }
  91. inline
  92. Boolean OpenElement::included() const
  93. {
  94. return included_;
  95. }
  96. inline
  97. const MatchState &OpenElement::matchState() const
  98. {
  99. return matchState_;
  100. }
  101. inline
  102. void OpenElement::setMatchState(const MatchState &state)
  103. {
  104. matchState_ = state;
  105. }
  106. inline
  107. Boolean OpenElement::isFinished() const
  108. {
  109. return (declaredContent_ != ElementDefinition::modelGroup
  110. || matchState_.isFinished());
  111. }
  112. inline
  113. Boolean OpenElement::tryTransition(const ElementType *e)
  114. {
  115. return (declaredContent_ == ElementDefinition::modelGroup
  116. ? matchState_.tryTransition(e)
  117. : (declaredContent_ == ElementDefinition::any));
  118. }
  119. inline
  120. Boolean OpenElement::tryTransitionPcdata()
  121. {
  122. return (declaredContent_ == ElementDefinition::modelGroup
  123. ? matchState_.tryTransitionPcdata()
  124. : 1); // CDATA, RCDATA, ANY all ok
  125. }
  126. inline
  127. const LeafContentToken *OpenElement::invalidExclusion(const ElementType *e)
  128. const
  129. {
  130. return (declaredContent_ == ElementDefinition::modelGroup
  131. ? matchState_.invalidExclusion(e)
  132. : 0);
  133. }
  134. inline
  135. void OpenElement::doRequiredTransition()
  136. {
  137. matchState_.doRequiredTransition();
  138. }
  139. inline
  140. const LeafContentToken *OpenElement::impliedStartTag() const
  141. {
  142. return (declaredContent_ == ElementDefinition::modelGroup
  143. ? matchState_.impliedStartTag()
  144. : 0);
  145. }
  146. inline
  147. const ShortReferenceMap *OpenElement::map() const
  148. {
  149. return map_;
  150. }
  151. inline
  152. void OpenElement::setMap(const ShortReferenceMap *map)
  153. {
  154. map_ = map;
  155. }
  156. inline
  157. Boolean OpenElement::requiresSpecialParse() const
  158. {
  159. return (declaredContent_ == ElementDefinition::cdata
  160. || declaredContent_ == ElementDefinition::rcdata);
  161. }
  162. inline
  163. Mode OpenElement::mode(Boolean netEnabled) const
  164. {
  165. return elementType_->definition()->mode(netEnabled);
  166. }
  167. inline
  168. const Location &OpenElement::startLocation() const
  169. {
  170. return startLocation_;
  171. }
  172. inline
  173. const LeafContentToken *OpenElement::currentPosition() const
  174. {
  175. return (declaredContent_ == ElementDefinition::modelGroup
  176. ? matchState_.currentPosition()
  177. : 0);
  178. }
  179. inline
  180. Boolean OpenElement::declaredEmpty() const
  181. {
  182. return declaredContent_ == ElementDefinition::empty;
  183. }
  184. inline
  185. void OpenElement::setConref()
  186. {
  187. declaredContent_ = ElementDefinition::empty;
  188. }
  189. #ifdef SP_NAMESPACE
  190. }
  191. #endif
  192. #endif /* not OpenElement_INCLUDED */