|
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: |
|
15 * ?description_line |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 // INCLUDES |
|
21 |
|
22 #include <e32math.h> |
|
23 #include <e32svr.h> |
|
24 #include <e32std.h> |
|
25 #include "FT_CCategoryLandmarkSearchResult.h" |
|
26 |
|
27 //CONSTANTS |
|
28 const TInt KMaxFieldLength = 80; |
|
29 const TInt KMaxLineLength=255; |
|
30 |
|
31 //const TReal KReal32Accuracy = 5.96E-8; |
|
32 /* |
|
33 const TReal KAccuracyHigh = 5.96E-8; |
|
34 const TReal KAccuracyMedium = 4E-5; |
|
35 const TReal KAccuracyLow = 4E-3; |
|
36 */ |
|
37 |
|
38 // C++ Constructor |
|
39 CCategoryLandmarkSearchResult::CCategoryLandmarkSearchResult() |
|
40 { |
|
41 } |
|
42 |
|
43 CCategoryLandmarkSearchResult* CCategoryLandmarkSearchResult::NewL(const TDesC& aDes) |
|
44 { |
|
45 CCategoryLandmarkSearchResult* self = new(ELeave) CCategoryLandmarkSearchResult; |
|
46 CleanupStack::PushL(self); |
|
47 self->ConstructL(aDes); |
|
48 CleanupStack::Pop(); |
|
49 return self; |
|
50 } |
|
51 |
|
52 // C++ destructor |
|
53 CCategoryLandmarkSearchResult::~CCategoryLandmarkSearchResult() |
|
54 { |
|
55 delete iCategoryName; |
|
56 iCategoryName = NULL; |
|
57 |
|
58 iPositionFields.Close(); |
|
59 } |
|
60 |
|
61 void CCategoryLandmarkSearchResult::ConstructL(const TDesC& aDes) |
|
62 { |
|
63 TLex line(aDes); |
|
64 line.Mark(); |
|
65 TInt redefined=0; |
|
66 TInt id=0; |
|
67 |
|
68 if (line.Peek() != '#' && line.Peek() != '\t') |
|
69 { |
|
70 TInt index=0; |
|
71 while (line.Peek() != '\n' && !(line.Peek()).Eos()) |
|
72 { |
|
73 line.Inc(); |
|
74 if (line.Peek() == '\t') |
|
75 { |
|
76 TPtrC token = line.MarkedToken(); |
|
77 TLex val(token); |
|
78 |
|
79 switch(index) |
|
80 { |
|
81 case ECategoryName: |
|
82 iCategoryName = token.AllocL(); |
|
83 break; |
|
84 /* case EAttributes: |
|
85 ParseAttributesL(token); |
|
86 break; |
|
87 */ |
|
88 case ECategoryId: |
|
89 //iTextCriteria = token.AllocL(); |
|
90 val.Val(id); |
|
91 iCategoryId = id; |
|
92 break; |
|
93 /* |
|
94 case EPositionFields: |
|
95 ParsePositionFields(token); |
|
96 break; |
|
97 */ |
|
98 case ELmSearchResult: |
|
99 ParseSearchResult(token); |
|
100 break; |
|
101 case ERedefined: |
|
102 val.Val(redefined); |
|
103 if (redefined == 1) |
|
104 { |
|
105 iRedefined = ETrue; |
|
106 } |
|
107 break; |
|
108 } |
|
109 line.Inc(); |
|
110 while (line.Peek() == '\t') // Empty value |
|
111 { |
|
112 line.Inc(); |
|
113 ++index; |
|
114 } |
|
115 line.Mark(); |
|
116 ++index; |
|
117 } |
|
118 } |
|
119 } |
|
120 //Print(); |
|
121 } |
|
122 |
|
123 // --------------------------------------------------------- |
|
124 // CCategoryLandmarkSearchResult::ParsePositionFields() |
|
125 // |
|
126 // (other items were commented in a header). |
|
127 // --------------------------------------------------------- |
|
128 // |
|
129 /* |
|
130 void CCategoryLandmarkSearchResult::ParsePositionFields(const TDesC& aDes) |
|
131 { |
|
132 TLex line(aDes); |
|
133 line.Mark(); |
|
134 TInt value=0; |
|
135 |
|
136 while (!(line.Peek()).Eos()) |
|
137 { |
|
138 line.Inc(); |
|
139 if (line.Peek() == ',' || (line.Peek()).Eos()) |
|
140 { |
|
141 TPtrC token = line.MarkedToken(); |
|
142 TLex val(token); |
|
143 val.Val(value); |
|
144 iPositionFields.Append(value); |
|
145 |
|
146 if (line.Peek() == ',') |
|
147 { |
|
148 line.Inc(); |
|
149 line.Mark(); |
|
150 } |
|
151 } |
|
152 } |
|
153 } |
|
154 */ |
|
155 // --------------------------------------------------------- |
|
156 // CCategoryLandmarkSearchResult::Print() |
|
157 // |
|
158 // (other items were commented in a header). |
|
159 // --------------------------------------------------------- |
|
160 // |
|
161 void CCategoryLandmarkSearchResult::Print() |
|
162 { |
|
163 TBuf<KMaxLineLength> print; |
|
164 |
|
165 TChar del(','); |
|
166 |
|
167 print.Append(*iCategoryName); |
|
168 print.Append(del); |
|
169 |
|
170 TBuf<KMaxFieldLength> info; |
|
171 _LIT(KAttrInfo, "%x"); |
|
172 info.Format(KAttrInfo, iAttributes); |
|
173 print.Append(info); |
|
174 print.Append(del); |
|
175 |
|
176 _LIT(KIntInfo, "%d"); |
|
177 TInt i=0; |
|
178 for (i=0; i<iPositionFields.Count(); i++) |
|
179 { |
|
180 info.Format(KIntInfo, iPositionFields[i]); |
|
181 print.Append(info); |
|
182 print.Append(del); |
|
183 } |
|
184 |
|
185 for (i=0; i<iSearchResult.Count(); i++) |
|
186 { |
|
187 info.Format(KIntInfo, iSearchResult[i]); |
|
188 print.Append(info); |
|
189 print.Append(del); |
|
190 } |
|
191 |
|
192 RDebug::Print(print); |
|
193 } |
|
194 |
|
195 // --------------------------------------------------------- |
|
196 // CCategoryLandmarkSearchResult::CategoryName() |
|
197 // |
|
198 // (other items were commented in a header). |
|
199 // --------------------------------------------------------- |
|
200 // |
|
201 TPtrC CCategoryLandmarkSearchResult::CategoryName() const |
|
202 { |
|
203 return *iCategoryName; |
|
204 } |
|
205 |
|
206 |
|
207 // --------------------------------------------------------- |
|
208 // CCategoryLandmarkSearchResult::CategoryId() |
|
209 // |
|
210 // (other items were commented in a header). |
|
211 // --------------------------------------------------------- |
|
212 // |
|
213 TPosLmItemId CCategoryLandmarkSearchResult::CategoryId() const |
|
214 { |
|
215 return iCategoryId; |
|
216 } |
|
217 |
|
218 // --------------------------------------------------------- |
|
219 // CCategoryLandmarkSearchResult::PositionFields |
|
220 // |
|
221 // (other items were commented in a header). |
|
222 // --------------------------------------------------------- |
|
223 // |
|
224 const RArray<TUint>& CCategoryLandmarkSearchResult::PositionFields() const |
|
225 { |
|
226 return iPositionFields; |
|
227 } |
|
228 |
|
229 // End of File |