|
1 /* |
|
2 * Copyright (c) 2005-2007 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: |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef TVPBKMAPPINGSFINDTOOL_H |
|
20 #define TVPBKMAPPINGSFINDTOOL_H |
|
21 |
|
22 #include "CVPbkVCardIdNameMapping.h" |
|
23 |
|
24 /** |
|
25 * Class searches from array a name or an id, specified by name or id. |
|
26 */ |
|
27 NONSHARABLE_CLASS( TVPbkMappingsFindTool ) |
|
28 { |
|
29 public: |
|
30 static TInt FindIdByName( |
|
31 const TDesC8& aName, |
|
32 const TArray<CVPbkVCardIdNameMapping*>& aArray ); |
|
33 |
|
34 static const TDesC8& FindNameById( |
|
35 TInt aId, const TArray<CVPbkVCardIdNameMapping*>& aArray ); |
|
36 private: |
|
37 TVPbkMappingsFindTool() { } |
|
38 }; |
|
39 |
|
40 TInt TVPbkMappingsFindTool::FindIdByName( |
|
41 const TDesC8& aName, const TArray<CVPbkVCardIdNameMapping*>& aArray ) |
|
42 { |
|
43 TInt retVal( KErrNotFound ); |
|
44 for ( TInt i = 0; |
|
45 i < aArray.Count() && ( retVal == KErrNotFound ); |
|
46 ++i ) |
|
47 { |
|
48 const CVPbkVCardIdNameMapping* mapping = aArray[ i ]; |
|
49 if ( mapping->Name().Compare( aName ) == 0 ) |
|
50 { |
|
51 retVal = mapping->Id(); |
|
52 } |
|
53 } |
|
54 return retVal; |
|
55 } |
|
56 |
|
57 const TDesC8& TVPbkMappingsFindTool::FindNameById( |
|
58 TInt aId, const TArray<CVPbkVCardIdNameMapping*>& aArray ) |
|
59 { |
|
60 for ( TInt i = 0; i < aArray.Count(); ++i ) |
|
61 { |
|
62 const CVPbkVCardIdNameMapping* mapping = aArray[ i ]; |
|
63 if ( mapping->Id() == aId ) |
|
64 { |
|
65 return mapping->Name(); |
|
66 } |
|
67 } |
|
68 return KNullDesC8; |
|
69 } |
|
70 |
|
71 #endif // TVPBKMAPPINGSFINDTOOL_H |
|
72 //End of file |
|
73 |