predictivesearch/PcsAlgorithm/Algorithm1/src/CPcsAlgorithm1Utils.cpp
branchRCL_3
changeset 13 a6539d1e8e43
parent 12 4ae315f230bc
--- a/predictivesearch/PcsAlgorithm/Algorithm1/src/CPcsAlgorithm1Utils.cpp	Tue May 25 12:26:45 2010 +0300
+++ b/predictivesearch/PcsAlgorithm/Algorithm1/src/CPcsAlgorithm1Utils.cpp	Wed Jun 09 09:26:27 2010 +0300
@@ -79,10 +79,33 @@
 }
 
 // ----------------------------------------------------------------------------
+// CPcsAlgorithm1Utils::CompareByCharacter()
+// Compare by character.
+// ----------------------------------------------------------------------------
+TInt CPcsAlgorithm1Utils::CompareByCharacter( const TChar& aFirst, const TChar& aSecond )
+{
+    TInt retValue;
+    if ( aFirst == aSecond )
+        {
+        retValue = 0;
+        }
+    else if ( aFirst < aSecond )
+        {
+        retValue = -1;
+        }
+    else 
+        {
+        retValue = 1;
+        }
+
+    return retValue;
+}
+
+// ----------------------------------------------------------------------------
 // CPcsAlgorithm1Utils::CompareByLength()
 // Compare by length.
 // ----------------------------------------------------------------------------
-TInt CPcsAlgorithm1Utils::CompareByLength ( const HBufC& aFirst, const HBufC& aSecond )
+TInt CPcsAlgorithm1Utils::CompareByLength( const HBufC& aFirst, const HBufC& aSecond )
 {
     return ( aFirst.Length() - aSecond.Length() );
 }
@@ -91,7 +114,7 @@
 // CPcsAlgorithm1Utils::CompareExact()
 // Compare strings exactly case sensitively.
 // ----------------------------------------------------------------------------
-TBool CPcsAlgorithm1Utils::CompareExact ( const TDesC& aFirst, const TDesC& aSecond )
+TBool CPcsAlgorithm1Utils::CompareExact( const TDesC& aFirst, const TDesC& aSecond )
 {
     return aFirst == aSecond;
 }
@@ -100,7 +123,7 @@
 // CPcsAlgorithm1Utils::CompareCollate()
 // Compare strings with collate rules depending on locale.
 // ----------------------------------------------------------------------------
-TInt CPcsAlgorithm1Utils::CompareCollate ( const TDesC& aFirst, const TDesC& aSecond )
+TInt CPcsAlgorithm1Utils::CompareCollate( const TDesC& aFirst, const TDesC& aSecond )
 {
     return CPcsAlgorithm1Utils::MyCompareC(aFirst, aSecond);
 }
@@ -146,9 +169,11 @@
         {
         for ( TInt i = 0; i < aPsQuery.Count(); i++ )
             {
-            CPsQueryItem& currentItem = aPsQuery.GetItemAtL(i);
-            if ( (CPcsKeyMap::IsModePredictive(currentItem.Mode()))
-                 && (aLeft[i] != aRight[i]) )
+            CPsQueryItem* currentItemPtr;
+            TRAPD ( err, currentItemPtr = &(aPsQuery.GetItemAtL(i)) );
+            if ( err != KErrNone
+                 || ( CPcsKeyMap::IsModePredictive(currentItemPtr->Mode())
+                    && aLeft[i] != aRight[i] ) )
                 {
                 comparison = EFalse;
                 break;