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.
22 #include <Security/utilities.h>
23 #include <Security/walkers.h>
24 #include <Security/cssmtype.h>
31 // @@@ Should not use using in headers.
37 //----------------------------------------------------------------
38 //typedef struct cssm_net_address {
39 // CSSM_NET_ADDRESS_TYPE AddressType;
41 //} CSSM_NET_ADDRESS, *CSSM_NET_ADDRESS_PTR;
42 //----------------------------------------------------------------
44 // XXX TODO: Make CssmNetAddress use a factory to constuct netadrress objects based on CSSM_NET_ADDRESS_TYPE!
45 class CssmNetAddress
: public PodWrapper
<CssmNetAddress
, CSSM_NET_ADDRESS
>
48 // Create a CssmNetAddress wrapper. Copies inAddress.Data
49 CssmNetAddress(CSSM_DB_RECORDTYPE inAddressType
, const CssmData
&inAddress
);
50 CssmNetAddress(const CSSM_NET_ADDRESS
&other
);
52 CSSM_DB_RECORDTYPE
addressType() const { return AddressType
; }
53 const CssmData
&address() const { return CssmData::overlay(Address
); }
54 bool operator <(const CssmNetAddress
&other
) const
56 return AddressType
!= other
.AddressType
? AddressType
< other
.AddressType
: address() < other
.address();
63 DbName (const char *inDbName
, const CSSM_NET_ADDRESS
*inDbLocation
);
64 DbName(const DbName
&other
);
65 DbName
&operator =(const DbName
&other
);
67 const string
&dbName() const { return mDbName
; }
68 const CssmNetAddress
*dbLocation() const { return mDbLocation
; }
69 bool operator <(const DbName
&other
) const
71 // If mDbNames are not equal return whether our mDbName is less than others mDbName.
72 if (mDbName
!= other
.mDbName
)
73 return mDbName
< other
.mDbName
;
75 // DbNames are equal so check for pointer equality of DbLocations
76 if (mDbLocation
== other
.mDbLocation
)
79 // If either DbLocations is nil the one that is nil is less than the other.
80 if (mDbLocation
== nil
|| other
.mDbLocation
== nil
)
81 return mDbLocation
< other
.mDbLocation
;
83 // Return which mDbLocation is smaller.
84 return *mDbLocation
< *other
.mDbLocation
;
86 bool operator ==(const DbName
&other
) const
87 { return (!(*this < other
)) && (!(other
< *this)); }
88 bool operator !=(const DbName
&other
) const
89 { return *this < other
|| other
< *this; }
93 CssmNetAddress
*mDbLocation
;
100 template<class Action
>
101 CssmNetAddress
*walk(Action
&operate
, CssmNetAddress
* &addr
)
104 walk(operate
, addr
->Address
);
108 } // end namespace DataWalkers
110 } // end namespace Security