1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/kernelhwsrv/kernel/eka/euser/unicode/CompareImp.inl Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,252 @@
1.4 +// Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies).
1.5 +// All rights reserved.
1.6 +// This component and the accompanying materials are made available
1.7 +// under the terms of the License "Eclipse Public License v1.0"
1.8 +// which accompanies this distribution, and is available
1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
1.10 +//
1.11 +// Initial Contributors:
1.12 +// Nokia Corporation - initial contribution.
1.13 +//
1.14 +// Contributors:
1.15 +//
1.16 +// Description:
1.17 +//
1.18 +
1.19 +/**
1.20 + @internalComponent
1.21 +*/
1.22 +inline TBool IsSurrogate(TText a)
1.23 + {
1.24 + return 0xD800 == (a & 0xF800);
1.25 + }
1.26 +
1.27 +/**
1.28 +@internalComponent
1.29 +*/
1.30 +inline TBool IsHighSurrogate(TText a)
1.31 + {
1.32 + return 0xD800 == (a & 0xFC00);
1.33 + }
1.34 +
1.35 +/**
1.36 +@internalComponent
1.37 +*/
1.38 +inline TBool IsLowSurrogate(TText a)
1.39 + {
1.40 + return 0xDC00 == (a & 0xFC00);
1.41 + }
1.42 +
1.43 +/**
1.44 +@internalComponent
1.45 +*/
1.46 +inline TChar PairSurrogates(TText aHigh, TText aLow)
1.47 + {
1.48 + return ((aHigh - 0xd7f7) << 10) + aLow;
1.49 + }
1.50 +
1.51 +inline void SkipCombiningCharacters(TUTF32Iterator& aUTF32It)
1.52 + {
1.53 + while(!aUTF32It.AtEnd() && !::IsBaseCharacter(aUTF32It.Current()))
1.54 + {
1.55 + aUTF32It.Next();
1.56 + }
1.57 + }
1.58 +
1.59 +////////////////////////////////////////////////////////////////////////////////////////////
1.60 +// TUTF32Iterator
1.61 +////////////////////////////////////////////////////////////////////////////////////////////
1.62 +
1.63 +/**
1.64 +@internalComponent
1.65 +*/
1.66 +inline TUTF32Iterator::TUTF32Iterator() :
1.67 + iStart(0),
1.68 + iEnd(0)
1.69 + {
1.70 + }
1.71 +
1.72 +/**
1.73 +@internalComponent
1.74 +*/
1.75 +inline TUTF32Iterator::TUTF32Iterator(const TText16* aSingleton) :
1.76 + iStart(aSingleton),
1.77 + iEnd(aSingleton + 1),
1.78 + iCurrent(*aSingleton)
1.79 + {
1.80 + ASSERT((iCurrent & 0xFFFE) != 0xFFFE);
1.81 + ASSERT(!::IsSurrogate(*aSingleton));
1.82 + }
1.83 +
1.84 +/**
1.85 +@internalComponent
1.86 +*/
1.87 +inline TUTF32Iterator::TUTF32Iterator(const TText16* aStart, const TText16* aEnd) :
1.88 + iEnd(aEnd)
1.89 + {
1.90 + SetStart(aStart);
1.91 + }
1.92 +
1.93 +/**
1.94 +Sets the iteration to begin at aStart.
1.95 +@param aStart New starting point of iteration.
1.96 +@internalComponent
1.97 +*/
1.98 +inline void TUTF32Iterator::SetStart(const TText16* aStart)
1.99 + {
1.100 + iStart = aStart;
1.101 + if(iStart != iEnd)
1.102 + {
1.103 + if(::IsSurrogate(iEnd[-1]))
1.104 + {
1.105 + --iEnd;
1.106 + if(iStart == iEnd)
1.107 + {
1.108 + return;
1.109 + }
1.110 + }
1.111 + iCurrent = ::UTF16ToChar(iStart);
1.112 + if(iCurrent == 0xFFFF)
1.113 + {
1.114 + Next();
1.115 + }
1.116 + }
1.117 + }
1.118 +
1.119 +/**
1.120 +@internalComponent
1.121 +*/
1.122 +inline TUTF32Iterator::TUTF32Iterator(const TText16* aStart, const TText16* aEnd, TStartsWithValidCharacter) :
1.123 + iStart(aStart),
1.124 + iEnd(aEnd)
1.125 + {
1.126 + ASSERT(iStart < iEnd);
1.127 + if(::IsSurrogate(iEnd[-1]))
1.128 + {
1.129 + --iEnd;
1.130 + }
1.131 + iCurrent = ::UTF16ToChar(iStart);
1.132 + ASSERT(iCurrent != 0xFFFF);
1.133 + }
1.134 +
1.135 +/**
1.136 +@internalComponent
1.137 +*/
1.138 +inline TUTF32Iterator TUTF32Iterator::CurrentAsIterator() const
1.139 + {
1.140 + TUTF32Iterator retval(*this);
1.141 + ASSERT(iStart != iEnd);
1.142 + retval.iEnd = iStart + 1;
1.143 + return retval;
1.144 + }
1.145 +
1.146 +/**
1.147 +@internalComponent
1.148 +*/
1.149 +inline TBool TUTF32Iterator::AtEnd() const
1.150 + {
1.151 + return iEnd == iStart;
1.152 + }
1.153 +
1.154 +/**
1.155 +@internalComponent
1.156 +*/
1.157 +inline TChar TUTF32Iterator::Current() const
1.158 + {
1.159 + ASSERT(iStart != iEnd);
1.160 + ASSERT(iCurrent != 0xFFFF);
1.161 + return iCurrent;
1.162 + }
1.163 +
1.164 +/**
1.165 +@internalComponent
1.166 +*/
1.167 +inline const TText16* TUTF32Iterator::CurrentPosition() const
1.168 + {
1.169 + return iStart;
1.170 + }
1.171 +
1.172 +/**
1.173 +@internalComponent
1.174 +*/
1.175 +inline TInt TUTF32Iterator::Length() const
1.176 + {
1.177 + return iEnd - iStart;
1.178 + }
1.179 +
1.180 +/**
1.181 +@internalComponent
1.182 +*/
1.183 +inline TInt TUTF32Iterator::operator[](TInt a) const
1.184 + {
1.185 + return iStart[a];
1.186 + }
1.187 +
1.188 +////////////////////////////////////////////////////////////////////////////////////////////
1.189 +// TFoldedDecompIterator
1.190 +////////////////////////////////////////////////////////////////////////////////////////////
1.191 +
1.192 +/**
1.193 +@internalComponent
1.194 +*/
1.195 +inline TFoldedDecompIterator::TFoldedDecompIterator()
1.196 + {
1.197 + }
1.198 +
1.199 +/**
1.200 +@internalComponent
1.201 +*/
1.202 +inline TUTF32Iterator TFoldedDecompIterator::BaseIterator() const
1.203 + {
1.204 + return iOriginal;
1.205 + }
1.206 +
1.207 +/**
1.208 +@internalComponent
1.209 +*/
1.210 +inline void TFoldedDecompIterator::Set(const TUTF32Iterator& a)
1.211 + {
1.212 + iOriginal = a;
1.213 + }
1.214 +
1.215 +/**
1.216 +@internalComponent
1.217 +*/
1.218 +inline TBool TFoldedDecompIterator::IsInFoldedSequence() const
1.219 + {
1.220 + return !iFolded.AtEnd();
1.221 + }
1.222 +
1.223 +////////////////////////////////////////////////////////////////////////////////////////////
1.224 +// TFoldedSortedDecompIterator
1.225 +////////////////////////////////////////////////////////////////////////////////////////////
1.226 +
1.227 +/**
1.228 +@internalComponent
1.229 +*/
1.230 +inline TFoldedSortedDecompIterator::TFoldedSortedDecompIterator()
1.231 + {
1.232 + }
1.233 +
1.234 +////////////////////////////////////////////////////////////////////////////////////////////
1.235 +// TDecompositionIterator
1.236 +////////////////////////////////////////////////////////////////////////////////////////////
1.237 +
1.238 +/**
1.239 +@internalComponent
1.240 +*/
1.241 +inline TDecompositionIterator::TDecompositionIterator()
1.242 + {
1.243 + }
1.244 +
1.245 +////////////////////////////////////////////////////////////////////////////////////////////
1.246 +// TCanonicalDecompositionIterator
1.247 +////////////////////////////////////////////////////////////////////////////////////////////
1.248 +
1.249 +/**
1.250 +@internalComponent
1.251 +*/
1.252 +inline TCanonicalDecompositionIterator::TCanonicalDecompositionIterator()
1.253 + {
1.254 + }
1.255 +