]> git.saurik.com Git - apple/security.git/blob - SecuritySNACCRuntime/c++-lib/inc/asn-real.h
64019c320cc760e304a179fb396743a9f27fe04e
[apple/security.git] / SecuritySNACCRuntime / c++-lib / inc / asn-real.h
1 /*
2 * Copyright (c) 2000-2001 Apple Computer, Inc. All Rights Reserved.
3 *
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
8 * using this file.
9 *
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.
16 */
17
18
19 // file: .../c++-lib/inc/asn-real.h - ASN.1 REAL type
20 //
21 // Mike Sample
22 // 92/07/02
23 // Copyright (C) 1992 Michael Sample and the University of British Columbia
24 //
25 // This library is free software; you can redistribute it and/or
26 // modify it provided that this copyright/license information is retained
27 // in original form.
28 //
29 // If you modify this file, you must clearly indicate your changes.
30 //
31 // This source code is distributed in the hope that it will be
32 // useful, but WITHOUT ANY WARRANTY; without even the implied warranty
33 // of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
34 //
35 // $Header: /cvs/Darwin/Security/SecuritySNACCRuntime/c++-lib/inc/asn-real.h,v 1.2 2001/06/21 21:57:00 dmitch Exp $
36 // $Log: asn-real.h,v $
37 // Revision 1.2 2001/06/21 21:57:00 dmitch
38 // Avoid global const PLUS_INFINITY, MINUS_INFINITY
39 //
40 // Revision 1.1.1.1 2001/05/18 23:14:06 mb
41 // Move from private repository to open source repository
42 //
43 // Revision 1.3 2001/05/05 00:59:18 rmurphy
44 // Adding darwin license headers
45 //
46 // Revision 1.2 2000/06/15 18:48:24 dmitch
47 // Snacc-generated source files, now part of CVS tree to allow for cross-platform build of snaccRuntime.
48 //
49 // Revision 1.1.1.1 2000/03/09 01:00:05 rmurphy
50 // Base Fortissimo Tree
51 //
52 // Revision 1.2 1999/03/21 02:07:33 mb
53 // Added Copy to every AsnType.
54 //
55 // Revision 1.1 1999/02/25 05:21:45 mb
56 // Added snacc c++ library
57 //
58 // Revision 1.5 1997/02/16 20:25:42 rj
59 // check-in of a few cosmetic changes
60 //
61 // Revision 1.4 1995/07/24 17:53:59 rj
62 // #if TCL ... #endif wrapped into #if META ... #endif
63 //
64 // changed `_' to `-' in file names.
65 //
66 // Revision 1.3 1994/10/08 04:18:09 rj
67 // code for meta structures added (provides information about the generated code itself).
68 //
69 // code for Tcl interface added (makes use of the above mentioned meta code).
70 //
71 // virtual inline functions (the destructor, the Clone() function, BEnc(), BDec() and Print()) moved from inc/*.h to src/*.C because g++ turns every one of them into a static non-inline function in every file where the .h file gets included.
72 //
73 // made Print() const (and some other, mainly comparison functions).
74 //
75 // several `unsigned long int' turned into `size_t'.
76 //
77 // Revision 1.2 1994/08/28 10:00:55 rj
78 // comment leader fixed.
79 //
80 // Revision 1.1 1994/08/28 09:20:41 rj
81 // first check-in. for a list of changes to the snacc-1.1 distribution please refer to the ChangeLog.
82
83 #ifndef _asn_real_h_
84 #define _asn_real_h_
85
86 class AsnReal: public AsnType
87 {
88 protected:
89 double value;
90
91 public:
92 AsnReal():
93 value (0.0)
94 {}
95 AsnReal (double val):
96 value (val)
97 {}
98
99 virtual AsnType *Clone() const;
100 virtual AsnType *Copy() const;
101
102 operator double() const { return value; }
103 AsnReal &operator = (double newvalue) { value = newvalue; return *this; }
104
105 AsnLen BEncContent (BUF_TYPE b);
106 void BDecContent (BUF_TYPE b, AsnTag tagId, AsnLen elmtLen, AsnLen &bytesDecoded, ENV_TYPE env);
107 AsnLen BEnc (BUF_TYPE b);
108 void BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env);
109
110 void Print (ostream &os) const;
111
112 PDU_MEMBER_MACROS
113
114 #if META
115 static const AsnRealTypeDesc _desc;
116
117 const AsnTypeDesc *_getdesc() const;
118
119 #if TCL
120 int TclGetVal (Tcl_Interp *) const;
121 int TclSetVal (Tcl_Interp *, const char *val);
122 #endif /* TCL */
123 #endif /* META */
124 };
125
126 extern double AsnPlusInfinity();
127 extern double AsnMinusInfinity();
128
129 #define PLUS_INFINITY AsnReal(AsnPlusInfinity())
130 #define MINUS_INFINITY AsnReal(AsnMinusInfinity())
131
132 #endif /* conditional include */