"Fossies" - the Fresh Open Source Software Archive

Member "OpenSP-1.5.2/include/OpenElement.h" (5 Nov 2005, 4917 Bytes) of package /linux/misc/old/OpenSP-1.5.2.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "OpenElement.h" see the Fossies "Dox" file reference documentation.

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