xref: /onnv-gate/usr/src/cmd/man/src/util/nsgmls.src/lib/OutputState.h (revision 0:68f95e015346)
1 // Copyright (c) 1994 James Clark
2 // See the file COPYING for copying permission.
3 #pragma ident	"%Z%%M%	%I%	%E% SMI"
4 
5 #ifndef OutputState_INCLUDED
6 #define OutputState_INCLUDED 1
7 #ifdef __GNUG__
8 #pragma interface
9 #endif
10 
11 #include "Location.h"
12 #include "IList.h"
13 #include "Link.h"
14 #include "Boolean.h"
15 #include "types.h"
16 #include "EventsWanted.h"
17 
18 #ifdef SP_NAMESPACE
19 namespace SP_NAMESPACE {
20 #endif
21 
22 struct OutputStateLevel : public Link {
23   OutputStateLevel();
24   Boolean hasPendingRe() const;
25   char state;			// should be OutputState::State
26   unsigned long reSerial;
27   Location reLocation;
28 };
29 
30 class EventHandler;
31 class Allocator;
32 
33 class OutputState {
34 public:
35   OutputState();
36   void init();
37   void handleRe(EventHandler &, Allocator &, const EventsWanted &,
38 		Char, const Location &);
39   void noteRs(EventHandler &, Allocator &, const EventsWanted &);
40   void noteMarkup(EventHandler &, Allocator &, const EventsWanted &);
41   void noteData(EventHandler &, Allocator &, const EventsWanted &);
42   void noteStartElement(Boolean included,
43 			EventHandler &, Allocator &, const EventsWanted &);
44   void noteEndElement(Boolean included,
45 		      EventHandler &, Allocator &, const EventsWanted &);
46 private:
47   OutputState(const OutputState &); // undefined
48   void operator=(const OutputState &); // undefined
49   enum State {
50     afterStartTag,
51     afterRsOrRe,
52     afterData,
53     pendingAfterRsOrRe,
54     pendingAfterMarkup
55   };
56   IList<OutputStateLevel> stack_;
57   OutputStateLevel &top();
58   Char re_;
59   unsigned long nextSerial_;
60   friend struct OutputStateLevel;
61 };
62 
63 inline
hasPendingRe()64 Boolean OutputStateLevel::hasPendingRe() const
65 {
66   return int(state) >= int(OutputState::pendingAfterRsOrRe);
67 }
68 
69 inline
top()70 OutputStateLevel &OutputState::top()
71 {
72   return *stack_.head();
73 }
74 
75 #ifdef SP_NAMESPACE
76 }
77 #endif
78 
79 #endif /* not OutputState_INCLUDED */
80