]>
Commit | Line | Data |
---|---|---|
bac41a7b A |
1 | // NOTE: this is a machine generated file--editing not recommended |
2 | // | |
3 | // asn-useful.cpp - class member functions for ASN.1 module ASN-USEFUL | |
4 | // | |
29654253 | 5 | // This file was generated by snacc on Wed Mar 20 11:39:57 2002 |
bac41a7b A |
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 "asn-useful.h" | |
12 | ||
13 | //------------------------------------------------------------------------------ | |
14 | // value defs | |
15 | ||
16 | ||
17 | //------------------------------------------------------------------------------ | |
18 | // class member definitions: | |
19 | ||
20 | AsnType *ObjectDescriptor::Clone() const | |
21 | { | |
22 | return new ObjectDescriptor; | |
23 | } | |
24 | ||
25 | AsnType *ObjectDescriptor::Copy() const | |
26 | { | |
27 | return new ObjectDescriptor (*this); | |
28 | } | |
29 | ||
30 | AsnLen ObjectDescriptor::BEnc (BUF_TYPE b) | |
31 | { | |
32 | AsnLen l; | |
33 | l = BEncContent (b); | |
34 | l += BEncDefLen (b, l); | |
35 | ||
36 | l += BEncTag1 (b, UNIV, PRIM, OD_TAG_CODE); | |
37 | return l; | |
38 | } | |
39 | ||
40 | void ObjectDescriptor::BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env) | |
41 | { | |
42 | AsnTag tag; | |
43 | AsnLen elmtLen1; | |
44 | ||
45 | if (((tag = BDecTag (b, bytesDecoded, env)) != MAKE_TAG_ID (UNIV, PRIM, OD_TAG_CODE)) | |
46 | && (tag != MAKE_TAG_ID (UNIV, CONS, OD_TAG_CODE))) | |
47 | { | |
48 | Asn1Error << "ObjectDescriptor::BDec: ERROR - wrong tag" << endl; | |
29654253 | 49 | SnaccExcep::throwMe(50); |
bac41a7b A |
50 | } |
51 | elmtLen1 = BDecLen (b, bytesDecoded, env); | |
52 | BDecContent (b, tag, elmtLen1, bytesDecoded, env); | |
53 | } | |
54 | ||
bac41a7b A |
55 | AsnType *UTF8String::Clone() const |
56 | { | |
57 | return new UTF8String; | |
58 | } | |
59 | ||
60 | AsnType *UTF8String::Copy() const | |
61 | { | |
62 | return new UTF8String (*this); | |
63 | } | |
64 | ||
65 | AsnLen UTF8String::BEnc (BUF_TYPE b) | |
66 | { | |
67 | AsnLen l; | |
68 | l = BEncContent (b); | |
69 | l += BEncDefLen (b, l); | |
70 | ||
71 | l += BEncTag1 (b, UNIV, PRIM, 12); | |
72 | return l; | |
73 | } | |
74 | ||
75 | void UTF8String::BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env) | |
76 | { | |
77 | AsnTag tag; | |
78 | AsnLen elmtLen1; | |
79 | ||
80 | if (((tag = BDecTag (b, bytesDecoded, env)) != MAKE_TAG_ID (UNIV, PRIM, 12)) | |
81 | && (tag != MAKE_TAG_ID (UNIV, CONS, 12))) | |
82 | { | |
83 | Asn1Error << "UTF8String::BDec: ERROR - wrong tag" << endl; | |
29654253 | 84 | SnaccExcep::throwMe(49); |
bac41a7b A |
85 | } |
86 | elmtLen1 = BDecLen (b, bytesDecoded, env); | |
87 | BDecContent (b, tag, elmtLen1, bytesDecoded, env); | |
88 | } | |
89 | ||
bac41a7b A |
90 | AsnType *NumericString::Clone() const |
91 | { | |
92 | return new NumericString; | |
93 | } | |
94 | ||
95 | AsnType *NumericString::Copy() const | |
96 | { | |
97 | return new NumericString (*this); | |
98 | } | |
99 | ||
100 | AsnLen NumericString::BEnc (BUF_TYPE b) | |
101 | { | |
102 | AsnLen l; | |
103 | l = BEncContent (b); | |
104 | l += BEncDefLen (b, l); | |
105 | ||
106 | l += BEncTag1 (b, UNIV, PRIM, NUMERICSTRING_TAG_CODE); | |
107 | return l; | |
108 | } | |
109 | ||
110 | void NumericString::BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env) | |
111 | { | |
112 | AsnTag tag; | |
113 | AsnLen elmtLen1; | |
114 | ||
115 | if (((tag = BDecTag (b, bytesDecoded, env)) != MAKE_TAG_ID (UNIV, PRIM, NUMERICSTRING_TAG_CODE)) | |
116 | && (tag != MAKE_TAG_ID (UNIV, CONS, NUMERICSTRING_TAG_CODE))) | |
117 | { | |
118 | Asn1Error << "NumericString::BDec: ERROR - wrong tag" << endl; | |
29654253 | 119 | SnaccExcep::throwMe(48); |
bac41a7b A |
120 | } |
121 | elmtLen1 = BDecLen (b, bytesDecoded, env); | |
122 | BDecContent (b, tag, elmtLen1, bytesDecoded, env); | |
123 | } | |
124 | ||
bac41a7b A |
125 | AsnType *PrintableString::Clone() const |
126 | { | |
127 | return new PrintableString; | |
128 | } | |
129 | ||
130 | AsnType *PrintableString::Copy() const | |
131 | { | |
132 | return new PrintableString (*this); | |
133 | } | |
134 | ||
135 | AsnLen PrintableString::BEnc (BUF_TYPE b) | |
136 | { | |
137 | AsnLen l; | |
138 | l = BEncContent (b); | |
139 | l += BEncDefLen (b, l); | |
140 | ||
141 | l += BEncTag1 (b, UNIV, PRIM, PRINTABLESTRING_TAG_CODE); | |
142 | return l; | |
143 | } | |
144 | ||
145 | void PrintableString::BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env) | |
146 | { | |
147 | AsnTag tag; | |
148 | AsnLen elmtLen1; | |
149 | ||
150 | if (((tag = BDecTag (b, bytesDecoded, env)) != MAKE_TAG_ID (UNIV, PRIM, PRINTABLESTRING_TAG_CODE)) | |
151 | && (tag != MAKE_TAG_ID (UNIV, CONS, PRINTABLESTRING_TAG_CODE))) | |
152 | { | |
153 | Asn1Error << "PrintableString::BDec: ERROR - wrong tag" << endl; | |
29654253 | 154 | SnaccExcep::throwMe(47); |
bac41a7b A |
155 | } |
156 | elmtLen1 = BDecLen (b, bytesDecoded, env); | |
157 | BDecContent (b, tag, elmtLen1, bytesDecoded, env); | |
158 | } | |
159 | ||
bac41a7b A |
160 | AsnType *TeletexString::Clone() const |
161 | { | |
162 | return new TeletexString; | |
163 | } | |
164 | ||
165 | AsnType *TeletexString::Copy() const | |
166 | { | |
167 | return new TeletexString (*this); | |
168 | } | |
169 | ||
170 | AsnLen TeletexString::BEnc (BUF_TYPE b) | |
171 | { | |
172 | AsnLen l; | |
173 | l = BEncContent (b); | |
174 | l += BEncDefLen (b, l); | |
175 | ||
176 | l += BEncTag1 (b, UNIV, PRIM, TELETEXSTRING_TAG_CODE); | |
177 | return l; | |
178 | } | |
179 | ||
180 | void TeletexString::BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env) | |
181 | { | |
182 | AsnTag tag; | |
183 | AsnLen elmtLen1; | |
184 | ||
185 | if (((tag = BDecTag (b, bytesDecoded, env)) != MAKE_TAG_ID (UNIV, PRIM, TELETEXSTRING_TAG_CODE)) | |
186 | && (tag != MAKE_TAG_ID (UNIV, CONS, TELETEXSTRING_TAG_CODE))) | |
187 | { | |
188 | Asn1Error << "TeletexString::BDec: ERROR - wrong tag" << endl; | |
29654253 | 189 | SnaccExcep::throwMe(46); |
bac41a7b A |
190 | } |
191 | elmtLen1 = BDecLen (b, bytesDecoded, env); | |
192 | BDecContent (b, tag, elmtLen1, bytesDecoded, env); | |
193 | } | |
194 | ||
bac41a7b A |
195 | AsnType *T61String::Clone() const |
196 | { | |
197 | return new T61String; | |
198 | } | |
199 | ||
200 | AsnType *T61String::Copy() const | |
201 | { | |
202 | return new T61String (*this); | |
203 | } | |
204 | ||
205 | AsnLen T61String::BEnc (BUF_TYPE b) | |
206 | { | |
207 | AsnLen l; | |
208 | l = BEncContent (b); | |
209 | l += BEncDefLen (b, l); | |
210 | ||
211 | l += BEncTag1 (b, UNIV, PRIM, TELETEXSTRING_TAG_CODE); | |
212 | return l; | |
213 | } | |
214 | ||
215 | void T61String::BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env) | |
216 | { | |
217 | AsnTag tag; | |
218 | AsnLen elmtLen1; | |
219 | ||
220 | if (((tag = BDecTag (b, bytesDecoded, env)) != MAKE_TAG_ID (UNIV, PRIM, TELETEXSTRING_TAG_CODE)) | |
221 | && (tag != MAKE_TAG_ID (UNIV, CONS, TELETEXSTRING_TAG_CODE))) | |
222 | { | |
223 | Asn1Error << "T61String::BDec: ERROR - wrong tag" << endl; | |
29654253 | 224 | SnaccExcep::throwMe(45); |
bac41a7b A |
225 | } |
226 | elmtLen1 = BDecLen (b, bytesDecoded, env); | |
227 | BDecContent (b, tag, elmtLen1, bytesDecoded, env); | |
228 | } | |
229 | ||
bac41a7b A |
230 | AsnType *VideotexString::Clone() const |
231 | { | |
232 | return new VideotexString; | |
233 | } | |
234 | ||
235 | AsnType *VideotexString::Copy() const | |
236 | { | |
237 | return new VideotexString (*this); | |
238 | } | |
239 | ||
240 | AsnLen VideotexString::BEnc (BUF_TYPE b) | |
241 | { | |
242 | AsnLen l; | |
243 | l = BEncContent (b); | |
244 | l += BEncDefLen (b, l); | |
245 | ||
246 | l += BEncTag1 (b, UNIV, PRIM, VIDEOTEXSTRING_TAG_CODE); | |
247 | return l; | |
248 | } | |
249 | ||
250 | void VideotexString::BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env) | |
251 | { | |
252 | AsnTag tag; | |
253 | AsnLen elmtLen1; | |
254 | ||
255 | if (((tag = BDecTag (b, bytesDecoded, env)) != MAKE_TAG_ID (UNIV, PRIM, VIDEOTEXSTRING_TAG_CODE)) | |
256 | && (tag != MAKE_TAG_ID (UNIV, CONS, VIDEOTEXSTRING_TAG_CODE))) | |
257 | { | |
258 | Asn1Error << "VideotexString::BDec: ERROR - wrong tag" << endl; | |
29654253 | 259 | SnaccExcep::throwMe(44); |
bac41a7b A |
260 | } |
261 | elmtLen1 = BDecLen (b, bytesDecoded, env); | |
262 | BDecContent (b, tag, elmtLen1, bytesDecoded, env); | |
263 | } | |
264 | ||
bac41a7b A |
265 | AsnType *IA5String::Clone() const |
266 | { | |
267 | return new IA5String; | |
268 | } | |
269 | ||
270 | AsnType *IA5String::Copy() const | |
271 | { | |
272 | return new IA5String (*this); | |
273 | } | |
274 | ||
275 | AsnLen IA5String::BEnc (BUF_TYPE b) | |
276 | { | |
277 | AsnLen l; | |
278 | l = BEncContent (b); | |
279 | l += BEncDefLen (b, l); | |
280 | ||
281 | l += BEncTag1 (b, UNIV, PRIM, IA5STRING_TAG_CODE); | |
282 | return l; | |
283 | } | |
284 | ||
285 | void IA5String::BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env) | |
286 | { | |
287 | AsnTag tag; | |
288 | AsnLen elmtLen1; | |
289 | ||
290 | if (((tag = BDecTag (b, bytesDecoded, env)) != MAKE_TAG_ID (UNIV, PRIM, IA5STRING_TAG_CODE)) | |
291 | && (tag != MAKE_TAG_ID (UNIV, CONS, IA5STRING_TAG_CODE))) | |
292 | { | |
293 | Asn1Error << "IA5String::BDec: ERROR - wrong tag" << endl; | |
29654253 | 294 | SnaccExcep::throwMe(43); |
bac41a7b A |
295 | } |
296 | elmtLen1 = BDecLen (b, bytesDecoded, env); | |
297 | BDecContent (b, tag, elmtLen1, bytesDecoded, env); | |
298 | } | |
299 | ||
bac41a7b A |
300 | AsnType *GraphicString::Clone() const |
301 | { | |
302 | return new GraphicString; | |
303 | } | |
304 | ||
305 | AsnType *GraphicString::Copy() const | |
306 | { | |
307 | return new GraphicString (*this); | |
308 | } | |
309 | ||
310 | AsnLen GraphicString::BEnc (BUF_TYPE b) | |
311 | { | |
312 | AsnLen l; | |
313 | l = BEncContent (b); | |
314 | l += BEncDefLen (b, l); | |
315 | ||
316 | l += BEncTag1 (b, UNIV, PRIM, GRAPHICSTRING_TAG_CODE); | |
317 | return l; | |
318 | } | |
319 | ||
320 | void GraphicString::BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env) | |
321 | { | |
322 | AsnTag tag; | |
323 | AsnLen elmtLen1; | |
324 | ||
325 | if (((tag = BDecTag (b, bytesDecoded, env)) != MAKE_TAG_ID (UNIV, PRIM, GRAPHICSTRING_TAG_CODE)) | |
326 | && (tag != MAKE_TAG_ID (UNIV, CONS, GRAPHICSTRING_TAG_CODE))) | |
327 | { | |
328 | Asn1Error << "GraphicString::BDec: ERROR - wrong tag" << endl; | |
29654253 | 329 | SnaccExcep::throwMe(42); |
bac41a7b A |
330 | } |
331 | elmtLen1 = BDecLen (b, bytesDecoded, env); | |
332 | BDecContent (b, tag, elmtLen1, bytesDecoded, env); | |
333 | } | |
334 | ||
bac41a7b A |
335 | AsnType *VisibleString::Clone() const |
336 | { | |
337 | return new VisibleString; | |
338 | } | |
339 | ||
340 | AsnType *VisibleString::Copy() const | |
341 | { | |
342 | return new VisibleString (*this); | |
343 | } | |
344 | ||
345 | AsnLen VisibleString::BEnc (BUF_TYPE b) | |
346 | { | |
347 | AsnLen l; | |
348 | l = BEncContent (b); | |
349 | l += BEncDefLen (b, l); | |
350 | ||
351 | l += BEncTag1 (b, UNIV, PRIM, VISIBLESTRING_TAG_CODE); | |
352 | return l; | |
353 | } | |
354 | ||
355 | void VisibleString::BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env) | |
356 | { | |
357 | AsnTag tag; | |
358 | AsnLen elmtLen1; | |
359 | ||
360 | if (((tag = BDecTag (b, bytesDecoded, env)) != MAKE_TAG_ID (UNIV, PRIM, VISIBLESTRING_TAG_CODE)) | |
361 | && (tag != MAKE_TAG_ID (UNIV, CONS, VISIBLESTRING_TAG_CODE))) | |
362 | { | |
363 | Asn1Error << "VisibleString::BDec: ERROR - wrong tag" << endl; | |
29654253 | 364 | SnaccExcep::throwMe(41); |
bac41a7b A |
365 | } |
366 | elmtLen1 = BDecLen (b, bytesDecoded, env); | |
367 | BDecContent (b, tag, elmtLen1, bytesDecoded, env); | |
368 | } | |
369 | ||
bac41a7b A |
370 | AsnType *ISO646String::Clone() const |
371 | { | |
372 | return new ISO646String; | |
373 | } | |
374 | ||
375 | AsnType *ISO646String::Copy() const | |
376 | { | |
377 | return new ISO646String (*this); | |
378 | } | |
379 | ||
380 | AsnLen ISO646String::BEnc (BUF_TYPE b) | |
381 | { | |
382 | AsnLen l; | |
383 | l = BEncContent (b); | |
384 | l += BEncDefLen (b, l); | |
385 | ||
386 | l += BEncTag1 (b, UNIV, PRIM, VISIBLESTRING_TAG_CODE); | |
387 | return l; | |
388 | } | |
389 | ||
390 | void ISO646String::BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env) | |
391 | { | |
392 | AsnTag tag; | |
393 | AsnLen elmtLen1; | |
394 | ||
395 | if (((tag = BDecTag (b, bytesDecoded, env)) != MAKE_TAG_ID (UNIV, PRIM, VISIBLESTRING_TAG_CODE)) | |
396 | && (tag != MAKE_TAG_ID (UNIV, CONS, VISIBLESTRING_TAG_CODE))) | |
397 | { | |
398 | Asn1Error << "ISO646String::BDec: ERROR - wrong tag" << endl; | |
29654253 | 399 | SnaccExcep::throwMe(40); |
bac41a7b A |
400 | } |
401 | elmtLen1 = BDecLen (b, bytesDecoded, env); | |
402 | BDecContent (b, tag, elmtLen1, bytesDecoded, env); | |
403 | } | |
404 | ||
bac41a7b A |
405 | AsnType *GeneralString::Clone() const |
406 | { | |
407 | return new GeneralString; | |
408 | } | |
409 | ||
410 | AsnType *GeneralString::Copy() const | |
411 | { | |
412 | return new GeneralString (*this); | |
413 | } | |
414 | ||
415 | AsnLen GeneralString::BEnc (BUF_TYPE b) | |
416 | { | |
417 | AsnLen l; | |
418 | l = BEncContent (b); | |
419 | l += BEncDefLen (b, l); | |
420 | ||
421 | l += BEncTag1 (b, UNIV, PRIM, GENERALSTRING_TAG_CODE); | |
422 | return l; | |
423 | } | |
424 | ||
425 | void GeneralString::BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env) | |
426 | { | |
427 | AsnTag tag; | |
428 | AsnLen elmtLen1; | |
429 | ||
430 | if (((tag = BDecTag (b, bytesDecoded, env)) != MAKE_TAG_ID (UNIV, PRIM, GENERALSTRING_TAG_CODE)) | |
431 | && (tag != MAKE_TAG_ID (UNIV, CONS, GENERALSTRING_TAG_CODE))) | |
432 | { | |
433 | Asn1Error << "GeneralString::BDec: ERROR - wrong tag" << endl; | |
29654253 | 434 | SnaccExcep::throwMe(39); |
bac41a7b A |
435 | } |
436 | elmtLen1 = BDecLen (b, bytesDecoded, env); | |
437 | BDecContent (b, tag, elmtLen1, bytesDecoded, env); | |
438 | } | |
439 | ||
bac41a7b A |
440 | AsnType *UTCTime::Clone() const |
441 | { | |
442 | return new UTCTime; | |
443 | } | |
444 | ||
445 | AsnType *UTCTime::Copy() const | |
446 | { | |
447 | return new UTCTime (*this); | |
448 | } | |
449 | ||
450 | AsnLen UTCTime::BEnc (BUF_TYPE b) | |
451 | { | |
452 | AsnLen l; | |
453 | l = BEncContent (b); | |
454 | l += BEncDefLen (b, l); | |
455 | ||
456 | l += BEncTag1 (b, UNIV, PRIM, UTCTIME_TAG_CODE); | |
457 | return l; | |
458 | } | |
459 | ||
460 | void UTCTime::BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env) | |
461 | { | |
462 | AsnTag tag; | |
463 | AsnLen elmtLen1; | |
464 | ||
465 | if (((tag = BDecTag (b, bytesDecoded, env)) != MAKE_TAG_ID (UNIV, PRIM, UTCTIME_TAG_CODE)) | |
466 | && (tag != MAKE_TAG_ID (UNIV, CONS, UTCTIME_TAG_CODE))) | |
467 | { | |
468 | Asn1Error << "UTCTime::BDec: ERROR - wrong tag" << endl; | |
29654253 | 469 | SnaccExcep::throwMe(38); |
bac41a7b A |
470 | } |
471 | elmtLen1 = BDecLen (b, bytesDecoded, env); | |
472 | BDecContent (b, tag, elmtLen1, bytesDecoded, env); | |
473 | } | |
474 | ||
bac41a7b A |
475 | AsnType *GeneralizedTime::Clone() const |
476 | { | |
477 | return new GeneralizedTime; | |
478 | } | |
479 | ||
480 | AsnType *GeneralizedTime::Copy() const | |
481 | { | |
482 | return new GeneralizedTime (*this); | |
483 | } | |
484 | ||
485 | AsnLen GeneralizedTime::BEnc (BUF_TYPE b) | |
486 | { | |
487 | AsnLen l; | |
488 | l = BEncContent (b); | |
489 | l += BEncDefLen (b, l); | |
490 | ||
491 | l += BEncTag1 (b, UNIV, PRIM, GENERALIZEDTIME_TAG_CODE); | |
492 | return l; | |
493 | } | |
494 | ||
495 | void GeneralizedTime::BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env) | |
496 | { | |
497 | AsnTag tag; | |
498 | AsnLen elmtLen1; | |
499 | ||
500 | if (((tag = BDecTag (b, bytesDecoded, env)) != MAKE_TAG_ID (UNIV, PRIM, GENERALIZEDTIME_TAG_CODE)) | |
501 | && (tag != MAKE_TAG_ID (UNIV, CONS, GENERALIZEDTIME_TAG_CODE))) | |
502 | { | |
503 | Asn1Error << "GeneralizedTime::BDec: ERROR - wrong tag" << endl; | |
29654253 | 504 | SnaccExcep::throwMe(37); |
bac41a7b A |
505 | } |
506 | elmtLen1 = BDecLen (b, bytesDecoded, env); | |
507 | BDecContent (b, tag, elmtLen1, bytesDecoded, env); | |
508 | } | |
509 | ||
bac41a7b A |
510 | AsnType *UniversalString::Clone() const |
511 | { | |
512 | return new UniversalString; | |
513 | } | |
514 | ||
515 | AsnType *UniversalString::Copy() const | |
516 | { | |
517 | return new UniversalString (*this); | |
518 | } | |
519 | ||
520 | AsnLen UniversalString::BEnc (BUF_TYPE b) | |
521 | { | |
522 | AsnLen l; | |
523 | l = BEncContent (b); | |
524 | l += BEncDefLen (b, l); | |
525 | ||
526 | l += BEncTag1 (b, UNIV, PRIM, UNIVERSALSTRING_TAG_CODE); | |
527 | return l; | |
528 | } | |
529 | ||
530 | void UniversalString::BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env) | |
531 | { | |
532 | AsnTag tag; | |
533 | AsnLen elmtLen1; | |
534 | ||
535 | if (((tag = BDecTag (b, bytesDecoded, env)) != MAKE_TAG_ID (UNIV, PRIM, UNIVERSALSTRING_TAG_CODE)) | |
536 | && (tag != MAKE_TAG_ID (UNIV, CONS, UNIVERSALSTRING_TAG_CODE))) | |
537 | { | |
538 | Asn1Error << "UniversalString::BDec: ERROR - wrong tag" << endl; | |
29654253 | 539 | SnaccExcep::throwMe(36); |
bac41a7b A |
540 | } |
541 | elmtLen1 = BDecLen (b, bytesDecoded, env); | |
542 | BDecContent (b, tag, elmtLen1, bytesDecoded, env); | |
543 | } | |
544 | ||
bac41a7b A |
545 | AsnType *BMPString::Clone() const |
546 | { | |
547 | return new BMPString; | |
548 | } | |
549 | ||
550 | AsnType *BMPString::Copy() const | |
551 | { | |
552 | return new BMPString (*this); | |
553 | } | |
554 | ||
555 | AsnLen BMPString::BEnc (BUF_TYPE b) | |
556 | { | |
557 | AsnLen l; | |
558 | l = BEncContent (b); | |
559 | l += BEncDefLen (b, l); | |
560 | ||
561 | l += BEncTag1 (b, UNIV, PRIM, BMPSTRING_TAG_CODE); | |
562 | return l; | |
563 | } | |
564 | ||
565 | void BMPString::BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env) | |
566 | { | |
567 | AsnTag tag; | |
568 | AsnLen elmtLen1; | |
569 | ||
570 | if (((tag = BDecTag (b, bytesDecoded, env)) != MAKE_TAG_ID (UNIV, PRIM, BMPSTRING_TAG_CODE)) | |
571 | && (tag != MAKE_TAG_ID (UNIV, CONS, BMPSTRING_TAG_CODE))) | |
572 | { | |
573 | Asn1Error << "BMPString::BDec: ERROR - wrong tag" << endl; | |
29654253 | 574 | SnaccExcep::throwMe(35); |
bac41a7b A |
575 | } |
576 | elmtLen1 = BDecLen (b, bytesDecoded, env); | |
577 | BDecContent (b, tag, elmtLen1, bytesDecoded, env); | |
578 | } | |
579 | ||
bac41a7b A |
580 | EXTERNALChoice::EXTERNALChoice() |
581 | { | |
582 | choiceId = single_ASN1_typeCid; | |
583 | #if TCL | |
584 | single_ASN1_type = new AsnOcts; | |
585 | #else | |
586 | single_ASN1_type = NULL; // incomplete initialization of mandatory element! | |
587 | #endif // TCL | |
588 | } | |
589 | ||
590 | EXTERNALChoice::EXTERNALChoice (const EXTERNALChoice &) | |
591 | { | |
592 | Asn1Error << "use of incompletely defined EXTERNALChoice::EXTERNALChoice (const EXTERNALChoice &)" << endl; | |
593 | abort(); | |
594 | } | |
595 | ||
596 | EXTERNALChoice::~EXTERNALChoice() | |
597 | { | |
598 | switch (choiceId) | |
599 | { | |
600 | case single_ASN1_typeCid: | |
601 | delete single_ASN1_type; | |
602 | break; | |
603 | case octet_alignedCid: | |
604 | delete octet_aligned; | |
605 | break; | |
606 | case arbitraryCid: | |
607 | delete arbitrary; | |
608 | break; | |
609 | } // end of switch | |
610 | } // end of destructor | |
611 | ||
612 | AsnType *EXTERNALChoice::Clone() const | |
613 | { | |
614 | return new EXTERNALChoice; | |
615 | } | |
616 | ||
617 | AsnType *EXTERNALChoice::Copy() const | |
618 | { | |
619 | return new EXTERNALChoice (*this); | |
620 | } | |
621 | ||
622 | #if SNACC_DEEP_COPY | |
623 | EXTERNALChoice &EXTERNALChoice::operator = (const EXTERNALChoice &that) | |
624 | #else // SNACC_DEEP_COPY | |
625 | EXTERNALChoice &EXTERNALChoice::operator = (const EXTERNALChoice &) | |
626 | #endif // SNACC_DEEP_COPY | |
627 | { | |
628 | #if SNACC_DEEP_COPY | |
629 | if (this != &that) | |
630 | { | |
631 | switch (choiceId) | |
632 | { | |
633 | case single_ASN1_typeCid: | |
634 | delete single_ASN1_type; | |
635 | break; | |
636 | case octet_alignedCid: | |
637 | delete octet_aligned; | |
638 | break; | |
639 | case arbitraryCid: | |
640 | delete arbitrary; | |
641 | break; | |
642 | } | |
643 | switch (choiceId = that.choiceId) | |
644 | { | |
645 | case single_ASN1_typeCid: | |
646 | single_ASN1_type = new AsnOcts; | |
647 | *single_ASN1_type = *that.single_ASN1_type; | |
648 | break; | |
649 | case octet_alignedCid: | |
650 | octet_aligned = new AsnOcts; | |
651 | *octet_aligned = *that.octet_aligned; | |
652 | break; | |
653 | case arbitraryCid: | |
654 | arbitrary = new AsnBits; | |
655 | *arbitrary = *that.arbitrary; | |
656 | break; | |
657 | } | |
658 | } | |
659 | ||
660 | return *this; | |
661 | #else // SNACC_DEEP_COPY | |
662 | Asn1Error << "use of incompletely defined EXTERNALChoice &EXTERNALChoice::operator = (const EXTERNALChoice &)" << endl; | |
663 | abort(); | |
664 | // if your compiler complains here, check the -novolat option | |
665 | #endif // SNACC_DEEP_COPY | |
666 | } | |
667 | ||
668 | AsnLen | |
669 | EXTERNALChoice::BEncContent (BUF_TYPE b) | |
670 | { | |
671 | AsnLen l; | |
672 | switch (choiceId) | |
673 | { | |
674 | case single_ASN1_typeCid: | |
675 | BEncEocIfNec (b); | |
676 | l = single_ASN1_type->BEncContent (b); | |
677 | l += BEncDefLen (b, l); | |
678 | ||
679 | l += BEncTag1 (b, UNIV, PRIM, OCTETSTRING_TAG_CODE); | |
680 | l += BEncConsLen (b, l); | |
681 | ||
682 | l += BEncTag1 (b, CNTX, CONS, 0); | |
683 | break; | |
684 | ||
685 | case octet_alignedCid: | |
686 | l = octet_aligned->BEncContent (b); | |
687 | l += BEncDefLen (b, l); | |
688 | ||
689 | l += BEncTag1 (b, CNTX, PRIM, 1); | |
690 | break; | |
691 | ||
692 | case arbitraryCid: | |
693 | l = arbitrary->BEncContent (b); | |
694 | l += BEncDefLen (b, l); | |
695 | ||
696 | l += BEncTag1 (b, CNTX, PRIM, 2); | |
697 | break; | |
698 | ||
699 | } // end switch | |
700 | return l; | |
701 | } // EXTERNALChoice::BEncContent | |
702 | ||
703 | ||
704 | void EXTERNALChoice::BDecContent (BUF_TYPE b, AsnTag tag, AsnLen elmtLen0, AsnLen &bytesDecoded, ENV_TYPE env) | |
705 | { | |
706 | AsnLen elmtLen1; | |
707 | switch (tag) | |
708 | { | |
709 | case MAKE_TAG_ID (CNTX, CONS, 0): | |
710 | tag = BDecTag (b, bytesDecoded, env); | |
711 | if ((tag != MAKE_TAG_ID (UNIV, PRIM, OCTETSTRING_TAG_CODE)) | |
712 | && (tag != MAKE_TAG_ID (UNIV, CONS, OCTETSTRING_TAG_CODE))) | |
713 | { | |
714 | Asn1Error << "Unexpected Tag" << endl; | |
29654253 | 715 | SnaccExcep::throwMe(34); |
bac41a7b A |
716 | } |
717 | ||
718 | elmtLen1 = BDecLen (b, bytesDecoded, env); | |
719 | choiceId = single_ASN1_typeCid; | |
720 | single_ASN1_type = new AsnOcts; | |
721 | single_ASN1_type->BDecContent (b, tag, elmtLen1, bytesDecoded, env); | |
722 | if (elmtLen0 == INDEFINITE_LEN) | |
723 | BDecEoc (b, bytesDecoded, env); | |
724 | break; | |
725 | ||
726 | case MAKE_TAG_ID (CNTX, PRIM, 1): | |
727 | case MAKE_TAG_ID (CNTX, CONS, 1): | |
728 | choiceId = octet_alignedCid; | |
729 | octet_aligned = new AsnOcts; | |
730 | octet_aligned->BDecContent (b, tag, elmtLen0, bytesDecoded, env); | |
731 | break; | |
732 | ||
733 | case MAKE_TAG_ID (CNTX, PRIM, 2): | |
734 | case MAKE_TAG_ID (CNTX, CONS, 2): | |
735 | choiceId = arbitraryCid; | |
736 | arbitrary = new AsnBits; | |
737 | arbitrary->BDecContent (b, tag, elmtLen0, bytesDecoded, env); | |
738 | break; | |
739 | ||
740 | default: | |
741 | Asn1Error << "ERROR - unexpected tag in CHOICE" << endl; | |
29654253 | 742 | SnaccExcep::throwMe(33); |
bac41a7b A |
743 | break; |
744 | } // end switch | |
745 | } // EXTERNALChoice::BDecContent | |
746 | ||
747 | ||
748 | AsnLen EXTERNALChoice::BEnc (BUF_TYPE b) | |
749 | { | |
750 | AsnLen l; | |
751 | l = BEncContent (b); | |
752 | return l; | |
753 | } | |
754 | ||
755 | void EXTERNALChoice::BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env) | |
756 | { | |
757 | AsnLen elmtLen; | |
758 | AsnTag tag; | |
759 | ||
760 | /* CHOICEs are a special case - grab identifying tag */ | |
761 | /* this allows easier handling of nested CHOICEs */ | |
762 | tag = BDecTag (b, bytesDecoded, env); | |
763 | elmtLen = BDecLen (b, bytesDecoded, env); | |
764 | BDecContent (b, tag, elmtLen, bytesDecoded, env); | |
765 | } | |
766 | ||
bac41a7b A |
767 | void EXTERNALChoice::Print (ostream &os) const |
768 | { | |
29654253 | 769 | #ifndef NDEBUG |
bac41a7b A |
770 | switch (choiceId) |
771 | { | |
772 | case single_ASN1_typeCid: | |
773 | os << "single-ASN1-type "; | |
774 | if (single_ASN1_type) | |
775 | os << *single_ASN1_type; | |
776 | else | |
777 | os << "-- void3 --\n"; | |
778 | break; | |
779 | ||
780 | case octet_alignedCid: | |
781 | os << "octet-aligned "; | |
782 | if (octet_aligned) | |
783 | os << *octet_aligned; | |
784 | else | |
785 | os << "-- void3 --\n"; | |
786 | break; | |
787 | ||
788 | case arbitraryCid: | |
789 | os << "arbitrary "; | |
790 | if (arbitrary) | |
791 | os << *arbitrary; | |
792 | else | |
793 | os << "-- void3 --\n"; | |
794 | break; | |
795 | ||
796 | } // end of switch | |
29654253 | 797 | #endif /* NDEBUG */ |
bac41a7b A |
798 | } // EXTERNALChoice::Print |
799 | ||
800 | EXTERNAL::EXTERNAL() | |
801 | { | |
802 | direct_reference = NULL; | |
803 | indirect_reference = NULL; | |
804 | data_value_descriptor = NULL; | |
805 | #if TCL | |
806 | encoding = new EXTERNALChoice; | |
807 | #else | |
808 | encoding = NULL; // incomplete initialization of mandatory element! | |
809 | #endif // TCL | |
810 | } | |
811 | ||
812 | EXTERNAL::EXTERNAL (const EXTERNAL &) | |
813 | { | |
814 | Asn1Error << "use of incompletely defined EXTERNAL::EXTERNAL (const EXTERNAL &)" << endl; | |
815 | abort(); | |
816 | } | |
817 | ||
818 | EXTERNAL::~EXTERNAL() | |
819 | { | |
820 | delete direct_reference; | |
821 | delete indirect_reference; | |
822 | delete data_value_descriptor; | |
823 | delete encoding; | |
824 | } | |
825 | ||
826 | AsnType *EXTERNAL::Clone() const | |
827 | { | |
828 | return new EXTERNAL; | |
829 | } | |
830 | ||
831 | AsnType *EXTERNAL::Copy() const | |
832 | { | |
833 | return new EXTERNAL (*this); | |
834 | } | |
835 | ||
836 | #if SNACC_DEEP_COPY | |
837 | EXTERNAL &EXTERNAL::operator = (const EXTERNAL &that) | |
838 | #else // SNACC_DEEP_COPY | |
839 | EXTERNAL &EXTERNAL::operator = (const EXTERNAL &) | |
840 | #endif // SNACC_DEEP_COPY | |
841 | { | |
842 | #if SNACC_DEEP_COPY | |
843 | if (this != &that) | |
844 | { | |
845 | if (that.direct_reference) | |
846 | { | |
847 | if (!direct_reference) | |
848 | direct_reference = new AsnOid; | |
849 | *direct_reference = *that.direct_reference; | |
850 | } | |
851 | else | |
852 | { | |
853 | delete direct_reference; | |
854 | direct_reference = NULL; | |
855 | } | |
856 | if (that.indirect_reference) | |
857 | { | |
858 | if (!indirect_reference) | |
859 | indirect_reference = new AsnInt; | |
860 | *indirect_reference = *that.indirect_reference; | |
861 | } | |
862 | else | |
863 | { | |
864 | delete indirect_reference; | |
865 | indirect_reference = NULL; | |
866 | } | |
867 | if (that.data_value_descriptor) | |
868 | { | |
869 | if (!data_value_descriptor) | |
870 | data_value_descriptor = new ObjectDescriptor; | |
871 | *data_value_descriptor = *that.data_value_descriptor; | |
872 | } | |
873 | else | |
874 | { | |
875 | delete data_value_descriptor; | |
876 | data_value_descriptor = NULL; | |
877 | } | |
878 | if (that.encoding) | |
879 | { | |
880 | if (!encoding) | |
881 | encoding = new EXTERNALChoice; | |
882 | *encoding = *that.encoding; | |
883 | } | |
884 | else | |
885 | { | |
886 | delete encoding; | |
887 | encoding = NULL; | |
888 | } | |
889 | } | |
890 | ||
891 | return *this; | |
892 | #else // SNACC_DEEP_COPY | |
893 | Asn1Error << "use of incompletely defined EXTERNAL &EXTERNAL::operator = (const EXTERNAL &)" << endl; | |
894 | abort(); | |
895 | // if your compiler complains here, check the -novolat option | |
896 | #endif // SNACC_DEEP_COPY | |
897 | } | |
898 | ||
899 | AsnLen | |
900 | EXTERNAL::BEncContent (BUF_TYPE b) | |
901 | { | |
902 | AsnLen totalLen = 0; | |
903 | AsnLen l; | |
904 | ||
905 | l = encoding->BEncContent (b); | |
906 | totalLen += l; | |
907 | ||
908 | if (NOT_NULL (data_value_descriptor)) | |
909 | { | |
910 | l = data_value_descriptor->BEncContent (b); | |
911 | l += BEncDefLen (b, l); | |
912 | ||
913 | l += BEncTag1 (b, UNIV, PRIM, OD_TAG_CODE); | |
914 | totalLen += l; | |
915 | } | |
916 | ||
917 | if (NOT_NULL (indirect_reference)) | |
918 | { | |
919 | l = indirect_reference->BEncContent (b); | |
920 | BEncDefLenTo127 (b, l); | |
921 | l++; | |
922 | ||
923 | l += BEncTag1 (b, UNIV, PRIM, INTEGER_TAG_CODE); | |
924 | totalLen += l; | |
925 | } | |
926 | ||
927 | if (NOT_NULL (direct_reference)) | |
928 | { | |
929 | l = direct_reference->BEncContent (b); | |
930 | l += BEncDefLen (b, l); | |
931 | ||
932 | l += BEncTag1 (b, UNIV, PRIM, OID_TAG_CODE); | |
933 | totalLen += l; | |
934 | } | |
935 | ||
936 | return totalLen; | |
937 | } // EXTERNAL::BEncContent | |
938 | ||
939 | ||
940 | void EXTERNAL::BDecContent (BUF_TYPE b, AsnTag /*tag0*/, AsnLen elmtLen0, AsnLen &bytesDecoded, ENV_TYPE env) | |
941 | { | |
942 | AsnTag tag1; | |
943 | AsnLen seqBytesDecoded = 0; | |
944 | AsnLen elmtLen1; | |
945 | tag1 = BDecTag (b, seqBytesDecoded, env); | |
946 | ||
947 | if ((tag1 == MAKE_TAG_ID (UNIV, PRIM, OID_TAG_CODE))) | |
948 | { | |
949 | elmtLen1 = BDecLen (b, seqBytesDecoded, env); | |
950 | direct_reference = new AsnOid; | |
951 | direct_reference->BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env); | |
952 | tag1 = BDecTag (b, seqBytesDecoded, env); | |
953 | } | |
954 | ||
955 | if ((tag1 == MAKE_TAG_ID (UNIV, PRIM, INTEGER_TAG_CODE))) | |
956 | { | |
957 | elmtLen1 = BDecLen (b, seqBytesDecoded, env); | |
958 | indirect_reference = new AsnInt; | |
959 | indirect_reference->BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env); | |
960 | tag1 = BDecTag (b, seqBytesDecoded, env); | |
961 | } | |
962 | ||
963 | if ((tag1 == MAKE_TAG_ID (UNIV, PRIM, OD_TAG_CODE)) | |
964 | || (tag1 == MAKE_TAG_ID (UNIV, CONS, OD_TAG_CODE))) | |
965 | { | |
966 | elmtLen1 = BDecLen (b, seqBytesDecoded, env); | |
967 | data_value_descriptor = new ObjectDescriptor; | |
968 | data_value_descriptor->BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env); | |
969 | tag1 = BDecTag (b, seqBytesDecoded, env); | |
970 | } | |
971 | ||
972 | if ((tag1 == MAKE_TAG_ID (CNTX, CONS, 0)) | |
973 | || (tag1 == MAKE_TAG_ID (CNTX, PRIM, 1)) | |
974 | || (tag1 == MAKE_TAG_ID (CNTX, CONS, 1)) | |
975 | || (tag1 == MAKE_TAG_ID (CNTX, PRIM, 2)) | |
976 | || (tag1 == MAKE_TAG_ID (CNTX, CONS, 2))) | |
977 | { | |
978 | elmtLen1 = BDecLen (b, seqBytesDecoded, env); | |
979 | encoding = new EXTERNALChoice; | |
980 | encoding->BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env); | |
981 | } | |
982 | else | |
983 | { | |
984 | Asn1Error << "ERROR - SEQUENCE is missing non-optional elmt." << endl; | |
29654253 | 985 | SnaccExcep::throwMe(32); |
bac41a7b A |
986 | } |
987 | ||
988 | bytesDecoded += seqBytesDecoded; | |
989 | if (elmtLen0 == INDEFINITE_LEN) | |
990 | { | |
991 | BDecEoc (b, bytesDecoded, env); | |
992 | return; | |
993 | } | |
994 | else if (seqBytesDecoded != elmtLen0) | |
995 | { | |
996 | Asn1Error << "ERROR - Length discrepancy on sequence." << endl; | |
29654253 | 997 | SnaccExcep::throwMe(31); |
bac41a7b A |
998 | } |
999 | else | |
1000 | return; | |
1001 | } // EXTERNAL::BDecContent | |
1002 | ||
1003 | AsnLen EXTERNAL::BEnc (BUF_TYPE b) | |
1004 | { | |
1005 | AsnLen l; | |
1006 | l = BEncContent (b); | |
1007 | l += BEncConsLen (b, l); | |
1008 | l += BEncTag1 (b, UNIV, CONS, EXTERNAL_TAG_CODE); | |
1009 | return l; | |
1010 | } | |
1011 | ||
1012 | void EXTERNAL::BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env) | |
1013 | { | |
1014 | AsnTag tag; | |
1015 | AsnLen elmtLen1; | |
1016 | ||
1017 | if ((tag = BDecTag (b, bytesDecoded, env)) != MAKE_TAG_ID (UNIV, CONS, EXTERNAL_TAG_CODE)) | |
1018 | { | |
1019 | Asn1Error << "EXTERNAL::BDec: ERROR - wrong tag" << endl; | |
29654253 | 1020 | SnaccExcep::throwMe(30); |
bac41a7b A |
1021 | } |
1022 | elmtLen1 = BDecLen (b, bytesDecoded, env); | |
1023 | BDecContent (b, tag, elmtLen1, bytesDecoded, env); | |
1024 | } | |
1025 | ||
bac41a7b A |
1026 | void EXTERNAL::Print (ostream &os) const |
1027 | { | |
29654253 | 1028 | #ifndef NDEBUG |
bac41a7b A |
1029 | os << "{ -- SEQUENCE --" << endl; |
1030 | indentG += stdIndentG; | |
1031 | ||
1032 | if (NOT_NULL (direct_reference)) | |
1033 | { | |
1034 | Indent (os, indentG); | |
1035 | os << "direct-reference "; | |
1036 | os << *direct_reference; | |
1037 | } | |
1038 | else | |
1039 | { | |
1040 | Indent (os, indentG); | |
1041 | os << "direct-reference "; | |
1042 | os << "-- void --"; | |
1043 | os << "," << endl; | |
1044 | } | |
1045 | ||
1046 | if (NOT_NULL (indirect_reference)) | |
1047 | { | |
1048 | Indent (os, indentG); | |
1049 | os << "indirect-reference "; | |
1050 | os << *indirect_reference; | |
1051 | } | |
1052 | else | |
1053 | { | |
1054 | Indent (os, indentG); | |
1055 | os << "indirect-reference "; | |
1056 | os << "-- void --"; | |
1057 | os << "," << endl; | |
1058 | } | |
1059 | ||
1060 | if (NOT_NULL (data_value_descriptor)) | |
1061 | { | |
1062 | Indent (os, indentG); | |
1063 | os << "data-value-descriptor "; | |
1064 | os << *data_value_descriptor; | |
1065 | } | |
1066 | else | |
1067 | { | |
1068 | Indent (os, indentG); | |
1069 | os << "data-value-descriptor "; | |
1070 | os << "-- void --"; | |
1071 | os << "," << endl; | |
1072 | } | |
1073 | ||
1074 | if (NOT_NULL (encoding)) | |
1075 | { | |
1076 | Indent (os, indentG); | |
1077 | os << "encoding "; | |
1078 | os << *encoding; | |
1079 | } | |
1080 | else | |
1081 | { | |
1082 | Indent (os, indentG); | |
1083 | os << "encoding "; | |
1084 | os << "-- void --"; | |
1085 | os << endl; | |
1086 | } | |
1087 | ||
1088 | os << endl; | |
1089 | indentG -= stdIndentG; | |
1090 | Indent (os, indentG); | |
1091 | os << "}"; | |
29654253 | 1092 | #endif /* NDEBUG */ |
bac41a7b A |
1093 | } // EXTERNAL::Print |
1094 | ||
1095 |