sl@0: // Copyright (c) 1998-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: // All rights reserved. sl@0: // This component and the accompanying materials are made available sl@0: // under the terms of "Eclipse Public License v1.0" sl@0: // which accompanies this distribution, and is available sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: // sl@0: // Initial Contributors: sl@0: // Nokia Corporation - initial contribution. sl@0: // sl@0: // Contributors: sl@0: // sl@0: // Description: sl@0: // sl@0: sl@0: #include "UD_STD.H" sl@0: sl@0: EXPORT_C TInt TTextOps::Compare(const TDesC8& aLeft,const TDesC8& aRight) const sl@0: { sl@0: return Compare(aLeft.Ptr(),aLeft.Length(),aRight.Ptr(),aRight.Length()); sl@0: } sl@0: sl@0: EXPORT_C TInt TTextOps::Match(const TText8* aPtr,TInt aLen,const TText8* aPatternPtr,TInt aPatternLen) const sl@0: { sl@0: return Match(TPtrC8(aPtr,aLen),TPtrC8(aPatternPtr,aPatternLen)); sl@0: } sl@0: sl@0: EXPORT_C TInt TTextOps::Find(const TDesC8& aDes,const TDesC8& aSub) const sl@0: { sl@0: return iFind8(aDes,aSub.Ptr(),aSub.Length()); sl@0: } sl@0: sl@0: EXPORT_C TInt TTextOps::Find(const TText8* aPtr,TInt aLen,const TText8* aSubPtr,TInt aSubLen) const sl@0: { sl@0: return iFind8(TPtrC8(aPtr,aLen),aSubPtr,aSubLen); sl@0: } sl@0: sl@0: EXPORT_C TInt TTextOps::Compare(const TDesC16& aLeft,const TDesC16& aRight) const sl@0: { sl@0: return Compare(aLeft.Ptr(),aLeft.Length(),aRight.Ptr(),aRight.Length()); sl@0: } sl@0: sl@0: EXPORT_C TInt TTextOps::Match(const TText16* aPtr,TInt aLen,const TText16* aPatternPtr,TInt aPatternLen) const sl@0: { sl@0: return Match(TPtrC16(aPtr,aLen),TPtrC16(aPatternPtr,aPatternLen)); sl@0: } sl@0: sl@0: EXPORT_C TInt TTextOps::Find(const TDesC16& aDes,const TDesC16& aSub) const sl@0: { sl@0: return iFind16(aDes,aSub.Ptr(),aSub.Length()); sl@0: } sl@0: sl@0: EXPORT_C TInt TTextOps::Find(const TText16* aPtr,TInt aLen,const TText16* aSubPtr,TInt aSubLen) const sl@0: { sl@0: return iFind16(TPtrC16(aPtr,aLen),aSubPtr,aSubLen); sl@0: } sl@0: sl@0: /** sl@0: The method compares aLeft and aRight unicode strings. sl@0: Collation level 3 will be used. sl@0: @param aLeft Left string to compare. sl@0: @param aRight Right string to compare. sl@0: This method is used by sorting algorithms when the key field is a unciode string. sl@0: @return Positive. if aLeft is greater than aRight. sl@0: Negative. if aLeft is less than aRight. sl@0: Zero, if aLeft is equal to aRight. sl@0: */ sl@0: TInt TTextOps::Order(const TDesC16& aLeft, const TDesC16& aRight) const sl@0: { sl@0: return Order(aLeft.Ptr(), aLeft.Length(), aRight.Ptr(), aRight.Length()); sl@0: } sl@0: sl@0: LOCAL_C TUint DoFold(TUint aChar) sl@0: { sl@0: return aChar; sl@0: } sl@0: sl@0: LOCAL_C TInt DoMatch(const TDesC8& aDes,const TDesC8& aPattern) sl@0: { sl@0: return aDes.Match(aPattern); sl@0: } sl@0: sl@0: LOCAL_C TInt DoMatchF(const TDesC8& aDes,const TDesC8& aPattern) sl@0: { sl@0: return aDes.MatchF(aPattern); sl@0: } sl@0: sl@0: LOCAL_C TInt DoMatchC(const TDesC8& aDes,const TDesC8& aPattern) sl@0: { sl@0: return aDes.MatchC(aPattern); sl@0: } sl@0: sl@0: LOCAL_C TInt DoFind(const TDesC8& aDes,const TText8* aSubPtr,TInt aSubLen) sl@0: { sl@0: return aDes.Find(aSubPtr,aSubLen); sl@0: } sl@0: sl@0: LOCAL_C TInt DoFindF(const TDesC8& aDes,const TText8* aSubPtr,TInt aSubLen) sl@0: { sl@0: return aDes.FindF(aSubPtr,aSubLen); sl@0: } sl@0: sl@0: LOCAL_C TInt DoFindC(const TDesC8& aDes,const TText8* aSubPtr,TInt aSubLen) sl@0: { sl@0: return aDes.FindC(aSubPtr,aSubLen); sl@0: } sl@0: sl@0: LOCAL_C TInt DoMatch(const TDesC16& aDes,const TDesC16& aPattern) sl@0: { sl@0: return aDes.Match(aPattern); sl@0: } sl@0: sl@0: LOCAL_C TInt DoMatchF(const TDesC16& aDes,const TDesC16& aPattern) sl@0: { sl@0: return aDes.MatchF(aPattern); sl@0: } sl@0: sl@0: LOCAL_C TInt DoMatchC(const TDesC16& aDes,const TDesC16& aPattern) sl@0: { sl@0: return aDes.MatchC(aPattern); sl@0: } sl@0: sl@0: LOCAL_C TInt DoFind(const TDesC16& aDes,const TText16* aSubPtr,TInt aSubLen) sl@0: { sl@0: return aDes.Find(aSubPtr,aSubLen); sl@0: } sl@0: sl@0: LOCAL_C TInt DoFindF(const TDesC16& aDes,const TText16* aSubPtr,TInt aSubLen) sl@0: { sl@0: return aDes.FindF(aSubPtr,aSubLen); sl@0: } sl@0: sl@0: LOCAL_C TInt DoFindC(const TDesC16& aDes,const TText16* aSubPtr,TInt aSubLen) sl@0: { sl@0: return aDes.FindC(aSubPtr,aSubLen,0); sl@0: } sl@0: sl@0: LOCAL_C TInt DoCompareC(const TText16* aLeftPtr,TInt aLeftLen,const TText16* aRightPtr,TInt aRightLen) sl@0: { sl@0: return Mem::CompareC(aLeftPtr,aLeftLen,aRightPtr,aRightLen,0,NULL); sl@0: } sl@0: sl@0: /** sl@0: The method compares aLeftPtr and aRightPtr unicode strings. sl@0: Collation level 3 will be used. sl@0: @param aLeftPtr Left string to compare. sl@0: @param aLeftLen The length of left string. sl@0: @param aRightPtr Right string to compare. sl@0: @param aRightLen The length of right string. sl@0: This method is used by sorting algorithms when the key field is a unciode string. sl@0: @return Positive. if aLeftPtr is greater than aRightPtr. sl@0: Negative. if aLeftPtr is less than aRightPtr. sl@0: Zero, if aLeftPtr is equal to aRightPtr. sl@0: */ sl@0: LOCAL_C TInt DoOrderC(const TText16* aLeftPtr, TInt aLeftLen, const TText16* aRightPtr, TInt aRightLen) sl@0: { sl@0: return Mem::CompareC(aLeftPtr, aLeftLen, aRightPtr, aRightLen); sl@0: } sl@0: sl@0: LOCAL_D TTextOps const OpTable[3]= sl@0: { sl@0: //iFold iCompare8 iMatch8 iFind8 iCompare16 iMatch16 iFind16 iOrder16 sl@0: {&DoFold, &Mem::Compare, &DoMatch, &DoFind, &Mem::Compare, &DoMatch, &DoFind, &Mem::Compare}, //EDbCompareNormal sl@0: {&User::Fold, &Mem::CompareF,&DoMatchF,&DoFindF,&Mem::CompareF,&DoMatchF,&DoFindF,&Mem::CompareF},//EDbCompareFolded sl@0: {&User::Collate,&Mem::CompareC,&DoMatchC,&DoFindC,&DoCompareC, &DoMatchC,&DoFindC,&DoOrderC} //EDbCompareCollated sl@0: }; sl@0: sl@0: EXPORT_C const TTextOps& TTextOps::Ops(TDbTextComparison aType) sl@0: { sl@0: return OpTable[aType]; sl@0: }