|
1 /* |
|
2 * Copyright (c) 2005 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: Iterator for landmark item search matches. |
|
15 * |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 // INCLUDE FILES |
|
21 #include <EPos_LandmarksErrors.h> |
|
22 #include "EPos_CPosLmLocalSearchIterator.h" |
|
23 |
|
24 // ============================ MEMBER FUNCTIONS =============================== |
|
25 |
|
26 // ----------------------------------------------------------------------------- |
|
27 // CPosLmLocalSearchIterator::CPosLmLocalSearchIterator |
|
28 // C++ default constructor can NOT contain any code, that |
|
29 // might leave. |
|
30 // ----------------------------------------------------------------------------- |
|
31 // |
|
32 CPosLmLocalSearchIterator::CPosLmLocalSearchIterator() |
|
33 : CPosLmItemIterator(), |
|
34 iCurrent(0) |
|
35 { |
|
36 } |
|
37 |
|
38 // ----------------------------------------------------------------------------- |
|
39 // CPosLmLocalSearchIterator::ConstructL |
|
40 // Symbian 2nd phase constructor can leave. |
|
41 // ----------------------------------------------------------------------------- |
|
42 // |
|
43 void CPosLmLocalSearchIterator::ConstructL( |
|
44 const RArray<TPosLmItemId>& aMatchArray) |
|
45 { |
|
46 for (TInt i = 0; i < aMatchArray.Count(); i++) |
|
47 { |
|
48 User::LeaveIfError(iIdArray.Append(aMatchArray[i])); |
|
49 } |
|
50 } |
|
51 |
|
52 // ----------------------------------------------------------------------------- |
|
53 // CPosLmLocalSearchIterator::NewL |
|
54 // Two-phased constructor. |
|
55 // ----------------------------------------------------------------------------- |
|
56 // |
|
57 CPosLmLocalSearchIterator* CPosLmLocalSearchIterator::NewL( |
|
58 const RArray<TPosLmItemId>& aMatchArray) |
|
59 { |
|
60 CPosLmLocalSearchIterator* self = new(ELeave) CPosLmLocalSearchIterator(); |
|
61 CleanupStack::PushL(self); |
|
62 self->ConstructL(aMatchArray); |
|
63 CleanupStack::Pop(self); |
|
64 return self; |
|
65 } |
|
66 |
|
67 // ----------------------------------------------------------------------------- |
|
68 // CPosLmLocalSearchIterator::NewL |
|
69 // Two-phased constructor. |
|
70 // ----------------------------------------------------------------------------- |
|
71 // |
|
72 CPosLmLocalSearchIterator* CPosLmLocalSearchIterator::NewL() |
|
73 { |
|
74 return new (ELeave) CPosLmLocalSearchIterator(); |
|
75 } |
|
76 |
|
77 // Destructor |
|
78 CPosLmLocalSearchIterator::~CPosLmLocalSearchIterator() |
|
79 { |
|
80 iIdArray.Close(); |
|
81 } |
|
82 |
|
83 // ----------------------------------------------------------------------------- |
|
84 // CPosLmLocalSearchIterator::NextL |
|
85 // |
|
86 // (other items were commented in a header). |
|
87 // ----------------------------------------------------------------------------- |
|
88 // |
|
89 TPosLmItemId CPosLmLocalSearchIterator::NextL() |
|
90 { |
|
91 if (iCurrent >= iIdArray.Count()) |
|
92 { |
|
93 return KPosLmNullItemId; |
|
94 } |
|
95 |
|
96 return iIdArray[iCurrent++]; |
|
97 } |
|
98 |
|
99 // ----------------------------------------------------------------------------- |
|
100 // CPosLmLocalSearchIterator::Reset |
|
101 // |
|
102 // (other items were commented in a header). |
|
103 // ----------------------------------------------------------------------------- |
|
104 // |
|
105 void CPosLmLocalSearchIterator::Reset() |
|
106 { |
|
107 iCurrent = 0; |
|
108 } |
|
109 |
|
110 // ----------------------------------------------------------------------------- |
|
111 // CPosLmLocalSearchIterator::NumOfItemsL |
|
112 // |
|
113 // (other items were commented in a header). |
|
114 // ----------------------------------------------------------------------------- |
|
115 // |
|
116 TUint CPosLmLocalSearchIterator::NumOfItemsL() |
|
117 { |
|
118 return iIdArray.Count(); |
|
119 } |
|
120 |
|
121 // ----------------------------------------------------------------------------- |
|
122 // CPosLmLocalSearchIterator::GetItemIdsL |
|
123 // |
|
124 // (other items were commented in a header). |
|
125 // ----------------------------------------------------------------------------- |
|
126 // |
|
127 void CPosLmLocalSearchIterator::GetItemIdsL( |
|
128 RArray<TPosLmItemId>& aIdArray, |
|
129 TInt aStartIndex, |
|
130 TInt aNumOfItems) |
|
131 { |
|
132 if (aStartIndex < 0 || aStartIndex >= iIdArray.Count() || |
|
133 aStartIndex + aNumOfItems > iIdArray.Count()) |
|
134 { |
|
135 Panic(KPosLandmarksClientPanic, |
|
136 EPosSpecifiedIntervalLiesOutsideIteratedSet); |
|
137 } |
|
138 |
|
139 aIdArray.Reset(); |
|
140 |
|
141 for (TInt i = aStartIndex; i < aStartIndex + aNumOfItems; i++) |
|
142 { |
|
143 User::LeaveIfError(aIdArray.Append(iIdArray[i])); |
|
144 } |
|
145 } |
|
146 |
|
147 // End of File |