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