Add GNU LGPL headers to all .c .C and .h files
[oweals/cde.git] / cde / programs / dtinfo / dtinfogen / infolib / etc / EntityScope.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: EntityScope.h /main/2 1996/07/18 16:43:47 drk $ */
24 #ifndef ENT_SCOPE_HDR
25 #define ENT_SCOPE_HDR
26
27 #include "EntityList.h"
28
29 class EntityScope {
30 private:
31   EntityList *currentEntityScope;
32
33 public:
34   void push ( EntityList *escope ) {
35     escope->next = currentEntityScope;
36     currentEntityScope = escope;
37   }
38
39   EntityList *pop();
40   EntityList *GetTopEntities() const { return(currentEntityScope); }
41
42   SGMLDefn *LookupEntity( int ename );
43
44   /*
45    * Constructor EntityScope creates a topmost entitylist
46    * so the stack will contain an element after it is constructed
47    */
48   
49   EntityScope() { currentEntityScope = new EntityList(); }
50   ~EntityScope();
51
52 };
53
54 //----------------------------------------------------------------
55 inline
56 SGMLDefn *
57 EntityScope::LookupEntity( int ename )
58 {
59   return ( currentEntityScope->lookup( ename ) );
60 }
61
62 //-----------------------------------------------------------------
63 inline
64 EntityList *
65 EntityScope::pop()
66 {
67   EntityList *ptr;
68   
69   ptr = currentEntityScope;
70   currentEntityScope = ptr->next;
71   return ( ptr );
72 }
73
74 //-----------------------------------------------------------------
75 inline
76 EntityScope::~EntityScope()
77 {
78   EntityList *pt = currentEntityScope;
79   while( pt ) {
80     EntityList *tmp = pt;
81     pt = pt->next;
82     delete tmp;
83   }
84 }
85
86 #endif
87
88