|
1 /* |
|
2 * Copyright (c) 2002 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: this class handls key operation |
|
15 * |
|
16 */ |
|
17 |
|
18 #ifndef __TPENGSTORAGESERVERBTREEKEYS_H__ |
|
19 #define __TPENGSTORAGESERVERBTREEKEYS_H__ |
|
20 |
|
21 // INCLUDES |
|
22 #include <s32btree.h> |
|
23 #include "CPEngDataEntry.h" |
|
24 #include "PEngStorageServerCommon.h" |
|
25 |
|
26 |
|
27 // CLASS DECLARATION |
|
28 class TPEngBaseKey : public MBtreeKey |
|
29 { |
|
30 public: |
|
31 /* |
|
32 * Return key which is between aLeft and aRight. Can be also equal to left. |
|
33 */ |
|
34 void Between( const TAny* aLeft, const TAny* aRight, TBtreePivot& aPivot ) const |
|
35 { |
|
36 __ASSERT_ALWAYS( aLeft && aRight, User::Panic( KStorageServerName, EErrorInBTree ) ); |
|
37 //Return key equal to left. |
|
38 aPivot.Copy( reinterpret_cast<const TUint8*>( aLeft ), 4 ); |
|
39 } |
|
40 |
|
41 //Compare two keys. |
|
42 TInt Compare( const TAny* aLeft, const TAny* aRight ) const |
|
43 { |
|
44 __ASSERT_ALWAYS( aLeft && aRight, User::Panic( KStorageServerName, EErrorInBTree ) ); |
|
45 HBufC* left = *reinterpret_cast<HBufC**>( const_cast<TAny*>( aLeft ) ); |
|
46 HBufC* right = *reinterpret_cast<HBufC**>( const_cast<TAny*>( aRight ) ); |
|
47 TInt ret = left->CompareF( *right ); |
|
48 return ret; |
|
49 } |
|
50 }; |
|
51 |
|
52 class TPEngDataEntryKey : public TPEngBaseKey |
|
53 { |
|
54 public: |
|
55 |
|
56 //Get pointer to entry key.(HBufC**) |
|
57 const TAny* Key( const TAny* anEntry ) const |
|
58 { |
|
59 __ASSERT_ALWAYS( anEntry, User::Panic( KStorageServerName, EErrorInBTree ) ); |
|
60 CPEngDataEntry* entry = *reinterpret_cast<CPEngDataEntry**>( const_cast<TAny*>( anEntry ) ); |
|
61 return entry->KeyBuffer(); |
|
62 } |
|
63 }; |
|
64 |
|
65 #endif // __TPENGSTORAGESERVERBTREEKEYS_H__ |
|
66 |
|
67 // End of File |