Add GNU LGPL headers to all .c .C and .h files
[oweals/cde.git] / cde / programs / nsgmls / OutputState.h
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 librararies 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: OutputState.h /main/1 1996/07/29 16:59:49 cde-hp $ */
24 // Copyright (c) 1994 James Clark
25 // See the file COPYING for copying permission.
26
27 #ifndef OutputState_INCLUDED
28 #define OutputState_INCLUDED 1
29 #ifdef __GNUG__
30 #pragma interface
31 #endif
32
33 #include "Location.h"
34 #include "IList.h"
35 #include "Link.h"
36 #include "Boolean.h"
37 #include "types.h"
38 #include "EventsWanted.h"
39
40 #ifdef SP_NAMESPACE
41 namespace SP_NAMESPACE {
42 #endif
43
44 struct OutputStateLevel : public Link {
45   OutputStateLevel();
46   Boolean hasPendingRe() const;
47   char state;                   // should be OutputState::State
48   unsigned long reSerial;
49   Location reLocation;
50 };
51
52 class EventHandler;
53 class Allocator;
54
55 class OutputState {
56 public:
57   OutputState();
58   void init();
59   void handleRe(EventHandler &, Allocator &, const EventsWanted &,
60                 Char, const Location &);
61   void noteRs(EventHandler &, Allocator &, const EventsWanted &);
62   void noteMarkup(EventHandler &, Allocator &, const EventsWanted &);
63   void noteData(EventHandler &, Allocator &, const EventsWanted &);
64   void noteStartElement(Boolean included,
65                         EventHandler &, Allocator &, const EventsWanted &);
66   void noteEndElement(Boolean included,
67                       EventHandler &, Allocator &, const EventsWanted &);
68 private:
69   OutputState(const OutputState &); // undefined
70   void operator=(const OutputState &); // undefined
71   enum State {
72     afterStartTag,
73     afterRsOrRe,
74     afterData,
75     pendingAfterRsOrRe,
76     pendingAfterMarkup
77   };
78   IList<OutputStateLevel> stack_;
79   OutputStateLevel &top();
80   Char re_;
81   unsigned long nextSerial_;
82   friend struct OutputStateLevel;
83 };
84
85 inline
86 Boolean OutputStateLevel::hasPendingRe() const
87 {
88   return int(state) >= int(OutputState::pendingAfterRsOrRe);
89 }
90
91 inline
92 OutputStateLevel &OutputState::top()
93 {
94   return *stack_.head();
95 }
96
97 #ifdef SP_NAMESPACE
98 }
99 #endif
100
101 #endif /* not OutputState_INCLUDED */