dsdm: Change to ANSI function definitions
[oweals/cde.git] / cde / programs / nsgmls / ShortReferenceMap.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 libraries 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: ShortReferenceMap.h /main/1 1996/07/29 17:04:33 cde-hp $ */
24 // Copyright (c) 1994 James Clark
25 // See the file COPYING for copying permission.
26
27 #ifndef ShortReferenceMap_INCLUDED
28 #define ShortReferenceMap_INCLUDED 1
29 #ifdef __GNUG__
30 #pragma interface
31 #endif
32
33 #include "Vector.h"
34 #include "Vector.h"
35 #include "StringC.h"
36 #include "Named.h"
37 #include "Boolean.h"
38 #include "Entity.h"
39 #include "Ptr.h"
40
41 #ifdef SP_NAMESPACE
42 namespace SP_NAMESPACE {
43 #endif
44
45 class SP_API ShortReferenceMap : public Named {
46 public:
47   ShortReferenceMap();
48   ShortReferenceMap(const StringC &);
49   Boolean defined() const;
50   void setNameMap(Vector<StringC> &map);
51   void setEntityMap(Vector<ConstPtr<Entity> > &map);
52   Boolean lookup(int i, const StringC *&) const;
53   const StringC *entityName(size_t i) const;
54   const ConstPtr<Entity> &entity(size_t i) const;
55   Boolean used() const;
56   void setUsed();
57   const Location &defLocation() const;
58   void setDefLocation(const Location &);
59 private:
60   ShortReferenceMap(const ShortReferenceMap &); // undefined
61   void operator=(const ShortReferenceMap &);    // undefined
62   Vector<StringC> nameMap_;
63   Vector<ConstPtr<Entity> > entityMap_;
64   ConstPtr<Entity> nullEntity_;
65   Boolean used_;
66   Location defLocation_;
67 };
68
69 inline
70 Boolean ShortReferenceMap::defined() const
71 {
72   return nameMap_.size() > 0;
73 }
74
75 inline
76 const StringC *ShortReferenceMap::entityName(size_t i) const
77 {
78   if (i < nameMap_.size() && nameMap_[i].size() != 0)
79     return &nameMap_[i];
80   else
81     return 0;
82 }
83
84 inline
85 const ConstPtr<Entity> &ShortReferenceMap::entity(size_t i) const
86 {
87   if (i < entityMap_.size())
88     return entityMap_[i];
89   else
90     return nullEntity_;
91 }
92
93 inline
94 void ShortReferenceMap::setEntityMap(Vector<ConstPtr<Entity> > &map)
95 {
96   map.swap(entityMap_);
97 }
98
99 inline
100 Boolean ShortReferenceMap::used() const
101 {
102   return used_;
103 }
104
105 inline
106 void ShortReferenceMap::setUsed()
107 {
108   used_ = 1;
109 }
110
111 inline
112 void ShortReferenceMap::setDefLocation(const Location &loc)
113 {
114   defLocation_ = loc;
115 }
116
117 inline
118 const Location &ShortReferenceMap::defLocation() const
119 {
120   return defLocation_;
121 }
122
123 #ifdef SP_NAMESPACE
124 }
125 #endif
126
127 #endif /* not ShortReferenceMap_INCLUDED */