158 RArray<TInt> supportedDataFields; |
158 RArray<TInt> supportedDataFields; |
159 CleanupClosePushL( supportedDataFields ); |
159 CleanupClosePushL( supportedDataFields ); |
160 cache->GetDataFields(supportedDataFields); |
160 cache->GetDataFields(supportedDataFields); |
161 |
161 |
162 // Get the filtered data fields for this data store |
162 // Get the filtered data fields for this data store |
163 TUint8 filteredDataMatch = FilterDataFieldsL(requiredDataFields, |
163 TUint8 filteredDataMatch = CPcsAlgorithm1Utils::FilterDataFieldsL(requiredDataFields, |
164 supportedDataFields); |
164 supportedDataFields); |
165 |
165 |
166 // Filter the results now |
166 // Filter the results now |
167 FilterResultsMultiL(filterHelper, |
167 FilterResultsMultiL(filterHelper, |
168 elements, |
168 elements, |
169 aPsQuery, |
169 aPsQuery, |
229 RPointerArray<TDesC>& aMatchSeq, |
229 RPointerArray<TDesC>& aMatchSeq, |
230 RArray<TPsMatchLocation>& aMatchLocation ) |
230 RArray<TPsMatchLocation>& aMatchLocation ) |
231 { |
231 { |
232 PRINT ( _L("Enter CPcsAlgorithm1MultiSearchHelper::SearchMatchSeqMultiL") ); |
232 PRINT ( _L("Enter CPcsAlgorithm1MultiSearchHelper::SearchMatchSeqMultiL") ); |
233 RPointerArray<HBufC> descriptorsQueryList; |
233 RPointerArray<HBufC> descriptorsQueryList; |
|
234 CleanupResetAndDestroyPushL( descriptorsQueryList ); |
234 ConvertQueryToListL(aPsQuery, descriptorsQueryList); |
235 ConvertQueryToListL(aPsQuery, descriptorsQueryList); |
235 TLex lex(aData); |
236 TLex lex(aData); |
236 while ( !lex.Eos() ) // Search thru all words |
237 while ( !lex.Eos() ) // Search thru all words |
237 { |
238 { |
238 TPtrC currentWord = lex.NextToken(); // next word |
239 TPtrC currentWord = lex.NextToken(); // next word |
250 |
251 |
251 if ( CPcsAlgorithm1Utils::MyCompareKeyAndString(convertedWord, *currentQuery, *aPsQuery[queryIndex]) ) |
252 if ( CPcsAlgorithm1Utils::MyCompareKeyAndString(convertedWord, *currentQuery, *aPsQuery[queryIndex]) ) |
252 { |
253 { |
253 newLocation.length = currentQuery->Length(); |
254 newLocation.length = currentQuery->Length(); |
254 aMatchLocation.AppendL( newLocation ); |
255 aMatchLocation.AppendL( newLocation ); |
255 AppendMatchToSeqL( aMatchSeq, currentWord.Left(newLocation.length) ); |
256 TPtrC matchPart = currentWord.Left(newLocation.length); |
|
257 CPcsAlgorithm1Utils::AppendMatchToSeqL( aMatchSeq, matchPart ); |
256 } |
258 } |
257 } |
259 } |
258 } |
260 } |
259 descriptorsQueryList.ResetAndDestroy(); |
261 CleanupStack::PopAndDestroy( &descriptorsQueryList ); // ResetAndDestroy |
260 PRINT ( _L("End CPcsAlgorithm1MultiSearchHelper::SearchMatchSeqMultiL") ); |
262 PRINT ( _L("End CPcsAlgorithm1MultiSearchHelper::SearchMatchSeqMultiL") ); |
261 } |
|
262 |
|
263 // ---------------------------------------------------------------------------- |
|
264 // CPcsAlgorithm1MultiSearchHelper::AppendMatchToSeqL |
|
265 // ---------------------------------------------------------------------------- |
|
266 void CPcsAlgorithm1MultiSearchHelper::AppendMatchToSeqL( |
|
267 RPointerArray<TDesC>& aMatchSeq, const TDesC& aMatch ) |
|
268 { |
|
269 HBufC* seq = aMatch.AllocLC(); |
|
270 seq->Des().UpperCase(); |
|
271 TIdentityRelation<TDesC> rule(CPcsAlgorithm1Utils::CompareExact); |
|
272 if ( aMatchSeq.Find(seq, rule) == KErrNotFound ) |
|
273 { |
|
274 aMatchSeq.Append(seq); |
|
275 CleanupStack::Pop( seq ); |
|
276 } |
|
277 else |
|
278 { |
|
279 CleanupStack::PopAndDestroy( seq ); |
|
280 } |
|
281 } |
263 } |
282 |
264 |
283 // ---------------------------------------------------------------------------- |
265 // ---------------------------------------------------------------------------- |
284 // CPcsAlgorithm1MultiSearchHelper::LookupMatchL |
266 // CPcsAlgorithm1MultiSearchHelper::LookupMatchL |
285 // ---------------------------------------------------------------------------- |
267 // ---------------------------------------------------------------------------- |
297 TLex lex( aData ); |
279 TLex lex( aData ); |
298 while ( !lex.Eos() ) |
280 while ( !lex.Eos() ) |
299 { |
281 { |
300 TPtrC currentWord = lex.NextToken(); |
282 TPtrC currentWord = lex.NextToken(); |
301 PRINT2( _L("idx len: %d %d"), lex.Offset() - currentWord.Length(), currentWord.Length() ); |
283 PRINT2( _L("idx len: %d %d"), lex.Offset() - currentWord.Length(), currentWord.Length() ); |
302 dataWordIndexes.AppendL( lex.Offset() - currentWord.Length() ); |
284 dataWordIndexes.AppendL( lex.Offset() - currentWord.Length() ); |
303 dataWordLengths.AppendL( currentWord.Length() ); |
285 dataWordLengths.AppendL( currentWord.Length() ); |
304 } |
286 } |
305 |
287 |
306 RArray<TInt> queryIndexes; |
288 RArray<TInt> queryIndexes; |
307 RArray<TPtrC> convertedQueriesAsDes; |
289 RArray<TPtrC> convertedQueriesAsDes; |
554 SetWordMap(dataIndex, wordIndex); |
536 SetWordMap(dataIndex, wordIndex); |
555 } |
537 } |
556 |
538 |
557 // Extract matched character sequence and fill in temp array |
539 // Extract matched character sequence and fill in temp array |
558 TInt len = tmpQuery->Length(); |
540 TInt len = tmpQuery->Length(); |
559 HBufC* seq = tmpData.Left(len).AllocLC(); |
541 TPtrC seq = tmpData.Left(len); |
560 |
542 CPcsAlgorithm1Utils::AppendMatchToSeqL( tmpMatchSet, seq ); |
561 seq->Des().UpperCase(); |
|
562 TIdentityRelation<TDesC> searchRule(CPcsAlgorithm1Utils::CompareExact); |
|
563 if ( tmpMatchSet.Find(seq, searchRule) == KErrNotFound ) |
|
564 { |
|
565 tmpMatchSet.AppendL(seq); |
|
566 CleanupStack::Pop(seq); |
|
567 } |
|
568 else |
|
569 { |
|
570 CleanupStack::PopAndDestroy(seq); |
|
571 seq = NULL; |
|
572 } |
|
573 } |
543 } |
574 } |
544 } |
575 |
545 |
576 // Next word |
546 // Next word |
577 tmpData.Set(lex.NextToken()); |
547 tmpData.Set(lex.NextToken()); |
722 } |
692 } |
723 |
693 |
724 return query; |
694 return query; |
725 } |
695 } |
726 |
696 |
727 // ---------------------------------------------------------------------------- |
|
728 // CPcsAlgorithm1MultiSearchHelper::FilterDataFieldsL() |
|
729 // Constructs a bit pattern using the required/supported data fields |
|
730 // For example, 6, 4 and 27 are supported fields <-- 00000111 |
|
731 // 6 and 4 are required fields <-- 00000011 |
|
732 // Bit pattern returned is 00000011. |
|
733 // ---------------------------------------------------------------------------- |
|
734 TUint8 CPcsAlgorithm1MultiSearchHelper::FilterDataFieldsL(RArray<TInt>& aRequiredDataFields, |
|
735 RArray<TInt>& aSupportedDataFields) |
|
736 { |
|
737 TUint8 filteredMatch = 0x0; |
|
738 |
|
739 for ( TInt i = 0; i < aSupportedDataFields.Count(); i++ ) |
|
740 { |
|
741 for ( TInt j = 0; j < aRequiredDataFields.Count(); j++ ) |
|
742 { |
|
743 if ( aSupportedDataFields[i] == aRequiredDataFields[j] ) |
|
744 { |
|
745 TUint8 val = 1 << i; |
|
746 filteredMatch |= val; |
|
747 } |
|
748 } |
|
749 } |
|
750 |
|
751 return filteredMatch; |
|
752 } |
|
753 |
|
754 // End of file |
697 // End of file |