19 #ifndef C_PCS_ALGORITHM_1_UTILS |
19 #ifndef C_PCS_ALGORITHM_1_UTILS |
20 #define C_PCS_ALGORITHM_1_UTILS |
20 #define C_PCS_ALGORITHM_1_UTILS |
21 |
21 |
22 // INCLUDE FILES |
22 // INCLUDE FILES |
23 |
23 |
|
24 #include <e32base.h> |
24 #include <e32hashtab.h> |
25 #include <e32hashtab.h> |
25 |
26 |
26 #include "CPsData.h" |
|
27 #include "CPsQuery.h" |
|
28 |
27 |
29 // FORWARD DECLARATION |
28 // FORWARD DECLARATION |
|
29 class CPsData; |
|
30 class CPsQuery; |
30 |
31 |
31 typedef RPointerArray<CPsData> CPSDATA_R_PTR_ARRAY; |
32 typedef RPointerArray<CPsData> CPSDATA_R_PTR_ARRAY; |
|
33 |
32 |
34 |
33 // CLASS DECLARATION |
35 // CLASS DECLARATION |
34 class CPcsAlgorithm1Utils : public CBase |
36 class CPcsAlgorithm1Utils : public CBase |
35 { |
37 { |
36 public: |
38 public: |
46 RPointerArray<CPsData>& SearchResults); |
48 RPointerArray<CPsData>& SearchResults); |
47 |
49 |
48 /** |
50 /** |
49 * Compare by length. |
51 * Compare by length. |
50 */ |
52 */ |
51 static TBool CompareByLength(const HBufC& aFirst, const HBufC& aSecond); |
53 static TInt CompareByLength(const HBufC& aFirst, const HBufC& aSecond); |
52 |
54 |
53 /** |
55 /** |
54 * Compare strings exactly case sensitively. |
56 * Compare strings exactly case sensitively. |
55 */ |
57 */ |
56 static TBool CompareExact(const TDesC& aFirst, const TDesC& aSecond); |
58 static TBool CompareExact(const TDesC& aFirst, const TDesC& aSecond); |
57 |
59 |
58 /** |
60 /** |
59 * Compare strings with collate rules depending on locale. |
61 * Compare strings with collate rules depending on locale. |
60 */ |
62 */ |
61 static TBool CompareCollate(const TDesC& aFirst, const TDesC& aSecond); |
63 static TInt CompareCollate(const TDesC& aFirst, const TDesC& aSecond); |
62 |
64 |
63 /** |
65 /** |
64 * Compare for keys and strings: |
66 * Compare for keys and strings: |
65 * - Case sensitive compare for keys, |
67 * - Case sensitive compare for keys, |
66 * - Case insensitive and language dependent compare for Contact Data and Query. |
68 * - Case insensitive and language dependent compare for Contact Data and Query. |
73 * Case Sensitive compare for keys |
75 * Case Sensitive compare for keys |
74 */ |
76 */ |
75 static TBool MyCompareK(const TDesC& aLeft, const TDesC& aRight, CPsQuery& aPsQuery); |
77 static TBool MyCompareK(const TDesC& aLeft, const TDesC& aRight, CPsQuery& aPsQuery); |
76 |
78 |
77 /** |
79 /** |
78 * Customized CompareC |
80 * Customized CompareC |
79 */ |
81 */ |
80 static TInt MyCompareC(const TDesC& aLeft, const TDesC& aRight); |
82 static TInt MyCompareC(const TDesC& aLeft, const TDesC& aRight); |
81 |
83 |
82 |
84 |
83 /** |
85 /** |
84 * TLinearOrder rule for comparison of data objects |
86 * TLinearOrder rule for comparison of data objects |
85 */ |
87 */ |
86 static TInt CompareDataBySortOrderL(const CPsData& aObject1, |
88 static TInt CompareDataBySortOrderL(const CPsData& aObject1, |
87 const CPsData& aObject2); |
89 const CPsData& aObject2); |
88 |
90 |
89 /** |
91 /** |
90 * Trim off all white spaces and special chars |
92 * Trim off all white spaces and special chars |
91 */ |
93 */ |
92 static void MyTrim(TDes& aString); |
94 static void MyTrim(TDes& aString); |
93 |
95 |
94 |
96 |
95 /** |
97 /** |
96 * Check if the input URI is of contact search in a group template form |
98 * Check if the input URI is of contact search in a group template form |
97 */ |
99 */ |
98 static TBool IsGroupUri(TDesC& aURI); |
100 static TBool IsGroupUri(TDesC& aURI); |
99 |
101 |
100 }; |
102 }; |
|
103 |
|
104 |
|
105 // CleanupStack helpers for item owning RPointerArrays |
|
106 template <class T> |
|
107 class CleanupResetAndDestroy |
|
108 { |
|
109 public: |
|
110 inline static void PushL(T& aRef) |
|
111 { CleanupStack::PushL(TCleanupItem(&ResetAndDestroy,&aRef)); } |
|
112 private: |
|
113 inline static void ResetAndDestroy(TAny *aPtr) |
|
114 { static_cast<T*>(aPtr)->ResetAndDestroy(); } |
|
115 }; |
|
116 |
|
117 template <class T> |
|
118 inline void CleanupResetAndDestroyPushL(T& aRef) |
|
119 { CleanupResetAndDestroy<T>::PushL(aRef); } |
|
120 |
101 #endif // C_PCS_ALGORITHM_1_UTILS |
121 #endif // C_PCS_ALGORITHM_1_UTILS |
102 |
122 |