os/kernelhwsrv/kernel/eka/euser/unicode/CompareImp.inl
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
     1 // Copyright (c) 2004-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 the License "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 /**
    17  @internalComponent
    18 */
    19 inline TBool IsSurrogate(TText a) 
    20 	{ 
    21 	return 0xD800 == (a & 0xF800); 
    22 	}
    23 
    24 /**
    25 @internalComponent
    26 */
    27 inline TBool IsHighSurrogate(TText a) 
    28 	{ 
    29 	return 0xD800 == (a & 0xFC00); 
    30 	}
    31 
    32 /**
    33 @internalComponent
    34 */
    35 inline TBool IsLowSurrogate(TText a) 
    36 	{ 
    37 	return 0xDC00 == (a & 0xFC00); 
    38 	}
    39 
    40 /**
    41 @internalComponent
    42 */
    43 inline TChar PairSurrogates(TText aHigh, TText aLow)
    44 	{
    45 	return ((aHigh - 0xd7f7) << 10) + aLow;
    46 	}
    47 
    48 inline void SkipCombiningCharacters(TUTF32Iterator& aUTF32It)
    49 	{
    50 	while(!aUTF32It.AtEnd() && !::IsBaseCharacter(aUTF32It.Current()))
    51 		{
    52 		aUTF32It.Next();
    53 		}
    54 	}
    55 
    56 ////////////////////////////////////////////////////////////////////////////////////////////
    57 // TUTF32Iterator
    58 ////////////////////////////////////////////////////////////////////////////////////////////
    59 
    60 /**
    61 @internalComponent
    62 */
    63 inline TUTF32Iterator::TUTF32Iterator() : 
    64 	iStart(0), 
    65 	iEnd(0) 
    66 	{
    67 	}
    68 
    69 /**
    70 @internalComponent
    71 */
    72 inline TUTF32Iterator::TUTF32Iterator(const TText16* aSingleton) : 
    73 	iStart(aSingleton), 
    74 	iEnd(aSingleton + 1), 
    75 	iCurrent(*aSingleton)
    76 	{
    77 	ASSERT((iCurrent & 0xFFFE) != 0xFFFE);
    78 	ASSERT(!::IsSurrogate(*aSingleton));
    79 	}
    80 
    81 /**
    82 @internalComponent
    83 */
    84 inline TUTF32Iterator::TUTF32Iterator(const TText16* aStart, const TText16* aEnd) : 
    85 	iEnd(aEnd)
    86 	{
    87 	SetStart(aStart);
    88 	}
    89 
    90 /**
    91 Sets the iteration to begin at aStart.
    92 @param aStart New starting point of iteration.
    93 @internalComponent
    94 */
    95 inline void TUTF32Iterator::SetStart(const TText16* aStart)
    96 	{
    97 	iStart = aStart;
    98 	if(iStart != iEnd)
    99 		{
   100 		if(::IsSurrogate(iEnd[-1]))
   101 			{
   102 			--iEnd;
   103 			if(iStart == iEnd)
   104 				{
   105 				return;
   106 				}
   107 			}
   108 		iCurrent = ::UTF16ToChar(iStart);
   109 		if(iCurrent == 0xFFFF)
   110 			{
   111 			Next();
   112 			}
   113 		}
   114 	}
   115 
   116 /**
   117 @internalComponent
   118 */
   119 inline TUTF32Iterator::TUTF32Iterator(const TText16* aStart, const TText16* aEnd, TStartsWithValidCharacter) : 
   120 	iStart(aStart), 
   121 	iEnd(aEnd)
   122 	{
   123 	ASSERT(iStart < iEnd);
   124 	if(::IsSurrogate(iEnd[-1]))
   125 		{
   126 		--iEnd;
   127 		}
   128 	iCurrent = ::UTF16ToChar(iStart);
   129 	ASSERT(iCurrent != 0xFFFF);
   130 	}
   131 
   132 /**
   133 @internalComponent
   134 */
   135 inline TUTF32Iterator TUTF32Iterator::CurrentAsIterator() const
   136 	{
   137 	TUTF32Iterator retval(*this);
   138 	ASSERT(iStart != iEnd);
   139 	retval.iEnd = iStart + 1;
   140 	return retval;
   141 	}
   142 
   143 /**
   144 @internalComponent
   145 */
   146 inline TBool TUTF32Iterator::AtEnd() const
   147 	{
   148 	return iEnd == iStart;
   149 	}
   150 
   151 /**
   152 @internalComponent
   153 */
   154 inline TChar TUTF32Iterator::Current() const
   155 	{
   156 	ASSERT(iStart != iEnd);
   157 	ASSERT(iCurrent != 0xFFFF);
   158 	return iCurrent;
   159 	}
   160 
   161 /**
   162 @internalComponent
   163 */
   164 inline const TText16* TUTF32Iterator::CurrentPosition() const
   165 	{
   166 	return iStart;
   167 	}
   168 
   169 /**
   170 @internalComponent
   171 */
   172 inline TInt TUTF32Iterator::Length() const
   173 	{
   174 	return iEnd - iStart;
   175 	}
   176 
   177 /**
   178 @internalComponent
   179 */
   180 inline TInt TUTF32Iterator::operator[](TInt a) const
   181 	{
   182 	return iStart[a];
   183 	}
   184 
   185 ////////////////////////////////////////////////////////////////////////////////////////////
   186 // TFoldedDecompIterator
   187 ////////////////////////////////////////////////////////////////////////////////////////////
   188 
   189 /**
   190 @internalComponent
   191 */
   192 inline TFoldedDecompIterator::TFoldedDecompIterator() 
   193 	{
   194 	}
   195 
   196 /**
   197 @internalComponent
   198 */
   199 inline TUTF32Iterator TFoldedDecompIterator::BaseIterator() const 
   200 	{ 
   201 	return iOriginal; 
   202 	}
   203 
   204 /**
   205 @internalComponent
   206 */
   207 inline void TFoldedDecompIterator::Set(const TUTF32Iterator& a)
   208 	{
   209 	iOriginal = a;
   210 	}
   211 
   212 /**
   213 @internalComponent
   214 */
   215 inline TBool TFoldedDecompIterator::IsInFoldedSequence() const
   216 	{
   217 	return !iFolded.AtEnd();
   218 	}
   219 
   220 ////////////////////////////////////////////////////////////////////////////////////////////
   221 // TFoldedSortedDecompIterator
   222 ////////////////////////////////////////////////////////////////////////////////////////////
   223 
   224 /**
   225 @internalComponent
   226 */
   227 inline TFoldedSortedDecompIterator::TFoldedSortedDecompIterator() 
   228 	{
   229 	}
   230 
   231 ////////////////////////////////////////////////////////////////////////////////////////////
   232 // TDecompositionIterator
   233 ////////////////////////////////////////////////////////////////////////////////////////////
   234 
   235 /**
   236 @internalComponent
   237 */
   238 inline TDecompositionIterator::TDecompositionIterator() 
   239 	{
   240 	}
   241 
   242 ////////////////////////////////////////////////////////////////////////////////////////////
   243 // TCanonicalDecompositionIterator
   244 ////////////////////////////////////////////////////////////////////////////////////////////
   245 
   246 /**
   247 @internalComponent
   248 */
   249 inline TCanonicalDecompositionIterator::TCanonicalDecompositionIterator() 
   250 	{
   251 	}
   252