predictivesearch/PcsAlgorithm/Algorithm1/src/CPcsAlgorithm1Utils.cpp
branchRCL_3
changeset 39 a6539d1e8e43
parent 35 4ae315f230bc
child 64 c1e8ba0c2b16
equal deleted inserted replaced
35:4ae315f230bc 39:a6539d1e8e43
    77     }
    77     }
    78     CleanupStack::Pop();
    78     CleanupStack::Pop();
    79 }
    79 }
    80 
    80 
    81 // ----------------------------------------------------------------------------
    81 // ----------------------------------------------------------------------------
       
    82 // CPcsAlgorithm1Utils::CompareByCharacter()
       
    83 // Compare by character.
       
    84 // ----------------------------------------------------------------------------
       
    85 TInt CPcsAlgorithm1Utils::CompareByCharacter( const TChar& aFirst, const TChar& aSecond )
       
    86 {
       
    87     TInt retValue;
       
    88     if ( aFirst == aSecond )
       
    89         {
       
    90         retValue = 0;
       
    91         }
       
    92     else if ( aFirst < aSecond )
       
    93         {
       
    94         retValue = -1;
       
    95         }
       
    96     else 
       
    97         {
       
    98         retValue = 1;
       
    99         }
       
   100 
       
   101     return retValue;
       
   102 }
       
   103 
       
   104 // ----------------------------------------------------------------------------
    82 // CPcsAlgorithm1Utils::CompareByLength()
   105 // CPcsAlgorithm1Utils::CompareByLength()
    83 // Compare by length.
   106 // Compare by length.
    84 // ----------------------------------------------------------------------------
   107 // ----------------------------------------------------------------------------
    85 TInt CPcsAlgorithm1Utils::CompareByLength ( const HBufC& aFirst, const HBufC& aSecond )
   108 TInt CPcsAlgorithm1Utils::CompareByLength( const HBufC& aFirst, const HBufC& aSecond )
    86 {
   109 {
    87     return ( aFirst.Length() - aSecond.Length() );
   110     return ( aFirst.Length() - aSecond.Length() );
    88 }
   111 }
    89 
   112 
    90 // ----------------------------------------------------------------------------
   113 // ----------------------------------------------------------------------------
    91 // CPcsAlgorithm1Utils::CompareExact()
   114 // CPcsAlgorithm1Utils::CompareExact()
    92 // Compare strings exactly case sensitively.
   115 // Compare strings exactly case sensitively.
    93 // ----------------------------------------------------------------------------
   116 // ----------------------------------------------------------------------------
    94 TBool CPcsAlgorithm1Utils::CompareExact ( const TDesC& aFirst, const TDesC& aSecond )
   117 TBool CPcsAlgorithm1Utils::CompareExact( const TDesC& aFirst, const TDesC& aSecond )
    95 {
   118 {
    96     return aFirst == aSecond;
   119     return aFirst == aSecond;
    97 }
   120 }
    98 
   121 
    99 // ----------------------------------------------------------------------------
   122 // ----------------------------------------------------------------------------
   100 // CPcsAlgorithm1Utils::CompareCollate()
   123 // CPcsAlgorithm1Utils::CompareCollate()
   101 // Compare strings with collate rules depending on locale.
   124 // Compare strings with collate rules depending on locale.
   102 // ----------------------------------------------------------------------------
   125 // ----------------------------------------------------------------------------
   103 TInt CPcsAlgorithm1Utils::CompareCollate ( const TDesC& aFirst, const TDesC& aSecond )
   126 TInt CPcsAlgorithm1Utils::CompareCollate( const TDesC& aFirst, const TDesC& aSecond )
   104 {
   127 {
   105     return CPcsAlgorithm1Utils::MyCompareC(aFirst, aSecond);
   128     return CPcsAlgorithm1Utils::MyCompareC(aFirst, aSecond);
   106 }
   129 }
   107 
   130 
   108 // ----------------------------------------------------------------------------
   131 // ----------------------------------------------------------------------------
   144         }
   167         }
   145     else
   168     else
   146         {
   169         {
   147         for ( TInt i = 0; i < aPsQuery.Count(); i++ )
   170         for ( TInt i = 0; i < aPsQuery.Count(); i++ )
   148             {
   171             {
   149             CPsQueryItem& currentItem = aPsQuery.GetItemAtL(i);
   172             CPsQueryItem* currentItemPtr;
   150             if ( (CPcsKeyMap::IsModePredictive(currentItem.Mode()))
   173             TRAPD ( err, currentItemPtr = &(aPsQuery.GetItemAtL(i)) );
   151                  && (aLeft[i] != aRight[i]) )
   174             if ( err != KErrNone
       
   175                  || ( CPcsKeyMap::IsModePredictive(currentItemPtr->Mode())
       
   176                     && aLeft[i] != aRight[i] ) )
   152                 {
   177                 {
   153                 comparison = EFalse;
   178                 comparison = EFalse;
   154                 break;
   179                 break;
   155                 }
   180                 }
   156             }
   181             }