]> git.saurik.com Git - apple/security.git/blob - SecurityASN1/c++/sm_x520sa.cpp
Security-54.1.9.tar.gz
[apple/security.git] / SecurityASN1 / c++ / sm_x520sa.cpp
1 // NOTE: this is a machine generated file--editing not recommended
2 //
3 // sm_x520sa.cpp - class member functions for ASN.1 module SelectedAttributeTypes
4 //
5 // This file was generated by snacc on Mon Apr 22 22:34:19 2002
6 // UBC snacc written by Mike Sample
7 // A couple of enhancements made by IBM European Networking Center
8
9
10 #include "asn-incl.h"
11 #include "sm_vdatypes.h"
12 #include "sm_x501ud.h"
13 #include "sm_x411ub.h"
14 #include "sm_x411mtsas.h"
15 #include "sm_x501if.h"
16 #include "sm_x520sa.h"
17 #include "sm_x509cmn.h"
18 #include "sm_x509af.h"
19 #include "sm_x509ce.h"
20 #include "pkcs1oids.h"
21 #include "pkcs9oids.h"
22 #include "sm_cms.h"
23 #include "sm_ess.h"
24 #include "pkcs7.h"
25 #include "pkcs8.h"
26 #include "appleoids.h"
27 #include "pkcs10.h"
28
29 //------------------------------------------------------------------------------
30 // value defs
31
32
33 //------------------------------------------------------------------------------
34 // class member definitions:
35
36 DirectoryString::DirectoryString()
37 {
38 choiceId = teletexStringCid;
39 #if TCL
40 teletexString = new TeletexString;
41 #else
42 teletexString = NULL; // incomplete initialization of mandatory element!
43 #endif // TCL
44 }
45
46 DirectoryString::DirectoryString (const DirectoryString &)
47 {
48 Asn1Error << "use of incompletely defined DirectoryString::DirectoryString (const DirectoryString &)" << endl;
49 abort();
50 }
51
52 DirectoryString::~DirectoryString()
53 {
54 switch (choiceId)
55 {
56 case teletexStringCid:
57 delete teletexString;
58 break;
59 case printableStringCid:
60 delete printableString;
61 break;
62 case universalStringCid:
63 delete universalString;
64 break;
65 case bmpStringCid:
66 delete bmpString;
67 break;
68 case utf8StringCid:
69 delete utf8String;
70 break;
71 } // end of switch
72 } // end of destructor
73
74 AsnType *DirectoryString::Clone() const
75 {
76 return new DirectoryString;
77 }
78
79 AsnType *DirectoryString::Copy() const
80 {
81 return new DirectoryString (*this);
82 }
83
84 #if SNACC_DEEP_COPY
85 DirectoryString &DirectoryString::operator = (const DirectoryString &that)
86 #else // SNACC_DEEP_COPY
87 DirectoryString &DirectoryString::operator = (const DirectoryString &)
88 #endif // SNACC_DEEP_COPY
89 {
90 #if SNACC_DEEP_COPY
91 if (this != &that)
92 {
93 switch (choiceId)
94 {
95 case teletexStringCid:
96 delete teletexString;
97 break;
98 case printableStringCid:
99 delete printableString;
100 break;
101 case universalStringCid:
102 delete universalString;
103 break;
104 case bmpStringCid:
105 delete bmpString;
106 break;
107 case utf8StringCid:
108 delete utf8String;
109 break;
110 }
111 switch (choiceId = that.choiceId)
112 {
113 case teletexStringCid:
114 teletexString = new TeletexString;
115 *teletexString = *that.teletexString;
116 break;
117 case printableStringCid:
118 printableString = new PrintableString;
119 *printableString = *that.printableString;
120 break;
121 case universalStringCid:
122 universalString = new UniversalString;
123 *universalString = *that.universalString;
124 break;
125 case bmpStringCid:
126 bmpString = new BMPString;
127 *bmpString = *that.bmpString;
128 break;
129 case utf8StringCid:
130 utf8String = new UTF8String;
131 *utf8String = *that.utf8String;
132 break;
133 }
134 }
135
136 return *this;
137 #else // SNACC_DEEP_COPY
138 Asn1Error << "use of incompletely defined DirectoryString &DirectoryString::operator = (const DirectoryString &)" << endl;
139 abort();
140 // if your compiler complains here, check the -novolat option
141 #endif // SNACC_DEEP_COPY
142 }
143
144 AsnLen
145 DirectoryString::BEncContent (BUF_TYPE b)
146 {
147 AsnLen l;
148 switch (choiceId)
149 {
150 case teletexStringCid:
151 l = teletexString->BEncContent (b);
152 l += BEncDefLen (b, l);
153
154 l += BEncTag1 (b, UNIV, PRIM, TELETEXSTRING_TAG_CODE);
155 break;
156
157 case printableStringCid:
158 l = printableString->BEncContent (b);
159 l += BEncDefLen (b, l);
160
161 l += BEncTag1 (b, UNIV, PRIM, PRINTABLESTRING_TAG_CODE);
162 break;
163
164 case universalStringCid:
165 l = universalString->BEncContent (b);
166 l += BEncDefLen (b, l);
167
168 l += BEncTag1 (b, UNIV, PRIM, UNIVERSALSTRING_TAG_CODE);
169 break;
170
171 case bmpStringCid:
172 l = bmpString->BEncContent (b);
173 l += BEncDefLen (b, l);
174
175 l += BEncTag1 (b, UNIV, PRIM, BMPSTRING_TAG_CODE);
176 break;
177
178 case utf8StringCid:
179 l = utf8String->BEncContent (b);
180 l += BEncDefLen (b, l);
181
182 l += BEncTag1 (b, UNIV, PRIM, 12);
183 break;
184
185 } // end switch
186 return l;
187 } // DirectoryString::BEncContent
188
189
190 void DirectoryString::BDecContent (BUF_TYPE b, AsnTag tag, AsnLen elmtLen0, AsnLen &bytesDecoded, ENV_TYPE env)
191 {
192 switch (tag)
193 {
194 case MAKE_TAG_ID (UNIV, PRIM, TELETEXSTRING_TAG_CODE):
195 case MAKE_TAG_ID (UNIV, CONS, TELETEXSTRING_TAG_CODE):
196 choiceId = teletexStringCid;
197 teletexString = new TeletexString;
198 teletexString->BDecContent (b, tag, elmtLen0, bytesDecoded, env);
199 break;
200
201 case MAKE_TAG_ID (UNIV, PRIM, PRINTABLESTRING_TAG_CODE):
202 case MAKE_TAG_ID (UNIV, CONS, PRINTABLESTRING_TAG_CODE):
203 choiceId = printableStringCid;
204 printableString = new PrintableString;
205 printableString->BDecContent (b, tag, elmtLen0, bytesDecoded, env);
206 break;
207
208 case MAKE_TAG_ID (UNIV, PRIM, UNIVERSALSTRING_TAG_CODE):
209 case MAKE_TAG_ID (UNIV, CONS, UNIVERSALSTRING_TAG_CODE):
210 choiceId = universalStringCid;
211 universalString = new UniversalString;
212 universalString->BDecContent (b, tag, elmtLen0, bytesDecoded, env);
213 break;
214
215 case MAKE_TAG_ID (UNIV, PRIM, BMPSTRING_TAG_CODE):
216 case MAKE_TAG_ID (UNIV, CONS, BMPSTRING_TAG_CODE):
217 choiceId = bmpStringCid;
218 bmpString = new BMPString;
219 bmpString->BDecContent (b, tag, elmtLen0, bytesDecoded, env);
220 break;
221
222 case MAKE_TAG_ID (UNIV, PRIM, 12):
223 case MAKE_TAG_ID (UNIV, CONS, 12):
224 choiceId = utf8StringCid;
225 utf8String = new UTF8String;
226 utf8String->BDecContent (b, tag, elmtLen0, bytesDecoded, env);
227 break;
228
229 default:
230 Asn1Error << "ERROR - unexpected tag in CHOICE" << endl;
231 SnaccExcep::throwMe(-100);
232 break;
233 } // end switch
234 } // DirectoryString::BDecContent
235
236
237 AsnLen DirectoryString::BEnc (BUF_TYPE b)
238 {
239 AsnLen l;
240 l = BEncContent (b);
241 return l;
242 }
243
244 void DirectoryString::BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env)
245 {
246 AsnLen elmtLen;
247 AsnTag tag;
248
249 /* CHOICEs are a special case - grab identifying tag */
250 /* this allows easier handling of nested CHOICEs */
251 tag = BDecTag (b, bytesDecoded, env);
252 elmtLen = BDecLen (b, bytesDecoded, env);
253 BDecContent (b, tag, elmtLen, bytesDecoded, env);
254 }
255
256 void DirectoryString::Print (ostream &os) const
257 {
258 #ifndef NDEBUG
259 switch (choiceId)
260 {
261 case teletexStringCid:
262 os << "teletexString ";
263 if (teletexString)
264 os << *teletexString;
265 else
266 os << "-- void3 --\n";
267 break;
268
269 case printableStringCid:
270 os << "printableString ";
271 if (printableString)
272 os << *printableString;
273 else
274 os << "-- void3 --\n";
275 break;
276
277 case universalStringCid:
278 os << "universalString ";
279 if (universalString)
280 os << *universalString;
281 else
282 os << "-- void3 --\n";
283 break;
284
285 case bmpStringCid:
286 os << "bmpString ";
287 if (bmpString)
288 os << *bmpString;
289 else
290 os << "-- void3 --\n";
291 break;
292
293 case utf8StringCid:
294 os << "utf8String ";
295 if (utf8String)
296 os << *utf8String;
297 else
298 os << "-- void3 --\n";
299 break;
300
301 } // end of switch
302 #endif /* NDEBUG */
303 } // DirectoryString::Print
304