Link with C++ linker
[oweals/cde.git] / cde / programs / nsgmls / Param.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: Param.h /main/1 1996/07/29 17:00:19 cde-hp $ */
24 // Copyright (c) 1994 James Clark
25 // See the file COPYING for copying permission.
26
27 #ifndef Param_INCLUDED
28 #define Param_INCLUDED 1
29 #ifdef __GNUG__
30 #pragma interface
31 #endif
32
33 #include "Boolean.h"
34 #include "ContentToken.h"
35 #include "StringC.h"
36 #include "Location.h"
37 #include "MessageArg.h"
38 #include "Mode.h"
39 #include "NameToken.h"
40 #include "Owner.h"
41 #include "Ptr.h"
42 #include "Syntax.h"
43 #include "Text.h"
44 #include "Vector.h"
45
46 // This describes a markup declaration parameter.
47
48 #ifdef SP_NAMESPACE
49 namespace SP_NAMESPACE {
50 #endif
51
52 class ElementType;
53
54 class Param {
55 public:
56   Param() { }
57   typedef unsigned char Type;
58   enum {
59     invalid,
60     dso,
61     mdc,
62     minus,
63     pero,
64     inclusions,
65     exclusions,
66     nameGroup,
67     nameTokenGroup,
68     modelGroup,
69     number,
70     minimumLiteral,
71     attributeValueLiteral,
72     tokenizedAttributeValueLiteral,
73     systemIdentifier,
74     paramLiteral,
75     name,
76     entityName,
77     paramEntityName,
78     attributeValue,
79     reservedName,               // Syntax::ReservedName is added to this
80     // this is a reserved name preceded by the RNI delimiter
81     indicatedReservedName = reservedName + Syntax::nNames
82     };
83   enum { nTypes = indicatedReservedName + Syntax::nNames };
84   Type type;
85   Location startLocation;
86   Text literalText;
87   Boolean lita;
88   Owner<ModelGroup> modelGroupPtr;
89   Vector<NameToken> nameTokenVector;
90   StringC token;                // name nameToken; with substitution
91   Vector<const ElementType *> elementVector;
92 private:
93   Param(const Param &);         // undefined
94   void operator=(const Param &); // undefined
95 };
96
97 class AllowedParams {
98 public:
99   AllowedParams(Param::Type,
100                 Param::Type = Param::invalid,
101                 Param::Type = Param::invalid,
102                 Param::Type = Param::invalid,
103                 Param::Type = Param::invalid,
104                 Param::Type = Param::invalid,
105                 Param::Type = Param::invalid,
106                 Param::Type = Param::invalid,
107                 Param::Type = Param::invalid,
108                 Param::Type = Param::invalid);
109   AllowedParams(const Param::Type *types, int nTypes);
110   Mode mainMode() const;
111   Boolean mdc() const;
112   Boolean rni() const;
113   Boolean dso() const;
114   Boolean inclusions() const;
115   Boolean exclusions() const;
116   Boolean reservedName(Syntax::ReservedName) const;
117   Param::Type group() const;
118   Param::Type nameStart() const;
119   Param::Type digit() const;
120   Param::Type nmchar() const;
121   Param::Type literal() const;
122 private:
123   void init();
124   void allow(Param::Type);
125   PackedBoolean mdc_;
126   PackedBoolean rni_;
127   PackedBoolean dso_;
128   PackedBoolean inclusions_;
129   PackedBoolean exclusions_;
130   // invalid, minus, pero
131   Param::Type extraDelimiter_;
132   // invalid, nameGroup, nameTokenGroup, modelGroup
133   Param::Type group_;
134   // invalid, reservedName, name, entityName, paramEntityName, attributeValue
135   Param::Type nameStart_;
136   // invalid, number, attributeValue
137   Param::Type digit_;
138   // invalid, attributeValue
139   Param::Type nmchar_; // LCNMCHAR or UCNMCHAR
140   // invalid, minimumLiteral, systemIdentifier, paramLiteral,
141   // (tokenized)attributeValueLiteral
142   Param::Type literal_;
143   PackedBoolean reservedNames_[Syntax::nNames];
144   Mode mainMode_;               // mdMode mdMinusMode mdPeroMode
145 };
146
147 class MessageBuilder;
148
149 class AllowedParamsMessageArg : public MessageArg {
150 public:
151   AllowedParamsMessageArg(const AllowedParams &allow,
152                           const ConstPtr<Syntax> &syntax);
153   MessageArg *copy() const;
154   void append(MessageBuilder &) const;
155 private:
156   AllowedParams allow_;
157   ConstPtr<Syntax> syntax_;
158 };
159
160 inline
161 Mode AllowedParams::mainMode() const
162 {
163   return mainMode_;
164 }
165
166 inline
167 Boolean AllowedParams::mdc() const
168 {
169   return mdc_;
170 }
171
172 inline
173 Boolean AllowedParams::rni() const
174 {
175   return rni_;
176 }
177
178 inline
179 Boolean AllowedParams::dso() const
180 {
181   return dso_;
182 }
183
184 inline
185 Boolean AllowedParams::inclusions() const
186 {
187   return inclusions_;
188 }
189
190 inline
191 Boolean AllowedParams::exclusions() const
192 {
193   return exclusions_;
194 }
195
196 inline
197 Boolean AllowedParams::reservedName(Syntax::ReservedName i) const
198 {
199   return reservedNames_[i];
200 }
201
202 inline
203 Param::Type AllowedParams::group() const
204 {
205   return group_;
206 }
207
208 inline
209 Param::Type AllowedParams::nameStart() const
210 {
211   return nameStart_;
212 }
213
214 inline
215 Param::Type AllowedParams::digit() const
216 {
217   return digit_;
218 }
219
220 inline
221 Param::Type AllowedParams::nmchar() const
222 {
223   return nmchar_;
224 }
225
226 inline
227 Param::Type AllowedParams::literal() const
228 {
229   return literal_;
230 }
231
232 #ifdef SP_NAMESPACE
233 }
234 #endif
235
236 #endif /* not Param_INCLUDED */