]>
git.saurik.com Git - apple/security.git/blob - SecuritySNACCRuntime/c++-lib/inc/asn-list.h
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 // file: .../c++-lib/inc/asn-list.h
21 // **** NOTE - this is not used or tested due to problems with gcc ****
25 // Copyright (C) 1992 Michael Sample and the University of British Columbia
27 // This library is free software; you can redistribute it and/or
28 // modify it provided that this copyright/license information is retained
31 // If you modify this file, you must clearly indicate your changes.
33 // This source code is distributed in the hope that it will be
34 // useful, but WITHOUT ANY WARRANTY; without even the implied warranty
35 // of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
37 // $Header: /cvs/root/Security/SecuritySNACCRuntime/c++-lib/inc/Attic/asn-list.h,v 1.1.1.1 2001/05/18 23:14:06 mb Exp $
38 // $Log: asn-list.h,v $
39 // Revision 1.1.1.1 2001/05/18 23:14:06 mb
40 // Move from private repository to open source repository
42 // Revision 1.3 2001/05/05 00:59:18 rmurphy
43 // Adding darwin license headers
45 // Revision 1.2 2000/06/15 18:48:24 dmitch
46 // Snacc-generated source files, now part of CVS tree to allow for cross-platform build of snaccRuntime.
48 // Revision 1.1.1.1 2000/03/09 01:00:05 rmurphy
49 // Base Fortissimo Tree
51 // Revision 1.2 1999/03/21 02:07:32 mb
52 // Added Copy to every AsnType.
54 // Revision 1.1 1999/02/25 05:21:43 mb
55 // Added snacc c++ library
57 // Revision 1.6 1997/02/16 20:25:38 rj
58 // check-in of a few cosmetic changes
60 // Revision 1.5 1995/07/24 17:46:54 rj
61 // operator == and != return bool instead of int.
63 // #if TCL ... #endif wrapped into #if META ... #endif
65 // changed `_' to `-' in file names.
67 // Revision 1.4 1995/02/18 14:06:09 rj
68 // #pragma interface/implementation are GNU specific and need to be wrapped.
70 // Revision 1.3 1994/10/08 04:18:05 rj
71 // code for meta structures added (provides information about the generated code itself).
73 // code for Tcl interface added (makes use of the above mentioned meta code).
75 // 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.
77 // made Print() const (and some other, mainly comparison functions).
79 // several `unsigned long int' turned into `size_t'.
81 // Revision 1.2 1994/08/28 10:00:51 rj
82 // comment leader fixed.
84 // Revision 1.1 1994/08/28 09:20:37 rj
85 // first check-in. for a list of changes to the snacc-1.1 distribution please refer to the ChangeLog.
95 #include "shmmgr.h" // Guido Grassel 5.8.93
96 #endif /* _IBM_ENC_ */
102 class AsnList
: public MemMgr
// Guido Grassel 12.8.93
103 #endif /* _IBM_ENC_ */
106 unsigned long int count
;
110 AsnListElmt
* next
, * prev
;
111 } * first
, * curr
, * last
;
114 AsnListElmt
* first
, * curr
, * last
;
115 #endif /* _IBM_ENC_ */
125 friend ostream
& operator << ( ostream
& os
, AsnList
& l
);
127 void SetCurrElmt ( unsigned long int index
);
128 void SetCurrToFirst () { curr
= first
; }
129 void SetCurrToLast () { curr
= last
; }
131 // reading member fcns
132 int Count () { return count
; }
133 T
* First () { return count
> 0 ? & first
-> elmt
: NULL
; }
134 T
* Last () { return count
> 0 ? & last
-> elmt
: NULL
; }
135 T
* Curr () { return curr
? & curr
-> elmt
: NULL
; }
136 T
* Next () { return curr
&& curr
-> next
? & curr
-> next
-> elmt
: NULL
; }
137 T
* Prev () { return curr
&& curr
-> prev
? & curr
-> prev
-> elmt
: NULL
; }
139 // routines that move the curr elmt
140 T
* GoNext () { if ( curr
) curr
= curr
-> next
; return Curr (); }
141 T
* GoPrev () { if ( curr
) curr
= curr
-> prev
; return Curr (); }
143 // write & alloc fcns - returns new elmt
144 T
& Append (); // add elmt to end of list
145 T
& Prepend (); // add elmt to begginning of list
146 // T &InsertBefore(); insert elmt before current elmt
147 // T &InsertAfter(); insert elmt after current elmt
149 // write & alloc & copy - returns list after copying elmt
150 AsnList
& AppendAndCopy ( T
& elmt
); // add elmt to end of list
151 AsnList
& PrependAndCopy ( T
& elmt
); // add elmt to begginning of list
152 // AsnList &InsertBeforeAndCopy (T &elmt); insert elmt before current elmt
153 // AsnList &InsertAfterAndCopy (T &elmt); insert elmt after current elmt
155 virtual AsnType
* Clone () const ;
156 virtual AsnType
* Copy () const ;
158 // encode and decode routines
159 AsnLen
BEncContent ( BUF_TYPE b
);
160 void BDecContent ( BUF_TYPE b
, AsnTag tagId
, AsnLen elmtLen
, AsnLen
& bytesDecoded
, ENV_TYPE env
);
161 AsnLen
BEnc ( BUF_TYPE b
);
162 void BDec ( BUF_TYPE b
, AsnLen
& bytesDecoded
, ENV_TYPE env
);
167 static const AsnTypeDesc _desc
;
169 const AsnTypeDesc
* _getdesc () const ;
172 int TclGetVal ( Tcl_Interp
*) const ;
173 int TclSetVal ( Tcl_Interp
*, const char * val
);
178 // This causes gcc2 on C++ to choke
181 template < class T
, class U
>
182 int ListsEquiv ( AsnList
< T
> & l1
, AsnList
< U
> & l2
);
184 template < class T
, class U
>
185 inline bool operator == ( AsnList
< T
> & l1
, AsnList
< U
> & l2
)
187 return ListsEquiv ( l1
, l2
);
190 template < class T
, class U
>
191 inline bool operator != ( AsnList
< T
> & l1
, AsnList
< U
> & l2
)
193 return ! ListsEquiv ( l1
, l2
);
197 #endif /* conditional include */