os/persistentdata/persistentstorage/dbms/udbms/UD_TEXT.CPP
author sl@SLION-WIN7.fritz.box
Fri, 15 Jun 2012 03:10:57 +0200
changeset 0 bde4ae8d615e
permissions -rw-r--r--
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".
     7 //
     8 // Initial Contributors:
     9 // Nokia Corporation - initial contribution.
    10 //
    11 // Contributors:
    12 //
    13 // Description:
    14 //
    15 
    16 #include "UD_STD.H"
    17 
    18 EXPORT_C TInt TTextOps::Compare(const TDesC8& aLeft,const TDesC8& aRight) const
    19 	{
    20 	return Compare(aLeft.Ptr(),aLeft.Length(),aRight.Ptr(),aRight.Length());
    21 	}
    22 
    23 EXPORT_C TInt TTextOps::Match(const TText8* aPtr,TInt aLen,const TText8* aPatternPtr,TInt aPatternLen) const
    24 	{
    25 	return Match(TPtrC8(aPtr,aLen),TPtrC8(aPatternPtr,aPatternLen));
    26 	}
    27 
    28 EXPORT_C TInt TTextOps::Find(const TDesC8& aDes,const TDesC8& aSub) const
    29 	{
    30 	return iFind8(aDes,aSub.Ptr(),aSub.Length());
    31 	}
    32 
    33 EXPORT_C TInt TTextOps::Find(const TText8* aPtr,TInt aLen,const TText8* aSubPtr,TInt aSubLen) const
    34 	{
    35 	return iFind8(TPtrC8(aPtr,aLen),aSubPtr,aSubLen);
    36 	}
    37 
    38 EXPORT_C TInt TTextOps::Compare(const TDesC16& aLeft,const TDesC16& aRight) const
    39 	{
    40 	return Compare(aLeft.Ptr(),aLeft.Length(),aRight.Ptr(),aRight.Length());
    41 	}
    42 
    43 EXPORT_C TInt TTextOps::Match(const TText16* aPtr,TInt aLen,const TText16* aPatternPtr,TInt aPatternLen) const
    44 	{
    45 	return Match(TPtrC16(aPtr,aLen),TPtrC16(aPatternPtr,aPatternLen));
    46 	}
    47 
    48 EXPORT_C TInt TTextOps::Find(const TDesC16& aDes,const TDesC16& aSub) const
    49 	{
    50 	return iFind16(aDes,aSub.Ptr(),aSub.Length());
    51 	}
    52 
    53 EXPORT_C TInt TTextOps::Find(const TText16* aPtr,TInt aLen,const TText16* aSubPtr,TInt aSubLen) const
    54 	{
    55 	return iFind16(TPtrC16(aPtr,aLen),aSubPtr,aSubLen);
    56 	}
    57 
    58 /**
    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.
    67 */
    68 TInt TTextOps::Order(const TDesC16& aLeft, const TDesC16& aRight) const
    69 	{
    70 	return Order(aLeft.Ptr(), aLeft.Length(), aRight.Ptr(), aRight.Length());
    71 	}
    72 	
    73 LOCAL_C TUint DoFold(TUint aChar)
    74 	{
    75 	return aChar;
    76 	}
    77 
    78 LOCAL_C TInt DoMatch(const TDesC8& aDes,const TDesC8& aPattern)
    79 	{
    80 	return aDes.Match(aPattern);
    81 	}
    82 
    83 LOCAL_C TInt DoMatchF(const TDesC8& aDes,const TDesC8& aPattern)
    84 	{
    85 	return aDes.MatchF(aPattern);
    86 	}
    87 
    88 LOCAL_C TInt DoMatchC(const TDesC8& aDes,const TDesC8& aPattern)
    89 	{
    90 	return aDes.MatchC(aPattern);
    91 	}
    92 
    93 LOCAL_C TInt DoFind(const TDesC8& aDes,const TText8* aSubPtr,TInt aSubLen)
    94 	{
    95 	return aDes.Find(aSubPtr,aSubLen);
    96 	}
    97 
    98 LOCAL_C TInt DoFindF(const TDesC8& aDes,const TText8* aSubPtr,TInt aSubLen)
    99 	{
   100 	return aDes.FindF(aSubPtr,aSubLen);
   101 	}
   102 
   103 LOCAL_C TInt DoFindC(const TDesC8& aDes,const TText8* aSubPtr,TInt aSubLen)
   104 	{
   105 	return aDes.FindC(aSubPtr,aSubLen);
   106 	}
   107 
   108 LOCAL_C TInt DoMatch(const TDesC16& aDes,const TDesC16& aPattern)
   109 	{
   110 	return aDes.Match(aPattern);
   111 	}
   112 
   113 LOCAL_C TInt DoMatchF(const TDesC16& aDes,const TDesC16& aPattern)
   114 	{
   115 	return aDes.MatchF(aPattern);
   116 	}
   117 
   118 LOCAL_C TInt DoMatchC(const TDesC16& aDes,const TDesC16& aPattern)
   119 	{
   120 	return aDes.MatchC(aPattern);
   121 	}
   122 
   123 LOCAL_C TInt DoFind(const TDesC16& aDes,const TText16* aSubPtr,TInt aSubLen)
   124 	{
   125 	return aDes.Find(aSubPtr,aSubLen);
   126 	}
   127 
   128 LOCAL_C TInt DoFindF(const TDesC16& aDes,const TText16* aSubPtr,TInt aSubLen)
   129 	{
   130 	return aDes.FindF(aSubPtr,aSubLen);
   131 	}
   132 
   133 LOCAL_C TInt DoFindC(const TDesC16& aDes,const TText16* aSubPtr,TInt aSubLen)
   134 	{
   135 	return aDes.FindC(aSubPtr,aSubLen,0);
   136 	}
   137 
   138 LOCAL_C TInt DoCompareC(const TText16* aLeftPtr,TInt aLeftLen,const TText16* aRightPtr,TInt aRightLen)
   139     {
   140 	return Mem::CompareC(aLeftPtr,aLeftLen,aRightPtr,aRightLen,0,NULL);
   141 	}
   142 	
   143 /**
   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.
   154 */
   155 LOCAL_C TInt DoOrderC(const TText16* aLeftPtr, TInt aLeftLen, const TText16* aRightPtr, TInt aRightLen)
   156     {
   157 	return Mem::CompareC(aLeftPtr, aLeftLen, aRightPtr, aRightLen);
   158 	}
   159 
   160 LOCAL_D TTextOps const OpTable[3]=
   161 	{
   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
   166 	};
   167 
   168 EXPORT_C const TTextOps& TTextOps::Ops(TDbTextComparison aType)
   169 	{
   170 	return OpTable[aType];
   171 	}