First public contribution.
1 // Copyright (c) 1998-2009 Nokia Corporation and/or its subsidiary(-ies).
2 // All rights reserved.
3 // This component and the accompanying materials are made available
4 // under the terms of "Eclipse Public License v1.0"
5 // which accompanies this distribution, and is available
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
18 EXPORT_C TInt TTextOps::Compare(const TDesC8& aLeft,const TDesC8& aRight) const
20 return Compare(aLeft.Ptr(),aLeft.Length(),aRight.Ptr(),aRight.Length());
23 EXPORT_C TInt TTextOps::Match(const TText8* aPtr,TInt aLen,const TText8* aPatternPtr,TInt aPatternLen) const
25 return Match(TPtrC8(aPtr,aLen),TPtrC8(aPatternPtr,aPatternLen));
28 EXPORT_C TInt TTextOps::Find(const TDesC8& aDes,const TDesC8& aSub) const
30 return iFind8(aDes,aSub.Ptr(),aSub.Length());
33 EXPORT_C TInt TTextOps::Find(const TText8* aPtr,TInt aLen,const TText8* aSubPtr,TInt aSubLen) const
35 return iFind8(TPtrC8(aPtr,aLen),aSubPtr,aSubLen);
38 EXPORT_C TInt TTextOps::Compare(const TDesC16& aLeft,const TDesC16& aRight) const
40 return Compare(aLeft.Ptr(),aLeft.Length(),aRight.Ptr(),aRight.Length());
43 EXPORT_C TInt TTextOps::Match(const TText16* aPtr,TInt aLen,const TText16* aPatternPtr,TInt aPatternLen) const
45 return Match(TPtrC16(aPtr,aLen),TPtrC16(aPatternPtr,aPatternLen));
48 EXPORT_C TInt TTextOps::Find(const TDesC16& aDes,const TDesC16& aSub) const
50 return iFind16(aDes,aSub.Ptr(),aSub.Length());
53 EXPORT_C TInt TTextOps::Find(const TText16* aPtr,TInt aLen,const TText16* aSubPtr,TInt aSubLen) const
55 return iFind16(TPtrC16(aPtr,aLen),aSubPtr,aSubLen);
59 The method compares aLeft and aRight unicode strings.
60 Collation level 3 will be used.
61 @param aLeft Left string to compare.
62 @param aRight Right string to compare.
63 This method is used by sorting algorithms when the key field is a unciode string.
64 @return Positive. if aLeft is greater than aRight.
65 Negative. if aLeft is less than aRight.
66 Zero, if aLeft is equal to aRight.
68 TInt TTextOps::Order(const TDesC16& aLeft, const TDesC16& aRight) const
70 return Order(aLeft.Ptr(), aLeft.Length(), aRight.Ptr(), aRight.Length());
73 LOCAL_C TUint DoFold(TUint aChar)
78 LOCAL_C TInt DoMatch(const TDesC8& aDes,const TDesC8& aPattern)
80 return aDes.Match(aPattern);
83 LOCAL_C TInt DoMatchF(const TDesC8& aDes,const TDesC8& aPattern)
85 return aDes.MatchF(aPattern);
88 LOCAL_C TInt DoMatchC(const TDesC8& aDes,const TDesC8& aPattern)
90 return aDes.MatchC(aPattern);
93 LOCAL_C TInt DoFind(const TDesC8& aDes,const TText8* aSubPtr,TInt aSubLen)
95 return aDes.Find(aSubPtr,aSubLen);
98 LOCAL_C TInt DoFindF(const TDesC8& aDes,const TText8* aSubPtr,TInt aSubLen)
100 return aDes.FindF(aSubPtr,aSubLen);
103 LOCAL_C TInt DoFindC(const TDesC8& aDes,const TText8* aSubPtr,TInt aSubLen)
105 return aDes.FindC(aSubPtr,aSubLen);
108 LOCAL_C TInt DoMatch(const TDesC16& aDes,const TDesC16& aPattern)
110 return aDes.Match(aPattern);
113 LOCAL_C TInt DoMatchF(const TDesC16& aDes,const TDesC16& aPattern)
115 return aDes.MatchF(aPattern);
118 LOCAL_C TInt DoMatchC(const TDesC16& aDes,const TDesC16& aPattern)
120 return aDes.MatchC(aPattern);
123 LOCAL_C TInt DoFind(const TDesC16& aDes,const TText16* aSubPtr,TInt aSubLen)
125 return aDes.Find(aSubPtr,aSubLen);
128 LOCAL_C TInt DoFindF(const TDesC16& aDes,const TText16* aSubPtr,TInt aSubLen)
130 return aDes.FindF(aSubPtr,aSubLen);
133 LOCAL_C TInt DoFindC(const TDesC16& aDes,const TText16* aSubPtr,TInt aSubLen)
135 return aDes.FindC(aSubPtr,aSubLen,0);
138 LOCAL_C TInt DoCompareC(const TText16* aLeftPtr,TInt aLeftLen,const TText16* aRightPtr,TInt aRightLen)
140 return Mem::CompareC(aLeftPtr,aLeftLen,aRightPtr,aRightLen,0,NULL);
144 The method compares aLeftPtr and aRightPtr unicode strings.
145 Collation level 3 will be used.
146 @param aLeftPtr Left string to compare.
147 @param aLeftLen The length of left string.
148 @param aRightPtr Right string to compare.
149 @param aRightLen The length of right string.
150 This method is used by sorting algorithms when the key field is a unciode string.
151 @return Positive. if aLeftPtr is greater than aRightPtr.
152 Negative. if aLeftPtr is less than aRightPtr.
153 Zero, if aLeftPtr is equal to aRightPtr.
155 LOCAL_C TInt DoOrderC(const TText16* aLeftPtr, TInt aLeftLen, const TText16* aRightPtr, TInt aRightLen)
157 return Mem::CompareC(aLeftPtr, aLeftLen, aRightPtr, aRightLen);
160 LOCAL_D TTextOps const OpTable[3]=
162 //iFold iCompare8 iMatch8 iFind8 iCompare16 iMatch16 iFind16 iOrder16
163 {&DoFold, &Mem::Compare, &DoMatch, &DoFind, &Mem::Compare, &DoMatch, &DoFind, &Mem::Compare}, //EDbCompareNormal
164 {&User::Fold, &Mem::CompareF,&DoMatchF,&DoFindF,&Mem::CompareF,&DoMatchF,&DoFindF,&Mem::CompareF},//EDbCompareFolded
165 {&User::Collate,&Mem::CompareC,&DoMatchC,&DoFindC,&DoCompareC, &DoMatchC,&DoFindC,&DoOrderC} //EDbCompareCollated
168 EXPORT_C const TTextOps& TTextOps::Ops(TDbTextComparison aType)
170 return OpTable[aType];