File: ContentState.h

package info (click to toggle)
jade 1.2.1-43
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 8,808 kB
  • ctags: 16,989
  • sloc: cpp: 120,657; sh: 10,452; ansic: 8,228; perl: 378; makefile: 296; sed: 5
file content (118 lines) | stat: -rw-r--r-- 2,670 bytes parent folder | download | duplicates (10)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
// Copyright (c) 1994, 1996 James Clark
// See the file COPYING for copying permission.

#ifndef ContentState_INCLUDED
#define ContentState_INCLUDED 1

#ifdef __GNUG__
#pragma interface
#endif

#include <stddef.h>
#include "OpenElement.h"
#include "IList.h"
#include "Vector.h"
#include "Message.h"
#include "Dtd.h"
#include "Mode.h"
#include "Boolean.h"

#ifdef SP_NAMESPACE
namespace SP_NAMESPACE {
#endif

class SP_API ContentState {
public:
  ContentState();
  void startContent(const Dtd &);
  void pushElement(OpenElement *);
  OpenElement *popSaveElement();
  void popElement();
  OpenElement &currentElement();
  const OpenElement &currentElement() const;
  void getOpenElementInfo(Vector<OpenElementInfo> &,
			  const StringC &rniPcdata) const;
  unsigned tagLevel() const;
  Boolean elementIsIncluded(const ElementType *) const;
  Boolean elementIsExcluded(const ElementType *) const;
  Boolean elementIsOpen(const ElementType *) const;
  Boolean afterDocumentElement() const;
  const ElementType *lastEndedElementType() const;
  Mode contentMode() const;
  ElementType *lookupCreateUndefinedElement(const StringC &,
					    const Location &,
					    Dtd &);
  Boolean checkImplyLoop(unsigned);
  static const ShortReferenceMap theEmptyMap;
private:
  IList<OpenElement> openElements_;
  Vector<unsigned> openElementCount_;
  Vector<unsigned> includeCount_;
  Vector<unsigned> excludeCount_;
  unsigned totalExcludeCount_;
  unsigned tagLevel_;
  unsigned netEnablingCount_;
  unsigned long nextIndex_;
  const ElementType *lastEndedElementType_;
  ElementType documentElementContainer_;
};

inline
OpenElement &ContentState::currentElement()
{
  return *openElements_.head();
}

inline
const OpenElement &ContentState::currentElement() const
{
  return *openElements_.head();
}

inline
Boolean ContentState::elementIsOpen(const ElementType *e) const
{
  return openElementCount_[e->index()] != 0;
}

inline
Boolean ContentState::elementIsIncluded(const ElementType *e) const
{
  return includeCount_[e->index()] != 0 && excludeCount_[e->index()] == 0;
}

inline
Boolean ContentState::elementIsExcluded(const ElementType *e) const
{
  return excludeCount_[e->index()] != 0;
}

inline
const ElementType *ContentState::lastEndedElementType() const
{
  return lastEndedElementType_;
}

inline
unsigned ContentState::tagLevel() const
{
  return tagLevel_;
}

inline
Boolean ContentState::afterDocumentElement() const
{
  return tagLevel() == 0 && currentElement().isFinished();
}

inline
Mode ContentState::contentMode() const
{
  return openElements_.head()->mode(netEnablingCount_ > 0);
}

#ifdef SP_NAMESPACE
}
#endif

#endif /* not ContentState_INCLUDED */