]>
git.saurik.com Git - apple/security.git/blob - SecuritySNACCRuntime/c++-lib/src/asn-useful.cpp
3e53655b3b6124601edcb8a5c8e887bee3e35700
1 // NOTE: this is a machine generated file--editing not recommended
3 // asn-useful.cpp - class member functions for ASN.1 module ASN-USEFUL
5 // This file was generated by snacc on Wed Mar 20 11:39:57 2002
6 // UBC snacc written by Mike Sample
7 // A couple of enhancements made by IBM European Networking Center
11 #include "asn-useful.h"
13 //------------------------------------------------------------------------------
17 //------------------------------------------------------------------------------
18 // class member definitions:
20 AsnType
*ObjectDescriptor::Clone() const
22 return new ObjectDescriptor
;
25 AsnType
*ObjectDescriptor::Copy() const
27 return new ObjectDescriptor (*this);
30 AsnLen
ObjectDescriptor::BEnc (BUF_TYPE b
)
34 l
+= BEncDefLen (b
, l
);
36 l
+= BEncTag1 (b
, UNIV
, PRIM
, OD_TAG_CODE
);
40 void ObjectDescriptor::BDec (BUF_TYPE b
, AsnLen
&bytesDecoded
, ENV_TYPE env
)
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
)))
48 Asn1Error
<< "ObjectDescriptor::BDec: ERROR - wrong tag" << endl
;
49 SnaccExcep::throwMe(50);
51 elmtLen1
= BDecLen (b
, bytesDecoded
, env
);
52 BDecContent (b
, tag
, elmtLen1
, bytesDecoded
, env
);
55 AsnType
*UTF8String::Clone() const
57 return new UTF8String
;
60 AsnType
*UTF8String::Copy() const
62 return new UTF8String (*this);
65 AsnLen
UTF8String::BEnc (BUF_TYPE b
)
69 l
+= BEncDefLen (b
, l
);
71 l
+= BEncTag1 (b
, UNIV
, PRIM
, 12);
75 void UTF8String::BDec (BUF_TYPE b
, AsnLen
&bytesDecoded
, ENV_TYPE env
)
80 if (((tag
= BDecTag (b
, bytesDecoded
, env
)) != MAKE_TAG_ID (UNIV
, PRIM
, 12))
81 && (tag
!= MAKE_TAG_ID (UNIV
, CONS
, 12)))
83 Asn1Error
<< "UTF8String::BDec: ERROR - wrong tag" << endl
;
84 SnaccExcep::throwMe(49);
86 elmtLen1
= BDecLen (b
, bytesDecoded
, env
);
87 BDecContent (b
, tag
, elmtLen1
, bytesDecoded
, env
);
90 AsnType
*NumericString::Clone() const
92 return new NumericString
;
95 AsnType
*NumericString::Copy() const
97 return new NumericString (*this);
100 AsnLen
NumericString::BEnc (BUF_TYPE b
)
104 l
+= BEncDefLen (b
, l
);
106 l
+= BEncTag1 (b
, UNIV
, PRIM
, NUMERICSTRING_TAG_CODE
);
110 void NumericString::BDec (BUF_TYPE b
, AsnLen
&bytesDecoded
, ENV_TYPE env
)
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
)))
118 Asn1Error
<< "NumericString::BDec: ERROR - wrong tag" << endl
;
119 SnaccExcep::throwMe(48);
121 elmtLen1
= BDecLen (b
, bytesDecoded
, env
);
122 BDecContent (b
, tag
, elmtLen1
, bytesDecoded
, env
);
125 AsnType
*PrintableString::Clone() const
127 return new PrintableString
;
130 AsnType
*PrintableString::Copy() const
132 return new PrintableString (*this);
135 AsnLen
PrintableString::BEnc (BUF_TYPE b
)
139 l
+= BEncDefLen (b
, l
);
141 l
+= BEncTag1 (b
, UNIV
, PRIM
, PRINTABLESTRING_TAG_CODE
);
145 void PrintableString::BDec (BUF_TYPE b
, AsnLen
&bytesDecoded
, ENV_TYPE env
)
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
)))
153 Asn1Error
<< "PrintableString::BDec: ERROR - wrong tag" << endl
;
154 SnaccExcep::throwMe(47);
156 elmtLen1
= BDecLen (b
, bytesDecoded
, env
);
157 BDecContent (b
, tag
, elmtLen1
, bytesDecoded
, env
);
160 AsnType
*TeletexString::Clone() const
162 return new TeletexString
;
165 AsnType
*TeletexString::Copy() const
167 return new TeletexString (*this);
170 AsnLen
TeletexString::BEnc (BUF_TYPE b
)
174 l
+= BEncDefLen (b
, l
);
176 l
+= BEncTag1 (b
, UNIV
, PRIM
, TELETEXSTRING_TAG_CODE
);
180 void TeletexString::BDec (BUF_TYPE b
, AsnLen
&bytesDecoded
, ENV_TYPE env
)
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
)))
188 Asn1Error
<< "TeletexString::BDec: ERROR - wrong tag" << endl
;
189 SnaccExcep::throwMe(46);
191 elmtLen1
= BDecLen (b
, bytesDecoded
, env
);
192 BDecContent (b
, tag
, elmtLen1
, bytesDecoded
, env
);
195 AsnType
*T61String::Clone() const
197 return new T61String
;
200 AsnType
*T61String::Copy() const
202 return new T61String (*this);
205 AsnLen
T61String::BEnc (BUF_TYPE b
)
209 l
+= BEncDefLen (b
, l
);
211 l
+= BEncTag1 (b
, UNIV
, PRIM
, TELETEXSTRING_TAG_CODE
);
215 void T61String::BDec (BUF_TYPE b
, AsnLen
&bytesDecoded
, ENV_TYPE env
)
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
)))
223 Asn1Error
<< "T61String::BDec: ERROR - wrong tag" << endl
;
224 SnaccExcep::throwMe(45);
226 elmtLen1
= BDecLen (b
, bytesDecoded
, env
);
227 BDecContent (b
, tag
, elmtLen1
, bytesDecoded
, env
);
230 AsnType
*VideotexString::Clone() const
232 return new VideotexString
;
235 AsnType
*VideotexString::Copy() const
237 return new VideotexString (*this);
240 AsnLen
VideotexString::BEnc (BUF_TYPE b
)
244 l
+= BEncDefLen (b
, l
);
246 l
+= BEncTag1 (b
, UNIV
, PRIM
, VIDEOTEXSTRING_TAG_CODE
);
250 void VideotexString::BDec (BUF_TYPE b
, AsnLen
&bytesDecoded
, ENV_TYPE env
)
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
)))
258 Asn1Error
<< "VideotexString::BDec: ERROR - wrong tag" << endl
;
259 SnaccExcep::throwMe(44);
261 elmtLen1
= BDecLen (b
, bytesDecoded
, env
);
262 BDecContent (b
, tag
, elmtLen1
, bytesDecoded
, env
);
265 AsnType
*IA5String::Clone() const
267 return new IA5String
;
270 AsnType
*IA5String::Copy() const
272 return new IA5String (*this);
275 AsnLen
IA5String::BEnc (BUF_TYPE b
)
279 l
+= BEncDefLen (b
, l
);
281 l
+= BEncTag1 (b
, UNIV
, PRIM
, IA5STRING_TAG_CODE
);
285 void IA5String::BDec (BUF_TYPE b
, AsnLen
&bytesDecoded
, ENV_TYPE env
)
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
)))
293 Asn1Error
<< "IA5String::BDec: ERROR - wrong tag" << endl
;
294 SnaccExcep::throwMe(43);
296 elmtLen1
= BDecLen (b
, bytesDecoded
, env
);
297 BDecContent (b
, tag
, elmtLen1
, bytesDecoded
, env
);
300 AsnType
*GraphicString::Clone() const
302 return new GraphicString
;
305 AsnType
*GraphicString::Copy() const
307 return new GraphicString (*this);
310 AsnLen
GraphicString::BEnc (BUF_TYPE b
)
314 l
+= BEncDefLen (b
, l
);
316 l
+= BEncTag1 (b
, UNIV
, PRIM
, GRAPHICSTRING_TAG_CODE
);
320 void GraphicString::BDec (BUF_TYPE b
, AsnLen
&bytesDecoded
, ENV_TYPE env
)
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
)))
328 Asn1Error
<< "GraphicString::BDec: ERROR - wrong tag" << endl
;
329 SnaccExcep::throwMe(42);
331 elmtLen1
= BDecLen (b
, bytesDecoded
, env
);
332 BDecContent (b
, tag
, elmtLen1
, bytesDecoded
, env
);
335 AsnType
*VisibleString::Clone() const
337 return new VisibleString
;
340 AsnType
*VisibleString::Copy() const
342 return new VisibleString (*this);
345 AsnLen
VisibleString::BEnc (BUF_TYPE b
)
349 l
+= BEncDefLen (b
, l
);
351 l
+= BEncTag1 (b
, UNIV
, PRIM
, VISIBLESTRING_TAG_CODE
);
355 void VisibleString::BDec (BUF_TYPE b
, AsnLen
&bytesDecoded
, ENV_TYPE env
)
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
)))
363 Asn1Error
<< "VisibleString::BDec: ERROR - wrong tag" << endl
;
364 SnaccExcep::throwMe(41);
366 elmtLen1
= BDecLen (b
, bytesDecoded
, env
);
367 BDecContent (b
, tag
, elmtLen1
, bytesDecoded
, env
);
370 AsnType
*ISO646String::Clone() const
372 return new ISO646String
;
375 AsnType
*ISO646String::Copy() const
377 return new ISO646String (*this);
380 AsnLen
ISO646String::BEnc (BUF_TYPE b
)
384 l
+= BEncDefLen (b
, l
);
386 l
+= BEncTag1 (b
, UNIV
, PRIM
, VISIBLESTRING_TAG_CODE
);
390 void ISO646String::BDec (BUF_TYPE b
, AsnLen
&bytesDecoded
, ENV_TYPE env
)
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
)))
398 Asn1Error
<< "ISO646String::BDec: ERROR - wrong tag" << endl
;
399 SnaccExcep::throwMe(40);
401 elmtLen1
= BDecLen (b
, bytesDecoded
, env
);
402 BDecContent (b
, tag
, elmtLen1
, bytesDecoded
, env
);
405 AsnType
*GeneralString::Clone() const
407 return new GeneralString
;
410 AsnType
*GeneralString::Copy() const
412 return new GeneralString (*this);
415 AsnLen
GeneralString::BEnc (BUF_TYPE b
)
419 l
+= BEncDefLen (b
, l
);
421 l
+= BEncTag1 (b
, UNIV
, PRIM
, GENERALSTRING_TAG_CODE
);
425 void GeneralString::BDec (BUF_TYPE b
, AsnLen
&bytesDecoded
, ENV_TYPE env
)
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
)))
433 Asn1Error
<< "GeneralString::BDec: ERROR - wrong tag" << endl
;
434 SnaccExcep::throwMe(39);
436 elmtLen1
= BDecLen (b
, bytesDecoded
, env
);
437 BDecContent (b
, tag
, elmtLen1
, bytesDecoded
, env
);
440 AsnType
*UTCTime::Clone() const
445 AsnType
*UTCTime::Copy() const
447 return new UTCTime (*this);
450 AsnLen
UTCTime::BEnc (BUF_TYPE b
)
454 l
+= BEncDefLen (b
, l
);
456 l
+= BEncTag1 (b
, UNIV
, PRIM
, UTCTIME_TAG_CODE
);
460 void UTCTime::BDec (BUF_TYPE b
, AsnLen
&bytesDecoded
, ENV_TYPE env
)
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
)))
468 Asn1Error
<< "UTCTime::BDec: ERROR - wrong tag" << endl
;
469 SnaccExcep::throwMe(38);
471 elmtLen1
= BDecLen (b
, bytesDecoded
, env
);
472 BDecContent (b
, tag
, elmtLen1
, bytesDecoded
, env
);
475 AsnType
*GeneralizedTime::Clone() const
477 return new GeneralizedTime
;
480 AsnType
*GeneralizedTime::Copy() const
482 return new GeneralizedTime (*this);
485 AsnLen
GeneralizedTime::BEnc (BUF_TYPE b
)
489 l
+= BEncDefLen (b
, l
);
491 l
+= BEncTag1 (b
, UNIV
, PRIM
, GENERALIZEDTIME_TAG_CODE
);
495 void GeneralizedTime::BDec (BUF_TYPE b
, AsnLen
&bytesDecoded
, ENV_TYPE env
)
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
)))
503 Asn1Error
<< "GeneralizedTime::BDec: ERROR - wrong tag" << endl
;
504 SnaccExcep::throwMe(37);
506 elmtLen1
= BDecLen (b
, bytesDecoded
, env
);
507 BDecContent (b
, tag
, elmtLen1
, bytesDecoded
, env
);
510 AsnType
*UniversalString::Clone() const
512 return new UniversalString
;
515 AsnType
*UniversalString::Copy() const
517 return new UniversalString (*this);
520 AsnLen
UniversalString::BEnc (BUF_TYPE b
)
524 l
+= BEncDefLen (b
, l
);
526 l
+= BEncTag1 (b
, UNIV
, PRIM
, UNIVERSALSTRING_TAG_CODE
);
530 void UniversalString::BDec (BUF_TYPE b
, AsnLen
&bytesDecoded
, ENV_TYPE env
)
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
)))
538 Asn1Error
<< "UniversalString::BDec: ERROR - wrong tag" << endl
;
539 SnaccExcep::throwMe(36);
541 elmtLen1
= BDecLen (b
, bytesDecoded
, env
);
542 BDecContent (b
, tag
, elmtLen1
, bytesDecoded
, env
);
545 AsnType
*BMPString::Clone() const
547 return new BMPString
;
550 AsnType
*BMPString::Copy() const
552 return new BMPString (*this);
555 AsnLen
BMPString::BEnc (BUF_TYPE b
)
559 l
+= BEncDefLen (b
, l
);
561 l
+= BEncTag1 (b
, UNIV
, PRIM
, BMPSTRING_TAG_CODE
);
565 void BMPString::BDec (BUF_TYPE b
, AsnLen
&bytesDecoded
, ENV_TYPE env
)
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
)))
573 Asn1Error
<< "BMPString::BDec: ERROR - wrong tag" << endl
;
574 SnaccExcep::throwMe(35);
576 elmtLen1
= BDecLen (b
, bytesDecoded
, env
);
577 BDecContent (b
, tag
, elmtLen1
, bytesDecoded
, env
);
580 EXTERNALChoice::EXTERNALChoice()
582 choiceId
= single_ASN1_typeCid
;
584 single_ASN1_type
= new AsnOcts
;
586 single_ASN1_type
= NULL
; // incomplete initialization of mandatory element!
590 EXTERNALChoice::EXTERNALChoice (const EXTERNALChoice
&)
592 Asn1Error
<< "use of incompletely defined EXTERNALChoice::EXTERNALChoice (const EXTERNALChoice &)" << endl
;
596 EXTERNALChoice::~EXTERNALChoice()
600 case single_ASN1_typeCid
:
601 delete single_ASN1_type
;
603 case octet_alignedCid
:
604 delete octet_aligned
;
610 } // end of destructor
612 AsnType
*EXTERNALChoice::Clone() const
614 return new EXTERNALChoice
;
617 AsnType
*EXTERNALChoice::Copy() const
619 return new EXTERNALChoice (*this);
623 EXTERNALChoice
&EXTERNALChoice::operator = (const EXTERNALChoice
&that
)
624 #else // SNACC_DEEP_COPY
625 EXTERNALChoice
&EXTERNALChoice::operator = (const EXTERNALChoice
&)
626 #endif // SNACC_DEEP_COPY
633 case single_ASN1_typeCid
:
634 delete single_ASN1_type
;
636 case octet_alignedCid
:
637 delete octet_aligned
;
643 switch (choiceId
= that
.choiceId
)
645 case single_ASN1_typeCid
:
646 single_ASN1_type
= new AsnOcts
;
647 *single_ASN1_type
= *that
.single_ASN1_type
;
649 case octet_alignedCid
:
650 octet_aligned
= new AsnOcts
;
651 *octet_aligned
= *that
.octet_aligned
;
654 arbitrary
= new AsnBits
;
655 *arbitrary
= *that
.arbitrary
;
661 #else // SNACC_DEEP_COPY
662 Asn1Error
<< "use of incompletely defined EXTERNALChoice &EXTERNALChoice::operator = (const EXTERNALChoice &)" << endl
;
664 // if your compiler complains here, check the -novolat option
665 #endif // SNACC_DEEP_COPY
669 EXTERNALChoice::BEncContent (BUF_TYPE b
)
674 case single_ASN1_typeCid
:
676 l
= single_ASN1_type
->BEncContent (b
);
677 l
+= BEncDefLen (b
, l
);
679 l
+= BEncTag1 (b
, UNIV
, PRIM
, OCTETSTRING_TAG_CODE
);
680 l
+= BEncConsLen (b
, l
);
682 l
+= BEncTag1 (b
, CNTX
, CONS
, 0);
685 case octet_alignedCid
:
686 l
= octet_aligned
->BEncContent (b
);
687 l
+= BEncDefLen (b
, l
);
689 l
+= BEncTag1 (b
, CNTX
, PRIM
, 1);
693 l
= arbitrary
->BEncContent (b
);
694 l
+= BEncDefLen (b
, l
);
696 l
+= BEncTag1 (b
, CNTX
, PRIM
, 2);
701 } // EXTERNALChoice::BEncContent
704 void EXTERNALChoice::BDecContent (BUF_TYPE b
, AsnTag tag
, AsnLen elmtLen0
, AsnLen
&bytesDecoded
, ENV_TYPE env
)
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
)))
714 Asn1Error
<< "Unexpected Tag" << endl
;
715 SnaccExcep::throwMe(34);
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
);
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
);
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
);
741 Asn1Error
<< "ERROR - unexpected tag in CHOICE" << endl
;
742 SnaccExcep::throwMe(33);
745 } // EXTERNALChoice::BDecContent
748 AsnLen
EXTERNALChoice::BEnc (BUF_TYPE b
)
755 void EXTERNALChoice::BDec (BUF_TYPE b
, AsnLen
&bytesDecoded
, ENV_TYPE env
)
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
);
767 void EXTERNALChoice::Print (ostream
&os
) const
772 case single_ASN1_typeCid
:
773 os
<< "single-ASN1-type ";
774 if (single_ASN1_type
)
775 os
<< *single_ASN1_type
;
777 os
<< "-- void3 --\n";
780 case octet_alignedCid
:
781 os
<< "octet-aligned ";
783 os
<< *octet_aligned
;
785 os
<< "-- void3 --\n";
793 os
<< "-- void3 --\n";
798 } // EXTERNALChoice::Print
802 direct_reference
= NULL
;
803 indirect_reference
= NULL
;
804 data_value_descriptor
= NULL
;
806 encoding
= new EXTERNALChoice
;
808 encoding
= NULL
; // incomplete initialization of mandatory element!
812 EXTERNAL::EXTERNAL (const EXTERNAL
&)
814 Asn1Error
<< "use of incompletely defined EXTERNAL::EXTERNAL (const EXTERNAL &)" << endl
;
818 EXTERNAL::~EXTERNAL()
820 delete direct_reference
;
821 delete indirect_reference
;
822 delete data_value_descriptor
;
826 AsnType
*EXTERNAL::Clone() const
831 AsnType
*EXTERNAL::Copy() const
833 return new EXTERNAL (*this);
837 EXTERNAL
&EXTERNAL::operator = (const EXTERNAL
&that
)
838 #else // SNACC_DEEP_COPY
839 EXTERNAL
&EXTERNAL::operator = (const EXTERNAL
&)
840 #endif // SNACC_DEEP_COPY
845 if (that
.direct_reference
)
847 if (!direct_reference
)
848 direct_reference
= new AsnOid
;
849 *direct_reference
= *that
.direct_reference
;
853 delete direct_reference
;
854 direct_reference
= NULL
;
856 if (that
.indirect_reference
)
858 if (!indirect_reference
)
859 indirect_reference
= new AsnInt
;
860 *indirect_reference
= *that
.indirect_reference
;
864 delete indirect_reference
;
865 indirect_reference
= NULL
;
867 if (that
.data_value_descriptor
)
869 if (!data_value_descriptor
)
870 data_value_descriptor
= new ObjectDescriptor
;
871 *data_value_descriptor
= *that
.data_value_descriptor
;
875 delete data_value_descriptor
;
876 data_value_descriptor
= NULL
;
881 encoding
= new EXTERNALChoice
;
882 *encoding
= *that
.encoding
;
892 #else // SNACC_DEEP_COPY
893 Asn1Error
<< "use of incompletely defined EXTERNAL &EXTERNAL::operator = (const EXTERNAL &)" << endl
;
895 // if your compiler complains here, check the -novolat option
896 #endif // SNACC_DEEP_COPY
900 EXTERNAL::BEncContent (BUF_TYPE b
)
905 l
= encoding
->BEncContent (b
);
908 if (NOT_NULL (data_value_descriptor
))
910 l
= data_value_descriptor
->BEncContent (b
);
911 l
+= BEncDefLen (b
, l
);
913 l
+= BEncTag1 (b
, UNIV
, PRIM
, OD_TAG_CODE
);
917 if (NOT_NULL (indirect_reference
))
919 l
= indirect_reference
->BEncContent (b
);
920 BEncDefLenTo127 (b
, l
);
923 l
+= BEncTag1 (b
, UNIV
, PRIM
, INTEGER_TAG_CODE
);
927 if (NOT_NULL (direct_reference
))
929 l
= direct_reference
->BEncContent (b
);
930 l
+= BEncDefLen (b
, l
);
932 l
+= BEncTag1 (b
, UNIV
, PRIM
, OID_TAG_CODE
);
937 } // EXTERNAL::BEncContent
940 void EXTERNAL::BDecContent (BUF_TYPE b
, AsnTag
/*tag0*/, AsnLen elmtLen0
, AsnLen
&bytesDecoded
, ENV_TYPE env
)
943 AsnLen seqBytesDecoded
= 0;
945 tag1
= BDecTag (b
, seqBytesDecoded
, env
);
947 if ((tag1
== MAKE_TAG_ID (UNIV
, PRIM
, OID_TAG_CODE
)))
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
);
955 if ((tag1
== MAKE_TAG_ID (UNIV
, PRIM
, INTEGER_TAG_CODE
)))
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
);
963 if ((tag1
== MAKE_TAG_ID (UNIV
, PRIM
, OD_TAG_CODE
))
964 || (tag1
== MAKE_TAG_ID (UNIV
, CONS
, OD_TAG_CODE
)))
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
);
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)))
978 elmtLen1
= BDecLen (b
, seqBytesDecoded
, env
);
979 encoding
= new EXTERNALChoice
;
980 encoding
->BDecContent (b
, tag1
, elmtLen1
, seqBytesDecoded
, env
);
984 Asn1Error
<< "ERROR - SEQUENCE is missing non-optional elmt." << endl
;
985 SnaccExcep::throwMe(32);
988 bytesDecoded
+= seqBytesDecoded
;
989 if (elmtLen0
== INDEFINITE_LEN
)
991 BDecEoc (b
, bytesDecoded
, env
);
994 else if (seqBytesDecoded
!= elmtLen0
)
996 Asn1Error
<< "ERROR - Length discrepancy on sequence." << endl
;
997 SnaccExcep::throwMe(31);
1001 } // EXTERNAL::BDecContent
1003 AsnLen
EXTERNAL::BEnc (BUF_TYPE b
)
1006 l
= BEncContent (b
);
1007 l
+= BEncConsLen (b
, l
);
1008 l
+= BEncTag1 (b
, UNIV
, CONS
, EXTERNAL_TAG_CODE
);
1012 void EXTERNAL::BDec (BUF_TYPE b
, AsnLen
&bytesDecoded
, ENV_TYPE env
)
1017 if ((tag
= BDecTag (b
, bytesDecoded
, env
)) != MAKE_TAG_ID (UNIV
, CONS
, EXTERNAL_TAG_CODE
))
1019 Asn1Error
<< "EXTERNAL::BDec: ERROR - wrong tag" << endl
;
1020 SnaccExcep::throwMe(30);
1022 elmtLen1
= BDecLen (b
, bytesDecoded
, env
);
1023 BDecContent (b
, tag
, elmtLen1
, bytesDecoded
, env
);
1026 void EXTERNAL::Print (ostream
&os
) const
1029 os
<< "{ -- SEQUENCE --" << endl
;
1030 indentG
+= stdIndentG
;
1032 if (NOT_NULL (direct_reference
))
1034 Indent (os
, indentG
);
1035 os
<< "direct-reference ";
1036 os
<< *direct_reference
;
1040 Indent (os
, indentG
);
1041 os
<< "direct-reference ";
1046 if (NOT_NULL (indirect_reference
))
1048 Indent (os
, indentG
);
1049 os
<< "indirect-reference ";
1050 os
<< *indirect_reference
;
1054 Indent (os
, indentG
);
1055 os
<< "indirect-reference ";
1060 if (NOT_NULL (data_value_descriptor
))
1062 Indent (os
, indentG
);
1063 os
<< "data-value-descriptor ";
1064 os
<< *data_value_descriptor
;
1068 Indent (os
, indentG
);
1069 os
<< "data-value-descriptor ";
1074 if (NOT_NULL (encoding
))
1076 Indent (os
, indentG
);
1082 Indent (os
, indentG
);
1089 indentG
-= stdIndentG
;
1090 Indent (os
, indentG
);
1093 } // EXTERNAL::Print