]>
git.saurik.com Git - apple/security.git/blob - SecuritySNACCRuntime/c++-lib/c++/asn-useful.cpp
2 * Copyright (c) 2000-2001 Apple Computer, Inc. All Rights Reserved.
4 * The contents of this file constitute Original Code as defined in and are
5 * subject to the Apple Public Source License Version 1.2 (the 'License').
6 * You may not use this file except in compliance with the License. Please obtain
7 * a copy of the License at http://www.apple.com/publicsource and read it before
10 * This Original Code and all software distributed under the License are
11 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS
12 * OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT
13 * LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
14 * PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see the License for the
15 * specific language governing rights and limitations under the License.
19 // NOTE: this is a machine generated file--editing not recommended
21 // asn-useful.cpp - class member functions for ASN.1 module ASN-USEFUL
23 // This file was generated by snacc on Wed Jun 14 14:50:26 2000
24 // UBC snacc written by Mike Sample
25 // A couple of enhancements made by IBM European Networking Center
29 #include "asn-useful.h"
31 //------------------------------------------------------------------------------
35 //------------------------------------------------------------------------------
36 // class member definitions:
38 AsnType
*ObjectDescriptor::Clone() const
40 return new ObjectDescriptor
;
43 AsnType
*ObjectDescriptor::Copy() const
45 return new ObjectDescriptor (*this);
48 AsnLen
ObjectDescriptor::BEnc (BUF_TYPE b
)
52 l
+= BEncDefLen (b
, l
);
54 l
+= BEncTag1 (b
, UNIV
, PRIM
, OD_TAG_CODE
);
58 void ObjectDescriptor::BDec (BUF_TYPE b
, AsnLen
&bytesDecoded
, ENV_TYPE env
)
63 if (((tag
= BDecTag (b
, bytesDecoded
, env
)) != MAKE_TAG_ID (UNIV
, PRIM
, OD_TAG_CODE
))
64 && (tag
!= MAKE_TAG_ID (UNIV
, CONS
, OD_TAG_CODE
)))
66 Asn1Error
<< "ObjectDescriptor::BDec: ERROR - wrong tag" << endl
;
69 elmtLen1
= BDecLen (b
, bytesDecoded
, env
);
70 BDecContent (b
, tag
, elmtLen1
, bytesDecoded
, env
);
73 int ObjectDescriptor::BEncPdu (BUF_TYPE b
, AsnLen
&bytesEncoded
)
75 bytesEncoded
= BEnc (b
);
76 return !b
.WriteError();
79 int ObjectDescriptor::BDecPdu (BUF_TYPE b
, AsnLen
&bytesDecoded
)
85 if ((val
= setjmp (env
)) == 0)
87 BDec (b
, bytesDecoded
, env
);
88 return !b
.ReadError();
94 AsnType
*UTF8String::Clone() const
96 return new UTF8String
;
99 AsnType
*UTF8String::Copy() const
101 return new UTF8String (*this);
104 AsnLen
UTF8String::BEnc (BUF_TYPE b
)
108 l
+= BEncDefLen (b
, l
);
110 l
+= BEncTag1 (b
, UNIV
, PRIM
, 12);
114 void UTF8String::BDec (BUF_TYPE b
, AsnLen
&bytesDecoded
, ENV_TYPE env
)
119 if (((tag
= BDecTag (b
, bytesDecoded
, env
)) != MAKE_TAG_ID (UNIV
, PRIM
, 12))
120 && (tag
!= MAKE_TAG_ID (UNIV
, CONS
, 12)))
122 Asn1Error
<< "UTF8String::BDec: ERROR - wrong tag" << endl
;
125 elmtLen1
= BDecLen (b
, bytesDecoded
, env
);
126 BDecContent (b
, tag
, elmtLen1
, bytesDecoded
, env
);
129 int UTF8String::BEncPdu (BUF_TYPE b
, AsnLen
&bytesEncoded
)
131 bytesEncoded
= BEnc (b
);
132 return !b
.WriteError();
135 int UTF8String::BDecPdu (BUF_TYPE b
, AsnLen
&bytesDecoded
)
141 if ((val
= setjmp (env
)) == 0)
143 BDec (b
, bytesDecoded
, env
);
144 return !b
.ReadError();
150 AsnType
*NumericString::Clone() const
152 return new NumericString
;
155 AsnType
*NumericString::Copy() const
157 return new NumericString (*this);
160 AsnLen
NumericString::BEnc (BUF_TYPE b
)
164 l
+= BEncDefLen (b
, l
);
166 l
+= BEncTag1 (b
, UNIV
, PRIM
, NUMERICSTRING_TAG_CODE
);
170 void NumericString::BDec (BUF_TYPE b
, AsnLen
&bytesDecoded
, ENV_TYPE env
)
175 if (((tag
= BDecTag (b
, bytesDecoded
, env
)) != MAKE_TAG_ID (UNIV
, PRIM
, NUMERICSTRING_TAG_CODE
))
176 && (tag
!= MAKE_TAG_ID (UNIV
, CONS
, NUMERICSTRING_TAG_CODE
)))
178 Asn1Error
<< "NumericString::BDec: ERROR - wrong tag" << endl
;
181 elmtLen1
= BDecLen (b
, bytesDecoded
, env
);
182 BDecContent (b
, tag
, elmtLen1
, bytesDecoded
, env
);
185 int NumericString::BEncPdu (BUF_TYPE b
, AsnLen
&bytesEncoded
)
187 bytesEncoded
= BEnc (b
);
188 return !b
.WriteError();
191 int NumericString::BDecPdu (BUF_TYPE b
, AsnLen
&bytesDecoded
)
197 if ((val
= setjmp (env
)) == 0)
199 BDec (b
, bytesDecoded
, env
);
200 return !b
.ReadError();
206 AsnType
*PrintableString::Clone() const
208 return new PrintableString
;
211 AsnType
*PrintableString::Copy() const
213 return new PrintableString (*this);
216 AsnLen
PrintableString::BEnc (BUF_TYPE b
)
220 l
+= BEncDefLen (b
, l
);
222 l
+= BEncTag1 (b
, UNIV
, PRIM
, PRINTABLESTRING_TAG_CODE
);
226 void PrintableString::BDec (BUF_TYPE b
, AsnLen
&bytesDecoded
, ENV_TYPE env
)
231 if (((tag
= BDecTag (b
, bytesDecoded
, env
)) != MAKE_TAG_ID (UNIV
, PRIM
, PRINTABLESTRING_TAG_CODE
))
232 && (tag
!= MAKE_TAG_ID (UNIV
, CONS
, PRINTABLESTRING_TAG_CODE
)))
234 Asn1Error
<< "PrintableString::BDec: ERROR - wrong tag" << endl
;
237 elmtLen1
= BDecLen (b
, bytesDecoded
, env
);
238 BDecContent (b
, tag
, elmtLen1
, bytesDecoded
, env
);
241 int PrintableString::BEncPdu (BUF_TYPE b
, AsnLen
&bytesEncoded
)
243 bytesEncoded
= BEnc (b
);
244 return !b
.WriteError();
247 int PrintableString::BDecPdu (BUF_TYPE b
, AsnLen
&bytesDecoded
)
253 if ((val
= setjmp (env
)) == 0)
255 BDec (b
, bytesDecoded
, env
);
256 return !b
.ReadError();
262 AsnType
*TeletexString::Clone() const
264 return new TeletexString
;
267 AsnType
*TeletexString::Copy() const
269 return new TeletexString (*this);
272 AsnLen
TeletexString::BEnc (BUF_TYPE b
)
276 l
+= BEncDefLen (b
, l
);
278 l
+= BEncTag1 (b
, UNIV
, PRIM
, TELETEXSTRING_TAG_CODE
);
282 void TeletexString::BDec (BUF_TYPE b
, AsnLen
&bytesDecoded
, ENV_TYPE env
)
287 if (((tag
= BDecTag (b
, bytesDecoded
, env
)) != MAKE_TAG_ID (UNIV
, PRIM
, TELETEXSTRING_TAG_CODE
))
288 && (tag
!= MAKE_TAG_ID (UNIV
, CONS
, TELETEXSTRING_TAG_CODE
)))
290 Asn1Error
<< "TeletexString::BDec: ERROR - wrong tag" << endl
;
293 elmtLen1
= BDecLen (b
, bytesDecoded
, env
);
294 BDecContent (b
, tag
, elmtLen1
, bytesDecoded
, env
);
297 int TeletexString::BEncPdu (BUF_TYPE b
, AsnLen
&bytesEncoded
)
299 bytesEncoded
= BEnc (b
);
300 return !b
.WriteError();
303 int TeletexString::BDecPdu (BUF_TYPE b
, AsnLen
&bytesDecoded
)
309 if ((val
= setjmp (env
)) == 0)
311 BDec (b
, bytesDecoded
, env
);
312 return !b
.ReadError();
318 AsnType
*T61String::Clone() const
320 return new T61String
;
323 AsnType
*T61String::Copy() const
325 return new T61String (*this);
328 AsnLen
T61String::BEnc (BUF_TYPE b
)
332 l
+= BEncDefLen (b
, l
);
334 l
+= BEncTag1 (b
, UNIV
, PRIM
, TELETEXSTRING_TAG_CODE
);
338 void T61String::BDec (BUF_TYPE b
, AsnLen
&bytesDecoded
, ENV_TYPE env
)
343 if (((tag
= BDecTag (b
, bytesDecoded
, env
)) != MAKE_TAG_ID (UNIV
, PRIM
, TELETEXSTRING_TAG_CODE
))
344 && (tag
!= MAKE_TAG_ID (UNIV
, CONS
, TELETEXSTRING_TAG_CODE
)))
346 Asn1Error
<< "T61String::BDec: ERROR - wrong tag" << endl
;
349 elmtLen1
= BDecLen (b
, bytesDecoded
, env
);
350 BDecContent (b
, tag
, elmtLen1
, bytesDecoded
, env
);
353 int T61String::BEncPdu (BUF_TYPE b
, AsnLen
&bytesEncoded
)
355 bytesEncoded
= BEnc (b
);
356 return !b
.WriteError();
359 int T61String::BDecPdu (BUF_TYPE b
, AsnLen
&bytesDecoded
)
365 if ((val
= setjmp (env
)) == 0)
367 BDec (b
, bytesDecoded
, env
);
368 return !b
.ReadError();
374 AsnType
*VideotexString::Clone() const
376 return new VideotexString
;
379 AsnType
*VideotexString::Copy() const
381 return new VideotexString (*this);
384 AsnLen
VideotexString::BEnc (BUF_TYPE b
)
388 l
+= BEncDefLen (b
, l
);
390 l
+= BEncTag1 (b
, UNIV
, PRIM
, VIDEOTEXSTRING_TAG_CODE
);
394 void VideotexString::BDec (BUF_TYPE b
, AsnLen
&bytesDecoded
, ENV_TYPE env
)
399 if (((tag
= BDecTag (b
, bytesDecoded
, env
)) != MAKE_TAG_ID (UNIV
, PRIM
, VIDEOTEXSTRING_TAG_CODE
))
400 && (tag
!= MAKE_TAG_ID (UNIV
, CONS
, VIDEOTEXSTRING_TAG_CODE
)))
402 Asn1Error
<< "VideotexString::BDec: ERROR - wrong tag" << endl
;
405 elmtLen1
= BDecLen (b
, bytesDecoded
, env
);
406 BDecContent (b
, tag
, elmtLen1
, bytesDecoded
, env
);
409 int VideotexString::BEncPdu (BUF_TYPE b
, AsnLen
&bytesEncoded
)
411 bytesEncoded
= BEnc (b
);
412 return !b
.WriteError();
415 int VideotexString::BDecPdu (BUF_TYPE b
, AsnLen
&bytesDecoded
)
421 if ((val
= setjmp (env
)) == 0)
423 BDec (b
, bytesDecoded
, env
);
424 return !b
.ReadError();
430 AsnType
*IA5String::Clone() const
432 return new IA5String
;
435 AsnType
*IA5String::Copy() const
437 return new IA5String (*this);
440 AsnLen
IA5String::BEnc (BUF_TYPE b
)
444 l
+= BEncDefLen (b
, l
);
446 l
+= BEncTag1 (b
, UNIV
, PRIM
, IA5STRING_TAG_CODE
);
450 void IA5String::BDec (BUF_TYPE b
, AsnLen
&bytesDecoded
, ENV_TYPE env
)
455 if (((tag
= BDecTag (b
, bytesDecoded
, env
)) != MAKE_TAG_ID (UNIV
, PRIM
, IA5STRING_TAG_CODE
))
456 && (tag
!= MAKE_TAG_ID (UNIV
, CONS
, IA5STRING_TAG_CODE
)))
458 Asn1Error
<< "IA5String::BDec: ERROR - wrong tag" << endl
;
461 elmtLen1
= BDecLen (b
, bytesDecoded
, env
);
462 BDecContent (b
, tag
, elmtLen1
, bytesDecoded
, env
);
465 int IA5String::BEncPdu (BUF_TYPE b
, AsnLen
&bytesEncoded
)
467 bytesEncoded
= BEnc (b
);
468 return !b
.WriteError();
471 int IA5String::BDecPdu (BUF_TYPE b
, AsnLen
&bytesDecoded
)
477 if ((val
= setjmp (env
)) == 0)
479 BDec (b
, bytesDecoded
, env
);
480 return !b
.ReadError();
486 AsnType
*GraphicString::Clone() const
488 return new GraphicString
;
491 AsnType
*GraphicString::Copy() const
493 return new GraphicString (*this);
496 AsnLen
GraphicString::BEnc (BUF_TYPE b
)
500 l
+= BEncDefLen (b
, l
);
502 l
+= BEncTag1 (b
, UNIV
, PRIM
, GRAPHICSTRING_TAG_CODE
);
506 void GraphicString::BDec (BUF_TYPE b
, AsnLen
&bytesDecoded
, ENV_TYPE env
)
511 if (((tag
= BDecTag (b
, bytesDecoded
, env
)) != MAKE_TAG_ID (UNIV
, PRIM
, GRAPHICSTRING_TAG_CODE
))
512 && (tag
!= MAKE_TAG_ID (UNIV
, CONS
, GRAPHICSTRING_TAG_CODE
)))
514 Asn1Error
<< "GraphicString::BDec: ERROR - wrong tag" << endl
;
517 elmtLen1
= BDecLen (b
, bytesDecoded
, env
);
518 BDecContent (b
, tag
, elmtLen1
, bytesDecoded
, env
);
521 int GraphicString::BEncPdu (BUF_TYPE b
, AsnLen
&bytesEncoded
)
523 bytesEncoded
= BEnc (b
);
524 return !b
.WriteError();
527 int GraphicString::BDecPdu (BUF_TYPE b
, AsnLen
&bytesDecoded
)
533 if ((val
= setjmp (env
)) == 0)
535 BDec (b
, bytesDecoded
, env
);
536 return !b
.ReadError();
542 AsnType
*VisibleString::Clone() const
544 return new VisibleString
;
547 AsnType
*VisibleString::Copy() const
549 return new VisibleString (*this);
552 AsnLen
VisibleString::BEnc (BUF_TYPE b
)
556 l
+= BEncDefLen (b
, l
);
558 l
+= BEncTag1 (b
, UNIV
, PRIM
, VISIBLESTRING_TAG_CODE
);
562 void VisibleString::BDec (BUF_TYPE b
, AsnLen
&bytesDecoded
, ENV_TYPE env
)
567 if (((tag
= BDecTag (b
, bytesDecoded
, env
)) != MAKE_TAG_ID (UNIV
, PRIM
, VISIBLESTRING_TAG_CODE
))
568 && (tag
!= MAKE_TAG_ID (UNIV
, CONS
, VISIBLESTRING_TAG_CODE
)))
570 Asn1Error
<< "VisibleString::BDec: ERROR - wrong tag" << endl
;
573 elmtLen1
= BDecLen (b
, bytesDecoded
, env
);
574 BDecContent (b
, tag
, elmtLen1
, bytesDecoded
, env
);
577 int VisibleString::BEncPdu (BUF_TYPE b
, AsnLen
&bytesEncoded
)
579 bytesEncoded
= BEnc (b
);
580 return !b
.WriteError();
583 int VisibleString::BDecPdu (BUF_TYPE b
, AsnLen
&bytesDecoded
)
589 if ((val
= setjmp (env
)) == 0)
591 BDec (b
, bytesDecoded
, env
);
592 return !b
.ReadError();
598 AsnType
*ISO646String::Clone() const
600 return new ISO646String
;
603 AsnType
*ISO646String::Copy() const
605 return new ISO646String (*this);
608 AsnLen
ISO646String::BEnc (BUF_TYPE b
)
612 l
+= BEncDefLen (b
, l
);
614 l
+= BEncTag1 (b
, UNIV
, PRIM
, VISIBLESTRING_TAG_CODE
);
618 void ISO646String::BDec (BUF_TYPE b
, AsnLen
&bytesDecoded
, ENV_TYPE env
)
623 if (((tag
= BDecTag (b
, bytesDecoded
, env
)) != MAKE_TAG_ID (UNIV
, PRIM
, VISIBLESTRING_TAG_CODE
))
624 && (tag
!= MAKE_TAG_ID (UNIV
, CONS
, VISIBLESTRING_TAG_CODE
)))
626 Asn1Error
<< "ISO646String::BDec: ERROR - wrong tag" << endl
;
629 elmtLen1
= BDecLen (b
, bytesDecoded
, env
);
630 BDecContent (b
, tag
, elmtLen1
, bytesDecoded
, env
);
633 int ISO646String::BEncPdu (BUF_TYPE b
, AsnLen
&bytesEncoded
)
635 bytesEncoded
= BEnc (b
);
636 return !b
.WriteError();
639 int ISO646String::BDecPdu (BUF_TYPE b
, AsnLen
&bytesDecoded
)
645 if ((val
= setjmp (env
)) == 0)
647 BDec (b
, bytesDecoded
, env
);
648 return !b
.ReadError();
654 AsnType
*GeneralString::Clone() const
656 return new GeneralString
;
659 AsnType
*GeneralString::Copy() const
661 return new GeneralString (*this);
664 AsnLen
GeneralString::BEnc (BUF_TYPE b
)
668 l
+= BEncDefLen (b
, l
);
670 l
+= BEncTag1 (b
, UNIV
, PRIM
, GENERALSTRING_TAG_CODE
);
674 void GeneralString::BDec (BUF_TYPE b
, AsnLen
&bytesDecoded
, ENV_TYPE env
)
679 if (((tag
= BDecTag (b
, bytesDecoded
, env
)) != MAKE_TAG_ID (UNIV
, PRIM
, GENERALSTRING_TAG_CODE
))
680 && (tag
!= MAKE_TAG_ID (UNIV
, CONS
, GENERALSTRING_TAG_CODE
)))
682 Asn1Error
<< "GeneralString::BDec: ERROR - wrong tag" << endl
;
685 elmtLen1
= BDecLen (b
, bytesDecoded
, env
);
686 BDecContent (b
, tag
, elmtLen1
, bytesDecoded
, env
);
689 int GeneralString::BEncPdu (BUF_TYPE b
, AsnLen
&bytesEncoded
)
691 bytesEncoded
= BEnc (b
);
692 return !b
.WriteError();
695 int GeneralString::BDecPdu (BUF_TYPE b
, AsnLen
&bytesDecoded
)
701 if ((val
= setjmp (env
)) == 0)
703 BDec (b
, bytesDecoded
, env
);
704 return !b
.ReadError();
710 AsnType
*UTCTime::Clone() const
715 AsnType
*UTCTime::Copy() const
717 return new UTCTime (*this);
720 AsnLen
UTCTime::BEnc (BUF_TYPE b
)
724 l
+= BEncDefLen (b
, l
);
726 l
+= BEncTag1 (b
, UNIV
, PRIM
, UTCTIME_TAG_CODE
);
730 void UTCTime::BDec (BUF_TYPE b
, AsnLen
&bytesDecoded
, ENV_TYPE env
)
735 if (((tag
= BDecTag (b
, bytesDecoded
, env
)) != MAKE_TAG_ID (UNIV
, PRIM
, UTCTIME_TAG_CODE
))
736 && (tag
!= MAKE_TAG_ID (UNIV
, CONS
, UTCTIME_TAG_CODE
)))
738 Asn1Error
<< "UTCTime::BDec: ERROR - wrong tag" << endl
;
741 elmtLen1
= BDecLen (b
, bytesDecoded
, env
);
742 BDecContent (b
, tag
, elmtLen1
, bytesDecoded
, env
);
745 int UTCTime::BEncPdu (BUF_TYPE b
, AsnLen
&bytesEncoded
)
747 bytesEncoded
= BEnc (b
);
748 return !b
.WriteError();
751 int UTCTime::BDecPdu (BUF_TYPE b
, AsnLen
&bytesDecoded
)
757 if ((val
= setjmp (env
)) == 0)
759 BDec (b
, bytesDecoded
, env
);
760 return !b
.ReadError();
766 AsnType
*GeneralizedTime::Clone() const
768 return new GeneralizedTime
;
771 AsnType
*GeneralizedTime::Copy() const
773 return new GeneralizedTime (*this);
776 AsnLen
GeneralizedTime::BEnc (BUF_TYPE b
)
780 l
+= BEncDefLen (b
, l
);
782 l
+= BEncTag1 (b
, UNIV
, PRIM
, GENERALIZEDTIME_TAG_CODE
);
786 void GeneralizedTime::BDec (BUF_TYPE b
, AsnLen
&bytesDecoded
, ENV_TYPE env
)
791 if (((tag
= BDecTag (b
, bytesDecoded
, env
)) != MAKE_TAG_ID (UNIV
, PRIM
, GENERALIZEDTIME_TAG_CODE
))
792 && (tag
!= MAKE_TAG_ID (UNIV
, CONS
, GENERALIZEDTIME_TAG_CODE
)))
794 Asn1Error
<< "GeneralizedTime::BDec: ERROR - wrong tag" << endl
;
797 elmtLen1
= BDecLen (b
, bytesDecoded
, env
);
798 BDecContent (b
, tag
, elmtLen1
, bytesDecoded
, env
);
801 int GeneralizedTime::BEncPdu (BUF_TYPE b
, AsnLen
&bytesEncoded
)
803 bytesEncoded
= BEnc (b
);
804 return !b
.WriteError();
807 int GeneralizedTime::BDecPdu (BUF_TYPE b
, AsnLen
&bytesDecoded
)
813 if ((val
= setjmp (env
)) == 0)
815 BDec (b
, bytesDecoded
, env
);
816 return !b
.ReadError();
822 AsnType
*UniversalString::Clone() const
824 return new UniversalString
;
827 AsnType
*UniversalString::Copy() const
829 return new UniversalString (*this);
832 AsnLen
UniversalString::BEnc (BUF_TYPE b
)
836 l
+= BEncDefLen (b
, l
);
838 l
+= BEncTag1 (b
, UNIV
, PRIM
, UNIVERSALSTRING_TAG_CODE
);
842 void UniversalString::BDec (BUF_TYPE b
, AsnLen
&bytesDecoded
, ENV_TYPE env
)
847 if (((tag
= BDecTag (b
, bytesDecoded
, env
)) != MAKE_TAG_ID (UNIV
, PRIM
, UNIVERSALSTRING_TAG_CODE
))
848 && (tag
!= MAKE_TAG_ID (UNIV
, CONS
, UNIVERSALSTRING_TAG_CODE
)))
850 Asn1Error
<< "UniversalString::BDec: ERROR - wrong tag" << endl
;
853 elmtLen1
= BDecLen (b
, bytesDecoded
, env
);
854 BDecContent (b
, tag
, elmtLen1
, bytesDecoded
, env
);
857 int UniversalString::BEncPdu (BUF_TYPE b
, AsnLen
&bytesEncoded
)
859 bytesEncoded
= BEnc (b
);
860 return !b
.WriteError();
863 int UniversalString::BDecPdu (BUF_TYPE b
, AsnLen
&bytesDecoded
)
869 if ((val
= setjmp (env
)) == 0)
871 BDec (b
, bytesDecoded
, env
);
872 return !b
.ReadError();
878 AsnType
*BMPString::Clone() const
880 return new BMPString
;
883 AsnType
*BMPString::Copy() const
885 return new BMPString (*this);
888 AsnLen
BMPString::BEnc (BUF_TYPE b
)
892 l
+= BEncDefLen (b
, l
);
894 l
+= BEncTag1 (b
, UNIV
, PRIM
, BMPSTRING_TAG_CODE
);
898 void BMPString::BDec (BUF_TYPE b
, AsnLen
&bytesDecoded
, ENV_TYPE env
)
903 if (((tag
= BDecTag (b
, bytesDecoded
, env
)) != MAKE_TAG_ID (UNIV
, PRIM
, BMPSTRING_TAG_CODE
))
904 && (tag
!= MAKE_TAG_ID (UNIV
, CONS
, BMPSTRING_TAG_CODE
)))
906 Asn1Error
<< "BMPString::BDec: ERROR - wrong tag" << endl
;
909 elmtLen1
= BDecLen (b
, bytesDecoded
, env
);
910 BDecContent (b
, tag
, elmtLen1
, bytesDecoded
, env
);
913 int BMPString::BEncPdu (BUF_TYPE b
, AsnLen
&bytesEncoded
)
915 bytesEncoded
= BEnc (b
);
916 return !b
.WriteError();
919 int BMPString::BDecPdu (BUF_TYPE b
, AsnLen
&bytesDecoded
)
925 if ((val
= setjmp (env
)) == 0)
927 BDec (b
, bytesDecoded
, env
);
928 return !b
.ReadError();
934 EXTERNALChoice::EXTERNALChoice()
936 choiceId
= single_ASN1_typeCid
;
938 single_ASN1_type
= new AsnOcts
;
940 single_ASN1_type
= NULL
; // incomplete initialization of mandatory element!
944 EXTERNALChoice::EXTERNALChoice (const EXTERNALChoice
&)
946 Asn1Error
<< "use of incompletely defined EXTERNALChoice::EXTERNALChoice (const EXTERNALChoice &)" << endl
;
950 EXTERNALChoice::~EXTERNALChoice()
954 case single_ASN1_typeCid
:
955 delete single_ASN1_type
;
957 case octet_alignedCid
:
958 delete octet_aligned
;
964 } // end of destructor
966 AsnType
*EXTERNALChoice::Clone() const
968 return new EXTERNALChoice
;
971 AsnType
*EXTERNALChoice::Copy() const
973 return new EXTERNALChoice (*this);
977 EXTERNALChoice
&EXTERNALChoice::operator = (const EXTERNALChoice
&that
)
978 #else // SNACC_DEEP_COPY
979 EXTERNALChoice
&EXTERNALChoice::operator = (const EXTERNALChoice
&)
980 #endif // SNACC_DEEP_COPY
987 case single_ASN1_typeCid
:
988 delete single_ASN1_type
;
990 case octet_alignedCid
:
991 delete octet_aligned
;
997 switch (choiceId
= that
.choiceId
)
999 case single_ASN1_typeCid
:
1000 single_ASN1_type
= new AsnOcts
;
1001 *single_ASN1_type
= *that
.single_ASN1_type
;
1003 case octet_alignedCid
:
1004 octet_aligned
= new AsnOcts
;
1005 *octet_aligned
= *that
.octet_aligned
;
1008 arbitrary
= new AsnBits
;
1009 *arbitrary
= *that
.arbitrary
;
1015 #else // SNACC_DEEP_COPY
1016 Asn1Error
<< "use of incompletely defined EXTERNALChoice &EXTERNALChoice::operator = (const EXTERNALChoice &)" << endl
;
1018 // if your compiler complains here, check the -novolat option
1019 #endif // SNACC_DEEP_COPY
1023 EXTERNALChoice::BEncContent (BUF_TYPE b
)
1028 case single_ASN1_typeCid
:
1030 l
= single_ASN1_type
->BEncContent (b
);
1031 l
+= BEncDefLen (b
, l
);
1033 l
+= BEncTag1 (b
, UNIV
, PRIM
, OCTETSTRING_TAG_CODE
);
1034 l
+= BEncConsLen (b
, l
);
1036 l
+= BEncTag1 (b
, CNTX
, CONS
, 0);
1039 case octet_alignedCid
:
1040 l
= octet_aligned
->BEncContent (b
);
1041 l
+= BEncDefLen (b
, l
);
1043 l
+= BEncTag1 (b
, CNTX
, PRIM
, 1);
1047 l
= arbitrary
->BEncContent (b
);
1048 l
+= BEncDefLen (b
, l
);
1050 l
+= BEncTag1 (b
, CNTX
, PRIM
, 2);
1055 } // EXTERNALChoice::BEncContent
1058 void EXTERNALChoice::BDecContent (BUF_TYPE b
, AsnTag tag
, AsnLen elmtLen0
, AsnLen
&bytesDecoded
, ENV_TYPE env
)
1063 case MAKE_TAG_ID (CNTX
, CONS
, 0):
1064 tag
= BDecTag (b
, bytesDecoded
, env
);
1065 if ((tag
!= MAKE_TAG_ID (UNIV
, PRIM
, OCTETSTRING_TAG_CODE
))
1066 && (tag
!= MAKE_TAG_ID (UNIV
, CONS
, OCTETSTRING_TAG_CODE
)))
1068 Asn1Error
<< "Unexpected Tag" << endl
;
1072 elmtLen1
= BDecLen (b
, bytesDecoded
, env
);
1073 choiceId
= single_ASN1_typeCid
;
1074 single_ASN1_type
= new AsnOcts
;
1075 single_ASN1_type
->BDecContent (b
, tag
, elmtLen1
, bytesDecoded
, env
);
1076 if (elmtLen0
== INDEFINITE_LEN
)
1077 BDecEoc (b
, bytesDecoded
, env
);
1080 case MAKE_TAG_ID (CNTX
, PRIM
, 1):
1081 case MAKE_TAG_ID (CNTX
, CONS
, 1):
1082 choiceId
= octet_alignedCid
;
1083 octet_aligned
= new AsnOcts
;
1084 octet_aligned
->BDecContent (b
, tag
, elmtLen0
, bytesDecoded
, env
);
1087 case MAKE_TAG_ID (CNTX
, PRIM
, 2):
1088 case MAKE_TAG_ID (CNTX
, CONS
, 2):
1089 choiceId
= arbitraryCid
;
1090 arbitrary
= new AsnBits
;
1091 arbitrary
->BDecContent (b
, tag
, elmtLen0
, bytesDecoded
, env
);
1095 Asn1Error
<< "ERROR - unexpected tag in CHOICE" << endl
;
1099 } // EXTERNALChoice::BDecContent
1102 AsnLen
EXTERNALChoice::BEnc (BUF_TYPE b
)
1105 l
= BEncContent (b
);
1109 void EXTERNALChoice::BDec (BUF_TYPE b
, AsnLen
&bytesDecoded
, ENV_TYPE env
)
1114 /* CHOICEs are a special case - grab identifying tag */
1115 /* this allows easier handling of nested CHOICEs */
1116 tag
= BDecTag (b
, bytesDecoded
, env
);
1117 elmtLen
= BDecLen (b
, bytesDecoded
, env
);
1118 BDecContent (b
, tag
, elmtLen
, bytesDecoded
, env
);
1121 int EXTERNALChoice::BEncPdu (BUF_TYPE b
, AsnLen
&bytesEncoded
)
1123 bytesEncoded
= BEnc (b
);
1124 return !b
.WriteError();
1127 int EXTERNALChoice::BDecPdu (BUF_TYPE b
, AsnLen
&bytesDecoded
)
1133 if ((val
= setjmp (env
)) == 0)
1135 BDec (b
, bytesDecoded
, env
);
1136 return !b
.ReadError();
1142 void EXTERNALChoice::Print (ostream
&os
) const
1147 case single_ASN1_typeCid
:
1148 os
<< "single-ASN1-type ";
1149 if (single_ASN1_type
)
1150 os
<< *single_ASN1_type
;
1152 os
<< "-- void3 --\n";
1155 case octet_alignedCid
:
1156 os
<< "octet-aligned ";
1158 os
<< *octet_aligned
;
1160 os
<< "-- void3 --\n";
1168 os
<< "-- void3 --\n";
1173 } // EXTERNALChoice::Print
1175 EXTERNAL::EXTERNAL()
1177 direct_reference
= NULL
;
1178 indirect_reference
= NULL
;
1179 data_value_descriptor
= NULL
;
1181 encoding
= new EXTERNALChoice
;
1183 encoding
= NULL
; // incomplete initialization of mandatory element!
1187 EXTERNAL::EXTERNAL (const EXTERNAL
&)
1189 Asn1Error
<< "use of incompletely defined EXTERNAL::EXTERNAL (const EXTERNAL &)" << endl
;
1193 EXTERNAL::~EXTERNAL()
1195 delete direct_reference
;
1196 delete indirect_reference
;
1197 delete data_value_descriptor
;
1201 AsnType
*EXTERNAL::Clone() const
1203 return new EXTERNAL
;
1206 AsnType
*EXTERNAL::Copy() const
1208 return new EXTERNAL (*this);
1212 EXTERNAL
&EXTERNAL::operator = (const EXTERNAL
&that
)
1213 #else // SNACC_DEEP_COPY
1214 EXTERNAL
&EXTERNAL::operator = (const EXTERNAL
&)
1215 #endif // SNACC_DEEP_COPY
1220 if (that
.direct_reference
)
1222 if (!direct_reference
)
1223 direct_reference
= new AsnOid
;
1224 *direct_reference
= *that
.direct_reference
;
1228 delete direct_reference
;
1229 direct_reference
= NULL
;
1231 if (that
.indirect_reference
)
1233 if (!indirect_reference
)
1234 indirect_reference
= new AsnInt
;
1235 *indirect_reference
= *that
.indirect_reference
;
1239 delete indirect_reference
;
1240 indirect_reference
= NULL
;
1242 if (that
.data_value_descriptor
)
1244 if (!data_value_descriptor
)
1245 data_value_descriptor
= new ObjectDescriptor
;
1246 *data_value_descriptor
= *that
.data_value_descriptor
;
1250 delete data_value_descriptor
;
1251 data_value_descriptor
= NULL
;
1256 encoding
= new EXTERNALChoice
;
1257 *encoding
= *that
.encoding
;
1267 #else // SNACC_DEEP_COPY
1268 Asn1Error
<< "use of incompletely defined EXTERNAL &EXTERNAL::operator = (const EXTERNAL &)" << endl
;
1270 // if your compiler complains here, check the -novolat option
1271 #endif // SNACC_DEEP_COPY
1275 EXTERNAL::BEncContent (BUF_TYPE b
)
1277 AsnLen totalLen
= 0;
1280 l
= encoding
->BEncContent (b
);
1283 if (NOT_NULL (data_value_descriptor
))
1285 l
= data_value_descriptor
->BEncContent (b
);
1286 l
+= BEncDefLen (b
, l
);
1288 l
+= BEncTag1 (b
, UNIV
, PRIM
, OD_TAG_CODE
);
1292 if (NOT_NULL (indirect_reference
))
1294 l
= indirect_reference
->BEncContent (b
);
1295 BEncDefLenTo127 (b
, l
);
1298 l
+= BEncTag1 (b
, UNIV
, PRIM
, INTEGER_TAG_CODE
);
1302 if (NOT_NULL (direct_reference
))
1304 l
= direct_reference
->BEncContent (b
);
1305 l
+= BEncDefLen (b
, l
);
1307 l
+= BEncTag1 (b
, UNIV
, PRIM
, OID_TAG_CODE
);
1312 } // EXTERNAL::BEncContent
1315 void EXTERNAL::BDecContent (BUF_TYPE b
, AsnTag
/*tag0*/, AsnLen elmtLen0
, AsnLen
&bytesDecoded
, ENV_TYPE env
)
1318 AsnLen seqBytesDecoded
= 0;
1320 tag1
= BDecTag (b
, seqBytesDecoded
, env
);
1322 if ((tag1
== MAKE_TAG_ID (UNIV
, PRIM
, OID_TAG_CODE
)))
1324 elmtLen1
= BDecLen (b
, seqBytesDecoded
, env
);
1325 direct_reference
= new AsnOid
;
1326 direct_reference
->BDecContent (b
, tag1
, elmtLen1
, seqBytesDecoded
, env
);
1327 tag1
= BDecTag (b
, seqBytesDecoded
, env
);
1330 if ((tag1
== MAKE_TAG_ID (UNIV
, PRIM
, INTEGER_TAG_CODE
)))
1332 elmtLen1
= BDecLen (b
, seqBytesDecoded
, env
);
1333 indirect_reference
= new AsnInt
;
1334 indirect_reference
->BDecContent (b
, tag1
, elmtLen1
, seqBytesDecoded
, env
);
1335 tag1
= BDecTag (b
, seqBytesDecoded
, env
);
1338 if ((tag1
== MAKE_TAG_ID (UNIV
, PRIM
, OD_TAG_CODE
))
1339 || (tag1
== MAKE_TAG_ID (UNIV
, CONS
, OD_TAG_CODE
)))
1341 elmtLen1
= BDecLen (b
, seqBytesDecoded
, env
);
1342 data_value_descriptor
= new ObjectDescriptor
;
1343 data_value_descriptor
->BDecContent (b
, tag1
, elmtLen1
, seqBytesDecoded
, env
);
1344 tag1
= BDecTag (b
, seqBytesDecoded
, env
);
1347 if ((tag1
== MAKE_TAG_ID (CNTX
, CONS
, 0))
1348 || (tag1
== MAKE_TAG_ID (CNTX
, PRIM
, 1))
1349 || (tag1
== MAKE_TAG_ID (CNTX
, CONS
, 1))
1350 || (tag1
== MAKE_TAG_ID (CNTX
, PRIM
, 2))
1351 || (tag1
== MAKE_TAG_ID (CNTX
, CONS
, 2)))
1353 elmtLen1
= BDecLen (b
, seqBytesDecoded
, env
);
1354 encoding
= new EXTERNALChoice
;
1355 encoding
->BDecContent (b
, tag1
, elmtLen1
, seqBytesDecoded
, env
);
1359 Asn1Error
<< "ERROR - SEQUENCE is missing non-optional elmt." << endl
;
1363 bytesDecoded
+= seqBytesDecoded
;
1364 if (elmtLen0
== INDEFINITE_LEN
)
1366 BDecEoc (b
, bytesDecoded
, env
);
1369 else if (seqBytesDecoded
!= elmtLen0
)
1371 Asn1Error
<< "ERROR - Length discrepancy on sequence." << endl
;
1376 } // EXTERNAL::BDecContent
1378 AsnLen
EXTERNAL::BEnc (BUF_TYPE b
)
1381 l
= BEncContent (b
);
1382 l
+= BEncConsLen (b
, l
);
1383 l
+= BEncTag1 (b
, UNIV
, CONS
, EXTERNAL_TAG_CODE
);
1387 void EXTERNAL::BDec (BUF_TYPE b
, AsnLen
&bytesDecoded
, ENV_TYPE env
)
1392 if ((tag
= BDecTag (b
, bytesDecoded
, env
)) != MAKE_TAG_ID (UNIV
, CONS
, EXTERNAL_TAG_CODE
))
1394 Asn1Error
<< "EXTERNAL::BDec: ERROR - wrong tag" << endl
;
1397 elmtLen1
= BDecLen (b
, bytesDecoded
, env
);
1398 BDecContent (b
, tag
, elmtLen1
, bytesDecoded
, env
);
1401 int EXTERNAL::BEncPdu (BUF_TYPE b
, AsnLen
&bytesEncoded
)
1403 bytesEncoded
= BEnc (b
);
1404 return !b
.WriteError();
1407 int EXTERNAL::BDecPdu (BUF_TYPE b
, AsnLen
&bytesDecoded
)
1413 if ((val
= setjmp (env
)) == 0)
1415 BDec (b
, bytesDecoded
, env
);
1416 return !b
.ReadError();
1422 void EXTERNAL::Print (ostream
&os
) const
1425 os
<< "{ -- SEQUENCE --" << endl
;
1426 indentG
+= stdIndentG
;
1428 if (NOT_NULL (direct_reference
))
1430 Indent (os
, indentG
);
1431 os
<< "direct-reference ";
1432 os
<< *direct_reference
;
1436 Indent (os
, indentG
);
1437 os
<< "direct-reference ";
1442 if (NOT_NULL (indirect_reference
))
1444 Indent (os
, indentG
);
1445 os
<< "indirect-reference ";
1446 os
<< *indirect_reference
;
1450 Indent (os
, indentG
);
1451 os
<< "indirect-reference ";
1456 if (NOT_NULL (data_value_descriptor
))
1458 Indent (os
, indentG
);
1459 os
<< "data-value-descriptor ";
1460 os
<< *data_value_descriptor
;
1464 Indent (os
, indentG
);
1465 os
<< "data-value-descriptor ";
1470 if (NOT_NULL (encoding
))
1472 Indent (os
, indentG
);
1478 Indent (os
, indentG
);
1485 indentG
-= stdIndentG
;
1486 Indent (os
, indentG
);
1489 } // EXTERNAL::Print