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